📄 i43hostmot2.vhd
字号:
CLKIN_DIVIDE_BY_2 => FALSE, CLKIN_PERIOD => 20.0, CLKOUT_PHASE_SHIFT => "NONE", CLK_FEEDBACK => "1X", DESKEW_ADJUST => "SYSTEM_SYNCHRONOUS", DFS_FREQUENCY_MODE => "LOW", DLL_FREQUENCY_MODE => "LOW", DUTY_CYCLE_CORRECTION => TRUE, FACTORY_JF => X"C080", PHASE_SHIFT => 0, STARTUP_WAIT => FALSE) port map ( CLK0 => clk0, -- CLKFB => clk0, -- DCM clock feedback CLKFX => clkfx, CLKIN => CLK, -- Clock input (from IBUFG, BUFG or DCM) PSCLK => '0', -- Dynamic phase adjust clock input PSEN => '0', -- Dynamic phase adjust enable input PSINCDEC => '0', -- Dynamic phase adjust increment/decrement RST => '0' -- DCM asynchronous reset input ); BUFG_inst : BUFG port map ( O => fclk, -- Clock buffer output I => clkfx -- Clock buffer input ); -- End of DCM_inst instantiation EPPInterface: process(clk, waitpipe, alatch, afilter, dfilter, EPP_READ, EPP_DSTROBE, EPP_ASTROBE, depp_dstrobe, depp_astrobe) begin if rising_edge(CLK) then depp_dstrobe <= EPP_DSTROBE; -- async so one level of FF before anything else depp_astrobe <= EPP_ASTROBE; depp_read <= EPP_READ; afilter(1) <= afilter(0); dfilter(1) <= dfilter(0); if (depp_dstrobe = '0') or (depp_astrobe = '0') then waitpipe <= waitpipe(8 downto 0) & '1'; -- left shift in a 1 else waitpipe <= (others => '0'); end if; if depp_astrobe = '0' then if afcnt /= "111" then afcnt <= afcnt +1; end if; else if afcnt /= "000" then afcnt <= afcnt -1; end if; end if; if afcnt = "111" then afilter(0) <= '1'; end if; if afcnt = "000" then afilter(0) <= '0'; end if; if depp_dstrobe = '0' then if dfcnt /= "111" then dfcnt <= dfcnt +1; end if; else if dfcnt /= "000" then dfcnt <= dfcnt -1; end if; end if; if dfcnt = "111" then dfilter(0) <= '1'; end if; if dfcnt = "000" then dfilter(0) <= '0'; end if; if depp_read = '1' then if rfcnt /= "11" then rfcnt <= rfcnt +1; end if; else if rfcnt /= "00" then rfcnt <= rfcnt -1; end if; end if; if rfcnt = "11" then rfilter <= '1'; end if; if rfcnt = "00" then rfilter <= '0'; end if; if awritele = '1' then if wasaddr = '0' then alatch(7 downto 0) <= EPP_DATABUS; else alatch(15 downto 8) <= EPP_DATABUS; end if; end if; if dstrobete = '1' then wasaddr <= '0'; end if; if astrobete = '1' then wasaddr <= '1'; end if; if dstrobete = '1' and alatch(15) = '1' then -- auto increment address on data access if address MSB is 1 alatch(14 downto 0) <= alatch(14 downto 0) +1; end if; end if; -- clk EPP_WAIT <= waitpipeend; if dfilter = "01" and rfilter = '0' then -- generate write 80 ns after leading edge of strobe dwritele <= '1'; else dwritele <= '0'; end if; if dfilter = "10" and rfilter = '0' then -- generate write 80 ns after leading edge of strobe dwritete <= '1'; else dwritete <= '0'; end if; if dfilter = "01" and rfilter = '1' then -- generate read 80 ns after leading edge of strobe dreadle <= '1'; else dreadle <= '0'; end if; if dfilter = "10" and rfilter = '1' then -- generate read 80 ns after leading edge of strobe dreadte <= '1'; else dreadte <= '0'; end if; if dfilter = "10" then -- generate writete 80 ns after trailng edge of strobe dstrobete <= '1'; else dstrobete <= '0'; end if; if afilter = "10" then -- generate writete 80 ns after trailng edge of strobe astrobete <= '1'; else astrobete <= '0'; end if; if afilter = "01" and rfilter = '0' then -- generate write 80 ns after leading edge of strobe awritele <= '1'; else awritele <= '0'; end if; if rfilter = '1' and depp_dstrobe = '0' then dread <= '1'; else dread <= '0'; end if; if rfilter = '1' and depp_astrobe = '0' then aread <= '1'; else aread <= '0'; end if; end process EPPInterface; bus_shim32: process (CLK,alatch,EPP_DATABUS) -- 8 to 32 bit bus shim begin if rising_edge(CLK) then if dwritele = '1' then -- on writes, latch the data in our 32 bit write data latch case seladd(1 downto 0) is -- 32 data is written after last byte saved in latch when "00" => wdlatch(7 downto 0) <= EPP_DataBus; when "01" => wdlatch(15 downto 8) <= EPP_DataBus; when "10" => wdlatch(23 downto 16) <= EPP_DataBus; when "11" => wdlatch(31 downto 24) <= EPP_DataBus; when others => null; end case; end if; if alatch(14 downto 9) = TranslateRegionAddr(6 downto 1) then if dreadle = '1' and translatestrobe = '1' then rdlatch <= obus; end if; else if dreadle = '1' and seladd(1 downto 0) = "00" then rdlatch <= obus; end if; end if; end if; -- clk case seladd(1 downto 0) is -- on reads, data previously stored in read data latch when "00" => idata <= rdlatch(7 downto 0); -- is muxed onto 8 bit bus by A(0..1) when "01" => idata <= rdlatch(15 downto 8); when "10" => idata <= rdlatch(23 downto 16); when "11" => idata <= rdlatch(31 downto 24); when others => null; end case; if alatch(14 downto 10) = TranslateRamAddr(6 downto 2) then translateramsel <= '1'; else translateramsel <= '0'; end if; if dwritete = '1' and translateramsel = '1' then loadtranslateram <= '1'; else loadtranslateram <= '0'; end if; if dreadle = '1' and translateramsel = '1' then readtranslateram <= '1'; else readtranslateram <= '0'; end if; if alatch(14 downto 8) = TranslateRegionAddr(6 downto 0) then write32 <= dwritete and translatestrobe; read32 <= dreadle and translatestrobe; seladd <= '0'&translateaddr(AddrWidth-2 downto 0); -- drop msb = translatestrobe else write32 <= dwritete and alatch(1) and alatch(0); read32 <= dreadle and ((not alatch(1)) and (not alatch(0))); seladd <= '0'&alatch(AddrWidth-2 downto 0); -- drop msb = autoincbit end if; end process; doreconfig: process (CLK,ReConfigreg) begin if alatch = x"7F7F" then ReconfigSel <= '1'; else ReconfigSel <= '0'; end if; if rising_edge(CLK) then if dwritele = '1' and ReconfigSel = '1' then if EPP_DATABUS = x"5A" then ReConfigreg <= '1'; end if; end if; end if; RECONFIG <= not ReConfigreg; end process doreconfig; BusDrive: process (aread,dread,idata,alatch) begin EPP_DATABUS <= "ZZZZZZZZ"; if dread = '1' then EPP_DATABUS <= idata; end if; if aread = '1' then if wasaddr = '0' then EPP_DATABUS <= alatch(7 downto 0); else EPP_DATABUS <= alatch(15 downto 8); end if; end if; PARACONFIG <= '1'; SPICS <= '1'; SPICLK <= '0'; SPIOUT <= '0'; end process BusDrive; end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -