组合逻辑之3-8 译码器 利用Verilog实现

组合逻辑之3-8 译码器 利用Verilog实现

module demo(a,b,c,out);
	input a;
	input b;
	input c;
	
	output reg[7:0]out;
	
	always@(a,b,c) begin
		case({a,b,c})
			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;
		endcase
	end
endmodule

TestBanch

`timescale 1ns/1ns

module demo_tb;

	reg a;
	reg b;
	reg c;
	
	wire [7:0]out;
	
	demo demo(     //待测试文件例化到仿真文件
			.a(a),
			.b(b),
			.c(c),
			.out(out)
			);
	initial begin 
		a = 0;b = 0;c = 0;
		#200
		a = 0;b = 0;c = 1;
		#200
		a = 0;b = 1;c = 0;
		#200
		a = 0;b = 1;c = 1;
		#200
		a = 1;b = 0;c = 0;
		#200
		a = 1;b = 0;c = 1;
		#200
		a = 1;b = 1;c = 0;
		#200
		a = 1;b = 1;c = 1;
		#200
		$stop;
	end
endmodule
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值