biplab77 Posted May 24, 2015 Report Share Posted May 24, 2015 Hi All, I am a novice in systemC. I am having some doubts in using SC_METHOD(). I am building a network simulator in systemC. And from each node there are about four channels. I want the four channels to work simultaneously. The four channels get data from a common buffer in receiver and then transmit. So i declared a SC_Module and declared 4 SC_METHOD processes in it corresponding to each channel. SC_MODULE(NoximRouter) { SC_CTOR(NoximRouter) { //Recieving process SC_METHOD(rxProcess_local); sensitive << reset; sensitive << clock.pos(); ////Transmission processes SC_METHOD(txProcess_mode4); sensitive << reset; sensitive << clock.pos(); SC_METHOD(txProcess_mode1); sensitive << reset; sensitive << clock.pos(); SC_METHOD(txProcess_mode2); sensitive << reset; sensitive << clock.pos(); SC_METHOD(txProcess_mode3); sensitive << reset; sensitive << clock.pos(); } }; But when i try printing sth inside all the methods... I can see for a given simulation time only the receiver method and one of the txprocess method is running....i want everythimng to run parallely... 'kindly help me out. Quote Link to comment Share on other sites More sharing options...
kartikkg Posted May 25, 2015 Report Share Posted May 25, 2015 Can we see the implementation details of your Tx methods ? Currently there is not much information to make out anything. Quote Link to comment Share on other sites More sharing options...
sumit_tuwien Posted May 25, 2015 Report Share Posted May 25, 2015 Hi Biplab, This is wrong! Each SC_METHOD will be written as follows : SC_METHOD(rxProcess_local); sensitive << reset << clock.pos() ; Also I would expect that the reset will be either posedge or negedge triggered, and hence it should look like : SC_METHOD(rxProcess_local); sensitive << reset.neg() << clock.pos() ; If you do not want the methods to be initialized at t=0 then it has to be : SC_METHOD(rxProcess_local); sensitive << reset.neg() << clock.pos() ; dont_initialize(); Regards, Sumit Quote Link to comment Share on other sites More sharing options...
David Black Posted May 25, 2015 Report Share Posted May 25, 2015 I doubt the reset.neg() is the issue in this case. Furthermore, I disagree that the approach is wrong. Being sensitive to both edges can have a purpose depending on the design. For instance, assuming a positive edge going reset, you might wish to clear various things out on the leading edge and check that they remained so at the trailing edge. The real problem lies somewhere in the methods I strongly suspect. Perhaps the stimuli. We need to see the implementations. Quote Link to comment Share on other sites More sharing options...
biplab77 Posted May 25, 2015 Author Report Share Posted May 25, 2015 My Tx methods are like as follows :- void NoximRouter::txProcess_mode1() { if( buffer_snd.Size()!=0) //Going with just one buffer(may be corresponding to the router,... but actually forthe processing element) { NoximPacket packet = buffer_snd.Front(); NoximRouteData route_data; route_data.current_id = local_id; route_data.src_id = packet.src_id; route_data.dst_id = packet.dst_id; const vector < vector<int> > o = Route(route_data); //stats.power.Arbitration(o.size()); int src= packet.src_id; vector <int> path; int col =0; // checking in the global table the channels which are free and writhing to the res[ective channels path.push_back(src); packet.dir=checkdir(o); if(checkmode1(path,o,src,col,packet)==1) { buffer_snd.Pop(); // cout<<"Mode1\n"; packet.seq_no=path; packet.mode_tx=1; flit_tx.write(packet); mode1_traffic++; stats.pkthist.push_back(makePacketHist(packet)); for(int i=0;i<path.size();i++){ MappingTable[path[i]].channel_status_neighbor.available =0; } } } } //Checkmode function........................... int NoximRouter::checkmode1( vector <int> &path,const vector < vector<int> > &o, int src,int col, const NoximPacket &packet) { for(int i=0;i<o.size()-1;i++) { src = getNeighborId(src, o.at(i).at(col)); if(MappingTable[src].channel_status_neighbor.available ==0) path.push_back(src); else { if ((i != o.size()-2) && (col ==0)) { path.clear(); src=packet.src_id; path.push_back(src); i=-1; col=1; } else { if(col == 1) return 0; } }//else }//end of for loop /***************UPDATING MAP*****************/ path.push_back(packet.dst_id); //cout<<"Path details:"; for(int j=0;j<path.size();j++) { MappingTable[path[j]].channel_status_neighbor.available =1; } return 1; } Similar to above i have implemented all other tx methods... Lemme know if u guys need any more details.... Another Information :- When i rearrange the sequence of registering methods inside SC_CTOR , the tx process which starts getting executed changes...... At one time it is txProcess_mode1.... If i change the ordering then only txProcess_mode4 gets executed..... But in both cases rxProcess_local gets executed regardless as it gets stimuli from other signals...Another Interesting Observation :- If change the placement of rxProcess_local inside the constructor then the execution of txProcess_mode processes change. i.e if i do the following inside SC_CTOR SC_METHOD(txProcess_mode2); sensitive << reset; sensitive << clock.pos(); SC_METHOD(rxProcess_local); sensitive << reset; sensitive << clock.pos(); Only rxProcess_local and txProcess_mode2 gets executed... & if i do SC_METHOD(txProcess_mode3); sensitive << reset; sensitive << clock.pos(); SC_METHOD(rxProcess_local); sensitive << reset; sensitive << clock.pos(); Then only rxProcess_local and txProcess_mode3 gets executed Quote Link to comment Share on other sites More sharing options...
dakupoto Posted May 27, 2015 Report Share Posted May 27, 2015 Hi All, I am a novice in systemC. I am having some doubts in using SC_METHOD(). I am building a network simulator in systemC. And from each node there are about four channels. I want the four channels to work simultaneously. The four channels get data from a common buffer in receiver and then transmit. So i declared a SC_Module and declared 4 SC_METHOD processes in it corresponding to each channel. SC_MODULE(NoximRouter) { SC_CTOR(NoximRouter) { //Recieving process SC_METHOD(rxProcess_local); sensitive << reset; sensitive << clock.pos(); ////Transmission processes SC_METHOD(txProcess_mode4); sensitive << reset; sensitive << clock.pos(); SC_METHOD(txProcess_mode1); sensitive << reset; sensitive << clock.pos(); SC_METHOD(txProcess_mode2); sensitive << reset; sensitive << clock.pos(); SC_METHOD(txProcess_mode3); sensitive << reset; sensitive << clock.pos(); } }; But when i try printing sth inside all the methods... I can see for a given simulation time only the receiver method and one of the txprocess method is running....i want everythimng to run parallely... 'kindly help me out. Hello Sir, A sound way to pin down the issue is to use 'divide-and-conquer'. 1. First set up a small simulation with the receiver and any one of the transmit methods that is not running now. Make this sub-system work exactly as per your design specifications. 2. Incrementally add in the other currently non-running transmit processes. Repeat as above. This incremental approach will help you identify the failure point. Have you tried using SC_THREAD instead of SC_METHOD ? Please note that minor/often ignored glitches/latencies etc., present in real-world hardware that actually make the device work, are not present in the purified world of simulations and so often times simulations do not work as desired. Hope that helps. 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.