Hello
I'm currently working on my assignment in Spartan-3E.My assignment is:
While button is clicked show values of switches in low 4 bit of LED,when
button is released move from left to right.Switching speed 2Hz.
But i haven't got any success so far.It not even showing values of
switch.
And here is my code:
1 | library IEEE;
|
2 |
|
3 | use IEEE.STD_LOGIC_1164.ALL;
|
4 | use ieee.std_logic_unsigned.all;
|
5 | use ieee.std_logic_arith.all;
|
6 |
|
7 |
|
8 | entity daalgavar_13 is
|
9 | Port ( clk : in STD_LOGIC;
|
10 | led : out STD_LOGIC_VECTOR (7 downto 0);
|
11 | button : in std_logic;
|
12 | switch : in STD_LOGIC_VECTOR (3 downto 0));
|
13 | end daalgavar_13;
|
14 |
|
15 | architecture Behavioral of daalgavar_13 is
|
16 |
|
17 | signal clk_2G: std_logic;
|
18 |
|
19 | signal tooluur: integer range 0 to 25000000;
|
20 | signal data : STD_LOGIC_VECTOR (7 downto 0);
|
21 | begin
|
22 |
|
23 | --led<=data;
|
24 |
|
25 | process(clk_2G) --, switch)
|
26 | variable temp:std_logic_vector(7 downto 0);
|
27 | begin
|
28 | --if (rst = '0') then
|
29 | if clk_2G'event and clk_2G='1' then
|
30 | if button='1' then
|
31 | data <="0000" & switch(3 downto 0);
|
32 | else
|
33 | temp := data;
|
34 | data <= temp (6 downto 0)& temp(7) ;
|
35 | end if;
|
36 | end if;
|
37 | end process;
|
38 |
|
39 | led<=data;
|
40 |
|
41 | process(clk)
|
42 | begin
|
43 | if clk'event and clk='1' then
|
44 | if tooluur=25000000 then --2Hz
|
45 | tooluur<=0;
|
46 | clk_2G<='1';
|
47 | else
|
48 | tooluur<=tooluur+1;
|
49 | clk_2G<='0';
|
50 | end if;
|
51 | end if;
|
52 | end process;
|
53 | end Behavioral;
|
Thank you