From e4578773c3d0a4382218c320ac434fbfafd0234b Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Fri, 9 Jun 2023 15:27:45 +0100 Subject: [PATCH] WIP issue 709 --- src/lower.c | 25 ++++++++++++++------ test/questa.sh | 2 +- test/regress/issue709.vhd | 49 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 8 deletions(-) create mode 100644 test/regress/issue709.vhd diff --git a/src/lower.c b/src/lower.c index c466972d..5d20e5cb 100644 --- a/src/lower.c +++ b/src/lower.c @@ -3040,23 +3040,34 @@ static vcode_reg_t lower_ref(lower_unit_t *lu, tree_t ref, expr_ctx_t ctx) static vcode_reg_t lower_external_name(tree_t ref, expr_ctx_t ctx) { - ident_t path = NULL; + ident_t path = NULL, name = NULL; const int nparts = tree_parts(ref); for (int i = 0; i < nparts - 1; i++) { tree_t pe = tree_part(ref, i); - assert(tree_subkind(pe) == PE_SIMPLE); - if (tree_has_ident(pe)) + switch (tree_subkind(pe)) { + case PE_SIMPLE: path = ident_prefix(path, tree_ident(pe), '.'); + break; + case PE_ABSOLUTE: + case PE_RELATIVE: + path = lib_name(lib_work()); + break; + default: + fatal_at(tree_loc(pe), "unexpected external name component %d", tree_subkind(pe)); + } } vcode_reg_t locus = lower_debug_locus(ref); vcode_reg_t context = emit_link_instance(path, locus); - tree_t decl = tree_ref(ref); - type_t type = tree_type(decl); - vcode_type_t vtype = lower_var_type(decl); + tree_t last = tree_part(ref, nparts - 1); - vcode_reg_t ptr_reg = emit_link_var(context, tree_ident(decl), vtype); + type_t type = tree_type(ref); + vcode_type_t vtype = lower_var_type(ref); + + printf("name=%s ident=%s\n", istr(name), istr(tree_ident(last))); + + vcode_reg_t ptr_reg = emit_link_var(context, tree_ident(last), vtype); if (lower_have_uarray_ptr(ptr_reg)) return emit_load_indirect(ptr_reg); else if (tree_class(ref) == C_SIGNAL && type_is_homogeneous(type)) diff --git a/test/questa.sh b/test/questa.sh index 0060acf1..15256127 100755 --- a/test/questa.sh +++ b/test/questa.sh @@ -10,7 +10,7 @@ if [ -f $regress/$1.v ]; then fi if [ -f $regress/$1.vhd ]; then - vcom -2008 $regress/$1.vhd + vcom +acc -2008 $regress/$1.vhd fi cat >/tmp/questa.do <> ; + begin + report "d: 0b" & to_string(d); + assert d = "01010101" + severity failure; + end procedure; + +end package body; + +------------------------------------------------------------------------------- + +entity sub is +end entity; + +architecture test of sub is + signal d : bit_vector(7 downto 0); +begin + + d <= "01010101" after 5 ns; + +end architecture; + +------------------------------------------------------------------------------- + +entity issue709 is +end entity; + +use work.pack.all; + +architecture test of issue709 is +begin + + DUT: entity work.sub; + + process is + begin + wait for 6 ns; + p; + wait; + end process; + +end architecture; -- 2.39.2