SamFox Posted March 13, 2023 Report Share Posted March 13, 2023 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. Quote Link to comment Share on other sites More sharing options...
Eyck Posted March 13, 2023 Report Share Posted March 13, 2023 In both cases there is no difference. The operator=() is overloaded with read() adn write() respectively. So you can use both notions interchangably. I personally tend to use read() and write() since this expresses my intend. SamFox 1 Quote Link to comment Share on other sites More sharing options...
David Black Posted March 13, 2023 Report Share Posted March 13, 2023 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. SamFox and maehne 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.