Skip to end of metadata
Go to start of metadata

1. Summary

In this project, I created a functional CPU, using a ROM for the program memory, a RAM for the data memory, and a separate ALU circuit.

 

2. Tasks

1) Testing my ALU:

 

The CPU requires nine states: Start, Fetch, Execute-Setup, Execute-ALU, Execute-MemoryWait, Execute-Write, Execute-ReturnPause1, Execute-ReturnPause2, and Halt.

The first state is a startup state, and the final state is a halt state. After eight clock cycles, this state moves to the fetch state.

The RETURN instruction requires two extra clock cycles--the Execute-ReturnPause1 and Execute-ReturnPause2--after the Execute-Write state in order to load the instruction at the return address into the IR.

 

The initial content of my ROM:

 

The initial content of my RAM:

 

2) Testing ProgramROM:

 

3) Testing push and pop using testpush.mif:

 

4) Testing a function call using testcall.mif:

 

5) Write a program for your computer that creates the first 10 values of the fibonnaci sequence.

Following the basic structure as shown above, I wrote a program fibonnaci.mif.

I used RA and RB to store the initial operands, RC to temporarily store the sum of RA and RB, and RE as a loop index n.

Testing fib:

The first 10 numbers were stored to output: 0, 1, 1, 2, 3, 5, 8, 13(hex 0D), 21(hex 15), 34(hex 22).

 

3. Extensions

1) Write an unsigned multiply program.

Multiplying [RA] and [RB] is equivalent to adding [RA] to itself ([RB]-1) times.

For this extension, I wrote a program multi.mif, where I put 3 into RA and 4 into RB. 

3 * 4 = 12.

RC stores the temporary result of addition and gets updated until RB reaches 0.

In this example,

RC = 3 --> 6 --> 9 -->12

Testing multi:

The output(oport) is 12.

 

2) Download your CPU to the board and demonstrate it works properly.

I used the board to display the fibonacci sequence.

To do this, I added a component SevenSegDriver from previous projects and port-mapped the four instances of it.

I also added a process and an internal signal ctr for slowing down the clock.

 

Below is a video:

fibonnaci.mp4

It is displaying 00, 01, 01, 02, 03, 05, 08, 0D, 15, 22, 37, 59, 90... in hex, which corresponds to 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144 in decimal. 

 

3) Write another fibonnaci sequence program.

I wrote a fib2.mif using CALL and RETURN.

 

The sequence is generated by oport:


4) Write a program to find the sum of first n natural numbers using recursion.


I wrote a sumrec.mif where n=6 and the sum is 6 + 5 + 4 + 3 + 2 + 1 = 21.


4. Credit

Ethan Seal

Mike Zheng

Di Luo

Bruce

Labels