Download presentation
Presentation is loading. Please wait.
Published byCynthia Barber Modified over 9 years ago
1
SystemC: Introduction
2
SystemC A C++ based class library and design environment for system-level design. Suitable for functional description that might eventually be implemented as either HW or SW. Open standard www.systemc.org
3
Language Architecture C++ Language Standard Core Language Module Ports Processes Events Interfaces Channels Event-driven simulation kernel Data types Bits and bit-vectors Arbitrary precision integers Fixed-point numbers 4-valued logic types, logic-vectors C++ user defined types Elementary Channels Signal, Timer, Mutex, Semaphore, FIFO, etc Channels for MoCs Kahn process networks, SDF, etc Methodology-specific Channels Master/Slave library
4
Glossary Module Basic building block for structural partitioning Basic building block for structural partitioning Contains ports, processes, data Contains ports, processes, data Other modules Other modules Process Basic specification mechanism for functional description Basic specification mechanism for functional description Three types Three types sc_method : sensitive to some ports/signals, no wait statementssc_method : sensitive to some ports/signals, no wait statements sc_thread: sensitive to some ports/signals with wait statementssc_thread: sensitive to some ports/signals with wait statements sc_cthread: sensitive to only clocksc_cthread: sensitive to only clock
5
Glossary Interface A set of operations for communication A set of operations for communication No specification about the actual implementation No specification about the actual implementation For example, a signal supports read and write operations For example, a signal supports read and write operations Port Explicit objects for inter-module communication Explicit objects for inter-module communication Each port object specifies the interface for communication Each port object specifies the interface for communication Channel An implementation of the interface operations An implementation of the interface operations Performs the actual data transfer Performs the actual data transfer Vary from signals to complex protocols. Vary from signals to complex protocols.
6
Module Module is the basic building block in SystemC SystemC has a macro for convenient module definition Macro name : SC_MODULE Macro name : SC_MODULE Macro implements C++ class inheritance Macro implements C++ class inheritance SC_MODULE(adder) { // ports, processes, internal data }; struct adder: SC_MODULE { // ports, processes, internal data };
7
Module constructor Module constructor also defined with another macro Macro name : SC_CTOR Macro name : SC_CTOR SC_CTOR must have module name as an argument SC_CTOR must have module name as an argument SC_MODULE(adder) { // ports, processes, internal data SC_CTOR(adder) { // body of constructor // process declaration, sensitivities etc } };
8
Module constructor User can also define own constructor Must include SC_HAS_PROCESS macro to define processes Must include SC_HAS_PROCESS macro to define processes SC_MODULE(adder) { // ports, processes, internal data SC_HAS_PROCESS(adder); adder(sc_module_name name; int other_param): sc_module(name){ // body of constructor // process declaration, sensitivities etc } };
9
Interface Consists of a set of operations Specifies only the signature of an operation name, parameter, return value name, parameter, return value All SystemC interfaces derived from sc_interface Contains a virtual function called register_port() Contains a virtual function called register_port() Connects a port to a channel through the interfaceConnects a port to a channel through the interface Arguments: port object and type name of the interface that port acceptsArguments: port object and type name of the interface that port accepts
10
Interface HW signal interfaces sc_signal_in_if sc_signal_in_if Contains virtual function read()Contains virtual function read() read() returns a constant reference to T such that value may be readread() returns a constant reference to T such that value may be read sc_signal_inout_if sc_signal_inout_if Derived from sc_signal_in_if Derived from sc_signal_in_if Contains virtual function write()Contains virtual function write() write() takes as input a constant reference to Twrite() takes as input a constant reference to T HW signal interfaces provide the functions that are implemented by channel
11
Port Ports provide the well-defined boundaries through which the module interacts Implicit interfaces such a global variable must be avoided Implicit interfaces such a global variable must be avoided Ports specify the interface that it uses through a template parameter All ports are derived from sc_port_base class
12
Port SystemC provides a template class for creating ports template class sc_port: ……// class derivation details omitted { public : IF* operator->(); // other member functions and member variables }; “IF” denotes the interface class N is the number of interfaces attached to the port Default value of 1 Default value of 1
13
Port Most prominent member of sc_port is operator->() Returns a pointer to the interface Returns a pointer to the interface Any interface method can be invoked through the port Any interface method can be invoked through the port read() and write() below are interface method calls read() and write() below are interface method calls sc_port > p; …… x = p->read(); ….. p->write(y);
14
Port User can derive specialized ports from sc_port class Signal ports are provided by SystemC Signal ports are provided by SystemC template class sc_in : public sc_port > …; template class sc_inout : public sc_port > …;
15
Port and Module SC_MODULE(adder) { sc_in a; sc_in b; sc_out c; // processes, etc SC_CTOR(adder) { // body of constructor // process declaration, sensitivities etc c.initialize(0); } };
16
Channel Port and Interface describe the functions available in the communication package Channel defines the implementation of the communication functions Channel is derived from the interface It implements the interface if it defines all the interface functions It implements the interface if it defines all the interface functions More than one Channel might implement that same interface in different ways A Channel might implement more than one interface
17
Channel SystemC provides for Primitive channels Primitive channels Hierarchical channels Hierarchical channels Primitive channel Examples: sc_signal, sc_mutex, sc_fifo Examples: sc_signal, sc_mutex, sc_fifo Hierarchical channel User defined channels User defined channels
18
Channel and Interface template class sc_signal_in_if : virtual public sc_interface { public: // get the value changed event virtual const sc_event& value_changed_event() const = 0; // read current value virtual const T& read const() = 0; }; template class sc_signal_inout_if : virtual public sc_signal_in_if { public: // write the new value virtual void write(const T&) = 0; };
19
Channel and Interface template class sc_signal :public sc_signal_inout_if, public sc_prim_channel public sc_prim_channel{ public: public: //get the default event virtual const sc_event& default_event() const { return m_value_changed_event;} virtual const sc_event& value_changed_event() const { return m_value_changed_event;} virtual const T& read() const { return m_cur_val;} virtual void write(const T& value_) { m_new_value = value_; m_new_value = value_; if ( ! (m_new_val == m_cur_val)) request_update(); if ( ! (m_new_val == m_cur_val)) request_update();}
20
Channel and Interface protected: protected: //get the default event virtual void update() { if ( ! (m_new_val == m_cur_value)) { if ( ! (m_new_val == m_cur_value)) { m_cur_value = m_new_value; m_value_changed_event.notify(SC_ZERO_TIME);}} T m_cur_valu; T m_new_val; sc_event m_value_changed_event; };
21
Channel Writing process calls write(const &T) method of the channel write(const &) stores the value in m_new_value Calls request_update() if new value different from previous Calls request_update() if new value different from previous request_update() informs the SystemC scheduler Change the value of the signal once the current cycle is over. Change the value of the signal once the current cycle is over. At the end of the simulation cycle Schedule calls update() to change the value of the signal Schedule calls update() to change the value of the signal update() calls m_value_changed_event.notify() if new value different from current Event notification causes the read process to be resumed in the following simulation cycle Event notification causes the read process to be resumed in the following simulation cycle
22
Process Basic unit of functionality in SystemC Process is contained in a module Described as a member function Described as a member function Not all member functions are processes Not all member functions are processes Process member function should be registered with the simulation kernel Registration is via a declaration in the module constructor Registration is via a declaration in the module constructor
23
Process and Module SC_MODULE(adder) { sc_in a; sc_in b; sc_out c; void compute() { c = a + b; } SC_CTOR(adder) { SC_METHOD(compute); sensitive << a << b; c.initialize(0); } };
24
Process Two basic kinds of processes SC_METHOD SC_METHOD SC_THREAD SC_THREAD SC_CTHREADSC_CTHREAD SC_METHOD Always executes its body from beginning to end and returns Always executes its body from beginning to end and returns Does not maintain an implicit execution state Does not maintain an implicit execution state States if required is maintained via module variables States if required is maintained via module variables
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.