Lab 8

SystemC

The purpose of this lab is to get familiar with SystemC and to try some simulations. During this lab you are going to rewrite a small project “image edge detector algorithm” from C++ language to SystemC and simulate it with the help of GNU C++ compiler (plus SystemC library, plus waveform viewer) and with the help of ModelSim simulator.

Introduction to SystemC

In order to practice compilation and simulation of SystemC files with g++ compiler (plus systemC library) you are given source code of multiplexer written in SystemC (mux.h

 and mux.cpp) and a testbench for the multiplexer (t_mux.cpp).

In order to work with other C++ compilers (plus systemC library) you need to:

./[output name]

 

In order to practice how to compile and simulate SystemC files in ModelSim you are given source code of multiplexer mux.h and mux.cpp written in SystemC, and a testbench for the multiplexer is proposed t_muxMS.cpp.

In order to run SystemC in ModelSim you need to make some changes in the original SystemC code (see also last pages of systemC lecture slides).

sccom filename

or chose from menu Compile -> Compile Selected (note that you can’t compile .h files)

sccom -link

 

Image processing using HW and SW

 

During this lab you are going to rewrite image edge detector algorithm from C++ language to SystemC language. A gray-scaled picture is given to the input of this algorithm. In this picture every pixel is represented with an 8-bit number, which describes pixel color. The output picture is in the same format. In given program example picture is read from PGM (portable gray map) format and is written in the same format. Algorithm has 2 stages: image Gaussian blurring, which is divided itself to horizontal and vertical, and edge detection. Whole program has 4 steps in sequence: image reading, image Gaussian blurring, edge detection and image writing. 

Task:

·         In order to get familiar with SystemC tools, run multiplexer example with two different simulators (g++ compiler+SystemC lib and ModelSim). See above how to use both.

·         Compile and run C++ program imageEdgeDetector.cpp of edge detection algorithm, try to understand the program in general, at least to find 4 steps of the program.

o   To compile you need to type in terminal window:

g++ -o [output name] [file name]

o   To run:

./[output name]

·         Let’s imagine we would like to make some simple co-design of the algorithm given above. We divide it into 2 parts (Software and Hardware). Let the software part “SW” read and write picture from/to a file and hardware “HW” makes all the calculations for the algorithm. Lets store the picture read as input into some common memory, the same story goes for calculated picture (this means we would have some global matrixes of pictures as unsigned char* inputImage). Make 2 clocked modules in SystemC: “SW” and “HW” and establish communication between them with the help of ready signals, for example such as inputPictureReady and outputPictureReady. Similar to the schema depicted below:

o   Write the program in SystemC according description above, some similar example of handshaking communication can be found in lecture slides (slides 51-54). Some starting point is given to you in t_imageDetector.cpp;

o   Simulate it with both simulators (g++ compiler+SystemC lib and ModelSim), make sc_main files separate;

o   Check the trace file

·         Separate “HW” module into 2 modules: one for Gaussian blur and another for edge detection. Establish similar communication with ready signals as you have done in the previous step. Again simulate and check trace file.

·         Calculate approximately delay in clock cycles for every separate module and add this delay to your SystemC program with the help of wait command. Check now the trace file.

Requirements: