这是我的代码:
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY AND_Bank_Test IS
END AND_Bank_Test;
ARCHITECTURE behavior OF AND_Bank_Test IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT AND_Bank
PORT(
Input : IN std_logic_vector(7 downto 0);
AND_Bit : IN std_logic;
Output : OUT std_logic_vector(7 downto 0)
);
END COMPONENT;
--Inputs
signal Input : std_logic_vector(7 downto 0) := (others => '0');
signal AND_Bit : std_logic := '0';
--Outputs
signal Output : std_logic_vector(7 downto 0);
-- No clocks detected in port list. Replace <clock> below with
-- appropriate port name
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: AND_Bank PORT MAP (
Input => Input,
AND_Bit => AND_Bit,
Output => Output
);
-- Stimulus process
stim_proc: process
begin
-- hold reset state for 100 ns.
wait for 100 ns;
Input <= "00000001" ; AND_Bit <= 0;
wait for 100 ns;
Input <= "00111011" ; AND_Bit <= 1;
wait for 100 ns;
Input <= "10111011" ; AND_Bit <= 0;
wait for 100 ns;
Input <= "10110011" ; AND_Bit <= 1;
wait for 100 ns;
Input <= "01110111" ; AND_Bit <= 0;
wait for 100 ns;
Input <= "10110000" ; AND_Bit <= 1;
wait for 100 ns;
Input <= "11110011" ; AND_Bit <= 0;
wait for 100 ns;
Input <= "01110011" ; AND_Bit <= 1;
wait for 100 ns;
Input <= "10111111" ; AND_Bit <= 0;
wait for 100 ns;
Input <= "11111111" ; AND_Bit <= 1;
wait for 100 ns;
wait;
end process;
END;
Run Code Online (Sandbox Code Playgroud)
这是我得到的错误:
Type std_logic does not match with the integer literal
(this refers to Input <= "00000001" ; AND_Bit <= 0; )
我用这个替换了我的代码:
ENTITY AND_Bank_Test结束AND_Bank_Test;
AND_Bank_Test IS的架构行为
COMPONENT AND_Bank
PORT(
Input : IN std_logic_vector(15 downto 0);
AND_Bit : IN std_logic;
Output : OUT std_logic_vector(15 downto 0)
);
Run Code Online (Sandbox Code Playgroud)
结束组件;
--Inputs
signal Input : std_logic_vector(15 downto 0) := (others => '0');
signal AND_Bit : std_logic := '0';
--Outputs
signal Output : std_logic_vector(15 downto 0);
Run Code Online (Sandbox Code Playgroud)
开始
-- Instantiate the Unit Under Test (UUT)
uut: AND_Bank PORT MAP (
Input => Input,
AND_Bit => AND_Bit,
Output => Output
);
Run Code Online (Sandbox Code Playgroud)
- 刺激过程
stim_proc:进程开始
- 保持复位状态100 ns.
wait for 100 ns;
Input <= "0000000000000001" ; AND_Bit <= '0';
wait for 100 ns;
Input <= "0000000000111011" ; AND_Bit <= '1';
wait for 100 ns;
Input <= "0000000010111011" ; AND_Bit <= '0';
wait for 100 ns;
Input <= "0000000010110011" ; AND_Bit <= '1';
wait for 100 ns;
Input <= "0000000001110111" ; AND_Bit <= '0';
wait for 100 ns;
Input <= "0000000010110000" ; AND_Bit <= '1';
wait for 100 ns;
Input <= "0000000011110011" ; AND_Bit <= '0';
wait for 100 ns;
Input <= "0000000001110011" ; AND_Bit <= '1';
wait for 100 ns;
Input <= "0000000010111111" ; AND_Bit <= '0';
wait for 100 ns;
Input <= "0000000011111111" ; AND_Bit <= '1';
wait for 100 ns;
Run Code Online (Sandbox Code Playgroud)
等待; 结束过程;
结束;
这是运行AND银行测试的正确方法吗?为什么不能只用8位运行它?
您需要使用单引号,例如:
Input <= "00000001" ; AND_Bit <= '0';
Run Code Online (Sandbox Code Playgroud)
如果您没有使用单引号,则假定您正在为其分配一个整数值AND_Bit,这就是为什么它会给您一个错误.