Hello everyone,
I'm an italian student, so I apologize for my english, and I'm new in
the forum, I have to do an exercise: the creation by MSF of a 5-bit
counter using VHDL.
I have various input signals: a STOP signal which stops the count at the
moment, a RESTART signal that resume the count, an UP_DOWN signal to
choose the direction of the count and the signal of RESET.
I have alse 3 output signals: a signal END_C which indicates the end of
the count, a signal START_C which indicates the start and a Q signal
which indicates the value of the count.
This is my VHDL code:
1 | library ieee;
|
2 | use ieee.std_logic_1164.all;
|
3 | use ieee.std_logic_unsigned.all;
|
4 |
|
5 | entity esercizio3 is
|
6 | port(CK, stop, restart, reset, up_down: in std_logic;
|
7 | end_c, start_c: out std_logic;
|
8 | Q: out std_logic_vector(4 downto 0));
|
9 | end esercizio3;
|
10 |
|
11 | architecture arc of esercizio3 is
|
12 | type stato is(ST0, ST1, ST2, ST3);
|
13 | signal ps, ns: stato;
|
14 | signal temp: std_logic_vector(4 downto 0);
|
15 | begin
|
16 | seq_proc: process(CK, RESET)
|
17 | begin
|
18 | if(RESET='0')then
|
19 | ps<=ST0;
|
20 | elsif(rising_edge(CK)) then
|
21 | ps<=ns;
|
22 | end if;
|
23 | end process seq_proc;
|
24 |
|
25 | comb_proc:process(RESTART, STOP, UP_DOWN, PS)
|
26 | begin
|
27 | end_c<='0';
|
28 | start_c<='0';
|
29 | case ps is
|
30 | when ST0=>
|
31 | temp<="00000";
|
32 | if(stop='0')then
|
33 | ns<=ST0;
|
34 | elsif(up_down='0')then
|
35 | ns<=ST1;
|
36 | else
|
37 | ns<=ST2;
|
38 | end if;
|
39 |
|
40 | when ST1=>
|
41 | temp<=temp-"00001";
|
42 | if(stop='0')then
|
43 | ns<=ST3;
|
44 | elsif(up_down='0')then
|
45 | ns<=ST1;
|
46 | else
|
47 | ns<=ST2;
|
48 | end if;
|
49 |
|
50 | when ST2=>
|
51 | temp<=temp+"00001";
|
52 | if(stop='0')then
|
53 | ns<=ST3;
|
54 | elsif(up_down<='0')then
|
55 | ns<=ST1;
|
56 | else
|
57 | ns<=ST2;
|
58 | end if;
|
59 |
|
60 | when ST3=>
|
61 | if(Restart='1')then
|
62 | ns<=ST3;
|
63 | elsif(up_down='0')then
|
64 | ns<=ST1;
|
65 | else
|
66 | ns<=ST2;
|
67 | end if;
|
68 | when others=>
|
69 | ns<=ST0;
|
70 | end case;
|
71 | Q<=temp;
|
72 | if(temp="00000")then
|
73 | start_c<='1';
|
74 | elsif(temp="11111")then
|
75 | end_c<='1';
|
76 | end if;
|
77 | end process comb_proc;
|
78 | end arc;
|
The compilation is successful but I get an error in model sim which is:
#**Error: (vsim-3601) Iteration limit reached at time 15ns.
I suppose there is a loop that does not allow proper execution.
Can you help me fix it? Thanks you.