aboutsummaryrefslogtreecommitdiffstats
path: root/src/synth/synth-ieee-numeric_std.adb
diff options
context:
space:
mode:
Diffstat (limited to 'src/synth/synth-ieee-numeric_std.adb')
-rw-r--r--src/synth/synth-ieee-numeric_std.adb10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/synth/synth-ieee-numeric_std.adb b/src/synth/synth-ieee-numeric_std.adb
index d23b4e858..cbe34db47 100644
--- a/src/synth/synth-ieee-numeric_std.adb
+++ b/src/synth/synth-ieee-numeric_std.adb
@@ -888,19 +888,27 @@ package body Synth.Ieee.Numeric_Std is
Signed : Boolean) return Memtyp
is
Old_Size : constant Uns32 := Uns32 (Vec_Length (Val.Typ));
+ L : Uns32;
Res : Memtyp;
Pad, B : Std_Ulogic;
begin
Res.Typ := Create_Res_Type (Val.Typ, Size);
Res := Create_Memory (Res.Typ);
+ if Size = 0 then
+ return Res;
+ end if;
+
if Signed and then Old_Size > 0 then
Pad := Read_Std_Logic (Val.Mem, 0);
+ Write_Std_Logic (Res.Mem, 0, Pad);
+ L := Size - 1;
else
Pad := '0';
+ L := Size;
end if;
- for I in 1 .. Size loop
+ for I in 1 .. L loop
if I <= Old_Size then
B := Read_Std_Logic (Val.Mem, Old_Size - I);
else