You are on page 1of 3

Assignment 2: Introduction to SystemC

February 23, 2016


As already mentioned in the first assignment, please use the given file and repositories names as
mentioned in the text, since your assignment is checked using a script. Any deviation will lead to a
reduction of marks.

Counter

In the exam, a small counter module was introduced and the following source code was provided:
1

#include c o u n t e r . hpp

2
3
4
5
6
7
8
9
10

void Counter : : counterFunc ( ) {


sc uint <4> value = 1 ;
while ( 1 ) {
output . write ( value ) ;
wait ( ) ;
value++;
}
}
Listing 1: counter.cpp
1. In your user account on nanu.iiitd.edu.in, create a git repository called assignment2 and check it
out to your personal machine.
2. Copy content of listing 1 into the file counter.cpp.
3. Create an appropriate header file (counter.hpp) for your class Counter using macros provided by
SystemC.
Make sure to use include guards (refer to assignment 1).
4. Create a test bench (TbCounter.x pp) in SystemC which drives all ports of the Counter module
and displays the output on screen.
Issue a reset to Counter for the first and tenth clock cycle in the simulation.
In addition it also checks the output automatically for correctness by comparing the returned
value from Counter with the expected value.
5. Create a SystemC module SYSTEM which as top level module instantiates the test bench for Counter
and Counter itself. In the same file, have a sc main instantiating the top level module and starting
the simulation.
6. Create the Makefile so that only changed source code files are recompiled.

1.1

CounterBig

1. Create a branch in your git repository called counterBig.


2. Implement a class CounterBig (CounterBig.x pp) which has to count to 255 and then it restarts
at the beginning.
To implement CounterBig, you need to use the module Counter.
You are not allowed to use arithmetics inside CounterBig.
3. Since the output of CounterBig is double the size compared to Counter, you need to adapt the
test bench. Therefore change the test bench to a class template that can handle different output
formats.
4. Extend the SystemC module SYSTEM implemented in section 1, and instantiate additionally CounterBig with a test bench with an appropriate set type for the template.
5. Adapt the Makefile so that only changed source code files are recompiled.
6. Observe the output. Is it in a nice sequence?
7. Add an UML diagram to the documentation.
8. Commit all changes into the git repository (branch counterBig).

ALU
Instruction
ADD
SUB
MUL
DIV
CMP
any other instruction

Clock Cycles required


4
5
19
120
2
1

Table 1: Clock cycles required for the ALU instructions


1. In the repository of your first assignment, create a branch, called tlm.
2. Convert the SAM of the ALU implemented in assignment 1 to a TLM using SystemC which allows
you to simulate cycle-accurate computation (at least). Table 1 shows, how many clock cycles are
required to execute the instructions. Allow only one instruction to be executed at the same time.
3. Implement appropriate handshaking protocols to make the ALU operational.
4. Compare the results with the output of the ALU in the first assignment and make sure, the
functionality stays the same.
5. Extend the main/sc main function to generate a VCD file of the clock, reset, registers (Registers
class), and all ALU signals. You can observe the VCD file in free and open-source tools such as
GTKWave (http://gtkwave.sourceforge.net/).
6. Adapt the Makefile so that only changed source code files are recompiled.
7. Commit all changes into the git repository (assignment1.git, branch tlm).

Remarks
Do not forget to submit (push) your final additions to the repositories before the deadline. Late
submissions will be penalized.
If a name is given for e.g. a class or repository, please use it in exactly the same way. Pay attention
to uppercase and lowercase spellings.
If you plagiarize, the policy of the institute will be applied (https://www.iiitd.ac.in/education/
resources/academic-dishonesty) with the exception that apart that your assignment will not
carry any marks, your final grade is going to be reduced by one grade point instead of a letter
grade. You may discuss possible solutions, however refrain from inspecting and/or copying code
from websites, colleagues, etc.
Regardless of your system, the submitted code is checked out and compiled on nanu.iiitd.edu.in.
Therefore you have to make sure, that your Makefiles are correct and that your program compiles
on the server. So after a submission, you can log in to the server using SSH, check out a local copy
of the repository (refer to assignment 1) and execute the Makefile.

You might also like