aboutsummaryrefslogtreecommitdiffstats
path: root/src/synth/netlists-inference.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-05-29 18:43:42 +0200
committerTristan Gingold <tgingold@free.fr>2020-05-29 18:56:33 +0200
commitd3939d44c07dcdb8c80b522269126392c72c9505 (patch)
tree8fe166d0687c44c4aa29a9569496ed57498a2681 /src/synth/netlists-inference.adb
parent36cf92801b25119b12b300eef517e7e85c796efb (diff)
downloadghdl-d3939d44c07dcdb8c80b522269126392c72c9505.tar.gz
ghdl-d3939d44c07dcdb8c80b522269126392c72c9505.tar.bz2
ghdl-d3939d44c07dcdb8c80b522269126392c72c9505.zip
netlists: rework clock handling in memories.
Diffstat (limited to 'src/synth/netlists-inference.adb')
-rw-r--r--src/synth/netlists-inference.adb37
1 files changed, 20 insertions, 17 deletions
diff --git a/src/synth/netlists-inference.adb b/src/synth/netlists-inference.adb
index 936bb4f23..700cf09ba 100644
--- a/src/synth/netlists-inference.adb
+++ b/src/synth/netlists-inference.adb
@@ -457,25 +457,28 @@ package body Netlists.Inference is
and then Can_Infere_RAM (Data, Prev_Val)
then
-- Maybe it is a RAM.
- Ndata := Infere_RAM (Ctxt, Data, Clk_Enable);
- elsif Clk_Enable /= No_Net then
- -- If there is a condition with the clock, that's an enable which
- -- keep the previous value if the condition is false. Add the mux
- -- for it.
- declare
- Prev : Net;
- begin
- Prev := Build2_Extract (Ctxt, Prev_Val, Off, Get_Width (Data));
-
- Ndata := Build_Mux2 (Ctxt, Clk_Enable, Prev, Data);
- Copy_Location (Ndata, Clk_Enable);
- end;
+ Res := Infere_RAM (Ctxt, Data, Clk, Clk_Enable);
else
- Ndata := Data;
- end if;
+ if Clk_Enable /= No_Net then
+ -- If there is a condition with the clock, that's an enable which
+ -- keep the previous value if the condition is false. Add the mux
+ -- for it, to create a synchronous enable.
+ declare
+ Prev : Net;
+ begin
+ Prev := Build2_Extract (Ctxt, Prev_Val, Off, Get_Width (Data));
+
+ Ndata := Build_Mux2 (Ctxt, Clk_Enable, Prev, Data);
+ Copy_Location (Ndata, Clk_Enable);
+ end;
+ else
+ Ndata := Data;
+ end if;
- -- Create the FF.
- Res := Infere_FF_Create (Ctxt, Rst, Rst_Val, Init, Clk, Ndata, Els, Loc);
+ -- Create the FF.
+ Res := Infere_FF_Create (Ctxt, Rst, Rst_Val,
+ Init, Clk, Ndata, Els, Loc);
+ end if;
-- The output may already be used (if the target is a variable that
-- is read). So redirect the net.