How to create balanced logic (case
) instead of priority (if .. else
) for the following case?
I know I could get balanced logic when I change following priority logic
if(a == 2'b00) out = 1;
else if(a == 2'b01) out = 4'b0010;
else if(a == 2'b10) out = 4'b0100;
else if(a == 2'b11) out = 4'b1000;
To
case(a)
2'b00: out = 1;
2'b01: out = 2;
2'b10: out = 4;
2'b11: out = 8;
endcase
But how can I get balanced logic if the priority logic is this?
if(a) out = 1;
else if(b) out = 4'b0010;
else if(c) out = 4'b0100;
else if(d) out = 4'b1000;