Jump to content

Tri-State output port


HenkNep

Recommended Posts

Hi,

I have a simple tri-state output signal

sc_out<sc_logic> ctrlout;

If I write to it directly compilation fails:

ctrlout.write('Z'); // fails

The same applies to using a variable:

sc_logic local='Z'; // fails

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

Link to comment
Share on other sites

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 definitions

A 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

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