Jump to content

Data lost in transmission


Recommended Posts


I am currently working on a model that consists of three components: memory, adder and link element between the two of them. The data transmission between them happens via ports that look like sc_in<BasePort*>, so a pointer to the BasePort class. This class only contains the status bits (e.g. valid), while the actual data is part of a child class of BasePort that is just callled Port. Inside the memory an object of type Port will be instatiated, the data will be written to that object, and finally the oject is static casted to an object of type BasePort that will then be written to the output port. The reason for this split is that the linking element should be able to work independently from the underlying data type that is transmitted.

The problem I am running into is that the data of BasePort,  the status bits, seem to get lost during transmission. So for example, in the linking element I can only see the data while the valid flag will always be set to false, even though it was correctly set in the memory. So, i can see the correct data but the valid flag will not be set.

So far I have checked that the pointer that is seen in the linking element is the same as the one that is written in the memory, which is the case. I have also tried chaning the data type of the channels connecting the components from sc_signal<BasePort*> to sc_buffer<BasePort*> but that also didn't fix the issue. I really don't understand why this part of the data transmission is lost. If either all or nothing is lost that would make sense, but I can't think of any reason why only the data of BasePort but not the data of Port is lost.

Any thoughts on what I am doing wrong here?

Thank you!


Link to comment
Share on other sites

Answering your question without having a code example is difficult. You transmit a pointer to BasePort which does not contain the data. Therefore you do not see the data. At your signal sink you need to do a dynamic_cast<> to get a pointer to your Port

Your approach to modeling is strange not to say wrong. What Do you want to model between your memory and adder? Actually you describe a signal carrying a pointer to a Port? Usually a signal carries a value (or a set of values aka a struct) and there will only be value changes which manifest as events. Or do you want to model a bus based communication? In that case you should use TLM2.0 sockets and payload which has quite some flexibility to adapt to particular needs keeping the semantics.

Link to comment
Share on other sites

I would further suggest that the static casting sounds suspicious, but without actual code we cannot determine much about the situation. Ideally you could put a subset of your code on www.EDAplayground.com and share a link. You might also consider turning on compiler switches such as GCC’s --pedantic and -Wall to see if the are any coding violations. 

Link to comment
Share on other sites


so the underlying idea of the whole model I'm working on is that it should be generated from a configuration file during runtime. Thats also the reason for the split between BasePort and Port: The component between the adder and the memory (which is a DMA) doesn't need the data as access to the data would require a dynamic cast.

See this EDAPlayground link for an example how its used. If the actual data is needed you would have to do a dynamic_cast<> as was already mentioned.

Now that I'm thinking about it, you are probably right that this is not a good solution and is, at best, a strange model. I have dug through this forum a bit and stumbled upon sc_bv_base for which you can define the width without relying on templates. So that probably would have been the better idea I think. Any thoughts on this idead?

Anyway, I am still curious why the status bits in this implementation are dropped during the transmission. See the according note in dma.cpp in the link.

Thank you very much!

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