@@ -8,6 +8,20 @@ class top_chip_dv_gpio_base_vseq extends top_chip_dv_base_vseq;
88 // Standard SV/UVM methods
99 extern function new (string name = " " );
1010 extern task body ();
11+
12+ // Class specific methods
13+
14+ // Drives a pattern on the GPIOs
15+ extern local virtual task drive_pattern (int unsigned num_clks, int unsigned pin, bit val);
16+
17+ // Waits for the paatern to appear on the GPIOs
18+ extern local virtual task wait_for_pattern (logic [NUM_GPIOS - 1 : 0 ] exp_val);
19+
20+ // Checks the GPIOs in both input and output mode. A smoketest.c writes walking 0's and walking
21+ // 1's pattern on the lower and upper byte of direct_out register and gpio_test() should wait (for
22+ // a reasonable amount of timeout) for that pattern to appear on the pads to drive 1's and 0's in
23+ // temperature sequence fashion.
24+ extern virtual task gpio_test ();
1125endclass : top_chip_dv_gpio_base_vseq
1226
1327function top_chip_dv_gpio_base_vseq::new (string name = " " );
@@ -17,5 +31,114 @@ endfunction : new
1731task top_chip_dv_gpio_base_vseq::body ();
1832 super .body ();
1933 `DV_WAIT (cfg.sw_test_status_vif.sw_test_status == SwTestStatusInTest);
20- // TODO
34+ gpio_test ();
2135endtask : body
36+
37+ task top_chip_dv_gpio_base_vseq::drive_pattern (int unsigned num_clks, int unsigned pin, bit val);
38+ cfg.peri_clk_vif.wait_clks (num_clks);
39+ cfg.gpio_vif.drive_pin (pin, val);
40+ endtask : drive_pattern
41+
42+ task top_chip_dv_gpio_base_vseq::wait_for_pattern (logic [NUM_GPIOS - 1 : 0 ] exp_val);
43+ `DV_SPINWAIT (wait (cfg.gpio_vif.pins == ? exp_val);,
44+ $sformatf (" Timed out waiting for GPIOs == %0h " , exp_val),
45+ /* use default_spinwait_timeout_ns*/ ,
46+ `gfn )
47+ endtask : wait_for_pattern
48+
49+ task top_chip_dv_gpio_base_vseq::gpio_test ();
50+ // Enable the pulldown so that the pads are driving 0's than Z's when no external driver is
51+ // connected
52+ cfg.gpio_vif.set_pulldown_en ('1 );
53+
54+ // GPIO pads : 'h0
55+ //
56+ // Disable GPIOs from being driven as chip inputs.
57+ cfg.gpio_vif.drive_en ({ (NUM_GPIOS / 4 ){ 1'b0 }} );
58+
59+ `uvm_info (`gfn , " Starting GPIOs outputs test" , UVM_LOW )
60+
61+ // The C code first sets the GPIOs to '0s in order to walk 1 on first 8 pins of upper and lower
62+ // halves.
63+ //
64+ // Wait and check for all 0s.
65+ wait_for_pattern ({ NUM_GPIOS { 1'b0 }} );
66+
67+ // Check for walking 1's pattern on lower 8 pins.
68+ for (int i = 0 ; i < NUM_GPIOS / 4 ; i++ ) begin
69+ wait_for_pattern ({ 24'h? , 1 << i} );
70+ end
71+
72+ // GPIO pads : 'h00000080
73+ //
74+ // Drive 1's in temperature pattern on the lower 8 pins.
75+ for (int i = NUM_GPIOS / 4 ; i < (NUM_GPIOS / 4 ) * 2 ; i++ ) begin
76+ drive_pattern (1 , i, 1 );
77+ end
78+
79+ // GPIO pads : 'h0000FF80
80+ //
81+ // Check for walking 1's pattern on the first 8 pins upper half.
82+ for (int i = 0 ; i < NUM_GPIOS / 4 ; i++ ) begin
83+ wait_for_pattern ({ 8'h? , 1 << i, 16'h???? } );
84+ end
85+
86+ // GPIO pads : 'h0080FF80
87+ //
88+ // Drive 1's in temperature pattern on the second half of 8 pins of upper half.
89+ for (int i = (NUM_GPIOS / 4 ) * 3 ; i < NUM_GPIOS ; i++ ) begin
90+ drive_pattern (1 , i, 1 );
91+ end
92+
93+ // GPIO pads : 'hFF80FF80
94+ //
95+ // The C code first sets the first 8 pins of both upper and lower halves to 1's in order to walk
96+ // 0's.
97+ //
98+ // Wait and check for all 1s.
99+ wait_for_pattern ({ NUM_GPIOS { 1'b1 }} );
100+
101+ // GPIO pads : 'hFFFFFFFF
102+ //
103+ // Check for walking 0's pattern on first 8 pins of lower half.
104+ for (int i = 0 ; i < NUM_GPIOS / 4 ; i++ ) begin
105+ wait_for_pattern ({ 24'h? , ~ (1 << i)} );
106+ // logic [(NUM_GPIOS/4)-1:0] exp_gpios = ~(1 << i);
107+ // $display("waiting for %0h at %0t", exp_gpios, $realtime);
108+ // `DV_SPINWAIT(wait(cfg.gpio_vif.pins ==? {8'h??, 8'h??, 8'h??, exp_gpios});,
109+ // $sformatf("Timed out waiting for GPIOs == %0h", exp_gpios),
110+ // /*use default_spinwait_timeout_ns*/,
111+ // `gfn)
112+ end
113+
114+ // GPIO pads : 'hFFFFFF7F
115+ //
116+ // Drive 0's in temperature pattern on the upper 8 pins of the lower half.
117+ for (int i = NUM_GPIOS / 4 ; i < (NUM_GPIOS / 4 ) * 2 ; i++ ) begin
118+ drive_pattern (1 , i, 0 );
119+ // cfg.peri_clk_vif.wait_clks(1);
120+ // cfg.gpio_vif.drive_pin(i, 0);
121+ end
122+
123+ // GPIO pads : 'hFFFF007F
124+ //
125+ // Check for walking 0's pattern on lower 8 pins of the upper half.
126+ for (int i = 0 ; i < NUM_GPIOS / 4 ; i++ ) begin
127+ wait_for_pattern ({ 8'h? , ~ (1 << i), 16'h? } );
128+ // logic [(NUM_GPIOS/4)-1:0] exp_gpios = ~(1 << i);
129+ // $display("waiting for %0h at %0t", exp_gpios, $realtime);
130+ // `DV_SPINWAIT(wait(cfg.gpio_vif.pins ==? {8'h??, exp_gpios, 8'h??, 8'h??});,
131+ // $sformatf("Timed out waiting for GPIOs == %0h", exp_gpios),
132+ // /*use default_spinwait_timeout_ns*/,
133+ // `gfn)
134+ end
135+
136+ // GPIO pads : 'hFF00007F
137+ //
138+ // Drive 0's in temperature pattern on the upper 8 pins of the upper half.
139+ for (int i = (NUM_GPIOS / 4 ) * 3 ; i < NUM_GPIOS ; i++ ) begin
140+ drive_pattern (1 , i, 0 );
141+ end
142+
143+ // GPIO pads : 'h7F00007F
144+ endtask : gpio_test
0 commit comments