@@ -140,7 +140,18 @@ module prim_count
140140 // The sum of both counters must always equal the counter maximum.
141141 logic [Width: 0 ] sum;
142142 assign sum = (cnt_q[0 ] + cnt_q[1 ]);
143- assign err_o = (sum != { 1'b0 , { Width{ 1'b1 }}} );
143+
144+ // Register the error signal to avoid potential CDC issues downstream.
145+ logic err_d, err_q;
146+ assign err_d = (sum != { 1'b0 , { Width{ 1'b1 }}} );
147+ always_ff @ (posedge clk_i or negedge rst_ni) begin
148+ if (! rst_ni) begin
149+ err_q <= 1'b0 ;
150+ end else begin
151+ err_q <= err_d;
152+ end
153+ end
154+ assign err_o = err_q;
144155
145156 // Output count values
146157 assign cnt_o = cnt_q[0 ];
@@ -190,7 +201,7 @@ module prim_count
190201 rst_ni
191202 | =>
192203 $past (! commit_i) || (cnt_o == $past (cnt_after_commit_o)),
193- clk_i, err_o || fpv_err_present || ! rst_ni)
204+ clk_i, err_d || fpv_err_present || ! rst_ni)
194205
195206 // Clear
196207 if (PossibleActions & Clr) begin : g_check_clr_fwd_a
@@ -199,7 +210,7 @@ module prim_count
199210 | =>
200211 (cnt_o == ResetValue) &&
201212 (cnt_q[1 ] == ({ Width{ 1'b1 }} - ResetValue)),
202- clk_i, err_o || fpv_err_present || ! rst_ni)
213+ clk_i, err_d || fpv_err_present || ! rst_ni)
203214 end
204215
205216 // Set
@@ -209,7 +220,7 @@ module prim_count
209220 | =>
210221 (cnt_o == $past (set_cnt_i)) &&
211222 (cnt_q[1 ] == ({ Width{ 1'b1 }} - $past (set_cnt_i))),
212- clk_i, err_o || fpv_err_present || ! rst_ni)
223+ clk_i, err_d || fpv_err_present || ! rst_ni)
213224 end
214225
215226 // Do not count if both increment and decrement are asserted.
@@ -218,7 +229,7 @@ module prim_count
218229 rst_ni && incr_en_i && decr_en_i && ! (clr_i || set_i)
219230 | =>
220231 $stable (cnt_o) && $stable (cnt_q[1 ]),
221- clk_i, err_o || fpv_err_present || ! rst_ni)
232+ clk_i, err_d || fpv_err_present || ! rst_ni)
222233 end
223234
224235 // Increment
@@ -227,24 +238,24 @@ module prim_count
227238 rst_ni && incr_en_i && ! (clr_i || set_i || decr_en_i) && commit_i
228239 | =>
229240 cnt_o == min ($past (cnt_o) + $past ({ 2'b0 , step_i} ), { 2'b0 , { Width{ 1'b1 }}} ),
230- clk_i, err_o || fpv_err_present || ! rst_ni)
241+ clk_i, err_d || fpv_err_present || ! rst_ni)
231242 `ASSERT (IncrDnCnt_A,
232243 rst_ni && incr_en_i && ! (clr_i || set_i || decr_en_i) && commit_i
233244 | =>
234245 cnt_q[1 ] == max ($past (signed '({ 2'b0 , cnt_q[1 ]} )) - $past ({ 2'b0 , step_i} ), '0 ),
235- clk_i, err_o || fpv_err_present || ! rst_ni)
246+ clk_i, err_d || fpv_err_present || ! rst_ni)
236247 `ASSERT (UpCntIncrStable_A,
237248 incr_en_i && ! (clr_i || set_i || decr_en_i) &&
238249 cnt_o == { Width{ 1'b1 }}
239250 | =>
240251 $stable (cnt_o),
241- clk_i, err_o || fpv_err_present || ! rst_ni)
252+ clk_i, err_d || fpv_err_present || ! rst_ni)
242253 `ASSERT (DnCntIncrStable_A,
243254 rst_ni && incr_en_i && ! (clr_i || set_i || decr_en_i) &&
244255 cnt_q[1 ] == '0
245256 | =>
246257 $stable (cnt_q[1 ]),
247- clk_i, err_o || fpv_err_present || ! rst_ni)
258+ clk_i, err_d || fpv_err_present || ! rst_ni)
248259 end
249260
250261 // Decrement
@@ -253,24 +264,24 @@ module prim_count
253264 rst_ni && decr_en_i && ! (clr_i || set_i || incr_en_i) && commit_i
254265 | =>
255266 cnt_o == max ($past (signed '({ 2'b0 , cnt_o} )) - $past ({ 2'b0 , step_i} ), '0 ),
256- clk_i, err_o || fpv_err_present || ! rst_ni)
267+ clk_i, err_d || fpv_err_present || ! rst_ni)
257268 `ASSERT (DecrDnCnt_A,
258269 rst_ni && decr_en_i && ! (clr_i || set_i || incr_en_i) && commit_i
259270 | =>
260271 cnt_q[1 ] == min ($past (cnt_q[1 ]) + $past ({ 2'b0 , step_i} ), { 2'b0 , { Width{ 1'b1 }}} ),
261- clk_i, err_o || fpv_err_present || ! rst_ni)
272+ clk_i, err_d || fpv_err_present || ! rst_ni)
262273 `ASSERT (UpCntDecrStable_A,
263274 decr_en_i && ! (clr_i || set_i || incr_en_i) &&
264275 cnt_o == '0
265276 | =>
266277 $stable (cnt_o),
267- clk_i, err_o || fpv_err_present || ! rst_ni)
278+ clk_i, err_d || fpv_err_present || ! rst_ni)
268279 `ASSERT (DnCntDecrStable_A,
269280 rst_ni && decr_en_i && ! (clr_i || set_i || incr_en_i) &&
270281 cnt_q[1 ] == { Width{ 1'b1 }}
271282 | =>
272283 $stable (cnt_q[1 ]),
273- clk_i, err_o || fpv_err_present || ! rst_ni)
284+ clk_i, err_d || fpv_err_present || ! rst_ni)
274285 end
275286
276287 // A backwards check for count changes. This asserts that the count only changes if one of the
@@ -279,12 +290,12 @@ module prim_count
279290 rst_ni ## 1 $changed (cnt_o) && $changed (cnt_q[1 ])
280291 | - >
281292 $past (clr_i || set_i || (commit_i && (incr_en_i || decr_en_i))),
282- clk_i, err_o || fpv_err_present || ! rst_ni)
293+ clk_i, err_d || fpv_err_present || ! rst_ni)
283294
284- // Check that count errors are reported properly in err_o
285- `ASSERT (CntErrReported_A, ((cnt_q[1 ] + cnt_q[0 ]) != { Width{ 1'b1 }} ) == err_o )
295+ // Check that count errors are reported properly in err_d
296+ `ASSERT (CntErrReported_A, ((cnt_q[1 ] + cnt_q[0 ]) != { Width{ 1'b1 }} ) == err_d )
286297 `ifdef PrimCountFpv
287- `COVER (CntErr_C, err_o )
298+ `COVER (CntErr_C, err_d )
288299 `endif
289300
290301 // This logic that will be assign to one, when user adds macro
0 commit comments