(1)visio:
(2)Verilog代码:
module decoder3_8(in_1,in_2,in_3,out);
input in_1;
input in_2;
input in_3;
output reg [7:0]out;
always@(*)
case({in_1,in_2,in_3})
3'd0: out <= 8'b0000_0001;
3'd1: out <= 8'b0000_0010;
3'd2: out <= 8'b0000_0100;
3'd3: out <= 8'b0000_1000;
3'd4: out <= 8'b0001_0000;
3'd5: out <= 8'b0010_0000;
3'd6: out <= 8'b0100_0000;
3'd7: out <= 8'b1000_0000;
endcase
endmodule
(3)RTL视图:
(4)仿真文件代码:
`timescale 1ns/1ns
module decoder3_8_tb;
reg in_1;
reg in_2;
reg in_3;
wire [7:0] out;
decoder3_8 decoder3_8_inst(
.in_1(in_1),
.in_2(in_2),
.in_3(in_3),
.out(out)
);
initial begin
in_1 <= 1'd0;
in_2 <= 1'd0;
in_3 <= 1'd0;
#2000;
$stop;
end
always #10 in_1 <= {$random} % 2;
always #10 in_2 <= {$random} % 2;
always #10 in_3 <= {$random} % 2;
endmodule
(5)仿真波形: