SystemC_3-1.ppt

advertisement
Processes in
SystemC
Part of
HW/SW Codesign of Embedded
Systems Course (CE 40-226)
Winter-Spring 2001
Codesign of Embedded Systems
1
Process

Basics




Basic unit of execution within SystemC
Emulate the behavior of target device
Are triggered by clock edges and/or signal
expressions
Are not hierarchical


No process can directly call another
Processes communicate through signals
Winter-Spring 2001
Codesign of Embedded Systems
2
Process
Categories in SystemC



Method process
Thread process
CThread process
Winter-Spring 2001
Codesign of Embedded Systems
3
Method Process



Is called once, when events occur on its
sensitivity list
Cannot suspend execution (i.e. wait)
Returns control to the caller (SystemC
Kernel)
Winter-Spring 2001
Codesign of Embedded Systems
4
Method Example:
Packet Receiver
frame
rcv
id
void rcv::extract_id()
{
frame_type frame;
frame = xin;
if(frame.type==1)
id = frame.ida;
else
id = frame.idb;
#include “frame.h”
SC_MODULE(rcv) {
sc_in<frame_type> xin;
sc_out<int> id;
}
void extract_id();
SC_CTOR(rcv){
SC_METHOD(extract_id);
sensitive(xin);
}};
Winter-Spring 2001
Codesign of Embedded Systems
5
Thread Process


Declaration to SystemC kernel is the same as
Method process
Can be suspended and re-activated

wait() system call

Process is re-activated when an event occurs on process
SL (Sensitivity List)
Winter-Spring 2001
Codesign of Embedded Systems
6
Thread Example:
Traffic Light Controller
SC_MODULE(traff) {
sc_in<bool> roadsensor;
sc_in<bool> clock;
sc_out<bool>
sc_out<bool>
sc_out<bool>
sc_out<bool>
sc_out<bool>
sc_out<bool>
NSred;
NSyellow;
NSgreen;
EWred;
EWyellow;
EWgreen;
void control_lights();
Winter-Spring 2001
Road
Sensor
SC_CTOR(traff){
SC_THREAD(control_lights);
sensitive<<roadsensor;
sensitive_pos<<clock;
}
};
Codesign of Embedded Systems
7
Thread Example:
Traffic Light Controller (cont’d)
void traff::control_lights() {
NSred = NSyellow = false;
NSgreen = true;
EWred = true;
EWyellow = EWgreen = false;
while (true) {
while (roadsensor.delayed()
== false)
wait();
NSgreen = false;
NSyellow = true;
NSred = false;
for (i=0; i<5; i++)
wait();
Winter-Spring 2001
NSgreen = NSyellow = false;
NSred = true;
EWgreen = true;
EWyellow = EWred = false;
for (i= 0; i<50; i++)
wait();
NSgreen = NSyellow = false;
NSred = true;
EWgreen = false;
EWyellow = true;
EWred = false;
for (i=0; i<5; i++)
wait();
Codesign of Embedded Systems
8
Thread Example:
Traffic Light Controller (cont’d)
NSgreen = true;
NSyellow = NSred = false;
EWgreen = EWyellow = false;
EWred = true;
for (i=0; i<50; i++)
wait();


}
}

The Thread process is
the most general one
Implementing traff
module with Method
process requires
defining several states
Threads are slower than
Methods
Winter-Spring 2001
Codesign of Embedded Systems
9
Clocked Thread Process





The same as Thread, but is merely sensitive to edge
of one clock
Results in better descriptions to synthesize
One major use: Implicit state machine
Implicit state machine vs. Explicit state machine
Additional waiting mechanisms
 wait_until(<signal condition>) system call


Process is re-activated when the condition on the signals
hold
timed wait, wait until condition with timeout
(SystemC 2.0)
Winter-Spring 2001
Codesign of Embedded Systems
10
Clocked Thread Example:
Bus Controller
SC_MODULE(bus) {
sc_in_clk clock;
sc_in<bool> newaddr;
sc_in<sc_uint<32> > addr;
sc_in<bool> ready;
sc_out<sc_uint<32> > data;
sc_out<bool> start;
sc_out<bool> datardy;
sc_inout<sc_uint<8> >
data8;
sc_uint<32> tdata;
sc_uint<32> taddr;
addr 32
newaddr
data 32
start
Bus
Cntrlr
datardy
data8
ready
Mem
Cntrlr
SC_CTOR(bus) {
SC_CTHREAD(xfer,
clock.pos());
datardy = true;
}
void xfer();
};
Winter-Spring 2001
Codesign of Embedded Systems
11
Clocked Thread Example:
Bus Controller (cont’d)
void bus::xfer() {
while (true) {
wait_until(
newaddr.delayed() ==
true);
taddr = addr.read();
datardy = false;
data8 = taddr.range(7,0);
start = true;
wait();
data8 = taddr.range(15,8);
start = false;
wait();
data8 = taddr.range(23,16);
wait();
Winter-Spring 2001
data8 = taddr.range(31,24);
wait();
wait_until(ready.delayed()
== true);
tdata.range(7,0)=data8;
wait();
tdata.range(15,8)=data8;
wait();
tdata.range(23,16)=data8;
wait();
tdata.range(31,24)=data8;
data = tdata;
datardy = true;
}
}
Codesign of Embedded Systems
12
What we learned today

Process in SystemC



Methods
Threads
Clocked Threads
Winter-Spring 2001
Codesign of Embedded Systems
13
Complementary notes:
Assignments



DON’T FORGET
Subscribe to ce226list@ce.sharif.edu by sending an
email to majordomo@ce.sharif.edu containing
subscribe ce226list in the body.
Today is due date for Assignment 4
Take Assignment 5
Due date: Sat. Ordibehesht 8th
Winter-Spring 2001
Codesign of Embedded Systems
14
Complementary notes:
Final Projects

Titles









MP3 Encoder-Decoder
JPEG Encoder-Decoder
TCP/IP Sender-Receiver
ARM7 Processor
TMS32025 DSP
MPEG-2 Encoder
MPEG-2 Decoder
DES/ Tripple-DES/ RSA Encryption-Decryption
Your Suggestion
Winter-Spring 2001
Codesign of Embedded Systems
15
Complementary notes:
Final Projects (cont’d)


Today, choose your final project
First Report



Turn in a 1-2 page document of your references
Deadline: Sat. Ordibehesht 8th
Second Report


Prepare a PowerPoint presentation of algorithm or
architecture of your design
Deadline: Sat. Ordibehesht 22nd
Winter-Spring 2001
Codesign of Embedded Systems
16
Download