diff options
| -rw-r--r-- | src/synth/synth-ieee-numeric_std.adb | 34 | ||||
| -rw-r--r-- | src/synth/synth-ieee-numeric_std.ads | 4 | ||||
| -rw-r--r-- | src/synth/synth-static_oper.adb | 12 | 
3 files changed, 20 insertions, 30 deletions
| diff --git a/src/synth/synth-ieee-numeric_std.adb b/src/synth/synth-ieee-numeric_std.adb index 89f428580..5101734ad 100644 --- a/src/synth/synth-ieee-numeric_std.adb +++ b/src/synth/synth-ieee-numeric_std.adb @@ -20,10 +20,9 @@  with Types_Utils; use Types_Utils;  with Synth.Errors; use Synth.Errors; +with Synth.Ieee.Std_Logic_1164; use Synth.Ieee.Std_Logic_1164;  package body Synth.Ieee.Numeric_Std is -   Null_Vec : constant Std_Logic_Vector (1 .. 0) := (others => '0'); -     subtype Sl_01 is Std_Ulogic range '0' .. '1';     subtype Sl_X01 is Std_Ulogic range 'X' .. '1'; @@ -466,32 +465,33 @@ package body Synth.Ieee.Numeric_Std is        return Mul_Sgn_Sgn (L, Rv, Loc);     end Mul_Sgn_Int; -   function Neg_Sgn (V : Std_Logic_Vector) return Std_Logic_Vector +   function Neg_Vec (V : Memtyp; Loc : Syn_Src) return Memtyp     is -      pragma Assert (V'First = 1); -      Len : constant Integer := V'Last; -      subtype Res_Type is Std_Logic_Vector (1 .. Len); -      Res : Res_Type; +      Len : constant Uns32 := V.Typ.Vbound.Len; +      Res : Memtyp;        Vb, Carry : Sl_X01;     begin -      if Len < 1 then -         return Null_Vec; +      Res.Typ := Create_Res_Type (V.Typ, Len); +      Res := Create_Memory (Res.Typ); + +      if Len = 0 then +         return Res;        end if; +        Carry := '1'; -      for I in 0 .. Len - 1 loop -         Vb := Sl_To_X01 (V (V'Last - I)); +      for I in 1 .. Len loop +         Vb := Sl_To_X01 (Read_Std_Logic (V.Mem, Len - I));           if Vb = 'X' then -            --assert NO_WARNING -            --  report "NUMERIC_STD.""+"": non logical value detected" -            --  severity warning; -            Res := (others => 'X'); +            Warning_Msg_Synth +              (+Loc, "NUMERIC_STD.""-"": non logical value detected"); +            Fill (Res, 'X');              exit;           end if;           Vb := Not_Table (Vb); -         Res (Res'Last - I) := Xor_Table (Carry, Vb); +         Write_Std_Logic (Res.Mem, Len - I, Xor_Table (Carry, Vb));           Carry := And_Table (Carry, Vb);        end loop;        return Res; -   end Neg_Sgn; +   end Neg_Vec;  end Synth.Ieee.Numeric_Std; diff --git a/src/synth/synth-ieee-numeric_std.ads b/src/synth/synth-ieee-numeric_std.ads index c9324f7ea..d390b14b3 100644 --- a/src/synth/synth-ieee-numeric_std.ads +++ b/src/synth/synth-ieee-numeric_std.ads @@ -22,12 +22,12 @@ with Types; use Types;  with Synth.Objtypes; use Synth.Objtypes;  with Synth.Source; use Synth.Source; -with Synth.Ieee.Std_Logic_1164; use Synth.Ieee.Std_Logic_1164;  package Synth.Ieee.Numeric_Std is     --  Reminder: vectors elements are from left to right. -   function Neg_Sgn (V : Std_Logic_Vector) return Std_Logic_Vector; +   --  Unary "-" +   function Neg_Vec (V : Memtyp; Loc : Syn_Src) return Memtyp;     --  "+"     function Add_Uns_Uns (L, R : Memtyp; Loc : Syn_Src) return Memtyp; diff --git a/src/synth/synth-static_oper.adb b/src/synth/synth-static_oper.adb index 440df4c0a..ecfc0db80 100644 --- a/src/synth/synth-static_oper.adb +++ b/src/synth/synth-static_oper.adb @@ -984,17 +984,7 @@ package body Synth.Static_Oper is              end;           when Iir_Predefined_Ieee_Numeric_Std_Neg_Sgn => -            declare -               Op_Arr : Std_Logic_Vector -                 (1 .. Natural (Vec_Length (Operand.Typ))); -            begin -               To_Std_Logic_Vector (Operand, Op_Arr); -               declare -                  Res_Arr : constant Std_Logic_Vector := Neg_Sgn (Op_Arr); -               begin -                  return To_Memtyp (Res_Arr, Operand.Typ.Vec_El); -               end; -            end; +            return Neg_Vec (Operand, Expr);           when Iir_Predefined_Ieee_1164_Vector_Not             | Iir_Predefined_Ieee_Numeric_Std_Not_Uns | 
