CPU simulation: Difference between revisions

From Computer Science Wiki
(Created page with "right|frame|This a problem set for you to work through <ref>http://www.flaticon.com/</ref> This is a problem set. Some of these are easy, others are far m...")
 
 
(10 intermediate revisions by the same user not shown)
Line 5: Line 5:
# to build your skill applying computational thinking to a problem
# to build your skill applying computational thinking to a problem
# to assess your knowledge and skills of different programming practices
# to assess your knowledge and skills of different programming practices
 
# to asses your depth of knowledge for the parts of a CPU, and how those parts work together.


== What is this problem set trying to do ==
== What is this problem set trying to do ==


This is example problem set. In this example we are learning about [[lists]], [[conditionals]],  and processing user input.
You must demonstrate your understanding of the function and architecture of a CPU by creating a simulation of the CPU. Please [http://tools.withcode.uk/cpu/ look at this for an example] of ABOUT what I'm looking for. Please also visit our page on [[Computer organization]]. Please read this problem set very carefully. You do NOT need to build a graphical user interface!!


== The Problem ==
== The Problem ==


At a prestigious international school, we have only 5 administrators, Michael, Carol, Jen, Constance and TJ. Your program should ask the user to type in their name. If their name matches one of our administrators, your program must output a special greeting. If the user input is any other name (does not match the list of administrators) your program should simply output a simple greeting.
Construct a simulation of a CPU. Your simulation must model and simulate:  
 
There is no testing for user input. That is, if a user enters a number, an integer, or nothing, your program should not evaluate the input.
 
== Unit Tests ==
 
* '''User Input:''' Name: Bill
* '''Expected output:''' Hello Bill


* '''User Input:''' Name: TJ
# a data structure representing the ALU - The arithmetic logic unit executes all calculations within the CPU
* '''Expected output:''' An administrator! Hello TJ
# a data structure representing the CU - control unit, coordinates how data moves around
# a data structure representing the PC - program counter - stores address of the -> next <- instruction in RAM
* '''User Input:''' Name: 123
# a data structure representing the MAR - memory address register - stores the address of the current instruction being executed
* '''Expected output:''' Hello 123
# a data structure representing the MDR - memory data register - stores the data that is to be sent to or fetched from memory
# a data structure representing the CIR - current instruction register - stores actual instruction that is being decoded and executed
# a data structure representing the ACC - accumulator - stores result of calculations
# a data structure representing the address bus - carries the ADDRESS of the instruction or data
# a data structure representing the data bus - carries data between processor and the memory
# a data structure representing the control bus - sends control signals such as: memory read, memory write
# a data structure representing primary memory. You need to represent address and data/instruction space
# a clear representation and visible functioning of the machine instruction cycle
# you should represent clock cycles
# you should represent a simple set of instructions being fully executed (fetched, execute store)


== Hacker edition ==
Your solution must explain how a CPU functions. Everything must be explicit and clear. Please reference this IB standard for this problem set: Explain the machine instruction cycle.


In the hacker version:
* Please carefully read and understand [[Computer modeling|this article on computer modelling]]
 
* Please carefully read and understand [[Model and a simulation|this article on modelling and simulation]].
* Your program should test for valid user input. The user input should be only allow for strings
 
THIS PART ISNT DONE YET


== How you will be assessed ==
== How you will be assessed ==


Your solution will be graded using the following axis:  
Your solution will be graded using the following axis:  


'''Scope'''
'''Scope'''
Line 47: Line 45:
'''Correctness'''
'''Correctness'''
* To what extent did your code meet specifications?
* To what extent did your code meet specifications?
* To what extent did your code meet unit tests?
* To what extent is your code free of bugs?
* To what extent is your code free of bugs?


Line 59: Line 56:
* To what extent is your code commented?
* To what extent is your code commented?
* To what extent are your variables well named?
* To what extent are your variables well named?
* To what extent do you adhere to style guide?


== References ==
== References ==
Line 65: Line 61:
<references />
<references />


== A possible solution ==
<div class="toccolours mw-collapsible mw-collapsed">
Click the expand link to see one possible solution, but NOT before you have tried and failed!
<div class="mw-collapsible-content">
<syntaxhighlight lang="python" >
not yet!
</syntaxhighlight>


</div>
</div>


[[Category:problem set]]
[[Category:problem set]]

Latest revision as of 13:01, 13 September 2021

This a problem set for you to work through [1]

This is a problem set. Some of these are easy, others are far more difficult. The purpose of these problems sets are:

  1. to build your skill applying computational thinking to a problem
  2. to assess your knowledge and skills of different programming practices
  3. to asses your depth of knowledge for the parts of a CPU, and how those parts work together.

What is this problem set trying to do[edit]

You must demonstrate your understanding of the function and architecture of a CPU by creating a simulation of the CPU. Please look at this for an example of ABOUT what I'm looking for. Please also visit our page on Computer organization. Please read this problem set very carefully. You do NOT need to build a graphical user interface!!

The Problem[edit]

Construct a simulation of a CPU. Your simulation must model and simulate:

  1. a data structure representing the ALU - The arithmetic logic unit executes all calculations within the CPU
  2. a data structure representing the CU - control unit, coordinates how data moves around
  3. a data structure representing the PC - program counter - stores address of the -> next <- instruction in RAM
  4. a data structure representing the MAR - memory address register - stores the address of the current instruction being executed
  5. a data structure representing the MDR - memory data register - stores the data that is to be sent to or fetched from memory
  6. a data structure representing the CIR - current instruction register - stores actual instruction that is being decoded and executed
  7. a data structure representing the ACC - accumulator - stores result of calculations
  8. a data structure representing the address bus - carries the ADDRESS of the instruction or data
  9. a data structure representing the data bus - carries data between processor and the memory
  10. a data structure representing the control bus - sends control signals such as: memory read, memory write
  11. a data structure representing primary memory. You need to represent address and data/instruction space
  12. a clear representation and visible functioning of the machine instruction cycle
  13. you should represent clock cycles
  14. you should represent a simple set of instructions being fully executed (fetched, execute store)

Your solution must explain how a CPU functions. Everything must be explicit and clear. Please reference this IB standard for this problem set: Explain the machine instruction cycle.

How you will be assessed[edit]

Your solution will be graded using the following axis:

Scope

  • To what extent does your code implement the features required by our specification?
  • To what extent is there evidence of effort?

Correctness

  • To what extent did your code meet specifications?
  • To what extent is your code free of bugs?

Design

  • To what extent is your code written well (i.e. clearly, efficiently, elegantly, and/or logically)?
  • To what extent is your code eliminating repetition?
  • To what extent is your code using functions appropriately?

Style

  • To what extent is your code readable?
  • To what extent is your code commented?
  • To what extent are your variables well named?

References[edit]