How to make a chip programmable? What is programmability? The ability to "reconfigure" digital blocks to perform different functions (easily). What is a "program"? A kind of "specification" (declarative) and a kind of "step-by-step" (imperative) recipe to do something. What "represent" a program? Diagram (flow-chart, state diagram), pattern (bits), and mostly language (script). It has to be "concise" and most importantly "human readable" because engineers must be able to read and write it. (It may not be easy to read though). Examples of programs bit patterns higher level (event by signal names) We will explore "language" from bottom-up (hardware to software) Programmable computers data path control logic simple processor how the "funtional units" are used repeatedly to satisfy "a work". how to "specify" this behaviour? and it becomes a language. (assembly language) The heart is the control logic (or control unit) hardwired softwired how to softwired? Maurice Wilkes invented it around 1970. Microprogram Vs. Assembly Now we look at "high level" assembly to high level language Compiler technology language design language "implementation" Implementation means how to execute the language on a particular "platform" (or processors). "platform" is more like a virtual machine. Example of high to asm a = b + c if a, b, c are local variables, they can be mapped to registers, then, add a b c if a is global then some additional step is needed, add r1 b c st r1 a_global (a slot in the memory) control flow convert "flow" into "jump" (because assembly program is "linearly" code). if cond then true-act else false-act jump-if-false @else jump @exit else: exit: abstraction function call, passing parameters, recursive function. a compiler organisation input: source program (text file) output: assembly program (text or object code) lexical analyser (change source to tokens) parser (change tokens to parse-tree) code generator (change parse-tree to output) optimiser (improve output, faster, or smaller) lexical analyser (recogniser, automaton or FSM) parser (grammar and parser generator) code generator (mostly a kind of "interpreter") optimiser (hand made) Can a chip be programmed differently? YES data-flow meta-interpreter (cricket, lego-brick, scratch) macro-recorder (excell) (grid-based) etc. Demo how to program at low level (stupid simple assembly) (calculator programming) assembly language (gentle intro) mix high-low microprogramming examples how to generate a scanner from dictionary how to generate a parser from grammar End