diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/synth/synth-expr.adb | 1 | ||||
| -rw-r--r-- | src/synth/synth-ieee-numeric_std.adb | 2 | ||||
| -rw-r--r-- | src/synth/synth-ieee-std_logic_1164.ads | 3 | ||||
| -rw-r--r-- | src/synth/synth-insts.adb | 1 | ||||
| -rw-r--r-- | src/synth/synth-memtype.adb | 124 | ||||
| -rw-r--r-- | src/synth/synth-memtype.ads | 49 | ||||
| -rw-r--r-- | src/synth/synth-objtypes.adb | 102 | ||||
| -rw-r--r-- | src/synth/synth-objtypes.ads | 27 | ||||
| -rw-r--r-- | src/synth/synth-static_oper.adb | 1 | ||||
| -rw-r--r-- | src/synth/synth-stmts.adb | 1 | ||||
| -rw-r--r-- | src/synth/synth-values.ads | 1 | ||||
| -rw-r--r-- | src/synth/synth-vhdl_aggr.adb | 1 | ||||
| -rw-r--r-- | src/synth/synth-vhdl_files.adb | 1 | ||||
| -rw-r--r-- | src/synth/synth-vhdl_heap.adb | 2 | ||||
| -rw-r--r-- | src/synth/synth-vhdl_oper.adb | 1 | 
15 files changed, 193 insertions, 124 deletions
diff --git a/src/synth/synth-expr.adb b/src/synth/synth-expr.adb index d52ab0c29..e05eee89b 100644 --- a/src/synth/synth-expr.adb +++ b/src/synth/synth-expr.adb @@ -39,6 +39,7 @@ with Netlists.Folds; use Netlists.Folds;  with Netlists.Utils; use Netlists.Utils;  with Netlists.Locations; +with Synth.Memtype; use Synth.Memtype;  with Synth.Errors; use Synth.Errors;  with Synth.Environment;  with Synth.Decls; diff --git a/src/synth/synth-ieee-numeric_std.adb b/src/synth/synth-ieee-numeric_std.adb index 39fcc0655..fd260a59b 100644 --- a/src/synth/synth-ieee-numeric_std.adb +++ b/src/synth/synth-ieee-numeric_std.adb @@ -17,6 +17,8 @@  --  along with this program.  If not, see <gnu.org/licenses>.  with Types_Utils; use Types_Utils; + +with Synth.Memtype; use Synth.Memtype;  with Synth.Errors; use Synth.Errors;  with Synth.Ieee.Std_Logic_1164; use Synth.Ieee.Std_Logic_1164; diff --git a/src/synth/synth-ieee-std_logic_1164.ads b/src/synth/synth-ieee-std_logic_1164.ads index 21919e1e7..c3670882f 100644 --- a/src/synth/synth-ieee-std_logic_1164.ads +++ b/src/synth/synth-ieee-std_logic_1164.ads @@ -17,7 +17,8 @@  --  along with this program.  If not, see <gnu.org/licenses>.  with Types; use Types; -with Synth.Objtypes; use Synth.Objtypes; + +with Synth.Memtype; use Synth.Memtype;  package Synth.Ieee.Std_Logic_1164 is diff --git a/src/synth/synth-insts.adb b/src/synth/synth-insts.adb index adb7332a6..228feef94 100644 --- a/src/synth/synth-insts.adb +++ b/src/synth/synth-insts.adb @@ -42,6 +42,7 @@ with Vhdl.Utils; use Vhdl.Utils;  with Vhdl.Errors;  with Vhdl.Ieee.Math_Real; +with Synth.Memtype; use Synth.Memtype;  with Synth.Objtypes; use Synth.Objtypes;  with Synth.Values; use Synth.Values;  with Synth.Environment; use Synth.Environment; diff --git a/src/synth/synth-memtype.adb b/src/synth/synth-memtype.adb new file mode 100644 index 000000000..46f1c308e --- /dev/null +++ b/src/synth/synth-memtype.adb @@ -0,0 +1,124 @@ +--  Values in synthesis. +--  Copyright (C) 2017 Tristan Gingold +-- +--  This file is part of GHDL. +-- +--  This program is free software: you can redistribute it and/or modify +--  it under the terms of the GNU General Public License as published by +--  the Free Software Foundation, either version 2 of the License, or +--  (at your option) any later version. +-- +--  This program is distributed in the hope that it will be useful, +--  but WITHOUT ANY WARRANTY; without even the implied warranty of +--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the +--  GNU General Public License for more details. +-- +--  You should have received a copy of the GNU General Public License +--  along with this program.  If not, see <gnu.org/licenses>. + +with System; use System; +with System.Storage_Elements; +with Ada.Unchecked_Conversion; + +package body Synth.Memtype is + +   --  For conversions use Address to avoidcompiler warnings about alignment. +   function To_Address is new Ada.Unchecked_Conversion +     (Memory_Ptr, Address); +   function To_Memory_Ptr is new Ada.Unchecked_Conversion +     (Address, Memory_Ptr); + +   function "+" (Base : Memory_Ptr; Off : Size_Type) return Memory_Ptr +   is +      use System.Storage_Elements; +   begin +      return To_Memory_Ptr (To_Address (Base) + Storage_Offset (Off)); +   end "+"; + +   type Ghdl_U8_Ptr is access all Ghdl_U8; +   function To_U8_Ptr is +      new Ada.Unchecked_Conversion (Address, Ghdl_U8_Ptr); + +   procedure Write_U8 (Mem : Memory_Ptr; Val : Ghdl_U8) is +   begin +      To_U8_Ptr (To_Address (Mem)).all := Val; +   end Write_U8; + +   function Read_U8 (Mem : Memory_Ptr) return Ghdl_U8 is +   begin +      return To_U8_Ptr (To_Address (Mem)).all; +   end Read_U8; + +      procedure Write_I32 (Mem : Memory_Ptr; Val : Ghdl_I32) +   is +      V : Ghdl_I32; +      for V'Address use To_Address (Mem); +      pragma Import (Ada, V); +   begin +      V := Val; +   end Write_I32; + +   function Read_I32 (Mem : Memory_Ptr) return Ghdl_I32 +   is +      V : Ghdl_I32; +      for V'Address use To_Address (Mem); +      pragma Import (Ada, V); +   begin +      return V; +   end Read_I32; + +   procedure Write_U32 (Mem : Memory_Ptr; Val : Ghdl_U32) +   is +      V : Ghdl_U32; +      for V'Address use To_Address (Mem); +      pragma Import (Ada, V); +   begin +      V := Val; +   end Write_U32; + +   function Read_U32 (Mem : Memory_Ptr) return Ghdl_U32 +   is +      V : Ghdl_U32; +      for V'Address use To_Address (Mem); +      pragma Import (Ada, V); +   begin +      return V; +   end Read_U32; + +   procedure Write_I64 (Mem : Memory_Ptr; Val : Ghdl_I64) +   is +      V : Ghdl_I64; +      for V'Address use To_Address (Mem); +      pragma Import (Ada, V); +   begin +      V := Val; +   end Write_I64; + +   function Read_I64 (Mem : Memory_Ptr) return Ghdl_I64 +   is +      V : Ghdl_I64; +      for V'Address use To_Address (Mem); +      pragma Import (Ada, V); +   begin +      return V; +   end Read_I64; + +   procedure Write_Fp64 (Mem : Memory_Ptr; Val : Fp64) +   is +      V : Fp64; +      for V'Address use To_Address (Mem); +      pragma Import (Ada, V); +   begin +      V := Val; +   end Write_Fp64; + +   function Read_Fp64 (Mem : Memory_Ptr) return Fp64 +   is +      V : Fp64; +      for V'Address use To_Address (Mem); +      pragma Import (Ada, V); +   begin +      return V; +   end Read_Fp64; + +end Synth.Memtype; diff --git a/src/synth/synth-memtype.ads b/src/synth/synth-memtype.ads new file mode 100644 index 000000000..5fc096e68 --- /dev/null +++ b/src/synth/synth-memtype.ads @@ -0,0 +1,49 @@ +--  Values in synthesis. +--  Copyright (C) 2017 Tristan Gingold +-- +--  This file is part of GHDL. +-- +--  This program is free software: you can redistribute it and/or modify +--  it under the terms of the GNU General Public License as published by +--  the Free Software Foundation, either version 2 of the License, or +--  (at your option) any later version. +-- +--  This program is distributed in the hope that it will be useful, +--  but WITHOUT ANY WARRANTY; without even the implied warranty of +--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the +--  GNU General Public License for more details. +-- +--  You should have received a copy of the GNU General Public License +--  along with this program.  If not, see <gnu.org/licenses>. + +with Types; use Types; + +with Grt.Types; use Grt.Types; + +package Synth.Memtype is +   type Memory_Element is mod 2**8; +   type Memory_Array is array (Size_Type range <>) of Memory_Element; + +   --  Thin pointer for a generic pointer. +   type Memory_Ptr is access all Memory_Array (Size_Type); +   pragma No_Strict_Aliasing (Memory_Ptr); + +   --  Low-level functions. + +   function "+" (Base : Memory_Ptr; Off : Size_Type) return Memory_Ptr; + +   procedure Write_U8 (Mem : Memory_Ptr; Val : Ghdl_U8); +   function Read_U8 (Mem : Memory_Ptr) return Ghdl_U8; + +   procedure Write_U32 (Mem : Memory_Ptr; Val : Ghdl_U32); +   function Read_U32 (Mem : Memory_Ptr) return Ghdl_U32; + +   procedure Write_I32 (Mem : Memory_Ptr; Val : Ghdl_I32); +   function Read_I32 (Mem : Memory_Ptr) return Ghdl_I32; + +   procedure Write_I64 (Mem : Memory_Ptr; Val : Ghdl_I64); +   function Read_I64 (Mem : Memory_Ptr) return Ghdl_I64; + +   procedure Write_Fp64 (Mem : Memory_Ptr; Val : Fp64); +   function Read_Fp64 (Mem : Memory_Ptr) return Fp64; +end Synth.Memtype; diff --git a/src/synth/synth-objtypes.adb b/src/synth/synth-objtypes.adb index 1eeaa3e74..036c4151d 100644 --- a/src/synth/synth-objtypes.adb +++ b/src/synth/synth-objtypes.adb @@ -18,7 +18,6 @@  with Ada.Unchecked_Conversion;  with System; use System; -with System.Storage_Elements;  with Mutils; use Mutils; @@ -613,26 +612,6 @@ package body Synth.Objtypes is        end case;     end Is_Matching_Bounds; -   --  For conversions use Address to avoidcompiler warnings about alignment. -   function To_Address is new Ada.Unchecked_Conversion -     (Memory_Ptr, Address); -   function To_Memory_Ptr is new Ada.Unchecked_Conversion -     (Address, Memory_Ptr); - -   type Ghdl_U8_Ptr is access all Ghdl_U8; -   function To_U8_Ptr is -      new Ada.Unchecked_Conversion (Address, Ghdl_U8_Ptr); - -   procedure Write_U8 (Mem : Memory_Ptr; Val : Ghdl_U8) is -   begin -      To_U8_Ptr (To_Address (Mem)).all := Val; -   end Write_U8; - -   function Read_U8 (Mem : Memory_Ptr) return Ghdl_U8 is -   begin -      return To_U8_Ptr (To_Address (Mem)).all; -   end Read_U8; -     function Read_U8 (Mt : Memtyp) return Ghdl_U8     is        pragma Assert (Mt.Typ.Sz = 1); @@ -640,90 +619,12 @@ package body Synth.Objtypes is        return Read_U8 (Mt.Mem);     end Read_U8; -   procedure Write_I32 (Mem : Memory_Ptr; Val : Ghdl_I32) -   is -      V : Ghdl_I32; -      for V'Address use To_Address (Mem); -      pragma Import (Ada, V); -   begin -      V := Val; -   end Write_I32; - -   function Read_I32 (Mem : Memory_Ptr) return Ghdl_I32 -   is -      V : Ghdl_I32; -      for V'Address use To_Address (Mem); -      pragma Import (Ada, V); -   begin -      return V; -   end Read_I32; - -   procedure Write_U32 (Mem : Memory_Ptr; Val : Ghdl_U32) -   is -      V : Ghdl_U32; -      for V'Address use To_Address (Mem); -      pragma Import (Ada, V); -   begin -      V := Val; -   end Write_U32; - -   function Read_U32 (Mem : Memory_Ptr) return Ghdl_U32 -   is -      V : Ghdl_U32; -      for V'Address use To_Address (Mem); -      pragma Import (Ada, V); -   begin -      return V; -   end Read_U32; - -   procedure Write_I64 (Mem : Memory_Ptr; Val : Ghdl_I64) -   is -      V : Ghdl_I64; -      for V'Address use To_Address (Mem); -      pragma Import (Ada, V); -   begin -      V := Val; -   end Write_I64; - -   function Read_I64 (Mem : Memory_Ptr) return Ghdl_I64 -   is -      V : Ghdl_I64; -      for V'Address use To_Address (Mem); -      pragma Import (Ada, V); -   begin -      return V; -   end Read_I64; - -   procedure Write_Fp64 (Mem : Memory_Ptr; Val : Fp64) -   is -      V : Fp64; -      for V'Address use To_Address (Mem); -      pragma Import (Ada, V); -   begin -      V := Val; -   end Write_Fp64; - -   function Read_Fp64 (Mem : Memory_Ptr) return Fp64 -   is -      V : Fp64; -      for V'Address use To_Address (Mem); -      pragma Import (Ada, V); -   begin -      return V; -   end Read_Fp64;     function Read_Fp64 (Mt : Memtyp) return Fp64 is     begin        return Read_Fp64 (Mt.Mem);     end Read_Fp64; -   function "+" (Base : Memory_Ptr; Off : Size_Type) return Memory_Ptr -   is -      use System.Storage_Elements; -   begin -      return To_Memory_Ptr (To_Address (Base) + Storage_Offset (Off)); -   end "+"; -     function Read_Discrete (Mt : Memtyp) return Int64 is     begin        case Mt.Typ.Sz is @@ -859,6 +760,9 @@ package body Synth.Objtypes is     Bit0_Mem : constant Memory_Element := 0;     Bit1_Mem : constant Memory_Element := 1; +   function To_Memory_Ptr is new Ada.Unchecked_Conversion +     (Address, Memory_Ptr); +     procedure Init is     begin        Instance_Pool := Global_Pool'Access; diff --git a/src/synth/synth-objtypes.ads b/src/synth/synth-objtypes.ads index 93d277164..91c26327e 100644 --- a/src/synth/synth-objtypes.ads +++ b/src/synth/synth-objtypes.ads @@ -23,6 +23,8 @@ with Netlists; use Netlists;  with Grt.Types; use Grt.Types; +with Synth.Memtype; use Synth.Memtype; +  with Vhdl.Nodes; use Vhdl.Nodes;  package Synth.Objtypes is @@ -163,13 +165,6 @@ package Synth.Objtypes is        end case;     end record; -   type Memory_Element is mod 2**8; -   type Memory_Array is array (Size_Type range <>) of Memory_Element; - -   --  Thin pointer for a generic pointer. -   type Memory_Ptr is access all Memory_Array (Size_Type); -   pragma No_Strict_Aliasing (Memory_Ptr); -     type Memtyp is record        Typ : Type_Acc;        Mem : Memory_Ptr; @@ -258,25 +253,9 @@ package Synth.Objtypes is     function Get_Type_Width (Atype : Type_Acc) return Width; -   --  Low-level functions. - -   function "+" (Base : Memory_Ptr; Off : Size_Type) return Memory_Ptr; +   --  Low-level functions -   procedure Write_U8 (Mem : Memory_Ptr; Val : Ghdl_U8); -   function Read_U8 (Mem : Memory_Ptr) return Ghdl_U8;     function Read_U8 (Mt : Memtyp) return Ghdl_U8; - -   procedure Write_U32 (Mem : Memory_Ptr; Val : Ghdl_U32); -   function Read_U32 (Mem : Memory_Ptr) return Ghdl_U32; - -   procedure Write_I32 (Mem : Memory_Ptr; Val : Ghdl_I32); -   function Read_I32 (Mem : Memory_Ptr) return Ghdl_I32; - -   procedure Write_I64 (Mem : Memory_Ptr; Val : Ghdl_I64); -   function Read_I64 (Mem : Memory_Ptr) return Ghdl_I64; - -   procedure Write_Fp64 (Mem : Memory_Ptr; Val : Fp64); -   function Read_Fp64 (Mem : Memory_Ptr) return Fp64;     function Read_Fp64 (Mt : Memtyp) return Fp64;     procedure Write_Discrete (Mem : Memory_Ptr; Typ : Type_Acc; Val : Int64); diff --git a/src/synth/synth-static_oper.adb b/src/synth/synth-static_oper.adb index 80ec64b76..5c9db02e9 100644 --- a/src/synth/synth-static_oper.adb +++ b/src/synth/synth-static_oper.adb @@ -26,6 +26,7 @@ with Vhdl.Ieee.Std_Logic_1164; use Vhdl.Ieee.Std_Logic_1164;  with Netlists; use Netlists; +with Synth.Memtype; use Synth.Memtype;  with Synth.Errors; use Synth.Errors;  with Synth.Source; use Synth.Source;  with Synth.Expr; use Synth.Expr; diff --git a/src/synth/synth-stmts.adb b/src/synth/synth-stmts.adb index bc7c7f4a4..c77fc92be 100644 --- a/src/synth/synth-stmts.adb +++ b/src/synth/synth-stmts.adb @@ -39,6 +39,7 @@ with Vhdl.Ieee.Std_Logic_1164;  with PSL.Types;  with PSL.NFAs; +with Synth.Memtype; use Synth.Memtype;  with Synth.Errors; use Synth.Errors;  with Synth.Decls; use Synth.Decls;  with Synth.Expr; use Synth.Expr; diff --git a/src/synth/synth-values.ads b/src/synth/synth-values.ads index 33cb58b59..6094509d1 100644 --- a/src/synth/synth-values.ads +++ b/src/synth/synth-values.ads @@ -25,6 +25,7 @@ with Grt.Files_Operations;  with Netlists; use Netlists; +with Synth.Memtype; use Synth.Memtype;  with Synth.Objtypes; use Synth.Objtypes;  with Synth.Environment; use Synth.Environment;  with Synth.Source; use Synth.Source; diff --git a/src/synth/synth-vhdl_aggr.adb b/src/synth/synth-vhdl_aggr.adb index 6863924f0..250ebb1aa 100644 --- a/src/synth/synth-vhdl_aggr.adb +++ b/src/synth/synth-vhdl_aggr.adb @@ -26,6 +26,7 @@ with Netlists.Builders; use Netlists.Builders;  with Vhdl.Errors; use Vhdl.Errors;  with Vhdl.Utils; use Vhdl.Utils; +with Synth.Memtype; use Synth.Memtype;  with Synth.Errors; use Synth.Errors;  with Synth.Expr; use Synth.Expr;  with Synth.Stmts; use Synth.Stmts; diff --git a/src/synth/synth-vhdl_files.adb b/src/synth/synth-vhdl_files.adb index e9015afaf..180062e01 100644 --- a/src/synth/synth-vhdl_files.adb +++ b/src/synth/synth-vhdl_files.adb @@ -24,6 +24,7 @@ with Grt.Types; use Grt.Types;  with Grt.Files_Operations; use Grt.Files_Operations;  with Grt.Stdio; +with Synth.Memtype; use Synth.Memtype;  with Synth.Objtypes; use Synth.Objtypes;  with Synth.Expr; use Synth.Expr;  with Synth.Errors; use Synth.Errors; diff --git a/src/synth/synth-vhdl_heap.adb b/src/synth/synth-vhdl_heap.adb index 5270c99e0..6ab9af3e5 100644 --- a/src/synth/synth-vhdl_heap.adb +++ b/src/synth/synth-vhdl_heap.adb @@ -20,6 +20,8 @@ with Types; use Types;  with Tables; +with Synth.Memtype; use Synth.Memtype; +  package body Synth.Vhdl_Heap is     package Heap_Table is new Tables diff --git a/src/synth/synth-vhdl_oper.adb b/src/synth/synth-vhdl_oper.adb index 9aaf725d1..0a3075b94 100644 --- a/src/synth/synth-vhdl_oper.adb +++ b/src/synth/synth-vhdl_oper.adb @@ -32,6 +32,7 @@ with Netlists.Builders; use Netlists.Builders;  with Netlists.Folds; use Netlists.Folds;  with Netlists.Utils; +with Synth.Memtype; use Synth.Memtype;  with Synth.Errors; use Synth.Errors;  with Synth.Stmts; use Synth.Stmts;  with Synth.Expr; use Synth.Expr;  | 
