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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×