You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
916 B
Verilog

module decoder38(
input wire [2:0]i,
output wire [7:0]o
);
// 直接使用门电路连线
wire [7:0] w_o;
assign w_o[0] = i[0] && i[1] && i[2];
assign w_o[1] = !i[0] && i[1] && i[2];
assign w_o[2] = i[0] && !i[1] && i[2];
assign w_o[3] = !i[0] && !i[1] && i[2];
assign w_o[4] = i[0] && i[1] && !i[2];
assign w_o[5] = !i[0] && i[1] && !i[2];
assign w_o[6] = i[0] && !i[1] && !i[2];
assign w_o[7] = !i[0] && !i[1] && !i[2];
assign o = w_o;
// 使用 always 连线
reg [7:0]r_o;
always @(i) begin
// 阻塞赋值
r_o[0] = i[0] && i[1] && i[2];
r_o[1] = !i[0] && i[1] && i[2];
r_o[2] = i[0] && !i[1] && i[2];
r_o[3] = !i[0] && !i[1] && i[2];
// 非阻塞赋值, 他们是并行连线的
r_o[4] <= i[0] && i[1] && !i[2];
r_o[5] <= !i[0] && i[1] && !i[2];
r_o[6] <= i == 3'b001; // i[0] && !i[1] && !i[2];
r_o[7] <= !i[0] && !i[1] && !i[2];
end
assign o=r_o;
endmodule