-1
感谢您的所有输入,我实现了您的建议,但问题仍然存在。模拟结果正常,但硬件 输出不同的东西。只是简要地回顾一下,我有一个确定的实体的行为的两个CTRL信号:“简单”VHDL模块的设计仍然使我疯狂
GET (ctrl = "00000000") sets register tx to input of op1
SH1_L (ctrl = "00000001") res := (op1 << 1) | tx;
tx := tx >> 31;
这里是VHDL代码:
library ieee;
use ieee.std_logic_1164.all;
entity test is
port
(
op1 : in std_logic_vector(31 downto 0); -- Input operand
ctrl : in std_logic_vector(7 downto 0); -- Control signal
clk : in std_logic; -- clock
res : out std_logic_vector(31 downto 0) -- Result
);
end;
architecture rtl of test is
type res_sel_type is (GET, SH1_L);
constant Z : std_logic_vector(31 downto 0) := (others => '0');
signal res_sel : res_sel_type;
signal load : std_logic := '0';
signal shl : std_logic := '0';
signal tx : std_logic_vector(31 downto 0) := (others => '0');
signal inp1 : std_logic_vector(31 downto 0) := (others => '0');
begin
dec_op: process (ctrl, op1)
begin
res_sel <= GET;
load <= '0';
shl <= '0';
inp1 <= (others => '0');
case ctrl is
-- store operand
when "00000000" =>
inp1 <= op1;
load <= '1';
res_sel <= GET;
-- 1-bit left-shift with carry
when "00000001" =>
inp1 <= op1;
shl <= '1';
res_sel <= SH1_L;
when others =>
-- Leave default values
end case;
end process;
sel_out: process (res_sel, inp1, tx)
begin
case res_sel is
when SH1_L =>
res <= (inp1(30 downto 0) & '0') or tx;
when others =>
res <= (others => '0');
end case;
end process;
sync: process(clk)
begin
if clk'event and clk = '1' then
if load = '1' then
tx <= op1;
elsif shl = '1' then
tx <= Z(30 downto 0) & op1(31);
end if;
end if;
end process;
end rtl;
TESTPROGRAM
GET 0 (this sets tx <= 0)
SH1_L 0xfedcba90 exp. output: 0xfdb97520 act. output = 0xfdb97521
SH1_L 0x7654321f exp. output: 0xeca8643f act. output = 0xeca8643f
SH1_L 0x71234567 exp. output: 0xe2468ace act. output = 0xe2468ace
正如你所看到的,第一个SH1_L操作的最后一位是错误的。由于 MSB被设置为其中一个输入,所以第一个SH1_L操作为NEXT SH1_L操作产生一个进位,但是,似乎这个进位在当前SH1_L操作中已经被考虑,这是错误的(tx应该为零)。 我检查了综合报告,并没有锁存器,所以我有点无知,几乎绝望,这里出了什么问题。我使用Xilinx ISE 12.1进行 综合,可能会出现问题,因为我的体系结构中没有重置信号,实例化了错误种类的锁存器?
进一步有益的意见非常感谢来解决这个问题, 帕特里克
我不得不承认我不知道如何检查。我只是检查了在合成过程中没有出现锁存器和其他警告。此外,该设计不违反关键路径。我可以重新设计我的模块以避免这种竞争状况吗?非常感谢 – Patrick 2011-02-27 23:46:30
我不是在谈论设计,而是在硬件上如何将输入信号/时钟应用于实践,即输入信号不应该接近上升时钟边缘。 – 2011-02-28 08:39:48