1

I have written a code and trying to generate vcd file in systemc, but I had a error that I can't fix.

// File : pe_main.cpp
#include "driver.h"
#include "monitor.h"
#include "pe.h"
#include "systemc.h"

int sc_main(int argc , char *argv[] )
{

    sc_signal< int > t_data,t_weight;
    sc_signal< int > t_inputpsum,t_outdata;     
    sc_signal <bool> b1,b2;
    pe pe1("pe");
    pe1.data(t_data);
    pe1.weight(t_weight);
    pe1.inputpsum(t_inputpsum);
    pe1.outdata(t_outdata);
    pe1.accinpsum(b1);
    pe1.resacc(b2);

    driver d1("GenerateWaveforms");
    d1.d_data(t_data);
    d1.d_weight(t_weight) ;
    d1.d_inputpsum(t_inputpsum);


   monitor m1("MonitorWaveforms");
   m1.m_data(t_data);
   m1.m_weight(t_weight);
   m1.m_inputpsum(t_inputpsum);
   m1.m_outdata(t_outdata);

  sc_trace_file *tf=sc_create_vcd_trace_file("PE");
  sc_trace(tf, t_data, "InputData");
  sc_trace(tf, t_weight, "InputWeight");
  sc_trace(tf, t_inputpsum, "InputPsum");
  sc_trace(tf, t_outdata, "OutData");

  sc_start(100, SC_NS);


   return 0;
  }

The code has no error, but for vcd file, I get the following error:

Error: (E115) sc_signal cannot have more than one driver: signal 'signal_2' (sc_signal) first driver 'MonitorWaveforms.port_3' (sc_inout) second driver 'GenerateWaveforms.port_2' (sc_inout) In file: c:\users\asus\desktop\systemc\system- 2.3.0a\src\sysc\communication\sc_signal.cpp:75

Marc-André
  • 325
  • 2
  • 17

1 Answers1

0

I think the error speaks for itself: you can't bind more than one sc_out or sc_inout port to sc_signal.

Here is a small reproducer for your issue:

#include <systemc.h>

SC_MODULE(top) {

    sc_signal<int> sig{"sig"};
    sc_out<int> port_0{"port_0"};
    sc_out<int> port_1{"port_1"};

    SC_CTOR(top) {
        port_0(sig);
        port_1(sig);
    }
};

int sc_main (int argc, char **argv) {
    top t{"t"};
    sc_start();
}

Error:

Error: (E115) sc_signal<T> cannot have more than one driver: 
 signal `t.sig' (sc_signal)
 first driver `t.port_1' (sc_out)
 second driver `t.port_0' (sc_out)

Depending on your design intent you can do multiple things:

  1. Rewrite your code so that there will be a single driving port for each signal
  2. Change signal writer policy to SC_MANY_WRITERS

    sc_signal<int, SC_MANY_WRITERS> sig{"sig"};

  3. Use sc_signal_resolved if you are modeling a single-write bus with tristate drivers.

random
  • 3,868
  • 3
  • 22
  • 39