すべてのご意見のおかげで、私はあなたの提案を実装しましたが、問題は同じままです. シミュレーションの結果は正常に動作しますが、ハードウェアは異なるものを出力します。簡単に要約すると、エンティティの動作を決定する 2 つの ctrl シグナルがあります。
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;
テストプログラム
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 操作の最後のビットが間違っています。最初の SH1_L 操作は、MSB が入力の 1 つに設定されているため、次の SH1_L 操作のキャリーを生成しますが、このキャリーは現在の SH1_L 操作で既に考慮されているようで、これは間違っています (tx はゼロである必要があります)。合成レポートを確認したところ、ラッチがないため、何が問題なのか少しわかりません。合成に Xilinx ISE 12.1 を使用していますが、アーキテクチャにリセット信号がないため、間違った種類のラッチがインスタンシエートされるという問題はありますか?
この問題を解決するための有益なコメントをありがとう、Patrick