1.创建新工程:lab(实际功能是,两个与模块的结果再进行或)
新建工程:
工程命名:
选择器件型号和语言类型:
然后点击next和finish,工程创立完成
2.编写程序:
右击工程,创建新的文件:
我这里选择的是VHDL module ,如果你是Verilog,也可以选择,然后输入文件名字:
然后可以输入这个模块的输入输出端口:
点击next和finish后,完成创建,因为我关联了notepad++,会自动跳转到编辑器界面:
然后编写程序即可:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity MY_AND2 is
Port ( A : in STD_LOGIC;
B : in STD_LOGIC;
C : out STD_LOGIC);
end MY_AND2;
architecture Behavioral of MY_AND2 is
begin
C <= A and B;
end Behavioral;
同理,我们编写MY_OR2程序:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity MY_OR2 is
Port ( A : in STD_LOGIC;
B : in STD_LOGIC;
C : out STD_LOGIC);
end MY_OR2;
architecture Behavioral of MY_OR2 is
begin
C <= A or B;
end Behavioral;
然后我们编写顶层文件:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity AND_OR is
Port ( IN1 : in STD_LOGIC;
IN2 : in STD_LOGIC;
IN3 : in STD_LOGIC;
IN4 : in STD_LOGIC;
Z : out STD_LOGIC);
end AND_OR;
architecture Behavioral of AND_OR is
component MY_AND2
port(
A : in std_logic;
B:in std_logic;
C :out std_logic
);
end component;
component MY_OR2
port(
A : in std_logic;
B:in std_logic;
C :out std_logic
);
end component;
signal sig1,sig2:std_logic;
begin
U0:MY_AND2 port map(A => IN1,B => IN2,C=>sig1);
U1:MY_AND2 port map(A => IN3,B => IN4,C=>sig2);
U2:MY_OR2 port map(A => sig1,B => sig2,C=>Z);
end Behavioral;
3.语法检查:
4.查看电路图:
双击 view rtl schmemaic即可:
5.行为级仿真:
创建tb测试文件:
选择顶层文件:
进行tb文件编写:
然后双击simulate behavioral model就可以进行仿真了:
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY tb_AND_OR IS
END tb_AND_OR;
ARCHITECTURE behavior OF tb_AND_OR IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT AND_OR
PORT(
IN1 : IN std_logic;
IN2 : IN std_logic;
IN3 : IN std_logic;
IN4 : IN std_logic;
Z : OUT std_logic
);
END COMPONENT;
--Inputs
signal IN1 : std_logic:='0';
signal IN2 : std_logic:='0';
signal IN3 : std_logic :='0';
signal IN4 : std_logic :='0';
--Outputs
signal Z : std_logic;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: AND_OR PORT MAP (
IN1 => IN1,
IN2 => IN2,
IN3 => IN3,
IN4 => IN4,
Z => Z
);
TB:process
begin
IN1 <= '1';IN2<='0';
IN3 <= '0';IN4<='1';
wait for 50 ns;
IN1 <= '0';IN2<='0';
IN3 <= '1';IN4<='1';
wait for 50 ns;
IN1 <= '1';IN2<='0';
IN3 <= '0';IN4<='1';
wait;
end process;
END;
得出仿真波形图:
6.生成网表文件
双击implement design:
然后就可以看到占用的资源的总体报告:
7.布局布线后仿真:
如果没有出现仿真器,就点击一下tb文件
我们可以看到后仿真后 时序依旧满足要求: