CS 370
– Spring 2005
Introduction to Digital
Design
Instructor:
Homework Set 8
DISTRIBUTED: May 20
Collaboration Policy:
Unless otherwise noted, you may collaborate with other CSE370 students on the
homework assignments. Do not look at homework or exam solutions from previous
years. You must spend at least 15 minutes working on a problem before seeking
assistance. Collaboration means that you may discuss the problems and make
notes during the discussion, but you may not look at other student’s work
when writing up your homework. Your homework represents your own work—the
homework must show that you understand the material and have worked as an
individual on every problem. You may not divide up the task of doing the
problem sets in the interpretation of collaboration. You may discuss lecture
material with anyone.
Late Homework Policy:
The weekly assignments are due at the beginning of class. Assignments handed in
during or immediately after class will incur a 10% penalty.
We will penalize your assignment 10% per day for each additional day late.
Please show all of your work. Your solutions must be legible…we will not spend time trying to decipher poorly written assignments.
The test programs for this homework are linked here iram1.dat and iram2.dat . They are in the course hw8 folder. iram1.dat tests the load instruction and iram2.dat tests the branch instructions. You can find the expected values of the registers after executing these two programs in the comments.
The test program for x370 Model 3 is linked here search.dat. Use the data file data_250.dat for the dram module.
The remaining homework assignments will focus on implementing the x370 Processor. You already understand the operation of the x370 Model 0, which only executes ALU instructions using the registers in the register file. You will now implement the remaining instructions, a few at a time, until you have the complete processor designed. We will give you simple test programs to use to make sure your design works correctly, but you should write programs of your own to help you debug your circuit.
For both parts, you should turn in a copy of your schematics (and Verilog programs, if any), plus a screen shot showing the contents of your register file and data memory at the end of the simulation. You must also submit a final copy of your project electronically – details will be posted later.
1. (Due Friday, May 27, start of class) Design the x370 Model 1 and 2. This involves adding the Load Immediate and the Branch instructions to the x370 Model 0. The Load Immediate instruction uses data that is contained in the instruction, instead of data from the ALU, to write into the register file. This allows programs to load registers with specific values. Don’t forget to sign-extend this value from the instruction, which is only 8 bits. Implementing the Branch instructions will mean implementing a new PC (program counter) so that it can load a new address value, which is provided by the instruction itself, instead of just counting.
2. (Due Friday, June 3, start of class) Design the x370 Model 3. This involves adding the data memory to your processor and implementing the load and store instructions. You will find the dram module in the lib370 library to use for the data memory. The dram module is a single-ported memory, which means that it has only one address port and one data port for both reading memory and writing memory. The write control signal determines whether a value on the Data port is being written. If write = 1, then the data to be written to the memory is driven onto this port from the outside (by your circuit). This data is written to the memory location indicated by the value on the Address port. If write = 0, then you must tri-state the Data bus, and the memory will drive the value at the specified location onto the bus. That is, the memory will tri-state its output when you are writing to the memory, and you must tri-state your output to the bus when the memory is reading a value onto it. You will have to use what you learned in the Lab about tri-state drivers. The TBUF module in lib370 is a tri-state driver that you can use in your schematics.
As part of the last homework, you must write the following program which decrypts a message stored in the data memory and prints it to the console.
I have written a C program for this algorithm:
==================
key = dram[0];
for (i=1; dram[i]!=0; i++) {
dram[255] = dram[i] XOR key;
key = (key XOR (key<<4)) + 1;
}
==================
That is, the decryption key is stored at address 0, and the string to be decoded is stored one character per location starting at address 1. A value of 0 marks the end of the string. Note that you can print a character by writing it to address 255 of the dram. This is called memory-mapped I/O.
You will need a new version of the dram to do this, called dram3.v. Use the data file dram.dat for the dram module.
[Extra Credit] Add a new instruction to the processor for executing function calls. Document your design decisions. Write a program that uses function calls. If you are very ambitious, you will allow nested, even recursive, function calls!