你好我必須做一個rs232驅動程序協議連接到nexys 2,我用3個模塊,frecuency除數,Tx,Rx代碼,但現在我必須看看我的代碼是否工作在測試臺上,我知道如何創建測試臺模塊,但不知道爲了使其工作而必須放置哪些東西。測試臺RS232協議VHDL
以下是測試臺我做了,但我不知道我要補充那裏,以我的RS232 UART炒鍋
-- VHDL Test Bench Created by ISE for module: UART
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--USE ieee.numeric_std.ALL;
ENTITY TB_RS232 IS
END TB_RS232;
ARCHITECTURE behavior OF TB_RS232 IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT UART
PORT(
Rx : IN std_logic;
clk : IN std_logic;
Data_in : IN std_logic_vector(7 downto 0);
send : IN std_logic;
Tx : OUT std_logic;
Data_out : OUT std_logic_vector(7 downto 0);
ready : OUT std_logic
);
END COMPONENT;
--Inputs
signal Rx : std_logic := '0';
signal clk : std_logic := '0';
signal Data_in : std_logic_vector(7 downto 0) := (others => '0');
signal send : std_logic := '0';
--Outputs
signal Tx : std_logic;
signal Data_out : std_logic_vector(7 downto 0);
signal ready : std_logic;
-- Clock period definitions
constant clk_period : time := 10 ns;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: UART PORT MAP (
Rx => Rx,
clk => clk,
Data_in => Data_in,
send => send,
Tx => Tx,
Data_out => Data_out,
ready => ready
);
-- Clock process definitions
clk_process :process
begin
clk <= '0';
wait for clk_period/2;
clk <= '1';
wait for clk_period/2;
end process;
-- Stimulus process
stim_proc: process
begin
-- hold reset state for 100 ns.
wait for 100 ns;
wait for clk_period*10;
-- insert stimulus here
wait;
end process;
END;
這裏是Frecuency除數:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use ieee.std_logic_unsigned.all;
entity DivFrec is
Port (clk : in STD_LOGIC;
clk_div : out STD_LOGIC);
end DivFrec;
architecture Behavioral of DivFrec is
signal contador : std_logic_vector(8 downto 0):=(others=>'0');
begin
process(clk)
begin
if(rising_edge(clk))then
clk_div<='0';
if(contador<433)then microsegundos
contador<=contador+1;
else
clk_div<='1';
contador<=(others=>'0');
end if;
end if;
end process;
end Behavioral;
在刺激部分,您需要修改UUT的輸入信號,並在預期的時間延遲上使用一些測試值,然後驗證輸出是否包含預期值(斷言...報告對此有好處) –