我有这个代码我想做一个LSFR,但我有几个问题,包括:
错误:HDLParsers:3010 - “C:/Users/user/Documents/tp_vhdl/median_LSFR/LSFR.vhd”第18行。实体LFSR不存在。
错误:HDLParsers:3312 - “C:/Users/user/Documents/tp_vhdl/median_LSFR/LSFR.vhd”第19行。未定义的符号'std_logic_vector'。
错误:HDLParsers:1209 - “C:/Users/user/Documents/tp_vhdl/median_LSFR/LSFR.vhd”第19行.std_logic_vector:未定义的符号(此块中的最后一个报告)
错误:HDLParsers:3312 - “C:/Users/user/Documents/tp_vhdl/median_LSFR/LSFR.vhd”第20行。未定义的符号'std_logic'。
错误:HDLParsers:1209 - “C:/Users/user/Documents/tp_vhdl/median_LSFR/LSFR.vhd”第20行.std_logic:未定义的符号(此块中的上一个报告)
错误:HDLParsers:3312 - “C:/Users/user/Documents/tp_vhdl/median_LSFR/LSFR.vhd”第24行。未定义的符号's_xor1'。
代码:
library ieee;
use ieee.std_logic_1164.all;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity LSFR is port (
clk : in std_logic;
reset,en : in std_logic;
de1,de2 : out std_logic_vector(2 downto 0)
);
end LSFR;
architecture arch of LFSR is
signal etatpresent, etatfutur : std_logic_vector(16 downto 1);
signal s_xor1, s_xor2, s_xor3 : std_logic;
begin
-- Calcul intermediaire des ou exclusifs
s_xor1 <= etatpresent(15) xor etatpresent(1);
s_xor2 <= etatpresent(14) xor etatpresent(1);
s_xor3 <= etatpresent(12) xor etatpresent(1);
-- Calcul de l'état futur en fonction de l'état présent et des ou exclusifs
process(etatpresent) begin
etatfutur(16) <= etatpresent(1);
etatfutur(1) <= etatpresent(2);
etatfutur (2) <= etatpresent(3);
etatfutur (3) <= etatpresent(4);
etatfutur (4) <= etatpresent(5);
etatfutur (5) <= etatpresent(6);
etatfutur (6) <= etatpresent(7);
etatfutur (7) <= etatpresent(8);
etatfutur (8) <= etatpresent(9);
etatfutur (9) <= etatpresent(10);
etatfutur (10) <= etatpresent(11);
etatfutur (11) <= s_xor3;
s_xor3 <= etatpresent(12);
etatfutur (12) <= etatpresent(13);
etatfutur (13) <= s_xor2;
s_xor2 <= etatpresent(14);
etatfutur (14) <= s_xor1;
s_xor1 <= etatpresent(15);
etatfutur (15) <= etatpresent(16);
end process;
process(reset) begin
if (reset = '1' ) then
etatfutur <="0000000000000001";
end if ;
end process;
-- cablage des deux sorties
de1(2 downto 0) <= etatpresent(16 downto 14);
de2 (2 downto 0) <= etatpresent(3 downto 1);
end arch;
答案 0 :(得分:2)
虽然您没有识别行号并且它们与第一个错误不匹配,但LFSR并不是Martin Zobel指出的架构拱的声明实体。它似乎是实体声明中的拼写错误的实体名称及其结束语句。
不依靠互联网搜索来识别产生错误消息的VHDL工具,它并不符合标准,Maria可能会在评论中发现错误消息来源。
通常,上下文子句中的重复库名称将被忽略,同一内部声明区域中的use子句中的复制声明也将被忽略。
理顺实体名称和上下文子句(通过删除多余的元素):
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity LFSR is -- was LSFR is port (
port (
clk: in std_logic;
reset, en: in std_logic;
de1, de2: out std_logic_vector(2 downto 0)
);
end entity LFSR; -- was end LSFR;
architecture arch of LFSR is -- Line 16, LFSR doesn't match LSFR
signal etatpresent, etatfutur: std_logic_vector(16 downto 1);
signal s_xor1, s_xor2, s_xor3: std_logic;
begin
-- Calcul intermediaire des ou exclusifs
s_xor1 <= etatpresent(15) xor etatpresent(1);
s_xor2 <= etatpresent(14) xor etatpresent(1);
s_xor3 <= etatpresent(12) xor etatpresent(1);
-- Calcul de l'état futur en fonction de l'état présent et des ou exclusifs
process (etatpresent)
begin
etatfutur(16) <= etatpresent(1);
etatfutur(1) <= etatpresent(2);
etatfutur (2) <= etatpresent(3);
etatfutur (3) <= etatpresent(4);
etatfutur (4) <= etatpresent(5);
etatfutur (5) <= etatpresent(6);
etatfutur (6) <= etatpresent(7);
etatfutur (7) <= etatpresent(8);
etatfutur (8) <= etatpresent(9);
etatfutur (9) <= etatpresent(10);
etatfutur (10) <= etatpresent(11);
etatfutur (11) <= s_xor3;
s_xor3 <= etatpresent(12);
etatfutur (12) <= etatpresent(13);
etatfutur (13) <= s_xor2;
s_xor2 <= etatpresent(14);
etatfutur (14) <= s_xor1;
s_xor1 <= etatpresent(15);
etatfutur (15) <= etatpresent(16);
end process;
process (reset, clk) -- added clock to sensitivity list
begin
if reset = '1' then
etatpresent <= "0000000000000001"; -- was etatfutur
elsif rising_edge(clk) and en = '1' then
etatpresent <= etatfutur;
end if;
end process;
-- cablage des deux sorties
de1(2 downto 0) <= etatpresent(16 downto 14);
de2 (2 downto 0) <= etatpresent(3 downto 1);
end architecture arch;
给我们一些分析的东西。注意我还将clk添加到过程灵敏度列表中,更正了重置并添加了etatpresent寄存器。
它有效吗?我们可以通过创建一个小型测试平台并模拟:
library ieee;
use ieee.std_logic_1164.all;
entity lfsr_tb is
end entity;
architecture fum of lfsr_tb is
signal clk: std_logic := '0';
signal reset: std_logic;
signal en: std_logic;
signal de1: std_logic_vector (2 downto 0);
signal de2: std_logic_vector (2 downto 0);
begin
DUT:
entity work.lfsr
port map (
clk => clk,
reset => reset,
en => en,
de1 => de1,
de2 => de2
);
CLOCK:
process
begin
wait for 10 ns;
clk <= not clk;
if now > 450 ns then
wait;
end if;
end process;
STIMULI:
process
begin
wait for 11 ns;
reset <= '1';
en <= '0';
wait for 20 ns;
reset <= '0';
wait for 20 ns;
en <= '1';
wait for 100 ns;
en <= '0';
wait for 40 ns;
en <= '1';
wait;
end process;
end architecture;
模拟这会给我们一些看起来并不好的东西:
那发生了什么?
仔细观察lfsr拱形中未标记的第一个进程,可以看出s_xor1,s_xor_2和s_xor3有重复的驱动程序,以及灵敏度列表中缺少的三个驱动程序(它们显示在右侧的表达式中)分配)。
如果没有引用您正在实施的LFSR算法,我们可以简单地添加缺少的敏感性列表项,并注释掉驱动程序:
-- Calcul de l'état futur en fonction de l'état présent et des ou exclusifs
process (etatpresent, s_xor1, s_xor2, s_xor3)
begin
etatfutur(16) <= etatpresent(1);
etatfutur(1) <= etatpresent(2);
etatfutur (2) <= etatpresent(3);
etatfutur (3) <= etatpresent(4);
etatfutur (4) <= etatpresent(5);
etatfutur (5) <= etatpresent(6);
etatfutur (6) <= etatpresent(7);
etatfutur (7) <= etatpresent(8);
etatfutur (8) <= etatpresent(9);
etatfutur (9) <= etatpresent(10);
etatfutur (10) <= etatpresent(11);
etatfutur (11) <= s_xor3;
-- s_xor3 <= etatpresent(12);
etatfutur (12) <= etatpresent(13);
etatfutur (13) <= s_xor2;
-- s_xor2 <= etatpresent(14);
etatfutur (14) <= s_xor1;
-- s_xor1 <= etatpresent(15);
etatfutur (15) <= etatpresent(16);
end process;
这给了我们一个无错误的波形:
您需要根据算法规范验证LFSR操作。
注意两个时钟工作无效。
答案 1 :(得分:1)
您在实体中拼写错误的LFSR。 (&#34; LSFR&#34)