@@ -362,18 +362,35 @@ public boolean validateOrdering() {
362362 */
363363 public void fixClockRollover () {
364364 boolean modified = true ;
365+ // ungated clock
365366 while (modified ) {
366367 modified = false ;
367368 for (int i =this .scalers .size ()-1 ; i >0 ; --i ) {
368369 Dsc2Scaler previous = this .scalers .get (i -1 ).dsc2 ;
369- Dsc2Scaler next = this .scalers .get (i ).dsc2 ;
370+ Dsc2Scaler next = this .scalers .get (i ).dsc2 ;
370371 if (previous .clock > next .clock ) {
371372 for (int j =i ; j <this .scalers .size (); ++j ) {
372- if (j ==i ) System .out .print ( String .format ("FIXING CLOCK ROLLOVER: %d %d -> " ,this .scalers .get (j ).dsc2 .clock , this . scalers . get ( j ). dsc2 . gatedClock ));
373+ if (j ==i ) System .out .print ( String .format ("FIXING UNGATED CLOCK ROLLOVER: %d -> " ,this .scalers .get (j ).dsc2 .clock ));
373374 this .scalers .get (j ).dsc2 .clock += 2 *(long )Integer .MAX_VALUE ;
374- // The gated clock also rolls over (but it's triggered by the ungated clock, not itself!?):
375+ if (j ==i ) System .out .println (String .format ("%d" ,this .scalers .get (j ).dsc2 .clock ));
376+ }
377+ modified = true ;
378+ break ;
379+ }
380+ }
381+ }
382+ // repeat for gated clock
383+ modified = true ;
384+ while (modified ) {
385+ modified = false ;
386+ for (int i =this .scalers .size ()-1 ; i >0 ; --i ) {
387+ Dsc2Scaler previous = this .scalers .get (i -1 ).dsc2 ;
388+ Dsc2Scaler next = this .scalers .get (i ).dsc2 ;
389+ if (previous .gatedClock > next .gatedClock ) {
390+ for (int j =i ; j <this .scalers .size (); ++j ) {
391+ if (j ==i ) System .out .print ( String .format ("FIXING GATED CLOCK ROLLOVER: %d -> " ,this .scalers .get (j ).dsc2 .gatedClock ));
375392 this .scalers .get (j ).dsc2 .gatedClock += 2 *(long )Integer .MAX_VALUE ;
376- if (j ==i ) System .out .println (String .format ("%d %d" , this . scalers . get ( j ). dsc2 . clock ,this .scalers .get (j ).dsc2 .gatedClock ));
393+ if (j ==i ) System .out .println (String .format ("%d" ,this .scalers .get (j ).dsc2 .gatedClock ));
377394 }
378395 modified = true ;
379396 break ;
0 commit comments