Project1 Hardware Design With Verilog: Submission Modalities
Project1 Hardware Design With Verilog: Submission Modalities
Both parts will be included in the evaluation of the project. A total of 32 points (plus 6 extra points) can be
achieved. Projects submitted late will be graded with 0 points. Use a ZIP file or a gzip compressed tar archive
(i.e., *.tar.gz) for your submission. The archive should immediately contain all Verilog files (i.e., do not use
subfolders). Use the skeleton files we provide, which already contain the necessary Verilog module declarations.
Do not modify these module declarations unless it is explicitly allowed. Also, do not modify the existing filenames.
If not all of these requirements are met, your submission cannot be evaluated.
Use the two sanitizer testbenches from the CMS to check your solution for illegal changes. To do this, run the
following command:
iverilog -s SanitizerAufwaermteil *.v
(analogously for the main part). If everything compiles without problems and warnings, the sanitizer did not detect
a violation. If our test detects a violation, adjust your submission accordingly.
If you worked on the project in a group, add a contributions.txt file to the archive that briefly describes
how each team member contributed to the implementation. We may grade the project with 0 points for individual
members if they have not made a significant contribution.
Notes: Any collaboration with people who are not part of your own group is not allowed. We will check all
submissions for plagiarism (against submissions from other groups, as well as submissions from previous years).
Submissions that were created by modifying another project, for example by changing variable names, are also
considered to be plagiarized. Plagiarized submissions will be graded with 0 points and will be reported to the
examination board as a cheating attempt; this may lead to expulsion from the university..
If you have attended the system architecture course in the past and would like to use your previous submission
as a basis for the current project: This is only allowed for parts that you implemented yourself; code written by
other members of your previous team may not be reused. In this case, add a file previousyear.txt to the
submission that describes exactly which parts have been reused. Note, however, that the current project is not
identical to projects from previous years. Submissions that only solve an old project will be graded with 0 points.
Tools and Documentation
For the synthesis and simulation of Verilog code, we will use Icarus Verilog7 , and for viewing generated wave-
forms, we will use gtkwave8 . Both programs are available for Linux, macOS, and Windows. Detailed installation
instructions can be found in the CMS under “Zusatzmaterial”.
To synthesize a top-level module M , whose definition including all sub-modules is contained in the files
file1.v to filen.v, run the following command on the command line
Warm-Up Part
Start as soon as possible with this part of the project so that you have enough time left for the main part. The
skeleton files for the project can be found in our CMS under materials12 .
7 http://iverilog.icarus.com
8 http://gtkwave.sourceforge.net
9 http://www.asic-world.com/verilog/veritut.html
10 https://www.mips.com/?do-download=the-mips32-instruction-set-v6-06
11 http://courses.missouristate.edu/kenvollmar/mars/
7
Problem 1.2: Division Circuit 5 Points
In the lectures, we have seen circuits for addition, subtraction and multiplication, but not for division. Integer
division of two unsigned binary numbers can be implemented as a sequential circuit, based on the grade school
hAi
division method. The division hBi according to the school method can be expressed algorithmically as follows.
R = 0
for i = N-1 to 0
R’ = 2 * R + A[i]
if (R’ < B) then Q[i] = 0, R = R’
else Q[i] = 1, R = R’-B
7
Exercise Compute 3 using this algorithm.
Now design the corresponding sequential circuit. The division circuit has two 32-bit inputs A and B, a 1-bit input
start, an input clock and two 32-bit outputs Q and R, where Q is the quotient, and R is the remainder. 32 cycles
hAi
after start = 1 at a rising clock edge, let hQi be the quotient and hRi the remainder of the division hBi . If
start = 1 occurs again during the computation of a division, the circuit aborts the current computation and starts
over with the new operand values. In the following section, we provide some additional guidance.
Implement your sequential circuit as a Verilog module division and verify your design using testbenches.
Notes The sequential circuit shall perform one iteration of the loop per cycle between two consecutive rising
clock edges, i.e. essentially one subtraction and one negativity test. Multiplication in hardware is expensive.
Therefore, try to express the multiplication by cheaper shift operations.
Use three 32-bit wide registers to store the current state of the sequential circuit: The first register stores the
current value of the remainder R. The second register stores the current value of the divisor B. The third register
stores the remaining of the dividend A and the already computed bits of the quotient Q. Thus, before iteration i,
the third register has the state
{A[i : 0], Q[N − 1 : i + 1]}
If at a rising edge of clock the start signal is set (start = 1), we store the inputs A and B in the corresponding
registers and start the computation. A computation takes exactly 32 cycles; after that, the correct result is available
at the outputs until a new division starts. To achieve that not in every cycle an iteration is executed, but only in the
first 32 cycles after the start, it can be helpful to use a counter.
8
Table 2: Control bits and operation of the arithmetic logic unit. The behavior for other assignments is undefined.
alucontrol [2 : 0] result[31:0]
0 0 0 a&b
0 0 1 a|b
0 1 0 hai + hbi
1 1 0 hai − hbi
1 1 1 031 (hai < hbi ? 1 : 0)
Main Part
The skeleton files for the main part of the project can be found in our CMS under materials12 . For simulations, you
can use the module ProcessorTestbench. We provide some test programs, which you need to uncomment
in the testbench. Make sure to pass all these tests successfully.
You should additionally build your own testbenches to verify the correct operation of your circuits. Design
suitable testbenches and think about the expected results before you start implementing them. Your testbenches
for this part of the project will not be used for grading.
9
Problem 2.5: Function Calls 6 Points
To support function calls efficiently, one needs a so-called link register to store the return address, which is needed
to return to the caller at the end of a function call. The convention on MIPS machines is to use register 31. In
assembler code, it is therefore also referred to as ra (return address).
Implement the jal and jr instructions for function calls and returns. Try to change the existing interface
between the datapath and the decoder as minimally as possible.
Note: MIPS uses so-called branch delay slots. This means that the instruction located immediately after a
branch or jump instruction is executed before the jump actually occurs. Therefore, the MIPS documentation lists
PC + 8 as the value of the link register. However, we do not consider delay slots for this project, and thus, the
jal instruction shall write PC + 4 to the link register.
10