emmagood
Member level 4
- Joined
- Feb 13, 2010
- Messages
- 74
- Helped
- 3
- Reputation
- 6
- Reaction score
- 1
- Trophy points
- 1,288
- Activity points
- 1,849
Using google turns up many
What specific problems are you having? why not post the code that doesnt work?
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity hex_kp is
Port ( clk : in STD_LOGIC;
row : out STD_LOGIC_VECTOR (3 downto 0);
coloumn : in STD_LOGIC_VECTOR (3 downto 0);
sevenseg : out STD_LOGIC_VECTOR (7 downto 0);
ca : out STD_LOGIC);
end hex_kp;
architecture Behavioral of hex_kp is
begin
process(clk)
begin
ca <='1'; -- to enable a seven segment element
if(clk'event and clk = '1') then
row <= "0111";
if(coloumn = "0111") then sevenseg <= "00000110" after 10ms;
elsif (coloumn = "1011") then sevenseg <= "01011011" after 10ms;
elsif (coloumn = "1101") then sevenseg <= "01001111" after 10ms;
elsif (coloumn = "1110") then sevenseg <= "01110001" after 10ms;
end if;
row <= "1011";
if(coloumn = "0111") then sevenseg <= "01100110" after 10ms;
elsif (coloumn = "1011") then sevenseg <= "01101101" after 10ms;
elsif (coloumn = "1101") then sevenseg <= "01111101" after 10ms;
elsif (coloumn = "1110") then sevenseg <= "01111001" after 10ms;
end if;
row <= "1101";
if(coloumn = "0111") then sevenseg <= "00000111" after 10ms;
elsif (coloumn = "1011") then sevenseg <= "01111111" after 10ms;
elsif (coloumn = "1101") then sevenseg <= "01101111" after 10ms;
elsif (coloumn = "1110") then sevenseg <= "01011110" after 10ms;
end if;
row <= "1110";
if(coloumn = "0111") then sevenseg <= "00111111" after 10ms;
elsif (coloumn = "1011") then sevenseg <= "01110111" after 10ms;
elsif (coloumn = "1101") then sevenseg <= "01111101" after 10ms;
elsif (coloumn = "1110") then sevenseg <= "01011110" after 10ms;
end if;
end if;
end process;
end Behavioral;
If the simulation says there are delays that is because you are writing nonsensical code with after 10ms, which won't synthesize to anything 0ns, 100ms, 1000000000s, etc are all the same to synthesis (i.e. nothing).
If you need to delay for some length of time you have to count clock cycles (i.e. you need to add a counter and use the counter to decide when you output new values of row).
I'm also not sure what you've done to deal with switch bounce as it's not readily apparent from this code.
I actually tried a quick search and can't seem to find a nice concise table of synthesizable statements in VHDL. I learned, which were and weren't by reading a number of VHDL books and looking at others code.Thanks for the reply. I did not know that "after <time duration>" is not synthesizable (I am still learning VHDL). Is there any list of VHDL language constructs which are synthesizable. If so, do point me to the same.
Debouncing a switch is just sampling the input at long enough intervals, that you know it's at a stable value before forwarding it. If you don't do this you may misinterpret a single switch for multiple switches as the contacts of the switch "bounce". Here is a debounce circuit I ran across, it's very similar to the one I designed and use.Also, for counting clock cycles, how to decide the length of internal counter. There are programs on the internet which initalises a temp signal array of lenght 0-29 and consider 10 to 8 bits of it for counting. Is that related to avoid effects due to switch bouncing. I could not understand this and hence avoided it in the code.
I only just glanced at the code.OK... and how to decide the length of the internal counter...? Also, did you find the code in the previous **broken link removed**OK.
Thanks,
Emma
Huh? All you have to do is hold a 4-bit value on your column input and as the rows get scanned the "key" will be detected while the row is selected. I'm not sure why this is a problem.No... I dont know how to simulate the code.... I can give the coloumn line inputs but how do I give the mechanical switch input which will short the row and coloumn lines ...Then only I can see the output of the row line vector and thereby decide if the vector for seven segment is getting the right value..
Ignore the definition of 29:0 it should have been defined as 10:0.Also any reason for taking temp vector to be 29 downto 0 and then considering 10 downto 8 instead of simply taking it to be 7 downto 0..?
Huh? All you have to do is hold a 4-bit value on your column input and as the rows get scanned the "key" will be detected while the row is selected. I'm not sure why this is a problem.
col_cnt <= col_cnt + 1;
column <= col_cnt(14 downto 11);
signal column : std_logic_vector(3 downto 0) := "1110";
column <= column(2 downto 0) & column(3);
I am only using waveform test bench in Xilinx ISE....
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?