Lecture6 SystemC Intro PDF
Lecture6 SystemC Intro PDF
November 2002
Stuart Swan, [email protected]
CADENCE CONFIDENTIAL
Why do we need a new design language?!
• Verilog and VHDL work very well for HW implementation flows,
but…
• Systems are becoming more complex, pushing us to design and
verify at higher levels of abstraction
¾Enables early exploration of system level design tradeoffs
¾Enables early verification of the entire system, reducing risk
¾Enables much higher speed verification
• Software is playing an increasing role in system design
¾Essential that new design flows support early software
development, integration with existing C/C++ code, and HW/SW co-
design
• New system level flows require a design language that supports
system level IP delivery and integration
2
What are the requirements for the new language?
• Don’t invent a new language! Build on C/C++ so that:
– Extensive C/C++ infrastructure (compilers, debuggers, language
standards, books, etc.) can be re-used.
– Users’ existing knowledge of C/C++ can be leveraged
– Integration with existing C/C++ code is easy
• The language must have best-in-class performance.
• It must provide a very general set of modeling constructs to
cleanly support the wide range of abstraction levels and models
of computation used in system design.
• It must support specification and refinement to detailed
implementation of both software and hardware.
• It must support verification through all stages of the design
process
3
So what is SystemC?
• The “de facto” industry standard language (implemented as a C++
class library) providing both system level and HDL modeling
capabilities.
• SystemC is controlled by a board & steering group that includes 10
companies: ARM, Cadence, CoWare, Fujitsu, Mentor, Motorola, NEC,
Sony, ST, Synopsys,...
• The SystemC reference simulator can be downloaded free from
www.systemc.org.
• Many EDA companies are starting to offer tools and libraries that
support the SystemC standard.
• Major electronics companies are using SystemC now and are also
planning to extend their use.
4
SystemC History & Organization
• SystemC History
– Early development done at Synopsys, CoWare/IMEC, UC Irvine
– Open SystemC Initiative (OSCI) formed in 2000, many new members
joined.
– OSCI LWG developed SystemC 2.0 specification and implementation in
2000-2001, greatly extending the language capabilities
• SystemC Organization Today
– Open SystemC Initiative (OSCI) is incorporated as a California non-profit
organization with formal bylaws, a significant budget, etc.
– Licensing model is Open Community Licensing. (Unlike GNU, it is OK to
build proprietary products from SystemC code.)
– Well-organized public relations efforts for SystemC are on-going (e.g.
SystemC Tech Forum at DAC 2002).
– Website and source code maintenance for reference implementations are
located on SourceForge, and key developers from different companies
can access/modify code.
5
Alternative Languages to SystemC
• Raw C/C++
– In wide use, but it’s very difficult to build everything yourself.
– IP exchange is difficult.
• SpecC
– Not much activity apparent in organization. No RTL modeling. Is neither C
nor C++.
• Superlog, SystemVerilog
– A wide range of extensions to Verilog; many focused on improving RTL
designer productivity, some focused on system design & verification. A
large amount of work remains for language definition & standardization.
For SW design and verification, it is becoming more like C/C++, but it is
still not C/C++.
• Accelera System Level Languages Group
– Not much apparent progress.
• Possibly others: UML, SDL, Vera, Verisity’s ‘e’, etc.
6
What does SystemC actually provide?
• SystemC 1.0 provided RTL and behavioral HDL modeling
capabilities. HW is modeled using zero-delay semantics for
combinational logic. Signals are modeled using 01XZ, “C” data
types and complex data types can also be used within signals.
• SystemC 1.0 includes good support for fixed point modeling.
• SystemC 1.1 beta and 1.2 beta provided some limited
communication refinement capabilities.
• SystemC 2.0 has more general system level modeling
capabilities with channels, interfaces, and events.
• SystemC 3.0 will focus on software and scheduler modeling
(more later).
7
C/C++ Isn't a Magic Bullet for HW Design
• Switching to C/C++ does not necessarily change design flows.
Changing the design language does not by itself mean that designers
can change the required modeling levels.
• Finding a good hardware or system architecture is just as difficult in
C++ as in other languages.
• Behavioral synthesis tools have not eliminated the need for engineers
to carefully design hardware architectures.
• At best, simulation performance in C/C++ will be on par with HDL at
equivalent levels of abstraction
• For HW RTL design, HDLs are easier to use, more stable, faster,
have more mature tools and libraries, better debuggers, etc.
8
System Level Modeling in SystemC 2.0
• Real potential for SystemC is to be the industry standard language for
system level design, verification and IP delivery for both HW and SW.
• Towards this goal, SystemC 2.0 supports generalized modeling for
communication and synchronization with channels, interfaces, and
events. Hardware signals are now modeled as a specialization of
channels.
• System level extensions in SystemC 2.0 support transaction-level
modeling, communication refinement, executable specification modeling,
HW/SW co-design.
• Ability to refine HW portions of design to RTL level within a single
language is a unique strength of SystemC, as is the fixed point modeling
capability, and easy integration of existing C/C++ models.
9
SystemC 2.0 Language Architecture
10
Models of Computation in SystemC 2.0
• A model of computation is broadly defined by:
– Model of time (real, integer, untimed) and event ordering constraints
(globally ordered, partially ordered, etc.)
– Methods of communication between processes
– Rules for process activation
11
RTL Model of Computation in SystemC
• Models combinational logic and sequential logic triggered by
clocks.
• Very similar to RTL modeling in Verilog & VHDL.
• Signals modeled using sc_signal<>, sc_signal_rv<>
• Ports modeled using sc_in<>, sc_out<>, sc_inout<>
D Q
A
OUT D Q
CLK B
SEL
D Q
CLK
CLK
12
Kahn Process Network MOC in SystemC
• Very useful for high level system modeling
• Modules communicate via FIFOs (sc_fifo<T>) that suspend
readers and writers as needed to reliably deliver data items.
• Easy to use and guaranteed to be deterministic
• Pure KPN has no concept of time
• With annotated time delays, becomes timed functional model or
performance model.
13
Static Dataflow MOC in SystemC
• A proper subset of the KPN MOC
• Each module reads and writes a fixed number of data items each time it is
activated. Sample delays modeled by writing data items into FIFOs before
simulation starts.
• Simulators and implementation tools can determine static schedule for system
at compile-time, enabling high performance simulation and implementation.
• Commonly used in DSP systems, especially along with SystemC’s fixed point
types (sc_fixed<>, sc_fix).
Z(-1)
1 1
1 1
2 1
1
10
1
10
14
Transaction-Level MOC in SystemC
• Communication & synchronization between modules modeled
using function calls (rather than signals)
• Transactions have a start time, end time, and set of data
attributes (e.g. burst_read(uint addr, char* data, uint n))
• Two-phase synchronization scheme typically used for overall
system synchronization
• Much faster than RTL models (more later…)
15
Modeling Example - Interfaces
16
Modeling Example - Channel
class fifo : public sc_channel, public write_if, public read_if
{
public:
fifo() : num_elements(0), first(0) {}
void write(char c) {
if (num_elements == max_elements)
wait(read_event);
17
Modeling Example - Producer / Consumer
class producer : public sc_module class consumer : public sc_module
{ {
public: public:
sc_port<write_if> out; // the producer's output port sc_port<read_if> in; // the consumer's input port
void main() // the producer process void main() // the consumer process
{ {
char c; char c;
while (true) { while (true) {
... in->read(c); // read c from the fifo
out->write(c); // write c into the fifo if (in->num_available() > 5)
if (...) ...; // perhaps speed up processing
out->reset(); // reset the fifo }
} }
} };
};
18
Modeling Example - Top
19
Communication Refinement in SystemC
• Channels may have multiple separate interfaces.
• Ports are bound to a particular interface, not to a channel
• Interfaces can be reused with different channels
• Communication can be refined via channel substitution
• Examples of communication refinement
– Exploration during functional specification
– Retargeting abstract communication and synchronization to RTOS API
– Refining communication to a hardware implementation using adapters
and hierarchical channels, perhaps followed by “protocol inlining”.
20
Transaction-Level Modeling in SystemC
Communication between modules
CPU / Bus Master DSP / Bus Master Monitor
is modeled using function calls that
represent transactions. No signals
are used.
Bus Arbiter
Read: Addr: 0xFF12
Data: 0x0123
FastMem / Slave SlowMem / Slave HW Accel / Slave Read: Addr: 0xFF14
Data: 0xBEEF
21
Transaction-Based Verification in SystemC
23
What’s Happening in the SystemC Committees?
• Language Working Group
– Working on SystemC 3.0 extensions for software modeling support (e.g.,
modeling schedulers, abstract RTOS, complex hierarchical FSMs). Code
release target Q2/Q3 2003.
• Verification WG
– Version 1.0 of Verification Standard awaiting final OSCI approval. Open
source code should be on OSCI website Nov. or Dec. 2002.
• Mixed Signal WG
– Considering mixed signal integration
• Synthesis WG
– Standardize RTL and behavioral “synthesizable subsets” for SystemC
• Probable Future Efforts:
– IP Integration WG: Develop TLM standards for bus models, various
standards for IP packaging and reuse
24
Learning more about SystemC
• Our new book is available at:
– www.systemc.org
¾ Products & Solutions
¾ Books
¾ System Design with SystemC
25