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

3 SC Process

This document discusses different types of processes in SystemC including SC_METHOD, SC_THREAD, and SC_CTHREAD. SC_METHOD processes are called once when events occur on their sensitivity list and cannot suspend execution. SC_THREAD processes can suspend using wait() and have an infinite loop. SC_CTHREAD processes are similar to SC_THREAD but are only sensitive to a clock edge. The document provides examples of each type of process and explains their usage and semantics. It also covers watching signals and local watching using macros.

Uploaded by

rohanpatilpa
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)
56 views14 pages

3 SC Process

This document discusses different types of processes in SystemC including SC_METHOD, SC_THREAD, and SC_CTHREAD. SC_METHOD processes are called once when events occur on their sensitivity list and cannot suspend execution. SC_THREAD processes can suspend using wait() and have an infinite loop. SC_CTHREAD processes are similar to SC_THREAD but are only sensitive to a clock edge. The document provides examples of each type of process and explains their usage and semantics. It also covers watching signals and local watching using macros.

Uploaded by

rohanpatilpa
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

SystemC Processes

Rolf Drechsler
Daniel Groe
University of Bremen

Process Basics
l
l
l

Basic unit of Parallel execution


Sequential in the process
Executed concurrently

Processes are not hierarchical


Processes have sensitive list
Processes are triggered (called) by event on sensitivity list
Can call methods or functions that are not processes

Types of processes

Method : SC_METHOD
Thread : SC_THREAD
Clocked thread : SC_CTHREAD

SC_METHOD
l
l
l
l

Is called once, when events occur on its


sensitivity list
Cannot suspend execution
Returns control to the caller (SystemC Kernel)
Sensitivity list is specified in the module
constructor

SC_METHOD - Example
frame

rcv

// rcv.h
#include frame.h
SC_MODULE(rcv) {
sc_in<frame_type> xin;
sc_out<int> id;

id
// rcv.cc
void rcv::extract_id()
{
frame_type frame;
frame = xin;

void extract_id();

};

SC_CTOR(rcv) {
SC_METHOD(extract_id);
sensitive<<xin;
}

if(frame.type==1)
id = frame.ida;
else
id = frame.idb;

SC_THREAD
l

Can be suspended and reactivated

l
l
l

Suspend using wait()


Process is reactivated when an event occurs on
process sensitivity list

Has infinite loop


Most general process
Slower than SC_METHOD processes

SC_THREAD Example (1)


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>

Road
Sensor

NSred;
NSyellow;
NSgreen;
EWred;
EWyellow;
EWgreen;

void control_lights();
SC_CTOR(traff){
SC_THREAD(control_lights);
sensitive<<roadsensor;
sensitive_pos<<clock;
}

Sensitive to road sensor and clock

};

SC_THREAD Example (2)


void traff::control_lights() {
// default: NS green, EW read
NSred = NSyellow = false; NSgreen = true;
EWred = true; EWyellow = EWgreen = false;
while (true) {
while (roadsensor.delayed() == false) wait();
// road sensor triggered, set NS to yellow
NSred = false; NSyellow = true; NSgreen = false;
for (i=0; i<5; i++) wait();
// NS yellow intervall over, set NS red and EW green
NSred = true; NSgreen = NSyellow = false;
Ewred = EWyellow = false; EWgreen = true;
for (i=0; i<50; i++) wait();

Road
Sensor

SC_THREAD Example (3)


// EW yellow
EWred = false; EWyellow = true; EWgreen = false;
for (i=0; i<5; i++) wait();
// EW red, NS green
Nsred = NSyellow = false; Nsgreen = true;
Ewred = true; EWyellow = EWgreen = true;
// interval before allowing a sensor again
for (i=0; i<50; i++) wait();
} // end of infinite while loop
}

Road
Sensor

SC_CTHREAD
l
l
l

The same as SC_THREAD, but is only sensitive to


edge of one clock
Results in better descriptions to synthesize
Additional waiting mechanisms
wait_until(<signal condition>) system call
l

Process is reactivated when the condition on the


signals hold

timed wait, wait until condition with timeout


(SystemC 2.0)

Processes, Type of
Process Type

SC_METHOD

SC_THREAD

SC_CTHREAD

Exec. Trigger

Signal Events

Signal Events

Clock Edge

Exec.
Suspend

NO

YES

YES

Infinite Loop

NO

YES

YES

Suspend /
Resume by

N.A.

wait()

wait()
wait_until(bool-sign.-cond.)

Construct &
Sensitize
Method

SC_METHOD(p);
sensitive(signals);
sensitive_pos(signals);
sensitive_neg(signals
);

SC_THREAD(p);
sensitive(signals);
sensitive_pos(signals);
sensitive_neg(signals);

SC_CTHREAD(p, clock.pos());
SC_CTHREAD(p, clock.neg());

Watching (1)
l
l

Break infinite loop (SC_THREAD, SC_CTHREAD)


Watching construct monitor a specified condition
SC_CTOR(test)
{
SC_CTHREAD(do_test, clk.pos());

}
l

watching(reset.delayed()==true); // Watching : monitor signal reset

Process method has infinite loop:


void test::do_test()
{

if (reset==true) { // Watching : Initialized by monitored signal reset


// reset action
}

while (true) // Infinite loop


{
// Normal process function
}

Watching (2)
l

Watching signal

Use delay() to identify watching signal


Must be bool type
Watching condition is tested at every active edge

Process method

Behave as functions in programming language,


when watching condition is true.
l
l

Start from beginning of function


Local variables will lose their values

Local Watching (1)


l
l

Specify watching in the process


Use 4 macros :

W_BEGIN : Marks local watching section begin


W_DO : Process functionality
W_ESCAPE : Watched event handler
W_END : End of watching section

Notes about local watching

Watched events has same priority.


Local watching block can be nested for priority.
Works only in the SC_CTHREAD process.
Watched signals are sampled only on active edge of clock.
Global watching has higher priority than local watching.

Local Watching (2)


W_BEGIN // put watching condition here
watching(reset.delayed() == true);
watching(in1.delayed() && in2.delayed() == true);

W_DO // process functionality (watched code sequence)

W_ESCAPE // handlers for watched events


if (reset) { }
If (in1 && in2) { }

W_END // End of watching section

You might also like