#FPGA(Modelsim-Altera仿真)

本文介绍了如何在QuartusII集成开发环境中,针对CycloneIIEP2C8Q208C8NFPGA设计一个基本的三输入译码器,包括电路描述、步骤和仿真实现的详细代码。
摘要由CSDN通过智能技术生成

1.IDE:Quartus II


2.设备:Cyclone II  EP2C8Q208C8N  


3.实验:译码器


4.时序图:


5.步骤:


6.代码:

译码器:

/*
 *译码器
 */
module decoder(
input wire             in1,
input wire             in2,
input wire             in3,

output reg    [7:0]    out
);

always @ (*) begin
   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
end

endmodule

 仿真文件代码:

/*
 *译码器仿真代码
 */
`timescale 1ns/1ns 

module tb_decoder();

reg             in1;
reg             in2;
reg             in3;

wire    [7:0]   out;

/*
 *初始化
 */
initial
    begin
	    in1 <= 1'b0;
		 in2 <= 1'b0;
		 in3 <= 1'b0;
	 end

/*
 *延时一段时间后(10ns)进行随机赋值(0/1)
 */ 
always #10  in1 <= {$random} % 2;         //#10表示时间延时10个单位
always #10  in2 <= {$random} % 2;
always #10  in3 <= {$random} % 2;

/*
 *打印仿真信息
 */
initial
    begin
	    $timeformat(-9,0,"ns",6);   //-9代表ns,0代表小数位,6代表数据位宽
	    $monitor("@time %t:in1=%b,in2=%b,in3=%b,out=%b",$time,in1,in2,in3,out);
	 end

/*  
 *实例化
 */
decoder decoder_inst
(
          .in1(in1),
			 .in2(in2),
			 .in3(in3),
			 
			 .out(out)
);


endmodule

  • 4
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值