Update i2c/dv/env and i2c_agent
diff --git a/hw/dv/sv/i2c_agent/i2c_item.sv b/hw/dv/sv/i2c_agent/i2c_item.sv
index 97153b4..bca5c06 100644
--- a/hw/dv/sv/i2c_agent/i2c_item.sv
+++ b/hw/dv/sv/i2c_agent/i2c_item.sv
@@ -5,10 +5,28 @@
class i2c_item extends uvm_sequence_item;
// random variables
+ //rand i2c_bit_type_t bit_type = 1'b0;
+ rand bit sda_bit = 1'b1;
+ rand bit scl_bit = 1'b1;
+
+ rand bit stop_detected = 1'b0;
+ rand bit start_detected = 1'b0;
+
+ // dont override start_bit unless testing an error scenario
+ constraint sda_bit_c {
+ sda_bit == 1'b1;
+ }
+
+ // dont override stop_bit unless testing an error scenario
+ constraint scl_bit_c {
+ sda_bit == 1'b1;
+ }
`uvm_object_utils_begin(i2c_item)
+ `uvm_field_int(sda_bit, UVM_DEFAULT | UVM_NOCOMPARE | UVM_NOPRINT)
+ `uvm_field_int(scl_bit, UVM_DEFAULT)
`uvm_object_utils_end
`uvm_object_new
-endclass
+endclass : i2c_item
diff --git a/hw/dv/sv/i2c_agent/i2c_monitor.sv b/hw/dv/sv/i2c_agent/i2c_monitor.sv
index 8c6d30d..b5bebea 100644
--- a/hw/dv/sv/i2c_agent/i2c_monitor.sv
+++ b/hw/dv/sv/i2c_agent/i2c_monitor.sv
@@ -10,9 +10,11 @@
`uvm_component_utils(i2c_monitor)
// the base class provides the following handles for use:
- // i2c_agent_cfg: cfg
- // i2c_agent_cov: cov
- // uvm_analysis_port #(i2c_item): analysis_port
+ i2c_agent_cfg cfg;
+ i2c_agent_cov cov;
+
+ // analize ports
+ //uvm_analysis_port #(i2c_item) analysis_port;
`uvm_component_new
@@ -40,4 +42,4 @@
end
endtask
-endclass
+endclass : i2c_monitor
diff --git a/hw/ip/i2c/dv/env/i2c_env.sv b/hw/ip/i2c/dv/env/i2c_env.sv
index 84c8048..8f8a954 100644
--- a/hw/ip/i2c/dv/env/i2c_env.sv
+++ b/hw/ip/i2c/dv/env/i2c_env.sv
@@ -3,14 +3,14 @@
// SPDX-License-Identifier: Apache-2.0
class i2c_env extends cip_base_env #(
- .CFG_T (i2c_env_cfg),
- .COV_T (i2c_env_cov),
- .VIRTUAL_SEQUENCER_T(i2c_virtual_sequencer),
- .SCOREBOARD_T (i2c_scoreboard)
- );
+ .CFG_T (i2c_env_cfg),
+ .COV_T (i2c_env_cov),
+ .VIRTUAL_SEQUENCER_T (i2c_virtual_sequencer),
+ .SCOREBOARD_T (i2c_scoreboard));
+
`uvm_component_utils(i2c_env)
- i2c_agent m_i2c_agent;
+ i2c_agent m_i2c_agent;
`uvm_component_new
@@ -30,4 +30,4 @@
end
endfunction
-endclass
+endclass : i2c_env
diff --git a/hw/ip/i2c/dv/env/i2c_env_pkg.sv b/hw/ip/i2c/dv/env/i2c_env_pkg.sv
index a82ce53..424cf05 100644
--- a/hw/ip/i2c/dv/env/i2c_env_pkg.sv
+++ b/hw/ip/i2c/dv/env/i2c_env_pkg.sv
@@ -36,6 +36,46 @@
parameter uint I2C_RX_FIFO_DEPTH = 32;
// functions
+ // get the number of bytes that triggers watermark interrupt
+ function automatic int get_watermark_bytes_by_level(int lvl);
+ case(lvl)
+ 0: return 1;
+ 1: return 4;
+ 2: return 8;
+ 3: return 16;
+ 4: return 30;
+ default: begin
+ `uvm_fatal("i2c_env_pkg::get_watermark_bytes_by_level",
+ $sformatf("invalid watermark level value - %0d", lvl))
+ end
+ endcase
+ endfunction : get_watermark_bytes_by_level
+
+ // get the number of bytes that triggers break interrupt
+ function automatic int get_break_bytes_by_level(int lvl);
+ case(lvl)
+ 0: return 2;
+ 1: return 4;
+ 2: return 8;
+ 3: return 16;
+ default: begin
+ `uvm_fatal("i2c_env_pkg::get_break_bytes_by_level",
+ $sformatf("invalid break level value - %0d", lvl))
+ end
+ endcase
+ endfunction : get_break_bytes_by_level
+
+ // get timing values from speed mode
+ function automatic int get_timing_values_by_speed_mode(int speed_mode);
+ // TBD
+ endfunction : get_timing_values_by_speed_mode
+
+ // get speed mode from timing values
+ function automatic int get_speed_mode_by_timing_values(int timing0, int timing1,
+ int timing2, int timing3,
+ int timing4, int timing5);
+ // TBD
+ endfunction : get_speed_mode_by_timing_values
// package sources
`include "i2c_reg_block.sv"
@@ -46,4 +86,4 @@
`include "i2c_env.sv"
`include "i2c_vseq_list.sv"
-endpackage
+endpackage : i2c_env_pkg
diff --git a/hw/ip/i2c/dv/env/i2c_virtual_sequencer.sv b/hw/ip/i2c/dv/env/i2c_virtual_sequencer.sv
index 16853f1..12702d3 100644
--- a/hw/ip/i2c/dv/env/i2c_virtual_sequencer.sv
+++ b/hw/ip/i2c/dv/env/i2c_virtual_sequencer.sv
@@ -2,14 +2,13 @@
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
-class i2c_virtual_sequencer extends cip_base_virtual_sequencer #(
- .CFG_T(i2c_env_cfg),
- .COV_T(i2c_env_cov)
- );
+class i2c_virtual_sequencer extends cip_base_virtual_sequencer #(.CFG_T(i2c_env_cfg),
+ .COV_T(i2c_env_cov));
+
`uvm_component_utils(i2c_virtual_sequencer)
- i2c_sequencer i2c_sequencer_h;
+ i2c_sequencer i2c_sequencer_h;
`uvm_component_new
-endclass
+endclass : i2c_virtual_sequencer