VHDL四输入与非门74LS00编写及testbench文件仿真

该博客详细介绍了如何使用VHDL进行数字逻辑设计,从新建工程开始,逐步构建了一个二输入与非门实体MYNAND2,然后利用这个基本单元设计了74LS00芯片的逻辑实现。通过编写testbench文件进行仿真验证,最终在Quartus II中运行RTL simulation得到预期的仿真结果。
摘要由CSDN通过智能技术生成

1.新建工程
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
此处型号根据自己板子而定。

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
2.新建二输入与非门实体
在这里插入图片描述
MYNAND2.vhd文件如下

LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;

ENTITY MYNAND2 IS
	PORT(A,B:IN STD_LOGIC;
		Y:OUT STD_LOGIC);
END	ENTITY MYNAND2;

ARCHITECTURE ART1 OF MYNAND2 IS
	BEGIN
	Y<=A NAND B;
END ARCHITECTURE ART1;

在这里插入图片描述

3.MY74LS00.vhd文件如下:

LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;

ENTITY MY74LS00 IS
	PORT(A1,B1,A2,B2,A3,B3,A4,B4:IN STD_LOGIC;
		Y1,Y2,Y3,Y4:OUT STD_LOGIC);
END	ENTITY MY74LS00;

ARCHITECTURE ART2 OF MY74LS00 IS
	--调用元器件声明
	COMPONENT MYNAND2 IS
		PORT(A,B:IN STD_LOGIC;
			Y:OUT STD_LOGIC);
	END COMPONENT MYNAND2;
	
	BEGIN
	--名称映射
	U1:MYNAND2 PORT MAP(A=>A1,B=>B1,Y=>Y1);
	U2:MYNAND2 PORT MAP(A=>A2,B=>B2,Y=>Y2);
	--位置映射
	U3:MYNAND2 PORT MAP(A3,B3,Y3);
	U4:MYNAND2 PORT MAP(A4,B4,Y4);
END ARCHITECTURE ART2;

4.编写testbench文件
参考链接
点击菜单栏中processing,选择start,选择start testbench template write。此时会自动生成testbench模板到项目文件夹simulation里面,后缀为.vht。在MY74LS00\simulation\modelsim文件夹下。
右键,点setting
在这里插入图片描述
点test benches
在这里插入图片描述

在这里插入图片描述
选择…,在文件夹弹窗里面选择刚才的vht文件
点击add,结果如下:
在这里插入图片描述
修改名字,和tb文件里面的entity一致
在这里插入图片描述
在MY74LS00\simulation\modelsim文件夹下找到MY74LS00.vht文件
testbench文件如下:

-- Copyright (C) 1991-2013 Altera Corporation
-- Your use of Altera Corporation's design tools, logic functions 
-- and other software and tools, and its AMPP partner logic 
-- functions, and any output files from any of the foregoing 
-- (including device programming or simulation files), and any 
-- associated documentation or information are expressly subject 
-- to the terms and conditions of the Altera Program License 
-- Subscription Agreement, Altera MegaCore Function License 
-- Agreement, or other applicable license agreement, including, 
-- without limitation, that your use is for the sole purpose of 
-- programming logic devices manufactured by Altera and sold by 
-- Altera or its authorized distributors.  Please refer to the 
-- applicable agreement for further details.

-- ***************************************************************************
-- This file contains a Vhdl test bench template that is freely editable to   
-- suit user's needs .Comments are provided in each section to help the user  
-- fill out necessary details.                                                
-- ***************************************************************************
-- Generated on "05/07/2021 22:28:19"
                                                            
-- Vhdl Test Bench template for design  :  MY74LS00
-- 
-- Simulation tool : ModelSim-Altera (VHDL)
-- 

LIBRARY ieee;                                               
USE ieee.std_logic_1164.all;                                

ENTITY MY74LS00_vhd_tst IS
END MY74LS00_vhd_tst;
ARCHITECTURE MY74LS00_arch OF MY74LS00_vhd_tst IS
-- constants
constant clk_period :time   :=20 ns;                                                  
-- signals                                                   
SIGNAL A1 : STD_LOGIC;
SIGNAL A2 : STD_LOGIC;
SIGNAL A3 : STD_LOGIC;
SIGNAL A4 : STD_LOGIC;
SIGNAL B1 : STD_LOGIC;
SIGNAL B2 : STD_LOGIC;
SIGNAL B3 : STD_LOGIC;
SIGNAL B4 : STD_LOGIC;
SIGNAL Y1 : STD_LOGIC;
SIGNAL Y2 : STD_LOGIC;
SIGNAL Y3 : STD_LOGIC;
SIGNAL Y4 : STD_LOGIC;
COMPONENT MY74LS00
	PORT (
	A1 : IN STD_LOGIC;
	A2 : IN STD_LOGIC;
	A3 : IN STD_LOGIC;
	A4 : IN STD_LOGIC;
	B1 : IN STD_LOGIC;
	B2 : IN STD_LOGIC;
	B3 : IN STD_LOGIC;
	B4 : IN STD_LOGIC;
	Y1 : OUT STD_LOGIC;
	Y2 : OUT STD_LOGIC;
	Y3 : OUT STD_LOGIC;
	Y4 : OUT STD_LOGIC
	);
END COMPONENT;
BEGIN
	i1 : MY74LS00
	PORT MAP (
-- list connections between master ports and signals
	A1 => A1,
	A2 => A2,
	A3 => A3,
	A4 => A4,
	B1 => B1,
	B2 => B2,
	B3 => B3,
	B4 => B4,
	Y1 => Y1,
	Y2 => Y2,
	Y3 => Y3,
	Y4 => Y4
	);
init : PROCESS                                               
-- variable declarations                                     
BEGIN                                                        
        -- code that executes only once
	A1 <= '0';
	B1 <= '0';
	A2 <= '1';
	B2 <= '0';
	A3 <= '0';
	B3 <= '1';
	A4 <= '1';
	B4 <= '1';
WAIT;                                                       
END PROCESS init;                                           
always : PROCESS                                              
-- optional sensitivity list                                  
-- (        )                                                 
-- variable declarations                                      
BEGIN                                                         
        -- code executes for every event on sensitivity list
WAIT;                                                        
END PROCESS always;                                          
END MY74LS00_arch;

5.quartusII 点tools–run simulation tool–RTL simulation,内联modelsim启动,仿真结果如下

仿真结果:
在这里插入图片描述

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值