EmbDev.net

Forum: FPGA, VHDL & Verilog Need help in code


Du wurdest von Mikrocontroller.net auf diese Seite weitergeleitet. Zurück zu Mikrocontroller.net
von Gombo K. (grizzly09)


Attached files:

Rate this post
useful
not useful
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

: Edited by Moderator
von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Rate this post
useful
not useful
Rock B. wrote:
> where did i go wrong?
First: what does the simulation say?

Second: use your clock enable as a clock enable, not as a clock:
1
process(clk) -- the one and only clock in the whole design!
2
variable temp:std_logic_vector(7 downto 0);
3
begin
4
   if clk'event and clk='1' then
5
      if clk_2G='1' then -- this is the 2Hz clock enable
6
         if button='1' then
7
            data <="0000" & switch(3 downto 0);
8
         else 
9
            ...

Third, why this:
1
   temp := data;
2
   data <= temp (6 downto 0)& temp(7) ;
And not simply this:
1
   data <= data(6 downto 0)& data(7) ;

: Edited by Moderator
von Vancouver (Guest)


Rate this post
useful
not useful
Assuming the simulation is fine:

- Are you sure that the pin mapping on your board (ucf) is correct?
- Is the clock source running and at the correct frequency as assumed by 
your clock divider?
 Can you monitor clk_2G on an LED?

von arliepitogo (Guest)


Rate this post
useful
not useful
solve the following codes using cnc

explain the defferent codes what is the function?

G17G20G90G94G54

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.