

module decoder()
module decoder
(
input wire in1,
input wire in2,
input wire in3,
output reg [0:7] out
);
always@(*)
case({in1,in2,in3})
3'b000: out <= 8'b0000_0001;
3'b001: out <= 8'b0000_0010;
3'b010: out <= 8'b0000_0100;
3'b011: out <= 8'b0000_1000;
3'b100: out <= 8'b0001_0000;
3'b101: out <= 8'b0010_0000;
3'b110: out <= 8'b0100_0000;
3'b111: out <= 8'b1000_0000;
default:out <= 8'b0000_0001;
endcase
endmodule
tb_decoder
`timescale 1ns/1ns
module tb_decoder();
reg in1;
reg in2;
reg in3;
wir

这篇文章详细介绍了如何使用八进制输入信号对模块decoder进行操作,通过实例展示了输入wirein1、wirein2和wirein3的不同组合如何映射到outputreg的输出。测试用例部分使用了random函数生成随机输入,监测输出变化。
最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



