--RESET PCB BUG WORKAROUND:-------------------------------------------------------------
--On board-revision-1 there is a bug that makes the PCIe card-edge reset to be unusable.
--As a workaround, generate a reset internally:
--the counter is 22-bit, and generates a 100ms reset
sys_reset_n <= sys_reset_n_local;
process ( sys_reset_n_local_2ms, sys_reset_n_local_2msb, x25m_clkin)
begin
if (sys_reset_n_local_2ms='0' or sys_reset_n_local_2msb='0') then
sysreset_counter <= (others => '0');
sys_reset_n_local <= '0';
elsif (x25m_clkin'event and x25m_clkin='0') then --falling edge deassertion for good rec/rem timing
if (sysreset_counter = "1001100010010110100000") then
sys_reset_n_local <= '1';
--stop counting
else
sysreset_counter <= sysreset_counter +1;
sys_reset_n_local <= '0';
end if;
end if;
end process;
--This is to generate a reset signal for the reset generator:
--Unfortunatelly the counter starts at a random number, so the reset delay can be anywhere between 0ms...2ms.
--The counter is doubled, one counts up the other one down. so if all bits start at 0000 or at 1111 the first
--stage should still generate a few clock cycles reset to the main reset counter above.
process ( x25m_clkin)
begin
if (x25m_clkin'event and x25m_clkin='1') then
if (sysreset_counter_2ms = "1111111100000000") then --2ms if it started from zero
sys_reset_n_local_2ms <= '1';
--stop counting
else
sysreset_counter_2ms <= sysreset_counter_2ms +1;
sys_reset_n_local_2ms <= '0';
end if;
if (sysreset_counter_2msb = "0000000000000000") then --2ms if it started from oxFFFF
sys_reset_n_local_2msb <= '1';
--stop counting
else
sysreset_counter_2msb <= sysreset_counter_2msb -1;
sys_reset_n_local_2msb <= '0';
end if;
end if;
end process;