SumitK Posted May 1, 2018 Report Share Posted May 1, 2018 Hi I am not able to think of the case where we need to create dynamic processes using sc_spwan and cases where simple SC_THREAD/SC_METHOD is not suffice. Can you give me few example cases where I must use sc_spawn during end_of_elaboration or during simulation to create the processes? Thanks in advance Thanks Sumit Quote Link to comment Share on other sites More sharing options...
sheridp@umich.edu Posted May 1, 2018 Report Share Posted May 1, 2018 Hi Sumit, I think when you are just modeling hardware with fixed modules, there probably isn't a whole lot of uses for sc_spawn (I'm sure others could find some uses). However, in my models, I do a lot of modeling of firmware state machines at a pretty high level of abstraction (ie. I'm writing models before any firmware is available, so the models are not using something like instruction set simulators). In these models, a command is received and then a number of different actions are taken in sequence throughout the lifetime of the command, sometimes waiting on hardware or other threads, etc.). The easiest way to model this is as an sc_thread: void run(Command received_command) { do_x(received_command); wait(10, SC_US); do_y(received_command); mutex.lock(); do_z(received_command); mutex.unlock(); ... } The thing is, at compile time, I have no idea how many commands I'll receive, this depends on run-time inputs to the model. So I typically have a fixed module using SC_THREAD receiving the commands, but then for each command it receives, it kicks off a run using sc_spawn. SC_THREAD(receiver); void receiver() { while(true) { auto command = fifo.read(); sc_spawn(sc_bind(&run, command)); } } Quote Link to comment Share on other sites More sharing options...
sheridp@umich.edu Posted May 1, 2018 Report Share Posted May 1, 2018 Actually, even if you're just modeling hardware, you might want to use sc_spawn in the case that you have a run-time configurable number of hardware blocks. SC_THREADS have to be declared at compile time. Quote Link to comment Share on other sites More sharing options...
SumitK Posted May 1, 2018 Author Report Share Posted May 1, 2018 hi Sheridp I am not sure to understand your comment. Can you please elaborate a little possibly with an example. Sumit 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.