16
Winter-Spring 2001 Codesign of Embedded System s 1 Processes in SystemC Part of HW/SW Codesign of Embedded Systems Course (CE 40-226)

Winter-Spring 2001Codesign of Embedded Systems1 Processes in SystemC Part of HW/SW Codesign of Embedded Systems Course (CE 40-226)

Embed Size (px)

Citation preview

Page 1: Winter-Spring 2001Codesign of Embedded Systems1 Processes in SystemC Part of HW/SW Codesign of Embedded Systems Course (CE 40-226)

Winter-Spring 2001 Codesign of Embedded Syste

ms1

Processes inSystemC

Part ofHW/SW Codesign of

Embedded Systems Course (CE 40-226)

Page 2: Winter-Spring 2001Codesign of Embedded Systems1 Processes in SystemC Part of HW/SW Codesign of Embedded Systems Course (CE 40-226)

Winter-Spring 2001 Codesign of Embedded Syste

ms2

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

Page 3: Winter-Spring 2001Codesign of Embedded Systems1 Processes in SystemC Part of HW/SW Codesign of Embedded Systems Course (CE 40-226)

Winter-Spring 2001 Codesign of Embedded Syste

ms3

Process Categories in SystemC Method process Thread process CThread process

Page 4: Winter-Spring 2001Codesign of Embedded Systems1 Processes in SystemC Part of HW/SW Codesign of Embedded Systems Course (CE 40-226)

Winter-Spring 2001 Codesign of Embedded Syste

ms4

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)

Page 5: Winter-Spring 2001Codesign of Embedded Systems1 Processes in SystemC Part of HW/SW Codesign of Embedded Systems Course (CE 40-226)

Winter-Spring 2001 Codesign of Embedded Syste

ms5

Method Example:Packet Receiver

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

}};

void rcv::extract_id()

{

frame_type frame;

frame = xin;if(frame.type==1)

id = frame.ida;else

id = frame.idb;

}

rcvframe id

Page 6: Winter-Spring 2001Codesign of Embedded Systems1 Processes in SystemC Part of HW/SW Codesign of Embedded Systems Course (CE 40-226)

Winter-Spring 2001 Codesign of Embedded Syste

ms6

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)

Page 7: Winter-Spring 2001Codesign of Embedded Systems1 Processes in SystemC Part of HW/SW Codesign of Embedded Systems Course (CE 40-226)

Winter-Spring 2001 Codesign of Embedded Syste

ms7

Thread Example:Traffic Light Controller

SC_MODULE(traff) {

sc_in<bool> roadsensor;sc_in<bool> clock;

sc_out<bool> NSred;sc_out<bool> NSyellow;sc_out<bool> NSgreen;sc_out<bool> EWred;sc_out<bool> EWyellow;sc_out<bool> EWgreen;

void control_lights();

SC_CTOR(traff){

SC_THREAD(control_lights);

sensitive<<roadsensor;sensitive_pos<<clock;

}

};

RoadSensor

Page 8: Winter-Spring 2001Codesign of Embedded Systems1 Processes in SystemC Part of HW/SW Codesign of Embedded Systems Course (CE 40-226)

Winter-Spring 2001 Codesign of Embedded Syste

ms8

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

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

Page 9: Winter-Spring 2001Codesign of Embedded Systems1 Processes in SystemC Part of HW/SW Codesign of Embedded Systems Course (CE 40-226)

Winter-Spring 2001 Codesign of Embedded Syste

ms9

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

Page 10: Winter-Spring 2001Codesign of Embedded Systems1 Processes in SystemC Part of HW/SW Codesign of Embedded Systems Course (CE 40-226)

Winter-Spring 2001 Codesign of Embedded Syste

ms10

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)

Page 11: Winter-Spring 2001Codesign of Embedded Systems1 Processes in SystemC Part of HW/SW Codesign of Embedded Systems Course (CE 40-226)

Winter-Spring 2001 Codesign of Embedded Syste

ms11

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;

void xfer();

SC_CTOR(bus) {SC_CTHREAD(xfer,

clock.pos());

datardy = true;

}

};

BusCntrlr

MemCntrlr

addr 32newaddr start

data8ready

data 32

datardy

Page 12: Winter-Spring 2001Codesign of Embedded Systems1 Processes in SystemC Part of HW/SW Codesign of Embedded Systems Course (CE 40-226)

Winter-Spring 2001 Codesign of Embedded Syste

ms12

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

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;

}

}

Page 13: Winter-Spring 2001Codesign of Embedded Systems1 Processes in SystemC Part of HW/SW Codesign of Embedded Systems Course (CE 40-226)

Winter-Spring 2001 Codesign of Embedded Syste

ms13

What we learned today Process in SystemC

Methods Threads Clocked Threads

Page 14: Winter-Spring 2001Codesign of Embedded Systems1 Processes in SystemC Part of HW/SW Codesign of Embedded Systems Course (CE 40-226)

Winter-Spring 2001 Codesign of Embedded Syste

ms14

Complementary notes:Assignments DON’T FORGET

Subscribe to [email protected] by sending an email to [email protected] containing subscribe ce226list in the body.

Today is due date for Assignment 4 Take Assignment 5

Due date: Sat. Ordibehesht 8th

Page 15: Winter-Spring 2001Codesign of Embedded Systems1 Processes in SystemC Part of HW/SW Codesign of Embedded Systems Course (CE 40-226)

Winter-Spring 2001 Codesign of Embedded Syste

ms15

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

Page 16: Winter-Spring 2001Codesign of Embedded Systems1 Processes in SystemC Part of HW/SW Codesign of Embedded Systems Course (CE 40-226)

Winter-Spring 2001 Codesign of Embedded Syste

ms16

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