Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

I m a beginner in verilog please help in this regard which i m mentioning below

Status
Not open for further replies.

aahieo

Newbie level 1
Newbie level 1
Joined
Mar 3, 2013
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,286
I want to check a byte whether it has an "x" bit.

How can i proceed for this
 

can you clarify what you mean by " "x" bit"? If you mean checking whether a specific bit of a byte size register is some state "x" (1 or 0 ) simply use

if (reg_name[n] = x)

or to check if any bits in the byte are some state "x"

if ((reg_name[7] = x) | (reg_name[6] = x) ....etc)

There's many other ways it can be done, but that's the most obvious I can think of.

If you mean to check for the indeterminate state "x" which can be seen in some simulation software that is not 1 or 0, you won't find it. In terms of applying to hardware, registers initialise to 0, and even noise on a floating input pin is only ever seen as 1 or 0.
 

If you are using a simulator that supports SystemVerilog, like ModelSim/Questa, you can use the expression

$isunknown(mybyte)

that returns 1'b1 if any bit in the expression is X or Z.

Otherwise you will have to use a reduction XOR operation

(^mybyte) === 1'bx

The three '=' identity operator is needed to compare to an 'x. The two '=' equality operator will always return false with an unknown.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top