Aaron Yang Posted October 30, 2018 Report Share Posted October 30, 2018 Hey I am kinda new to system C, I met this error when connecting ports declared as array: sc_main.cpp: In function 'int sc_main(int, char**)': sc_main.cpp:16:21: error: expression cannot be used as a function tb0.in(sample_in); This is sc_main.cpp #include <systemc.h> #include "fir.h" #include "tb.h" int sc_main (int, char *[]){ sc_clock clock("clock", 10, SC_NS); sc_signal<bool> reset; sc_signal<sc_fixed<16,2>> sample_in[2]; sc_signal<sc_fixed<16,2>> sample_out[4]; tb tb0("tb0_name"); tb0.rstn(reset); tb0.clk(clock); tb0.in(sample_in); tb0.out(sample_out); fir1("fir1_name", true); fir1.din(sample_in); fir1.dout(sample_out); This is the tb.h file #include <systemc.h> SC_MODULE(tb) { sc_in<bool> clk; sc_out<bool> rstn; sc_out<sc_fixed<16,2>> in[2]; sc_in<sc_fixed<16,2>> out[4]; This is the fir.h #include <systemc.h> SC_MODULE(fir) { sc_in<bool> rst_n; sc_in<bool> clk; sc_in<sc_fixed<16,2>> din[2]; sc_out<sc_fixed<16,2>> dout[4]; What should I do in this case? Quote Link to comment Share on other sites More sharing options...
Roman Popov Posted October 30, 2018 Report Share Posted October 30, 2018 19 minutes ago, Aaron Yang said: What should I do in this case? Usually you should use sc_vector instead of array. The problem with array is that names of signals and ports in array will be initialized to meaningless values (port_0 ... port_1 ). If you still want to use arrays, then bind with a loop. Here is example, both for array and sc_vector. #include <systemc.h> static const int N_PORTS = 4; struct dut : sc_module { sc_in<int> in_array[N_PORTS]; sc_vector<sc_in<int>> in_vector{"in_vector", N_PORTS}; SC_CTOR(dut) {} }; struct test : sc_module { dut d0{"d0"}; sc_signal<int> sig_array[N_PORTS]; sc_vector<sc_signal<int>> sig_vector{"sig_vector", N_PORTS}; SC_CTOR(test) { for (size_t i = 0; i < N_PORTS; ++i) { d0.in_array[i](sig_array[i]); } d0.in_vector(sig_vector); } }; Aaron Yang 1 Quote Link to comment Share on other sites More sharing options...
Aaron Yang Posted October 30, 2018 Author Report Share Posted October 30, 2018 Thanks Roman, that works! 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.