Jump to content

syntax problems

Guest Basma

Recommended Posts

Guest Basma

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[0].init(4) ;
        in2[1].init(4) ;
        in2[2].init(4) ;
        in2[3].init(4) ;

        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 

Link to comment
Share on other sites

You can access elements using array index operator like this:


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.

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