SystemC Tutorial Author: Silvio Veloso

Slides:



Advertisements
Similar presentations
The Verilog Hardware Description Language
Advertisements

Verilog Intro: Part 1.
Winter-Spring 2001Codesign of Embedded Systems1 Introduction to SystemC Part of HW/SW Codesign of Embedded Systems Course (CE )
ECE 353 Computer Systems Lab II VHDL AND LABORATORY TOOLS TUTORIAL Professors Maciej Ciesielski & T. Baird Soules.
1 Processor Design 5Z032 SystemC + miniMIPS Henk Corporaal Eindhoven University of Technology 2011.
Chapter 3 : Combination and Sequential Circuits Modeling.
Reconfigurable Computing S. Reda, Brown University Reconfigurable Computing (EN2911X, Fall07) Lecture 15: SystemC (3/3) Prof. Sherief Reda Division of.
Copyright © 2001 Stephen A. Edwards All rights reserved SystemC Prof. Stephen A. Edwards.
VHDL Intro What does VHDL stand for? VHSIC Hardware Description Language VHSIC = Very High Speed Integrated Circuit Developed in 1982 by Govt. to standardize.
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
VHDL. What is VHDL? VHDL: VHSIC Hardware Description Language  VHSIC: Very High Speed Integrated Circuit 7/2/ R.H.Khade.
Chapter 2 : Data types. Extension Data Type Overview NameDescription sc_bitsingle bit with two values, ‘0’ and ‘1’ sc_bv Arbitrary width bit vector sc_logicSignle.
Copyright © 2001 Stephen A. Edwards All rights reserved SystemC Prof. Stephen A. Edwards.
Reconfigurable Computing S. Reda, Brown University Reconfigurable Computing (EN2911X, Fall07) Lecture 14: SystemC (2/3) Prof. Sherief Reda Division of.
Reconfigurable Computing S. Reda, Brown University Reconfigurable Computing (EN2911X, Fall07) Lecture 13: SystemC (1/3) Prof. Sherief Reda Division of.
Yoshinori Takeuchi Osaka University 1MPSoC Osaka University  Expansion of multi-functional portable multimedia devices requires high performance.
SystemC: Introduction. SystemC  A C++ based class library and design environment for system-level design.  Suitable for functional description that.
VHDL Training ©1995 Cypress Semiconductor 1 Introduction  VHDL is used to:  document circuits  simulate circuits  synthesize design descriptions 
1 Advanced Computer Architecture 5MD00 / 5Z032 SystemC Henk Corporaal 2007.
From Scenic to SystemC Mehrdad Abutalebi. Outline Introducing Scenic Scenic Implementation Modeling Reactivity A Simple example From Scenic to SystemC.
ECE 2372 Modern Digital System Design
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
VHDL TUTORIAL Preetha Thulasiraman ECE 223 Winter 2007.
A VHDL Tutorial ENG2410. ENG241/VHDL Tutorial2 Goals Introduce the students to the following: –VHDL as Hardware description language. –How to describe.
CPE 626 The SystemC Language Aleksandar Milenkovic Web:
1 Freeha Azmat Saba Zia Dec 02, Agenda Installation Introduction From Verilog to SystemC Counter as an Example Complete SystemC Modeling 2.
1 An Update on Verilog Ξ – Computer Architecture Lab 28/06/2005 Kypros Constantinides.
Design & Co-design of Embedded Systems Combinational Logic in SystemC Maziar Goudarzi.
Modules and Processes in SystemC A Presentation by: Najmeh Fakhraie Mozhgan Nazarian-Naeini Hardware-Software Codesign Spring 2006.
RTL Hardware Design by P. Chu Chapter Basic VHDL program 2. Lexical elements and program format 3. Objects 4. Data type and operators RTL Hardware.
Winter-Spring 2001Codesign of Embedded Systems1 Reactivity, Ports, and Signals in SystemC Part of HW/SW Codesign of Embedded Systems Course (CE )
1 IMEC / KHBO June 2004 Micro-electronics SystemC Dorine Gevaert.
1 Very Large Scale Integration II - VLSI II SystemC Gürer Özbek ITU VLSI Laboratories Istanbul Technical University.
Introduction to VHDL Spring EENG 2920 Digital Systems Design Introduction VHDL – VHSIC (Very high speed integrated circuit) Hardware Description.
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
Reconfigurable Computing - VHDL John Morris Computer Science/ Electrical and Computer Engineering The University of Auckland Iolanthe racing off Fremantle,
Modern VLSI Design 4e: Chapter 8 Copyright  2008 Wayne Wolf Topics VHDL register-transfer modeling: –basics using traffic light controller; –synthesis.
Electrical and Computer Engineering University of Cyprus LAB 1: VHDL.
HARDWARE DESCRIPTION LANGUAGE (HDL). What is HDL? A type of programming language for sampling and modeling of electronic & logic circuit designs It can.
Design & Co-design of Embedded Systems Data Types in SystemC Maziar Goudarzi.
(1) Basic Language Concepts © Sudhakar Yalamanchili, Georgia Institute of Technology, 2006.
Introduction to VHDL Simulation … Synthesis …. The digital design process… Initial specification Block diagram Final product Circuit equations Logic design.
CprE 588 Embedded Computer Systems Prof. Joseph Zambreno Department of Electrical and Computer Engineering Iowa State University Lecture #10 – Introduction.
Hardware languages "Programming"-language for modelling of (digital) hardware 1 Two main languages: VHDL (Very High Speed Integrated Circuit Hardware Description.
CPE 626 The SystemC Language Aleksandar Milenkovic Web:
Digital System Projects
04/26/20031 ECE 551: Digital System Design & Synthesis Lecture Set : Introduction to VHDL 12.2: VHDL versus Verilog (Separate File)
CPE 626 The SystemC Language Aleksandar Milenkovic Web:
Design & Co-design of Embedded Systems Introduction to SystemC Maziar Goudarzi.
Case Study: Xilinx Synthesis Tool (XST). Arrays & Records 2.
1 of 14 Ivan Ukhov Embedded Systems Laboratory Department of Computer and Information Science Linköping University TDDI08: Embedded Systems Design Introduction.
CIS 4930/6930 System-on-Chip Design Introduction to SystemC Hao Zheng Computer Science & Engineering U of South Florida.
1 Introduction to Engineering Spring 2007 Lecture 18: Digital Tools 2.
1 Computer Architecture & Assembly Language Spring 2009 Dr. Richard Spillman Lecture 11 – ALU Design.
Hardware Description Languages: Verilog
SystemC + miniMIPS Processor Design 5Z032 Henk Corporaal
Discussion 2: More to discuss
Introduction Introduction to VHDL Entities Signals Data & Scalar Types
Instructor: David Ferry
Hardware Description Languages: Verilog
Chapter 2. Introduction To VHDL
SystemC for SoC Designs
Design Flow System Level
Introduction to Verilog
Design Language 최기영 (서울대학교, 전기컴퓨터공학부) Copyrightⓒ2003.
The Verilog Hardware Description Language
ECE 545 Lecture 5 Simple Testbenches.
Chapter 1 : SystemC Overview
Introduction to System-Level Modeling in SystemC 2.0
EEL4712 Digital Design (VHDL Tutorial).
Presentation transcript:

SystemC Tutorial Author: Silvio Veloso

Contents Needed tools Starting example Introduction SystemC highlights Differences Modules, processes, ports, signals, clocks and data types

Needed tools SystemC library package v2.0.1 Download in Linux platform GCC compiler GTKWave – Waveform tool some text editor

Starting Example:Full Adder SC_MODULE( FullAdder ) { sc_in > A; sc_in > B; sc_out > result; void doIt( void ); SC_CTOR( FullAdder ) { SC_METHOD( doIt ); sensitive << A; sensitive << B; } }; void FullAdder::doIt( void ) { sc_int tmp_A, tmp_B; sc_int tmp_R; tmp_A = (sc_int ) A.read(); tmp_B = (sc_int ) B.read(); tmp_R = tmp_A + tmp_B; result.write( (sc_uint ) tmp_R.range(15,0) ); } FullAdder.hFullAdder.cpp

Introduction What is SystemC ?  SystemC is a C++ class library and methodology that can effectively be used to create a cycle- accurate model of a system consisting of software, hardware and their interfaces.

Introduction Where can I use SystemC ?  In creating an executable specification of the system to be developed. What should I know to learn SystemC ?  Notions of C++ programming and VHDL helps you a lot.

SystemC highlights Supports hardware and software co-design Developing an executable specification avoids inconsistency and errors Avoids wrong interpretation of the specification SystemC has a rich set of data types for you to model your systems It allows multiple abstraction levels, from high level design down to cycle-accurate RTL level

Why is SystemC different ? Current design methodology Manual conversion creates errors The C model is not more used Many tests are needed to validate

Why is SystemC different ? SystemC design methodology Better methodology, translate is not necessary Written in only one language

Modules Modules are the basic building blocks to partition a design Modules allow to partition complex systems in smaller components Modules hide internal data representation, use interfaces Modules are classes in C++ Modules are similar to „entity“ in VHDL

Modules SC_MODULE (module_name) { // Ports declaration // Signals declaration // Module constructor : SC_CTOR // Process constructors and sensibility list // SC_METHOD // Sub-Modules creation and port mappings // Signals initialization } They can contain ports, signals, local data, other modules, processes and constructors.

Modules Module constructor Similar to „architecture“ in VHDL SC_CTOR( FullAdder ) { SC_METHOD( doIt ); sensitive << A; sensitive << B; } Example: Full Adder constructor

Modules Sub-modules instantiation: Instantiate module Module_type Inst_module (“label”); Instantiate module as a pointer Module_type *pInst_module; // Instantiate at the module constructor SC_CTOR pInst_module = new module_type (“label”);

Modules How to connect sub-modules ?  Named Connection or  Positional Connection

Modules Named Connection Inst_module.a(s); Inst_module.b(c); Inst_module.q(q); pInst_module -> a(s); pInst_module -> b(c); pInst_module -> q(q);

Modules Positional Connection Inst_module << s << c << q; (*pInst_module)(s,c,q);

Modules Internal Data Storage Local variables: can not be used to connect ports Allowed data types  C++ types  SystemC types  User defined types

Modules Example: Mux 2:1 SC_MODULE( Mux21 ) { sc_in > in1; sc_in > in2; sc_in selection; sc_out > out; void doIt( void ); SC_CTOR( Mux21 ) { SC_METHOD( doIt ); sensitive << selection; sensitive << in1; sensitive << in2; } };

Modules Example: SC_MODULE(filter) { // Sub-modules : “components” sample *s1; coeff *c1; mult *m1; sc_signal > q, s, c; // Signals // Constructor : “architecture” SC_CTOR(filter) { // Sub-modules instantiation and mapping s1 = new sample (“s1”); s1->din(q); // named mapping s1->dout(s); c1 = new coeff(“c1”); c1->out(c); // named mapping m1 = new mult (“m1”); (*m1)(s, c, q); // Positional mapping }

Processes Processes are functions that are identified to the SystemC kernel. They are called if one signal of the sensitivity list changes its value. Processes implement the funcionality of modules Processes are very similar to a C++ function or method Processes can be Methods, Threads and CThreads

Processes Methods When activated, executes and returns - SC_METHOD(process_name) Threads Can be suspended and reactivated - wait() -> suspends - one sensitivity list event -> activates - SC_THREAD(process_name) CThreads Are activated in the clock pulse - SC_CTHREAD(process_name, clock value);

Processes Type SC_METHODSC_THREADSC_CTHREAD Activates Exec. Event in sensit. listEvent in sensit. ListClock pulse Suspends Exec. NOYES Infinite Loop NOYES suspended/ reactivated by N.D.wait() wait_until() Constructor & Sensibility definition SC_METHOD(call_back); sensitive(signals); sensitive_pos(signals); sensitive_neg(signals); SC_THREAD(call_back); sensitive(signals); sensitive_pos(signals); sensitive_neg(signals); SC_CTHREAD( call_back, clock.pos() ); SC_CTHREAD( call_back, clock.neg());

Processes Process Example void doIt( void ); SC_CTOR( Mux21 ) { SC_METHOD( doIt ); sensitive << selection; sensitive << in1; sensitive << in2; } Into the.H file void Mux21::doIt( void ) { sc_uint out_tmp; if( selection.read() ) { out_tmp = in2.read(); } else { out_tmp = in1.read(); } out.write( out_tmp ); } Into the.CPP file

Ports and Signals Ports of a module are the external interfaces that pass information to and from a module In SystemC one port can be IN, OUT or INOUT Signals are used to connect module ports allowing modules to communicate Very similar to ports and signals in VHDL

Ports and Signals Types of ports and signals:  All natives C/C++ types  All SystemC types  User defined types How to declare  IN : sc_in  OUT : sc_out  Bi-Directional : sc_inout

Ports and Signals How to read and write a port ?  Methods read( ); and write( ); Examples:  in_tmp = in.read( ); //reads the port in to in_tmp  out.write(out_temp); //writes out_temp in the out port

Clocks Special object How to create ? sc_clock clock_name ( “clock_label”, period, duty_ratio, offset, initial_value ); Clock connection f1.clk( clk_signal ); //where f1 is a module Clock example:

Data Types SystemC supports:  C/C++ native types  SystemC types SystemC types  Types for systems modelling  2 values ( ‘ 0 ’, ’ 1 ’ )  4 values ( ‘ 0 ’, ’ 1 ’, ’ Z ’, ’ X ’ )  Arbitrary size integer (Signed/Unsigned)  Fixed point types

SystemC types TypeDescription sc_logic Simple bit with 4 values(0/1/X/Z) sc_int Signed Integer from 1-64 bits sc_uint Unsigned Integer from 1-64 bits sc_bigint Arbitrary size signed integer sc_biguint Arbitrary size unsigned integer sc_bv Arbitrary size 2-values vector sc_lv Arbitrary size 4-values vector sc_fixed templated signed fixed point sc_ufixed templated unsigned fixed point sc_fix untemplated signed fixed point sc_ufix untemplated unsigned fixed point

SystemC types Simple bit type Assignment similar to char  my_bit = ‘1’; Declaration  bool my_bit; Operators Bitwise& (and)| (or)^ (xor)~ (not) Assignment=&=|=^= Equality==!=

SystemC types SC_LOGIC type More general than bool, 4 values :  (‘0’ (false), ‘1’ (true), ‘X’ (undefined), ‘Z’(high-impedance) ) Assignment like bool  my_logic = ‘0’;  my_logic = ‘Z’; Simulation time bigger than bool Operators like bool Declaration  sc_logic my_logic;

SystemC types Fixed precision integers Used when arithmetic operations need fixed size arithmetic operands INT can be converted in UINT and vice-versa “int” in C++  The size depends on the machine  Faster in the simulation 1-64 bits integer  sc_int -- signed integer with n-bits  sc_uint -- unsigned integer with n-bits

SystemC types Operators of fixed precision types Bitwise~&|^>><< Arithmetics+-*/% Assignement=+=-=*=/=%=&=|=^= Equality==!= Relational<<=>>=>= Auto-Inc/Dec++-- Bit selection[x] ex) mybit = myint[7] Part selectrange() ex) myrange = myint.range(7,4) Concatenation(,) ex) intc = (inta, intb);

SystemC types Arbitrary precision integers Integer bigger than 64 bits  sc_bigint  sc_biguint More precision, slow simulation Operators like SC_LOGIC Can be used together with:  Integer C++  sc_int, sc_uint

SystemC types Bit vector  sc_bv  2-value vector (0/1)  Not used in arithmetics operations  Faster simulation than sc_lv Logic Vector  sc_lv  Vector to the sc_logic type Assignment operator (“=“)  my_vector = “XZ01”  Conversion between vector and integer (int or uint)  Assignment between sc_bv and sc_lv  Additional Operators Reduction and_reduction() or_reduction() xor_reduction() Conversion to_string()

SystemC types Examples:  sc_bit y, sc_bv x;  y = x[6];  sc_bv x, sc_bv y;  y = x.range(0,7);  sc_bv databus, sc_logic result;  result = databus.or_reduce();  sc_lv bus2;  cout << “bus = “ << bus2.to_string();

User defined types Comparation operator  Operator “Built-in” “==“ can’t be used  function inline must be defined for user types inline bool operator == (const packet_type& rhs) const { return (rhs.info==info && rhs.seq==seq && rhs.retry==retry); }

User defined types Example #include "systemc.h" struct packet_type { long info; int seq; int retry; inline bool operator == (const packet_type& rhs) const { return (rhs.info == info && rhs.seq == seq && rhs.retry == retry); } }; #endif