Lecture5 PDF
Lecture5 PDF
EECS 222:
Embedded System Modeling
Lecture 5
Rainer Dömer
Lecture 5: Overview
• Review
– Communication and synchronization in SpecC
– Assignment 2: Producer-consumer example in SpecC
• SpecC Tools
– Compiler and simulator
– SIR tools
– Debugging and tracing
C C1
v1 v1
B v2 B v2 B C2
v3 v3
S R S R S R
Homework Assignment 2
• Task: Introduction to SpecC Compiler and Simulator
• Steps
– Setup the SpecC compiler scc
• source /opt/sce/bin/setup.csh
– Use scc to compile and simulate some simple examples
• scc HelloWorld -vv
• See man scc for the compiler manual page
– Build and simulate a Producer-Consumer example
• See slide 8 for reference
• Producer Prod should send string “Beans and Potatoes”
character by character to the consumer Cons
• Both print the sent/received characters to the screen
• Deliverables
– Source and log file: ProdCons.sc, ProdCons.log
• Due
– January 23, 2019, 6pm
interface i_semaphore
{
void acquire(void);
void release(void);
bool attempt(void);
};
channel c_semaphore(
in const unsigned long c)
implements i_semaphore;
interface i_semaphore
{
void acquire(void);
void release(void);
bool attempt(void);
};
interface i_critical_section
{
void enter(void);
void leave(void);
};
channel c_critical_section
implements i_critical_section;
interface i_token
{ channel c_token
void consume(unsigned long n); implements i_consumer,
void produce(unsigned long n); i_producer,
}; i_token;
interface i_barrier
{
void barrier(void);
};
channel c_barrier(
in unsigned long n)
implements i_barrier;
channel c_handshake
implements i_receive,
i_send;
interface i_tranceiver
{
void receive(void *d, unsigned long l); channel c_double_handshake
void send(void *d, unsigned long l); implements i_receiver,
}; i_sender;
interface i_type_tranceiver
{
void receive(type *d); channel c_type_double_handshake
void send(type d); implements i_type_receiver,
}; i_type_sender;
interface i_type_tranceiver
{ channel c_type_queue(
void receive(type *d); in const unsigned long s)
void send(type d); implements i_type_receiver,
}; i_type_sender;
SpecC Tools
• Compilation and Simulation
– scc DesignName –sc2out –vv –ww
– ./DesignName
– Header file sim.sh
• Access to simulation time
– macros PICO_SEC, NANO_SEC, MICRO_SEC,
MILLI_SEC, SEC
– typedef sim_time, sim_delta, sim_time_string
– function now(), delta()
– conversion functions time2str(), str2time()
• Handling of bit vectors
– conversion functions bit2str(), ubit2str(), str2bit(),
str2ubit()
• Handling of long-long values
– conversion functions ll2str(), ull2str(), str2ll(),
str2ull()
SpecC Tools
• SpecC Simulation Time
• Example: Print the current simulation time
#include <sim.sh>
...
sim_time t;
sim_delta d;
sim_time_string buffer;
...
t = now(); d = delta();
printf(“Time is now %s pico seconds.\n”, time2str(buffer, t));
printf(“(delta count is %s)\n”, time2str(buffer, d);
waitfor 42000 NANO_SEC;
printf(“Time is now %s pico seconds.\n”, time2str(buffer, t));
printf(“Time is now %s nano seconds.\n”,
time2str(buffer, t/(1 NANO_SEC)));
...
SpecC Tools
• SpecC Compiler
– Command line interface
– Usage: scc <design> [<cmd>] [<opt>…]
– Help: scc –h
man scc
– Example:
% scc HelloWorld –sc2out –v –ww
scc: SpecC Compiler V 2.2.1
(c)2012 CECS, UC Irvine
Preprocessing...
Parsing...
Translating...
Compiling...
Linking…
Done.
SpecC Tools
• SIR Tools
– Tools working with SpecC Internal Representation (SIR) files
– Example:
% scc Adder -sc2sir -o Adder.sir
– % sir_list -t Adder.sir
– behavior ADD8
– behavior AND2
– behavior FA
– behavior HA
– behavior Main
– behavior XOR2
– % sir_tree -bt Adder.sir FA
– behavior FA
– |------ HA ha1
– | |------ AND2 and1
– | \------ XOR2 xor1
– |------ HA ha2
– | |------ AND2 and1
– | \------ XOR2 xor1
– \------ OR2 or1
SpecC Tools
• Debugging
– scc DesignName –sc2out –vv –ww –g -G
gdb ./DesignName
ddd ./DesignName
– Header file sim.sh
• Access to simulation engine state
– functions ready_queue(), running_queue(), etc.
– functions _print_ready_queue(),
_print_running_queue(), etc.
– function _print_process_states()
– function _print_simulator_state()
• Access to current instance
– functions active_class(), active_instance()
– functions current_class(), current_instance()
– functions print_active_path(), print_current_path()
– ...
SpecC Tools
• Tracing
– scc DesignName –sc2out –vv –ww -Tvcds
./DesignName
gtkwave DesignName.vcd
– Trace instructions in file DesignName.do
– Trace log in file DesignName.vcd
– Waveform display gtkwave
• available as /opt/gtkwave/bin/gtkwave
• Documentation:
– E. Johnson, A. Gerstlauer, R. Dömer:
"Efficient Debugging and Tracing of System Level Designs",
CECS Technical Report 06-08, May 2006.
– http://www.cecs.uci.edu/~doemer/publications/CECS_TR_06_08.pdf