[dv/uvmdvgen] Add switch to auto-gen edn
This PR adds an option 'has_edn' to auto generate edn related switch in
tb.sv and ip_env_cfg.sv
Signed-off-by: Cindy Chen <chencindy@google.com>
diff --git a/util/uvmdvgen/env_cfg.sv.tpl b/util/uvmdvgen/env_cfg.sv.tpl
index 6fce2bb..71a0d75 100644
--- a/util/uvmdvgen/env_cfg.sv.tpl
+++ b/util/uvmdvgen/env_cfg.sv.tpl
@@ -27,6 +27,9 @@
% if has_alerts:
list_of_alerts = ${name}_env_pkg::LIST_OF_ALERTS;
% endif
+% if has_edn:
+ cfg.has_edn = 1;
+% endif
% if has_ral:
super.initialize(csr_base_addr);
% endif
diff --git a/util/uvmdvgen/gen_env.py b/util/uvmdvgen/gen_env.py
index 0fcbc65..f38e0cc 100644
--- a/util/uvmdvgen/gen_env.py
+++ b/util/uvmdvgen/gen_env.py
@@ -12,8 +12,8 @@
from uvmdvgen import VENDOR_DEFAULT
-def gen_env(name, is_cip, has_ral, has_interrupts, has_alerts, env_agents,
- root_dir, vendor):
+def gen_env(name, is_cip, has_ral, has_interrupts, has_alerts, has_edn,
+ env_agents, root_dir, vendor):
# yapf: disable
# 4-tuple - sub-path, ip name, class name, file ext
env_srcs = [('dv/env', name + '_', 'env_cfg', '.sv'),
@@ -79,6 +79,7 @@
has_ral=has_ral,
has_interrupts=has_interrupts,
has_alerts=has_alerts,
+ has_edn=has_edn,
env_agents=env_agents,
vendor=vendor))
except Exception as e:
diff --git a/util/uvmdvgen/tb.sv.tpl b/util/uvmdvgen/tb.sv.tpl
index ac81d8c..9e0f0bf 100644
--- a/util/uvmdvgen/tb.sv.tpl
+++ b/util/uvmdvgen/tb.sv.tpl
@@ -33,6 +33,9 @@
% for agent in env_agents:
${agent}_if ${agent}_if();
% endfor
+% if has_edn:
+ push_pull_if #(.DeviceDataWidth(cip_base_pkg::EDN_DATA_WIDTH)) edn_if(.clk(clk), .rst_n(rst_n));
+% endif
% if has_alerts:
`DV_ALERT_IF_CONNECT
@@ -42,19 +45,18 @@
${name} dut (
.clk_i (clk ),
% if is_cip:
- .rst_ni (rst_n ),
+ .rst_ni (rst_n )${"," if is_cip else ""}
.tl_i (tl_if.h2d),
-% if has_alerts:
- .tl_o (tl_if.d2h),
+ .tl_o (tl_if.d2h)${"," if has_alert or has_edn else ""}
+ % if has_alerts:
.alert_rx_i (alert_rx ),
- .alert_tx_o (alert_tx )
-% else:
- .tl_o (tl_if.d2h)
-% endif
-% else:
- .rst_ni (rst_n )
-
+ .alert_tx_o (alert_tx )${"," if has_edn else ""}
+ % endif
+ % if has_edn:
+ .edn_o (edn_if.req),
+ .edn_i ({edn_if.ack, edn_if.d_data})
+ % endif
% endif
// TODO: add remaining IOs and hook them
);
@@ -73,6 +75,10 @@
% for agent in env_agents:
uvm_config_db#(virtual ${agent}_if)::set(null, "*.env.m_${agent}_agent*", "vif", ${agent}_if);
% endfor
+% if has_edn:
+ uvm_config_db#(virtual push_pull_if#(.DeviceDataWidth(cip_base_pkg::EDN_DATA_WIDTH)))::set
+ (null, "*env.m_edn_pull_agent*", "vif", edn_if);
+% endif
$timeformat(-12, 0, " ps", 12);
run_test();
end
diff --git a/util/uvmdvgen/uvmdvgen.py b/util/uvmdvgen/uvmdvgen.py
index 9773581..f7c7c14 100755
--- a/util/uvmdvgen/uvmdvgen.py
+++ b/util/uvmdvgen/uvmdvgen.py
@@ -75,6 +75,13 @@
help="""CIP has alerts. Create alerts interface in tb""")
parser.add_argument(
+ "-he",
+ "--has-edn",
+ default=False,
+ action='store_true',
+ help="""CIP has EDN connection. Create edn pull interface in tb""")
+
+ parser.add_argument(
"-ea",
"--env-agents",
nargs="+",
@@ -134,8 +141,8 @@
if not args.env_agents:
args.env_agents = []
gen_env.gen_env(args.name, args.is_cip, args.has_ral,
- args.has_interrupts, args.has_alerts, args.env_agents,
- args.env_outdir, args.vendor)
+ args.has_interrupts, args.has_alerts, args.has_edn,
+ args.env_agents, args.env_outdir, args.vendor)
if __name__ == '__main__':