Jump to content

Some questions about assignment


SamFox

Recommended Posts

Hi, I'm a rookie studying systemc. In systemc, an input is sc_in<sc_uint<8>> a, a local variable is sc_uint<8> b. I want to ask what is the difference between b = a and b = a.read()? Also, if an input is sc_out<sc_uint<8>> a, a local variable is sc_uint<8> b, what is the difference between a = b and a.write(b)? Thank you.

Link to comment
Share on other sites

From a usage point of view, I would agree; however, there is an important difference.

sc_uint<N> is a type for a data value that may be stored in a variable, but may also be transmitted to another process via a local channel or a port external to the module.

sc_in<T> is a port, and is effectively a pointer to an sc_signal primitive channel external to the module. Channels are not data, but rather mechanisms for communication between processes.

Channels manage communication. The channel has an API, which defines how data can be moved in and out of the channel. In the case of sc_signal this means the read() and write() methods.

I agree with @Eyck to use port->read() over the implicit conversion. Similarly, I prefer port->write(expr) over the less obvious overloaded assignment operator.

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