how to I test putting in a value of "X" and "Z" on a reg in

A

andersod2

Guest
....sorry I don't have the software on my machine yet so I can't test
this, but need to know the syntax for this. i.e. do I just say

myreg = X; ??
 
On Sep 3, 2:36 am, andersod2 <thechrisander...@gmail.com> wrote:
I think myreg = 1'bx;

...and same for Z..
Correct. 1'bx or 1'bz. X and Z are just identifiers,
which could be used as variable names!

Watch out when testing for these values on an output.
You might try this:
if (signal == 1'bz)
but it won't work the way you expect, because the result
of that comparison (signal == 1'bz) is 1'bx, the
unknown value, which makes no sense in 'if' statements.
Instead, use the "case equality" operator:

if (signal === 1'bz)

which yields true (1'b1) if signal carries 1'bz, false
otherwise.

Same problem, same solution, for testing against 1'bx.

Don't try to use === in synthesisable (RTL) code.
It's a testbench-only operator.

While we're thinking about such things, it might be
worth mentioning a useful trick that's not as
well known as it could be. Suppose you have a
multi-bit value (e.g. "reg [7:0] sig") and you
would like to know if it has ANY unknown (x/z)
bits in it. You can easily test for that:

if (^sig === 1'bx)
$display("One or more bits of sig is unknown");
else
$display("All bits of sig are 0 or 1");

cheers
--
Jonathan Bromley
 
On Fri, 3 Sep 2010 06:01:49 -0700 (PDT), gabor <gabor@alacron.com>
wrote:
I'd be surprised to find that you could actually infer the hardware
that
detects the high-Z state. That implies you have some sort of
multilevel
logic. I2C bus repeaters have circuitry to detect whether a signal is
driven low externally while it is being driven low internally. Again
I don't think you could infer that sort of thing.
I think you mean one high, one low above but anyway you're right. The
easiest way to do this is to have a weak pull-X on your IO, activate
it by turning-off your output and see if the wire is being driven to
opposite direction by reading the input of the same IO. These days
there are IO libraries with cells which have a controllable (weak)
pull-up and a pull-down so it's rather easy to do.
--
Muzaffer Kal

DSPIA INC.
ASIC/FPGA Design Services

http://www.dspia.com
 
Jonathan Bromley <spam@oxfordbromley.plus.com> wrote:
(snip)

Watch out when testing for these values on an output.
(snip)
Instead, use the "case equality" operator:

if (signal === 1'bz)

which yields true (1'b1) if signal carries 1'bz, false
otherwise.

Same problem, same solution, for testing against 1'bx.

Don't try to use === in synthesisable (RTL) code.
It's a testbench-only operator.
That is likely true, but there are systems that need to
do that test. Bus repeaters between two systems that don't
have a signal to indicate bus direction. Pretty much, they
figure out which side is driven first, and drive the other
side based on that.

I used to have a Q-bus repeater which I believe did that.
I also had a VME repeater, but in that case it is possible
that the appropriate signal exists.

-- glen
 
On Sep 3, 8:47 am, glen herrmannsfeldt <g...@ugcs.caltech.edu> wrote:
Jonathan Bromley <s...@oxfordbromley.plus.com> wrote:

(snip)



Watch out when testing for these values on an output.
(snip)
Instead, use the "case equality" operator:
 if (signal === 1'bz)
which yields true (1'b1) if signal carries 1'bz, false
otherwise.
Same problem, same solution, for testing against 1'bx.
Don't try to use === in synthesisable (RTL) code.
It's a testbench-only operator.

That is likely true, but there are systems that need to
do that test.  Bus repeaters between two systems that don't
have a signal to indicate bus direction.  Pretty much, they
figure out which side is driven first, and drive the other
side based on that.

I used to have a Q-bus repeater which I believe did that.
I also had a VME repeater, but in that case it is possible
that the appropriate signal exists.

-- glen
I'd be surprised to find that you could actually infer the hardware
that
detects the high-Z state. That implies you have some sort of
multilevel
logic. I2C bus repeaters have circuitry to detect whether a signal is
driven low externally while it is being driven low internally. Again
I don't think you could infer that sort of thing.

regards,
Gabor
 

Welcome to EDABoard.com

Sponsor

Back
Top