Vhdl 意外的TOKBEGIN,应为AFFECT或分号

Vhdl 意外的TOKBEGIN,应为AFFECT或分号,vhdl,counter,Vhdl,Counter,我是vhdl新手,我已经为12位二进制计数器编写了代码,我收到了这个错误(意外的tokbeagin,预期影响或分号)。请指导我解决此错误 library IEEE; use IEEE.STD_LOGIC_1164.ALL; -- Uncomment the following library declaration if using -- arithmetic functions with Signed or Unsigned values use IEEE.NUMERIC_STD.ALL;

我是vhdl新手,我已经为12位二进制计数器编写了代码,我收到了这个错误(意外的tokbeagin,预期影响或分号)。请指导我解决此错误

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
use IEEE.NUMERIC_STD.ALL;

-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;

entity bin_count is
Port ( clk : in  STD_LOGIC;
       reset : in  STD_LOGIC;
       seq : out  STD_LOGIC_VECTOR (11 downto 0));
end bin_count;

architecture Behavioral of bin_count is
signal  ff, ff_next, max_pulse : std_logic_vector(11 downto 0)
begin
process(clk,reset)
begin
if(reset = '1') then
ff <= "000000000000"
elsif( rising_edge(clk)) then
ff <= ff_next
end if
end process;
ff_next <= ff + 1;
max_pulse <= '1' when ff = "111111111111" else
0;
seq<= ff
end

end Behavioral;

您的个人资料显示您尚未接受(在“帮助”下找到)。旅游团建议在提问之前先搜索网站。本例中的搜索没有找到一个错误的答案:HDLParsers:164还提到了一个预期的分号

在VHDL中,分号是语句和声明的分隔符。这种用法非常基本,除了扩展的BNF(它解决了如何解析VHDL语法)之外,在LRM的任何地方都找不到显示的需求

您遗漏了很多分号,这可能意味着在介绍VHDL的地方没有提到分隔符的使用

示例代码中的错误
除了5个缺少的分号外,没有可见的“+”运算符(ff不是无符号或有符号的值-请使用包numeric_std_unsigned,而不是numeric_std或使用类型转换)

max_plus选项的赋值不是std_logic_vector子类型max_plus值的表达式(“111111111”和“0000000000000”而不是“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;
使用测试台:

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;
ieee库;
使用ieee.std_logic_1164.all;
实体bin\u计数\u tb为
终端实体;
bin_count_tb的架构fum是
信号时钟:标准逻辑:='0';--默认值
信号复位:标准逻辑;
信号顺序:标准逻辑向量(11向下至0);
开始
时钟:
过程
开始
等待5秒;——时钟周期的一半
clk 85000 ns然后--现在返回模拟时间
等待
如果结束;
结束过程;
DUT:
实体work.bin\u计数
港口地图(
时钟=>clk,
重置=>重置,
seq=>seq
);
刺激:
过程
开始

重置该代码中有许多缺少的分号,正如错误消息所说的那样。
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;