Jump to content

Problem with CTHREAD methods


Recommended Posts

I have a design where a producer and a consumer are connected together through a simple packet interface. The consumer thread is just executed once. I did not understand what is wrong with it. Here is the code. The second module is executed once at the beginning of the simulation and is not executed after.



: cmMac.h :


#ifndef CM_MAC
#define CM_MAC

SC_MODULE(cmMac) {
   sc_in_clk     Clk;
   sc_in<bool>   Rst;
   sc_out<long>   txDout;
   sc_out<bool>  txDv;
   sc_out<bool>  txSof;
   sc_out<bool>  txEof;
   sc_out<char>  txMod;
   sc_out<bool>  txErr;

   SC_CTOR(cmMac) {
      SC_CTHREAD(cmMacSend, Clk.pos());
      //reset_signal_is(Rst, false);

   ifstream inFile;

   void cmMacInit();
   void cmMacSend();





: cmDutmodel.h:



#ifndef CM_DUTMOD
#define CM_DUTMOD
//#include "cm_mem.h"

SC_MODULE(cmDutmodel) {
   sc_in<bool>      Reset;
   sc_in_clk        Clk;
   sc_in<long>      txDin;
   sc_in<bool>      txDv;
   sc_in<bool>      txSof;
   sc_in<bool>      txEof;
   sc_in<char>      txMod;
   sc_in<bool>      txErr;

//   cmMem<sc_uint<70>,1024>  Fifo1;
   bool                  inPkt;
   sc_uint<32>           wrPtr;
   sc_uint<32>           rdPtr;
   sc_uint<1>            wEn;
   sc_uint<32>           pktSize;

   SC_CTOR(cmDutmodel) {
      SC_CTHREAD(cmDutmodelRx, Clk.pos());
      inPkt = false;
      wrPtr = 0;
      rdPtr = 0;

   void cmDutmodelRx();





Link to comment
Share on other sites

You don't have any bodies for the functions cmDutmodelRx(), cmMacSend() and cmMacInit(), which will result in a linker error.


If by chance you've just forgotten to post the code of those functions, that's a pity because that's probably where the bug lies - you need infinite loops in the SC_CTHREAD function bodies, and you probably don't have them.




Link to comment
Share on other sites

Thanks for the point. I actually did not post the code as I thought the issue was in the header files. However, I tried yesterday to include an infinite loop with a wait statement and everything worked. I did not know you would need an infinite loop in a CTHREAD. It should be clarified. The specs say that the method is executed everytime the clock rising edge occurs.

Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...