Modules in SystemC Part of HW/SW Codesign of Embedded Systems Course (CE 40-226) Winter-Spring 2001 Codesign of Embedded Systems 1 Today programme Modules in SystemC Winter-Spring 2001 Codesign of Embedded Systems 2 Module Advantages Building Block in Design Hierarchy Team Work Design Encapsulation Design Re-use Winter-Spring 2001 Codesign of Embedded Systems 3 Module (cont’d) Ingredients Module Ports Module Signals Internal Data Storage Processes Module Constructors Winter-Spring 2001 Codesign of Embedded Systems 4 Module (cont’d) Module Hierarchy Key to Implementing Complex Designs Divide and Conquer Winter-Spring 2001 Codesign of Embedded Systems 5 Hierarchical Module Example MAC (Multiply-Accumulate) module x e + f Register a c d clk Winter-Spring 2001 Codesign of Embedded Systems 6 Hierarchical MAC Module Example (cont’d) x c e + f clk SC_MODULE(mac) { sc_in<int> a,c; sc_in<bool> clk; sc_out<int> d; sc_signal<int> e,f; reg mult adder *r; *m; *add; Winter-Spring 2001 Register a d SC_CTOR(mac) { r=new reg(“Register”); m=new mult(“Mult”); add=new adder(“Adder”); //Named connection //Positional connection r->d(f); (*r)(f,d); r->q(d); (*m)(a,c,e); m->a(a); m->b(c); (*add)(d,e,f); } m->c(e); }; add->a(d); add->b(e); add->c(f); } }; Codesign of Embedded Systems 7 Hierarchical MAC Module Example (cont’d) Write down Adder and Multiplier modules in SystemC. Winter-Spring 2001 Codesign of Embedded Systems 8 Hierarchical Module Example2 Register Module q d DFF DFF DFF DFF clk Winter-Spring 2001 Codesign of Embedded Systems 9 Hierarchical Register Module Example (cont’d) #include "dff.h" #define REG_WIDTH 10 SC_MODULE(reg) { sc_in<bool> d[REG_WIDTH]; sc_in<bool> clk; sc_out<bool> q[REG_WIDTH]; DFF *ff[REG_WIDTH]; SC_CTOR(reg) { for(int i=0; i<REG_WIDTH; i++) { ff[i] = new DFF( itoa(i,NULL,10) ); ff[i]->d(d[i]); ff[i]->q(q[i]); ff[i]->clk(clk); } } }; Winter-Spring 2001 Codesign of Embedded Systems 10 Hierarchical Register Module Example (cont’d) Rewrite “Register module” in positional connection format. DFF declaration follows: SC_MODULE(DFF) { sc_in<bool> d, clk; sc_out<bool> q; ... } Winter-Spring 2001 Codesign of Embedded Systems 11 Module (cont’d) Ingredients Module Ports Module Signals Internal Data Storage Processes Module Constructors Winter-Spring 2001 Codesign of Embedded Systems 12 Internal Data Storage: Counter Module SC_MODULE(counter) { sc_in<bool> load; sc_in<int> din; sc_in<bool> clock; sc_out<int> dout; void counter::count_up() { if (load) count_val = din; else count_val++; dout = count_val; } int count_val; void count_up(); SC_CTOR(counter) { SC_METHOD(count_up); sensitive_pos << clock; } }; Winter-Spring 2001 Codesign of Embedded Systems 13 Processes Implement the real function of the module Are identified to SystemC Kernel at module instantiation time Are called by SystemC Kernel whenever a change is made on their “Sensitivity List” Winter-Spring 2001 Codesign of Embedded Systems 14 Module Constructor Identify module Processes, and their “sensitivity list” to “SystemC Kernel” Create and initialize Internal Data Structures of the module Initialize Internal Data Storage Instance name of the module is passed to the constructor at instantiation time Helps in reporting debug, error, and information messages from the module Winter-Spring 2001 Codesign of Embedded Systems 15 What we learned today Module Concept in SystemC Module Ingredients in SystemC Hierarchical Design Using Modules Winter-Spring 2001 Codesign of Embedded Systems 16 Complementary notes: Assignments DON’T FORGET Subscribe to ce226list@ce.sharif.edu by sending an email to majordomo@ce.sharif.edu containing subscribe ce226list in the body. Today is due date for Assignmentak 3 Take Assignment 4 Due date: Sat. Ordibehesht 1st Winter-Spring 2001 Codesign of Embedded Systems 17 Complementary notes: Verilog Classes Today class won’t be held Synthesis Seminar Sat., Ordibehesht 8th Winter-Spring 2001 Codesign of Embedded Systems 18 First Quiz Write a SystemC model for a synchronous up-counter with asynchronous load and clear Winter-Spring 2001 Codesign of Embedded Systems 19