From 9bf742b72a24479015c2bebe9a39bff0bf81ccb4 Mon Sep 17 00:00:00 2001 From: Dragon-Git <1762578117@qq.com> Date: Sat, 25 Nov 2023 15:39:58 +0800 Subject: [PATCH] [uvmgen] add ral in env --- src/uvmgen/templates/env_pkg/env.mako.sv | 17 ++++++------ src/uvmgen/templates/ral_pkg/ral_pkg.mako.sv | 29 ++++++++++++++++++++ test/json/env.json | 5 +++- 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/src/uvmgen/templates/env_pkg/env.mako.sv b/src/uvmgen/templates/env_pkg/env.mako.sv index de13ab1..4aea94e 100644 --- a/src/uvmgen/templates/env_pkg/env.mako.sv +++ b/src/uvmgen/templates/env_pkg/env.mako.sv @@ -7,8 +7,7 @@ class ${env_name} extends uvm_env; ${scb_name} scb; % if has_regmodel: ${ral_block_name} regmodel; - reg_seq ral_sequence; - ${}_reg_adapter m_${}_reg_adapter; + ${env_childs[reg_agt_name].replace("_agt", "")}_reg_adapter ${reg_agt_name}_reg_adapter; % endif ${vsqr_name} vsqr; // Declear agent @@ -50,9 +49,9 @@ function void ${env_name}::build_phase(uvm_phase phase); % if has_regmodel: regmodel = ${ral_block_name}::type_id::create("regmodel",this); regmodel.build(); - ral_sequence = reg_seq::type_id::create("ral_sequence"); - ral_sequence.model = regmodel; - reg2host = new("reg2host"); + // ral_sequence = reg_seq::type_id::create("ral_sequence"); + // ral_sequence.model = regmodel; + ${reg_agt_name}_reg_adapter = new("${reg_agt_name}_reg_adapter"); % endif endfunction: build_phase @@ -60,10 +59,10 @@ function void ${env_name}::connect_phase(uvm_phase phase); super.connect_phase(phase); % if has_regmodel: - regmodel.default_map.set_sequencer(mast_seqr,reg2host); - MULT_DRV_START - regmodel.default_map.set_sequencer(mast_seqr_0,reg2host); - MULT_DRV_END + regmodel.default_map.set_sequencer(${reg_agt_name}.sqr,${reg_agt_name}_reg_adapter); + // MULT_DRV_START + // regmodel.default_map.set_sequencer(mast_seqr_0,m_${reg_agt_name}_reg_adapter); + // MULT_DRV_END % endif % for child_name, child_type in env_childs.items(): $cast(vsqr.${child_name[:-3]}sqr, ${child_name}.sqr); diff --git a/src/uvmgen/templates/ral_pkg/ral_pkg.mako.sv b/src/uvmgen/templates/ral_pkg/ral_pkg.mako.sv index 0454e49..76c00ee 100644 --- a/src/uvmgen/templates/ral_pkg/ral_pkg.mako.sv +++ b/src/uvmgen/templates/ral_pkg/ral_pkg.mako.sv @@ -4,13 +4,42 @@ package ral_pkg; `include "uvm_macros.svh" import uvm_pkg::*; + class ctrl extends uvm_reg; + `uvm_object_utils(ctrl) + rand uvm_reg_field ctrl_field; + + function new(string name = "ctrl"); + super.new(name, 32, UVM_NO_COVERAGE); + endfunction + + virtual function void build(); + ctrl_field = uvm_reg_field::type_id::create("ctrl_field"); + ctrl_field.configure(this, 32, 0, "RW", 0, 0, 1, 0, 0); + endfunction + endclass + class empty_reg_block extends uvm_reg_block; `uvm_object_utils(empty_reg_block) + rand ctrl ctrl_reg; + + uvm_reg_map APB_map; // Block map function new(string name = "empty_reg_block"); super.new(name); endfunction + //-------------------------------------------------------------------- + // build + //-------------------------------------------------------------------- + virtual function void build(); + ctrl_reg = ctrl::type_id::create("ctrl"); + ctrl_reg.configure(this, null, ""); + ctrl_reg.build(); + // Map name, Offset, Number of bytes, Endianess) + APB_map = create_map("APB_map", 'h0, 4, UVM_LITTLE_ENDIAN); + APB_map.add_reg(ctrl_reg, 32'h00000000, "RW"); + lock_model(); + endfunction endclass endpackage diff --git a/test/json/env.json b/test/json/env.json index 0cb300a..eb4c94f 100644 --- a/test/json/env.json +++ b/test/json/env.json @@ -4,7 +4,7 @@ "type": "env_pkg", "vars": { "pkg_name": "spi_env_pkg", - "import_pkgs":["spi_agt_pkg"], + "import_pkgs":["spi_agt_pkg", "ral_pkg"], "env_name": "spi_env", "env_childs": {"m_spi_agt": "spi_agt"}, "scb_name": "spi_scb", @@ -12,6 +12,9 @@ "mst_action": "spi_item", "slv_action": "spi_item", "scb_item": "spi_item", + "has_regmodel": "True", + "ral_block_name": "empty_reg_block", + "reg_agt_name": "m_spi_agt", "mon2cov_con_approach": "analysis_port" } }