Mux256to1v

2023. 6. 12. 18:23FPGA/HDLBits

728x90

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.

//성공 코드
module top_module( 
    input [1023:0] in,
    input [7:0] sel,
    output [3:0] out );
	
    assign out = {in[sel * 4 + 3], in[sel * 4 + 2], in[sel * 4 + 1], in[sel * 4 + 0]};
endmodule

//실패 코드
module top_module( 
    input [1023:0] in,
    input [7:0] sel,
    output [3:0] out );
	
    assign out = in[4*sel+3 : 4*sel];
endmodule

'FPGA > HDLBits' 카테고리의 다른 글

Fadd  (0) 2023.06.12
Hadd  (0) 2023.06.12
Mux256to1  (0) 2023.06.12
Mux9to1v  (0) 2023.06.12
Mux2to1v  (0) 2023.06.12