signal gnd_bus: std_logic_vector(17 downto 0);
signal gnd: std_logic;
signal pwr: std_logic;
- signal last_write_data: std_logic_vector(17 downto 0);
- signal not_read_since_emtpy: std_logic;
- signal last_first_write_allow: std_logic;
+ signal read_after_write: std_logic;
+ signal read_after_empty: std_logic;
component BUFG
port (
end component;
begin
- read_enable <= read_enable_in or last_first_write_allow;
- write_enable <= write_enable_in;
- fifo_gsr <= fifo_gsr_in;
- write_data <= write_data_in;
- read_data_out <=
- read_data;
--- write_data_in when empty = '1' else
--- last_write_data when not_read_since_emtpy = '1' else
+ read_enable <= read_enable_in;
+ write_enable <= write_enable_in;
+ fifo_gsr <= fifo_gsr_in;
+ write_data <= write_data_in;
+ read_data_out <= read_data;
+
full_out <= full;
- empty_out <= empty and not fcounter(0);
gnd_bus <= "000000000000000000";
gnd <= '0';
pwr <= '1';
+ empty_out <= (empty or read_after_write) and read_after_empty;
+ clock <= clock_in;
--- process(clock_in)
--- begin
--- if rising_edge(clock_in) then
--- if fifo_gsr = '1' then
--- empty_out <= '0';
--- else
--- empty_out <= emptyg;
--- end if;
--- end if;
--- end process;
-
- process(clock_in)
- begin
- if rising_edge(clock_in) then
- if fifo_gsr = '1' then
- last_write_data <= (others => '0');
- elsif write_enable = '1' and empty = '1' then
- last_write_data <= write_data_in;
- end if;
- end if;
- end process;
-
- process(clock_in)
- begin
- if rising_edge(clock_in) then
- if fifo_gsr = '1' then
- not_read_since_emtpy <= '1';
- else
- if empty = '1' then
- not_read_since_emtpy <= '1';
- end if;
- if read_enable = '1' then
- not_read_since_emtpy <= '0';
- end if;
- end if;
- end if;
- end process;
-
---------------------------------------------------------------------------
--- --
--- A global buffer is instantianted to avoid skew problems. --
--- --
---------------------------------------------------------------------------
-
---gclk1: BUFG port map (I => clock_in, O => clock);
-clock <= clock_in;
--------------------------------------------------------------------------
-- --
-- Block RAM instantiation for FifO. Module is 1024x18, of which one --
-- begin
-- if (fifo_gsr = '1') then
-- read_allow <= '0';
--- read_active <= '0';
-- elsif (clock'EVENT AND clock = '1') then
-- read_allow <= read_enable AND NOT emptyg;
--- read_active <= read_enable and not (emptyg or (empty and write_enable));
-- end if;
-- end process proc1;
--
-- end process proc2;
write_allow <= write_enable AND NOT fullg;
-read_allow <= (read_enable AND (NOT empty or fcounter(0)));
+read_allow <= (read_enable or read_after_write) AND NOT empty;-- ;
+fcnt_allow <= write_allow XOR read_allow; -- and not read_after_write
-fcnt_allow <= (write_allow XOR read_allow) or (write_enable and empty) ;
+proc33: process (clock)
+begin
+ if rising_edge(clock) then
+ if (fifo_gsr = '1') then
+ read_after_write <= '0';
+ else
+ if empty = '1' and write_enable = '1' then
+ read_after_write <= '1';
+ else
+ read_after_write <= '0';
+ end if;
+ end if;
+ end if;
+end process;
- process(clock_in)
- begin
- if rising_edge(clock_in) then
- if fifo_gsr = '1' then
- last_first_write_allow <= '0';
- else
- last_first_write_allow <= write_enable and empty;
- end if;
+process(clock)
+ begin
+ if rising_edge(clock) then
+ if fifo_gsr = '1' or (empty = '0' and emptyg = '1') then
+ read_after_empty <= '0';
+ elsif read_enable_in = '1' then
+ read_after_empty <= '1';
end if;
- end process;
+ end if;
+ end process;
---------------------------------------------------------------
-- --
ra_or_fcnt0 <= (read_allow OR NOT fcounter(0));
-emptyg <= (not or_all(fcounter(9 downto 0)) AND ra_or_fcnt0); -- AND NOT write_allow
+emptyg <= (not or_all(fcounter(9 downto 1)) AND ra_or_fcnt0) AND NOT write_allow; --
proc3: process (clock, fifo_gsr)
begin
-- first valid clock edge after fifo_gsr is removed), or --
-- when on the next clock cycle, Read Enable is low, and --
-- either the FifOcount is equal to 3FF (hex), or it is --
--- equal to 1FE and the Write Enable is high (about to go --
+-- equal to 3FE and the Write Enable is high (about to go --
-- Full). --
-- --
---------------------------------------------------------------
wa_or_fcnt0 <= (write_allow OR fcounter(0));
---fcntandout(2) <= (fcounter(4) AND fcounter(3) AND fcounter(2) AND fcounter(1));
---fcntandout(3) <= (fcounter(8) AND fcounter(7) AND fcounter(6) AND fcounter(5));
-fullg <= (and_all(fcounter(9 downto 1)) AND NOT read_allow); -- AND wa_or_fcnt0
+fullg <= (and_all(fcounter(9 downto 1)) AND wa_or_fcnt0 AND NOT read_allow);
proc4: process (clock, fifo_gsr)
begin
if (fifo_gsr = '1') then
read_addr <= "0000000000";
elsif (clock'EVENT AND clock = '1') then
- if (read_allow = '1') then -- or(write_enable='1' and empty='1')
+ if (read_allow = '1') then
read_addr <= read_addr + '1';
end if;
end if;
fcounter <= "0000000000";
elsif (clock'EVENT AND clock = '1') then
if (fcnt_allow = '1') then
- if (read_allow = '0') then
- fcounter <= fcounter + '1';
- elsE
+ if (read_allow = '1') then -- and read_after_write = '0'
fcounter <= fcounter - '1';
+ elsE
+ fcounter <= fcounter + '1';
end if;
end if;
end if;