Skip to content

Commit

Permalink
first commit of rst_polarity switch to boolean; only touch the files …
Browse files Browse the repository at this point in the history
…used by the asic synthesis tool for now
  • Loading branch information
My Name committed Jun 3, 2024
1 parent 265b083 commit 944d8f5
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 78 deletions.
8 changes: 4 additions & 4 deletions base/fifo/rtl/FifoOutputPipeline.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use surf.StdRtlPkg.all;
entity FifoOutputPipeline is
generic (
TPD_G : time := 1 ns;
RST_POLARITY_G : sl := '1'; -- '1' for active high rst, '0' for active low
RST_POLARITY_G : boolean := true; -- true for active high rst, false for active low
RST_ASYNC_G : boolean := false;
DATA_WIDTH_G : integer range 1 to (2**24) := 16;
PIPE_STAGES_G : natural range 0 to 16 := 1);
Expand All @@ -37,7 +37,7 @@ entity FifoOutputPipeline is
mRdEn : in sl;
-- Clock and Reset
clk : in sl;
rst : in sl := not RST_POLARITY_G); -- Optional reset
rst : in sl := not toSl(RST_POLARITY_G)); -- Optional reset
end FifoOutputPipeline;

architecture rtl of FifoOutputPipeline is
Expand Down Expand Up @@ -143,7 +143,7 @@ begin
end if;

-- Synchronous Reset
if (RST_ASYNC_G = false and rst = RST_POLARITY_G) then
if (RST_ASYNC_G = false and rst = toSl(RST_POLARITY_G)) then
v := REG_INIT_C;
end if;

Expand All @@ -159,7 +159,7 @@ begin

seq : process (clk, rst) is
begin
if (RST_ASYNC_G and rst = RST_POLARITY_G) then
if (RST_ASYNC_G and rst = toSl(RST_POLARITY_G)) then
r <= REG_INIT_C after TPD_G;
elsif rising_edge(clk) then
r <= rin after TPD_G;
Expand Down
2 changes: 1 addition & 1 deletion base/fifo/rtl/inferred/FifoAsync.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use surf.StdRtlPkg.all;
entity FifoAsync is
generic (
TPD_G : time := 1 ns;
RST_POLARITY_G : sl := '1'; -- '1' for active high rst, '0' for active low
RST_POLARITY_G : boolean := true; -- true for active high rst, false for active low
RST_ASYNC_G : boolean := false;
MEMORY_TYPE_G : string := "block";
BYP_RAM_G : boolean := false;
Expand Down
6 changes: 3 additions & 3 deletions base/fifo/rtl/inferred/FifoRdFsm.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use surf.StdRtlPkg.all;
entity FifoRdFsm is
generic (
TPD_G : time := 1 ns;
RST_POLARITY_G : sl := '1'; -- '1' for active high rst, '0' for active low
RST_POLARITY_G : boolean := true; -- true for active high rst, false for active low
RST_ASYNC_G : boolean := false;
FIFO_ASYNC_G : boolean := false;
MEMORY_TYPE_G : string := "block";
Expand Down Expand Up @@ -298,7 +298,7 @@ begin
ASYNC_RST : if (RST_ASYNC_G) generate
seq : process (rd_clk, rst) is
begin
if (rst = RST_POLARITY_G) then
if (rst = toSl(RST_POLARITY_G)) then
r <= REG_INIT_C after TPD_G;
elsif (rising_edge(rd_clk)) then
r <= rin after TPD_G;
Expand All @@ -310,7 +310,7 @@ begin
seq : process (rd_clk) is
begin
if (rising_edge(rd_clk)) then
if (rst = RST_POLARITY_G) then
if (rst = toSl(RST_POLARITY_G)) then
r <= REG_INIT_C after TPD_G;
else
r <= rin after TPD_G;
Expand Down
4 changes: 2 additions & 2 deletions base/fifo/rtl/inferred/FifoSync.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use surf.StdRtlPkg.all;
entity FifoSync is
generic (
TPD_G : time := 1 ns;
RST_POLARITY_G : sl := '1'; -- '1' for active high rst, '0' for active low
RST_POLARITY_G : boolean := true; -- true for active high rst, false for active low
RST_ASYNC_G : boolean := false;
MEMORY_TYPE_G : string := "block";
BYP_RAM_G : boolean := false;
Expand All @@ -35,7 +35,7 @@ entity FifoSync is
FULL_THRES_G : positive := 1;
EMPTY_THRES_G : positive := 1);
port (
rst : in sl := not RST_POLARITY_G;
rst : in sl := not toSl(RST_POLARITY_G);
clk : in sl;
wr_en : in sl;
rd_en : in sl;
Expand Down
6 changes: 3 additions & 3 deletions base/fifo/rtl/inferred/FifoWrFsm.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use surf.StdRtlPkg.all;
entity FifoWrFsm is
generic (
TPD_G : time := 1 ns;
RST_POLARITY_G : sl := '1'; -- '1' for active high rst, '0' for active low
RST_POLARITY_G : boolean := true; -- true for active high rst, false for active low
RST_ASYNC_G : boolean := false;
FIFO_ASYNC_G : boolean := false;
DATA_WIDTH_G : positive := 16;
Expand Down Expand Up @@ -214,7 +214,7 @@ begin
ASYNC_RST : if (RST_ASYNC_G) generate
seq : process (rst, wr_clk) is
begin
if (rst = RST_POLARITY_G) then
if (rst = toSl(RST_POLARITY_G)) then
r <= REG_INIT_C after TPD_G;
elsif (rising_edge(wr_clk)) then
r <= rin after TPD_G;
Expand All @@ -226,7 +226,7 @@ begin
seq : process (wr_clk) is
begin
if (rising_edge(wr_clk)) then
if (rst = RST_POLARITY_G) then
if (rst = toSl(RST_POLARITY_G)) then
r <= REG_INIT_C after TPD_G;
else
r <= rin after TPD_G;
Expand Down
8 changes: 4 additions & 4 deletions base/ram/inferred/SimpleDualPortRam.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use surf.StdRtlPkg.all;
entity SimpleDualPortRam is
generic (
TPD_G : time := 1 ns;
RST_POLARITY_G : sl := '1'; -- '1' for active high rst, '0' for active low
RST_POLARITY_G : boolean := true; -- true for active high rst, false for active low
RST_ASYNC_G : boolean := false;
MEMORY_TYPE_G : string := "block";
DOB_REG_G : boolean := false; -- Extra reg on doutb (folded into BRAM)
Expand All @@ -44,7 +44,7 @@ entity SimpleDualPortRam is
clkb : in sl := '0';
enb : in sl := '1';
regceb : in sl := '1';
rstb : in sl := not(RST_POLARITY_G);
rstb : in sl := not(toSl(RST_POLARITY_G));
addrb : in slv(ADDR_WIDTH_G-1 downto 0) := (others => '0');
doutb : out slv(DATA_WIDTH_G-1 downto 0));
end SimpleDualPortRam;
Expand Down Expand Up @@ -105,10 +105,10 @@ begin
-- Port B
process(clkb, rstb)
begin
if (RST_ASYNC_G and rstb = RST_POLARITY_G) then
if (RST_ASYNC_G and rstb = toSl(RST_POLARITY_G)) then
doutbInt <= INIT_C after TPD_G;
elsif rising_edge(clkb) then
if (RST_ASYNC_G = false and rstb = RST_POLARITY_G) then
if (RST_ASYNC_G = false and rstb = toSl(RST_POLARITY_G)) then
doutbInt <= INIT_C after TPD_G;
elsif enb = '1' then
doutBInt <= mem(conv_integer(addrb)) after TPD_G;
Expand Down
14 changes: 7 additions & 7 deletions base/sync/rtl/RstSync.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ use surf.StdRtlPkg.all;
entity RstSync is
generic (
TPD_G : time := 1 ns; -- Simulation FF output delay
IN_POLARITY_G : sl := '1'; -- 0 for active low rst, 1 for high
OUT_POLARITY_G : sl := '1';
IN_POLARITY_G : boolean := true; -- false for active low rst, true for high
OUT_POLARITY_G : boolean := true;
BYPASS_SYNC_G : boolean := false; -- Bypass Synchronizer module for synchronous data configuration
RELEASE_DELAY_G : integer range 3 to positive'high := 3; -- Delay between deassertion of async and sync resets
OUT_REG_RST_G : boolean := true); -- Apply async reset to final reg stage
Expand All @@ -35,7 +35,7 @@ end RstSync;

architecture rtl of RstSync is

signal syncInt : sl := OUT_POLARITY_G;
signal syncInt : sl := toSl(OUT_POLARITY_G);

begin

Expand All @@ -49,18 +49,18 @@ begin
RST_ASYNC_G => true,
STAGES_G => RELEASE_DELAY_G-1,
BYPASS_SYNC_G => BYPASS_SYNC_G,
INIT_G => slvAll(RELEASE_DELAY_G-1, OUT_POLARITY_G))
INIT_G => slvAll(RELEASE_DELAY_G-1, toSl(OUT_POLARITY_G)))
port map (
clk => clk,
rst => asyncRst,
dataIn => not OUT_POLARITY_G,
dataIn => not toSl(OUT_POLARITY_G),
dataOut => syncInt);

-- Final stage does not have async constraints applied, can be duplicated to ease timing
OUT_REG : process (clk, asyncRst) is
begin
if (asyncRst = IN_POLARITY_G and OUT_REG_RST_G) then
syncRst <= OUT_POLARITY_G after TPD_G;
if (asyncRst = toSl(IN_POLARITY_G) and OUT_REG_RST_G) then
syncRst <= toSl(OUT_POLARITY_G) after TPD_G;
elsif (rising_edge(clk)) then
syncRst <= syncInt after TPD_G;
end if;
Expand Down
20 changes: 10 additions & 10 deletions base/sync/rtl/Synchronizer.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ use surf.StdRtlPkg.all;
entity Synchronizer is
generic (
TPD_G : time := 1 ns;
RST_POLARITY_G : sl := '1'; -- '1' for active HIGH reset, '0' for active LOW reset
OUT_POLARITY_G : sl := '1'; -- 0 for active LOW, 1 for active HIGH
RST_POLARITY_G : boolean := true; -- true for active HIGH reset, false for active LOW reset
OUT_POLARITY_G : boolean := true; -- false for active LOW, true for active HIGH
RST_ASYNC_G : boolean := false; -- Reset is asynchronous
STAGES_G : positive := 2;
BYPASS_SYNC_G : boolean := false; -- Bypass Synchronizer module for synchronous data configuration
INIT_G : slv := "0");
port (
clk : in sl; -- clock to be SYNC'd to
rst : in sl := not RST_POLARITY_G; -- Optional reset
dataIn : in sl; -- Data to be 'synced'
dataOut : out sl); -- synced data
clk : in sl; -- clock to be SYNC'd to
rst : in sl := not toSl(RST_POLARITY_G); -- Optional reset
dataIn : in sl; -- Data to be 'synced'
dataOut : out sl); -- synced data
end Synchronizer;

architecture rtl of Synchronizer is
Expand Down Expand Up @@ -83,7 +83,7 @@ begin
begin
rin <= crossDomainSyncReg(STAGES_G-2 downto 0) & dataIn;

if (OUT_POLARITY_G = '1') then
if (OUT_POLARITY_G) then
dataOut <= crossDomainSyncReg(STAGES_G-1);
else
dataOut <= not(crossDomainSyncReg(STAGES_G-1));
Expand All @@ -97,7 +97,7 @@ begin
if (rising_edge(clk)) then
crossDomainSyncReg <= rin after TPD_G;
end if;
if (rst = RST_POLARITY_G) then
if (rst = toSl(RST_POLARITY_G)) then
crossDomainSyncReg <= INIT_C after TPD_G;
end if;
end process seq;
Expand All @@ -107,7 +107,7 @@ begin
seq : process (clk) is
begin
if (rising_edge(clk)) then
if (rst = RST_POLARITY_G) then
if (rst = toSl(RST_POLARITY_G)) then
crossDomainSyncReg <= INIT_C after TPD_G;
else
crossDomainSyncReg <= rin after TPD_G;
Expand All @@ -120,7 +120,7 @@ begin

BYPASS : if (BYPASS_SYNC_G = true) generate

dataOut <= dataIn when(OUT_POLARITY_G = '1') else not(dataIn);
dataOut <= dataIn when(OUT_POLARITY_G) else not(dataIn);

end generate;

Expand Down
38 changes: 19 additions & 19 deletions base/sync/rtl/SynchronizerEdge.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ use surf.StdRtlPkg.all;
entity SynchronizerEdge is
generic (
TPD_G : time := 1 ns;
RST_POLARITY_G : sl := '1'; -- '1' for active HIGH reset, '0' for active LOW reset
OUT_POLARITY_G : sl := '1'; -- 0 for active LOW, 1 for active HIGH
RST_POLARITY_G : boolean := true; -- true for active HIGH reset, false for active LOW reset
OUT_POLARITY_G : boolean := true; -- false for active LOW, true for active HIGH
RST_ASYNC_G : boolean := false; -- Reset is asynchronous
BYPASS_SYNC_G : boolean := false; -- Bypass Synchronizer module for synchronous data configuration
STAGES_G : positive := 3;
INIT_G : slv := "0");
port (
clk : in sl; -- clock to be SYNC'd to
rst : in sl := not RST_POLARITY_G; -- Optional reset
dataIn : in sl; -- Data to be 'synced'
dataOut : out sl; -- synced data
risingEdge : out sl; -- Rising edge detected
fallingEdge : out sl); -- Falling edge detected
clk : in sl; -- clock to be SYNC'd to
rst : in sl := not toSl(RST_POLARITY_G); -- Optional reset
dataIn : in sl; -- Data to be 'synced'
dataOut : out sl; -- synced data
risingEdge : out sl; -- Rising edge detected
fallingEdge : out sl); -- Falling edge detected
end SynchronizerEdge;

architecture rtl of SynchronizerEdge is
Expand All @@ -48,9 +48,9 @@ architecture rtl of SynchronizerEdge is
end record RegType;
constant REG_INIT_C : RegType := (
syncDataDly => '0',
dataOut => (not OUT_POLARITY_G),
risingEdge => (not OUT_POLARITY_G),
fallingEdge => (not OUT_POLARITY_G));
dataOut => (not toSl(OUT_POLARITY_G)),
risingEdge => (not toSl(OUT_POLARITY_G)),
fallingEdge => (not toSl(OUT_POLARITY_G)));

signal r : RegType := REG_INIT_C;
signal rin : RegType;
Expand All @@ -65,7 +65,7 @@ begin
generic map (
TPD_G => TPD_G,
RST_POLARITY_G => RST_POLARITY_G,
OUT_POLARITY_G => '1',
OUT_POLARITY_G => true,
RST_ASYNC_G => RST_ASYNC_G,
STAGES_G => (STAGES_G-1),
BYPASS_SYNC_G => BYPASS_SYNC_G,
Expand All @@ -83,31 +83,31 @@ begin
v := r;

-- Reset strobe signals
v.risingEdge := not OUT_POLARITY_G;
v.fallingEdge := not OUT_POLARITY_G;
v.risingEdge := not toSl(OUT_POLARITY_G);
v.fallingEdge := not toSl(OUT_POLARITY_G);

-- Keep a record of the last syncData
v.syncDataDly := syncData;

-- Set the polarity of the output
if (OUT_POLARITY_G = '1') then
if (OUT_POLARITY_G) then
v.dataOut := syncData;
else
v.dataOut := not(syncData);
end if;

-- Check for a rising edge of the syncData
if (syncData = '1') and (r.syncDataDly = '0') then
v.risingEdge := OUT_POLARITY_G;
v.risingEdge := toSl(OUT_POLARITY_G);
end if;

-- Check for a rising edge of the syncData
if (syncData = '0') and (r.syncDataDly = '1') then
v.fallingEdge := OUT_POLARITY_G;
v.fallingEdge := toSl(OUT_POLARITY_G);
end if;

-- Sync Reset
if (RST_ASYNC_G = false and rst = RST_POLARITY_G) then
if (RST_ASYNC_G = false and rst = toSl(RST_POLARITY_G)) then
v := REG_INIT_C;
v.syncDataDly := syncData; -- prevent accidental edge detection
end if;
Expand All @@ -128,7 +128,7 @@ begin
r <= rin after TPD_G;
end if;
-- Async Reset
if (RST_ASYNC_G and rst = RST_POLARITY_G) then
if (RST_ASYNC_G and rst = toSl(RST_POLARITY_G)) then
r <= REG_INIT_C after TPD_G;
r.syncDataDly <= syncData after TPD_G; -- prevent accidental edge detection
end if;
Expand Down
Loading

0 comments on commit 944d8f5

Please sign in to comment.