verilog if else to casex

Guest #5155384
Rate this post
• ▲ useful
▼ not useful
1
reg A, B, C, D, E, F, G, H;
2
always@(*)
3
casex({A,B,C})
4
  3'b1xx:H = F & G;
5
  3'b01x:H = F | G;
6
  3'b001:H = F ^ G;
7
  3'b000:H = D & E;

think in sets.
The first if only concerns the A, the others don't matter.
the second if is inside the else clause to the first if so A==0 and 
B==1. c
does not matter. the third if is in the else clause to the previous 
statements, so A==0 B==0 and C==1. the last else selects the only 
leftover condition. A==0 B==0 C==0.

    A  B  C
    0  0  0  ->what's left for the else
    0  0  1  ->third if
    0  1  0  \->second if
    0  1  1  /
    1  0  0  \
    1  0  1   |
    1  1  0   |->first if
    1  1  1  /

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.