VHDL测试台:输出未更改
我目前正在学习为我的VHDL组件编写测试台。我正在测试一个时钟同步器,它由两个级联D型触发器组成。我已经编写了一个测试台,提供了一个时钟和适当的输入信号刺激,但我在模拟时没有看到输出变化,它只是保持在“00” 我将非常感谢任何帮助 编辑:dff组件是标准的Quartus组件,不太确定如何获取内部代码 以下是组件VHDL:VHDL测试台:输出未更改,vhdl,fpga,Vhdl,Fpga,我目前正在学习为我的VHDL组件编写测试台。我正在测试一个时钟同步器,它由两个级联D型触发器组成。我已经编写了一个测试台,提供了一个时钟和适当的输入信号刺激,但我在模拟时没有看到输出变化,它只是保持在“00” 我将非常感谢任何帮助 编辑:dff组件是标准的Quartus组件,不太确定如何获取内部代码 以下是组件VHDL: library ieee; use ieee.numeric_std.all; use ieee.std_logic_1164.all; --This device
library ieee;
use ieee.numeric_std.all;
use ieee.std_logic_1164.all;
--This device is to synchronize external signals that are asynchronous to the
--system by use of two cascaded D-Type flip flops, in order to avoid metastability issues.
--Set the generic term Nbits as required for the number of asynchronous inputs to
--be synchronized to the system clock OUTPUT(0) corresponds to INPUT(0), ect.
entity CLOCK_SYNCHRONIZER is
generic(Nbits : positive := 2);
port
(
--Define inputs
SYS_CLOCK : in std_logic;
RESET : in std_logic;
INPUT : in std_logic_vector(Nbits-1 downto 0);
--Define output
OUTPUT : out std_logic_vector(Nbits-1 downto 0) := (others=>'0')
);
end entity;
architecture v1 of CLOCK_SYNCHRONIZER is
--Declare signal for structural VHDL component wiring
signal A : std_logic_vector(Nbits-1 downto 0);
--Declare D-Type Flip-Flop
component dff
port(D : in std_logic; CLK : in std_logic; CLRN : in std_logic; Q : out std_logic);
end component;
begin
--Generate and wire number of synchronizers required
g1 : for n in Nbits-1 downto 0 generate
c1 : dff port map(D=>input(n), CLK=>sys_clock, Q=>A(n), CLRN=>reset);
c2 : dff port map(D=>A(n), CLK=>sys_clock, Q=>output(n), CLRN=>reset);
end generate;
end architecture v1;
这是测试台:
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity testbench is
end entity;
architecture v1 of testbench is
component CLOCK_SYNCHRONIZER
generic(Nbits : positive := 2);
port
(
--Define inputs
SYS_CLOCK : in std_logic;
RESET : in std_logic;
INPUT : in std_logic_vector(Nbits-1 downto 0);
--Define output
OUTPUT : out std_logic_vector(Nbits-1 downto 0)
);
end component;
constant Bus_width : integer := 2;
signal SYS_CLOCK : std_logic := '0';
signal RESET : std_logic := '1';
signal INPUT : std_logic_vector(Bus_width-1 downto 0) := (others=>'0');
signal OUTPUT : std_logic_vector(Bus_width-1 downto 0) := (others=>'0');
begin
C1 : CLOCK_SYNCHRONIZER
generic map(Nbits=>Bus_width)
port map(SYS_CLOCK=>SYS_CLOCK, RESET=>RESET, INPUT=>INPUT, OUTPUT=>OUTPUT);
always : process
begin
for i in 0 to 50 loop
INPUT <= "11";
wait for 24ns;
INPUT <= "00";
wait for 24ns;
end loop;
WAIT;
end process;
clk : process
begin
for i in 0 to 50 loop
SYS_CLOCK <= '1';
wait for 5ns;
SYS_CLOCK <= '0';
wait for 5ns;
end loop;
WAIT;
end process;
end architecture v1;
ieee库;
使用ieee.std_logic_1164.all;
使用ieee.numeric_std.all;
实体测试台是
终端实体;
testbench的架构v1是
组件时钟同步器
通用(Nbits:正:=2);
港口
(
--定义输入
系统时钟:在标准逻辑中;
复位:在标准逻辑中;
输入:标准逻辑向量(Nbits-1向下至0);
--定义输出
输出:输出标准逻辑向量(Nbits-1向下至0)
);
端部元件;
恒定总线宽度:整数:=2;
信号系统时钟:标准逻辑:='0';
信号复位:标准逻辑:='1';
信号输入:标准逻辑向量(总线宽度-1到0):=(其他=>'0');
信号输出:标准逻辑向量(总线宽度-1到0):=(其他=>'0');
开始
C1:时钟同步器
通用映射(Nbits=>总线宽度)
端口映射(系统时钟=>系统时钟,复位=>复位,输入=>输入,输出=>输出);
始终:过程
开始
对于0到50循环中的i
输入问题在于您没有编译一个实体来绑定到dff
组件。请参见,其中显示以下警告:
ELAB1警告ELAB1_0026:“组件没有默认绑定
“dff”。(未找到名为“dff”的实体)。“design.vhd”45 0。。。
ELBREAD:警告:ELBREAD_0037组件/测试台/C1/g1__1/C1:dff未绑定。
ELBREAD:警告:ELBREAD_0037组件/测试台/C1/g1__1/c2:dff未绑定。
ELBREAD:警告:ELBREAD_0037组件/测试台/C1/g1__0/C1:dff未绑定。
ELBREAD:警告:ELBREAD_0037组件/测试台/C1/g1__0/c2:dff未绑定
如果没有配置,则需要将其称为dff
,并且必须具有与dff
组件完全相同的端口,即:
entity dff is
port(D : in std_logic; CLK : in std_logic; CLRN : in std_logic; Q : out std_logic);
end entity;
(谷歌“VHDL默认绑定规则”)
这需要对dff
触发器的功能进行建模。我假设了以下功能:
architecture v1 of dff is
begin
process (CLK, CLRN)
begin
if CLRN = '0' then
Q <= '0';
elsif rising_edge(CLK) then
Q <= D;
end if;
end process;
end architecture v1;
您还没有给出dff
.Hmm的代码,不知道如何获得它。它是夸脱的标准成分。我知道该组件可以工作,我让它在物理设计中运行,它只是一个我无法理解的测试台。也许可以尝试用一种标准方式生成时钟:clk IEEE Std 1076-2008 15.3词汇元素、分隔符和分隔符,第2段-在某些情况下,需要显式分隔符来分隔相邻的词汇元素(也就是说,在没有分离的情况下,可以将解释作为单个词汇元素)..,第4段-…标识符或抽象文字与相邻标识符或抽象文字之间至少需要一个分隔符。5ns
必须是5ns
,或者可以被标识为包含非基字符的抽象文字。5ns
的可移植性问题被忽略,有利于供应商锁定。IEEE Std 1076-2008 7.3.3默认约束指示,第2段“…可见实体声明是下表中的第一个实体声明(如有):…c)用L.C表示的实体声明,其中L是目标库,C是实例化组件的简单名称。目标库是包含声明组件C的设计单元的库的库逻辑名称。“避免配置规范的机制,您的dff
实体位于与testbench
相同的工作库中。有关识别架构的详细信息,请参见第4段。
OUTPUT : out std_logic_vector(Nbits-1 downto 0) := (others=>'0')