What does the "?" symbol mean in Verilog?

Status
Not open for further replies.

rohankewl

Newbie level 5
Joined
Feb 27, 2007
Messages
10
Helped
3
Reputation
6
Reaction score
1
Trophy points
1,283
Activity points
1,328
I have a simple doubt in verilog,
what does this statement mean
assign Full=(wrptr > 4'b1111)?1'b1:1'b0;
I don't get the'?' mark part.
 

? in Verilog

if wrptr is larger than 1111, output is 1. Otherwise, 0
 

Re: ? in Verilog

I have a simple doubt in verilog,
what does this statement mean
assign Full=(wrptr > 4'b1111)?1'b1:1'b0;
I don't get the'?' mark part.


"?" is called a ternary operator because it works on not two but THREE operands( wrptr > 4'b1111 actually evaluates to True or False which is in turn taken as the third operand).If the expression before the "?" evaluates to true then the value immediately following the "?" is assigned to the variable(here, Full) otherwise if its false the value after the ":" is assigned.
This ternary operator is the most simple way of implementing a MUX ..
By nesting the ternary operators, we can actually implement n:1 MUX ..

Regards
Kaustubh
 

    rohankewl

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…