私は初めてのユーザーですので、ご容赦ください。
割り当てのために作成しなければならない単純なゲームの一部には、疑似乱数ジェネレーターを 8 ビット LFSR の形式で作成することが含まれます。ザイリンクス ISE を使用してコードを記述しています。ノートとサンプル コードは次のとおりです。
http://www.oocities.org/siliconvalley/screen/2257/vhdl/lfsr/lfsr.html
コードは合成されますが、センシティビティ リストに関する警告が表示されます。ただし、テスト ベンチを実行すると、pseudo_rand のすべての U 値が取得されます。この乱数ジェネレーターは内部にあるため、出力はありませんが、pseudo_rand をシグナルとしてコードを記述すると (そのバリアントは現在コメント アウトされています)、シミュレーションに表示されません。
以下は、対応するテスト ベンチのコードが続く LFSR のコードです。
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity LFSR_3_16_2013 is
port( clk: in std_logic;
rst: in std_logic;
pseu_rand: out std_logic_vector(7 downto 0));
end LFSR_3_16_2013;
architecture Behavioral of LFSR_3_16_2013 is
--signal clk: std_logic;
--signal rst: std_logic;
signal seed: std_logic_vector(7 downto 0):= "10000000";
signal biffer: std_logic_vector(7 downto 0);
--signal pseu_rand: std_logic_vector(7 downto 0);
begin
lfsr : PROCESS(clk,rst)
begin
if(rst='0') then
--pseu_rand <= seed;
biffer <= seed;
pseu_rand <= biffer;
elsif (clk'event and clk='1') then
--pseu_rand(0) <= pseu_rand(7) xor pseu_rand(6);
--pseu_rand(7 downto 1) <= pseu_rand(6 downto 0);
biffer(0) <= biffer(7) xor biffer(6);
biffer(7 downto 1) <= biffer(6 downto 0);
pseu_rand <= biffer;
end if;
end process lfsr;
end Behavioral;
そして今、テストベンチ:
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY LFSR_tb_3_16_2013 IS
END LFSR_tb_3_16_2013;
ARCHITECTURE behavior OF LFSR_tb_3_16_2013 IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT LFSR_3_16_2013
PORT(
clk : IN std_logic;
rst : IN std_logic;
pseu_rand : OUT std_logic_vector(7 downto 0)
);
END COMPONENT;
--Inputs
signal clk : std_logic := '0';
signal rst : std_logic := '0';
--Outputs
signal pseu_rand : std_logic_vector(7 downto 0);
-- Clock period definitions
constant clk_period : time := 10 ns;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: LFSR_3_16_2013 PORT MAP (
clk => clk,
rst => rst,
pseu_rand => pseu_rand
);
-- Clock process definitions
clk_process :process
begin
clk <= '0';
wait for clk_period/2;
clk <= '1';
wait for clk_period/2;
end process;
-- Stimulus process
stim_proc: process
begin
-- hold reset state for 100 ns.
wait for 100 ns;
wait for clk_period*10;
-- insert stimulus here
rst <= '1';
wait;
end process;
END;
どんな助けでも大歓迎です、私はかなり困惑しています。
ありがとう、ユシフ・ヌリザード