0

There is syntax error that I cannot understand.

process(clk) on line 166 of the code the error showing up is Error: Syntax error near 'process' , i'm pretty sure i've checked the code before this line, no matter what i put inside the brackets i get an error, i have also tried to put in an extra begin statement before the process(clk) and then the error moves to the begin statement.

Any help is appreciated. Thanks a lot.

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;
Mikef
  • 1,572
  • 2
  • 10
  • 21
  • There's a thinko in the length of ss_segments when segments a - g and ss_dp are 8 elements trying to go into something with a length of 7. Similarly display_value has a length of 8 and the string literals being assigned have a length of 7, which will cause an error during simulation (or during synthesis). – user16145658 Mar 13 '23 at 07:41

1 Answers1

2

The last process is not enclosed in an architecture.
Move the

end Behavioral;

line so that its after the end of the last process.

--- code that came before ---
            -- 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;
    
  end Behavioral;
Mikef
  • 1,572
  • 2
  • 10
  • 21