HLDBits Solution : 256-to-1 Multiplexer

In his quiz, I was required to create a 256-to-1 multiplexer. I used for-loop and if statement as I cannot write all cases here. Here is my code.

module top_module(
input [255:0] in,
input [7:0] sel,
output out );

always@(*)begin
for(int i=0; i<256;i=i+1)begin
if(sel==i)
out = in[i];
else
out = out;
end
end

endmodule

Reference: https://hdlbits.01xz.net/wiki/Mux256to1

Leave a Reply

Your email address will not be published. Required fields are marked *