-
Notifications
You must be signed in to change notification settings - Fork 13
[chip, gpio, dv] GPIO smoke test #382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
KinzaQamar
wants to merge
7
commits into
lowRISC:main
Choose a base branch
from
KinzaQamar:gpio_smoke
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
60c6bdc
[Dependency] Added GPIO related dependency
KinzaQamar 7b7030a
[chip, gpio, dv] Connected GPIO ports into the tb
KinzaQamar d848c02
[chip, gpio, dv] Feeded the gpio_vif inside the chip_dv_env
KinzaQamar 2388832
[chip, gpio, dv] Added GPIO smoke vseq
KinzaQamar 7a635a8
[chip, gpio, dv] Added smoketest.c
KinzaQamar b1c75ca
[chip, gpio, dv] Added functionality in UVM to test GPIOs pins
KinzaQamar 3943d42
[chip, gpio, dv] Added a gpio_smoke_cheri entry to run cheri compatib…
KinzaQamar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| // Copyright lowRISC contributors (COSMIC project). | ||
| // Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| class top_chip_dv_gpio_smoke_vseq extends top_chip_dv_base_vseq; | ||
| `uvm_object_utils(top_chip_dv_gpio_smoke_vseq) | ||
|
|
||
| // Standard SV/UVM methods | ||
| extern function new(string name=""); | ||
| extern task body(); | ||
|
|
||
| // Class specific methods | ||
| // | ||
| // Wait for the pattern to appear on the GPIO's pads | ||
| extern virtual task wait_for_pattern(logic [NUM_GPIOS-1:0] exp_val); | ||
| endclass : top_chip_dv_gpio_smoke_vseq | ||
|
|
||
| function top_chip_dv_gpio_smoke_vseq::new (string name = ""); | ||
| super.new(name); | ||
| endfunction : new | ||
|
|
||
| task top_chip_dv_gpio_smoke_vseq::body(); | ||
| super.body(); | ||
| `DV_WAIT(cfg.sw_test_status_vif.sw_test_status == SwTestStatusInTest); | ||
|
|
||
| `uvm_info(`gfn, "Starting GPIOs outputs test", UVM_LOW) | ||
|
|
||
| // SW first drives walking 1's on each pin. Wait till those patterns are visible | ||
| for (int i = 0; i < NUM_GPIOS; i++) begin | ||
| wait_for_pattern(1 << i); | ||
| end | ||
|
|
||
| // Wait for Z so that the pads can safely be driven in inputs | ||
| wait_for_pattern('Z); | ||
|
|
||
| // The outputs on the pads are seen on the edge of sys_clk_if.clk so wait at least a negedge | ||
| // before driving the pads in inputs. | ||
| cfg.sys_clk_vif.wait_n_clks(1); | ||
|
|
||
| `uvm_info(`gfn, "Starting GPIOs inputs test", UVM_LOW) | ||
|
|
||
| // Drive the pads as inputs | ||
| cfg.gpio_vif.drive('h5555_5555); | ||
| endtask : body | ||
|
|
||
| task top_chip_dv_gpio_smoke_vseq::wait_for_pattern(logic [NUM_GPIOS-1:0] exp_val); | ||
| `DV_SPINWAIT(wait(cfg.gpio_vif.pins === exp_val);, | ||
| $sformatf("Timed out waiting for GPIOs == %0h", exp_val)) | ||
| endtask : wait_for_pattern |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| // Copyright lowRISC contributors (COSMIC project). | ||
| // Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #include "hal/gpio.h" | ||
| #include "hal/mmio.h" | ||
| #include "hal/mocha.h" | ||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
|
|
||
| static bool gpio_test(gpio_t gpio) | ||
| { | ||
| // Enable the GPIOs in output mode | ||
| DEV_WRITE(gpio + GPIO_REG_DIRECT_OE, 0xFFFFFFFF); | ||
|
|
||
| // Set each pin in walking 1's fashion | ||
| for (int i = 0; i < GPIO_NUM_PINS; i++) { | ||
| DEV_WRITE(gpio + GPIO_REG_DIRECT_OUT, 1 << i); | ||
| } | ||
|
|
||
| // When the SW is done driving walking 1's on the last GPIO pin, it should disable the | ||
| // output enables so that the GPIO pads can safely be driven as inputs. | ||
| DEV_WRITE(gpio + GPIO_REG_DIRECT_OE, 0x0); | ||
|
|
||
| // Wait for the pads to set high externally | ||
| while (DEV_READ(gpio + GPIO_REG_DATA_IN) != 0x55555555) { | ||
| } | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| bool test_main() | ||
| { | ||
| gpio_t gpio = mocha_system_gpio(); | ||
| return gpio_test(gpio); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks reasonable, but I noticed that the first commit adds
gpio_envas a direct dependency of the sim. Can we drop it from there, maybe?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No then the environment is unable to find
NUM_GPIOS. There must be a dependency mess-up because I just saw inbuild.logthat it is unable to findtop_chip_dv_env_pkgThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I spent a while to make it work somehow. The problem atm is that I want to use
NUM_GPIOSparameter fromgpio_env_pkgintb.svanduvm. I have an importimport gpio_env_pkg::NUM_GPIOS;intop_chip_dv_env_pkgto be able to use that parameter inUVM. To achieve that I need to have- lowrisc:mocha_dv:gpio_envintop_chip_dv_env.coreThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. I think that the dependency chain should be:
tb.sv.But I just looked and I don't think
lowrisc:mocha_dv:top_chip_simdepends onlowrisc:mocha_dv:top_chip_dv_test. This is a bug! (I'd probably suggest opening a 1-line PR to put in the dependency, which can land before this PR)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be a bug indeed, I struggled a bit to set the core files