CSUY2214 python
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: _0206girl
CS-UY 2214 — Project 1
Ratan Dey,Jeff Epstein
1 Introduction
This project represents a substantive programming exercise. Like all work for this class, it is to be completed individually: any form of collaboration is prohibited, as detailed in the syllabus. This project is considered a take-home exam.
Before even reading this assignment, please read the E20 manual thoroughly. Read the provided E20 assembly language examples.
2 Assignment: Simulator
Your task is to write an E20 simulator: a program that will execute E20 machine language. Normally, machine language would be executed by a processor, but for simplicity, we will reproduce the behavior of an E20 processor in software. A correct simulator is one that will produce identical results to those produced by a real E20 processor, as described in the E20 manual.
Each E20 machine language program is a sequence of commands to be interpreted by an E20 processor, or a simulation thereof. Your simulator will need to accurately reproduce the state that is manipulated by those commands: the program counter, the general-purpose registers, and memory.
For example, consider the machine language instruction 0010100010000011. This machine language instruction corresponds to the assembly language instruction addi ✩1, ✩2, 3. Therefore, in order to execute this instruction, we must first know the current value of register ✩2. We add 3 to that value, and store the sum in register ✩1. This new value may then be accessed by subsequent instructions.
The basic operation of your simulator is as follows:
1. Initialize the processor state, including the program counter, the general-purpose registers, and memory.
2. Examine the instruction pointed to by the program counter. Determine what action is to be taken.
3. Take the indicated action, updating the value of the program counter, the general-purpose registers, and memory appropriately.
4. If the executed instruction is a halt instruction, end the simulation.
5. Otherwise, go to step 2.
For the purposes of this simulation, the initial state of the program counter is zero, and the initial state of all registers is zero. The machine code program will be loaded into memory starting at address zero, and the value of all other memory cells is zero.
2.1 Input
The input to your simulator will be the name of an E20 machine language file, given on the command line.
By convention, E20 machine language files have an .bin suffix.
Your program will read in the contents of the file. You may assume that the file contains well-formed
E20 machine language code. The file may contains comments, which your program should ignore.
You are provided with several examples of valid E20 machine language files, which you can use to test your simulator.
Here is an example of an E20 machine language program, in a file named loop3.bin, which was produced by assembling the file loop3.s:
ram [0] = 16 ’ b0000000000010000 ; // add ✩1 ,✩0 ,✩0
ram [1] = 16 ’ b0000000001000000 ; // add ✩4 ,✩0 ,✩0
ram [2] = 16 ’ b1000000110001001 ; // lw ✩3 , value (✩0 )
ram [3] = 16 ’ b1110110010010100 ; // loop : slti ✩1 ,✩3 ,20
ram [4] = 16 ’ b1100010000000011 ; // jeq ✩1 ,✩0 , skip
ram [5] = 16 ’ b0001000111000000 ; // add ✩4 ,✩4 ,✩3
ram [6] = 16 ’ b0010110110000001 ; // addi ✩3 ,✩3 ,1
ram [7] = 16 ’ b1100000001111011 ; // jeq ✩0 ,✩0 , loop
ram [8] = 16 ’ b0100000000001000 ; // skip : halt
ram [9] = 16 ’ b0000000000010000 ; // value : add ✩1 ,✩0 ,✩0
Note that each line consists of a memory address, followed by an equals sign, followed by a 16-bit binary number in Verilog syntax, followed by a semicolon. Comments, if present, will be in Verilog syntax.