Question
In c++ For this assignment you must create a class to simulate a simple microcontroller called the Simpletron. You may think about other classes to
In c++
For this assignment you must create a class to simulate a simple microcontroller called the Simpletron. You may think about other classes to design (i.e an Instruction class, Simulator class, etc.) if you wish. However, this is not a requirement for the assignment.
Building a microcontroller simulator is a fantastic way to build your understanding of how computers work. Deitel & Deitel have an interesting problem described in Chapter 8 (Exercises 8.15 and 8.16) called the Simpletron. Please be sure to see Building Your Own Computer in Chapter 8 starting on page 370.
In this assignment you will change the requirements of the Build Your Own Computer discussion to create a class that will be the Simpletron. This class will encapsulate all of the operations of the Simpletron microcontroller. You may also want to include some code for the Fatal Errors. This program will interpret instructions (called Simpletron Machine Language (SML) instructions) and carry out the corresponding operation. For this program you must place your SML instructions into a file and read each instruction from the file, instead of typing each instruction into the program every time the program starts up. You may find an example file at:http://eecs.wsu.edu/~aofallon/cpts122/progassignments/Example1.sml. By taking this approach you should be able to integrate Simpletron into a standard text wrapper/main driver to run the simulator. Note: the loading of the SML program into memory should be separate from the Simpletron class. An example of an SML program is shown below:
Location | Number (shows instructions where memory may reach 1000 cells) | Instruction |
000 | +10007 | (Read A) |
001 | +10008 | (Read B) |
002 | +20007 | (Load A) |
003 | +30008 | (Add B) |
004 | +21009 | (Store C) |
005 | +11009 | (Write C) |
006 | +43000 | (Halt) |
007 | +00000 | (Variable A) |
008 | +00000 | (Variable B) |
009 | +00000 | (Variable C) |
As many of you may know a computer uses the fetch/decode/execute cycle to gather and run each instruction. For part of the design of your Simpletron class, you may want to create functions fetch (), decode (), and execute (). The fetch () function will read the next SML instruction from memory. The decode () function will determine theoperationCode and operand of the instruction. The execute () function will perform the correct operation. Note that it is a fantastic idea to design a separate method for each operation. For example, you may have a method that performs ADDition, BRANCHing, etc, and these may be called from the execute () function!!!
Please take note of extensions to the Simpletron description in the grading table below.
BONUS (15 pts): Implement a Simpletron class template. Imagine you could operate on instructions that are integer representations or objects themselves!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started