EmbDev.net

Forum: FPGA, VHDL & Verilog Not showing where is the error


von Rock B. (rocko445)


Rate this post
useful
not useful
Hello, My code is not running , it says synthesys XST failed
but it doesnt say why.
i fixed every error shown before but now its not showing whats wrong

Thanks

1
library IEEE;
2
use IEEE.STD_LOGIC_1164.ALL;
3
use IEEE.STD_LOGIC_arith.ALL;
4
use IEEE.STD_LOGIC_unsigned.ALL;
5
-- Uncomment the following library declaration if using
6
-- arithmetic functions with Signed or Unsigned values
7
--use IEEE.NUMERIC_STD.ALL;
8
9
-- Uncomment the following library declaration if instantiating
10
-- any Xilinx primitives in this code.
11
--library UNISIM;
12
--use UNISIM.VComponents.all;
13
14
entity voting_machine is
15
Port
16
   (
17
    clk: in std_logic;
18
    reset: in std_logic;
19
    party1: in std_logic;
20
    party2: in std_logic;
21
    party3: in std_logic;
22
    select_party: in std_logic;
23
    count1_op : out std_logic_vector(5 downto 0);
24
    count2_op : out std_logic_vector(5 downto 0);
25
    count3_op : out std_logic_vector(5 downto 0)
26
   );
27
    
28
end voting_machine;
29
30
architecture Behavioral of voting_machine is
31
32
signal count1,count2,count3: std_logic_vector(5 downto 0);
33
signal state: std_logic_vector(5 downto 0);
34
constant initial: std_logic_vector(5 downto 0):="000001";
35
constant check: std_logic_vector(5 downto 0):="000010";
36
constant party1_state: std_logic_vector(5 downto 0):="000100";
37
constant party2_state: std_logic_vector(5 downto 0):="001000";
38
constant party3_state: std_logic_vector(5 downto 0):="010000";
39
constant done: std_logic_vector(5 downto 0):="100000";
40
41
42
begin
43
44
process( clk, party1, party2, party3,reset)
45
46
begin
47
48
      if (reset='1') then
49
        count1<=(others=>'0');
50
       count2<=(others=>'0');
51
       count3<=(others=>'0');
52
       state<=initial;
53
       elsif (rising_edge(clk) and reset='0') then
54
      
55
       case state is
56
            
57
          when initial=>
58
          --NSL
59
            if (party1='1' or party2='1' or party3='1') then
60
                state<=check;
61
              
62
            else
63
                state<=initial;
64
          --OFL  
65
                 end if;
66
            when check =>  
67
                   --NSL
68
                      if(party1='1') then 
69
                         state<=party1_state;
70
                      elsif (party2='1') then 
71
                   state<=party2_state;
72
                elsif (party3='1') then
73
                          state<=party3_state;             
74
               else
75
                   state<=check;
76
                end if;
77
                    --OFL
78
                when party1_state =>
79
             --NSL
80
            if (select_party='1') then 
81
                 state<=done;
82
             else
83
                       state<=party1_state;
84
                
85
                end if;
86
            --OFL
87
            count1<=count1 + 1;
88
            
89
            
90
            when party2_state =>
91
             --NSL
92
            if (select_party='1') then 
93
                 state<=done;
94
             else
95
                       state<=party2_state;
96
                
97
                end if;
98
            --OFL
99
            count2<=count2 + 1;
100
            
101
            when party3_state =>
102
             --NSL
103
            if (select_party='1') then 
104
                 state<=done;
105
             else
106
                       state<=party3_state;
107
                
108
                end if;
109
            --OFL
110
            count3<=count3 + 1;
111
            
112
            when done =>
113
               --NSL
114
                 state<=initial;
115
              --OFL
116
             when others=>
117
               state<=initial;
118
        end case;
119
      end if;
120
    
121
  end process;
122
 count1_op<=count1;
123
 count2_op<=count2;
124
 count3_op<=count3;
125
            
126
end Behavioral;

von loi le (Guest)


Rate this post
useful
not useful
You are implementing the Finite State Machine and your code is not good. 
Try to separate the Next state combinational logic, Sequential logic, 
and output combinational logic. You mixed it up and it looked messed up.
Follow this FSM example in VHDL:
http://www.fpga4student.com/2017/09/vhdl-code-for-moore-fsm-sequence-detector.html
or Verilog FSM here:
http://www.fpga4student.com/2017/09/verilog-code-for-moore-fsm-sequence-detector.html

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


Rate this post
useful
not useful
loi le wrote:
> Try to separate the Next state combinational logic, Sequential logic,
> and output combinational logic. You mixed it up and it looked messed up
There are two major ways to design FSM: the One-Process style and the 
traditional Two-Process style.

Both of them have advantages and disadvantages. The best with the 
One-Process style (beside being more compact and less "chatty") is: you 
will never ever get a combinatorial loop.

But of course one should understand what he's doing. And here we have 
two design flaws. One is the sensitivity list with much much signals in 
it. clk and reset would be enough. And then the reset='0' behind the 
clk'event. Why that?

Rock B. wrote:
> XST failed. but it doesnt say why.
Absolutely no message? The one and only message is "XST failed"?
Why don't you simply copy the whole message log in the edit box here?

von Bitwurschtler (Guest)


Rate this post
useful
not useful
IMHO this is strange coding for the synthesize tool:

1
    if (reset='1') then
2
        count1<=(others=>'0');
3
       count2<=(others=>'0');
4
       count3<=(others=>'0');
5
       state<=initial;
6
     elsif (rising_edge(clk) and reset='0') then  -- combinatorik at clock tree


replace the elsif condition with
1
elsif rising_edge(clk) then
and run Synthesis again

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


Rate this post
useful
not useful
Bitwurschtler wrote:
> elsif (rising_edge(clk) and reset='0') then
Usually this shouldn't rise problems, as it's only a clock enable. But 
it's not the "normal"  way and hey, who knows?

: Edited by Moderator
von Bitwurschtler (Guest)


Rate this post
useful
not useful
Lothar M. wrote:
> Bitwurschtler wrote:
>> elsif (rising_edge(clk) and reset='0') then
> Usually this shouldn't rise problems, as it's only a clock enable. But
> it's not the "normal"  way and hey, who knows?

Well, some FPGA architectures are simply not intended for using the same 
signal as asynchronous and synchronous control Signal (here 'reset' is 
used as high active async reset and low active sync clock enable. 
Despite the Standard (xilinx) template for clock enable is
1
if reset = '1' then
2
-- ..
3
elsif rissing_edge(clk) then
4
 if  reset = '0' then
5
-- ..
6
 end if;
7
end if:

https://www.xilinx.com/support/documentation/white_papers/wp275.pdf

VHDL Syntax for Synthesis is vendor specific, so there is a "good 
chance" that
1
 
2
elsif (rising_edge(clk) and reset='0') then
 is translated into a gated clock ant not a clock enable.
http://vhdlguru.blogspot.de/2010/04/what-is-gated-clock-and-how-it-reduces.html


I am also wondering how STA is handling a (assumed) asynchronous clock 
enable.

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


Rate this post
useful
not useful
Bitwurschtler wrote:
> VHDL Syntax for Synthesis is vendor specific, so there is a "good
> chance" that
> elsif (rising_edge(clk) and reset='0') then
>  is translated into a gated clock ant not a clock enable.
With all the toolchains I used up to now I got the same result just like 
the test there:
http://www.lothar-miller.de/s9y/categories/6-Clock-Enable

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.