[dv/alert_agent] Support async alert receiver
This commit enable the async return for alert ack signal with the
following changes:
1. Rename sender_clk to async clk.
2. Increase the handshake timeout timing, due to async clk
3. Add original frequency so async clk frequence will be randomized
based on dut clk
Signed-off-by: Cindy Chen <chencindy@google.com>
diff --git a/hw/dv/sv/alert_esc_agent/alert_esc_agent.sv b/hw/dv/sv/alert_esc_agent/alert_esc_agent.sv
index 4c8de31..7f0e968 100644
--- a/hw/dv/sv/alert_esc_agent/alert_esc_agent.sv
+++ b/hw/dv/sv/alert_esc_agent/alert_esc_agent.sv
@@ -70,7 +70,7 @@
int min_freq_mhz = (cfg.clk_freq_mhz / 10) ? (cfg.clk_freq_mhz / 10) : 1;
cfg.vif.clk_rst_async_if.set_freq_mhz($urandom_range(min_freq_mhz, cfg.clk_freq_mhz * 10));
end else begin
- cfg.vif.clk_rst_async_if.set_freq_mhz($urandom_range(1, 200));
+ cfg.vif.clk_rst_async_if.set_freq_mhz($urandom_range(10, 240));
end
end
endfunction
diff --git a/hw/dv/sv/alert_esc_agent/alert_esc_agent_cfg.sv b/hw/dv/sv/alert_esc_agent/alert_esc_agent_cfg.sv
index 0a33153..91fd986 100644
--- a/hw/dv/sv/alert_esc_agent/alert_esc_agent_cfg.sv
+++ b/hw/dv/sv/alert_esc_agent/alert_esc_agent_cfg.sv
@@ -33,7 +33,9 @@
int unsigned ping_delay_min = 0;
int unsigned ping_delay_max = 10;
- int unsigned handshake_timeout_cycle = 200;
+ // this timeout is to ensure handshake protocol did not hang, this timeout is not implemented in
+ // design. In design, if protocol hangs, the period ping check will catch the issue
+ int unsigned handshake_timeout_cycle = 100_000;
int unsigned ping_timeout_cycle = 32;
`uvm_object_utils_begin(alert_esc_agent_cfg)
diff --git a/hw/dv/sv/alert_esc_agent/alert_esc_if.sv b/hw/dv/sv/alert_esc_agent/alert_esc_if.sv
index 4fd613a..fb5a0cd 100644
--- a/hw/dv/sv/alert_esc_agent/alert_esc_if.sv
+++ b/hw/dv/sv/alert_esc_agent/alert_esc_if.sv
@@ -26,14 +26,14 @@
prim_esc_pkg::esc_tx_t esc_tx_int; // internal esc_tx
prim_esc_pkg::esc_rx_t esc_rx_int; // internal esc_rx
- wire sender_clk;
+ wire async_clk;
bit is_async, is_alert;
dv_utils_pkg::if_mode_e if_mode;
- clk_rst_if clk_rst_async_if(.clk(sender_clk), .rst_n(rst_n));
+ clk_rst_if clk_rst_async_if(.clk(async_clk), .rst_n(rst_n));
// if alert sender is async mode, the clock will be drived in alert_esc_agent,
// if it is sync mode, will assign to dut clk here
- assign sender_clk = (is_async) ? 'z : clk ;
+ assign async_clk = (is_async) ? 'z : clk ;
// async interface for alert_tx has two_clock cycles delay
// TODO: this is not needed once the CDC module is implemented
@@ -55,7 +55,7 @@
assign alert_rx_final = (is_async && (if_mode == dv_utils_pkg::Device)) ?
alert_rx_sync_dly2 : alert_rx;
- clocking sender_cb @(posedge sender_clk);
+ clocking sender_cb @(posedge async_clk);
input rst_n;
output alert_tx_int;
input alert_rx;
@@ -63,7 +63,7 @@
input esc_rx;
endclocking
- clocking receiver_cb @(posedge clk);
+ clocking receiver_cb @(posedge async_clk);
input rst_n;
input alert_tx;
output alert_rx_int;
diff --git a/hw/dv/sv/alert_esc_agent/alert_monitor.sv b/hw/dv/sv/alert_esc_agent/alert_monitor.sv
index 165abd8..eee02e9 100644
--- a/hw/dv/sv/alert_esc_agent/alert_monitor.sv
+++ b/hw/dv/sv/alert_esc_agent/alert_monitor.sv
@@ -118,6 +118,7 @@
req.alert_handshake_sta = AlertComplete;
wait_ack_complete();
req.alert_handshake_sta = AlertAckComplete;
+ @(cfg.vif.monitor_cb);
end
begin
wait(under_reset);
diff --git a/hw/dv/sv/alert_esc_agent/alert_receiver_driver.sv b/hw/dv/sv/alert_esc_agent/alert_receiver_driver.sv
index 3f91cb4..fe07300 100644
--- a/hw/dv/sv/alert_esc_agent/alert_receiver_driver.sv
+++ b/hw/dv/sv/alert_esc_agent/alert_receiver_driver.sv
@@ -90,9 +90,8 @@
endtask : rsp_alert
virtual task drive_alert_ping(alert_esc_seq_item req);
- int unsigned ping_delay;
- ping_delay = (cfg.use_seq_item_ping_delay) ?
- req.ping_delay : $urandom_range(cfg.ping_delay_max, cfg.ping_delay_min);
+ int unsigned ping_delay = (cfg.use_seq_item_ping_delay) ? req.ping_delay :
+ $urandom_range(cfg.ping_delay_max, cfg.ping_delay_min);
if (!req.int_err) begin
@(cfg.vif.receiver_cb);
repeat (ping_delay) @(cfg.vif.receiver_cb);
@@ -118,11 +117,10 @@
endtask
virtual task set_ack_pins(alert_esc_seq_item req);
- int unsigned ack_delay, ack_stable;
- ack_delay = (cfg.use_seq_item_ack_delay) ? req.ack_delay :
- $urandom_range(cfg.ack_delay_max, cfg.ack_delay_min);
- ack_stable = (cfg.use_seq_item_ack_stable) ? req.ack_stable :
- $urandom_range(cfg.ack_stable_max, cfg.ack_stable_min);
+ int unsigned ack_delay = (cfg.use_seq_item_ack_delay) ? req.ack_delay :
+ $urandom_range(cfg.ack_delay_max, cfg.ack_delay_min);
+ int unsigned ack_stable = (cfg.use_seq_item_ack_stable) ? req.ack_stable :
+ $urandom_range(cfg.ack_stable_max, cfg.ack_stable_min);
if (!req.int_err) begin
@(cfg.vif.receiver_cb);
repeat (ack_delay) @(cfg.vif.receiver_cb);
diff --git a/hw/dv/sv/cip_lib/cip_base_env.sv b/hw/dv/sv/cip_lib/cip_base_env.sv
index b6604c5..6309954 100644
--- a/hw/dv/sv/cip_lib/cip_base_env.sv
+++ b/hw/dv/sv/cip_lib/cip_base_env.sv
@@ -45,6 +45,7 @@
uvm_config_db#(alert_esc_agent_cfg)::set(this, agent_name, "cfg",
cfg.m_alert_agent_cfg[alert_name]);
cfg.m_alert_agent_cfg[alert_name].en_cov = cfg.en_cov;
+ cfg.m_alert_agent_cfg[alert_name].clk_freq_mhz = int'(cfg.clk_freq_mhz);
end
// Create and configure the EDN agent if available.