Академический Документы
Профессиональный Документы
Культура Документы
Hiren D. Patel
hiren@eecs.berkeley.edu http://www.eecs.berkeley.edu/hiren University of California, Berkeley, CA Thanks to Deian Tabakov for part of these slides dtabakov@rice.edu
November 1, 2007
Outline
Motivation Needs from an ESL Methodology The SystemC Proposition Fundamentals of SystemC SystemC Language Simulation Semantics Example of an EXOR gate Example of a simple counter Summary Installation on Cygwin
Hiren D. Patel
2/43
Motivation
Increasing design complexity Higher requirement demands Heterogeneous functionalities
Video, music, data, and communication
Shorter time-to-market Release design as a product in a shorter period of time Reduce design cycle by
Early design exploration Reduce validation and verication eorts Hardware and software co-design
Hiren D. Patel Brief Tutorial on SystemC 3/43
Motivation
Hiren D. Patel
4/43
ESL Model
Model Simulator
Model Simulator
Commercial IPs
Specification
Verification Engine
Test Generation
Behavioral Synthesis
HW/SW Partitioning
...
RTL
...
Equivalence Checkers
Hardware/software modeling and simulation. Fast simulation speed. Renement. Path to traditional synthesis tools
Hiren D. Patel Brief Tutorial on SystemC 5/43
Algorithmic Level
Functional
Untimed Functional
Untimed Functional
Untimed Functional
Layer 2: Transaction Layer - Architectural decisions - Coarse grain timing Layer 1: Transfer Layer - Cycle accurate - Software development
TLM
TLM
TLM
Programmers View with Timing: Bus architectures Approx. Timing Time accurate protocols
TLM
TLM
TLM
TLM
Word transfers Cycle accurate Layer 0: Register Transfer Layer - Pin accurate
RTL
RTL
RTL
RTL
RTL
Hiren D. Patel
6/43
Primitive Channels sc_signal, sc_mutex, sc_semaphore, sc_fifo, etc. Core Language Modules Ports Processes Interfaces Channels Events Event-driven simulation kernel C++ Data Types 4-valued logic 4-valued logic vector Bits and bit vectors Arbitrary prcecision integers Fixed-point C++ user-defined
Hiren D. Patel
7/43
Implementation Phase Design Phase System Level Design Space Exploration Modeling & Validation Hardware/ Software Partitioning Hardware development Software development RTL Modeling & Validation Software
DISCONNECT
Logic Synthesis
Hardware
Disconnect between high-level model and traditional synthesis path. Designs are often times re-implemented in RTL. Mainly used for early design space exploration and concept realization.
Hiren D. Patel Brief Tutorial on SystemC 8/43
Fundamentals of SystemC
Modules: the building blocks of SystemC models Hierarchy Abstraction IP reuse
sc_signal SC_MODULE SC_MODULE (Child Module) (Child Modules)
sc_in
SC_METHOD
sc_out
sc_in
SC_THREAD
module memory (local variables)
sc_inout
sc_out
Figure: SC MODULE
Hiren D. Patel Brief Tutorial on SystemC 9/43
Fundamentals of SystemC
Modules: the building blocks of SystemC models Example (Structure of a module)
SC_MODULE(Module_name) { // Declare ports, internal data, etc. // Declare and/or define module functions SC_CTOR(Module_name) { // Body of the constructor // Process declarations and sensitivities SC_METHOD(function1); sensitive << input1 << input2; SC_THREAD(function2); sensitive << input1 << clk; } };
Hiren D. Patel Brief Tutorial on SystemC 10/43
Fundamentals of SystemC
SC METHODs
Execute their body from beginning to end Function call equivalent (Simulates faster) Does not keep implicit state of execution
Processes must be contained in a module (but not every member function is a process!)
Hiren D. Patel
11/43
Fundamentals of SystemC
Hiren D. Patel
12/43
Interfaces: contract between modules for communication C++ interface Ports: helper objects for communication Agents for connecting modules with their environment Forward calls to the channel on behalf of the module Channels: workhorses for transmitting data Communication between modules Implements the functionality dened in the interfaces
Hiren D. Patel
13/43
MODULE 1 signals
MODULE 3 channels
Hiren D. Patel
14/43
Hiren D. Patel
15/43
Hiren D. Patel
15/43
Hiren D. Patel
15/43
Channels
Channels implement interfaces One channel can implement multiple interfaces Many channels can implement the same interface Example (exor.h) SC MODULE(exor) { sc in<bool> A, B; sc out<bool> F; nand n1, n2, n3, n4; sc signal<bool> S1, S2, S3; ... For example, sc signal<T> implements two interfaces: sc signal in if<T> and sc signal inout if<T>
Hiren D. Patel Brief Tutorial on SystemC 16/43
Events
In SystemC events are objects (sc event) that determine whether a process execution should be triggered or resumed An event is notied when a particular condition occurs Rising edge of a clock Change of a value of a signal Explicit call (e.notify()) Many others Three types of notication: Immediate: function call equivalent. Delta: delayed for a small increment of time (delta-delayed). Timed: delayed for a dened increment of time. Event notication schedules processes that are sensitive to it, to be triggered.
Hiren D. Patel Brief Tutorial on SystemC 17/43
Simulation Semantics
Initialization Stage
notify();
// immediate notification
Ready-to-run processes
Update Stage
Simulation Semantics
Initialize
Mark all processes runnable Each SC METHOD will be executed once Each SC THREAD will be executed until the rst synch point
Hiren D. Patel
19/43
Simulation Semantics
1 2
Initialize Evaluate
Select an eligible process and run it If the process uses immediate notication, other processes may become eligible too Continue selecting eligible processes until none are left
Hiren D. Patel
19/43
Simulation Semantics
1 2 3
Hiren D. Patel
19/43
Simulation Semantics
1 2 3 4
Initialize Evaluate Update If there are runnable processes, loop back to the Evaluate phase (step 2)
Hiren D. Patel
19/43
Simulation Semantics
1 2 3 4
Initialize Evaluate Update If there are runnable processes, loop back to the Evaluate phase (step 2) Advance the time
At this point there are no runnable processes Advance simulation clock to the earliest pending timed notication
Hiren D. Patel
19/43
Simulation Semantics
1 2 3 4
Initialize Evaluate Update If there are runnable processes, loop back to the Evaluate phase (step 2) Advance the time Determine runnable processes and go to Evaluate phase (step 2)
5 6
Hiren D. Patel
19/43
Hiren D. Patel
20/43
void do_it() { // a C++ function F.write( !(A.read() && B.read()) ); } SC_CTOR(nand) { SC_METHOD(do_it); sensitive << A << B; } }; // constructor for the module // register do_it() w/ kernel // sensitivity list
Hiren D. Patel
21/43
Hiren D. Patel
22/43
Hiren D. Patel
24/43
// run forever
Time 0 s 10 ns 20 ns 30 ns
Hiren D. Patel
28/43
Simulation Semantics
Example (main.cc)
#include "stim.h" #include "exor.h" #include "mon.h" int sc main(int argc, char* argv[]) { sc signal<bool> ASig, BSig, FSig; sc clock TestClk("TestClock", 10, SC NS, 0.5); ...
Hiren D. Patel
29/43
Simulation Semantics
Example (main.cc)
#include "stim.h" #include "exor.h" #include "mon.h" int sc main(int argc, char* argv[]) { sc signal<bool> ASig, BSig, FSig; sc clock TestClk("TestClock", 10, SC NS, 0.5, 1, SC NS); ...
Hiren D. Patel
29/43
Simulation Semantics
Example (main.cc)
#include "stim.h" #include "exor.h" #include "mon.h" int sc main(int argc, char* argv[]) { sc signal<bool> ASig, BSig, FSig; sc clock TestClk("TestClock", 10, SC NS, 0.5, 1, SC NS); ...
Simple Counter
Monitor
Hiren D. Patel
30/43
Hiren D. Patel
32/43
Hiren D. Patel
37/43
Summary
SystemC is currently poised as the ESL language of choice Modeling and simulation using SystemC at higher abstractions than RTL TLM (not covered) is the way to go Lots of resources available online Download and try it out
Hiren D. Patel
38/43
Summary
Core SystemC concepts Process : functionality Event : process synchronization Sensitivity : basis of event-driven simulation Channel : process communication Module : encapsulation Ports : external view of the module
Hiren D. Patel
39/43
Systemc version 2.2 compiles ne on Linux/Unix distributions Cygwin - always has problems
std::wctomb not declared ... Stack size issues
Solution
Compile using pthreads instead of QuickThreads Set SC DEFAULT STACK SIZE in sysc/kernel/sc constant.h to 0x50000
Hiren D. Patel
40/43
Cygwin Installation
Patch available at:
http://www.eecs.berkeley.edu/hiren/patches/sc-cygwin-hiren.patch
$ $ $ $ $ $ $ $ $ $ $ $
cd workspace tar xvf systemc-2.2.0.tgz mkdir systemc wget patch -p0 < sc-cygwin-hiren.patch cd systemc-2.2.0 mkdir objdir; cd objdir; ../configure --prefix=/cygdrive/c/workspace/systemc make pthreads make pthreads install make pthreads_check
Hiren D. Patel
41/43
Buzzwords
EDA Electronic Design Automation SoC System-on-chip TLM Transaction-Level Model(ing) PV Programmers View PVt Programmers View with Time HDL Hardware Description Language RTL Register Transfer Level ASIC Application-Specic Integrated Circuit IP Intellectual Property DSP Digital Signal Processing DUV Design Under Verication
Hiren D. Patel
42/43
References
P. Alexander. System-level Design with Rosetta. Elsevier Science [distributor], 2006. FERMAT. Systemc-h. Website: http://fermat.ece.vt.edu/systemc-h/. Metropolis Group. Metropolis: Design Environment for Heterogeneous Systems. Website: http://embedded.eecs.berkeley.edu/metropolis/index.html. J. Kramer. Is abstraction the key to computing? Communications of the ACM, 50(4):3642, 2007.
Hiren D. Patel Brief Tutorial on SystemC 43/43