-->

错误的测试平台(Error in testbench)

2019-10-29 22:23发布

我是一个初学者VHDL。 我试图写一个VHDL代码来描述一个红绿灯的行为。 它有3个信号输出黄色(0),绿(1)和红色(2)。 最初的光为黄色。 这将10ns的后转向绿色。 绿色会变成红色后40ns的红会为60ns后回来黄色。 状态机不具有任何外部输入和是10ns的时钟(总时间= 10ns的)同步的自由运行的机器。 交通灯有一个外部复位控制信号来复位的光yellow.I需要显示与2次复位例,无符号十进制格式的自由运行输出信号的测试平台。

VHDL代码运行在强制时钟并通过测试平台移除代码rst_process但如预期测试平台的rst_process不起作用(那张未定义仿真)的罚款

这是主要的VHDL代码

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity traf is
    Port ( clk : in  STD_LOGIC;
           rst : in  STD_LOGIC;
           Green : out  STD_LOGIC;
           Red : out  STD_LOGIC;
           Yellow : out  STD_LOGIC);
end traf;

architecture Behavioral of traf is

signal count:integer range 0 to 10 := 0;
signal state:integer range 0 to 2 := 0;
begin
    process(clk, rst)
    begin
        if(rst = '1') then
            state <= 0;
            Red <= '0';
            Green <= '0';
            Yellow <= '1';
            count <= 0;
        elsif clk'event and clk='1' then
        case state is
        when 0 =>  --Yellow Light
        if(count=1) then
            count <= 0;
            state <= 1;
        else
            count <= (count + 1);
            Red <= '0';
            Green <= '0';
            Yellow <= '1';
        end if;

        when 1 =>  --Green Light
        if(count=4) then
            count <= 0;
            state <= 2;
        else
            count <= count + 1;
            Red <= '0';
            Green <= '1';
            Yellow <= '0';
        end if;

        when 2 =>  --Red Light
        if(count=6) then
            count <= 0;
            state <= 0;
        else
            count <= count + 1;
            Red <= '1';
            Green <= '0';
            Yellow <= '0';
        end if;

        when others =>
            state <= 0;
            count <= 0;
        end case;
        end if;
    end process;
end Behavioral;

这是测试平台代码

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity tb is
--    Port ( );
end tb;

architecture Behavioral of tb is
signal clk,rst,Green,Red,Yellow:std_logic;
constant clk_period : time:=10 ns;
component traf is
     Port (  
              clk : in  STD_LOGIC;
              rst : in  STD_LOGIC;
              Green : out  STD_LOGIC;
              Red : out  STD_LOGIC;
              Yellow : out  STD_LOGIC
           );
 end component;
begin
DUT:traf PORT MAP
(
    clk=>clk,
    rst=>rst,
    Green=>Green,
    Red=>Red,
    Yellow=>Yellow
);

clk_process:process
begin
    clk <= '0';
    wait for clk_period/2;
    clk <= '1';
    wait for clk_period/2;
end process;

rst_process:process
begin
    rst <= '0';
    wait for clk_period * 15;

    rst <= '1';
    wait for clk_period;

    rst <= '0';
    wait for clk_period * 50;

    rst <= '1';
    wait for clk_period*2;

    rst <= '0';
    wait;
end proocess;

end Behavioral;
文章来源: Error in testbench
标签: vhdl fpga xilinx