[chip dv] Fix for failing GPIO test
- Fixes the pins_if to prevent accidental default pull down due to
ambiguity introduced by the internal `pins_int` signal.
- Fixes chip GPIO SV test seq to disable pullup or pulldown on
`gpio_vif` from the start of the test.
Signed-off-by: Srikrishna Iyer <sriyer@google.com>
diff --git a/hw/dv/sv/common_ifs/pins_if.sv b/hw/dv/sv/common_ifs/pins_if.sv
index 2a419ed..636af6f 100644
--- a/hw/dv/sv/common_ifs/pins_if.sv
+++ b/hw/dv/sv/common_ifs/pins_if.sv
@@ -15,7 +15,6 @@
logic [Width-1:0] pins_o; // value to be driven out
- wire [Width-1:0] pins_int; // value of pin using internal pull-up / pull-down
bit [Width-1:0] pins_oe = '0; // output enable
bit [Width-1:0] pins_pd = '0; // pull down enable
bit [Width-1:0] pins_pu = '0; // pull up enable
@@ -73,24 +72,26 @@
endfunction
// make connections
- generate
- for (genvar i = 0; i < Width; i++) begin : each_pin
- assign pins_int[i] = pins_pd[i] ? 1'b0 :
- pins_pu[i] ? 1'b1 : 1'bz;
- // If output enable is 1, strong driver assigns pin to 'value to be driven out';
- // the external strong driver can still affect pin, if exists.
- // Else if output enable is 0, weak pullup or pulldown is applied to pin.
- // By doing this, we make sure that weak pullup or pulldown does not override
- // any 'x' value on pin, that may result due to conflicting values
- // between 'value to be driven out' and the external driver's value.
- assign pins[i] = pins_oe[i] ? pins_o[i] : 1'bz;
+ for (genvar i = 0; i < Width; i++) begin : each_pin
`ifdef VERILATOR
- assign pins[i] = ~pins_oe[i] ? pins_int[i] : 1'bz;
+ assign pins[i] = pins_oe[i] ? pins_o[i] :
+ pins_pu[i] ? 1'b1 :
+ pins_pd[i] ? 1'b0 : 1'bz;
`else
- assign (pull0, pull1) pins[i] = ~pins_oe[i] ? pins_int[i] : 1'bz;
+ // Drive the pin with pull strength based on whether pullup / pulldown is enabled.
+ assign (pull0, pull1) pins[i] = ~pins_oe[i] ? (pins_pu[i] ? 1'b1 :
+ pins_pd[i] ? 1'b0 : 1'bz) : 1'bz;
+
+
+ // If output enable is 1, strong driver assigns pin to 'value to be driven out';
+ // the external strong driver can still affect pin, if exists.
+ // Else if output enable is 0, weak pullup or pulldown is applied to pin.
+ // By doing this, we make sure that weak pullup or pulldown does not override
+ // any 'x' value on pin, that may result due to conflicting values
+ // between 'value to be driven out' and the external driver's value.
+ assign pins[i] = pins_oe[i] ? pins_o[i] : 1'bz;
`endif
- end
- endgenerate
+ end
endinterface
`endif
diff --git a/hw/top_earlgrey/dv/env/seq_lib/chip_sw_gpio_vseq.sv b/hw/top_earlgrey/dv/env/seq_lib/chip_sw_gpio_vseq.sv
index 9d96ce4..e443bdf 100644
--- a/hw/top_earlgrey/dv/env/seq_lib/chip_sw_gpio_vseq.sv
+++ b/hw/top_earlgrey/dv/env/seq_lib/chip_sw_gpio_vseq.sv
@@ -16,6 +16,10 @@
// Wait until we reach the SW test state.
wait(cfg.sw_test_status_vif.sw_test_status == SwTestStatusInTest);
+ // Disable pullups and pulldowns on GPIOs.
+ cfg.gpio_vif.set_pulldown_en({chip_env_pkg::NUM_GPIOS{1'b0}});
+ cfg.gpio_vif.set_pullup_en({chip_env_pkg::NUM_GPIOS{1'b0}});
+
// Run the GPIO output tests.
gpio_output_test();
@@ -73,10 +77,6 @@
endtask
virtual task gpio_input_test();
- // Disable pullups and pulldowns on GPIOs.
- cfg.gpio_vif.set_pulldown_en({chip_env_pkg::NUM_GPIOS{1'b0}});
- cfg.gpio_vif.set_pullup_en({chip_env_pkg::NUM_GPIOS{1'b0}});
-
// Wait and check all zs - this indicates it is safe to drive GPIOs as inputs.
`DV_SPINWAIT(wait(cfg.gpio_vif.pins === {NUM_GPIOS{1'bz}});,
$sformatf("Timed out waiting for GPIOs == %0h", {NUM_GPIOS{1'bz}}),