Jump to content

Unable to initialize a vector of integers


otl0rz

Recommended Posts

I am trying to initialize a sc_vector of sc_uint<8>, but I always get this error message:

Error: (E403) conversion failed: character string 'test_0' is not valid
In file: ../../../src/sysc/datatypes/int/sc_uint_base.cpp:530

 

I don't get an error with the same approach but using sc_lv instead.

Here's a minimal code example to reproduce my issue:

#include <systemc.h>

int sc_main (int argc, char* argv[]) {
  sc_vector<sc_lv<8>> test2 {"test2", 1000};
  sc_vector<sc_uint<8>> test {"test", 1000};
  exit(0);
}

 

Can anyone explain to me what I'm doing wrong?

Link to comment
Share on other sites

The form you are using is causing the sc_vector constructor to think it has named elements, that is, it expects the vector elements to have a name field that is passed to the constructor for each element. So it will try to create elements with names test_0, test_1, ..., test_999 by calling the constructor for sc_uint<8> with those names. While the sc_uint class has a constructor that takes a char* argument, that argument is expected to be a character representation of a value.  

 

I would suggest you use std::vector for scalar types like sc_uint instead:

std::vector<sc_lv<8> > test2(1000);

std::vector<sc_uint<8> > test(1000);

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