EmbDev.net

Forum: FPGA, VHDL & Verilog Place 30-574 Poor placement for routing between an IO pin and BUFG


von tj anderson (Guest)


Rate this post
useful
not useful
1
`timescale 1ns / 1ps    
2
    module stopwatch(
3
        input clock,
4
        input reset,
5
        input increment,
6
        input start,
7
        output [6:0] seg,
8
        output dp,
9
        output [3:0] an
10
        );
11
     
12
        reg [3:0] reg_d0, reg_d1, reg_d2, reg_d3; //registers that will hold the individual counts
13
        reg [22:0] ticker;
14
        wire click;
15
         
16
         
17
        //the mod 1kHz clock to generate a tick ever 0.001 second
18
         
19
        always @ (posedge (clock) or posedge (reset))
20
        begin
21
            if(reset)
22
            begin
23
                ticker <= 0;
24
            end
25
            else 
26
            begin
27
                if (start)
28
                begin
29
                    if(ticker == (100000 - 1)) //if it reaches the desired max value reset it
30
                        ticker <= 0;
31
                    else if (increment)
32
                        ticker <= ticker;
33
                    else
34
                        ticker <= ticker + 1;
35
                end 
36
            end
37
        end
38
        
39
        //increment a second everytime rising edge of down button
40
        reg [3:0] inc_temp;
41
        always @ (posedge (increment)) 
42
        begin
43
            if (reg_d3 == 9)
44
                inc_temp = 0;
45
            else
46
                inc_temp = reg_d3 + 1;
47
        end
48
        
49
        assign click = ((ticker == (100000 - 1))?1'b1:1'b0); //click to be assigned high every 0.001 second
50
        
51
        //update data start from here
52
        always @ (posedge (clock) or posedge (reset))
53
        begin
54
            if(reset)
55
            begin
56
                reg_d0 <= 0;
57
                reg_d1 <= 0;
58
                reg_d2 <= 0;
59
                reg_d3 <= 0;
60
            end
61
            
62
            else
63
            begin
64
                if (increment)
65
                    begin
66
                        reg_d3 <= inc_temp;
67
                        reg_d0 <= reg_d0;
68
                        reg_d1 <= reg_d1;
69
                        reg_d2 <= reg_d2;    
70
                    end
71
                    else if (click) //increment at every click
72
                    begin
73
                        if(reg_d0 == 9) //xxx9 - 1th milisecond
74
                        begin
75
                            reg_d0 <= 0;
76
                            if (reg_d1 == 9) //xx99 - 10th milisecond
77
                            begin
78
                                reg_d1 <= 0;
79
                                if (reg_d2 == 9) //x999 - 100th milisecond
80
                                begin
81
                                    reg_d2 <= 0;
82
                                    if(reg_d3 == 9) //9999 - The second digit
83
                                        reg_d3 <= 0;
84
                                    else
85
                                        reg_d3 <= reg_d3 + 1;
86
                                end
87
                                else
88
                                    reg_d2 <= reg_d2 + 1;
89
                            end
90
                                
91
                            else
92
                                reg_d1 <= reg_d1 + 1;
93
                        end
94
                        
95
                        else
96
                            reg_d0 <= reg_d0 + 1;
97
                    end
98
                    else
99
                    begin
100
                        reg_d3 <= reg_d3;
101
                        reg_d0 <= reg_d0;
102
                        reg_d1 <= reg_d1;
103
                        reg_d2 <= reg_d2;
104
                    end
105
            end
106
            
107
        end
108
        
109
        
110
    
111
        //Mux for display 4 7segs LEDs
112
        localparam N = 18; 
113
        reg [N-1:0]count;
114
        always @ (posedge clock or posedge reset)
115
        begin
116
            if (reset)
117
                count <= 0;
118
            else
119
                count <= count + 1;
120
        end
121
         
122
        reg [6:0]sseg;
123
        reg [3:0]an_temp;
124
        reg reg_dp;
125
        always @ (*)
126
            begin
127
                case(count[N-1:N-2])
128
                    2'b00 :
129
                    begin
130
                        sseg = reg_d0;
131
                        an_temp = 4'b1110;
132
                        reg_dp = 1'b1;
133
                    end
134
                    
135
                    2'b01:
136
                    begin
137
                        sseg = reg_d1;
138
                        an_temp = 4'b1101;
139
                        reg_dp = 1'b0;
140
                    end
141
                    
142
                    2'b10:
143
                    begin
144
                        sseg = reg_d2;
145
                        an_temp = 4'b1011;
146
                        reg_dp = 1'b1;
147
                    end
148
                    
149
                    2'b11:
150
                    begin
151
                        sseg = reg_d3;
152
                        an_temp = 4'b0111;
153
                        reg_dp = 1'b0;
154
                    end
155
                endcase
156
            end
157
        assign an = an_temp;
158
         
159
        //update the data to display to LEDs
160
        reg [6:0] sseg_temp;
161
        always @ (*)
162
        begin
163
            case(sseg)
164
                4'd0 : sseg_temp = 7'b1000000;
165
                4'd1 : sseg_temp = 7'b1111001;
166
                4'd2 : sseg_temp = 7'b0100100;
167
                4'd3 : sseg_temp = 7'b0110000;
168
                4'd4 : sseg_temp = 7'b0011001;
169
                4'd5 : sseg_temp = 7'b0010010;
170
                4'd6 : sseg_temp = 7'b0000010;
171
                4'd7 : sseg_temp = 7'b1111000;
172
                4'd8 : sseg_temp = 7'b0000000;
173
                4'd9 : sseg_temp = 7'b0010000;
174
                default : sseg_temp = 7'b0111111; //dash
175
            endcase
176
        end
177
        assign seg = sseg_temp;
178
        assign dp = reg_dp;
179
    endmodule

I'm trying to design a stop watch, but i'm stuck at the increment thing. 
The intend is when I press `increment`(a button) the `reg_d3` will 
increment by one and hold it state until the button is release. I'm able 
to make the clock stop when the button is pressed, but I can't update 
the `reg_d3`. I always receive `[Place 30-574] Poor placement for 
routing between an IO pin and BUFG`. I don't know why, I use increment 
in the clkdivider just find. Please help me. Thanks

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


Rate this post
useful
not useful
The problem is this here:
> when I press `increment`(a button)
>  always @ (posedge (increment))

This is VERY BAD design practise due to a bunch of reasons:
1. every mechanical switch bounces, so you will get
   some undefined clock pulses every keypress

2. you add an asynchronous clock domain to your design

3. every asynchronous signal (e.g. switch, sensor...)
   must be synchronized to your systems clock

4. you use a non dedicated pin for a clock signal

BTW: number 4 is the tiniest problem in your design, although it is the 
reason for you error message...

My major hints for your designs are:
A. use only one clock throughout the whole design
B. every external signal must be synchronized to that clock with 2 
flipflops

tj anderson wrote:
> I'm trying to design a stop watch
So, not just copy a code from a place even your teacher knows very 
well 
(http://simplefpga.blogspot.de/2012/07/to-code-stopwatch-in-verilog.html), 
but at least try to understand, what happens there. And then find the 
right place to dig a hole for your buttons (after adding a sync stage 
and an edge detection to them)...

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.