EmbDev.net

Forum: FPGA, VHDL & Verilog help error 10822 vhdl


von daniel (Guest)


Rate this post
useful
not useful
i will be thankful if somebody will can help me..
my aim is to make a block that get 3 inputs:
a clc that change every 0.1 sec
a input that get '1' every time i press key0
and reset button that reset my count

the aim is to count the number of time i press and when there is 3 secs 
that i dont press i get the count of the time i pressed
i tried to it with this code"
1
library ieee;
2
use ieee.std_logic_1164.all;
3
use ieee.std_logic_unsigned.all;
4
use ieee.std_logic_arith.all;
5
6
entity CLAPNUM is 
7
   port( 
8
    resetN, clk : in std_logic;
9
    key0         : in std_logic   ;
10
    sinus      : out  std_logic_vector(4 downto 0));
11
end CLAPNUM ; 
12
architecture arc_CLAPNUM of CLAPNUM is 
13
14
signal countera : std_logic_vector(4 downto 0) :="00000"  ;
15
signal counterb : std_logic_vector(4 downto 0) :="00000" ;
16
signal cinout   : std_logic := '0' ;
17
signal moda   : std_logic := '0' ;
18
19
begin 
20
   
21
process ( resetN key0, clk)
22
  begin
23
    if resetN = '0' then
24
    countera<="00000" ;
25
    counterb<="11110";
26
  elsif (key0 ='1') and moda='0' then
27
    countera<= countera+"00001" ;
28
    counterb<="11110";
29
  elsif (rising_edge(clk))  then
30
    if counterb/="00000" and (key0 ='0') then
31
      counterb <= counterb-"00001";
32
    else      
33
      moda <= '1';
34
    end if;
35
  elsif moda='1' then
36
  sinus<= countera;
37
  end if;
38
   end process;
39
40
end arc_CLAPNUM;

but clearly it dosent work...
can someone help me plz?

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


Attached files:

Rate this post
useful
not useful
First have a look at the attached sreenshot...

> but clearly it dosent work...
And HOW did you see that?
Did you do a SIMULATION?
What ERROR messages or WARNINGS did you get?
And why do you ignore them all?

In fact the problem here is the well known and famous "combinatorial 
loop":
as long as key0 is 1 and moda is 0 the countera is counting upwards 
without any clock at maximum and random speed:
1
  elsif (key0 ='1') and moda='0' then
2
    countera<= countera+"00001" ;
Try Google translator on that:
http://www.lothar-miller.de/s9y/archives/42-Kombinatorische-Schleifen.html

Let me ask you: where did you see this structure in literature?
1
begin process ( resetN key0, clk)
2
begin
3
if resetN = '0' then
4
  ...
5
elsif (key0 ='1') and moda='0' then
6
  ...
7
elsif (rising_edge(clk)) then
8
  ...
9
end if;
There's only one way to desrcibe a synchronous process:
1
begin process ( resetN, clk)
2
begin
3
if resetN = '0' then
4
  ...
5
elsif (rising_edge(clk)) then
6
  ...
7
end if;

Beside the whole things above: the sensitivity list is incomplete, moda 
ist missing. Therefore a simulation will show wrong results...

BTW: congratulations to use the 1-process-FSM. You are a big step 
further than in the thread https://embdev.net/topic/386779

: Edited by Moderator
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.