ello guys. I am trying to learn systemC in school. If anyone is not familiar with it please check out the link.
Its an extension to the C++ library which helps to model concurrency in hardware. Im tryin to model a traffic light controller with 4 directions and since the whole idea is to come up with a code which correctly models event driven simulation, ive tried to use threads which respond to certain events (similar to the sensitivity list in VHDL in case u know VHDL).
And for some reason my output seems to be stuck somewhere..it hangs and i have to manually kill the terminal by force closing it. Heres the description of the problem: I have four light controllers for traffic light in each direction (North South(NS), South North(SN),West East(WE) and East West(EW).Each of these controllers has 2 inputs and 1 output.Each light controller receives input from a sensor(which magically senses cars) and the light controller responds to this 'event' by sending a request to the main controller thru the out port. The main controller processes its request and send it its decision(decribed below) which it receives on the 2nd in port. As u might have guessed, the main controller's job is to issue decisions to these local controllers( they shud have been called light controllers i know :|) taking care of conflicting requests if there are any. The main controller gives preference to the NS-SN direction over the WE-EW direction in case of a conflict. I have tried to introduce modularity in the code and hence I seperated the sensor from the light controller(controller). When I build the file and then run the executable, the whole terminal hangs and shows nothing ... Heres the code: include //main controller source file #include
main_controller::main_controller(sc_module_name name):sc_module(name) {
SC_THREAD(check_requests); result1.initialize(false); result2.initialize(false); result3.initialize(false); result4.initialize(false);
SC_METHOD(issue_results); dont_initialize(); sensitive read(); req1 = request1->read(); req3 = request3->read(); req4 = request4->read();
cout