Jump to content
katang

A void value confusion

Recommended Posts

In my testbench
 

     void Dendrit_Set(int index, int value)
       { *mNeuron->dendrit[index].write(value);}

     protected:
     Neuron* mNeuron;

I receive the error message

 error: void value not ignored as it ought to be
      { *mNeuron->dendrit[index].write(value);}
                                      ^

The relevant declaration/definition
 

typedef sc_dt::sc_uint<DENDRIT_WIDTH> SC_DENDRIT_TYPE;

SC_MODULE(Neuron) {
    // Ports
    sc_signal<SC_DENDRIT_TYPE > dendrit[NO_OF_DENDRITS];

What is wrong here? (I simple do not understand the error message)

Share this post


Link to post
Share on other sites
3 minutes ago, katang said:

I am sorry, the '*' is obsolete here. The error message, however, is strange, I think.

 

Can  you share some more code ? Where are you calling the function

Dendrit_Set

Share this post


Link to post
Share on other sites

Well, actually the error message from the point of the compiler is quite right: using the '*'-operator you intent to dereference the return value of write() which is 'void'.

BR

Share this post


Link to post
Share on other sites

Hello @katang,

The compiler message is quite right as mentioned by @Eyck.

The Compiler sees the code something like this:

void Dendrit_Set(int index, int value)
{
  *(mNeuron->dendrit[index].write(value));
}

Basically the operator precedence is at play here(refer here for more details).

Compiler sees that you are trying to dereference a void type, since the write method of the sc_signal returns void.

Hope it helps.

Best Regards,

Ameya Vikram Singh

Share this post


Link to post
Share on other sites

You are both right. However, I would formulate the error message something like

'You are attempting to use a void value' and would print the location pointer at after the '*' rather than at the beginning of 'value'

 

Share this post


Link to post
Share on other sites

Based on what I see, the * shouldn't even be there at all since the -> takes care of it.

Either use:

mNeuron->dendrit[index].write(value);

or

(*mNeuron).dendrit[index].write(value);

However, I'm more concerned that you're not using ports to access members of a module (assuming Dendrit_Set is not part of module Neuron). That violates a rather fundamental principle of SystemC. It's legal C++, but questionable SystemC.

Share this post


Link to post
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...