SlideShare ist ein Scribd-Unternehmen logo
1 von 55
Ports
蘇文鈺
成大資訊
本投影片取材自:
SYSTEMC: FROM THE GROUND UP
By
David C. Black and Jack Donovan
Ports
• SystemC lets modules use channels inserted
between the communicating modules.
• Such communication method uses a concept
related to a mechanism called port.
• Actually, a port is a pointer to a channel
outside the module.
Communication via Ports

• modA communicates a value contained in local variable v by calling
the write method of the parent module’s channel c. modB may
retrieve a value via the read method of channel c.
• Notice that access is accomplished via pointers pA and pB.
• modA only needs access to write, and modB only needs access to
read.
• This separation of access is managed using a concept known as an
interface.
Interfaces

• An interface class is a class that contains no data members
and only contains pure virtual methods. The derived classes
implements the access methods, respectively.
• If an object is declared as a pointer to an interface class, it
may be used with multiple derived classes.
Relation between interface and
channel
• A SystemC interface is an abstract class that inherits
from sc_interface and provides only pure virtual
declarations of methods referenced by SystemC
channels and ports. No implementations or data are
provided in SystemC interface.
• A SystemC channel is a class that implements one or
more SystemC interface classes and inherits from
either sc_channel or sc_prim_channel. A channel
implements all the methods of the inherited
interface classes.
Two Examples of Using Ports
• Ways of connecting ports, channels, modules
and processes cannot be arbitrary.
Convenience of sc_interfaces using
Ports
• Top: modA and modB are connected via a FIFO.
• Bottom: modA and modB are connected via a
shared bus.
• But, NO change to the definition of modA or
modB is necessary.
• A SystemC port is a class templated with and
inheriting from a SystemC interface. Ports
allow access of channels across module
boundaries.
Syntax
• sc_port<interface> portname;
SC_MODULE(stereo_amp) {
sc_port<sc_fifo_in_if<int> > soundin_p;
sc_port<sc_fifo_out_if<int> > soundout_p;
};
// declared in module;
Many ways of connections
Naming
• PX: Ports, divided into two kinds: sc_port and
sc_export
• ifX: interfaces
• cX: channels
• prX: processes
• evX: events
• mX: modules
Interconnect
Rules
• Port connected to channel through interface
• Between processes, events are used for
signaling, possibly for synchronization.
• Processes can communicate with processes via
interfaces to channels connected to the submodule ports or by way of interfaces through a
modules itself using sc_export.
• Modules communicate with processes via
channels. Ports and corresponding interfaces are
needed, mostly.
Mechanism
1.
2.
3.
4.
5.

Instantiate modules and channels
Make required interfaces
Connecting ports
Modules connected to channels
Syntaxes of connecting ports:
1. mod_inst.portname(channel_instance); // By
Name
2. mod_instance(channel_instance,...); // By
Position
Example: Video Mixer
• //FILE: Rgb2YCrCb.h
SC_MODULE(Rgb2YCrCb) {
sc_port<sc_fifo_in_if<RGB_frame> > rgb_pi;
sc_port<sc_fifo_out_if<YCRCB_frame> >
ycrcb_po;
};
Figure 11-11. Example of Port Interconnect Setup (1 of 3)
• //FILE: YCRCB_Mixer.h
SC_MODULE(YCRCB_Mixer) {
sc_port<sc_fifo_in_if<float> > K_pi;
sc_port<sc_fifo_in_if<YCRCB_frame> >
a_pi, b_pi;
sc_port<sc_fifo_out_if<YCRCB_frame> > y_po;
);
Figure 11-12. Example of Port Interconnect Setup (2 of 3)
• //FILE: VIDEO_Mixer.h
SC_MODULE(VIDEO_Mixer) {
// ports
sc_port<sc_fifo_in_if<YCRCB_frame> > dvd_pi;
sc_port<sc_fifo_out_if<YCRCB_frame> > video_po;
sc_port<sc_fifo_in_if<MIXER_ctrl> > control;
sc_port<sc_fifo_out_if<MIXER_state> > status;
// local channels
sc_fifo<float> K;
sc_fifo<RGB_frame> rgb_graphics;
sc_fifo<YCRCB_frame> ycrcb_graphics;
// constructor
SC_HAS_PROCESS(VIDEO_Mixer);
VIDEO_Mixer(sc_module_name nm);
void Mixer_thread();
};
Figure 11-13. Example of Port Interconnect Setup (3 of 3)
VIDEO_Mixer::VIDEO_Mixer(sc_module_name nm)
: sc_module(nm)
{
// Instantiate
Rgb2YCrCb Rgb2YCrCb_i("Rgb2YCrCb_i");
YCRCB_Mixer YCRCB_Mixer_i("YCRCB_Mixer_i");
// Connect
Rgb2YCrCb_i.rgb_pi(rgb_graphics);
Rgb2YCrCb_i.ycrcb_po(ycrcb_graphics);
YCRCB_Mixer_i.K_pi(K);
YCRCB_Mixer_I.a_pi(dvd_pi);
YCRCB_Mixer_i.b_pi(ycrcb_graphics);
YCRCB_Mixer_i.y_po(video_po);
};
Figure 11-14. Example of Port Interconnect by Name
VIDEO_Mixer::VIDEO_Mixer(sc_module_name nm)
: sc_module(nm)
{
// Instantiate
Rgb2YCrCb Rgb2YCrCb_i("Rgb2YCrCb_i");
YCRCB_Mixer YCRCB_Mixer_i("YCRCB_Mixer_i");
// Connect
Rgb2YCrCb_i(rgb_graphics,ycrcb_graphics);
YCRCB_Mixer_i(K,dvd_pi,ycrcb_graphics,video_po);
};
Figure 11-15. Example of Port Interconnect by Position
Within a Process
• A process is needed to activate some actions
on channels associated with it.
• It is also needed that the process be
connected to modules/channels.
• One can access ports from within a
process, too.
• Syntax:
– portname->method(optional_args);
Example: Video Mixer
void VIDEO_Mixer::Mixer_thread() {
…
switch (control->read()) {
case MOVIE: K.write(0.0f); break;
case MENU: K.write(1.0f); break;
case FADE: K.write(0.5f); break;
default: status->write(ERROR); break;
}
….
}
Notes of Video Mixer Example
• K: a channel using sc_fifo
• Control: port
– sc_port<sc_fifo_in_if<MIXER_ctrl> > control;

• Status: port
– sc_port<sc_fifo_out_if<MIXER_state> > status;
sc_fifo Interfaces
• Interfaces of sc_fifo: sc_fifo_in_if<>, and
sc_fifo_out_if<>.
• The channel sc_fifo is used to hold the data of
the fifo.
• Methods:
write, read, num_free, num_available, event,
…
Standard Interfaces
Interfaces were defined prior to the creation
of a channel. The channel is just the place to
implement the interfaces and provides the
request-update behavior for a signal.
Sc_fifo
• sc_fifo_in_if<>, and sc_fifo_out_if<>, are
provided for sc_fifo<>.
• Defined prior to the creation of the channel
• The channel is the place to implement the
interfaces and holds the data implied by a
FIFO functionality.
• The interface is templated on a class name
just like the corresponding channel
sc_fifo_out_if
template <class T>
struct sc_fifo_out_if: virtual public sc_interface {
virtual void write (const T& ) = 0;
virtual bool nb_write (const T& ) = 0;
virtual int num_free()const = 0;
virtual const sc_event&
data_read_event() const = 0;
};
sc_fifo_in_if
template <class T>
struct sc_fifo_in_if : virtual public sc_interface {
virtual void read( T& ) = 0;
virtual T read() = 0;
virtual bool nb_read( T& ) = 0;
virtual int num_available() const = 0;
virtual const sc_event&
data_written_event() const = 0;
};
Sc_fifo and sc_signal
• If you simply use the read() and write()
methods in your module and do not rely on
the other methods, then your use of these
interfaces is very compatible sc_signal<>
• However, sc_fifo::read() and sc_fifo::write()
block waiting for the FIFO to empty;
whereas, sc_signal::read() and
sc_signal::write() are non-blocking
sc_signal interfaces
• sc_signal_in_if<>, sc_signal_out_if<>, and
sc_signal_inout_if<> are provided.
• The update portion of the behavior is provided as
a result of a call to request_update() .
• request_update() is indirectly resulted by a call
from sc_signal::write().
• The update is implemented with the protected
sc_signal::update() method call.
• sc_signal_in_if<> interface provides access to the
results through sc_signal::read().
sc_signal_in_if
// Definition of sc_signal<T> input interface
template <class T>
struct sc_signal_in_if : virtual public sc_interface {
virtual const sc_event&
value_changed_event() const = 0;
virtual const T& read() const = 0;
virtual const T& get_data_ref() const = 0;
virtual bool event () const = 0;
};
sc_signal_inout_if
// Definition of sc_signal<T> input/output interface
template <class T>
struct sc_signal_inout_if: public sc_signal_in_if<T>
{
virtual void write ( const T& ) = 0;
};
#define sc_signal_out_if sc_signal_inout_if
More about sc_signal interfaces
• This definition lets a module read the value of an
output signal directly rather than being forced to
keep a local copy
• sc_signal_inout_if<> inherits the input behavior
from sc_signal_in_if<>. Thus, sc_signal<>
channel inherits directly from this
channel, sc_signal_inout_if<>, rather than the
other two interfaces.
• sc_signal_in_if<> interface provides access to the
results through sc_signal::read().
sc_mutex_if
// Definition of sc_mutex_if interface
struct sc_mutex_if: virtual public sc_interface {
virtual int lock() = 0;
virtual int trylock() = 0;
virtual int unlock() = 0;
};
// No event methods are provided for sensitivity. If
event sensitivity is required, one must implement
own channels and interfaces.
sc_semaphore_if
// Definition of sc_semaphore_if interface
struct sc_semaphore_if : virtual public sc_interface
{
virtual int wait() = 0;
virtual int trywait() = 0;
virtual int post() = 0;
virtual int get_value() const = 0;
};
//Same to sc_mutex_if, no event methods are provided
for sensitivity. You have to do your own if necessary.
Static Sensitivity when used with ports
• Sensitivity to events:
– an SC_METHOD statically sensitive to the
data_written_event.
– monitor an sc_signal for any change in the data
using the value_changed_event.

• Ports are pointers initialized during the
elaboration stage. However, they are not
defined when the sensitive method needs to
know about them.
sc_event_finder
• sc_event_finder allows the determination of
the actual event be deferred until after the
elaboration.
• sc_event_finder must be defined for each
event defined by the interface.
– define template specializations of port/interface
combinations to instantiate a port, and include an
sc_event_finder in the specialized class.
Example: A port with sensitivity to the
positive edge event of sc_signal
• sc_event_finder takes two arguments:
– a reference to the port being found (*this)
– a reference to the member function, (posedge_event()) that returns a
reference to the event of interest and can be used as sensitivity.
struct ea_port_sc_signal_in_if_bool
: public sc_port<sc_signal_in_if<bool>,1>
{
typedef sc_signal_in_if<bool> if_type;
sc_event_finder& ef_posedge_event() const {
return *new sc_event_finder_t<if_type>(
*this,
&if_type::posedge_event
);
}
};
Use of event finder
SC_MODULE(my_module) {
ea_port_sc_signal_in_if_bool my_p;
SC_CTOR(…) {
SC_METHOD(my_method);
sensitive << my_p.ef_posedge_event();
}
void my_method();
};

• An important concept of SystemC is its mechanism for
sensitivity to a port.
• A process is always concerned with any change on its input
port.
• An interface associated with a port provides a method called
default_event() that returns a reference to an sc_event. The
standard interfaces for sc_signal and sc_buffer provide this
method.
sc_port array
• Provide multi-port or port array of liked
defined.
• Syntax:
– sc_port <interface[ ,N]> portname;
– // N=0..MAX Default N=1
Example

//FILE: Switch.h
SC_MODULE(Switch) {
sc_port<sc_fifo_in_if<int>, 4> T1_ip;
sc_port<sc_signal_out_if<bool>,0> request_op;
};
There are four ports to provide data and 9 users to request data from
the ports. The switch thread is responsible to route the data from a left
side port to a right side user.
Port connections

Please note the use of switch_i.request_op.
SystemC Exports
• Sc_export is similar to standard ports, but
different in its connectivity.
• It moves the channel inside a module and use
the port externally so that it looks like a
channel itself.
Sc_export
• It can be replaced by using normal channelinterface-port configuration, but
• It is sometimes desirable that it exports some
channels but keep others private. This is a
feature preferred by most IP provider;
• It can provides multiple interfaces at the top
level, though one can still use hierarchical
channels.
Other advantages
• Each sc_export contains an interface, so
connection is not required and hidden interface
can be made.
• A specific interface is hidden from IP provider, not
disclosed to the users.
• A model for profiling or exploration can be made
with such exports which can be dropped in the
later stage of development.
• Syntax:
– sc_export<interface> portname;
Syntax of internal channel binding
SC_MODULE(modulename) {
sc_export<interface> portname;
channel cinstance;
SC_CTOR (modulename) {
portname (cinstance);
}
};
Export portname is bound to channel cinstance.
Hierarchical sc_export

SC_MODULE (modulename) {
sc_export<interface> xportname;
module minstance;
SC_CTOR(modulename), minstance ("minstance") {
xportname(minstance.subxport);
}
};
Export binding to export.
Three points to be noted
• No array export is supported.
• Unlike a sc_port, It lacks the requirement of a
connection.
• Static sensitivity cannot be used here, though
one can use wait(exportname->event()) on
defined interfaces in an SC_THREAD.
Example: Bus Model
//CBus.h
#ifndef CBUS_H
#define CBUS_H
#include "CBus_if.h"
class North_bus; // Forward declarations
class South_bus;
class Debug_bus;
class CBus_rtl;
SC_MODULE(CBus) {
sc_export<CBus_North_if> north_p ;
sc_export<CBus_South_if> south_p;
SC_CTOR(CBus);
private:
North_bus* nbus_ci; South_bus* sbus_ci;
Debug_bus* debug_ci; CBus_rtl* rtl_i;
};
#endif
Example
//FILE: CBus.cpp
#include "CBus.h"
#include "North_bus.h"
#include "South_bus.h"
#include "Debug_bus.h"
#include "CBus_rtl_bus.h"
CBus::CBus(sc_module_name(nm): sc_module(nm) {
// Local instances
nbus_ci = new North_bus("nbus_ci");
sbus_ci = new South_bus("sbus_ci");
debug_ci = new Debug_bus("debug_ci");
rtl_i = new CBus_rtl("rtl_i");
// Export connectivity
north_p(nbus_ci);
south_p(sbus_ci);
// Implementation connectivity; debug bus is not provided;
}
Hierarchical Channel
• Module controls and processes data.
• Channel takes care of communication among modules.
• Interface allows independent implementation of
modules and channels as well as separation of
processing and communication.
• Primitive channels contains no hierarchy, ports, and so
on, so they are fast.
• Hierarchical channels are able to access ports, build
hierarchy so that they can be used to model more
complex bus architectures, such as AMBA, PCI,….
• Actually, hierarchical channels are just MODULES that
implement one or usually more than one interfaces.
Example: A simple Bus Model
Pin Accurate Timing Model
Making Interfaces
struct ea_heartbeat_if: public sc_interface {
virtual const sc_event& default_event() const = 0;
virtual const sc_event& posedge_event() const = 0;
};

struct CPU_if: public sc_interface {
virtual void write(unsigned long addr, long data)=0
virtual long read(unsigned long addr)=0;
};
Memory Model
//FILE: mem_arch.h
#include "CPU_if.h"
struct mem: public sc_channel, CPU_if {
// Constructors & destructor
explicit mem(sc_module_name nm,
unsigned long ba, unsigned sz)
: sc_channel(nm), m_base(ba), m_size(sz)
{ m_mem = new long[m_size]; }
~mem() { delete [] m_mem; }
// Interface implementations
virtual void write(unsigned long addr, long data) {
if (m_start <= addr && addr < m_base+m_size) {
m_mem[addr–m_base] = data;
}
}

virtual long read(unsigned long addr) {
if (m_start <= addr && addr < m_base+m_size) {
return m_mem[addr–m_base];
} else {
cout <<
"ERROR:"<<name()<<"@"<<sc_time_stamp
()
<< ": Illegal address: " << addr << endl;
sc_stop(); return 0;
}
}
private:
unsigned long m_base;
unsigned m_size;
long m_mem[];
mem(const mem&); // Disable
};
Header of a Hierarchical Channel
#include "CPU_if.h"
#include "ea_heartbeat_if.h"
SC_MODULE(cpu2pca), CPU_if {
// Ports
sc_port<ea_heartbeat_if> ck; // clock
sc_out<bool> ld; // load/execute command
sc_out<bool> rw; // read high/write low
sc_out<unsigned long> a; // address
sc_inout_rv<32> d; // data
// Constructor
SC_CTOR(cpu2pca) {}
// Interface implementations
void write(unsigned long addr, long data);
long read(unsigned long addr);
private:
cpu2pca(const cpu2pca&); // Disable
};
Implementation
#include <systemc.h>
#include "cpu2pca.h"
enum operation {WRITE=false, READ=true};
void cpu2pca::write(unsigned long addr, long data) {
wait(ck–>posedge_event());
ld–>write(true);
rw–>write(WRITE);
a–>write(addr);
d–>write(data);
wait(ck–>posedge_event());
ld–>write(false);
}
long cpu2pca::read(unsigned long addr) {
wait(ck–>posedge_event());
ld–>write(true);
rw–>write(READ);
a–>write(addr);
d–>write(FLOAT);
wait(ck–>posedge_event());
ld–>write(false);
return d–>read().to_long();
}

Weitere ähnliche Inhalte

Was ist angesagt?

Session 6 sv_randomization
Session 6 sv_randomizationSession 6 sv_randomization
Session 6 sv_randomizationNirav Desai
 
Challenges in Using UVM at SoC Level
Challenges in Using UVM at SoC LevelChallenges in Using UVM at SoC Level
Challenges in Using UVM at SoC LevelDVClub
 
Session 8 assertion_based_verification_and_interfaces
Session 8 assertion_based_verification_and_interfacesSession 8 assertion_based_verification_and_interfaces
Session 8 assertion_based_verification_and_interfacesNirav Desai
 
Uart VHDL RTL design tutorial
Uart VHDL RTL design tutorialUart VHDL RTL design tutorial
Uart VHDL RTL design tutorialNabil Chouba
 
Verilog Tasks & Functions
Verilog Tasks & FunctionsVerilog Tasks & Functions
Verilog Tasks & Functionsanand hd
 
Presentation systemc
Presentation systemcPresentation systemc
Presentation systemcSUBRAHMANYA S
 
SOC Verification using SystemVerilog
SOC Verification using SystemVerilog SOC Verification using SystemVerilog
SOC Verification using SystemVerilog Ramdas Mozhikunnath
 
Soc architecture and design
Soc architecture and designSoc architecture and design
Soc architecture and designSatya Harish
 
2019 2 testing and verification of vlsi design_verification
2019 2 testing and verification of vlsi design_verification2019 2 testing and verification of vlsi design_verification
2019 2 testing and verification of vlsi design_verificationUsha Mehta
 
Low-Power Design and Verification
Low-Power Design and VerificationLow-Power Design and Verification
Low-Power Design and VerificationDVClub
 

Was ist angesagt? (20)

I2C
I2CI2C
I2C
 
PCI Drivers
PCI DriversPCI Drivers
PCI Drivers
 
Session 6 sv_randomization
Session 6 sv_randomizationSession 6 sv_randomization
Session 6 sv_randomization
 
Challenges in Using UVM at SoC Level
Challenges in Using UVM at SoC LevelChallenges in Using UVM at SoC Level
Challenges in Using UVM at SoC Level
 
Session 8 assertion_based_verification_and_interfaces
Session 8 assertion_based_verification_and_interfacesSession 8 assertion_based_verification_and_interfaces
Session 8 assertion_based_verification_and_interfaces
 
PCIe DL_layer_3.0.1 (1)
PCIe DL_layer_3.0.1 (1)PCIe DL_layer_3.0.1 (1)
PCIe DL_layer_3.0.1 (1)
 
Uart VHDL RTL design tutorial
Uart VHDL RTL design tutorialUart VHDL RTL design tutorial
Uart VHDL RTL design tutorial
 
Verilog Tasks & Functions
Verilog Tasks & FunctionsVerilog Tasks & Functions
Verilog Tasks & Functions
 
Inter Process Communication
Inter Process CommunicationInter Process Communication
Inter Process Communication
 
CPU Verification
CPU VerificationCPU Verification
CPU Verification
 
Presentation systemc
Presentation systemcPresentation systemc
Presentation systemc
 
Ral by pushpa
Ral by pushpa Ral by pushpa
Ral by pushpa
 
Verilog Tasks and functions
Verilog Tasks and functionsVerilog Tasks and functions
Verilog Tasks and functions
 
SOC Verification using SystemVerilog
SOC Verification using SystemVerilog SOC Verification using SystemVerilog
SOC Verification using SystemVerilog
 
Soc architecture and design
Soc architecture and designSoc architecture and design
Soc architecture and design
 
2019 2 testing and verification of vlsi design_verification
2019 2 testing and verification of vlsi design_verification2019 2 testing and verification of vlsi design_verification
2019 2 testing and verification of vlsi design_verification
 
Vlsi Synthesis
Vlsi SynthesisVlsi Synthesis
Vlsi Synthesis
 
Low-Power Design and Verification
Low-Power Design and VerificationLow-Power Design and Verification
Low-Power Design and Verification
 
Memory model
Memory modelMemory model
Memory model
 
Cache coherence
Cache coherenceCache coherence
Cache coherence
 

Andere mochten auch

Week1 Electronic System-level ESL Design and SystemC Begin
Week1 Electronic System-level ESL Design and SystemC BeginWeek1 Electronic System-level ESL Design and SystemC Begin
Week1 Electronic System-level ESL Design and SystemC Begin敬倫 林
 
Concurrency 2010
Concurrency 2010Concurrency 2010
Concurrency 2010敬倫 林
 
Systemc overview 2010
Systemc overview 2010Systemc overview 2010
Systemc overview 2010敬倫 林
 
C++ process new
C++ process newC++ process new
C++ process new敬倫 林
 
Transaction level modeling an overview
Transaction level modeling an overviewTransaction level modeling an overview
Transaction level modeling an overviewfagunp
 
Track c-High speed transaction-based hw-sw coverification -eve
Track c-High speed transaction-based hw-sw coverification -eveTrack c-High speed transaction-based hw-sw coverification -eve
Track c-High speed transaction-based hw-sw coverification -evechiportal
 
Top five reasons why every DV engineer will love the latest systemverilog 201...
Top five reasons why every DV engineer will love the latest systemverilog 201...Top five reasons why every DV engineer will love the latest systemverilog 201...
Top five reasons why every DV engineer will love the latest systemverilog 201...Srinivasan Venkataramanan
 
A Systematic Approach to Creating Behavioral Models (white paper) v1.0
A Systematic Approach to Creating Behavioral Models (white paper) v1.0A Systematic Approach to Creating Behavioral Models (white paper) v1.0
A Systematic Approach to Creating Behavioral Models (white paper) v1.0Robert O. Peruzzi, PhD, PE, DFE
 
SystemVerilog Assertions (SVA) in the Design/Verification Process
SystemVerilog Assertions (SVA) in the Design/Verification ProcessSystemVerilog Assertions (SVA) in the Design/Verification Process
SystemVerilog Assertions (SVA) in the Design/Verification ProcessDVClub
 
How to Connect SystemVerilog with Octave
How to Connect SystemVerilog with OctaveHow to Connect SystemVerilog with Octave
How to Connect SystemVerilog with OctaveAmiq Consulting
 
UVM Ral model usage
UVM Ral model usageUVM Ral model usage
UVM Ral model usageParth Pandya
 
System On Chip
System On ChipSystem On Chip
System On Chipanishgoel
 
UVM Update: Register Package
UVM Update: Register PackageUVM Update: Register Package
UVM Update: Register PackageDVClub
 
SystemVerilog Assertions verification with SVAUnit - DVCon US 2016 Tutorial
SystemVerilog Assertions verification with SVAUnit - DVCon US 2016 TutorialSystemVerilog Assertions verification with SVAUnit - DVCon US 2016 Tutorial
SystemVerilog Assertions verification with SVAUnit - DVCon US 2016 TutorialAmiq Consulting
 
Design and Implementation of an Advanced DMA Controller on AMBA-Based SoC
Design and Implementation of an Advanced DMA Controller on AMBA-Based SoCDesign and Implementation of an Advanced DMA Controller on AMBA-Based SoC
Design and Implementation of an Advanced DMA Controller on AMBA-Based SoCRabindranath Tagore University, Bhopal
 

Andere mochten auch (20)

Week1 Electronic System-level ESL Design and SystemC Begin
Week1 Electronic System-level ESL Design and SystemC BeginWeek1 Electronic System-level ESL Design and SystemC Begin
Week1 Electronic System-level ESL Design and SystemC Begin
 
Esl basics
Esl basicsEsl basics
Esl basics
 
Concurrency 2010
Concurrency 2010Concurrency 2010
Concurrency 2010
 
Systemc overview 2010
Systemc overview 2010Systemc overview 2010
Systemc overview 2010
 
C++ process new
C++ process newC++ process new
C++ process new
 
Transaction level modeling an overview
Transaction level modeling an overviewTransaction level modeling an overview
Transaction level modeling an overview
 
MixedSignal UVM Demo CDNLive
MixedSignal UVM Demo CDNLiveMixedSignal UVM Demo CDNLive
MixedSignal UVM Demo CDNLive
 
Track c-High speed transaction-based hw-sw coverification -eve
Track c-High speed transaction-based hw-sw coverification -eveTrack c-High speed transaction-based hw-sw coverification -eve
Track c-High speed transaction-based hw-sw coverification -eve
 
Top five reasons why every DV engineer will love the latest systemverilog 201...
Top five reasons why every DV engineer will love the latest systemverilog 201...Top five reasons why every DV engineer will love the latest systemverilog 201...
Top five reasons why every DV engineer will love the latest systemverilog 201...
 
A Systematic Approach to Creating Behavioral Models (white paper) v1.0
A Systematic Approach to Creating Behavioral Models (white paper) v1.0A Systematic Approach to Creating Behavioral Models (white paper) v1.0
A Systematic Approach to Creating Behavioral Models (white paper) v1.0
 
SystemVerilog Assertions (SVA) in the Design/Verification Process
SystemVerilog Assertions (SVA) in the Design/Verification ProcessSystemVerilog Assertions (SVA) in the Design/Verification Process
SystemVerilog Assertions (SVA) in the Design/Verification Process
 
How to Connect SystemVerilog with Octave
How to Connect SystemVerilog with OctaveHow to Connect SystemVerilog with Octave
How to Connect SystemVerilog with Octave
 
UVM Ral model usage
UVM Ral model usageUVM Ral model usage
UVM Ral model usage
 
System On Chip
System On ChipSystem On Chip
System On Chip
 
UVM Update: Register Package
UVM Update: Register PackageUVM Update: Register Package
UVM Update: Register Package
 
SystemVerilog Assertions verification with SVAUnit - DVCon US 2016 Tutorial
SystemVerilog Assertions verification with SVAUnit - DVCon US 2016 TutorialSystemVerilog Assertions verification with SVAUnit - DVCon US 2016 Tutorial
SystemVerilog Assertions verification with SVAUnit - DVCon US 2016 Tutorial
 
stack
stackstack
stack
 
Design and Implementation of an Advanced DMA Controller on AMBA-Based SoC
Design and Implementation of an Advanced DMA Controller on AMBA-Based SoCDesign and Implementation of an Advanced DMA Controller on AMBA-Based SoC
Design and Implementation of an Advanced DMA Controller on AMBA-Based SoC
 
Queue
QueueQueue
Queue
 
Tree
TreeTree
Tree
 

Ähnlich wie SystemC Ports

Rodrigo Almeida - Microkernel development from project to implementation
Rodrigo Almeida - Microkernel development from project to implementationRodrigo Almeida - Microkernel development from project to implementation
Rodrigo Almeida - Microkernel development from project to implementationFelipe Prado
 
systemverilog-interview-questions.docx
systemverilog-interview-questions.docxsystemverilog-interview-questions.docx
systemverilog-interview-questions.docxssuser1c8ca21
 
Evento formativo Spring 3 ottobre 2019
Evento formativo Spring 3 ottobre 2019Evento formativo Spring 3 ottobre 2019
Evento formativo Spring 3 ottobre 2019Giorgio Bernardi
 
tau 2015 spyrou fpga timing
tau 2015 spyrou fpga timingtau 2015 spyrou fpga timing
tau 2015 spyrou fpga timingTom Spyrou
 
Socket programming using C
Socket programming using CSocket programming using C
Socket programming using CAjit Nayak
 
PVS-Studio delved into the FreeBSD kernel
PVS-Studio delved into the FreeBSD kernelPVS-Studio delved into the FreeBSD kernel
PVS-Studio delved into the FreeBSD kernelPVS-Studio
 
Fpga implementation of multi protocol data
Fpga implementation of multi protocol dataFpga implementation of multi protocol data
Fpga implementation of multi protocol dataeSAT Publishing House
 
UVM_TB_20220621_slides-1.pdf
UVM_TB_20220621_slides-1.pdfUVM_TB_20220621_slides-1.pdf
UVM_TB_20220621_slides-1.pdfSamHoney6
 
Introduction to eBPF and XDP
Introduction to eBPF and XDPIntroduction to eBPF and XDP
Introduction to eBPF and XDPlcplcp1
 
Modification of l3 learning switch code for firewall functionality in pox con...
Modification of l3 learning switch code for firewall functionality in pox con...Modification of l3 learning switch code for firewall functionality in pox con...
Modification of l3 learning switch code for firewall functionality in pox con...eSAT Journals
 
Checking the Cross-Platform Framework Cocos2d-x
Checking the Cross-Platform Framework Cocos2d-xChecking the Cross-Platform Framework Cocos2d-x
Checking the Cross-Platform Framework Cocos2d-xAndrey Karpov
 
100 bugs in Open Source C/C++ projects
100 bugs in Open Source C/C++ projects 100 bugs in Open Source C/C++ projects
100 bugs in Open Source C/C++ projects Andrey Karpov
 
IWAN Lab Guide
IWAN Lab GuideIWAN Lab Guide
IWAN Lab Guidejww330015
 
Ekon25 mORMot 2 Server-Side Notifications
Ekon25 mORMot 2 Server-Side NotificationsEkon25 mORMot 2 Server-Side Notifications
Ekon25 mORMot 2 Server-Side NotificationsArnaud Bouchez
 

Ähnlich wie SystemC Ports (20)

Tierney bq207
Tierney bq207Tierney bq207
Tierney bq207
 
Verilog
VerilogVerilog
Verilog
 
Rodrigo Almeida - Microkernel development from project to implementation
Rodrigo Almeida - Microkernel development from project to implementationRodrigo Almeida - Microkernel development from project to implementation
Rodrigo Almeida - Microkernel development from project to implementation
 
Embedded networks
Embedded networksEmbedded networks
Embedded networks
 
Am044253258
Am044253258Am044253258
Am044253258
 
systemverilog-interview-questions.docx
systemverilog-interview-questions.docxsystemverilog-interview-questions.docx
systemverilog-interview-questions.docx
 
Evento formativo Spring 3 ottobre 2019
Evento formativo Spring 3 ottobre 2019Evento formativo Spring 3 ottobre 2019
Evento formativo Spring 3 ottobre 2019
 
Remote client copy
Remote client copyRemote client copy
Remote client copy
 
tau 2015 spyrou fpga timing
tau 2015 spyrou fpga timingtau 2015 spyrou fpga timing
tau 2015 spyrou fpga timing
 
Onnc intro
Onnc introOnnc intro
Onnc intro
 
Socket programming using C
Socket programming using CSocket programming using C
Socket programming using C
 
PVS-Studio delved into the FreeBSD kernel
PVS-Studio delved into the FreeBSD kernelPVS-Studio delved into the FreeBSD kernel
PVS-Studio delved into the FreeBSD kernel
 
Fpga implementation of multi protocol data
Fpga implementation of multi protocol dataFpga implementation of multi protocol data
Fpga implementation of multi protocol data
 
UVM_TB_20220621_slides-1.pdf
UVM_TB_20220621_slides-1.pdfUVM_TB_20220621_slides-1.pdf
UVM_TB_20220621_slides-1.pdf
 
Introduction to eBPF and XDP
Introduction to eBPF and XDPIntroduction to eBPF and XDP
Introduction to eBPF and XDP
 
Modification of l3 learning switch code for firewall functionality in pox con...
Modification of l3 learning switch code for firewall functionality in pox con...Modification of l3 learning switch code for firewall functionality in pox con...
Modification of l3 learning switch code for firewall functionality in pox con...
 
Checking the Cross-Platform Framework Cocos2d-x
Checking the Cross-Platform Framework Cocos2d-xChecking the Cross-Platform Framework Cocos2d-x
Checking the Cross-Platform Framework Cocos2d-x
 
100 bugs in Open Source C/C++ projects
100 bugs in Open Source C/C++ projects 100 bugs in Open Source C/C++ projects
100 bugs in Open Source C/C++ projects
 
IWAN Lab Guide
IWAN Lab GuideIWAN Lab Guide
IWAN Lab Guide
 
Ekon25 mORMot 2 Server-Side Notifications
Ekon25 mORMot 2 Server-Side NotificationsEkon25 mORMot 2 Server-Side Notifications
Ekon25 mORMot 2 Server-Side Notifications
 

Kürzlich hochgeladen

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 

Kürzlich hochgeladen (20)

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 

SystemC Ports

  • 1. Ports 蘇文鈺 成大資訊 本投影片取材自: SYSTEMC: FROM THE GROUND UP By David C. Black and Jack Donovan
  • 2. Ports • SystemC lets modules use channels inserted between the communicating modules. • Such communication method uses a concept related to a mechanism called port. • Actually, a port is a pointer to a channel outside the module.
  • 3. Communication via Ports • modA communicates a value contained in local variable v by calling the write method of the parent module’s channel c. modB may retrieve a value via the read method of channel c. • Notice that access is accomplished via pointers pA and pB. • modA only needs access to write, and modB only needs access to read. • This separation of access is managed using a concept known as an interface.
  • 4. Interfaces • An interface class is a class that contains no data members and only contains pure virtual methods. The derived classes implements the access methods, respectively. • If an object is declared as a pointer to an interface class, it may be used with multiple derived classes.
  • 5. Relation between interface and channel • A SystemC interface is an abstract class that inherits from sc_interface and provides only pure virtual declarations of methods referenced by SystemC channels and ports. No implementations or data are provided in SystemC interface. • A SystemC channel is a class that implements one or more SystemC interface classes and inherits from either sc_channel or sc_prim_channel. A channel implements all the methods of the inherited interface classes.
  • 6. Two Examples of Using Ports • Ways of connecting ports, channels, modules and processes cannot be arbitrary.
  • 7. Convenience of sc_interfaces using Ports • Top: modA and modB are connected via a FIFO. • Bottom: modA and modB are connected via a shared bus. • But, NO change to the definition of modA or modB is necessary. • A SystemC port is a class templated with and inheriting from a SystemC interface. Ports allow access of channels across module boundaries.
  • 8. Syntax • sc_port<interface> portname; SC_MODULE(stereo_amp) { sc_port<sc_fifo_in_if<int> > soundin_p; sc_port<sc_fifo_out_if<int> > soundout_p; }; // declared in module;
  • 9. Many ways of connections
  • 10. Naming • PX: Ports, divided into two kinds: sc_port and sc_export • ifX: interfaces • cX: channels • prX: processes • evX: events • mX: modules
  • 12. Rules • Port connected to channel through interface • Between processes, events are used for signaling, possibly for synchronization. • Processes can communicate with processes via interfaces to channels connected to the submodule ports or by way of interfaces through a modules itself using sc_export. • Modules communicate with processes via channels. Ports and corresponding interfaces are needed, mostly.
  • 13. Mechanism 1. 2. 3. 4. 5. Instantiate modules and channels Make required interfaces Connecting ports Modules connected to channels Syntaxes of connecting ports: 1. mod_inst.portname(channel_instance); // By Name 2. mod_instance(channel_instance,...); // By Position
  • 14. Example: Video Mixer • //FILE: Rgb2YCrCb.h SC_MODULE(Rgb2YCrCb) { sc_port<sc_fifo_in_if<RGB_frame> > rgb_pi; sc_port<sc_fifo_out_if<YCRCB_frame> > ycrcb_po; }; Figure 11-11. Example of Port Interconnect Setup (1 of 3)
  • 15. • //FILE: YCRCB_Mixer.h SC_MODULE(YCRCB_Mixer) { sc_port<sc_fifo_in_if<float> > K_pi; sc_port<sc_fifo_in_if<YCRCB_frame> > a_pi, b_pi; sc_port<sc_fifo_out_if<YCRCB_frame> > y_po; ); Figure 11-12. Example of Port Interconnect Setup (2 of 3)
  • 16. • //FILE: VIDEO_Mixer.h SC_MODULE(VIDEO_Mixer) { // ports sc_port<sc_fifo_in_if<YCRCB_frame> > dvd_pi; sc_port<sc_fifo_out_if<YCRCB_frame> > video_po; sc_port<sc_fifo_in_if<MIXER_ctrl> > control; sc_port<sc_fifo_out_if<MIXER_state> > status; // local channels sc_fifo<float> K; sc_fifo<RGB_frame> rgb_graphics; sc_fifo<YCRCB_frame> ycrcb_graphics; // constructor SC_HAS_PROCESS(VIDEO_Mixer); VIDEO_Mixer(sc_module_name nm); void Mixer_thread(); }; Figure 11-13. Example of Port Interconnect Setup (3 of 3)
  • 17. VIDEO_Mixer::VIDEO_Mixer(sc_module_name nm) : sc_module(nm) { // Instantiate Rgb2YCrCb Rgb2YCrCb_i("Rgb2YCrCb_i"); YCRCB_Mixer YCRCB_Mixer_i("YCRCB_Mixer_i"); // Connect Rgb2YCrCb_i.rgb_pi(rgb_graphics); Rgb2YCrCb_i.ycrcb_po(ycrcb_graphics); YCRCB_Mixer_i.K_pi(K); YCRCB_Mixer_I.a_pi(dvd_pi); YCRCB_Mixer_i.b_pi(ycrcb_graphics); YCRCB_Mixer_i.y_po(video_po); }; Figure 11-14. Example of Port Interconnect by Name
  • 18. VIDEO_Mixer::VIDEO_Mixer(sc_module_name nm) : sc_module(nm) { // Instantiate Rgb2YCrCb Rgb2YCrCb_i("Rgb2YCrCb_i"); YCRCB_Mixer YCRCB_Mixer_i("YCRCB_Mixer_i"); // Connect Rgb2YCrCb_i(rgb_graphics,ycrcb_graphics); YCRCB_Mixer_i(K,dvd_pi,ycrcb_graphics,video_po); }; Figure 11-15. Example of Port Interconnect by Position
  • 19. Within a Process • A process is needed to activate some actions on channels associated with it. • It is also needed that the process be connected to modules/channels. • One can access ports from within a process, too. • Syntax: – portname->method(optional_args);
  • 20. Example: Video Mixer void VIDEO_Mixer::Mixer_thread() { … switch (control->read()) { case MOVIE: K.write(0.0f); break; case MENU: K.write(1.0f); break; case FADE: K.write(0.5f); break; default: status->write(ERROR); break; } …. }
  • 21. Notes of Video Mixer Example • K: a channel using sc_fifo • Control: port – sc_port<sc_fifo_in_if<MIXER_ctrl> > control; • Status: port – sc_port<sc_fifo_out_if<MIXER_state> > status;
  • 22. sc_fifo Interfaces • Interfaces of sc_fifo: sc_fifo_in_if<>, and sc_fifo_out_if<>. • The channel sc_fifo is used to hold the data of the fifo. • Methods: write, read, num_free, num_available, event, …
  • 23. Standard Interfaces Interfaces were defined prior to the creation of a channel. The channel is just the place to implement the interfaces and provides the request-update behavior for a signal.
  • 24. Sc_fifo • sc_fifo_in_if<>, and sc_fifo_out_if<>, are provided for sc_fifo<>. • Defined prior to the creation of the channel • The channel is the place to implement the interfaces and holds the data implied by a FIFO functionality. • The interface is templated on a class name just like the corresponding channel
  • 25. sc_fifo_out_if template <class T> struct sc_fifo_out_if: virtual public sc_interface { virtual void write (const T& ) = 0; virtual bool nb_write (const T& ) = 0; virtual int num_free()const = 0; virtual const sc_event& data_read_event() const = 0; };
  • 26. sc_fifo_in_if template <class T> struct sc_fifo_in_if : virtual public sc_interface { virtual void read( T& ) = 0; virtual T read() = 0; virtual bool nb_read( T& ) = 0; virtual int num_available() const = 0; virtual const sc_event& data_written_event() const = 0; };
  • 27. Sc_fifo and sc_signal • If you simply use the read() and write() methods in your module and do not rely on the other methods, then your use of these interfaces is very compatible sc_signal<> • However, sc_fifo::read() and sc_fifo::write() block waiting for the FIFO to empty; whereas, sc_signal::read() and sc_signal::write() are non-blocking
  • 28. sc_signal interfaces • sc_signal_in_if<>, sc_signal_out_if<>, and sc_signal_inout_if<> are provided. • The update portion of the behavior is provided as a result of a call to request_update() . • request_update() is indirectly resulted by a call from sc_signal::write(). • The update is implemented with the protected sc_signal::update() method call. • sc_signal_in_if<> interface provides access to the results through sc_signal::read().
  • 29. sc_signal_in_if // Definition of sc_signal<T> input interface template <class T> struct sc_signal_in_if : virtual public sc_interface { virtual const sc_event& value_changed_event() const = 0; virtual const T& read() const = 0; virtual const T& get_data_ref() const = 0; virtual bool event () const = 0; };
  • 30. sc_signal_inout_if // Definition of sc_signal<T> input/output interface template <class T> struct sc_signal_inout_if: public sc_signal_in_if<T> { virtual void write ( const T& ) = 0; }; #define sc_signal_out_if sc_signal_inout_if
  • 31. More about sc_signal interfaces • This definition lets a module read the value of an output signal directly rather than being forced to keep a local copy • sc_signal_inout_if<> inherits the input behavior from sc_signal_in_if<>. Thus, sc_signal<> channel inherits directly from this channel, sc_signal_inout_if<>, rather than the other two interfaces. • sc_signal_in_if<> interface provides access to the results through sc_signal::read().
  • 32. sc_mutex_if // Definition of sc_mutex_if interface struct sc_mutex_if: virtual public sc_interface { virtual int lock() = 0; virtual int trylock() = 0; virtual int unlock() = 0; }; // No event methods are provided for sensitivity. If event sensitivity is required, one must implement own channels and interfaces.
  • 33. sc_semaphore_if // Definition of sc_semaphore_if interface struct sc_semaphore_if : virtual public sc_interface { virtual int wait() = 0; virtual int trywait() = 0; virtual int post() = 0; virtual int get_value() const = 0; }; //Same to sc_mutex_if, no event methods are provided for sensitivity. You have to do your own if necessary.
  • 34. Static Sensitivity when used with ports • Sensitivity to events: – an SC_METHOD statically sensitive to the data_written_event. – monitor an sc_signal for any change in the data using the value_changed_event. • Ports are pointers initialized during the elaboration stage. However, they are not defined when the sensitive method needs to know about them.
  • 35. sc_event_finder • sc_event_finder allows the determination of the actual event be deferred until after the elaboration. • sc_event_finder must be defined for each event defined by the interface. – define template specializations of port/interface combinations to instantiate a port, and include an sc_event_finder in the specialized class.
  • 36. Example: A port with sensitivity to the positive edge event of sc_signal • sc_event_finder takes two arguments: – a reference to the port being found (*this) – a reference to the member function, (posedge_event()) that returns a reference to the event of interest and can be used as sensitivity. struct ea_port_sc_signal_in_if_bool : public sc_port<sc_signal_in_if<bool>,1> { typedef sc_signal_in_if<bool> if_type; sc_event_finder& ef_posedge_event() const { return *new sc_event_finder_t<if_type>( *this, &if_type::posedge_event ); } };
  • 37. Use of event finder SC_MODULE(my_module) { ea_port_sc_signal_in_if_bool my_p; SC_CTOR(…) { SC_METHOD(my_method); sensitive << my_p.ef_posedge_event(); } void my_method(); }; • An important concept of SystemC is its mechanism for sensitivity to a port. • A process is always concerned with any change on its input port. • An interface associated with a port provides a method called default_event() that returns a reference to an sc_event. The standard interfaces for sc_signal and sc_buffer provide this method.
  • 38. sc_port array • Provide multi-port or port array of liked defined. • Syntax: – sc_port <interface[ ,N]> portname; – // N=0..MAX Default N=1
  • 39. Example //FILE: Switch.h SC_MODULE(Switch) { sc_port<sc_fifo_in_if<int>, 4> T1_ip; sc_port<sc_signal_out_if<bool>,0> request_op; }; There are four ports to provide data and 9 users to request data from the ports. The switch thread is responsible to route the data from a left side port to a right side user.
  • 40. Port connections Please note the use of switch_i.request_op.
  • 41. SystemC Exports • Sc_export is similar to standard ports, but different in its connectivity. • It moves the channel inside a module and use the port externally so that it looks like a channel itself.
  • 42. Sc_export • It can be replaced by using normal channelinterface-port configuration, but • It is sometimes desirable that it exports some channels but keep others private. This is a feature preferred by most IP provider; • It can provides multiple interfaces at the top level, though one can still use hierarchical channels.
  • 43. Other advantages • Each sc_export contains an interface, so connection is not required and hidden interface can be made. • A specific interface is hidden from IP provider, not disclosed to the users. • A model for profiling or exploration can be made with such exports which can be dropped in the later stage of development. • Syntax: – sc_export<interface> portname;
  • 44. Syntax of internal channel binding SC_MODULE(modulename) { sc_export<interface> portname; channel cinstance; SC_CTOR (modulename) { portname (cinstance); } }; Export portname is bound to channel cinstance.
  • 45. Hierarchical sc_export SC_MODULE (modulename) { sc_export<interface> xportname; module minstance; SC_CTOR(modulename), minstance ("minstance") { xportname(minstance.subxport); } }; Export binding to export.
  • 46. Three points to be noted • No array export is supported. • Unlike a sc_port, It lacks the requirement of a connection. • Static sensitivity cannot be used here, though one can use wait(exportname->event()) on defined interfaces in an SC_THREAD.
  • 47. Example: Bus Model //CBus.h #ifndef CBUS_H #define CBUS_H #include "CBus_if.h" class North_bus; // Forward declarations class South_bus; class Debug_bus; class CBus_rtl; SC_MODULE(CBus) { sc_export<CBus_North_if> north_p ; sc_export<CBus_South_if> south_p; SC_CTOR(CBus); private: North_bus* nbus_ci; South_bus* sbus_ci; Debug_bus* debug_ci; CBus_rtl* rtl_i; }; #endif
  • 48. Example //FILE: CBus.cpp #include "CBus.h" #include "North_bus.h" #include "South_bus.h" #include "Debug_bus.h" #include "CBus_rtl_bus.h" CBus::CBus(sc_module_name(nm): sc_module(nm) { // Local instances nbus_ci = new North_bus("nbus_ci"); sbus_ci = new South_bus("sbus_ci"); debug_ci = new Debug_bus("debug_ci"); rtl_i = new CBus_rtl("rtl_i"); // Export connectivity north_p(nbus_ci); south_p(sbus_ci); // Implementation connectivity; debug bus is not provided; }
  • 49. Hierarchical Channel • Module controls and processes data. • Channel takes care of communication among modules. • Interface allows independent implementation of modules and channels as well as separation of processing and communication. • Primitive channels contains no hierarchy, ports, and so on, so they are fast. • Hierarchical channels are able to access ports, build hierarchy so that they can be used to model more complex bus architectures, such as AMBA, PCI,…. • Actually, hierarchical channels are just MODULES that implement one or usually more than one interfaces.
  • 50. Example: A simple Bus Model
  • 52. Making Interfaces struct ea_heartbeat_if: public sc_interface { virtual const sc_event& default_event() const = 0; virtual const sc_event& posedge_event() const = 0; }; struct CPU_if: public sc_interface { virtual void write(unsigned long addr, long data)=0 virtual long read(unsigned long addr)=0; };
  • 53. Memory Model //FILE: mem_arch.h #include "CPU_if.h" struct mem: public sc_channel, CPU_if { // Constructors & destructor explicit mem(sc_module_name nm, unsigned long ba, unsigned sz) : sc_channel(nm), m_base(ba), m_size(sz) { m_mem = new long[m_size]; } ~mem() { delete [] m_mem; } // Interface implementations virtual void write(unsigned long addr, long data) { if (m_start <= addr && addr < m_base+m_size) { m_mem[addr–m_base] = data; } } virtual long read(unsigned long addr) { if (m_start <= addr && addr < m_base+m_size) { return m_mem[addr–m_base]; } else { cout << "ERROR:"<<name()<<"@"<<sc_time_stamp () << ": Illegal address: " << addr << endl; sc_stop(); return 0; } } private: unsigned long m_base; unsigned m_size; long m_mem[]; mem(const mem&); // Disable };
  • 54. Header of a Hierarchical Channel #include "CPU_if.h" #include "ea_heartbeat_if.h" SC_MODULE(cpu2pca), CPU_if { // Ports sc_port<ea_heartbeat_if> ck; // clock sc_out<bool> ld; // load/execute command sc_out<bool> rw; // read high/write low sc_out<unsigned long> a; // address sc_inout_rv<32> d; // data // Constructor SC_CTOR(cpu2pca) {} // Interface implementations void write(unsigned long addr, long data); long read(unsigned long addr); private: cpu2pca(const cpu2pca&); // Disable };
  • 55. Implementation #include <systemc.h> #include "cpu2pca.h" enum operation {WRITE=false, READ=true}; void cpu2pca::write(unsigned long addr, long data) { wait(ck–>posedge_event()); ld–>write(true); rw–>write(WRITE); a–>write(addr); d–>write(data); wait(ck–>posedge_event()); ld–>write(false); } long cpu2pca::read(unsigned long addr) { wait(ck–>posedge_event()); ld–>write(true); rw–>write(READ); a–>write(addr); d–>write(FLOAT); wait(ck–>posedge_event()); ld–>write(false); return d–>read().to_long(); }