⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 config.vhd

📁 fifo code. i have adde the code for key lib to the data which has been transfered
💻 VHD
字号:
--
-- XC9500 CPLD design which controls the configuration of the XSA Spartan2
-- with data from the Flash chip.
--

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity config is
	generic
	(
		ADDR_LEN: positive := 18		-- number of Flash address bits
	);
	port
	(
		clk		: in std_logic;	-- clock from DS1075 prog. osc.

		-- Flash address and control pins
		fa		: out std_logic_vector(ADDR_LEN-1 downto 0); -- Flash address
		fceb	: out std_logic;	-- Flash chip-enable
		foeb	: out std_logic;	-- Flash output-enable
		fweb	: out std_logic;	-- Flash write-enable
		frstb	: out std_logic;	-- Flash reset

		-- Spartan2 configuration pins
		S2_clk		: out std_logic;	-- Spartan2 global clock input
		S2_progb	: out std_logic;	-- Spartan2 PROGRAM pin
		S2_cclk		: out std_logic;	-- Spartan2 config clock
		S2_csb		: out std_logic;	-- Spartan2 config chip-select
		S2_wrb		: out std_logic;	-- Spartan2 config write-enable
		S2_initb	: in std_logic;	-- Spartan2 config init status
		S2_dout		: in std_logic;	-- Spartan2 config busy status
		S2_done		: in std_logic;	-- Spartan2 config done status
		S2_m			: out std_logic_vector(0 downto 0)	-- Spartan2 config. mode pins	
	);
end config;

architecture config_arch of config is
	constant LO			: std_logic := '0';
	constant HI			: std_logic := '1';
	constant FLOAT	: std_logic := 'Z';

	signal cclk							: std_logic;
	signal programb, cs			: std_logic;
	signal addr, next_addr	: std_logic_vector(ADDR_LEN-1 downto 0);
	signal poweron_reset		: std_logic;
	signal poweron_cnt			: std_logic_vector(7 downto 0);
	signal S2_busy					: std_logic;
	signal button_progb			: std_logic;
begin

	S2_busy <= S2_dout;		-- give this signal a better name

	-- set Spartan2 mode to Slave Parallel so it can be configured from Flash
	S2_m		<= "0";

	-- Flash is enabled for reading while Spartan2 is not yet configured
	-- and then the Flash pins float when configuration is done
	foeb		<= LO when (S2_done=LO) else FLOAT;
	fceb		<= LO when (S2_done=LO) else FLOAT;
	fweb		<= HI when (S2_done=LO) else FLOAT;	-- disable Flash writes
	frstb		<= HI;						-- remove Flash reset

	-- generate configuration clock for Spartan2 from the XSA clock.
	-- The XSA clock could be as much as 100 MHz, so divide by 16
	-- to exceed the access time of the Flash.

	cclk	<= clk;	-- internal configuration clock
	S2_cclk	<= cclk;		-- also send config. clock to Spartan2

	-- Apply reset when the power to the XSA Board is first applied.
	-- Remove the power-on reset after the counter reaches 0.
	process(cclk)
	begin
		if(cclk'event and cclk=HI) then
			if(poweron_cnt = 255) then
				poweron_reset <= LO;	-- remove reset when timeout expires
			else
				poweron_cnt <= poweron_cnt + 1;
				poweron_reset <= HI;
			end if;
		end if;
	end process;

	-- initiate Spartan2 configuration by lowering the /PROGRAM pin
	-- during the initial power-on reset and then raising it when
	-- the power-on timeout expires and the manual program control is high
	programb <= not(poweron_reset);
	S2_progb <= programb;

	-- Select the Spartan2 for configuration as long as the /PROGRAM pin
	-- is not held low and the INIT pin is not low.
	process(cclk,programb)
	begin
		if(programb = LO) then
			cs <= LO;
		elsif(cclk'event and cclk=HI) then
			cs <= S2_initb;
		end if;
	end process;

	-- Select the Spartan2 for configuration by lowering its chip-select
	-- and write inputs when the internal chip-select is high.  Then
	-- float these pins after the Spartan2 configuration is done.
	S2_csb <= not(cs)	when (S2_done=LO) else FLOAT;
	S2_wrb <= not(cs)	when (S2_done=LO) else FLOAT;

	-- increment the Flash address so the next byte of configuration
	-- data is presented to the Spartan2.  Stop incrementing if the
	-- Spartan2 is not selected, signals a config. error (INIT=0), or
	-- is busy.  Reset the address counter to zero whenever the
	-- /PROGRAM pin goes low and a new configuration sequence begins.
	process(cclk)
	begin
		if(cclk'event and cclk=HI) then
			if((cs=HI) and (S2_initb=HI) and (S2_busy=LO)) then
				addr <= addr + 1;
			elsif(programb = LO) then
				addr <= (others=>LO);
			end if;
		end if;
	end process;

	-- pass the Flash address out to the Flash chip.  Float the address
	-- lines once configuration is done.
	fa <= addr			when (S2_done=LO) else (others=>FLOAT);
	
	-- pass the clock from the DS1075 to the Spartan2 after it is configured
	S2_clk <= clk when (S2_done=HI) else FLOAT;

end config_arch;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -