Altera Corporation Configuring PLDs with Flash Memory
3
--To increase the size of the memory, change the size of std_logic_vector for ADDR output and
--std_logic_vector signal inc:
ADDR : out std_logic_vector(15 downto 0);
CEn : out std_logic);
-- The polarity of the CEn signal is determined by the type of Flash device
end;
architecture rtl of MAXconfig is
--The following encoding is done in such way that the LSB represents the nConfig signal:
constant start :std_logic_vector(2 downto 0) := "000";
constant wait_nCfg_8us :std_logic_vector(2 downto 0) := "100";
constant status :std_logic_vector(2 downto 0) := "001";
constant wait_40us :std_logic_vector(2 downto 0) := "101";
constant config :std_logic_vector(2 downto 0) := "011";
constant init :std_logic_vector(2 downto 0) := "111";
signal pp :std_logic_vector(2 downto 0);
signal count :std_logic_vector(2 downto 0);
signal data0_int, dclk_int :std_logic;
signal inc :std_logic_vector(15 downto 0);
signal div :std_logic_vector(2 downto 0);
signal waitd :std_logic_vector(11 downto 0);
--The width of signal ‘waitd’ is determined by the frequency. For 57 MHz (APEX 20KE devices),
--‘waitd’ is 12 bits. For 33 MHz (FLEX 10KE and ACEX devices) ‘waitd’ is 11 bits. To calculate
--the width of the ‘waitd’ signal fordifferent frequencies, calculate the following:
--(multiply tcf2ck * clock frequency)+ 40
--Then convert this value to binary to obtain the width.
--For example, for 33 MHz (FLEX 10KE & ACEX devices), converting 1360 ((40us * 33MHz)+40=1360)
--to binary code, the ‘waitd’ is an 11-bit signal. So signal ‘waitd’ will be:
--signal waitd :std_logic_vector(10 downto 0);
begin
--The following process is used to divide the CLOCK:
PROCESS (clock,restart)
begin if restart = '0' then
div <= (others => '0');
else IF (clock'EVENT AND clock = '1') THEN
div <= div + 1;
end if;
end if;
END PROCESS;
PROCESS (clock,restart)
begin if restart = '0' then
pp<=start;
count <= (others => '0');
inc <= (others => '0');
waitd <= (others => '0');
else
if clock'event and clock='1' then
--The following test is used to divide the CLOCK. The value compared to must be such that the
--condition is true at a maximum rate of 57 MHz (tclk = 17.5 ns min) for APEX 20KE devices
--and at a maximum rate of 33 MHz (tclk=30ns min) for FLEX 10KE or ACEX devices.
if (div = 7) then
case pp is
when start =>
count <= (others => '0');
inc <= (others => '0');
waitd <= (others => '0');