-
Notifications
You must be signed in to change notification settings - Fork 812
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
Gpio scoreboard imp #26098
Open
marcelocarvalhoLowRisc
wants to merge
2
commits into
lowRISC:master
Choose a base branch
from
marcelocarvalhoLowRisc:gpio_scoreboard_imp
base: master
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.
Open
Gpio scoreboard imp #26098
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
There are no files selected for viewing
This file contains 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 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 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 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,54 @@ | ||
// Copyright lowRISC contributors (OpenTitan project). | ||
// Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
`ifndef GPIO_STRAP_AGENT_SV | ||
`define GPIO_STRAP_AGENT_SV | ||
class gpio_strap_agent extends dv_base_agent #(.CFG_T(gpio_strap_agent_cfg), | ||
.DRIVER_T(gpio_strap_driver), | ||
.SEQUENCER_T(strap_sequencer), | ||
.MONITOR_T(gpio_strap_monitor)); | ||
|
||
`uvm_component_utils(gpio_strap_agent) | ||
|
||
gpio_strap_monitor strap_monitor; | ||
gpio_strap_driver strap_driver; | ||
strap_sequencer strap_sqr; | ||
gpio_strap_agent_cfg cfg; | ||
|
||
// Constructor | ||
function new(string name, uvm_component parent); | ||
super.new(name, parent); | ||
endfunction : new | ||
|
||
// Build phase | ||
function void build_phase(uvm_phase phase); | ||
|
||
// Instantiate the monitor | ||
strap_monitor = gpio_strap_monitor::type_id::create("strap_monitor", this); | ||
// Instantiate the driver | ||
strap_driver = gpio_strap_driver::type_id::create("strap_driver", this); | ||
// Instantiate the sequencer | ||
strap_sqr = strap_sequencer::type_id::create("strap_sqr", this); | ||
// Set the sequencer in the config DB for the driver | ||
uvm_config_db#(strap_sequencer)::set(this, "*", "strap_sqr", strap_sqr); | ||
|
||
// Instantiate the strap agent config object | ||
cfg = gpio_strap_agent_cfg::type_id::create("cfg", this); | ||
|
||
// Set the agent cfg in the config DB | ||
uvm_config_db#(gpio_strap_agent_cfg)::set(this, "", "cfg", cfg); | ||
// Set the agent cfg in the config DB | ||
uvm_config_db#(gpio_strap_agent_cfg)::set(this, "*", "monitor_cfg", cfg); | ||
|
||
super.build_phase(phase); | ||
endfunction : build_phase | ||
|
||
// Connect phase | ||
function void connect_phase(uvm_phase phase); | ||
strap_driver.seq_item_port.connect(strap_sqr.seq_item_export); | ||
super.connect_phase(phase); | ||
endfunction : connect_phase | ||
|
||
endclass : gpio_strap_agent | ||
`endif // GPIO_STRAP_AGENT_SV |
This file contains 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,14 @@ | ||
// Copyright lowRISC contributors (OpenTitan project). | ||
// Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
`ifndef GPIO_STRAP_AGENT_CFG_SV | ||
`define GPIO_STRAP_AGENT_CFG_SV | ||
class gpio_strap_agent_cfg extends dv_base_agent_cfg; | ||
`uvm_object_utils(gpio_strap_agent_cfg) | ||
|
||
function new (string name = "gpio_strap_agent_cfg"); | ||
super.new(name); | ||
endfunction : new | ||
|
||
endclass | ||
`endif // GPIO_STRAP_AGENT_SV |
This file contains 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,57 @@ | ||
// Copyright lowRISC contributors (OpenTitan project). | ||
// Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
`ifndef GPIO_STRAP_DRIVER_SV | ||
`define GPIO_STRAP_DRIVER_SV | ||
|
||
class gpio_strap_driver extends dv_base_driver #(.ITEM_T(uvm_sequence_item), | ||
.CFG_T(gpio_strap_agent_cfg)); | ||
|
||
`uvm_component_utils(gpio_strap_driver) | ||
|
||
straps_vif m_straps_vif; | ||
virtual clk_rst_if clk_rst_vif; | ||
strap_sequencer m_seqr; | ||
|
||
// Constructor: Creates a new instance of the gpio_driver class | ||
// @param name - The name of the component | ||
// @param parent - The parent component | ||
function new(string name, uvm_component parent); | ||
super.new(name, parent); | ||
endfunction | ||
|
||
virtual function void build_phase(uvm_phase phase); | ||
super.build_phase(phase); | ||
if (!uvm_config_db#(straps_vif)::get(this, "*.*", "straps_vif", m_straps_vif)) begin | ||
`uvm_fatal("gpio_strap_driver", "Virtual interface m_straps_vif is not set in the uvm_config_db") | ||
end | ||
if (!uvm_config_db#(virtual clk_rst_if)::get(this, "*.env", "clk_rst_vif", clk_rst_vif)) begin | ||
`uvm_fatal("gpio_strap_driver", "Could not get clk_rst_vif") | ||
end | ||
if (!uvm_config_db#(strap_sequencer)::get(this, "", "strap_sqr", m_seqr)) begin | ||
`uvm_fatal(get_type_name(), "Failed to get sequencer handle from config DB!") | ||
end | ||
endfunction | ||
|
||
virtual task run_phase(uvm_phase phase); | ||
forever begin | ||
gpio_seq_item m_item; | ||
seq_item_port.get_next_item(req); | ||
|
||
if(!$cast(m_item , req)) begin | ||
`uvm_error("gpio_strap_driver", "Failed to cast item to gpio_seq_item") | ||
end | ||
drive_item(m_item); | ||
seq_item_port.item_done(); | ||
end | ||
endtask | ||
|
||
// Drive the stran_en_i pin | ||
virtual task drive_item(gpio_seq_item req); | ||
@(posedge clk_rst_vif.clk); | ||
m_straps_vif.dut_if.strap_en <= req.strap_en_i; | ||
endtask | ||
|
||
endclass | ||
`endif // GPIO_STRAP_DRIVER_SV |
This file contains 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,78 @@ | ||
// Copyright lowRISC contributors (OpenTitan project). | ||
// Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
`ifndef GPIO_STRAP_MONITOR_SV | ||
`define GPIO_STRAP_MONITOR_SV | ||
class gpio_strap_monitor extends dv_base_monitor #(.ITEM_T(uvm_sequence_item), | ||
.CFG_T(gpio_strap_agent_cfg)); | ||
|
||
`uvm_component_utils(gpio_strap_monitor) | ||
|
||
// Used to send the strap outputs to the scoreboard | ||
uvm_analysis_port #(gpio_seq_item) mon_ap; | ||
// straps virtual interface | ||
straps_vif m_straps_vif; | ||
// gpio virtual interface | ||
gpio_vif m_gpio_vif; | ||
// clk and rst virtual interface | ||
virtual clk_rst_if clk_rst_vif; | ||
// GPIO sequence item | ||
gpio_seq_item item; | ||
// strap agent configuration object | ||
gpio_strap_agent_cfg cfg; | ||
|
||
// Constructor | ||
function new(string name = "gpio_strap_monitor", uvm_component parent = null); | ||
super.new(name, parent); | ||
mon_ap = new ("mon_ap", this); | ||
item = new(); | ||
endfunction | ||
|
||
virtual function void build_phase(uvm_phase phase); | ||
super.build_phase(phase); | ||
if (!uvm_config_db#(straps_vif)::get(this, "*.*", "straps_vif", m_straps_vif)) begin | ||
`uvm_fatal(`gfn, "Virtual interface m_straps_vif is not set") | ||
end | ||
if (!uvm_config_db#(gpio_vif)::get(this, "*.env", "gpio_vif", m_gpio_vif)) begin | ||
`uvm_fatal("gpio_strap_driver", "Could not get m_gpio_vif") | ||
end | ||
if (!uvm_config_db#(virtual clk_rst_if)::get(this, "*.env", "clk_rst_vif", clk_rst_vif)) begin | ||
`uvm_fatal(`gfn, "Could not get clk_rst_vif") | ||
end | ||
if (!uvm_config_db#(gpio_strap_agent_cfg)::get(this, "", "monitor_cfg", cfg)) begin | ||
`uvm_fatal(`gfn, "Could not get strap agent config") | ||
end | ||
// Required because the parent class use the agent configuration object. | ||
super.cfg = cfg; | ||
endfunction | ||
|
||
// Task to monitor GPIO strap signals | ||
virtual task run_phase(uvm_phase phase); | ||
fork | ||
monitor_gpio_straps(); | ||
join_none | ||
endtask | ||
|
||
// Task: monitor_gpio_straps | ||
// The task monitor the gpio straps enable signal | ||
// and send the strap ouput information to the scoreboard to be checked. | ||
virtual task monitor_gpio_straps(); | ||
forever begin : monitor_gpio_straps | ||
@(posedge clk_rst_vif.clk) | ||
if(clk_rst_vif.rst_n) begin | ||
if(m_straps_vif.tb_if.strap_en && | ||
!m_straps_vif.strap_en_q && | ||
!m_straps_vif.strap_en_qq) begin | ||
// Wait for at least 1 clock cycle after strap_en is asserted. | ||
clk_rst_vif.wait_clks(1); | ||
// Sample the straps | ||
item.sampled_straps_o.data = m_straps_vif.tb_if.sampled_straps.data; | ||
item.sampled_straps_o.valid = m_straps_vif.tb_if.sampled_straps.valid; | ||
// Send the sampled straps to the gpio scoreboard. | ||
mon_ap.write(item); | ||
end | ||
end | ||
end | ||
endtask : monitor_gpio_straps | ||
endclass : gpio_strap_monitor | ||
`endif // GPIO_STRAP_MONITOR_SV |
This file contains 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 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 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
Oops, something went wrong.
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.
I think it would help to use either
gfn
here or$sformatf("%m")
here in case we have multiple agents so it's easier to figure out the instance that's wrongThere 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.
I will fix that! thnks