您的个人资料显示您没有使用Tour(可在帮助下找到)。 The Tour 建议在提问前先搜索网站。在这种情况下搜索没有找到一个已回答的问题 ERROR:HDLParsers:164 还提到了预期的分号。
在 VHDL 中,分号是语句和声明的分隔符。使用非常基础,除了解决如何解析 VHDL 语法的扩展 BNF 之外,您在 LRM 的其他任何地方都找不到要求。
你错过了很多分号可能意味着在你被介绍到 VHDL 的地方没有提到分隔符的使用。
示例代码中的错误
除了 5 个缺失的分号外,没有可见的“+”运算符(ff 不是无符号或有符号值 - 使用包 numeric_std_unsigned 而不是 numeric_std 或使用类型转换)。
对 max_plus 选项的赋值不是 std_logic_vector 的子类型 max_plus 值的表达式(“111111111111”和“00000000000000”而不是“1”和 0)。
有一个错误的(额外的)结束语句(也没有分号)。
第一个错误显示在示例的第 26 行,没有第 39 行。您可以指出位置。
architecture behavioral of bin_count is
signal ff, ff_next, max_pulse:
std_logic_vector(11 downto 0); -- missing semicolon
begin
process(clk, reset)
begin
if reset = '1' then
ff <= "000000000000"; -- missing semicolon
elsif rising_edge(clk) then
ff <= ff_next; -- missing semicolon
end if; -- missing semicolon
end process;
-- ff_next <= ff + 1; -- no visible operator "+"
ff_next <= std_logic_vector(unsigned(ff) + 1); -- type converts ff to unsigned
-- and the result back
-- or in the context clause use numeric_std_unsigned:
-- use ieee.numeric_std_unsigned.all; -- makes "+" visible
-- instead of numeric_std;
--
-- and here:
-- ff_next <= ff + 1;
-- abstract literal 0 and enumeration literal '1' are not values
-- of std_logic_vector:
-- max_pulse <= '1' when ff = "111111111111" else
-- '0';
-- use string literal instead:
max_pulse <= "111111111111" when ff = "111111111111" else
"000000000000";
-- (and there are other expressions available)
seq <= ff; -- missing semicolon
-- end -- errant end statement - this doesn't match anything.
end behavioral;
通过上述更改,您的代码将进行分析。还可以进行一些其他更改。
max_pulse 不需要是 std_logic_vector,它可以是 std_logic。 (这将允许使用 '1' 和 '0' 作为条件赋值语句中分配的值。
不需要ff_next。
这些给我们一个稍微不同的架构:
architecture foo of bin_count is
signal ff: std_logic_vector(11 downto 0);
signal max_pulse: std_logic;
begin
process(clk, reset)
begin
if reset = '1' then
ff <= (others => '0'); -- an aggregate
elsif rising_edge(clk) then
ff <= std_logic_vector(unsigned(ff) + 1);
end if;
end process;
max_pulse <= '1' when ff = "111111111111" else
'0';
seq <= ff;
end architecture;
使用测试平台:
library ieee;
use ieee.std_logic_1164.all;
entity bin_count_tb is
end entity;
architecture fum of bin_count_tb is
signal clk: std_logic := '0'; -- default value
signal reset: std_logic;
signal seq: std_logic_vector (11 downto 0);
begin
CLOCK:
process
begin
wait for 5 ns; -- half the clock period
clk <= not clk;
if now > 85000 ns then -- now returns simulation time
wait;
end if;
end process;
DUT:
entity work.bin_count
port map (
clk => clk,
reset => reset,
seq => seq
);
STIMULUS:
process
begin
reset <= '1';
wait for 11 ns;
reset <= '0';
wait;
end process;
end architecture;
我们可以看到重置:
(可点击)
我们可以看到max_pulse周期性出现:
(可点击)
当seq = "111111111111"时我们可以看到max_pulse occurs:
(可点击)