Modeling SystemC
Modeling SystemC
September 2011
Agenda
Modeling
1. Basic Themes that came out through the Historical Background (repeat)
1
Modeling
Basic Themes
2. Analysis and Estimation :: Different models of the same system behavior need to
be analyzed and estimated for performance. Performance would include tradeoffs for
Area, Speed, Power. Cost to build, Time to Market are other factors.
4. Implementation generation :: Once the architecture has been generated and trade-
offs known, the designs for the hardware and software components must be created.
2
Modeling
Basic Modeling Requirements
2. State Transitions :: H/W & S/W :: Conceptualize the system into different modes
or states of operation (behavior). The states change based on input and the state
transitions imply certain output characterestics.
5. Exception Handling :: H/W & S/W :: The ability to respond to events external and
internal.
6. Timing :: H/W & S/W :: The ability to create a protocol and model it not only
behavioraly but also by specifying a timing constraint or delay in signals.
8. Process Synchronization : H/W & S/W :: The ability to generate data and events
to be used by other processes.
3
Modeling
Basic Modeling Requirements – Concurrency
2. From the point of System level modeling, one can further divide concurrency into
different types based on concepts of hardware modeling.
(a) Data-driven Concurrency :: As in a data flow graph (DFG) model, execution
depends on availability of data.
(b) Control-driven Concurrency :: There are constructs that specify multiple threads
of control, each of which can execute in parallel. eg. fork-join.
(c) Pipeline-driven Concurrency :: Specific to signal processing and driven by
throughput / latency requirements of systems.
4
Modeling
Basic Modeling Requirements – Concurrency - Data-Driven
5
Modeling
Basic Modeling Requirements – Concurrency - Control-Driven
6
Modeling
Basic Modeling Requirements – Concurrency - Pipeline-Driven
Below is example of a typical five-stage pipeline in a RISC machine.
1. IF = InstructionFetch
2. ID = InstructionDecode
3. EX = EXecute
5. WB = register WriteBack
7
Modeling
Basic Modeling Requirements – State Transitions
2. State transitions are triggered by the detection of certain events or certain conditions.
5. Actions can be associated with each transition, and a particular mode or state can
have an arbitrarily complex behavior or computation associated with it.
6. In case of the touchScreen example, the detection of a touch, followed by the invoka-
tion of the said task is an event driven State Transition.
8
Modeling
Basic Modeling Requirements – Hierarchy
1. Hierarchical models enable system to become modular and one can look at it as a set
of smaller subsystems.
2. These subsystems further down can be looked upon as another system with its own
characterestics.
3. This conceptual view helps development, due to inherent modularity and making a
complex system look as blocks of easily understood subsystems.
6. Hierarchy can be of two types basically coming from the h/w & s/w backgrounds ::
Structural hierarchy & Behavioral hierarchy
9
Modeling
Basic Modeling Requirements – Hierarchy - Structural
10
Modeling
Basic Modeling Requirements – Hierarchy - Behavioral
4. The Transitions can be grouped (as e4, e5) which looks like a request, grant pair.
11
Modeling
Basic Modeling Requirements – Programing Constructs
1. Many behaviors may be best described using programming constructs : it allows the
computations to be expressed explicitly.
4. In addition, data types are used like records (pascal?), arrays, linked lists and other
complex data structures (or structure of structures).
12
Modeling
Basic Modeling Requirements – Behavioral Completion
13
Modeling
Basic Modeling Requirements – Behavioral Completion
14
Modeling
Basic Modeling Requirements – Exception Handling
4. Depending on the direction of the transferred control Exceptions can be further divided
into :-
(a) Abort :: the current behavior is terminated completly, and control transferred to
event handling.
(b) Interrupt :: the current behavior is context-switched, control transferred to event
handling, and once the event handling is done, behavior is again context-switched
to the completion of the previous tasks (from where it was interrupted).
15
Modeling
Basic Modeling Requirements – Timing
3. In general, a timing relation can be described as (e1, e2, min, max) where e1 preceeds
e2 by at least min time units and at most max time units.
5. The timing information is important in real time embedded systems, whose per-
formance is measured in terms of how well the implementation respects the timing
constraints
16
Modeling
Basic Modeling Requirements – Timing
17
Modeling
Basic Modeling Requirements – Communication
1. Systems consist of several interacting behaviors which need to communicate with each
other.
18
Modeling
Basic Modeling Requirements – Communication – Shared Memory Model
5. Non Persistent – wired only (data is available only at the instant when it is written)
19
Modeling
Basic Modeling Requirements – Communication – Message Passing (Chan-
nel) Model
1. Messages sent through channels (an abstract medium, free from implementation de-
tails)
4. Uni/Bi directional
21
Modeling
Basic Modeling Requirements – Process Synchronization
1. Concurrent processes may generate data and events that need to be recognised by
ohter processes. Hence Synchronization is a necessary requirement.
22
Modeling
Basic Modeling Requirements – Process Synchronization – Control Depen-
dent
2. Initialization
23
Modeling
Basic Modeling Requirements – Process Synchronization – Data Dependent
24
Modeling
Basic Modeling Requirements – Summary
1. State Transitions
2. Behavior Hierarchy
3. Concurrency
4. Exception Handling
5. Programming constructs
6. Behavior completion
7. Timing representation
25
Modeling
LOGICAL BREAK
26
Modeling
Modeling Using SystemC – (Restate) System Level Design Flow
27
Modeling
Modeling Using SystemC – Benefits of a C/C++ Based Design Flow
1. Productivity aspect
• Specification between architect and implementer is executable
• High speed and High Level simulation and prototyping capibility
• Refinement, no translation into hardware (i.e, no ”semantic gap”)
3. Re-use aspect
• Optimum re-use support by ”Object Oriented” techniques
• Efficient testbench re-use (for both software, hardware and system)
28
Modeling
Modeling Using SystemC – Drawbacks of a C/C++ Based Design Flow
29
Modeling
Modeling Using SystemC – How does one get there using C/C++
30
• Allow hardware/software co-design and co-verification
• Fast simulation for validation and optimization
• Smooth path to hardware and software
• Support of design and architectural reuse
Modeling
Modeling Using SystemC – What is SystemC
2. A modeling style :: for modeling systems consisting of multiple design domains, ab-
straction levels, architectural components, real-life constraints
31
Modeling
Modeling Using SystemC – How Does SystemC Work?
33
Modeling
Modeling Using SystemC – What is the new Methodology?
34
Modeling
Modeling Using SystemC – What is the new Methodology?
35
Modeling
Modeling Using SystemC – SystemC Design Methodology
36
Modeling
Modeling Using SystemC – Modules
1. Modules are basic building blocks of a SystemC design
37
Modeling
Modeling Using SystemC – Ports
38
Modeling
Modeling Using SystemC – Signals
39
Modeling
Modeling Using SystemC – Ports & Signals Binding
40
Modeling
Modeling Using SystemC – Clocks
41
Modeling
Modeling Using SystemC – Data Types
1. SystemC supports
• Native C/C++ types
• SystemC types
• User-defined types
2. SystemC types
• 2-value (’0’, ’1’) logic / logic vector
• 4-value (’0’, ’1’, ’Z’, ’X’) logic / logic vector
• Arbitrary sized integer (signed / unsigned)
• Fixed point types (signed/unsigned, templated/untemplated)
42
Modeling
Modeling Using SystemC – Data Types
1. SystemC types
43
Modeling
Modeling Using SystemC – Data Types
2. sc logic :: 4-value single bit type :: ’0’ = false, ’1’ = true, ’X’ = unknown / indeter-
minate value, ’Z’ = high-impedence / floating value
3. SystemC allows for mixed use of operand types sc bit and sc logic. Use of character
literals for constant assignments is allowed.
44
Modeling
Modeling Using SystemC – Data Types
1. sc int< n > :: Signed Fixed point integer type :: (n : wordLength, 1 ≤ n ≤ 64)
5. Features ::
• Mixed use of operand types sc int, sc uint, sc bigint, sc biguint and C++ integer
types
• Truncation and / or sign extension can be done if required
• 2ś complement representation
45
Modeling
Modeling Using SystemC – Data Types
3. Features ::
• Assignment between sc bv and sc lv
• Use of string literals for vector constant assignments
• Conversions between sc bv/ sc lv ans SystemC integer types
• No arithmetic operation available
46
Modeling
Modeling Using SystemC – Modules and Hierarchies
47
Modeling
Modeling Using SystemC – Processes
1. Process
• Encapsulates functionality
• Basic unit of concurrent execution
• Not Hierarchical
2. Process Activation
• Processes have sensitivity lists
• Processes are triggered by events on sensitive signals
3. Process Types
• Method (SC METHOD) :: asynchronous block, like a sequential function
• Thread (SC THREAD) :: asynchronous process
• Clocked Thread (SC CTHREAD) :: synchronous process
48
Modeling
Modeling Using SystemC – Processes
49
Modeling
Modeling Using SystemC – Processes
50
Modeling
Modeling Using SystemC – Processes
51
Modeling
Modeling Using SystemC – Waiting and Watching
2. Halt process execution until an event occurs :: wait until() :: SC CTHREAD ONLY
52
Modeling
Modeling Using SystemC – Simulation Kernel Scheduler Steps
53
Modeling
Modeling Using SystemC – Example
54
Modeling
Modeling Using SystemC – Example – Typical File Structure
55
Modeling
Modeling Using SystemC – Example
56
Modeling
Modeling Using SystemC – Example
57
Modeling
Modeling Using SystemC – Example
58
Modeling
Acknowledgements
59