@@ -33,7 +33,7 @@ QsfpModuleController::Parameters qsfp_test_params =
33
33
core_clk_period_ns : i2c_test_params.core_clk_period_ns,
34
34
i2c_frequency_hz : i2c_test_params.scl_freq_hz,
35
35
power_good_timeout_ms : 10 ,
36
- t_init_ms : 20 , // normally 2000, but sped up for simulation
36
+ t_init_ms : 5 , // normally 2000, but sped up for simulation
37
37
t_clock_hold_us : i2c_test_params.max_scl_stretch_us
38
38
} ;
39
39
@@ -134,6 +134,14 @@ module mkBench (Bench);
134
134
mkConnection( controller.pins.sda.out, periph.sda_i) ;
135
135
mkConnection( controller.pins.sda.in, periph.sda_o) ;
136
136
137
+ // We need the ability to simulate the bus losing its pull-ups when a module has not been
138
+ // inserted since that is how the design behaves. We only apply power to the module (and by the
139
+ // board design, it's bus) when a module is present. This is kind of janky given we can't
140
+ // properly simulate tristate logic in bluesim.
141
+ rule do_pullup_simulation;
142
+ periph.bus_pullups( controller.pg) ;
143
+ endrule
144
+
137
145
// Used to make dummy data for the DUT to pull from
138
146
Reg # ( UInt # ( 8 )) fifo_idx < - mkReg( 0 ) ;
139
147
@@ -289,6 +297,21 @@ function Stmt insert_and_power_module(Bench bench);
289
297
endseq ) ;
290
298
endfunction
291
299
300
+ function Stmt remove_and_power_down_module( Bench bench) ;
301
+ return ( seq
302
+ bench.set_modprsl( 1 ) ;
303
+ // modprsl is debounced, so wait for it to transition
304
+ await( bench.modprsl == 1 ) ;
305
+ delay( 5 ) ;
306
+ assert_false( bench.hsc_en() ,
307
+ " Hot swap should be disabled when module is missing" ) ;
308
+ // after some delay, remove power good
309
+ bench.set_hsc_pg( 0 ) ;
310
+ // power good is debounced, so wait for it to transition
311
+ await( ! bench.hsc_pg) ;
312
+ endseq ) ;
313
+ endfunction
314
+
292
315
function Stmt deassert_reset_and_await_init( Bench bench) ;
293
316
return ( seq
294
317
// release reset
@@ -326,6 +349,9 @@ module mkNoModuleTest (Empty);
326
349
assert_eq( unpack( bench.registers.port_status.error[ 2 : 0 ] ) ,
327
350
NoModule,
328
351
" NoModule error should be present when attempting to communicate with a device which is not present." ) ;
352
+ assert_eq( unpack( bench.registers.port_status.stretching_seen) ,
353
+ False ,
354
+ " Should not have observed and SCL stretching." ) ;
329
355
delay( 5 ) ;
330
356
endseq ) ;
331
357
endmodule
@@ -352,6 +378,9 @@ module mkNoPowerTest (Empty);
352
378
assert_eq( unpack( bench.registers.port_status.error[ 2 : 0 ] ) ,
353
379
NoPower,
354
380
" NoPower error should be present when attempting to communicate before the hot swap is stable." ) ;
381
+ assert_eq( unpack( bench.registers.port_status.stretching_seen) ,
382
+ False ,
383
+ " Should not have observed and SCL stretching." ) ;
355
384
delay( 5 ) ;
356
385
endseq ) ;
357
386
endmodule
@@ -385,6 +414,9 @@ module mkRemovePowerEnableTest (Empty);
385
414
await( ! bench.hsc_pg) ;
386
415
delay( 3 ) ;
387
416
assert_eq( bench.hsc_en() , False , " Expect hot swap to no longer be enabled." ) ;
417
+ assert_eq( unpack( bench.registers.port_status.stretching_seen) ,
418
+ False ,
419
+ " Should not have observed and SCL stretching." ) ;
388
420
delay( 5 ) ;
389
421
endseq ) ;
390
422
endmodule
@@ -410,6 +442,9 @@ module mkPowerGoodTimeoutTest (Empty);
410
442
assert_eq( unpack( bench.registers.port_status.error[ 2 : 0 ] ) ,
411
443
PowerFault,
412
444
" PowerFault error should be present when attempting to communicate after the hot swap has timed out" ) ;
445
+ assert_eq( unpack( bench.registers.port_status.stretching_seen) ,
446
+ False ,
447
+ " Should not have observed and SCL stretching." ) ;
413
448
delay( 5 ) ;
414
449
endseq ) ;
415
450
endmodule
@@ -437,6 +472,9 @@ module mkPowerGoodLostTest (Empty);
437
472
assert_eq( unpack( bench.registers.port_status.error[ 2 : 0 ] ) ,
438
473
PowerFault,
439
474
" PowerFault error should be present when attempting to communicate after the hot swap has aborted" ) ;
475
+ assert_eq( unpack( bench.registers.port_status.stretching_seen) ,
476
+ False ,
477
+ " Should not have observed and SCL stretching." ) ;
440
478
delay( 5 ) ;
441
479
endseq ) ;
442
480
endmodule
@@ -535,6 +573,9 @@ module mkInitializationTest (Empty);
535
573
assert_eq( unpack( bench.registers.port_status.error[ 2 : 0 ] ) ,
536
574
NotInitialized,
537
575
" NotInitialized error should be present when resetl is asserted." ) ;
576
+ assert_eq( unpack( bench.registers.port_status.stretching_seen) ,
577
+ False ,
578
+ " Should not have observed and SCL stretching." ) ;
538
579
delay( 5 ) ;
539
580
endseq ) ;
540
581
endmodule
@@ -562,19 +603,18 @@ module mkUninitializationAfterRemovalTest (Empty);
562
603
NoError,
563
604
" NoError should be present when attempting to communicate after t_init has elapsed." ) ;
564
605
565
- bench.set_modprsl( 1 ) ;
566
- // ModPrsL is debounced and thus won't transition immediately
567
- await( bench.modprsl == 1 ) ;
568
- bench.set_modprsl( 0 ) ;
569
- await( bench.modprsl == 0 ) ;
570
- delay( 3 ) ; // wait a few cycles for power to re-enable
571
- bench.command( read_cmd, False , False ) ;
606
+ remove_and_power_down_module( bench) ;
607
+ insert_and_power_module( bench) ;
572
608
609
+ bench.command( read_cmd, False , False ) ;
573
610
await( ! bench.i2c_busy()) ;
574
611
delay( 3 ) ;
575
612
assert_eq( unpack( bench.registers.port_status.error[ 2 : 0 ] ) ,
576
613
NotInitialized,
577
614
" NotInitialized error should be present when a module has been reseated but not initialized." ) ;
615
+ assert_eq( unpack( bench.registers.port_status.stretching_seen) ,
616
+ False ,
617
+ " Should not have observed and SCL stretching." ) ;
578
618
endseq ) ;
579
619
endmodule
580
620
@@ -605,6 +645,9 @@ module mkNoLPModeWhenModuleIsUnpoweredTest (Empty);
605
645
606
646
await( bench.hsc_pg) ; // wait out debounce
607
647
assert_set( bench.lpmode, " LpMode should be asserted now that 3.3V is up." ) ;
648
+ assert_eq( unpack( bench.registers.port_status.stretching_seen) ,
649
+ False ,
650
+ " Should not have observed and SCL stretching." ) ;
608
651
endseq ) ;
609
652
endmodule
610
653
@@ -620,6 +663,9 @@ module mkIntLTest (Empty);
620
663
bench.set_intl( 0 ) ;
621
664
await( bench.intl == 0 ) ;
622
665
assert_not_set( bench.intl, " IntL should be low after debounce" ) ;
666
+ assert_eq( unpack( bench.registers.port_status.stretching_seen) ,
667
+ False ,
668
+ " Should not have observed and SCL stretching." ) ;
623
669
endseq ) ;
624
670
endmodule
625
671
@@ -635,6 +681,9 @@ module mkModPrsLTest (Empty);
635
681
bench.set_modprsl( 0 ) ;
636
682
await( bench.modprsl == 0 ) ;
637
683
assert_not_set( bench.modprsl, " ModPrsL should be low after debounce" ) ;
684
+ assert_eq( unpack( bench.registers.port_status.stretching_seen) ,
685
+ False ,
686
+ " Should not have observed and SCL stretching." ) ;
638
687
endseq ) ;
639
688
endmodule
640
689
0 commit comments