0% found this document useful (0 votes)
71 views14 pages

Lecture5 PDF

This document provides an overview of SpecC modeling language concepts covered in Lecture 5 of the EECS222 course, including: - SpecC standard channels for synchronization and communication using events and interfaces. - SpecC tools like the compiler and simulator for modeling and the SIR tools for debugging and tracing models. - SpecC language features like synchronization using wait, notify and notifyone and communication using shared variables, message passing through channels and interfaces, and hierarchical channel implementation.

Uploaded by

Frankie Liu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
71 views14 pages

Lecture5 PDF

This document provides an overview of SpecC modeling language concepts covered in Lecture 5 of the EECS222 course, including: - SpecC standard channels for synchronization and communication using events and interfaces. - SpecC tools like the compiler and simulator for modeling and the SIR tools for debugging and tracing models. - SpecC language features like synchronization using wait, notify and notifyone and communication using shared variables, message passing through channels and interfaces, and hierarchical channel implementation.

Uploaded by

Frankie Liu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

EECS222: Embedded System Modeling Lecture 5

EECS 222:
Embedded System Modeling
Lecture 5

Rainer Dömer

[email protected]

The Henry Samueli School of Engineering


Electrical Engineering and Computer Science
University of California, Irvine

Lecture 5: Overview
• Review
– Communication and synchronization in SpecC
– Assignment 2: Producer-consumer example in SpecC

• SpecC Standard Channels


– Synchronization
– Communication

• SpecC Tools
– Compiler and simulator
– SIR tools
– Debugging and tracing

EECS222: Embedded System Modeling, Lecture 5 (c) 2019 R. Doemer 2

(c) 2019 R. Doemer 1


EECS222: Embedded System Modeling Lecture 5

The SpecC Language


• Communication and synchronization
– via shared variable
– via channel with interfaces
– via hierarchical channels

C C1
v1 v1
B v2 B v2 B C2
v3 v3

S R S R S R

Shared memory Message passing Protocol stack

EECS222: Embedded System Modeling, Lecture 5 (c) 2019 R. Doemer 3

The SpecC Language


• Synchronization behavior S(out event Req,
out float Data,
– Event type in event Ack)
{
• event <event_List>; float X;
– Synchronization primitives void main(void)
{ ...
• wait <event_list>; Data = X;
notify Req;
• notify <event_list>; wait Ack;
...
• notifyone <event_list>; }
};
behavior R(in event Req,
Req in float Data,
B Data out event Ack)
{
Ack float Y;
void main(void)
{ ...
wait Req;
Y = Data;
S R notify Ack;
...
}
};
EECS222: Embedded System Modeling, Lecture 5 (c) 2019 R. Doemer 4

(c) 2019 R. Doemer 2


EECS222: Embedded System Modeling Lecture 5

The SpecC Language


interface IS
{
• Communication void Send(float);
};
– Interface class interface IR
{
• interface <name> float Receive(void);
{ <declarations> }; };
channel C
– Channel class behavior S(IS Port) implements IS, IR
• channel <name> { {
event Req;
float X;
implements <interfaces> void main(void) float Data;
{ <implementations> }; { ... event Ack;
Port.Send(X);
void Send(float X)
C ...
{ Data = X;
Req }
}; notify Req;
B IS Data IR wait Ack;
behavior R(IR Port) }
Ack { float Receive(void)
float Y; { float Y;
void main(void) wait Req;
{... Y = Data;
Y=Port.Receive(); notify Ack;
S R return Y;
...
} }
}; };
EECS222: Embedded System Modeling, Lecture 5 (c) 2019 R. Doemer 5

The SpecC Language


interface IS
{
• Hierarchical channel interface PCI_IF
{ };
void Send(float);

– Virtual channel void Transfer(


enum Mode,
interface IR
{
implemented by int NumBytes, float Receive(void);
int Address);
standard bus protocol };
};
channel PCI
• Example: behavior S(IS Port) implements PCI_IF;
simplified PCI bus {
float X; channel C2
void main(void) implements IS, IR
{ ... {
Port.Send(X); PCI Bus;
... void Send(float X)
C2 } { Bus.Transfer(
}; PCI_WRITE,
B PCI sizeof(X),&X);
behavior R(IR Port) }
{ float Receive(void)
float Y; { float Y;
void main(void) Bus.Transfer(
{... PCI_READ,
Y=Port.Receive(); sizeof(Y),&Y);
S R ... return Y;
} }
}; };
EECS222: Embedded System Modeling, Lecture 5 (c) 2019 R. Doemer 6

(c) 2019 R. Doemer 3


EECS222: Embedded System Modeling Lecture 5

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

EECS222: Embedded System Modeling, Lecture 5 (c) 2019 R. Doemer 7

The SpecC Language


• Summary
– True superset of ANSI-C
• ANSI-C plus extensions for HW-design
– Support of all concepts needed in system design
• Structural hierarchy
• Behavioral hierarchy
• State transitions
• Exception handling
• Communication
• Synchronization
• Timing
• Library support
• Persistent annotation
• Register Transfer Level (RTL) modeling (discussed later)

EECS222: Embedded System Modeling, Lecture 5 (c) 2019 R. Doemer 8

(c) 2019 R. Doemer 4


EECS222: Embedded System Modeling Lecture 5

SpecC Standard Channels


• SpecC Standard Channel Library
– introduced with SpecC Language Version 2.0
– safe and consistent modeling of common channels
with standard interfaces
• Standard Synchronization Channels
– Mutually exclusive execution
• Semaphore, mutex, critical section
– Dependent execution
• Token
• Handshake, barrier
• Standard Communication Channels
– Typed and type-less message passing
• Double handshake
• Queue
EECS222: Embedded System Modeling, Lecture 5 (c) 2019 R. Doemer 9

SpecC Standard Channels


c_semaphore
• Standard Synchronization Channels
acquire
– Mutually exclusive execution
release
• Semaphore
attempt

interface i_semaphore
{
void acquire(void);
void release(void);
bool attempt(void);
};

channel c_semaphore(
in const unsigned long c)
implements i_semaphore;

EECS222: Embedded System Modeling, Lecture 5 (c) 2019 R. Doemer 10

(c) 2019 R. Doemer 5


EECS222: Embedded System Modeling Lecture 5

SpecC Standard Channels


c_mutex
• Standard Synchronization Channels
acquire
– Mutually exclusive execution
release
• Semaphore
attempt
• Mutex

interface i_semaphore
{
void acquire(void);
void release(void);
bool attempt(void);
};

channel c_mutex channel c_semaphore(


implements i_semaphore; in const unsigned long c)
implements i_semaphore;

EECS222: Embedded System Modeling, Lecture 5 (c) 2019 R. Doemer 11

SpecC Standard Channels


c_critical_section
• Standard Synchronization Channels
– Mutually exclusive execution enter
• Critical section leave

interface i_critical_section
{
void enter(void);
void leave(void);
};

channel c_critical_section
implements i_critical_section;

EECS222: Embedded System Modeling, Lecture 5 (c) 2019 R. Doemer 12

(c) 2019 R. Doemer 6


EECS222: Embedded System Modeling Lecture 5

SpecC Standard Channels


c_token
• Standard Synchronization Channels
– Dependent execution produce
• Token consume

interface i_consumer interface i_producer


{ {
void consume(unsigned long n); void produce(unsigned long n);
}; };

interface i_token
{ channel c_token
void consume(unsigned long n); implements i_consumer,
void produce(unsigned long n); i_producer,
}; i_token;

EECS222: Embedded System Modeling, Lecture 5 (c) 2019 R. Doemer 13

SpecC Standard Channels


c_barrier
• Standard Synchronization Channels
– Dependent execution
barrier
• Barrier

interface i_barrier
{
void barrier(void);
};

channel c_barrier(
in unsigned long n)
implements i_barrier;

EECS222: Embedded System Modeling, Lecture 5 (c) 2019 R. Doemer 14

(c) 2019 R. Doemer 7


EECS222: Embedded System Modeling Lecture 5

SpecC Standard Channels


c_handshake
• Standard Synchronization Channels
– Dependent execution send
• Handshake receive

interface i_receive interface i_send


{ {
void receive(void); void send(void);
}; };

channel c_handshake
implements i_receive,
i_send;

EECS222: Embedded System Modeling, Lecture 5 (c) 2019 R. Doemer 15

SpecC Standard Channels


c_double_handshake
• Standard Communication Channels
– Type-less message passing send
• Double handshake receive

interface i_receiver interface i_sender


{ {
void receive(void *d, void send(void *d,
unsigned long l); unsigned long l);
}; };

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;

EECS222: Embedded System Modeling, Lecture 5 (c) 2019 R. Doemer 16

(c) 2019 R. Doemer 8


EECS222: Embedded System Modeling Lecture 5

SpecC Standard Channels


c_queue
• Standard Communication Channels
– Type-less message passing send
• Double handshake receive
• Queue

interface i_receiver interface i_sender


{ {
void receive(void *d, void send(void *d,
unsigned long l); unsigned long l);
}; };

interface i_tranceiver channel c_queue(


{ in const unsigned long s)
void receive(void *d, unsigned long l); implements i_receiver,
void send(void *d, unsigned long l); i_sender,
}; i_tranceiver;

EECS222: Embedded System Modeling, Lecture 5 (c) 2019 R. Doemer 17

SpecC Standard Channels


c_type_double_handshake
• Standard Communication Channels
– Typed message passing send
• Double handshake receive

interface i_type_receiver interface i_type_sender


{ {
void receive(type *d); void send(type d);
}; };

interface i_type_tranceiver
{
void receive(type *d); channel c_type_double_handshake
void send(type d); implements i_type_receiver,
}; i_type_sender;

• type can be any basic or composite SpecC type

EECS222: Embedded System Modeling, Lecture 5 (c) 2019 R. Doemer 18

(c) 2019 R. Doemer 9


EECS222: Embedded System Modeling Lecture 5

SpecC Standard Channels


c_type_queue
• Standard Communication Channels
– Typed message passing send
• Double handshake receive
• Queue

interface i_type_receiver interface i_type_sender


{ {
void receive(type *d); void send(type d);
}; };

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;

• type can be any basic or composite SpecC type

EECS222: Embedded System Modeling, Lecture 5 (c) 2019 R. Doemer 19

SpecC Standard Channels


• Using Standard Channels
– Import synchronization channels
• semaphore channel import “c_semaphore”;
• mutex channel import “c_mutex”;
• critical section import “c_critical_section”;
• token import “c_token”;
• barrier import “c_barrier”;
• handshake import “c_handshake”;
– Import type-less communication channels
• double handshake import “c_double_handshake”;
• queue import “c_queue”;
– Include typed communication channels
• double handshake #include <c_typed_double_handshake>
• queue #include <c_typed_queue>

EECS222: Embedded System Modeling, Lecture 5 (c) 2019 R. Doemer 20

(c) 2019 R. Doemer 10


EECS222: Embedded System Modeling Lecture 5

SpecC Standard Channels


• Using Typed Communication Channels
– Include channel header file (from $SPECC/inc/)
• double handshake #include <c_typed_double_handshake>
• queue #include <c_typed_queue>
– Example:
#include <c_typed_queue.sh>
struct pack { int a, b, c; };
DEFINE_I_TYPED_SENDER(pack, struct pack)
DEFINE_I_TYPED_RECEIVER(pack, struct pack)
DEFINE_C_TYPED_QUEUE(pack, struct pack)
behavior Sender(i_pack_sender Port)
{ void main(void)
{ struct pack Data = { 1, 2, 3 };
// ...
Port.send(Data); Example source code available here:
// ... ~eecs222/public/queue.sc
}
};

EECS222: Embedded System Modeling, Lecture 5 (c) 2019 R. Doemer 21

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()

EECS222: Embedded System Modeling, Lecture 5 (c) 2019 R. Doemer 22

(c) 2019 R. Doemer 11


EECS222: Embedded System Modeling Lecture 5

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)));
...

EECS222: Embedded System Modeling, Lecture 5 (c) 2019 R. Doemer 23

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.

EECS222: Embedded System Modeling, Lecture 5 (c) 2019 R. Doemer 24

(c) 2019 R. Doemer 12


EECS222: Embedded System Modeling Lecture 5

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

EECS222: Embedded System Modeling, Lecture 5 (c) 2019 R. Doemer 25

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()
– ...

EECS222: Embedded System Modeling, Lecture 5 (c) 2019 R. Doemer 26

(c) 2019 R. Doemer 13


EECS222: Embedded System Modeling Lecture 5

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

EECS222: Embedded System Modeling, Lecture 5 (c) 2019 R. Doemer 27

(c) 2019 R. Doemer 14

You might also like