Documente Academic
Documente Profesional
Documente Cultură
Contents
q
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Background & Basics m System-on-Chip Design m C/C++ Based System Design m The SystemC Approach m SystemC Licensing Model m Open SystemC Community Introduction to SystemC 1.0 m Modules & Hierarchie m Processes m Ports & Signals m Data Types & Fixed Point Data Types Design Example A m Simple 2-Process Scenario
System-on-Chip Design with SystemC 1
Joachim Gerlach
Joachim Gerlach
Contents
q
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Design Example B m JPEG Compression / Decompression Stream Design Activities m Modeling m Simulation m Debugging Tool Support m Synopsys: SystemC Compiler m CoWare: N2C m C-Level Design: System Compiler m Frontier Design: A xRT Builder Outlook to SystemC 1.1
System-on-Chip Design with SystemC 2
Joachim Gerlach
Joachim Gerlach
SYSTEMC
TM
Productivity Gap
complexity [gates]
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1 1G 256M 100M 10M 1M 256K 100K 16K 10K 1K 4K 8008 8080 1980 1990 64K 8088 1M 486DX 386DX memory processors 4M Pentium II Pentium (0,35 m)
(0,8 m)
/ chip
productivity gap
(source: ICE) 2000
1K 1970
gates / day
Wolfgang Rosenstiel
1980
1990
2000
time
Joachim Gerlach
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Multiple design domains: hardware, software, analog, ... Multiple source components: DSPs, ASICs, IP-Cores, ... Hard constraints: realtime, low power, ...
Wolfgang Rosenstiel
Joachim Gerlach
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Wolfgang Rosenstiel
hardware architecture
software architecture
Joachim Gerlach
Productivity aspect
m
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Specification between architect and implementer is executable High speed and high level simulation and prototyping Refinement, no translation into hardware (no semantic gap)
m m q
Tomorrows systems designers will be designing mostly C/C++ software and less hardware ! Co-design, co-simulation, co-verification, co-debugging, ...
System aspect Architect Marketing & Sales
HDL
m q
Re-use
m m
SoC Design
Wolfgang Rosenstiel
Joachim Gerlach
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Signals, protocols
Notion of time
l
Concurrency
l
Reactivity
l
Hardware is inherently reactive, responds to stimuli, interacts with its environment ( requires handling of exceptions)
m
Wolfgang Rosenstiel
Bit type, bit-vector type, multi-valued logic types, signed and unsigned integer types, fixed-point types
Joachim Gerlach
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
C
synthesizable subset of C synthesizable subset of C++
C++
new language constructs (HardwareC, C*) library based approach (SystemC, Cynlib)
m
Wolfgang Rosenstiel
notion of time
synthesizable subset
concurrency
reactivity
Joachim Gerlach
The Gap
m m
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Tomorrows systems designers will be designing mostly software and little hardware A software language is not capable of describing concurrency, clocks, hardware data types, reactivity
Requirements
m m m m
Allow hardware/software co-design and co-verification Fast simulation for validation and optimization Smooth path to hardware and software Support of design and architectural re-use
Joachim Gerlach
Joachim Gerlach
10
What is SystemC ?
q
A library of C++ classes m Processes (for concurrency) m Clocks (for time) m Modules, ports, signals (for hierarchy) m Waiting, watching (for reactivity) m Hardware data types A modeling style m ... for modeling systems consisting of multiple design domains, abstraction levels, architectural components, real-life constraints A light-weight simulation kernel m ... for high-speed cycle-accurate simulation
q
Design Activities Tool Support SystemC 1.1
q
Joachim Gerlach
Joachim Gerlach
11
System
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
C/C++ Testbench
Modeling Constructs
SystemC
Joachim Gerlach
Joachim Gerlach
12
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
system architect
C/C++
HDL
Wolfgang Rosenstiel
hardware designer
Joachim Gerlach
13
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
hardware designer
C/C++
Wolfgang Rosenstiel
5. understand specification 6. refine in C/C++ 7. validate re-using testbenches 8. synthesize from C/C++
Joachim Gerlach
14
The requirements...
m
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Fast system modeling containing multiple source components Model once for multiple abstraction level, multiple users, multiple purposes
The problem...
m
The approach...
m
Promote a standard C/C++ based modeling platform ... to model and exchange system level components and IP ... to build interoperable tools infrastructure
Wolfgang Rosenstiel
Joachim Gerlach
15
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Specification between architect and implementer is executable High simulation speed at higher level of abstraction Refinement, no translation into HDL (no semantic gap) Efficient testbench re-use
C/C++
m m m
System Architect
C/C++
SoC Design
Software Designer Hardware Designer
Wolfgang Rosenstiel
Joachim Gerlach
16
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
S Y S T E M
TM
is...
... a methodology for modeling SoC designs consisting of ... DSPs, ASICs, IP-Cores, Interfaces, ... ... a C++ library extending C/C++ by concurrency, timing, ... reactivity, communication, signal / data types, ... ... a cycle-accurate high-speed simulation
Wolfgang Rosenstiel
Joachim Gerlach
17
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
ASIC
....
........
source files for system and testbenches
make
e abl on t u ec icati x e ecif sp
a.out
Wolfgang Rosenstiel
executable = simulation
Joachim Gerlach
18
(Sync. and async. processes) (Multiple clocks with arbitrary phase relation) (Bit vectors, arbitrary precision integers, ...)
v1.0: arbitrary precision fixed point data types
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
(Signals, channels)
v1.0: advanced communication protocols
q q q q q
Simulation support Support of multiple abstraction levels and iterative refinement Support of functional model creation ....
System-on-Chip Design with SystemC 19
Wolfgang Rosenstiel
Joachim Gerlach
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Steering Group
SystemC v0.9
including:
download
www.SystemC.org
Wolfgang Rosenstiel
User
Joachim Gerlach
20
ARM Cadence CoWare Ericsson Fujitsu Microelectronics Infineon Technologies Lucent Technologies Motorola NEC Sony Corporation STMicroelectronics Synopsys Texas Instruments
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
q q q q q q q q q q q
Wolfgang Rosenstiel
Joachim Gerlach
21
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
American Applied Research Aptix Arcadia Design Systems ARC Cores Aristo Technology ARM Billions of Operations Per Second CAE Plus Chameleon Systems Co-Design Automation CoWare CSELT Denali Ericsson Frequency Technology Frontier Design
Wolfgang Rosenstiel
Joachim Gerlach
22
Community members
m
No licensing fees, anybody / any company is free and welcome to join the community Right and responsability to contribute enhancements Designers can create and share models with other companies, EDA vendors can build SystemC based tools
m m
q
Design Activities Tool Support SystemC 1.1
Steering Group
m m
Drives convergence and interoperability Ensures open evolution and structured innovation
Goal:
m m
Wolfgang Rosenstiel
Make SystemC a de-facto-standard for system-level design Provide a foundation to build a market upon
System-on-Chip Design with SystemC 23
Joachim Gerlach
SystemC
q
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Scenery
Wolfgang Rosenstiel
Joachim Gerlach
24
SystemC
q
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Communication platform for SystemC users take a look at: Information flow between SystemC users und Steering Group www-ti.informatik.uni-tuebingen.de/~systemc Acceleration of SystemC evolution and standardization Events:
FDL2000 European SystemC Users Group Conference (with DATE2001) 3rd European SystemC Users Group Meeting
Wolfgang Rosenstiel
2000
January 31 2000 March 28 June 30 September 4-8 2000 2000 2000
2001
March 12-16 2001
Joachim Gerlach
25
SYSTEMC
TM
SystemC 1.0
University of Tbingen Wilhelm-Schickard-Institut Department of Computer Engineering
Modules
q q
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Modules are basic building blocks of a SystemC design A module contains processes ( functionality) and/or sub-modules ( hierarchical structure)
SC_MODULE( module_name ) { // Declaration of module ports // Declaration of module signals // Declaration of processes // Declaration of sub-modules SC_CTOR( module_name ) { // Module constructor // Specification of process type and sensitivity // Sub-module instantiation and port mapping } // Initialization of module signals };
Joachim Gerlach
Joachim Gerlach
27
Modules
q
A module correspond to a C++ class class data members ports class member functions processes class constructor process generation .....
SC_MODULE( module_name ) { ..... };
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Joachim Gerlach
Joachim Gerlach
28
Ports
q q
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
q q
External interface of a module Passing data from and to processes / sub-modules Triggering of actions within the module A ports has a mode (direction) and a type mode: in, out, inout type: C++ type, SystemC type, user-defined type
// input port declaration sc_in< type > in_port_name; // output port declaration sc_out< type > out_port_name; // bidirectional port declaration sc_inout< type > inout_port_name;
Joachim Gerlach
Joachim Gerlach
29
Signals
q q
q q
Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Connects a port of one module to the port of another module Local to a module Signal semantics is the same as VHDL and Verilog deferred assignment semantics A signal has a type type: C++ type, SystemC type, user-defined type
// signal declaration sc_signal< type > signal_name;
q
Joachim Gerlach
Internal data storage not by signals but by local variables Local variable types: C++ types, SystemC types, user-defined types
Joachim Gerlach
30
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Ports and signals to be bound need to have the same type A signal connects two ports A port is bound to one signal (port-to-signal) or to one sub-module port (port-to-port)
Resolution m SystemC supports resolved ports and signals m Resolved ports/signals have 4-valued logic type (0,1,Z,X) m Resolved ports/signals allow multiple drivers m Resolved vector ports/vector signals
sc_in_rv< n > x; sc_signal_rv< n> y; // n bits wide resolved input port // n bits wide resolved signal
Joachim Gerlach
Joachim Gerlach
31
Clocks
q q
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support
q q
SystemC provides a special object sc_clock Clocks generate timing signals to synchronize events Multiple clocks with arbitrary phase relations are supported Clock generation:
sc_clock clock_name (label, period, duty_ratio, offset, start_value);
Example:
q
SystemC 1.1
Clock binding:
Example:
my_module.clk( my_clk.signal() );
Joachim Gerlach
Joachim Gerlach
32
Data Types
q
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
SystemC supports m Native C/C++ types m SystemC types m User-defined types SystemC types m 2-value (0, 1) logic / logic vector m 4-value (0, 1, Z, X) logic / logic vector m Arbitrary sized integer (signed/unsigned) m Fixed point types (signed/unsigned, templated/untemplated)
Joachim Gerlach
Joachim Gerlach
33
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Integer types: m char m unsigned char m short m unsigned short m int m unsigned int m long m unsigned long Floating point types m float m double m long double
Joachim Gerlach
Joachim Gerlach
34
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
sc_bit sc_logic sc_int sc_uint sc_bigint sc_biguint sc_bv sc_lv sc_fixed sc_ufixed sc_fix sc_ufix
Joachim Gerlach
Joachim Gerlach
35
sc_bit / sc_logic
q
2-value single bit type: sc_bit m 0=false, 1=true 4-value single bit type: sc_logic m 0=false, 1=true, X=unknown/indeterminate value, Z=high-impedance/floating value Features: m Mixed use of operand types sc_bit and sc_logic m Use of character literals for constant assignments
sc_bit / sc_logic operators Bitwise Assignment Equality & (and) = == | (or) &= != ^ (xor) |= ~ (not) ^=
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Joachim Gerlach
Joachim Gerlach
36
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Fixed precision integer types m Signed: tsc_int<n> (n: word length, 1 n 64) m Unsigned: sc_uint<n> (n: word length, 1 n 64) Arbitrary precision integer types m Signed: tsc_bigint<n> (n: word length, n > 64) m Unsigned: sc_biguint<n> (n: word length, n > 64) Features: m Mixed use of operand types sc_int, sc_uint, sc_bigint, sc_biguint and C++ integer types m Truncation and/or sign extension if required m 2s complement representation
Joachim Gerlach
Joachim Gerlach
37
sc_int / sc_uint / sc_bigint / sc_biguint operators Bitwise Arithmetic Assignment Equality Relational Auto-Ink/Dek Bit/Part Select Concatenation & + = == < ++ [] (,) | ^ * += -= != <= > -range() ~ / *= >= >> % /= << %= &= |= ^=
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Joachim Gerlach
Joachim Gerlach
38
sc_bv / sc_lv
q q
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Arbitrary length logic vector: sc_lv<n> (n: vector length) Features: m Assignment between sc_bv and sc_lv m Use of string literals for vector constant assignments m Conversions between sc_bv/sc_lv and SystemC integer types m No arithmetic operation available
q sc_bv / sc_lv
Joachim Gerlach
& | ^ ~ >> << = += -= *= /= %= &= |= ^= == != [] range() (,) and_reduction() or_reduction() xor_reduction() to_string()
System-on-Chip Design with SystemC 39
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
templated - static arguments (to be known at compile time) untemplated - nonstatic arguments (to be configured during runtime) signed unsigned - 2s complement representation
Joachim Gerlach
Features: m Operations performed using arbitrary precision m Multiple quantization and overflow modes
Joachim Gerlach
40
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
- total number of bits - number of integer bits - quantization mode (optional) - overflow_mode (optional) - number of bits for overflow mode (optional)
Joachim Gerlach
Joachim Gerlach
41
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Joachim Gerlach
integer bits
fractional bits
Joachim Gerlach
42
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Joachim Gerlach
Joachim Gerlach
43
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Joachim Gerlach
class complex { private: double re; double im; public: complex () {`re=0.0; im=0.0; } complex (double r, double i) {`re=r; im=i; } void set(double r, double i) { re=r; im=i; } double get_re() { return re; } double get_im() { return im; } int..... int operator== (const complex &c) const { }; if ( ( re == c.re ) && ( im == c.im() ) ) return 1; else return 0; } }; System-on-Chip Design with SystemC 44
Joachim Gerlach
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
sig3
Joachim Gerlach
Joachim Gerlach
45
Example:
alu plus
a b i1 o1 i2 e
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
SC_MODULE( plus ) { sc_in<int> i1; sc_in<int> i2; sc_out<int> o1; ..... }; SC_MODULE( minus ) { sc_in<int> i1; sc_in<int> i2; sc_out<int> o1; ..... };
SC_MODULE( alu ) { sc_in<int> a; sc_in<int> b; sc_in<int> c; sc_out<int> d; plus *p; minus *m; sc_signal<int> e; SC_CTOR( alu ) { p = new plus ( "PLUS ); p->i1 (a); p->i2 (b); p->o1 (e); m = new minus ( "MINUS ); (*m) (e,c,d); } };
minus
c i1 o1 i2 d
d=(a+b)-c
Joachim Gerlach
Joachim Gerlach
46
Processes
q
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Process Semantics m Encapsulates functionality m Basic unit of concurrent execution m Not hierarchical Process Activation m Processes have sensitivity lists m Pocesses are triggered by events on sensitive signals Process Types m Method (SC_METHOD)
asynchronous block, like a sequential function
m
Thread (SC_THREAD)
asynchronous process
Joachim Gerlach
Joachim Gerlach
Processes
SC_METHOD triggered infinite loop execution suspend suspend & resume construct & sentisize method by signal events no no SC_METHOD(p); sensitive( s); sensitive_pos(s); sensitive_neg(s); SC_THREAD by signal events yes yes wait() SC_THREAD(p); sensitive( s); sensitive_pos(s); sensitive_neg(s); sequential logic at RT level (asynchronous reset, etc.) SC_CTHREAD by clock edge yes yes wait() wait_until() SC_CTHREAD (p,clock.pos()); SC_CTHREAD (p,clock.neg()); sequential logic at higher design levels
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Joachim Gerlach
Joachim Gerlach
48
Processes
q
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
plus
i1 o1 i2
Joachim Gerlach
o1 = i1 + i2
Joachim Gerlach
49
Processes
q
Example: SC_METHOD
SC_MODULE( plus ) { sc_in<int> i1; sc_in<int> i2; sc_out<int> o1; void do_plus(); void plus::do_plus() { int arg1; int arg2; int sum; arg1 = i1.read(); arg2 = i2.read(); sum = arg1 + arg2; o1.write(sum); }
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Joachim Gerlach
Joachim Gerlach
50
Processes
q
Example: SC_THREAD
SC_MODULE( plus ) { sc_in<int> i1; sc_in<int> i2; sc_out<int> o1; void do_plus(); void plus::do_plus() { int arg1; int arg2; int sum; while ( true ) { arg1 = i1.read(); arg2 = i2.read(); sum = arg1 + arg2; o1.write(sum); wait(); } }
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Joachim Gerlach
Joachim Gerlach
51
Processes
q
Example: SC_CTHREAD
SC_MODULE( plus ) { sc_in_clk clk; sc_in<int> i1; sc_in<int> i2; sc_out<int> o1; void do_plus(); SC_CTOR( plus ) { SC_CTHREAD( do_plus, clk.pos() ); } }; } void do_plus() { int arg1; int arg2; int sum; while ( true ) { arg1 = i1.read(); arg2 = i2.read(); sum = arg1 + arg2; o1.write(sum); wait(); }
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Joachim Gerlach
Joachim Gerlach
52
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Suspend / reactivate process execution (SC_THREAD, SC_CTHREAD) m Suspension: wait() m Reactivation: event on a sensitive signal Halt process execution until an event occurs m wait_until ( my_bool_sig.delayed() == true )
(SC_CTHREAD only)
Transfer control to a special code sequenze if a specified condition occurs m watching ( reset .delayed() == true ) m Typical example: watching for reset signal
m
Global watching:
(SC_THREAD, SC_CTHREAD)
- watching condition specified in the module constructor - control is transfered to the beginning of the process (to be handled there) m
Local watching:
- allows to specifiy the process region to be watched - using macros W_BEGIN, W_DO, W_ESCAPE, W_END - can be nested and combined with global watching
(SC_CTHREAD only)
Joachim Gerlach
Joachim Gerlach
53
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Step2:
Step3:
Step 4: Step 5:
Joachim Gerlach
Step6:
Joachim Gerlach
SYSTEMC
TM
Design Example A
University of Tbingen Wilhelm-Schickard-Institut Department of Computer Engineering
SystemC: Example-1
Example Two processes (process_1 and process_2) alternately incrementing an integer value
process_1 int bool
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
a ready_a
+5
b ready_b
process_2
b ready_b
+3
a ready_a
int bool
Wolfgang Rosenstiel
Joachim Gerlach
56
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
systemc.h
process_1.h
process_2.h
process_1.cc library
process_2.cc
main.cc
g++
a.out
Wolfgang Rosenstiel
executable = simulation
Joachim Gerlach
57
University of Tbingen Department of Computer Engineering // header file: process_1.h SC_MODULE( process_1 ) { Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support }; SystemC 1.1 // Ports sc_in_clk clk; sc_in<int> a; sc_in<bool> ready_a; sc_out<int> b; sc_out<bool> ready_b; // Process functionality void do_process_1();
Module: process_1
// implementation file: process_1.cc #include "systemc.h" #include "process_1.h" void process_1::do_process_1() { int v; while ( true ) { wait_until( ready_a.delayed() == true ); v = a.read(); v += 5; cout << "P1: v = << v << endl; b.write( v ); ready_b.write( true ); wait(); ready_b.write( false ); } }
Wolfgang Rosenstiel
Joachim Gerlach
58
University of Tbingen Department of Computer Engineering // header file: process_2.h SC_MODULE( process_2 ) { Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support }; SystemC 1.1 // Ports sc_in_clk clk; sc_in<int> a; sc_in<bool> ready_a; sc_out<int> b; sc_out<bool> ready_b; // Process functionality void do_process_2();
Module: process_2
// implementation file: process_2.cc #include "systemc.h" #include "process_2.h" void process_2::do_process_2() { int v; while ( true ) { wait_until( ready_a.delayed() == true ); v = a.read(); v += 3; cout << "P2: v = << v << endl; b.write( v ); ready_b.write( true ); wait(); ready_b.write( false ); } }
Wolfgang Rosenstiel
Joachim Gerlach
59
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
process_2 p2 ( P2 ); p2.clk( clock ); p2.a( s2 ); p2.ready_a( ready_s2 ); p2.b( s1 ); p2.ready_b( ready_s1 ); s1.write(0); s2.write(0); ready_s1.write(true); ready_s2.write(false); sc_start(100000);
Wolfgang Rosenstiel
return 0; }
Joachim Gerlach
60
Simulation Results
q
Simulation output
SystemC (TM) Version 1.0 --- Apr 4 2000 10:12:32 ALL RIGHTS RESERVED Copyright (c) 1988-2000 by Synopsys, Inc. P1: v = 5 P2: v = 8 P1: v = 13 P2: v = 16 P1: v = 21 P2: v = 24 P1: v = 29 P2: v = 32 P1: v = 37 P2: v = 40 P1: v = 45 P2: v = 48 P1: v = 53 P2: v = 56 P1: v = 61 P2: v = 64 P1: v = 69 P2: v = 72 P1: v = 77 P2: v = 80 .....
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
simulation speed: simulation of 100.000 cycles takes about 0.08 seconds on a Sun Ultra Sparc 5 (384 MByte main memory) (output skipped) comparison to simulation speed of SystemC 0.9: simulation of 100.000 cycles takes about 0.31 seconds on the same machine
Wolfgang Rosenstiel
Joachim Gerlach
61
SYSTEMC
TM
Design Example B
University of Tbingen Wilhelm-Schickard-Institut Department of Computer Engineering
Background:
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
SystemC
C / C++
top-down bottom-up
HDL non-coded Transforming HDL into SystemC Creating new designs in SystemC
SystemC
Joachim Gerlach
Transforming C/C++ into SystemC Many algorithms exist in C/C++ Many standardization committees (e.g., ISO) use C specifications
Joachim Gerlach
63
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
JPEG Encoder
JPEG Decoder
Writer
Joachim Gerlach
Reference implementation: m 16 modules, approx. 950 lines of C++ code m by T. Thissenhusen, TU Dresden, Germany
Joachim Gerlach
64
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Reader
DCT
IRLEH
Encoder
Quant IZigZag
ZigZag
IQuant
Decoder
RLEH IDCT
Joachim Gerlach
Writer
output pgm-file
Joachim Gerlach
65
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
DCT
data_in start
Coeff_8x8 bool
ready
bool
Quant
clk
ZigZag
ZigZag
Matrix_64x12 bool bool
RLEH
Joachim Gerlach
char data;
Joachim Gerlach
66
data
Reader
data data ready ready
data
DCT
data data ready ready
IRLEH
data data ready ready
Encoder
Quant
data data ready ready
IZigZag
data data ready ready
data data ready ready
ZigZag
data ready
IQuant
Decoder
ready
data
data ready
ready
RLEH
data
data ready
ready
IDCT
Joachim Gerlach
Writer
output pgm-file
Joachim Gerlach
67
SYSTEMC
TM
Design Activities
University of Tbingen Wilhelm-Schickard-Institut Department of Computer Engineering
Design Activities
q
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Modeling m Module for zigzagcomputation Simulation m Generation and run of an executable specification Debugging m Techniques for checking the functionality of the system
Joachim Gerlach
Joachim Gerlach
69
Modeling
void zigzag::do_zigzag() {
zigzag.cc
zigzag.h
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
ready.write(true); data_out_ready.write(false); wait_until(start.delayed()==true); ready.write(false); fuv = data_in.read(); // zigzag u = 0; v = 0; dir = 1; // dir == 1: upwards, dir == 0: downwards for ( a = 0; a < 64; a++ ) { result.put ( a, (WORD) (fuv.get (v,u) ) ); if ( v == 0 ) if ( dir ) { u++; dir = 0; } else { u--; v++; } else if ( v == 7 ) if ( !dir ) { u++; dir = 1; } else { u++; v--; } else if ( u == 0 ) if ( !dir ) { v++; dir = 1; } else { u++; v--; } else if ( u == 7 ) if ( dir ) { v++; dir = 0; } else { u--; v++; } else if ( dir ) { u++; v--; } else { u--; v++; } } data_out.write(result); data_out_ready.write(true); wait_until(data_ok.delayed()==true); } }
sc_out<Matrix_64x12> data_out; sc_out<bool> ready; sc_out<bool> data_out_ready; void do_zigzag(); SC_CTOR(zigzag) { SC_CTHREAD(do_zigzag,clk.pos()); } };
Joachim Gerlach
Joachim Gerlach
70
Simulation
q
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
......
writer.h
reader.cc library
......
writer.cc
jpeg.cc
g++
Joachim Gerlach
Simulation
q
Simulation control
m
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Simulation start: sc_start() / sc_start(n) from the top-level function sc_main() Simulation stop: sc_stop() from within any process
Joachim Gerlach
sc_initialize(); for (int i=0; i<=200; i++) { clock = 1; sc_cycle(10); clock = 0; sc_cycle(10); }
System-on-Chip Design with SystemC 72
Joachim Gerlach
Simulation
q
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Joachim Gerlach
Joachim Gerlach
73
Simulation
q
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
JPEG Decoder
Writer
Joachim Gerlach
Joachim Gerlach
74
Debugging
q
Observation of simulation results Adding (C/C++) assertions/debug outputs to the source code Using SystemC debugging features Using standard debugging tools (gdb, Purify,...)
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Joachim Gerlach
Joachim Gerlach
75
Debugging
q
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
zigzag.cc
Joachim Gerlach
Joachim Gerlach
76
Debugging
q
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Joachim Gerlach
Joachim Gerlach
77
Debugging
q
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
zigzag.cc
Joachim Gerlach
Joachim Gerlach
78
Debugging
q
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Joachim Gerlach
Joachim Gerlach
79
Debugging
q
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
jpeg.cc
Joachim Gerlach
Joachim Gerlach
80
Debugging
q
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Joachim Gerlach
Joachim Gerlach
81
SYSTEMC
TM
Tool Support
University of Tbingen Wilhelm-Schickard-Institut Department of Computer Engineering
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
SystemC
Modeling Constructs
C/C++ Testbench
C/C++ Software
System
C/C++ Hardware/System
Wolfgang Rosenstiel
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
SystemCTM Compiler
db form db form db or HDL format
(This flow is not supported currently)
Behavioral synthesis
RTL synthesis
Wolfgang Rosenstiel
Joachim Gerlach
84
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Refine Structure Partition into blocks that will be independently synthesized/refined Refine interfaces for communication
Refine Control Specify I/O protocol Specify clock domains Specify latency, throughput Specify FSM & datapath for RTL
Wolfgang Rosenstiel
System Implementation
Joachim Gerlach System-on-Chip Design with SystemC 85
Code?
no
Timed DB File
SystemC Compiler
Initial Constraints
Design Activities
Check Design
Tool Support
Time/Area Estimates
SystemC 1.1
HDL Co-Simulation
Wolfgang Rosenstiel
Compile
Gate Level Netlist
Timed DB File
Timed DB Generation
Joachim Gerlach
High-Level Synthesis
System-on-Chip Design with SystemC 86
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Refinement
(communication, timing, memories)
Refinement
(resources, scheduling, allocation, FSM design)
Architectural Design
RT Level Design
Controller
Wolfgang Rosenstiel
Joachim Gerlach
87
Benefits
m
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Rapid time to market fast refinement from functional model behavioral model accommodating late spec changes
m m
Graphical analysis of design High quality of results tight integration into Synopsys synthesis flow flexibility for datapath components
Wolfgang Rosenstiel
Joachim Gerlach
88
CoWare N2C
q
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Wolfgang Rosenstiel
Joachim Gerlach
89
CoWare N2C
q
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Wolfgang Rosenstiel
Joachim Gerlach
90
CoWare N2C
q
N2C Workbench
m
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Hierarchical design browser (architecture, functionality) Source code editor (context sensitive) Project manager (partition management)
m m
CoWare Support
m
CoWare N2C supports a top-down design flow for HW/SW co-design from UTF to RTL Co-simulation of different languages Fast design exploration and HW/SW partitioning Allows for efficient IP reuse and delivery Provides synthesis of communication
m m m
Wolfgang Rosenstiel
Joachim Gerlach
91
System Compiler
m
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
supports full ANSI C and C++ provides complex data structures, static pointer analysis, abstraction, hierarchy output is RT level HDL (VHDL or Verilog)
native C/C++
bit-accurate (fixed and floating) simulation libraries native C/C++ CSim/System C++ simulation simulation System Compiler C/C++ synthesis
CSim
m m
executable specification discrete event simulation abstraction: temporal time, data values, functionality
Wolfgang Rosenstiel
RTL HDL
Joachim Gerlach
92
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
vendor HDL
edit/compile edit/compile
map mapto toarchitecture architecture source code tuning schedule operations schedule operations performance analysis build buildRTL RTLcode code logic synthesis FPGA Joachim Gerlach ASIC 93 architecture optimization
Wolfgang Rosenstiel
SYSTEMC
TM
Matlab
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1 target RTOS/core task partitioning
C++
SDL
Esterel
SystemC 1.1
UTF
design exploration performance analysis hw/sw partitioning
functional decomposition
untimed functional
assign execution time
TF
timed functional
hw/sw partitioning refine communication
Abstr. RTOS
BCA
Joachim Gerlach
RTOS
RTL hardware
cycle accurate
software
Joachim Gerlach
95
Background & Basics SystemC 1.0 Design Example A Design Example B Design Activities Tool Support SystemC 1.1
Functional decomposition of a system Architecture, timing, inter-block communication is abstracted Maximally sequential form by RPC (Remote Procedure Call) RPC: abstract (master/slave-)ports, multi-point link objects
Abstract ports refined to bus ports with data, adress, control terminals and communication protocols
q
Joachim Gerlach
Joachim Gerlach
96
SYSTEMC
TM