0
\$\begingroup\$
entity hex_kp is
    Port (
      coloumn : in  STD_LOGIC_VECTOR (3 downto 0);
      sevenseg : out  STD_LOGIC_VECTOR (7 downto 0);
      ca : out  STD_LOGIC_VECTOR (3 downto 0)
    );
end hex_kp;

architecture Behavioral of hex_kp is
  signal row: std_logic_vector(3 downto 0);

  process(row, column)
  begin
    ca <="0111";
    if(row = "0111") then
      case coloumn is
        when "0111" =>
          sevenseg <= "00000110";
        when "1011" =>
          sevenseg <= "01011011";
        when "1101" =>
          sevenseg <= "01001111";
        when "1110" =>
          sevenseg <= "01110001";
        when others =>
          sevenseg <= (others => '0');
      end case;
    end if;

This is one part of my VHDL code to interface keypad with Basys2. However it gives error to process(row, coloumn) part. When I exclude it it gives error to if (row = "0111") part. First I wrote row as an output but then I changed it to signal. Same errors occur in the situation row as an output. I can't see my mistake. Can anyone help?

\$\endgroup\$
9
  • 1
    \$\begingroup\$ You just asked the same question on StackOverflow. stackoverflow.com/questions/33597145/…. It would be better to edit that one rather than start a new one. And you still haven't told us what the error message says : that's quite important. It might be as simple as a spelling error. \$\endgroup\$
    – user16324
    Commented Nov 8, 2015 at 18:48
  • \$\begingroup\$ this is the error message : Line 17. parse error, unexpected PROCESS \$\endgroup\$
    – Ayca Ekin
    Commented Nov 8, 2015 at 18:57
  • \$\begingroup\$ I typically code in verilog, so, take this as you will. Don't you need a "begin" before process and "end process" at the bottom? \$\endgroup\$
    – johnnymopo
    Commented Nov 8, 2015 at 19:00
  • \$\begingroup\$ I meant to say "end behaviorsl" \$\endgroup\$
    – johnnymopo
    Commented Nov 8, 2015 at 19:00
  • \$\begingroup\$ Again, very basic stuff. No evidence of any research effort. Read how an architecture is laid out. \$\endgroup\$
    – user16324
    Commented Nov 8, 2015 at 19:02

1 Answer 1

1
\$\begingroup\$

Assuming `row is an input:

library ieee;
use ieee.std_logic_1164.all;

entity hex_kp is
    port ( 
        row:        in  std_logic_vector (3 downto 0);
        coloumn:    in  std_logic_vector (3 downto 0);  -- 'column 'is mispelled
        sevenseg:   out std_logic_vector (7 downto 0);  -- why is 7 segs 8 long?
        ca :        out std_logic_vector (3 downto 0)
    );
end entity hex_kp;

architecture behavioral of hex_kp is
    -- signal row: std_logic_vector(3 downto 0);  -- who drive row?
begin  -- this was missing
UNLABELLED:
    process(row, coloumn)  -- was 'column' (didn't match declaration)
    begin
        ca <="0111";
        if row = "0111" then
            case coloumn is
                when "0111" =>
                    sevenseg <= "00000110"; 
                when "1011" => 
                    sevenseg <= "01011011";  
                when "1101" =>
                    sevenseg <= "01001111";
                when "1110" =>
                 sevenseg <= "01110001";
                when others =>
                    sevenseg <= (others => '0');
            end case;
        end if;
    end process;
end architecture behavioral;

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity hex_kp_tb is
end entity;

architecture foo of hex_kp_tb is
    signal row:         std_logic_vector (3 downto 0);
    signal coloumn:     std_logic_vector (3 downto 0);
    signal sevenseg:    std_logic_vector (7 downto 0);
    signal ca:          std_logic_vector (3 downto 0);
    signal count:       unsigned (7 downto 0) := (others => '0');
begin

DUT: 
    entity work.hex_kp
        port map (
            row => row,
            coloumn => coloumn,
            sevenseg => sevenseg,
            ca => ca
        );
STIMULUS:
    process
    begin
        row <= std_logic_vector (count(3 downto 0));
        coloumn <= std_logic_vector (count(7 downto 4));
        wait for 100 ns;
        count <= count + 1;
        if count = "11111111" then
            wait;
        end if;
    end process;
end architecture;

You were missing the begin for the architecture body. You also mispelled column, while spelling it correctly one place.

Your modified code analyzes, elaborates and the added testbench simulates:

hex_kp_tb

Note that not having an else for the if statement based on a particular value of row causes latches preserving the value of sevenseg for other values of row.

This isn't particularly robust, `row = "0111" is a combinatoric evaluation that can cause glitches. You could consider using the result of the equality comparison as an enable to something with a clock.

You could also get rid of the latches by using an else for the if statement assigning sevenseg to some value.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.