Jump to content

Run-time configuration of sc_signal<sc_fix> wordlength

Marco Breiling

Recommended Posts

Dear all,

I have a question similar to https://forums.accellera.org/topic/2126-genericruntime-specification-of-ports/

I want to sweep through a set of wordlengths in a design space exploration task, i.e. test whether the system (including functional behaviour of the algorithm) works with signals of type sc_fix with e.g. 3 integer + 3 fractional bits, 2+4 or 4+2. All with the same build target (i.e. without re-compiling every time), i.e. the word lengths of the signals and corresponding module ports should be read from a file and then be used in the constructors (of the signals, and module-ports) at run-time.

However, I did not succeed. My approach was to pass the wordlengths of the sc_fix to the constructor of sc_signal (or the port), but there is apparently no sc_signal, sc_in, … constructor that accepts this additional input.

My next approach was, that the sc_signal<sc_fix> can apparently be configured by the current context parameters, when it is constructed. When I have ports in a module, however, they are constructed “en bloc” (during module construction) and I cannot set the context for each port individually. So this approach does not work either.

Do you maybe have an idea how to solve the problem?

Many thanks in advance,



Link to comment
Share on other sites

  • 3 weeks later...

Your question is not stupid at all, but requires knowledge of some less widely known corners of the IEEE Std 1666-2011. Typically, people constrain the word length of their data types using the template parameters, because this has the additional advantage of enforcing correct connectivity. As you noted, the port and signal types construct the value types using their default constructor. So, to configure the word lengths as required in your use case, you will have to profit from the fact that SystemC integers and vectors get their default length from the current sc_dt::sc_length_context in scope. I recommend to read up on the topic in chapter 7 of IEEE Std 1666-2011, in particular clause 7.2.3 "Base class default word length". I think this should allow you to implement all aspects of your use case.

Link to comment
Share on other sites

  • 2 weeks later...

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