Jump to content

How to write to a signal from same process of two different instances


Abishek

Recommended Posts

Hello,

Im trying to create a daisy chain by connecting multiple instances of same device into a single air of SPI lines. But Im getting E515 while reading data from multiple slaves to single master signal. My binding is something like this below? Can someone help me find a solution:

SC_MODULE(TESTBENCH)
{
    DaisyChainProcess DaisyChainProcess_1;
    DaisyChainProcess DaisyChainProcess_2;
    sc_signal<sc_logic,SC_MANY_WRITERS > spi_mrst[6];
    sc_signal<sc_logic, SC_MANY_WRITERS> spi_mtsr[6];
    sc_signal<sc_logic, SC_MANY_WRITERS > cs;
    SC_CTOR(TESTBENCH) : DaisyChainProcess_1("DaisyChainProcess_1", 1) , DaisyChainProcess_2("DaisyChainProcess_2", 2)  //Two instances of my process
    {
        SC_THREAD(testbench);
        DaisyChainProcess_1.CS(cs);
        DaisyChainProcess_2.CS(cs);
        for (int j = 0; j < 6; j++) {
            DaisyChainProcess_1.SPI_MRST[j](spi_mrst[j]);    //Out lines from device bind to common input signal Error here
            DaisyChainProcess_1.SPI_MTSR[j](spi_mtsr[j]);
            DaisyChainProcess_2.SPI_MRST[j](spi_mrst[j]);    //Out lines from device bind to common input signal Error here
            DaisyChainProcess_2.SPI_MTSR[j](spi_mtsr[j]);
        }
    }

And below are the daisy chain process module declaration


  public:
    sc_core::sc_in<sc_logic> SPI_MTSR[6];                         //SPI Master Transmit Slave Recieve
    sc_core::sc_out<sc_logic> SPI_MRST[6];                        //SPI Master Recieve Slave Transmit
    sc_core::sc_in<sc_logic> CS;                                   //SPI chip select
 

 

Link to comment
Share on other sites

In general - ignoring the fact that you are using sc_logic for now, we need to be aware of the following:

  • An sc_signal allows only one "writer" or "driver" by default. This means, even from within a single SystemC module, if an sc_out port is being written by two process instances (two threads or methods), a runtime (simulation time) error will be issued
  • We can however explicitly allow multiple writers by using the SC_MANY_WRITERS template argument, like you have already done. In this case, SystemC will allow different processes to write to the sc_out port - but only as long as the writes are not in the same evaluation phase (i.e., not in same delta cycle). Even with SC_MANY_WRITERS, it will be an error to write to an sc_out port from two different processes in the same evaluation cycle.

The fact that you are using signals of type sc_logic doesn't change the rules above. If you truly want multiple writers, you should use sc_signal_resolved as suggested by David.

In your example, you are showing the line that binds the port to the signal as the cause for the error, but my guess is that the error is during simulation.

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.

Guest
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...