HardwareSoftware Codesign with System C HMESth 1 Les

  • Slides: 11
Download presentation
Hardware/Software Codesign with System. C HM-ES-th 1 Les 4

Hardware/Software Codesign with System. C HM-ES-th 1 Les 4

System. C Hiërarchie l Een module kan (sub)modules bevatten in port module channel submodule

System. C Hiërarchie l Een module kan (sub)modules bevatten in port module channel submodule out port 18

Verbindingen tussen modules l Verbindingen tussen hiërarchische niveaus: l Input van module (rechtstreeks) verbonden

Verbindingen tussen modules l Verbindingen tussen hiërarchische niveaus: l Input van module (rechtstreeks) verbonden met input van submodule. l Output van submodule (rechtstreeks) verbonden met output van module. l Verbindingen binnen een hierarchische niveau: l Output van een module (via een channel) verbonden met de input van een andere module (op hetzelfde niveau). 19

2 bit full adder l Schema (opgebouwd uit twee 1 bit full adders). B

2 bit full adder l Schema (opgebouwd uit twee 1 bit full adders). B 0 Cin A 0 A Cin B adder 0 S A 1 B 1 A B Adder 2 Bits Cin adder 1 Cout S Cout carry S 0 S 1 Cout 20

2 bit full adder SC_MODULE(Adder 2 Bits) { sc_in<sc_logic> A 0, B 0, A

2 bit full adder SC_MODULE(Adder 2 Bits) { sc_in<sc_logic> A 0, B 0, A 1, B 1, Cin; sc_out<sc_logic> S 0, S 1, Cout; SC_CTOR(Adder 2 Bits): adder 0("adder 0"), adder 1("adder 1") { adder 0. A(A 0); adder 0. B(B 0); adder 0. Cin(Cin); adder 0. S(S 0); adder 0. Cout(carry); adder 1. Cin(carry); adder 1. A(A 1); adder 1. B(B 1); adder 1. S(S 1); adder 1. Cout(Cout); } private: Adder adder 0, adder 1; sc_signal<sc_logic> carry; }; 21

2 bit full adder (alternatief) SC_MODULE(Adder 2 Bits) { sc_in<sc_logic> A 0, B 0,

2 bit full adder (alternatief) SC_MODULE(Adder 2 Bits) { sc_in<sc_logic> A 0, B 0, A 1, B 1, Cin; sc_out<sc_logic> S 0, S 1, Cout; SC_CTOR(Adder 2 Bits) { SC_METHOD(add); sensitive << A 0 << B 0 << A 1 << B 1 << Cin; } private: void add() { sc_uint<3> a = 0, b = 0, c = 0; a[1] = A 1. read(). to_bool(); a[0] = A 0. read(). to_bool(); b[1] = B 1. read(). to_bool(); b[0] = B 0. read(). to_bool(); c[0] = Cin. read(). to_bool(); sc_uint<3> s = a + b + c; S 0. write(sc_logic(s[0]. to_bool())); S 1. write(sc_logic(s[1]. to_bool())); Cout. write(sc_logic(s[2]. to_bool())); } }; 22

l De 2 bit full adder opgebouwd met twee 1 bit full adders noemen

l De 2 bit full adder opgebouwd met twee 1 bit full adders noemen we een structural model. l De 2 bit full adder waarvan het gedrag wordt beschreven zonder gebruik te maken van submodules noemen we een behavioral model. 23

Modules l Modules are the basic building blocks for partitioning a design l A

Modules l Modules are the basic building blocks for partitioning a design l A module is a structural entity, which can contain processes, ports, channels, member functions not registered as processes and instances of other modules l A module is the foundation of structural hierarchy l Modules allow designers to hide internal data representation and algorithms from other modules l Designers are forced to use public interfaces to other modules, thus making the entire system easier to change and maintain reusability = lower design time 24

Processes l Processes are small pieces of code that run concurrently with other processes.

Processes l Processes are small pieces of code that run concurrently with other processes. l Functionality is described in processes. l Processes must be contained within a module. l They are registered as processes with the System. C kernel, using a process declaration in the module constructor. l Processes accept no arguments and produce no output 25

System. C in UML 26

System. C in UML 26

Fixed point getallen l Een fixed point getal heeft een bepaald aantal bits voor

Fixed point getallen l Een fixed point getal heeft een bepaald aantal bits voor de decimale punt en een bepaald aantal bits na de decimale punt. l Fixed point getallen kunnen in een integer worden opgeslagen. De programmeur moet dan wel zelf onthouden waar de decimale punt staat. l Rekenen met fixed point getallen: l Optellen en aftrekken niets bijzonders. l Vermenigvuldigen resultaat naar rechts schuiven zodat decimale punt weer goed staat. l Delen resultaat naar links schuiven zodat decimale punt weer goed staat. 27