140 likes | 264 Views
Extending the Spreadsheet to Illustrate Basic CPU Operations in a Computer Literacy Course. Richard E. Smith, Ph.D. Department of Quantitative Methods and Computer Science University of St. Thomas .
E N D
Extending the Spreadsheet to Illustrate Basic CPU Operations in a Computer Literacy Course Richard E. Smith, Ph.D.Department of Quantitative Methods and Computer ScienceUniversity of St. Thomas This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/2.0/ R. Smith - University of St Thomas - Minnesota
The Problem • How do we teach non-experts about the internals of the computer’s central processing unit (CPU)? • Option: Don’t bother • Option: Use a software simulation program • Option: use the Excel-based Simple CPU R. Smith - University of St Thomas - Minnesota
The Simple CPU Display R. Smith - University of St Thomas - Minnesota
Operating Features • RAM appears in Column A on the left • One-address instruction set • Some instructions refer to a single memory location • Calculations use a single “accumulator” register • Each instruction requires two cycles • Fetch cycle – get the instruction that’s to be executed • Execute cycle – perform the calculation or other action • This cycle may fetch or store data in RAM • Very Simple Instruction set • Three instructions refer to memory locations: Add, Store, Jump • Based on the TX-0 computer built in the 1950s R. Smith - University of St Thomas - Minnesota
Not your grandfather’s laptop. “Transistor Experiment” computer, version 0 Built in 1955-56 by MIT’s Lincoln Laboratory Absurdly simple instruction set Focus on testing the transistorized computer circuits Easier to build, easier to test, easier to fix The TX-0 R. Smith - University of St Thomas - Minnesota
In “Assembly Language” (text) format: Clear Add 5 Store 5 Jump 2 1 (data) In “Machine Language” (numeric) format: 2 105 205 302 1 A “Simple CPU” program R. Smith - University of St Thomas - Minnesota
Concepts to Convey • A program as a sequence of instructions • Instructions in a highly coded form • Processor cycles • CPU is separate from its RAM R. Smith - University of St Thomas - Minnesota
Use in Class • Demonstrate on a projection display. • Explain the notion of the processor cycle. • Demonstrate a simple program. • Explain how to translate simple add-and-subtract calculations into the right sequence of add-invert-add, etc. • Assignment to write their own programs in numeric form. R. Smith - University of St Thomas - Minnesota
Final Points • Integration into the spreadsheet • Relies on concepts the students learned in Excel training • Seems like a follow-on to Excel, not a major topic change • Easy to modify and extend for other classes, like computer architecture • Simulator conveys concepts more effectively • Pre-simulator training relied on rote learning of concepts with discussion but no hands-on work or live demonstrations • Simulator lets students demonstrate an understanding of machine level instructions by doing homework assignments • Success on CPU-oriented exam questions went from (estimate) 1 out of 3 to 7 out of 8. R. Smith - University of St Thomas - Minnesota
Thank You! Questions? • My contact information: • Dr. Rick Smith • University of St. Thomas • resmith@stthomas.edu • Getting the SimpleCPU Simulator: • Go to Google • Search for “smith simple cpu demo” http://www.cs.stthomas.edu/faculty/resmith /c/qmcs110/m/cpudemo1.html R. Smith - University of St Thomas - Minnesota
The Simple CPU Display R. Smith - University of St Thomas - Minnesota
Future Work • Extensions to simplify programming • Add conditional jumps • Add an index register • Make easier to modify and maintain • Rearrange calculations to minimize reliance on memorized cell identities • Move critical functions into VBasic modules to improve readability • Try using to teach computer architecture • Extension to multiple cycles, multiple address modes • Modifications by students to prototype their own processors, instruction sets R. Smith - University of St Thomas - Minnesota
Executing a Program • First, reset the CPU • Program address (PC) starts at 1 • AC register starts at 0 • Next, perform the Fetch cycle • Calculate new values for the AC, PC, and IR in locations E3-E5, based on the contents of D5-E5 and data fetched from memory • At the end of the cycle, copy the new values of the AC, PC, and IR from cells E3-E5 to D3-D5. • Finally, perform the Execute cycle • Use the IR, Instruction, and Address cells (D5, D10, D11) to identify and execute the instruction • At the end of the cycle, copy the new values of the AC, PC, and IR from cells E3-E5 to D3-D5. • If storing a result in memory, do that, too. • Start next instruction at the Fetch Cycle above R. Smith - University of St Thomas - Minnesota
Calculates the contents of the AC at the end of the Execute cycle (D4): =IF(D2,D3, IF(D10=1,D3+D9, IF(D5=1,-D3, IF(D5=2,0, D3)))) If it’s the Fetch cycle (D2 is TRUE), leave the AC (D3) unchanged. Else if it’s an ADD instruction (D10=1) Add the data from memory to the AC Else if it’s a Negate instruction (D5=1) Negate the data in the AC Else if it a Clear instruction (D5=2) Clear the data in the AC Example: part of the ADD calculation R. Smith - University of St Thomas - Minnesota