256-to-1 4-bit multiplexer
Create a 4-bit wide, 256-to-1 multiplexer. The 256 4-bit inputs are all packed into a single 1024-bit input vector. sel=0 should select bits in[3:0], sel=1 selects bits in[7:4], sel=2 selects bits in[11:8], etc.
Mux256to1v - HDLBits (01xz.net)
1 module top_module( 2 input [1023:0] in, 3 input [7:0] sel, 4 output [3:0] out ); 5 assign out = {in[sel*4+3],in[sel*4+2],in[sel*4+1],in[sel*4]}; 6 /*题5中不能使用assign out = in[sel*4+3:sel*4],此时会报错, 7 因为该等式不能证明选择的这个位宽是个常数。所以我们继续按bit进行选取然后进行拼接。*/ 8 endmodule

浙公网安备 33010602011771号