std_logic or std_ulogic?

Std_logic is a subtype of std_ulogic and has exactly one extra property: it's resolved if there are multiple drivers.

Regardless of common practice, std_ulogic is the correct type to use for non-resolved signals that need 9-valued logic. (Often, using "bit" is even more correct -- for instance, on some FPGA architectures that do not have any such thing as an 'X' or a 'U').

Basically, the best thing to do is use the correct type for the job. Often bad practices get propagated by people just parroting the style that they see others use, do without understanding why.


My history is this:

I started off (in about 1999 IIRC) using std_ulogic* all the time - as it's the right thing to do, for just the reasons you describe.

Then I had to interface to a bunch of wizard generated vendor IP which all had std_logics all over the interface. Which meant conversions on the port-mappings (for the _vector elements), and I got lazy and moved over to using std_logic*.

However, I seem to make very few "double-driver" mistakes, so I haven't missed std_ulogic as much as I would've thought. And Modelsim's drivers command makes it very easy to find "who is driving what" when I do occasionally need to...


IIRC the famed Reuse Methodology Manual recommended std_logic(_vector), so maybe methodology groups in companies etc. spread that further in the form of (mandatory) coding guides. Personally, +1 for using std_ulogic when possible.

Tags:

Vhdl