VHDL TB为3位bcd到二进制

时间:2016-02-10 14:38:23

标签: vhdl

我的3位BCD到二进制解码器的测试平台出了问题。 输入很好,但输出是UUUUUU ..... 不知道如何解决它。我应该以某种方式分配输出吗? 我使用ISE来模拟代码 我一直试图应用我在行为模型中使用的方法,但它不接受它。

    -- TestBench Template 
  LIBRARY ieee;
  USE ieee.std_logic_1164.ALL;
  USE ieee.numeric_std.ALL;
  ENTITY testbench IS
  END testbench;
  ARCHITECTURE behavior OF testbench IS 
  COMPONENT bcd_2_bin
    PORT(
         bcd_in_0 : IN  std_logic_vector(3 downto 0);
         bcd_in_10 : IN  std_logic_vector(3 downto 0);
         bcd_in_100 : IN  std_logic_vector(3 downto 0);
         bin_out : OUT  std_logic_vector(9 downto 0)
        );
    END COMPONENT;

   signal bcd_in_0 : std_logic_vector(3 downto 0) := (others => '0');
   signal bcd_in_10 : std_logic_vector(3 downto 0) := (others => '0');
   signal bcd_in_100 : std_logic_vector(3 downto 0) := (others => '0');
   signal bin_out : std_logic_vector(9 downto 0);
BEGIN
    -- Instantiate the Unit Under Test (UUT)
   uut: bcd_2_bin PORT MAP (
          bcd_in_0 => bcd_in_0,
          bcd_in_10 => bcd_in_10,
          bcd_in_100 => bcd_in_100,
          bin_out => bin_out
        );
-- Stimulus process
   stim_proc: process
   begin        
        bcd_in_0 <= x"0"; bcd_in_10 <= x"1"; bcd_in_100 <= x"2";
        wait for 100 ns;
        bcd_in_0 <= x"9"; bcd_in_10 <= x"9"; bcd_in_100 <= x"9"; 
        wait for 100 ns;
        bcd_in_0 <= x"8"; bcd_in_10 <= x"2"; bcd_in_100 <= x"4"; 
      wait;
   end process;
END;

1 个答案:

答案 0 :(得分:0)

您的测试平台没有问题。我检查了下面的虚拟UUT,

ibrary ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;

entity bcd_2_bin is
  port (
         bcd_in_0 : IN  std_logic_vector(3 downto 0);
         bcd_in_10 : IN  std_logic_vector(3 downto 0);
         bcd_in_100 : IN  std_logic_vector(3 downto 0);
         bin_out : OUT  std_logic_vector(9 downto 0)
       );
end bcd_2_bin;

architecture dummy of bcd_2_bin is
  begin
    bin_out(3 downto 0)  <= bcd_in_0;
    bin_out(7 downto 4)  <= bcd_in_10;
    bin_out(9 downto 8)  <= bcd_in_100(1 downto 0);
end dummy;

并成功模拟您的测试平台,无需任何更改。

查看您的UUT源内部以找到问题。在编译期间还要检查错误或警告。