k-map implemented with a multiplexer

题目如下:

For the following Karnaugh map, give the circuit implementation using one 4-to-1 multiplexer and as many 2-to-1 multiplexers as required, but using as few as possible. You are not allowed to use any other logic gate and you must use a and b as the multiplexer selector inputs, as shown on the 4-to-1 multiplexer below.


代码如下:

module top_module (
    input c,
    input d,
    output [3:0] mux_in
); 
	always @(*) begin
        case({c,d})
            2'b0:
                mux_in = 4'b0100;
            2'b1:
                mux_in = 4'b0001;
            2'b11:
                mux_in = 4'b1001;
            default:
                mux_in = 4'b0101;
        endcase
    end

endmodule
posted @ 2024-03-14 02:04  江左子固  阅读(19)  评论(0)    收藏  举报