Guest Basma Posted April 5, 2020 Report Share Posted April 5, 2020 hello, i'm new to systemc i want to have a code that initialize 2 2D arrays and perform convolution, what i've done in the header file is sc_vector < sc_vector <sc_in < float >>> in2 sc_vector < sc_vector <sc_in < float >>> w2 in2.init(4); in2[0].init(4) ; in2[1].init(4) ; in2[2].init(4) ; in2[3].init(4) ; w2.init(2); w2[0].init(2); w2[1].init(2) ; my problem is that i want to put values for in2 and w2 2D arrays to test my mehod however i don't know the syntax for this in main.cpp file i get compile errors . Thanks in advance Quote Link to comment Share on other sites More sharing options...
Eyck Posted April 6, 2020 Report Share Posted April 6, 2020 You can access elements using array index operator like this: in2[0][1]=42.0; But you write you want to put values onto the array. You cannot write onto ports as these are only proxys and do not hold values. You need to create a similar sc_signal array and connect it to the ports. sc_signals hold values so you can put values on them using write(). A side node: you should declare your vectors as: sc_vector<sc_vector<sc_in<float>>> in2{"in2", 4, [](char const* name, size_t idx) -> sc_vector<sc_in<float>>*{ return new sc_vector<sc_in<float>>(name, 4); }}; This names your ports (very helpful when tracing values) and you don't need to call init() separately. Bes 1 Quote Link to comment Share on other sites More sharing options...
Bes Posted April 6, 2020 Report Share Posted April 6, 2020 Thank you so much, this helped 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.