IBNobody
Junior Member level 1
One thing in Verilog always gives me fits:
assign data_out =
((output_select == 3'h01) * {2'b0, saved_rx_data[12:7]})
+ ((output_select == 3'h02) * {1'b0, saved_rx_data[6:0]})
+ ((output_select == 3'h03) * 8'h00);
This statement only produces 1 bit because of the logical equal-to sign. Similar logic would work just fine in C.
Can anyone tell me a better way to write out an equation-based MUX?
I thought about assigning aliases for each of the 3 MUX terms and using generates to combine them... But that's kinda clunky.
I'd love to hear your suggestions
assign data_out =
((output_select == 3'h01) * {2'b0, saved_rx_data[12:7]})
+ ((output_select == 3'h02) * {1'b0, saved_rx_data[6:0]})
+ ((output_select == 3'h03) * 8'h00);
This statement only produces 1 bit because of the logical equal-to sign. Similar logic would work just fine in C.
Can anyone tell me a better way to write out an equation-based MUX?
I thought about assigning aliases for each of the 3 MUX terms and using generates to combine them... But that's kinda clunky.
I'd love to hear your suggestions