我写了一个小的VHD文件,用于模拟正交解码器的行为,如下所示。按预期使用通用测试台进行设计仿真。但是在用Quartus生成可综合设计之后,我遇到了两个问题之一(例如,在使用 unsigned 时)
1.在整个合成后仿真过程中,position
和direction
信号始终为恒定的0值。
2. position
值似乎每3-4个时钟周期跳10个值,这归因于数据中的某些抖动。
有没有人有解决此问题的建议?这主要是时序问题,还是我的设计存在重大缺陷?
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.NUMERIC_STD.ALL;
entity quad_decoder is
port(rst : in std_logic;
clk : in std_logic;
a : in std_logic;
b : in std_logic;
direction : out std_logic;
position : out std_logic_vector(8 DOWNTO 0));
end quad_decoder;
architecture behavioral of quad_decoder is
begin
process(clk)
variable counter : integer range 0 to 360 := 0;
variable chanA,chanB : std_logic;
variable int_direction : std_logic;
begin
if (rst = '0') then
int_direction := '0';
counter := 0;
elsif (rising_edge(clk)) then
chanA := a;
chanB := b;
if (chanA = '1') and (chanB = '0') then
if (counter = 360) then
counter := 0;
else
counter:= counter + 1;
end if;
int_direction := '1';
elsif (chanA = '0') and (chanB = '1') then
if (counter = 0) then
counter := 360;
else
counter := counter-1;
end if;
int_direction := '0';
else
counter := counter;
int_direction := int_direction;
end if;
position <= std_logic_vector(to_unsigned(counter,9));
direction <= int_direction;
end if;
end process;
end behavioral;
预期的合成前快照为here。
我已经链接了合成后模拟here的示例快照。如图所示,在多个时钟周期中,position
和direction
均没有变化。
答案 0 :(得分:1)
如果有人好奇,在时钟边沿进行赋值以及将复位信号调高证明会引入各种时序问题,这些问题通过了多角时序分析测试,但未能通过 Quartus 中的其他测试,我没有注意到。
如果我的回答含糊不清,我可以详细说明。