Download presentation
Presentation is loading. Please wait.
1
snick snack A Working Computer Slides based on work by Bob Woodham and others
2
Learning Goals: In-Class By the end of this unit, mostly from the lab, you should be able to: –Trace execution of an instruction through our computer, in particular: Follow the basic fetch-decode-execute instruction cycle. Given appropriate documentation, a particular instruction, and a part of the computer to focus on, explain how that part executes its function on the instruction all the way down to wires and gates. 2
3
Where We Are in The Big Stories Theory How do we model computational systems? Now: Not really a theory show… Hardware How do we build devices to compute? Now: Done! A full working computer! 3
4
Computer Strategy Instead of a new DFA circuit for each problem: 1.Make a DFA with “instructions” as input. 2.Design a set of instructions that combine to solve many problems 3.Solve new tasks with new arrangements of instructions, not a new circuit. With appropriate instructions, this design is “universal”: it can perform any conceivable computation. (We won’t prove this, but we will see it implement basic Java/Racket instructions!)
5
A “Normal” DFA as a Sequential Circuit DFA with a bunch of states and with output on arcs Sequence of inputs Sequence of outputs clk
6
Ultra-High-Level CPU View: Fetch, Decode, Execute Cycle, as DFA DFA with LOTS of states and output on arcs Sequence of outputs clk A stored-program computer includes data and code in its memory. Load memory with code/data and start the machine, and it “acts out” its program. Load new code/data, and restart, and it “acts out” a totally different program! A stored-program computer can simulate any other computer that we can now practically or theoretically envision!
7
Ultra-High-Level CPU View: Fetch, Decode, Execute Cycle FetchDecodeExecute next instruction from memory “dissect” instruction into relevant pieces; route information from one part of the computer to another perform computations determine next instruction’s address
8
CPSC 121’s “circuits story” From the bottom up... we can build digital logic in physical devices (remember the water computers and switches?) we can use logic gates to organize our digital circuits we can organize logic gates into combinational circuits that calculate any logical function of their inputs (any truth table) we can use feedback to create sequential circuits that remember values and act on events we can implement any DFA using a sequential circuit we can build a working computer: a DFA with configurable memory that determines its own next instruction, which can perform any conceivable computation Wow! Too bad it’s a pain in the butt to program in our computer’s language! If only...
9
CPSC 110/111’s “programming story” From the top down: we can design algorithms to solve an enormous variety of computational problems we can encode those algorithms into programs in high-level programming languages compilers and interpreters can automatically transform those programs into low-level programming languages Any guesses what those low-level programming languages might look like? Here’s one we already saw...
10
Java Byte Code Part of our Java code: // Let's do something a hundred times. int i = 100; do { // Make i one smaller. i--; } while (i > 0); Here’s a typical “hex” view of ~1/5 th of the program’s byte code. 10
11
CPSC 110/111’s + 121’s Story... High-level languages all the way down to physical devices that compute. What’s left? HUGE TREMENDOUS AMAZING AMOUNTS OF STUFF: Software engineering: implementing incredibly complex systems as programs and helping programmers manage that complexity. Human-computer interaction: understanding how people work with computers and designing interfaces that are effective for them. Systems: building structures on top of the machine that knit computers together and let people and programs communicate and collaborate effectively. Artificial intelligence: recognizing, extracting, and acting on high-level patterns in complex and meaningful ways. Theory: analyzing the capabilities and limitations of computing systems to accomplish all of these tasks. Computer engineering: redesigning the machine to more efficiently (in terms of speed, power consumption, size, memory usage, etc.) execute programs. (And so on...)
12
A Sample Program (Racket) ;; Consumes a number n and ;; returns the sum of i from i=0 to n. (define (sum-to-n n) (cond [(= n 0) 0] [else (+ n (sum-to-n (- n 1)))])) ;; Consumes a number n and ;; returns the sum of i from i=0 to n. ;; "Tail recursive"; meaning the equivalent of a Java loop. (define (sum-to-n2 n result-so-far) (cond [(= n 0) result-so-far] [else (sum-to-n2 (- n 1) (+ n result-so-far))]))
13
A Sample Program (Java) /* Calculate the sum from 1 to n. * @param n A non-negative number (limit of sum) * @return the sum of i from i=1 to n */ public static int sumToN(int n) { int result = 0; while (n > 0) { result += n; n--; } return result; }
14
Learning Goals: In-Class By the end of this unit, mostly from the lab, you should be able to: –Trace execution of an instruction through our computer, in particular: Follow the basic fetch-decode-execute instruction cycle. Given appropriate documentation, a particular instruction, and a part of the computer to focus on, explain how that part executes its function on the instruction all the way down to wires and gates. 14
15
snick snack Extra Slides
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.