diff options
author | Tristan Gingold <tgingold@free.fr> | 2022-06-04 07:43:49 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2022-06-04 16:27:47 +0200 |
commit | 90ae71139bc39dc158f54e0337ed73f15033e77f (patch) | |
tree | 3be01f01b58f9a5ff82f2c8fa31187c6ba19a4a6 /src/synth/synth-ieee-numeric_std.adb | |
parent | adfe96ecbe5795f65f8214ce30073385de37bbc6 (diff) | |
download | ghdl-90ae71139bc39dc158f54e0337ed73f15033e77f.tar.gz ghdl-90ae71139bc39dc158f54e0337ed73f15033e77f.tar.bz2 ghdl-90ae71139bc39dc158f54e0337ed73f15033e77f.zip |
synth-vhdl_eval: handle rotations
Diffstat (limited to 'src/synth/synth-ieee-numeric_std.adb')
-rw-r--r-- | src/synth/synth-ieee-numeric_std.adb | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/src/synth/synth-ieee-numeric_std.adb b/src/synth/synth-ieee-numeric_std.adb index cbe34db47..656337ef6 100644 --- a/src/synth/synth-ieee-numeric_std.adb +++ b/src/synth/synth-ieee-numeric_std.adb @@ -844,7 +844,6 @@ package body Synth.Ieee.Numeric_Std is Res := Create_Memory (Res.Typ); if Len = 0 then - Fill (Res, '0'); return Res; end if; @@ -883,6 +882,47 @@ package body Synth.Ieee.Numeric_Std is return Res; end Shift_Vec; + function Rotate_Vec (Val : Memtyp; + Amt : Uns32; + Right : Boolean) return Memtyp + is + Len : constant Uns32 := Uns32 (Vec_Length (Val.Typ)); + Cnt : Uns32; + Res : Memtyp; + B : Std_Ulogic; + begin + Res.Typ := Create_Res_Type (Val.Typ, Len); + Res := Create_Memory (Res.Typ); + + if Len = 0 then + return Res; + end if; + + Cnt := Amt rem Len; + pragma Unreferenced (Amt); + + if Right then + for I in 1 .. Len - Cnt loop + B := Read_Std_Logic (Val.Mem, I - 1); + Write_Std_Logic (Res.Mem, Cnt + I - 1, B); + end loop; + for I in 1 .. Cnt loop + B := Read_Std_Logic (Val.Mem, Len - I); + Write_Std_Logic (Res.Mem, Cnt - I, B); + end loop; + else + for I in 1 .. Cnt loop + B := Read_Std_Logic (Val.Mem, I - 1); + Write_Std_Logic (Res.Mem, Len - Cnt + I - 1, B); + end loop; + for I in 1 .. Len - Cnt loop + B := Read_Std_Logic (Val.Mem, Len - I); + Write_Std_Logic (Res.Mem, Len - Cnt - I, B); + end loop; + end if; + return Res; + end Rotate_Vec; + function Resize_Vec (Val : Memtyp; Size : Uns32; Signed : Boolean) return Memtyp |