HenkNep Posted March 17, 2014 Report Share Posted March 17, 2014 Hi,I have a simple tri-state output signalsc_out<sc_logic> ctrlout;If I write to it directly compilation fails:ctrlout.write('Z'); // failsThe same applies to using a variable:sc_logic local='Z'; // failsThe only one that works is:sc_logic local;local='Z';ctrlout.write(local);Do I really have to jump through so many hoops to assign a tri-state value to an output port?I then found an example on the web which uses resolved types, even though I only have 1 driver the resolved type works:sc_out_rv<1> out;out.write('Z');Am I correct in stating that even for a single driver I need to use the _rv types?I also noticed that _resolved has the same issues, that is you cannot assign 'Z' directly.Thanks for any advice. Quote Link to comment Share on other sites More sharing options...
Philipp A Hartmann Posted March 17, 2014 Report Share Posted March 17, 2014 Conversion from char to sc_logic is not possible in all cases. But fortunately, you can find the solution to your question is Section 7.9.2.8 of the IEEE Std. 1666-2011for SystemC (emphasis added): 7.9.2.8 sc_logic constant definitionsA constant of type sc_logic shall be defined for each of the four possible sc_logic_value_t states. These constants should be used by applications to assign values to, or compare values with, other sc_logic objects, particularly in those cases where an implicit conversion from a C++ char value would be ambiguous. namespace sc_dt { const sc_logic SC_LOGIC_0( Log_0 ); const sc_logic SC_LOGIC_1( Log_1 ); const sc_logic SC_LOGIC_Z( Log_Z ); const sc_logic SC_LOGIC_X( Log_X ); } You can the use ctrlout.write( sc_dt::SC_LOGIC_Z ); to write to the port/signal directly. Greetings from Oldenburg, Philipp 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.