From 7529034c7ae02f8c04e877b76e925241dea48816 Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Tue, 18 Nov 2008 22:21:51 +0000 Subject: [PATCH] Fix incorrect temporary size with padding Fix for pr2224949 The compiler generates a concatenation LPM to zero-pad ports when the signal widths don't match up. However, when the VHDL generator generated the input signals to this LPM it incorrectly sized them to be the width of the result. --- tgt-vhdl/scope.cc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tgt-vhdl/scope.cc b/tgt-vhdl/scope.cc index 179abfbc9..5b15d6074 100644 --- a/tgt-vhdl/scope.cc +++ b/tgt-vhdl/scope.cc @@ -131,6 +131,7 @@ static string visible_nexus_signal_name(nexus_private_t *priv, vhdl_scope *scope void draw_nexus(ivl_nexus_t nexus) { nexus_private_t *priv = new nexus_private_t; + int nexus_signal_width = -1; priv->const_driver = NULL; int nptrs = ivl_nexus_ptrs(nexus); @@ -144,6 +145,8 @@ void draw_nexus(ivl_nexus_t nexus) vhdl_scope *scope = find_scope_for_signal(sig); unsigned pin = ivl_nexus_ptr_pin(nexus_ptr); link_scope_to_nexus_signal(priv, scope, sig, pin); + + nexus_signal_width = ivl_signal_width(sig); } } @@ -188,7 +191,17 @@ void draw_nexus(ivl_nexus_t nexus) else { // Create a temporary signal to connect the nexus // TODO: we could avoid this for IVL_LPM_PART_PV - vhdl_type *type = vhdl_type::type_for(ivl_lpm_width(lpm), + + // If we already know how wide the temporary should be + // (i.e. because we've seen a signal it's connected to) + // then use that, otherwise use the width of the LPM + int lpm_temp_width; + if (nexus_signal_width != -1) + lpm_temp_width = nexus_signal_width; + else + lpm_temp_width = ivl_lpm_width(lpm); + + vhdl_type *type = vhdl_type::type_for(lpm_temp_width, ivl_lpm_signed(lpm) != 0); ostringstream ss; ss << "LPM" << ivl_lpm_basename(lpm);