Design & Co-design of Embedded Systems

Slides:



Advertisements
Similar presentations
Introduction to C Programming
Advertisements

VHDL 5 FINITE STATE MACHINES (FSM) Some pictures are obtained from FPGA Express VHDL Reference Manual, it is accessible from the machines in the lab at.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 6: Process Synchronization.
Chapter 7: User-Defined Functions II Instructor: Mohammad Mojaddam.
Chapter 3 : Combination and Sequential Circuits Modeling.
Design & Co-design of Embedded Systems Processes in SystemC Maziar Goudarzi.
COMP3221: Microprocessors and Embedded Systems Lecture 15: Interrupts I Lecturer: Hui Wu Session 1, 2005.
ELEN 468 Lecture 161 ELEN 468 Advanced Logic Design Lecture 16 Synthesis of Language Construct II.
Copyright © 2001 Stephen A. Edwards All rights reserved SystemC Prof. Stephen A. Edwards.
OS Spring’03 Introduction Operating Systems Spring 2003.
16/27/ :53 PM6/27/ :53 PM6/27/ :53 PMLogic Control Structures Arithmetic Expressions Used to do arithmetic. Operations consist of +,
Digital System Design Verilog ® HDL Tasks and Functions Maziar Goudarzi.
Reconfigurable Computing S. Reda, Brown University Reconfigurable Computing (EN2911X, Fall07) Lecture 14: SystemC (2/3) Prof. Sherief Reda Division of.
Today’s Lecture Process model –initial & always statements Assignments –Continuous & procedural assignments Timing Control System tasks.
Advanced FPGA Based System Design Lecture-9 & 10 VHDL Sequential Code By: Dr Imtiaz Hussain 1.
SystemC: Introduction. SystemC  A C++ based class library and design environment for system-level design.  Suitable for functional description that.
From Scenic to SystemC Mehrdad Abutalebi. Outline Introducing Scenic Scenic Implementation Modeling Reactivity A Simple example From Scenic to SystemC.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
1 Freeha Azmat Saba Zia Dec 02, Agenda Installation Introduction From Verilog to SystemC Counter as an Example Complete SystemC Modeling 2.
Winter-Spring 2001Codesign of Embedded Systems1 Processes in SystemC Part of HW/SW Codesign of Embedded Systems Course (CE )
Design & Co-design of Embedded Systems Combinational Logic in SystemC Maziar Goudarzi.
RTL Hardware Design by P. Chu Chapter Overview on sequential circuits 2. Synchronous circuits 3. Danger of synthesizing asynchronous circuit 4.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
2-Jun-16EE5141 Chapter 3 ä The concept of the signal ä Process concurrency ä Delta time ä Concurrent and sequential statements ä Process activation by.
Winter-Spring 2001Codesign of Embedded Systems1 Reactivity, Ports, and Signals in SystemC Part of HW/SW Codesign of Embedded Systems Course (CE )
Unit-III Pipelined Architecture. Basic instruction cycle 6/4/2016MDS_SCOE_UNIT32.
13-Nov-15 (1) CSC Computer Organization Lecture 7: Input/Output Organization.
Winter-Spring 2001Codesign of Embedded Systems1 Debug and Trace Facilities in SystemC Part of HW/SW Codesign of Embedded Systems Course (CE )
1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
M.Mohajjel. Structured Procedures Two basic structured procedure statements always initial All behavioral statements appear only inside these blocks Each.
CPE 626 The SystemC Language Aleksandar Milenkovic Web:
Verilog® HDL Behavioral Modeling (2)
55:032 - Intro. to Digital DesignPage 1 VHDL and Processes Defining Sequential Circuit Behavior.
Winter-Spring 2001Codesign of Embedded Systems1 Processes in SystemC: Examples and Exercises Part of HW/SW Codesign of Embedded Systems Course (CE )
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
Lecture #12 Page 1 ECE 4110– Digital Logic Design Lecture #12 Agenda 1.VHDL : Behavioral Design (Processes) Announcements 1.n/a.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
CIS 4930/6930 System-on-Chip Design Introduction to SystemC Hao Zheng Computer Science & Engineering U of South Florida.
Tutorial 1 COEN691B.
ECE 4110–5110 Digital System Design
16.317: Microprocessor System Design I
Chapter 7 User-Defined Methods.
Last Lecture Talked about combinational logic always statements. e.g.,
CSE 374 Programming Concepts & Tools
Lecture 13 Derivation of State Graphs and Tables
Chapter 3 : Combination and Sequential Circuits Modeling
B e h a v i o r a l to R T L Coding
Introduction Introduction to VHDL Entities Signals Data & Scalar Types
‘if-else’ & ‘case’ Statements
Interrupts In 8085 and 8086.
Digital System Design Verilog ® HDL Scheduling Semantics Maziar Goudarzi.
Real-time Software Design
Tsao, Lin-wei Li, Han-lin Hu, Sun-Bo
Design Flow System Level
SystemC Scheduler Dynamic sensitivity.
CS1100 Computational Engineering
332:437 Lecture 8 Verilog and Finite State Machines
Transmitter Interrupts
Test Fixture (Testbench)
COE 202 Introduction to Verilog
Lecture #5 In this lecture we will introduce the sequential circuits.
Design & Co-design of Embedded Systems
Dr. Tassadaq Hussain Introduction to Verilog – Part-3 Expressing Sequential Circuits and FSM.
CSE 153 Design of Operating Systems Winter 19
Introduction to System-Level Modeling in SystemC 2.0
332:437 Lecture 8 Verilog and Finite State Machines
Introduction to Digital IC Design
COMP3221: Microprocessors and Embedded Systems
ECE 448 Lecture 6 Finite State Machines State Diagrams vs. Algorithmic State Machine (ASM) Charts.
Chapter 13: I/O Systems “The two main jobs of a computer are I/O and [CPU] processing. In many cases, the main job is I/O, and the [CPU] processing is.
Presentation transcript:

Design & Co-design of Embedded Systems Other Simulation Techniques in SystemC Maziar Goudarzi

Design & Co-design of Embedded Systems Today Program Advanced Simulation Control Reactivity in SC_CTHREAD processes FSM Modeling Techniques 2005 Design & Co-design of Embedded Systems

Other Simulation Techniques Advanced Simulation Control

Special Objects: Clocks Clocks generate timing signals to synchronize simulation events No clock-signal is declared Instead, an sc_clock object is instantiated Declaration syntax (old) sc_clock clk_name(“clk_name”, clk_period=1, clk_duty_cycle=0.5, first_edge_time=0, first_edge_type=true); 2005 Design & Co-design of Embedded Systems

Special Objects: Clocks (cont’d) Declaration syntax (new) sc_clock clk(“clk”, clk_period=1, time_unit=SC_NS); Example: sc_clock clk1(“clk1”, 10, SC_PS); Values for time_unit argument SC_FS, SC_PS, SC_NS, SC_US, SC_MS, SC_SEC 2005 Design & Co-design of Embedded Systems

Special Objects: Clocks (cont’d) Multiple clocks are allowed Different frequencies Different phase relations Declaration point Typically generated at top-level module and passed down to lower-level modules The clock object or its signal (i.e. clock_object.signal() ) can be passed down 2005 Design & Co-design of Embedded Systems

Special Objects: Clocks (cont’d) sc_clock clock("Clock", 20, 0.2, 3, false); 2005 Design & Co-design of Embedded Systems

Simulation Control Functions sc_start(double simulation_duration) sc_start(double duration, sc_time_unit) Use non-positive or no value for duration to continue indefinitely sc_stop() Debugging aid read/print signal, port, and variable values For ports and signals: The printed value is the current value, not the value just written to it 2005 Design & Co-design of Embedded Systems

Simulation Control Functions (cont’d) Advanced Simulation control techniques Instead of sc_start() use: sc_initialize();// init SystemC scheduler // Now set signals by writing values to them sc_cycle(double); // simulates signal writes, then advances simulation time by its argument value 2005 Design & Co-design of Embedded Systems

Simulation Control Functions (cont’d) Example int sc_main(int, char *[]) { ... // signal declarations ... // module instantiations sc_signal<bool> clock; sc_initialize(); for (int i = 0; i <= 10; i++) { clock = 1; sc_cycle(10); clock = 0; } 2005 Design & Co-design of Embedded Systems

Design & Co-design of Embedded Systems Example 20 5 int sc_main(int, char*[]) { sc_initialize(); // Let the clock run for 10 cycles for (int i = 0; i <= 10; i++) clock = 1; sc_cycle(10); clock = 0; } // Inject asynchronous reset sc_cycle(5); reset = 1; reset = 0; 20 // Now let the clock run indefinitely for (;;){ clock = 1; sc_cycle(10); clock = 0; } 2005 Design & Co-design of Embedded Systems

Other Simulation Techniques Describing FSM in SystemC

EXPLICIT State-Machine: 101 Sequence Detector 1 S1 1 S10 S101 1 Start 1 2005 Design & Co-design of Embedded Systems

Design & Co-design of Embedded Systems 101 Seq. Det. (cont’d) Start S1 1 S10 S101 enum states { START, S1, S10, S101 }; SC_MODULE(seq_det) { sc_in_clk clk; sc_in<bool> s, reset; sc_out<bool> z; states current_state, next_state; void change_state() { z = false; if (reset) { current_state=START; return; } switch(current_state) { case START: if (s==true) next_state = S1; else next_state = START; break; case S1: ... case S10: ... case S101: z = 1; if (s==(bool)1) next_state = S1; else next_state = S10; } current_state = next_state; } // switch SC_CTOR(seq_det) { SC_METHOD(...); sensitive_pos<<clk; } }; 2005 Design & Co-design of Embedded Systems

Design & Co-design of Embedded Systems SystemC_Win output 2005 Design & Co-design of Embedded Systems

101 Seq. Det.: IMPLICIT state-machine Question: How should “reset” be applied? void change_state_thread() { while (true) { z = 0; while (s==(bool)0) wait(); // 1 is detected up to now do wait(); while (s==(bool)1); // 10 is detected up to now if (s==1) z = 1; // The complete sequence (101) detected now } 2005 Design & Co-design of Embedded Systems

101 Seq. Det.: IMPLICIT state-mach. (cont’d) Changes required in SC_MODULE constructor: SC_CTOR(seq_det) { /* SC_THREAD(change_state_thread); sensitive_pos<<clk; */ SC_CTHREAD(change_state_thread, clk.pos()); } 2005 Design & Co-design of Embedded Systems

Design & Co-design of Embedded Systems SystemC_Win output 2005 Design & Co-design of Embedded Systems

Other Simulation Techniques Modeling Reactivity in SC_CTHREAD Processes

Design & Co-design of Embedded Systems Concept of Reactivity Property of Reaction to external events Inherent in HW => There MUST be some way to model it in any HDL Many SW or HW-SW systems are reactive as well: Any control systems (Chemical process control, ABS, …) Client-Server systems (Database Engines, …) 2005 Design & Co-design of Embedded Systems

Concept of Reactivity (cont’d) Things to consider Events to react to Type of event (Clock edge, Signal change, some condition on signals or ports, …) Style of reaction Waiting style Suspend process until an event comes or some condition holds (i.e. Blocking wait) Watching style Do not suspend. But always WATCH if some condition holds. Then, react accordingly: e.g. Jump to a certain routine, or point of a routine. (Non-blocking wait) 2005 Design & Co-design of Embedded Systems

Reactivity Facilities in SystemC Events to react to Sensitivity lists in SC_METHOD, SC_THREAD, and clock edge in SC_CTHREAD. Sensitivity to any event on a signal: sensitive data member of SC_MODULE Sensitivity to positive edge of a signal: sensitive_pos data member of SC_MODULE Sensitivity to negative edge of a signal: sensitive_neg data member of SC_MODULE Special case of infinite loop processes (SC_THREAD, SC_CTHREAD) Loop re-initialization, Wait for Signal condition 2005 Design & Co-design of Embedded Systems

Reactivity Facilities in SystemC (cont’d) Style of reaction Waiting style wait() Both SC_THREAD and SC_CTHREAD wait_until(<signal condition>) Only SC_CTHREAD Watching style (Only SC_CTHREAD) Global watching: Always done. Cannot be disabled. Local watching: Done in certain parts of a process. Can be disabled and re-enabled (statically) 2005 Design & Co-design of Embedded Systems

Global Watching Example SC_MODULE(data_gen) { sc_in_clk clk; sc_inout<int> data; sc_in<bool> reset; void proc(); SC_CTOR(data_gen){ SC_CTHREAD(proc, clk.pos()); watching( reset.delayed()==1 ); } }; void proc() { if (reset == true) { data = 0; } while (true) { data = data + 1; wait(); data = data + 2; wait(); data = data + 4; wait(); } } Only defined for signals and ports of type bool 2005 Design & Co-design of Embedded Systems

Global Watching in General void data_gen::proc () { // variable declarations // watching code if (reset == true) { data = 0; } // infinite loop while (true) { // Normal process function } } Notes: all local variables lose their values. Multiple watching is possible 2005 Design & Co-design of Embedded Systems

Local Watching in General W_BEGIN // put the watching declarations here watching(...); watching(...); W_DO // This is where the process functionality goes ... W_ESCAPE // This is where the handlers for the watched events // go if (..) { … } W_END 2005 Design & Co-design of Embedded Systems

Local Watching Example void bus::xfer() { while (true) { // wait for a new address to // appear wait_until( newaddr.delayed()); // got a new address. process it taddr = addr; datardy = false; // cannot accept new address now data8 = taddr.range(7,0); start = true; // new addr // for memory controller wait(); // wait 1 clock between data // transfers data8 = taddr.range(15,8); start = false; wait(); data8 = taddr.range(23,16); wait(); data8 = taddr.range(31,24); wait(); // now wait for ready signal // from memory controller wait_until(ready.delayed() == true); W_BEGIN watching( reset.delayed() ); // Active value of reset // will trigger watching 2005 Design & Co-design of Embedded Systems

Local Watching Example (cont’d) W_DO // the rest of this block is // as before // now transfer memory data // to databus tdata.range(7,0) = data8.read(); wait(); tdata.range(15,8) = data8.read(); wait(); tdata.range(23,16) = data8.read(); wait(); tdata.range(31,24) = data8.read(); data = tdata; datardy = true; // data is // ready, new addresses ok W_ESCAPE if (reset) { datardy = false; } W_END } 2005 Design & Co-design of Embedded Systems

watching statements (cont’d) Final notes Local watching All events have the same priority. Use nested watches to change this. The watched signals are only sampled at the active edges of the SC_CTHREAD clock Global watching has priority over local watching 2005 Design & Co-design of Embedded Systems

Design & Co-design of Embedded Systems Today Summary Advanced Simulation Control Techniques Local and Global Watching Self-study Chapters 7, 8, and 9 of “A SystemC Primer” book 2005 Design & Co-design of Embedded Systems

Design & Co-design of Embedded Systems Other Notes Project Progress Report 1 Today is the (postponed!) deadline 2-3 pages, covering List of your collected material Summary of what you’ve done + demo of the C++ app. Your plan for next phases and role of each person 2005 Design & Co-design of Embedded Systems