dakupoto Posted January 30, 2013 Report Share Posted January 30, 2013 Could some SystemC guru please provide some hints to my problem ? I am trying to translate some old VHDL code into SystemC, and running into issues. I have a VHDL entity with 3 input ports and one output ports. Of the 3 input ports, the data type of 2 is std_logic, which can be immediately translated to sc_dt::sc_logic. The other input port and the one output port has data type Boolesn. I am confused about how to convert VHDL statements that are executed always, into corresponding SystemC methods. If I use a SystemC SC_METHOD, they will always get executed, or alternatively use SC_THREAD and make the method sensitive to changes in the input ports. For example, if I have the following VHDL statement : rstall <= resetn and pcirst when PCIEN else resetn; (Here, 'resetn' and 'pcirst' are input ports of type std_logic in VHDL, and PCIEN is a Boolean environment variable) Any hint, suggestions would be of immense help. Thanks in advance for your help. Quote Link to comment Share on other sites More sharing options...
sandeepjana Posted January 30, 2013 Report Share Posted January 30, 2013 I am sorry I am not able to understand the statement " If I use a SystemC SC_METHOD, they will always get executed". SC_METHOD will only get executed in case of activity on their senstivity list. If I have understood your problem correctly then the above statement rstall <= resetn and pcirst when PCIEN else resetn; can be implemented as follows. SC_METHOD(drive_rstall); sensitive << resetn << pcirst; void drive_rstall(void) { if(PCIEN){ rstall.write(resetn.read() & pcirst.read()); }else{ rstall.write(resetn.read()); } } So the above process will only be executed whenever there is any activity on resetn and pcirst. Hope it helps. Although I am not an expert on VHDL to SystemC conversion but there are some commericial tools available from companies like Carbon which can convert your behavioral VHDL/Verilog code to equivalent SystemC code. You may explore them too. maehne 1 Quote Link to comment Share on other sites More sharing options...
dakupoto Posted January 30, 2013 Author Report Share Posted January 30, 2013 Hello Sir, I fully agree with your point about SC_METHOD, but why not use a SC_THREAD as: void test_thread_0() { while(1) { wait(); rstall = PCIEN == '1' ? (rstin.read() & pcirstin.read()) : rstin.read(); } } And in the constructor: SC_CTOR(test) { SC_THREAD(test_thread_0); sensitive << rstin << pcirstin; } Once again, this thread will respond to any changes in either input port rstin or pcirstin. So, which is a better way to tackle this issue ? Quote Link to comment Share on other sites More sharing options...
apfitch Posted January 30, 2013 Report Share Posted January 30, 2013 Hi, a couple of points - firstly if you use SC_THREAD to emulate a VHDL process, the wait() function call should be at the bottom of the thread. Regarding SC_METHOD vs SC_THREAD, in this case there is no different behaviour. SC_METHODs may simulate faster due to few context switches to the kernel, so I would prefer an SC_METHOD. regards Alan maehne 1 Quote Link to comment Share on other sites More sharing options...
sandeepjana Posted January 31, 2013 Report Share Posted January 31, 2013 As mentioned by Alan, using SC_METHOD is mostly recommended due to context switching involved with SC_THREADs and in your case since you don't have any blocking needs or delays to be inserted , SC_METHOD should be the preferrable choice. Regards, Sandeep Jana maehne 1 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.