From 96aef9e9a8886948510230a87dc7c6188569ef5d Mon Sep 17 00:00:00 2001 From: Harry Callahan Date: Tue, 1 Oct 2024 12:07:32 +0100 Subject: [PATCH] [dv] Cleanup some code in the compile_tb.py module Add comments, and move some variable declarations around to be closer to their use. Signed-off-by: Harry Callahan --- dv/uvm/core_ibex/scripts/compile_tb.py | 48 ++++++++++++++------------ 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/dv/uvm/core_ibex/scripts/compile_tb.py b/dv/uvm/core_ibex/scripts/compile_tb.py index 6d38e69a7..022982697 100755 --- a/dv/uvm/core_ibex/scripts/compile_tb.py +++ b/dv/uvm/core_ibex/scripts/compile_tb.py @@ -85,40 +85,42 @@ def _main() -> int: md.dir_tb.mkdir(exist_ok=True, parents=True) md.tb_build_log = md.dir_tb/'compile_tb.log' - subst_vars_dict = { - 'core_ibex': md.ibex_dv_root, - 'tb_dir': md.dir_tb, - 'tb_build_log': md.tb_build_log, - 'cmp_opts': get_compile_opts(md.ibex_config, - md.simulator), - 'dir_shared_cov': (md.dir_shared_cov if md.cov else ''), - 'xlm_cov_cfg_file': f"{md.ot_xcelium_cov_scripts}/cover.ccf", - 'dut_cov_rtl_path': md.dut_cov_rtl_path - } - # Locate the spike .pc files to allow us to link against it when # building, riscv-fesvr isn't strictly required but the DV flow has been # observed to see build failures where it isn't present with CentOS 7. spike_iss_pc = ['riscv-riscv', 'riscv-disasm', 'riscv-fdt', 'riscv-fesvr'] - - iss_pkgconfig_dict = { - 'ISS_CFLAGS' : ['--cflags'], - 'ISS_LDFLAGS' : ['--libs-only-other'], - 'ISS_LIBS' : ['--libs-only-l', '--libs-only-L'], - } - md.envvar_PKG_CONFIG_PATH = dict(os.environ).get('PKG_CONFIG_PATH') try: subprocess.check_output(['pkg-config', '--exists'] + spike_iss_pc) except subprocess.CalledProcessError as err: raise RuntimeError( f'Failed to find {spike_iss_pc} pkg-config packages. ' f'Did you set the PKG_CONFIG_PATH correctly?') from err - subst_vars_dict.update( - {k: _get_iss_pkgconfig_flags(v, - spike_iss_pc, - md.simulator) - for k, v in iss_pkgconfig_dict.items()}) + + # Now call out to pkg-config to return the appropriate flags for compilation + # (The keys here are the substitution placeholders in rtl_simulation.yaml) + iss_pkgconfig_dict = { + 'ISS_CFLAGS' : ['--cflags'], + 'ISS_LDFLAGS' : ['--libs-only-other'], + 'ISS_LIBS' : ['--libs-only-l', '--libs-only-L'], + } + iss_cc_subst_vars_dict = \ + {k: _get_iss_pkgconfig_flags(v, spike_iss_pc, md.simulator) + for k, v in iss_pkgconfig_dict.items()} + + # Populate the entire set of variables to substitute in the templated + # compilation command, including the compiler flags for the ISS. + subst_vars_dict = { + 'core_ibex': md.ibex_dv_root, + 'tb_dir': md.dir_tb, + 'tb_build_log': md.tb_build_log, + 'cmp_opts': get_compile_opts(md.ibex_config, + md.simulator), + 'dir_shared_cov': (md.dir_shared_cov if md.cov else ''), + 'xlm_cov_cfg_file': f"{md.ot_xcelium_cov_scripts}/cover.ccf", + 'dut_cov_rtl_path': md.dut_cov_rtl_path + } + subst_vars_dict.update(iss_cc_subst_vars_dict) md.tb_build_stdout = md.dir_tb/'compile_tb_stdstreams.log' md.tb_build_cmds = riscvdv_interface.get_tool_cmds(