jsmith125x Posted January 23, 2014 Report Share Posted January 23, 2014 I'm trying to implement an interactive digital simulator using SystemC. The user can place switches, gates etc. and can simulate the circuit. I have some problem with switches. Assume there is a circuit containing a "clock" an "and gate" and a "switch". The switch can switch from the H and L states to the output. By default it is low state, when the user press the switch its output goes to the high state. The and gate's inputs connected to the clock and to the switch. The circuit is converted to its SystemC representation (except the switch). The simulation runs endless, because of the clock. How to handle pressing the switch in the SystemC engine? I assume I have to send an event manually to the kernel. How to do that? Im running the SystemC simulation through a dll (the SystemC representation of the circuit is compiled to a dll). Quote Link to comment Share on other sites More sharing options...
ralph.goergen Posted January 24, 2014 Report Share Posted January 24, 2014 Hi. I think, you should think about synchronization first. SystemC runs in its logical/simulation time and the switch is pressed in physical/wall-clock time. Once you synchronized simulation time and wall-clock time, you can write to signals and generate SystemC events actually originated from the 'outer world' at every synchronization point. Greetings Ralph Quote Link to comment Share on other sites More sharing options...
dakupoto Posted January 24, 2014 Report Share Posted January 24, 2014 Hi. I think, you should think about synchronization first. SystemC runs in its logical/simulation time and the switch is pressed in physical/wall-clock time. Once you synchronized simulation time and wall-clock time, you can write to signals and generate SystemC events actually originated from the 'outer world' at every synchronization point. Greetings Ralph This is an extremely valuable insight that the OP must consider very carefully. Quote Link to comment Share on other sites More sharing options...
jsmith125x Posted January 24, 2014 Author Report Share Posted January 24, 2014 I have a simulation time point when the user press the switch. How to send an event to the kernel? Quote Link to comment Share on other sites More sharing options...
ralph.goergen Posted January 24, 2014 Report Share Posted January 24, 2014 My first idea on this is: by changing the value of a signal. My very raw idea is: sc_main(int,char*[]) { my_sc_design design("design"); my_environment env; sc_signal<bool> switch; //connect switch signal to sc design design.evnironment_switch_in(switch); //start simulation once to run elaboration sc_start(SC_ZERO_TIME); while(true) { // wait for wall-clock time wait_one_second_in_wall_clock_time(); //set switch signal accordig to actual switch if (env.switch_enabled()) { switch.write(true); } else { switch.write(false); } sc_start(1,SC_SEC); } } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.