-
Notifications
You must be signed in to change notification settings - Fork 16
[chip, I2C, DV] Top level I2C host test #473
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
11
commits into
lowRISC:main
Choose a base branch
from
KinzaQamar:i2c_dv
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.
+503
−67
Draft
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5dcd728
[I2C, hal, SW] Restructured and refactored the functions
KinzaQamar 3303352
[I2C, SW] Place the resetting of FMT fifo step when halt occurs
KinzaQamar ab608e2
[I2C, sw] Added a HAL function to return I2C RData
KinzaQamar dbf6a8d
[I2C, SW, hal] Extended read / write functions to R/W N bytes
KinzaQamar ed795b3
[i2c, sw] Added an overflow check when the byte is equal to FMT FIFO …
KinzaQamar 6527cb4
[i2c, sw, hal] Added a function to calculate SCL high cycles
KinzaQamar 8539f1d
[i2c, sw] Function added to calculate timing params based on speed
KinzaQamar c58a9e9
[chip, I2C, DV] Top level wiring of I2C ports with the interface
KinzaQamar 7f62c88
[chip, I2C, DV] Wired up I2C agent in the chip environment
KinzaQamar cae654e
[chip, I2C, SW] Added I2C host TX_RX test
KinzaQamar f5bc214
[chip, I2C, DV] Added Host TX-RX vseq
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
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
84 changes: 84 additions & 0 deletions
84
hw/top_chip/dv/env/seq_lib/top_chip_dv_i2c_host_tx_rx_vseq.sv
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,84 @@ | ||
| // Copyright lowRISC contributors (COSMIC project). | ||
| // Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| // This vseq is going to be starting a reactive sequence. | ||
| // | ||
| // i2c_monitor shares an analysis port with i2c_sequencer. It sends an i2c_item which contains | ||
| // a member "state". i2c_monitor watches the i2c_if and as soon as it sees the communication started | ||
| // on the bus, it change the state accordingly. Based on the state received on the | ||
| // analysis port of sequencer, i2c_base_seq initializes the start_item method to send i2c_item to | ||
| // i2c_driver so that it can drive ack, nack or rdata to the controller. | ||
| class top_chip_dv_i2c_host_tx_rx_vseq extends top_chip_dv_i2c_tx_rx_vseq; | ||
| `uvm_object_utils(top_chip_dv_i2c_host_tx_rx_vseq) | ||
|
|
||
| // The timing parameter in cycles used by the agent to add relevant delays before driving Ack, | ||
| // Nack and Rdata | ||
| local bit [15:0] scl_period_cycles; | ||
| local bit [15:0] scl_low_cycles; | ||
| local bit [15:0] sda_hold_cycles; | ||
|
|
||
| // Standard SV/UVM methods | ||
| extern function new(string name=""); | ||
| extern task body(); | ||
| extern virtual task dut_init(string reset_kind = "HARD"); | ||
| extern local function void configure_agent_timing(); | ||
| endclass : top_chip_dv_i2c_host_tx_rx_vseq | ||
|
|
||
| function top_chip_dv_i2c_host_tx_rx_vseq::new(string name = ""); | ||
| super.new(name); | ||
| endfunction : new | ||
|
|
||
| task top_chip_dv_i2c_host_tx_rx_vseq::dut_init(string reset_kind = "HARD"); | ||
| // Read the timing parameters through SW backdoor load | ||
| sw_symbol_backdoor_read("SysClkPeriodNS", sw_sys_clk_period_ns); | ||
| sw_symbol_backdoor_read("SCLLowTimeNs", sw_scl_low_time_ns); | ||
| sw_symbol_backdoor_read("HoldDataTimeNs", sw_data_hold_time_ns); | ||
|
|
||
| scl_period_cycles = round_up_divide({sw_scl_clk_period_ns[1], sw_scl_clk_period_ns[0]}, | ||
| sw_sys_clk_period_ns[0]); | ||
| scl_low_cycles = round_up_divide({sw_scl_low_time_ns[1], sw_scl_low_time_ns[0]}, | ||
| sw_sys_clk_period_ns[0]); | ||
| sda_hold_cycles = round_up_divide({sw_data_hold_time_ns[1], sw_data_hold_time_ns[0]}, | ||
| sw_sys_clk_period_ns[0]); | ||
|
|
||
| super.dut_init(reset_kind); | ||
| endtask | ||
|
|
||
| function void top_chip_dv_i2c_host_tx_rx_vseq::configure_agent_timing(); | ||
| // tSetupBit are going to be the cycles before SCL goes high to drive SDA. Agent should drive | ||
| // atleast two cycles before SCL goes high. | ||
| int unsigned tSetupBit = 2; | ||
| cfg.m_i2c_agent_cfg.timing_cfg.tSetupBit = tSetupBit; | ||
|
|
||
| // tHoldBit are the cycles to hold SDA after SCL goes low. | ||
| cfg.m_i2c_agent_cfg.timing_cfg.tHoldBit = sda_hold_cycles; | ||
|
|
||
| // Used by i2c_if to stretch SCL by tClockpulse before driving SDA. If tClockPulse is greater | ||
| // than scl_low_cycles then i2c_monitor acknowledge the Ack later and then drives Rdata when SCL | ||
| // is high. | ||
| cfg.m_i2c_agent_cfg.timing_cfg.tClockPulse = scl_low_cycles; | ||
|
|
||
| // tClockLow are the SCL low cycles that the i2c_driver use before driving SDA after stretching | ||
| // SCL by tClockPulse cycles. Drive SDA atleast tSetBit cycles earlier to avoid the chances of | ||
| // SDA interference. | ||
| cfg.m_i2c_agent_cfg.timing_cfg.tClockLow = scl_low_cycles - tSetupBit; | ||
|
elliotb-lowrisc marked this conversation as resolved.
|
||
| endfunction | ||
|
|
||
| task top_chip_dv_i2c_host_tx_rx_vseq::body(); | ||
| i2c_device_response_seq seq = i2c_device_response_seq::type_id::create("seq"); | ||
|
|
||
| configure_agent_timing(); | ||
| print_i2c_timing_cfg(); | ||
|
|
||
| // Configure the agent to be reactive | ||
| cfg.m_i2c_agent_cfg.if_mode = Device; | ||
|
|
||
| `DV_WAIT(cfg.sw_test_status_vif.sw_test_status == SwTestStatusInTest); | ||
|
|
||
| `uvm_info(`gfn, "Starting I2C Host TX-RX test", UVM_LOW) | ||
|
|
||
| fork | ||
| seq.start(p_sequencer.i2c_sqr); | ||
| join_none | ||
| endtask : body | ||
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,66 @@ | ||
| // Copyright lowRISC contributors (OpenTitan project). | ||
| // Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| class top_chip_dv_i2c_tx_rx_vseq extends top_chip_dv_base_vseq; | ||
| `uvm_object_utils(top_chip_dv_i2c_tx_rx_vseq) | ||
|
|
||
| // Below variables will get assign through SW backdoor load. They are defined as byte size array | ||
| // as "sw_symbol_backdoor_read/overwrite" takes an array as an argument to write or read the SW | ||
| // symbol. | ||
| protected bit [7:0] sw_sys_clk_period_ns[1]; | ||
| protected bit [7:0] sw_scl_clk_period_ns[2]; | ||
| protected bit [7:0] sw_scl_low_time_ns[2]; | ||
| protected bit [7:0] sw_data_hold_time_ns[2]; | ||
|
|
||
| extern function new(string name=""); | ||
|
|
||
| // Obtain an integer minimum of timing parameter "a" and round up to the next highest integer. | ||
| extern protected function int unsigned round_up_divide(int unsigned a, int unsigned b); | ||
| extern protected function void print_i2c_timing_cfg(); | ||
| endclass : top_chip_dv_i2c_tx_rx_vseq | ||
|
|
||
| function top_chip_dv_i2c_tx_rx_vseq::new(string name = ""); | ||
| super.new(name); | ||
| endfunction | ||
|
|
||
| function int unsigned top_chip_dv_i2c_tx_rx_vseq::round_up_divide(int unsigned a, int unsigned b); | ||
| return (((a - 1) / b) + 1); | ||
| endfunction | ||
|
|
||
| function void top_chip_dv_i2c_tx_rx_vseq::print_i2c_timing_cfg(); | ||
| string str; | ||
| str = {str, $sformatf("\n timing_cfg.tSetupStart : %d", | ||
| cfg.m_i2c_agent_cfg.timing_cfg.tSetupStart)}; | ||
| str = {str, $sformatf("\n timing_cfg.tHoldStart : %d", | ||
| cfg.m_i2c_agent_cfg.timing_cfg.tHoldStart)}; | ||
| str = {str, $sformatf("\n timing_cfg.tClockStart : %d", | ||
| cfg.m_i2c_agent_cfg.timing_cfg.tClockStart)}; | ||
| str = {str, $sformatf("\n timing_cfg.tClockLow : %d", | ||
| cfg.m_i2c_agent_cfg.timing_cfg.tClockLow)}; | ||
| str = {str, $sformatf("\n timing_cfg.tSetupBit : %d", | ||
| cfg.m_i2c_agent_cfg.timing_cfg.tSetupBit)}; | ||
| str = {str, $sformatf("\n timing_cfg.tClockPulse : %d", | ||
| cfg.m_i2c_agent_cfg.timing_cfg.tClockPulse)}; | ||
| str = {str, $sformatf("\n timing_cfg.tHoldBit : %d", | ||
| cfg.m_i2c_agent_cfg.timing_cfg.tHoldBit)}; | ||
| str = {str, $sformatf("\n timing_cfg.tClockStop : %d", | ||
| cfg.m_i2c_agent_cfg.timing_cfg.tClockStop)}; | ||
| str = {str, $sformatf("\n timing_cfg.tSetupStop : %d", | ||
| cfg.m_i2c_agent_cfg.timing_cfg.tSetupStop)}; | ||
| str = {str, $sformatf("\n timing_cfg.tHoldStop : %d", | ||
| cfg.m_i2c_agent_cfg.timing_cfg.tHoldStop)}; | ||
| str = {str, $sformatf("\n timing_cfg.tTimeOut : %d", | ||
| cfg.m_i2c_agent_cfg.timing_cfg.tTimeOut)}; | ||
| str = {str, $sformatf("\n timing_cfg.enbTimeOut : %d", | ||
| cfg.m_i2c_agent_cfg.timing_cfg.enbTimeOut)}; | ||
| str = {str, $sformatf("\n timing_cfg.tStretchHostClock : %d", | ||
| cfg.m_i2c_agent_cfg.timing_cfg.tStretchHostClock)}; | ||
| str = {str, $sformatf("\n timing_cfg.tSdaUnstable : %d", | ||
| cfg.m_i2c_agent_cfg.timing_cfg.tSdaUnstable)}; | ||
| str = {str, $sformatf("\n timing_cfg.tSdaInterference : %d", | ||
| cfg.m_i2c_agent_cfg.timing_cfg.tSdaInterference)}; | ||
| str = {str, $sformatf("\n timing_cfg.tSclInterference : %d", | ||
| cfg.m_i2c_agent_cfg.timing_cfg.tSclInterference)}; | ||
| `uvm_info(`gfn, $sformatf("%s", str), UVM_MEDIUM); | ||
| endfunction |
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
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.
Uh oh!
There was an error while loading. Please reload this page.