H include engineh scmodulecar body bodyi engine

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: r.h #include “Body.h” #include “Engine.h” SC_MODULE(Car) { Body body_i; Engine engine_i; SC_CTOR(Car) : body_i(“body_i”) , engine_i(“engine_i”) { …… } }; ECEN 468 Lecture 20 18 Direct Submodule // File: Car.h #include “Body.h” #include “Engine.h” SC_MODULE(Car) { Body body_i; Engine engine_i; Car(sc_module_name nm); }; // File: Car.cpp #include <systemc> #include “Car.h” //Constructor SC_HAS_PROCESS(Car); Car::Car(sc_module_name nm) : sc_module(nm) , body_i(“body_i”) , engine_i(“engine_i”) { …… } ECEN 468 Lecture 20 19 Indirect Submodule Header-Only // File: Body.h #include “Wheel.h” SC_MODULE(Body) { Wheel* wheel_left_iptr; Wheel* wheel_right_iptr;; SC_CTOR(Body) { wheel_left_iptr = new Wheel(“wheel_left_i”); wheel_right_iptr = new Wheel(“wheel_right_i”); …… } }; ECEN 468 Lecture 20 20 Indirect Submodule // File: Engine.h class FuelMix; class Exhaust; class Cylinder; SC_MODULE(Engin) { FuelMix* fuelmix_ip; Exhaust* exhaust_ip; Cylinder* cylinder_ip; Engine( sc_module_name nm); }; // File: Engin.cpp #include <systemc> #include “FuelMix.h” #include “Exhaust.h” #include “Cylinder.h” SC_HAS_PROCESS(Engine); Car::Car(sc_module_name nm) : sc_module(nm) { fuelmix_ip=new FuelMix(“Fi”); exhaust_ip=new Exhaust(“Ei”); cylinder_ip = new Cylinder(“Ci”); …… } ECEN 468 Lecture 20 21 Comparison Level Allocation Pros Main Direct Least code Main Indirect Dynamically configurable Module Direct header only All in one file, easier to understand Module Indirect header only All in one file, dynamically configurable Module Direct with separate compilation Hides implementation Module Indirect with separate compilation Hides submodule headers and implementation, dynamically configurable ECEN 468 Lecture 20 Cons Involves pointers Involves pointers Involve pointers 22...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online