Docsity

ECE 747 Digital Signal Processing Architecture Lecture, Study notes of Electrical and Electronics Engineering

Toggle sidebar
bg1
Spring 2007W. Rhett Davis NC State University ECE 747 Slide 1
ECE 747
ECE 747
Digital Signal Processing Architecture
Digital Signal Processing Architecture
SoC
SoC Lecture
Lecture –
–
Introduction to
Introduction to SystemC
SystemC
February 6, 2007
February 6, 2007
W. Rhett Davis
W. Rhett Davis
(with lots of help from Ramsey
(with lots of help from Ramsey Hourani
Hourani)
)
NC State University
NC State University
Spring 2007W. Rhett Davis NC State University ECE 747 Slide 2
Prerequisites
zThis lecture assumes a basic
understanding of C++ and Verilog-2001
»For more information on Verilog, see
–http://www.sutherland-hdl.com/
on-line_ref_guide/vlog_ref_top.html
»For more information on Verilog-2001, see
–http://sutherland-hdl.com/papers/
2000-HDLCon-paper_Verilog-2000.pdf
»For more information on C++, see
–http://www.cplusplus.com
→Documentation →C++ Language Tutorial
Spring 2007W. Rhett Davis NC State University ECE 747 Slide 3
Today’s Lecture
zVerilog RTL Version of an FIR Filter
zIntroduction to SystemC
zSystemC RTL Version of an FIR Filter
Spring 2007W. Rhett Davis NC State University ECE 747 Slide 4
Direct Form FIR Filter
pf3
pf4
pf5
pf8

Partial preview of the text

Download ECE 747 Digital Signal Processing Architecture Lecture and more Study notes Electrical and Electronics Engineering in PDF only on Docsity!

Spring 2007

NC State University

ECE 747

Slide 1

ECE 747ECE 747

Digital Signal Processing ArchitectureDigital Signal Processing Architecture

SoC LectureSoC

Lecture –

Introduction to SystemCIntroduction to

SystemC

February 6, 2007February 6, 2007W. Rhett DavisW. Rhett Davis

(with lots of help from Ramsey Hourani(with lots of help from Ramsey

Hourani)

NC State UniversityNC State University

Spring 2007

W. Rhett Davis

NC State University

ECE 747

Slide 2

Prerequisites

z^ This lecture assumes a basicunderstanding of C++ and Verilog-2001^ »^

For more information on Verilog, see– http://www.sutherland-hdl.com/on-line_ref_guide/vlog_ref_top.html » For more information on Verilog-2001, see– http://sutherland-hdl.com/papers/2000-HDLCon-paper_Verilog-2000.pdf » For more information on C++, see– http://www.cplusplus.com^ →

Documentation

→^ C++ Language Tutorial

Spring 2007

NC State University

ECE 747

Slide 3

Today’s Lecture

z^ Verilog RTL Version of an FIR Filter z^ Introduction to SystemC z^ SystemC RTL Version of an FIR Filter

Spring 2007

W. Rhett Davis

NC State University

ECE 747

Slide 4

Direct Form FIR Filter

Spring 2007

NC State University

ECE 747

Slide 5

Design Hierarchy-1^ Z^ b(k)

yk

cell 0^

cell 1^

cell 2^

cell L-^

cell L-

r^ km1 s^ km

r^ k s^ k

FIR_cascade^ FIR_cell

16 bits for

rk^ values

32 bits for

sk^ values

Spring 2007

W. Rhett Davis

NC State University

ECE 747

Slide 6

RTL Code for FIR_cell (1)

  • module FIR_cell

#(parameter

rw=16,

sw=32,

bw=16)

-^ (input

[rw-1:0]

rkm1,

input

[sw-1:0]

skm1,

input

[bw-1:0]

bk,

•^

input^

clock,

reset,

output

reg^ [rw-1:0]

rk,^ output

[sw-1:0]

sk);

-^ wire

[sw-1:0]

rkm1_ext,

bk_ext;

-^ assign

rkm1_ext={{sw-rw{rkm1[rw-1]}},rkm1};

-^ assign

bk_ext={{sw-bw{bk[bw-1]}},bk};

-^ assign

sk=(rkm1_ext*bk_ext)+skm1;

z^ Why do we define the signals

rkm1_ext

and^

bk_ext

Spring 2007

NC State University

ECE 747

Slide 7

RTL Code for FIR_cell (2)

-^ always@(posedge

clock)

-^ if

(reset)

-^

rk<=0;

-^ else •^

rk<=rkm1;

• endmodule z^ Is this a synchronous or asynchronous reset?

Spring 2007

W. Rhett Davis

NC State University

ECE 747

Slide 8

RTL Code for FIR_cascade (1) • module^ FIR_cascade

#(parameter

b_Len=9,

rw=16,

sw=32,

bw=16)

•^

(input

[rw-1:0]

xk,^ input

[b_Len*bw-1:0]

bk,^ input

clock,

•^

reset,

output

[sw-1:0]

yk);

-^ wire

[sw-1:0]

gnd =

-^ wire

[b_Len*rw-1:0]

r;

-^ wire

[(b_Len-1)*sw-1:0]

s;

z^ Why are the dimensions of

bk ,^ r

, and

s

multiplied by b_Len?

Spring 2007

NC State University

ECE 747

Slide 13

Parts of a Verilog Module

z^ Header:

module <module_name> (<port_list>);

z^ Parameter, Port, & Internal Variable declarations z^ Functionality description^ »^

Structural– Instantiations of basic gates– Instantiations of lower-level modules » Behavioral– Data-Flow (continuous assignments)– Procedural (initial & always blocks)

z^ Terminator:

endmodule

Spring 2007

W. Rhett Davis

NC State University

ECE 747

Slide 14

Parts of a SystemC Module z Declaration: class

<module_name>: sc_module

»^ Port & Internal Variable declarations »^ Instance & Process declarations z Constructor »^ Structural Functionality Description– Instantiations of lower-level modules »^ Procedural Functionality Description– Process re-declaration (thread & method processes) z Procedural Functionality Description »^ Process Definitions

Spring 2007

NC State University

ECE 747

Slide 15

Declaring a module in SystemC z Modules in SystemC are classes that arederived from the

sc_module

class

z^ You will often see the macroSC_MODULE, which is replaced with thecode above at compile time

class FIR_cascade : sc_module{ SC_MODULE(FIR_cascade){

Spring 2007

W. Rhett Davis

NC State University

ECE 747

Slide 16

Declaring Ports

z^ Ports are member instances of classesderived from

sc_port

(such as

sc_in

and

sc_out

sc_out<

sc_uint<32>

>^ yk;

sc_in<

sc_uint<16>

>^ xk,

sc_in<

sc_uint<16>

>^ bk[9];

sc_in

clock,

reset;

note that arrays of portsare legal in SystemC

sc_uint<>

types are used to model arbitrary word lengths

(see chapter 7 of the IEEE 1666-2005 standard for more)see the cplusplus.comtutorial on

Templates

Spring 2007

NC State University

ECE 747

Slide 17

Declaring Internal Variables z Internal Variables (like

wire

and^

reg^ variables in

Verilog) are member instances of other classes^ »^ If the variable will be used with proceduraldescriptions (

i.e.^ processes), then the basic data type

may be declared. » If the variable will be used with structural descriptions( i.e.^ instantiations) or sensitivity lists, then it must bedeclared as an

sc_signal<>

type.

sc_signal<

sc_uint<16>

>^ r[9];

sc_signal<

sc_uint<32>

>^ s[9];

sc_uint<16>

r[9];

sc_uint<32>

s[9];

Spring 2007

W. Rhett Davis

NC State University

ECE 747

Slide 18

Declaring Instances & Processes z Instances of lower-level modules must havemember variables to access them z SystemC processes are like

always

blocks in

Verilog^ »^ They are essentially class methods with noarguments or return value^ »^ They must be declared in the class definition

FIR_cell

*cell[9];

void^

unit_delay

Spring 2007

NC State University

ECE 747

Slide 19

Parts of a SystemC Module z Declaration: class

<module_name>: sc_module

»^ Port & Internal Variable declarations »^ Instance & Process declarations z Constructor »^ Structural Functionality Description– Instantiations of lower-level modules »^ Procedural Functionality Description– Process re-declaration (thread & method processes) z Procedural Functionality Description »^ Process Definitions

Spring 2007

W. Rhett Davis

NC State University

ECE 747

Slide 20

Constructor Declaration

z^ Before the constructor is declared, the typeSC_CURRENT_USER_MODULE is defined to the current modulename^ »^

This type is used during process re-declaration

z^ SystemC defines the macro

SC_CTOR

to represent this code more

conveniently z SystemC Also defines the macro

SC_HAS_PROCESS

to represent

only the

typedef

statement

typedef » This is helpful if the constructor needs extra arguments, as is the casewith parameterized modules

FIR_cascade

SC_CURRENT_USER_MODULE;

FIR_cascade(sc_module_name)SC_CTOR(FIR_cascade)SC_HAS_PROCESS(FIR_cascade);FIR_cascade(sc_module_name)

Spring 2007

NC State University

ECE 747

Slide 25

Today’s Lecture

z^ Verilog RTL Version of an FIR Filter z^ Introduction to SystemC z^ SystemC RTL Version of an FIR Filter

Spring 2007

W. Rhett Davis

NC State University

ECE 747

Slide 26

RTL Code for FIR_cell.h #include^ "systemc.h

SC_MODULE

(FIR_cell) {sc_out<

sc_uint<16>

^ rk;

sc_out<

sc_uint<32>

^ sk;

sc_in<

sc_uint<16>

^ rkm1,

bk;

sc_in<

sc_uint<32>

^ skm1;

sc_in

clock,

reset;

void unit_delay

void^ mult_add

SC_CTOR

(FIR_cell) {SC_METHOD(unit_delay);sensitive_pos

<<^ clock; SC_METHOD(mult_add);sensitive

<<^ rkm

<<^ skm

<<^ bk;

Spring 2007

NC State University

ECE 747

Slide 27

RTL Code for FIR_cell.cc #include "FIR_cell.h"void FIR_cell::unit_delay (){ if (reset.read()) {rk = 0;}else {rk = rkm1.read();}} void FIR_cell::mult_add (){sc_uint<32> tmp;tmp=(sc_int<16>)rkm1.read()*(sc_int<16>)bk.read();sk=tmp+skm1.read();}

Spring 2007

W. Rhett Davis

NC State University

ECE 747

Slide 28

RTL Code for FIR_cascade.h (1)^ • #include

"systemc.h"

  • #include

"FIR_cell.h"

  • #include

<stdio.h>

//^ to

define

sprintf()

• SC_MODULE

(FIR_cascade)

  • { •^ sc_out<

sc_uint<32>

^ yk;

-^ sc_in<

sc_uint<16>

^ xk,

bk[9];

-^ sc_in

clock,

reset;

-^ sc_signal<

sc_uint<16>

^ r[9];

-^ sc_signal<

sc_uint<32>

^ s[9],

gnd;

-^ FIR_cell

*cell[9];

Spring 2007

W. Rhett Davis

NC State University

ECE 747

Slide 29

RTL Code for FIR_cascade.h (2)

SC_CTOR (FIR_cascade){int i;char

buf[9];gnd=0;for (i=0;^

i<9;^ i++)

sprintf(buf,"cell[%d]",i);cell[i]

=^ new

FIR_cell(buf); if^ (i==0)

cell[i]

->^ rk(r[i]); cell[i]

->^ sk(s[i]); cell[i]

->^ rkm1(xk); cell[i]

->^ skm1(gnd); cell[i]

->^ bk(bk[i]); cell[i]

->^ clock(clock); cell[i]

->^ reset(reset);

}^ else

if^ (i==8)

cell[i]

->^ rk(r[i]); cell[i]

->^ sk(yk); cell[i]

->^ rkm1(r[i-1]); cell[i]

->^ skm1(s[i-1]); cell[i]

->^ bk(bk[i]); cell[i]

->^ clock(clock); cell[i]

->^ reset(reset); }else^ {cell[i]

->^ rk(r[i]); cell[i]

->^ sk(s[i]); cell[i]

->^ rkm1(r[i-1]); cell[i]

->^ skm1(s[i-1]); cell[i]

->^ bk(bk[i]); cell[i]

->^ clock(clock); cell[i]

->^ reset(reset); }}}

Spring 2007

W. Rhett Davis

NC State University

ECE 747

Slide 30

Questions

z^ Why does FIR_cell have two processes? z^ Why is there no FIR_cascade.cc file? z^ In practice, would we want to write a SystemCdescription like this one?