aboutsummaryrefslogtreecommitdiffstats
path: root/src/synth/netlists-memories.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-02-11 07:50:01 +0100
committerTristan Gingold <tgingold@free.fr>2020-02-11 07:50:01 +0100
commit77e18685a451b61e435cfa95a66a45475ccd053d (patch)
tree45cd8e7c00ff704d45bd3dfc24aa14cccd4202ff /src/synth/netlists-memories.adb
parent91516ee5a7b0910d6728d22936e3f669a877e7b8 (diff)
downloadghdl-77e18685a451b61e435cfa95a66a45475ccd053d.tar.gz
ghdl-77e18685a451b61e435cfa95a66a45475ccd053d.tar.bz2
ghdl-77e18685a451b61e435cfa95a66a45475ccd053d.zip
netlists-memories: handle split memories. Fix #1127
Diffstat (limited to 'src/synth/netlists-memories.adb')
-rw-r--r--src/synth/netlists-memories.adb26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/synth/netlists-memories.adb b/src/synth/netlists-memories.adb
index 93e7ebfdb..7c7a5e4f1 100644
--- a/src/synth/netlists-memories.adb
+++ b/src/synth/netlists-memories.adb
@@ -1154,8 +1154,14 @@ package body Netlists.Memories is
Nbr_Ports : Int32;
Inst : Instance;
+ -- Table of offsets.
+ -- The same RAM can be partially read or written: not all the bits of
+ -- the data bus are read or written. The RAM is split in several
+ -- sub-rams which are fully read/written.
+ -- This table will contain the offset of each sub-rams.
Offs : Off_Array_Acc;
Nbr_Offs : Int32;
+
Heads : Net_Array_Acc;
Tails : Net_Array_Acc;
Outs : Net_Array_Acc;
@@ -1277,7 +1283,7 @@ package body Netlists.Memories is
end;
end loop;
- -- 2.1 Sort
+ -- 2.1 Sort the offsets.
declare
function Lt (Op1, Op2 : Natural) return Boolean is
begin
@@ -1295,12 +1301,14 @@ package body Netlists.Memories is
procedure Heap_Sort is new Grt.Algos.Heap_Sort
(Lt => Lt, Swap => Swap);
-
- P : Nat32;
begin
Heap_Sort (Natural (Nbr_Offs));
+ end;
- -- Remove duplicates.
+ -- 2.2 Remove duplicates.
+ declare
+ P : Nat32;
+ begin
P := 1;
for I in 2 .. Nbr_Offs loop
if Offs (I) /= Offs (P) then
@@ -1478,14 +1486,16 @@ package body Netlists.Memories is
if En = No_Net then
En := Build_Const_UB32 (Ctxt, 1, 1);
end if;
+ Inp2 := Get_Input (Inst, 1);
+ Dat := Get_Driver (Inp2);
for I in Idx .. Idx + Len - 1 loop
- Inp2 := Get_Input (Inst, 1);
- Dat := Get_Driver (Inp2);
Wr_Inst := Build_Mem_Wr_Sync
- (Ctxt, Tails (I), Addr, Clk, En, Dat);
- Disconnect (Inp2);
+ (Ctxt, Tails (I), Addr, Clk, En,
+ Build2_Extract (Ctxt, Dat, Offs (I) - Offs (Idx),
+ Offs (I + 1) - Offs (I)));
Tails (I) := Get_Output (Wr_Inst, 0);
end loop;
+ Disconnect (Inp2);
end;
Remove_Instance (Inst);
when Id_Dff