我对 VHDL 代码还很陌生,我们得到了一个在大学内完成的项目。这是我到目前为止的代码,似乎有一个我无法理解的语法错误。
process(clk) on the line 166 of the code the error showing is Error: Syntax error near 'process' ,我很确定我已经检查了这一行之前的代码,不管我把什么放在括号里我得到一个错误,我还尝试在 process(clk) 之前添加一个额外的 begin 语句,然后错误移动到 begin 语句。
任何帮助表示赞赏。非常感谢。
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity ss_driver is
port (
-- Inputs
segment_a : in std_logic;
segment_b : in std_logic;
segment_c : in std_logic;
segment_d : in std_logic;
segment_e : in std_logic;
segment_f : in std_logic;
segment_g : in std_logic;
ss_dp : in std_logic; -- optional decimal point input
-- Outputs
ss_segments : out std_logic_vector(6 downto 0)
);
end ss_driver;
architecture Behavioral of ss_driver is
begin
-- Define the 7-segment display driver logic here
ss_segments <= not (segment_a & segment_b & segment_c & segment_d & segment_e & segment_f & segment_g);
-- Connect the decimal point segment to the ss_dp input
ss_segments(6) <= not ss_dp;
end Behavioral;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity Practice is
Port ( clk : in STD_LOGIC;
unhappy_btn : in STD_LOGIC;
neutral_btn : in STD_LOGIC;
pleased_btn : in STD_LOGIC;
delighted_btn : in STD_LOGIC;
-- Pause & Reset Functionality
pause_reset_btn : in STD_LOGIC;
-- Defining warning light output signal
warning_light : out STD_LOGIC;
-- Defining 7-segment displays
ss_segments : out STD_LOGIC_VECTOR (6 downto 0);
display_0 : out STD_LOGIC_VECTOR(6 downto 0);
display_1 : out STD_LOGIC_VECTOR(6 downto 0);
display_2 : out STD_LOGIC_VECTOR(6 downto 0);
display_3 : out STD_LOGIC_VECTOR(6 downto 0));
end Practice;
architecture Behavioral of Practice is
-- Declare the state type and signals
type satisfaction_state is (idle, unhappy, neutral, pleased, delighted, pause, paused, reset);
signal current_state, next_state : satisfaction_state;
-- Declare the count signals
signal unhappy_count, neutral_count, pleased_count, delighted_count : integer range 0 to 9999 := 0;
signal pause_count, reset_count : integer range 0 to 9999 := 0;
-- Declare reset_pending signal
signal reset_pending : boolean := false;
-- Declare display signals
signal display_unhappy, display_neutral, display_pleased, display_delighted : STD_LOGIC_VECTOR(6 downto 0);
signal display_count : integer range 0 to 99999 :=0;
signal display_value : STD_LOGIC_VECTOR(7 downto 0);
signal segment_a, segment_b, segment_c, segment_d, segment_e, segment_f, segment_g : std_logic;
signal display_counter : integer range 0 to 3;
begin
process(clk, current_state, reset_pending)
begin
if rising_edge(clk) then
-- Set the default next state
next_state <= current_state;
case current_state is
-- Idle state
when idle =>
-- Check which button was pressed
if unhappy_btn = '1' then
next_state <= unhappy;
elsif neutral_btn = '1' then
next_state <= neutral;
elsif pleased_btn = '1' then
next_state <= pleased;
elsif delighted_btn = '1' then
next_state <= delighted;
elsif pause_reset_btn = '1' then
next_state <= pause;
end if;
-- Unhappy state
when unhappy =>
if unhappy_btn = '1' then
unhappy_count <= unhappy_count + 1;
end if;
display_unhappy <= std_logic_vector(to_unsigned(unhappy_count, 7));
next_state <= idle;
-- Neutral state
when neutral =>
if neutral_btn = '1' then
neutral_count <= neutral_count + 1;
end if;
display_neutral <= std_logic_vector(to_unsigned(neutral_count, 7));
next_state <= idle;
-- Pleased state
when pleased =>
if pleased_btn = '1' then
pleased_count <= pleased_count + 1;
end if;
display_pleased <= std_logic_vector(to_unsigned(pleased_count, 7));
next_state <= idle;
-- Delighted state
when delighted =>
if delighted_btn = '1' then
delighted_count <= delighted_count + 1;
end if;
display_delighted <= std_logic_vector(to_unsigned(delighted_count, 7));
next_state <= idle;
-- Pause state
when pause =>
reset_pending <= false;
pause_count <= 1;
next_state <= paused;
-- Paused state
when paused =>
-- Count down for 10 clock cycles
if pause_count < 10 then
pause_count <= pause_count + 1;
next_state <= paused;
-- If reset button is pressed, set reset_pending signal
elsif pause_reset_btn = '1' then
reset_pending <= true;
-- If any satisfaction button is pressed, return to pause state
elsif unhappy_btn = '1' or neutral_btn = '1' or pleased_btn = '1' or delighted_btn = '1' then
next_state <= pause;
end if;
-- Reset state
when reset =>
unhappy_count <= 0;
neutral_count <= 0;
pleased_count <= 0;
delighted_count <= 0;
display_count <= 0;
reset_count <= 0;
reset_pending <= false;
next_state <= idle;
end case;
end if;
end process;
end Behavioral;
-- Define a process for updating the 7-segment display
process(clk)
begin
if rising_edge(clk) then
case current_state is
when unhappy =>
display_count <= unhappy_count;
when neutral =>
display_count <= neutral_count;
when pleased =>
display_count <= pleased_count;
when delighted =>
display_count <= delighted_count;
when others =>
display_count <= 0;
end case;
-- Convert the count to a 7-segmentsplay value
case display_count is
when 0 =>
display_value <= "0000001"; -- 0
when 1 =>
display_value <= "1001111"; -- 1
when 2 =>
display_value <= "0010010"; -- 2
when 3 =>
display_value <= "0000110"; -- 3
when 4 =>
display_value <= "1001100"; -- 4
when 5 =>
display_value <= "0100100"; -- 5
when 6 =>
display_value <= "0100000"; -- 6
when 7 =>
display_value <= "0001111"; -- 7
when 8 =>
display_value <= "0000000"; -- 8
when 9 =>
display_value <= "0000100"; -- 9
when others =>
display_value <= "1111111"; -- Error
end case;
end if;
end process;