Reconfigurable Computing S. Reda, Brown University Reconfigurable Computing (EN2911X, Fall07) Lecture 13: SystemC (1/3) Prof. Sherief Reda Division of.

Slides:



Advertisements
Similar presentations
Reconfigurable Computing S. Reda, Brown University Reconfigurable Computing (EN2911X, Fall07) Lecture 06: Verilog (2/3) Prof. Sherief Reda Division of.
Advertisements

Contents o Introduction o Characteristics of Constructor. o Types of constructor. - Default Constructor - Parameterized Constructor - Copy Constructor.
Reconfigurable Computing S. Reda, Brown University Reconfigurable Computing (EN2911X, Fall07) Lecture 07: Verilog (3/3) Prof. Sherief Reda Division of.
Inheritance Inheritance Reserved word protected Reserved word super
Chapter 3 : Combination and Sequential Circuits Modeling.
14 Templates. OBJECTIVES In this chapter you will learn:  To use function templates to conveniently create a group of related (overloaded) functions.
 2006 Pearson Education, Inc. All rights reserved Midterm review Introduction to Classes and Objects.
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.
Reconfigurable Computing (EN2911X, Fall07) Lecture 05: Verilog (1/3) Prof. Sherief Reda Division of Engineering, Brown University
Introduction to Classes and Objects CS-2303, C-Term Introduction to Classes and Objects CS-2303 System Programming Concepts (Slides include materials.
Reconfigurable Computing S. Reda, Brown University Reconfigurable Computing (EN2911X, Fall07) Lecture 14: SystemC (2/3) Prof. Sherief Reda Division of.
SystemC: Introduction. SystemC  A C++ based class library and design environment for system-level design.  Suitable for functional description that.
From Scenic to SystemC Mehrdad Abutalebi. Outline Introducing Scenic Scenic Implementation Modeling Reactivity A Simple example From Scenic to SystemC.
Chapter 13. Binary Files In binary files we do not need to format data File streams include two member functions specifically designed to input and output.
Copyright © 2012 Pearson Education, Inc. Chapter 13: Introduction to Classes.
ECE 2372 Modern Digital System Design
SystemC Tutorial Author: Silvio Veloso
Looking toward C++ Object-Oriented Programming Traditional Programming Procedure-Oriented Programming Task-Based Programming circle method draw data C.draw()
C++ Classes CSci 588: Data Structures, Algorithms and Software Design All material not from online sources copyright © Travis Desell, 2011
OOP IN PHP `Object Oriented Programming in any language is the use of objects to represent functional parts of an application and real life entities. For.
1 Freeha Azmat Saba Zia Dec 02, Agenda Installation Introduction From Verilog to SystemC Counter as an Example Complete SystemC Modeling 2.
Copyright © 2012 Pearson Education, Inc. Chapter 13: Introduction to Classes.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 13: Introduction to Classes.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 13 Introduction to Classes.
C++ Review (3) Structs, Classes, Data Abstraction.
Copyright 2004 Scott/Jones Publishing Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 7 Structured Data and Classes.
Inheritance. Lecture contents Inheritance Class hierarchy Types of Inheritance Derived and Base classes derived class constructors protected access identifier.
Winter-Spring 2001Codesign of Embedded Systems1 Reactivity, Ports, and Signals in SystemC Part of HW/SW Codesign of Embedded Systems Course (CE )
1 Very Large Scale Integration II - VLSI II SystemC Gürer Özbek ITU VLSI Laboratories Istanbul Technical University.
Classes In C++ 1. What is a class Can make a new type in C++ by declaring a class. A class is an expanded concept of a data structure: instead of holding.
Module 1.2 Introduction to Verilog
C++ Programming Basic Learning Prepared By The Smartpath Information systems
Fall 2004EE 3563 Digital Systems Design EE 3563 VHSIC Hardware Description Language  Required Reading: –These Slides –VHDL Tutorial  Very High Speed.
1 CSC241: Object Oriented Programming Lecture No 02.
OOP using C Abstract data types How to accomplish the task??? Requirements Details Input, output, process Specify each task in terms of input.
1 OOP - An Introduction ISQS 6337 John R. Durrett.
Week 02 Object Oriented Analysis and Designing. Constructors Constructors are member functions of any class, which are invoked the moment an instance.
CPE 626 The SystemC Language Aleksandar Milenkovic Web:
04/26/20031 ECE 551: Digital System Design & Synthesis Lecture Set : Introduction to VHDL 12.2: VHDL versus Verilog (Separate File)
VHDL Discussion Subprograms IAY 0600 Digital Systems Design Alexander Sudnitson Tallinn University of Technology 1.
Chapter 9. Inheritance - Basics Inheritance is a mechanism that allows you to base a new class upon the definition of a pre-existing class Subclass inherits.
Copyright 2006 Pearson Addison-Wesley, 2008, 2013 Joey Paquet 2-1 Concordia University Department of Computer Science and Software Engineering COMP345.
نظام المحاضرات الالكترونينظام المحاضرات الالكتروني Object Oriented Programming(Objects& Class) Classes are an expanded concept of data structures: like.
نظام المحاضرات الالكترونينظام المحاضرات الالكتروني Destructors The destructor fulfills the opposite functionality. It is automatically called when an object.
CSIS 123A Lecture 10 Inheritance. Organizing Code Why should programs be organized? –Humans are "complexity challenged" Need simplicity, clarity, efficiency.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures C++ Review 2.
Classes Sujana Jyothi C++ Workshop Day 2. A class in C++ is an encapsulation of data members and functions that manipulate the data. A class is a mechanism.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 13: Introduction to Classes.
Structure A Data structure is a collection of variable which can be same or different types. You can refer to a structure as a single variable, and to.
Computer Programming II Lecture 5. Introduction to Object Oriented Programming (OOP) - There are two common programming methods : procedural programming.
Hardware Description Languages: Verilog
Constructors and Destructors
Chapter 3 : Combination and Sequential Circuits Modeling
Introduction to Classes
Chapter 5 Classes.
Hardware Description Languages: Verilog
SystemC for SoC Designs
Design Flow System Level
Introduction to Classes
VHDL Discussion Subprograms
Constructors and Destructors
VHDL Discussion Subprograms
Chapter 1 : SystemC Overview
ENERGY 211 / CME 211 Lecture 17 October 29, 2008.
Reconfigurable Computing (EN2911X, Fall07)
Reconfigurable Computing (EN2911X, Fall07)
Introduction to Classes and Objects
Presentation transcript:

Reconfigurable Computing S. Reda, Brown University Reconfigurable Computing (EN2911X, Fall07) Lecture 13: SystemC (1/3) Prof. Sherief Reda Division of Engineering, Brown University

Reconfigurable Computing S. Reda, Brown University Introduction to SystemC SystemC is not a language, but rather a class library within a well established language C++. The primary motivation for using SystemC is to attain the productivity increases required to design modern electronic systems with their ever increasing complexity. [SystemC: From Ground Up]

Reconfigurable Computing S. Reda, Brown University SystemC resources SystemC: from the ground up / by David C. Black and Jack DonovanSystemC: from the ground up SystemC: methodologies and applications / edited by Wolfgang Müller, Wolfgang Rosenstiel, and Jürgen RufSystemC: methodologies and applications System design with SystemC / by Thorsten Grotker, Stan Liao, Grant Martin, Stuart SwanSystem design with SystemC

Reconfigurable Computing S. Reda, Brown University C++ mini refresher C++ is an object oriented language A key concept in C++ is the class. A class is an expanded concept of a data structure: instead of holding only data, it can hold both data and functions. class CRectangle { private: int x, y; public: void set_values (int,int); int area (void); } rect; rect.set_values (3,4); myarea = rect.area(); Examples from

Reconfigurable Computing S. Reda, Brown University CRectangle example #include class CRectangle { private: int x, y; public: void set_values (int,int); int area () { return (x*y); } }; void CRectangle::set_values (int a, int b) { x = a; y = b; } int main () { CRectangle rect; rect.set_values (3,4); cout << "area: " << rect.area(); return 0; } declaration declaration & definition definition

Reconfigurable Computing S. Reda, Brown University Constructors #include class CRectangle { int width, height; public: CRectangle (int,int); int area () { return (width*height); } }; CRectangle::CRectangle (int a, int b) { width = a; height = b; } int main () { CRectangle rect (3,4); CRectangle rectb (5,6); return 0; } A constructor is automatically called whenever a new object of this class is created. The constructor function must have the same name as the class, and cannot have any return type; not even void.

Reconfigurable Computing S. Reda, Brown University (Destructors) class CRectangle { int *width, *height; public: CRectangle (int,int); ~CRectangle (); int area () { return (*width * *height); } }; CRectangle::CRectangle (int a, int b) { width = new int; height = new int; *width = a; *height = b; } CRectangle::~CRectangle () { delete width; delete height; } destructor definition allocating memory freeing memory destructor definition

Reconfigurable Computing S. Reda, Brown University Pointer to classes It is perfectly valid to create pointers that point to classes. We simply have to consider that once declared, a class becomes a valid type, so we can use the class name as the type for the pointer. For example: CRectangle *prect; prect = new CRectangle; prect->set_values(1, 2); As with data structures, in order to refer directly to a member of an object pointed by a pointer we can use the arrow operator (->) of indirection.

Reconfigurable Computing S. Reda, Brown University Inheritance between classes polygon rectangletriangle A key feature of C++ classes is inheritance. Inheritance allows to create classes which are derived from other classes, so that they automatically include some of its "parent's" members, plus its own. The class CPolygon contain members that are common for both types of polygon. In our case: width and height. And CRectangle and CTriangle would be its derived classes, with specific features that are different from one type of polygon to the other. Classes that are derived from others inherit all the accessible members of the base class.

Reconfigurable Computing S. Reda, Brown University Inheritance example class CPolygon { protected: int width, height; public: void set_values (int a, int b) { width=a; height=b; } }; class CRectangle: public CPolygon { public: int area () { return (width * height); } }; class CTriangle: public CPolygon { public: int area () { return (width * height / 2); } }; int main () { CRectangle rect; CTriangle trgl; rect.set_values (4,5); trgl.set_values (4,5); } The protected access specifier is similar to private. The only difference occurs in fact with inheritance. When a class inherits from another one, the members of the derived class can access the protected members inherited from the base class, but not its private members.

Reconfigurable Computing S. Reda, Brown University Class templates motivation class mypairi { int a, b; public: mypair (int first, int second) { a=first; b=second; } int getmax () { int retval; retval = a>b? a : b; return retval; }; int main () { mypairi myobject (100, 75); cout << myobject.getmax(); return 0; } class mypairf { float a, b; public: mypair (float first, float second) { a=first; b=second; } float getmax () { float retval; retval = a>b? a : b; return retval; }; int main () { mypairf myobject (100, 75); cout << myobject.getmax(); return 0; } Can we have an automatic way to avoid writing multiple versions of the same class for different data types?

Reconfigurable Computing S. Reda, Brown University Class templates template class mypair { T a, b; public: mypair (T first, T second) { a=first; b=second; } T getmax () { T retval; retval = a>b? a : b; return retval; }; int main () { mypair myobject (100, 75); cout << myobject.getmax(); return 0; } C++ Class Templates are used where we have multiple copies of code for different data types with the same logic. If a set of functions or classes have the same functionality for different data types, they become good candidates for being written as Templates.

Reconfigurable Computing S. Reda, Brown University What is wrong with plain C++? Concurrency: hardware systems are inherently parallel; SW are not. Time: C++ has no notion of time Hardware style communication: signals, protocols Reactivity: hardware is inherently reactive Hardware data types: bit type, multi-valued logic Some of the functionalities in C++ are not simply applicable in hardware systems (e.g. destructors)

Reconfigurable Computing S. Reda, Brown University Extending C++ with SystemC library SystemC library of C++ classes: –Processes (for concurrency) –Clocks (for time) –Hardware data types (bit vectors, 4-valued logic, fixed-point types, arbitrary precision integers) –Waiting, watching, and sensitivity (for reactivity) –Modules, ports, signals (for hierarchy)

Reconfigurable Computing S. Reda, Brown University Synthesizable SystemC  Our discussions will focus on SystemC synthesis as afforded by the Celoxica SystemC agility compiler

Reconfigurable Computing S. Reda, Brown University SC_MODULE SC_MODULE(module_name) {... // port declarations to connect modules together... // variable declarations... // function declarations/definitions SC_CTOR(module_name) {... // body of constructor... // process declarations, sensitivities } }; The arguments to SC_MODULE and SC_CTOR must be the same. creates a class inherted from sc_module

Reconfigurable Computing S. Reda, Brown University Module ports Ports are used to communicate with the external modules or channels. –Input ports (defined using sc_in and sc_in_clk ) –Output ports (defined using sc_out and sc_out_clk) –Input/output ports (defined using sc_inout, sc_inout_clk and sc_inout_rv ) SC_MODULE (module_name) { //Module port declarations sc_in port_name; sc_out port_name; sc_inout port_name; sc_in port_name; … };

Reconfigurable Computing S. Reda, Brown University Datatypes Supported native C++ synthesizable data types –long long –long –int –short –char –bool SystemC also allows further refined storage types –sc_bit –sc_bv –sc_int –sc_uint –sc_bigint –sc_biguint

Reconfigurable Computing S. Reda, Brown University Module process Processes describe the parallel behavior of hardware systems. Processes execute concurrently. The code within a process, however, executes sequentially. Defining a process is similar to defining a C++ function. A process is declared as a member function of a module class and registered as a process in the module’s constructor. SC_MODULE (my_module) { sc_in clk; sc_in in1; sc_out out1; void my_method(); SC_CTOR(my_module) { SC_METHOD(my_method); sensitive << in1 << clk.pos(); } module process in1 clk out

Reconfigurable Computing S. Reda, Brown University Definition of process body A thread process body within a module definition SC_MODULE (my_module) { void my_method();... }; A thread process body outside a module definition The process body contains the implementation of the process. Like C++ functions, it may be defined: within the module definition, typically in a.h header file outside the module, typically in a.cpp file SC_MODULE (my_module) { void my_method() {... }... }; my_module.h void my_module::my_thread() {... } my_module.cpp

Reconfigurable Computing S. Reda, Brown University SC_CTOR construct The SC_CTOR constructor is used to: –Initialize variables declared in the module. –Specify the functionality of the module in terms of SC_METHOD, SC_THREAD and SC_CTHREAD. –The threads and methods must be defined using synthesizable code. The constructor should also contain: –The sensitivity lists describing the inputs that each process is sensitive to. –Instantiation of sub-modules. –Port mapping code for hierarchical modules.

Reconfigurable Computing S. Reda, Brown University OR gate example #include "systemc.h" SC_MODULE(or_gate) { sc_in a; sc_in b; sc_out c; void prc_or_gate() { c=a | b; } SC_CTOR(or_gate) { SC_METHOD(prc_or_gate); sensitive << a << b; } }; OR_GATE a b c

Reconfigurable Computing S. Reda, Brown University Full adder example SC_MODULE( half_adder ) { sc_in a,b; sc_out sum, carry; void half_adder_defn(); SC_CTOR( half_adder ) { SC_METHOD ( half_adder_defn ); sensitive << a << b; } }; void half_adder::half_adder_defn() { sum = a ^ b; carry = a & b; } FA a b sum carry