- reworked FIFOs
- use synchronous resets git-svn-id: http://moon:8086/svn/vhdl/trunk@1090 cc03376c-175c-47c8-b038-4cd826a8556b
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
vlib work
|
vlib work
|
||||||
vcom -explicit -93 "../src/fifo_ctrl_pkg.vhd"
|
vcom -explicit -93 "../src/fifo_ctrl_pkg.vhd"
|
||||||
vcom -explicit -93 "../src/gray_counter.vhd"
|
vcom -explicit -93 "../src/gray_counter.vhd"
|
||||||
vcom -explicit -93 "../../rams/dpram_1w1r2c_ro_sim.vhd"
|
vcom -explicit -93 "../../rams/dpram_1w1r2c_ra_sim.vhd"
|
||||||
vcom -explicit -93 "../src/fifo_async_ctrl.vhd"
|
vcom -explicit -93 "../src/fifo_async_ctrl.vhd"
|
||||||
vcom -explicit -93 "../src/fifo_async.vhd"
|
vcom -explicit -93 "../src/fifo_async.vhd"
|
||||||
vcom -explicit -93 "../src/tb_fifo_async.vhd"
|
vcom -explicit -93 "../src/tb_fifo_async.vhd"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
##
|
##
|
||||||
vlib work
|
vlib work
|
||||||
vcom -explicit -93 "../src/fifo_ctrl_pkg.vhd"
|
vcom -explicit -93 "../src/fifo_ctrl_pkg.vhd"
|
||||||
vcom -explicit -93 "../../rams/dpram_1w1r2c_ro_sim.vhd"
|
vcom -explicit -93 "../../rams/dpram_1w1r2c_ra_sim.vhd"
|
||||||
vcom -explicit -93 "../src/fifo_sync_ctrl.vhd"
|
vcom -explicit -93 "../src/fifo_sync_ctrl.vhd"
|
||||||
vcom -explicit -93 "../src/fifo_sync.vhd"
|
vcom -explicit -93 "../src/fifo_sync.vhd"
|
||||||
vcom -explicit -93 "../src/tb_fifo_sync.vhd"
|
vcom -explicit -93 "../src/tb_fifo_sync.vhd"
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ architecture Behavioral of fifo_async_ctrl is
|
|||||||
|
|
||||||
signal pre_empty, pre_full : std_logic;
|
signal pre_empty, pre_full : std_logic;
|
||||||
signal full, empty : std_logic;
|
signal full, empty : std_logic;
|
||||||
|
signal rst_w, rst_r : std_logic;
|
||||||
|
|
||||||
-- synthesis translate_off
|
-- synthesis translate_off
|
||||||
signal diffw : signed (addr_width downto 0);
|
signal diffw : signed (addr_width downto 0);
|
||||||
@@ -85,25 +86,45 @@ begin
|
|||||||
fifo_empty <= empty;
|
fifo_empty <= empty;
|
||||||
fifo_pre_full <= pre_full;
|
fifo_pre_full <= pre_full;
|
||||||
fifo_pre_empty <= pre_empty;
|
fifo_pre_empty <= pre_empty;
|
||||||
|
|
||||||
|
sync_reset_w:
|
||||||
|
process(clk_w)
|
||||||
|
begin
|
||||||
|
if rising_edge(clk_w) then
|
||||||
|
rst_w <= rst;
|
||||||
|
end if;
|
||||||
|
end process;
|
||||||
|
|
||||||
|
sync_reset_r:
|
||||||
|
process(clk_r)
|
||||||
|
begin
|
||||||
|
if rising_edge(clk_r) then
|
||||||
|
rst_r <= rst;
|
||||||
|
end if;
|
||||||
|
end process;
|
||||||
|
|
||||||
proc_write_inhibit:
|
proc_write_inhibit:
|
||||||
process(rst, clk_w)
|
process(clk_w)
|
||||||
begin
|
begin
|
||||||
if rst = '1' then
|
if rising_edge(clk_w) then
|
||||||
full <= '0';
|
if rst_w = '1' then
|
||||||
elsif rising_edge(clk_w) then
|
full <= '0';
|
||||||
full <= pre_full;
|
else
|
||||||
|
full <= pre_full;
|
||||||
|
end if;
|
||||||
end if;
|
end if;
|
||||||
end process;
|
end process;
|
||||||
|
|
||||||
proc_read_inhibit:
|
proc_read_inhibit:
|
||||||
process(rst, clk_r)
|
process(clk_r)
|
||||||
begin
|
begin
|
||||||
if rst = '1' then
|
if rising_edge(clk_r) then
|
||||||
empty <= '1';
|
if rst_r = '1' then
|
||||||
elsif rising_edge(clk_r) then
|
empty <= '1';
|
||||||
empty <= pre_empty;
|
else
|
||||||
end if;
|
empty <= pre_empty;
|
||||||
|
end if;
|
||||||
|
end if;
|
||||||
end process;
|
end process;
|
||||||
|
|
||||||
proc_sync_grptr:
|
proc_sync_grptr:
|
||||||
@@ -171,42 +192,46 @@ proc_ptr_awptr:
|
|||||||
end process;
|
end process;
|
||||||
|
|
||||||
proc_status_almost_full:
|
proc_status_almost_full:
|
||||||
process(rst, clk_w)
|
process(clk_w)
|
||||||
variable diff : unsigned (addr_width downto 0);
|
variable diff : unsigned (addr_width downto 0);
|
||||||
begin
|
begin
|
||||||
-- synthesis translate_off
|
-- synthesis translate_off
|
||||||
diffw <= signed(diff);
|
diffw <= signed(diff);
|
||||||
-- synthesis translate_on
|
-- synthesis translate_on
|
||||||
if rst = '1' then
|
if rising_edge(clk_w) then
|
||||||
fifo_afull <= '0';
|
if rst_w = '1' then
|
||||||
diff := (others => '0');
|
fifo_afull <= '0';
|
||||||
elsif rising_edge(clk_w) then
|
diff := (others => '0');
|
||||||
if diff >= almost_full_thresh-1 then
|
else
|
||||||
fifo_afull <= '1';
|
if diff >= almost_full_thresh-1 then
|
||||||
else
|
fifo_afull <= '1';
|
||||||
fifo_afull <= '0';
|
else
|
||||||
end if;
|
fifo_afull <= '0';
|
||||||
diff := unsigned(abs(signed(bnxt_w) - signed(bcnt2_ar)));
|
end if;
|
||||||
|
diff := unsigned(abs(signed(bnxt_w) - signed(bcnt2_ar)));
|
||||||
|
end if;
|
||||||
end if;
|
end if;
|
||||||
end process;
|
end process;
|
||||||
|
|
||||||
proc_status_almost_empty:
|
proc_status_almost_empty:
|
||||||
process(rst, clk_r)
|
process(clk_r)
|
||||||
variable diff : unsigned (addr_width downto 0);
|
variable diff : unsigned (addr_width downto 0);
|
||||||
begin
|
begin
|
||||||
-- synthesis translate_off
|
-- synthesis translate_off
|
||||||
diffr <= signed(diff);
|
diffr <= signed(diff);
|
||||||
-- synthesis translate_on
|
-- synthesis translate_on
|
||||||
if rst = '1' then
|
if rising_edge(clk_r) then
|
||||||
fifo_aempty <= '1';
|
if rst_r = '1' then
|
||||||
diff := (others => '0');
|
fifo_aempty <= '1';
|
||||||
elsif rising_edge(clk_r) then
|
diff := (others => '0');
|
||||||
if diff <= almost_empty_thresh+1 then
|
else
|
||||||
fifo_aempty <= '1';
|
if diff <= almost_empty_thresh+1 then
|
||||||
else
|
fifo_aempty <= '1';
|
||||||
fifo_aempty <= '0';
|
else
|
||||||
end if;
|
fifo_aempty <= '0';
|
||||||
diff := unsigned(abs(signed(bcnt2_aw) - signed(bnxt_r)));
|
end if;
|
||||||
|
diff := unsigned(abs(signed(bcnt2_aw) - signed(bnxt_r)));
|
||||||
|
end if;
|
||||||
end if;
|
end if;
|
||||||
end process;
|
end process;
|
||||||
|
|
||||||
@@ -218,7 +243,7 @@ inst_gray_counter_w : entity work.gray_counter
|
|||||||
)
|
)
|
||||||
port map
|
port map
|
||||||
(
|
(
|
||||||
rst => rst,
|
rst => rst_w,
|
||||||
clk => clk_w,
|
clk => clk_w,
|
||||||
ce => winc,
|
ce => winc,
|
||||||
bcnt => bcnt_w,
|
bcnt => bcnt_w,
|
||||||
@@ -235,7 +260,7 @@ inst_gray_counter_r : entity work.gray_counter
|
|||||||
)
|
)
|
||||||
port map
|
port map
|
||||||
(
|
(
|
||||||
rst => rst,
|
rst => rst_r,
|
||||||
clk => clk_r,
|
clk => clk_r,
|
||||||
ce => rinc,
|
ce => rinc,
|
||||||
bcnt => bcnt_r,
|
bcnt => bcnt_r,
|
||||||
|
|||||||
@@ -68,64 +68,74 @@ begin
|
|||||||
|
|
||||||
|
|
||||||
proc_diff_gen:
|
proc_diff_gen:
|
||||||
process(rst, clk)
|
process(clk)
|
||||||
begin
|
begin
|
||||||
if rst = '1' then
|
if rising_edge(clk) then
|
||||||
diff <= (others => '0');
|
if rst = '1' then
|
||||||
elsif rising_edge(clk) then
|
diff <= (others => '0');
|
||||||
if winc = '1' and rinc = '0' then
|
else
|
||||||
diff <= diff + 1;
|
if winc = '1' and rinc = '0' then
|
||||||
elsif winc = '0' and rinc = '1' then
|
diff <= diff + 1;
|
||||||
diff <= diff - 1;
|
elsif winc = '0' and rinc = '1' then
|
||||||
end if;
|
diff <= diff - 1;
|
||||||
|
end if;
|
||||||
|
end if;
|
||||||
end if;
|
end if;
|
||||||
end process;
|
end process;
|
||||||
|
|
||||||
proc_status_almost_full:
|
proc_status_almost_full:
|
||||||
process(rst, clk)
|
process(clk)
|
||||||
begin
|
begin
|
||||||
if rst = '1' then
|
if rising_edge(clk) then
|
||||||
fifo_afull <= '0';
|
if rst = '1' then
|
||||||
elsif rising_edge(clk) then
|
fifo_afull <= '0';
|
||||||
if diff >= almost_full_thresh-1 then
|
else
|
||||||
fifo_afull <= '1';
|
if diff >= almost_full_thresh-1 then
|
||||||
else
|
fifo_afull <= '1';
|
||||||
fifo_afull <= '0';
|
else
|
||||||
end if;
|
fifo_afull <= '0';
|
||||||
|
end if;
|
||||||
|
end if;
|
||||||
end if;
|
end if;
|
||||||
end process;
|
end process;
|
||||||
|
|
||||||
proc_status_almost_empty:
|
proc_status_almost_empty:
|
||||||
process(rst, clk)
|
process(clk)
|
||||||
begin
|
begin
|
||||||
if rst = '1' then
|
if rising_edge(clk) then
|
||||||
fifo_aempty <= '1';
|
if rst = '1' then
|
||||||
elsif rising_edge(clk) then
|
fifo_aempty <= '1';
|
||||||
if diff <= almost_empty_thresh+1 then
|
else
|
||||||
fifo_aempty <= '1';
|
if diff <= almost_empty_thresh+1 then
|
||||||
else
|
fifo_aempty <= '1';
|
||||||
fifo_aempty <= '0';
|
else
|
||||||
end if;
|
fifo_aempty <= '0';
|
||||||
|
end if;
|
||||||
|
end if;
|
||||||
end if;
|
end if;
|
||||||
end process;
|
end process;
|
||||||
|
|
||||||
proc_full_reg:
|
proc_full_reg:
|
||||||
process(rst, clk)
|
process(clk)
|
||||||
begin
|
begin
|
||||||
if rst = '1' then
|
if rising_edge(clk) then
|
||||||
full <= '0';
|
if rst = '1' then
|
||||||
elsif rising_edge(clk) then
|
full <= '0';
|
||||||
full <= pre_full;
|
else
|
||||||
|
full <= pre_full;
|
||||||
|
end if;
|
||||||
end if;
|
end if;
|
||||||
end process;
|
end process;
|
||||||
|
|
||||||
proc_empty_reg:
|
proc_empty_reg:
|
||||||
process(rst, clk)
|
process(clk)
|
||||||
begin
|
begin
|
||||||
if rst = '1' then
|
if rising_edge(clk) then
|
||||||
empty <= '1';
|
if rst = '1' then
|
||||||
elsif rising_edge(clk) then
|
empty <= '1';
|
||||||
empty <= pre_empty;
|
else
|
||||||
|
empty <= pre_empty;
|
||||||
|
end if;
|
||||||
end if;
|
end if;
|
||||||
end process;
|
end process;
|
||||||
|
|
||||||
@@ -147,10 +157,10 @@ proc_status_w:
|
|||||||
proc_flag_write:
|
proc_flag_write:
|
||||||
process(rst, clk)
|
process(rst, clk)
|
||||||
begin
|
begin
|
||||||
if rst = '1' then
|
if rising_edge(clk) then
|
||||||
was_write <= '0';
|
if rst = '1' then
|
||||||
elsif rising_edge(clk) then
|
was_write <= '0';
|
||||||
if winc = '1' then
|
elsif winc = '1' then
|
||||||
was_write <= '1';
|
was_write <= '1';
|
||||||
elsif rinc = '1' then
|
elsif rinc = '1' then
|
||||||
was_write <= '0';
|
was_write <= '0';
|
||||||
@@ -158,40 +168,34 @@ proc_flag_write:
|
|||||||
end if;
|
end if;
|
||||||
end process;
|
end process;
|
||||||
|
|
||||||
|
pW_next <= (pW + 1) when winc = '1' else pW;
|
||||||
|
ptr_w <= pW;
|
||||||
|
|
||||||
proc_ptr_w:
|
proc_ptr_w:
|
||||||
process(rst, clk, pW, winc)
|
process(clk)
|
||||||
begin
|
begin
|
||||||
if rst = '1' then
|
if rising_edge(clk) then
|
||||||
pW <= to_unsigned(0, addr_width);
|
if rst = '1' then
|
||||||
pW_next <= to_unsigned(0, addr_width);
|
pW <= to_unsigned(0, addr_width);
|
||||||
elsif rising_edge(clk) then
|
else
|
||||||
if winc = '1' then
|
|
||||||
pW <= pW_next;
|
pW <= pW_next;
|
||||||
end if;
|
end if;
|
||||||
end if;
|
end if;
|
||||||
pW_next <= pW;
|
|
||||||
if winc = '1' then
|
|
||||||
pW_next <= pW + 1;
|
|
||||||
end if;
|
|
||||||
ptr_w <= pW;
|
|
||||||
end process;
|
end process;
|
||||||
|
|
||||||
|
pR_next <= (pR + 1) when rinc = '1' else pR;
|
||||||
|
ptr_r <= pR_next;
|
||||||
|
|
||||||
proc_ptr_r:
|
proc_ptr_r:
|
||||||
process(rst, clk, pR_next, pR, rinc)
|
process(clk)
|
||||||
begin
|
begin
|
||||||
if rst = '1' then
|
if rising_edge(clk) then
|
||||||
pR <= to_unsigned(0, addr_width);
|
if rst = '1' then
|
||||||
pR_next <= to_unsigned(0, addr_width);
|
pR <= to_unsigned(0, addr_width);
|
||||||
elsif rising_edge(clk) then
|
else
|
||||||
if rinc = '1' then
|
|
||||||
pR <= pR_next;
|
pR <= pR_next;
|
||||||
end if;
|
end if;
|
||||||
end if;
|
end if;
|
||||||
pR_next <= pR;
|
|
||||||
if rinc = '1' then
|
|
||||||
pR_next <= pR + 1;
|
|
||||||
end if;
|
|
||||||
ptr_r <= pR_next;
|
|
||||||
end process;
|
end process;
|
||||||
|
|
||||||
end Behavioral;
|
end Behavioral;
|
||||||
|
|||||||
@@ -60,25 +60,21 @@ begin
|
|||||||
bcnt <= cntb;
|
bcnt <= cntb;
|
||||||
gcnt <= cntg;
|
gcnt <= cntg;
|
||||||
|
|
||||||
process(rst, clk, ce, cntb, nxtb)
|
nxtg <= bin2gray(nxtb);
|
||||||
begin
|
nxtb <= (cntb + 1) when ce = '1' else cntb;
|
||||||
if rst = '1' then
|
|
||||||
cntb <= to_unsigned(init_value, width);
|
process(clk)
|
||||||
nxtb <= to_unsigned(init_value, width);
|
begin
|
||||||
nxtg <= to_unsigned(init_value, width);
|
if rising_edge(clk) then
|
||||||
cntg <= to_unsigned(init_value, width);
|
if rst = '1' then
|
||||||
else
|
cntb <= to_unsigned(init_value, width);
|
||||||
if rising_edge(clk) then
|
cntg <= to_unsigned(init_value, width);
|
||||||
cntg <= nxtg;
|
else
|
||||||
cntb <= nxtb;
|
cntg <= nxtg;
|
||||||
end if;
|
cntb <= nxtb;
|
||||||
nxtg <= bin2gray(nxtb);
|
end if;
|
||||||
nxtb <= cntb;
|
end if;
|
||||||
if ce = '1' then
|
end process;
|
||||||
nxtb <= cntb + 1;
|
|
||||||
end if;
|
|
||||||
end if;
|
|
||||||
end process;
|
|
||||||
|
|
||||||
end Behavioral;
|
end Behavioral;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user