aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2022-07-28 18:59:32 +0200
committerTristan Gingold <tgingold@free.fr>2022-07-28 18:59:32 +0200
commit852992b1843f38be176e04826ec4c04b03b43d90 (patch)
treee2c7a4668096aee0071594f55e4328bf2b794e2e
parenta961af98bbadc6e3490110e11531d36fe7927b09 (diff)
downloadghdl-852992b1843f38be176e04826ec4c04b03b43d90.tar.gz
ghdl-852992b1843f38be176e04826ec4c04b03b43d90.tar.bz2
ghdl-852992b1843f38be176e04826ec4c04b03b43d90.zip
synth-disp_vhdl: fix out conversion. Fix #2145
In the case the width of a vector is only 1 bit
-rw-r--r--src/synth/synth-disp_vhdl.adb50
1 files changed, 29 insertions, 21 deletions
diff --git a/src/synth/synth-disp_vhdl.adb b/src/synth/synth-disp_vhdl.adb
index 01046a297..f96a51494 100644
--- a/src/synth/synth-disp_vhdl.adb
+++ b/src/synth/synth-disp_vhdl.adb
@@ -368,27 +368,35 @@ package body Synth.Disp_Vhdl is
elsif Is_Std_Logic_Array (Btype) then
-- unsigned, signed or a compatible array.
W := Typ.Abound.Len;
- Put (" " & Pfx & " <= ");
- -- First the first non-anonymous parent type of the prefix.
- -- We could directly use the base type, but:
- -- * it is less intuitive
- -- * vhdl2008 base type of 'unsigned' is 'unresolved_unsigned',
- -- which is barely used and not defined in vhdl93
- declare
- Pfx_Type : Node;
- Type_Decl : Node;
- begin
- Pfx_Type := Ptype;
- loop
- Type_Decl := Get_Type_Declarator (Pfx_Type);
- exit when Type_Decl /= Null_Node;
- Pfx_Type := Get_Parent_Type (Pfx_Type);
- end loop;
- Put (Name_Table.Image (Get_Identifier (Type_Decl)));
- end;
- Put ("(");
- Disp_Out_Rhs (Mname, Off, W, Full);
- Put_Line (");");
+ Put (" " & Pfx);
+ if W = 1 then
+ Put ("(" & Pfx & "'left) <= ");
+ Disp_Out_Rhs (Mname, Off, W, Full);
+ Put_Line (";");
+ else
+ Put (" <= ");
+ -- First the first non-anonymous parent type of the prefix.
+ -- We could directly use the base type, but:
+ -- * it is less intuitive
+ -- * vhdl2008 base type of 'unsigned' is
+ -- 'unresolved_unsigned', which is barely used and not
+ -- defined in vhdl93
+ declare
+ Pfx_Type : Node;
+ Type_Decl : Node;
+ begin
+ Pfx_Type := Ptype;
+ loop
+ Type_Decl := Get_Type_Declarator (Pfx_Type);
+ exit when Type_Decl /= Null_Node;
+ Pfx_Type := Get_Parent_Type (Pfx_Type);
+ end loop;
+ Put (Name_Table.Image (Get_Identifier (Type_Decl)));
+ end;
+ Put ("(");
+ Disp_Out_Rhs (Mname, Off, W, Full);
+ Put_Line (");");
+ end if;
else
declare
Bnd : Bound_Type renames Typ.Abound;