This page describes the script used in the systemc parameterized CRC module.
-
The following compilation / simulation options exists:
option name
|
Description
|
(none)
|
Skips compilation, checks if executable exists:yes run it without debugger. no shows first error using less command.
|
comp
|
Compiles, checks if executable was created:yes run it without debugger. no shows first error using less command.
|
comp gdb
|
Compiles, checks if executable was created:yes run it with GDB debugger. no shows first error using less command.
|
gdb
|
Checks if executable was created:yes run it with GDB debugger. no shows first error using less command.
|
-
Note that you can not run the systemc executable from the script. Since the script does not globally set the environment variable, namely, LD_LIBRARY_PATH, you can not run it from terminal, unless you set it manually.
-
The script measures the time, in seconds, that the compilation takes to run. It prints it and in case of error, appends it to the compilation log file: log.txt.
The way it is done is shown below:
- #!/bin/bash
- LD_LIBRARY_PATH=.:/mnt/Home/pini/Home_1/pini/systemc_2.2.0/include:/mnt/Home/pini/Home_1/pini/systemc_2.2.0/lib-linux:${LD_LIBRARY_PATH}
- export LD_LIBRARY_PATH
- if [ "$1" = "comp" ] ; then #allows to skip compilation
- time_start=`date +%s`
- clear
- \rm -f run.x *.o
- time_start=`date +%s`
- echo "compilation started"
- make linux >& log.txt
- echo "compilation ended"
- time_end=`date +%s`
- time_tot=$(($time_end - $time_start))
- echo "it took "${time_tot}" seconds for compilation to end"
- fi
-
To enable debug, I have made slight changes in the make file. I removed optimizations and add the debug switches:
g++ -I${SYSC_INC_PREFIX} -I${includedir} -fPIC -c -g -Wall -O2 ${SOURCE_FILES}; \
g++ -g Wno-deprecated -fno-default-inline -fno-inline -gstabs -I${SYSC_INC_PREFIX} -I${includedir} -fPIC -c -g -Wall ${SOURCE_FILES}; \
Put a break point, decide what commands gdb
will execute, when it breaks at the break point and
run.
- ./run_test.unx comp gdb
- break crc_auto_inst.cpp:67
- command 1
- p data_t
- p u_name
- end
- r
- p (char *)inst_buf
- $1 = 0xbfc0e192 "u_0"
- p name
- $1 = (sc_module_name &) @0xbf929854: {m_name = 0x80f34a7 "u_dut",
- m_module_p = 0xbf9295b8, m_next = 0x0, m_simc = 0x8125558, m_pushed = true}
Another debug option is to instruct g++ to
generate dependencies (in .d files). In the
Makefile.rules add the MMD switch:
g++ -MMD
-g Wno-deprecated
This will create the file crc_auto_inst.d:
- crc_auto_inst.o: crc_auto_inst.cpp \
- /mnt/Home/pini/Home_1/pini/systemc_2.2.0/include/systemc.h \
- /mnt/Home/pini/Home_1/pini/systemc_2.2.0/include/systemc \
- /mnt/Home/pini/Home_1/pini/systemc_2.2.0/include/sysc/kernel/sc_cmnhdr.h \
- /mnt/Home/pini/Home_1/pini/systemc_2.2.0/include/sysc/kernel/sc_externs.h \
- ...
- /mnt/Home/pini/Home_1/pini/systemc_2.2.0/include/scv/scv_tr.h \
- /mnt/Home/pini/Home_1/pini/systemc_2.2.0/include/scv/scv_kit_date.h
-
The second part of the script starts simulation, optionally with debugger invocation, if it finds the executable file: run.x . If does not find it, then it shows the first error, using less command.
This part of the script is listed below:
- #checks if okay; if so run ; otherwise display errors
- if [ -e "run.x" ]
- then
- if [ "$1" = "gdb" ] || [ "$2" = "gdb" ] ; then
- gdb ./run.x
- else
- ./run.x
- fi
- else
- echo "it took "${time_tot}" seconds for compilation to end" >> log.txt
- less -p "crc_auto_inst.*error.*" log.txt
- fi
- echo "script end"
To go to main project page: systemc parameterized CRC module .
|