HDL Lecture3
HDL Lecture3
HDL Lecture3
Languages
VHDL/Verilog
Analysis
Simulation
Result
Refinement Synthesis
SystemC Model
Simulation
Refinement
Synthesis
Modules
Basic units of hierarchy
Processes
Concurrent threads of execution
Events
Control of the processes timing
Channels
Means of communication of modules
Interfaces
Definitions of features a channel must implement
Ports
Access points for modules to connect to channels
Synopsys University Courseware
Copyright © 2014 Synopsys, Inc. All rights reserved.
Hardware Description Languages
Lecture - 3
Developed By: Vazgen Melikyan
13
Modules
Module declaration
SC_MODULE(module_name) {
// ports, logic, etc.
SC_CTOR {
// Module constructor
// contains process declaration, sensitivities, etc.
}
}
Hierarchical
Module 1 Module 2
channel
port
interface
Synopsys University Courseware
Copyright © 2014 Synopsys, Inc. All rights reserved.
Hardware Description Languages
Lecture - 3
Developed By: Vazgen Melikyan
18
Interface
Syntax
port_type<data_type> port_name
SC_MODULE(Multiplier) {
sc_in<int> a; // ports
sc_in<int> b;
sc_out<int> product;
Connects modules
Channels implement all the functions of
interface
Two types of channels
Primitive
sc_signal, sc_fifo, sc_mutex, sc_semaphore
Hierarchical
Actually a module (modules, ports, channels contained within)
//ports
SC_CTOR(channel_name) { … } //channel
constructor
private:
…
}
Processes
Methods (sc_method)
Threads (sc_thread)
Clocked Threads (sc_cthread)
Methods
Simply a C++ function
Runs completely, then returns
Cannot be terminated
Dynamic sensitivity can be defined using
next_trigger() function
Threads
Used for processes not expected to halt
Threads can be suspended using wait()
wait() waits for event before continuing execution (static
sensitivity)
wait() can be called with an argument to override default
sensitivity (dynamic sensitivity)
Not synthesizable
Clocked Threads
Triggers at clock
Do not have separate sensitivity
Used for behavioral synthesis
constructor SC_CTOR(Multiplier) {
SC_METHOD(mul); // process
sensitive << A << B; // sensitivity
}
};
Fixed Precision
64 bit
sc_int<N>
sc_uint<N>
Arbitrary Precision
Up to 512 Bits
sc_bigint<N>
sc_biguint<N>
SystemC Operators
C++ Built-in Types
Bit selection
Part Selection
Bitwise
Concatenation
Integer Conversion
Bit selection
Access to a specific bit in a variable
C++ operator [ ]
sc_int<32> intNumber;
Part Selection
Access to a specific bit subset of bits in a variable.
Available methods:
range(int, int)
C++ operator()
Bitwise Reduction
Performs bitwise operation on all bits in integer or vector
Returns bool
Operations:
and_reduce() - Bitwise AND between all bits
nand_reduce() - Bitwise NAND between all bits
or_reduce() - Bitwise OR between all bits
nor_reduce() - Bitwise NOR between all bits
xor_reduce() - Bitwise XOR between all bits
xnor_reduce() - Bitwise XNOR between all bits
Concatenation
Concatenates the bits of two variables together
Available methods:
concat(arg0, arg1)
C++ comma operator “operator,”
// myInt3 = 00111101
//assignment to concatenation
(myInt2[2], myInt1.range(3,5)) = myInt3.range(3, 0);
Text based
Uses console to output internal status
Waveform Tracing
Uses special tracing functions
printf(“Started.”);
Debugging Constructor
Used to debug class initialization issues
name() method used to identify SystemC classes
SC_CTOR(Multiplier) {
cout << “Initializing Multiplier: “ << name() << endl;
...
...
}
void monitorInputs()
{
cout << “Time > A B" << endl;
while (true) //infinite loop
{
cout << sc_time_stamp() << “: A=";
cout << A.read() << ", B=";
cout << B.read() << endl;
wait(); // wait for next event
}
}
SC_CTOR(ClockedModule)
{
SC_THREAD(printInputs);
sensitive << Clock.pos();
}
}
((vcd_trace_file*) myTraceFile)->sc_set_vcd_time_unit(-9);
// Set time unit
sc_trace(myTraceFile, B , "B" );
sc_trace(myTraceFile, mul.C, “C");