Advertisement
Guest User

broken clockport 2 ftdi fifo

a guest
Feb 19th, 2013
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.73 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3.  
  4. entity clockportFifo is
  5.     Port(
  6.         data :      inout STD_LOGIC_VECTOR (7 downto 0);
  7.         addressIn : in STD_LOGIC_VECTOR (3 downto 0);
  8.         iord :      in STD_LOGIC;
  9.         iowr :      in STD_LOGIC;
  10.         cs :        in STD_LOGIC;
  11.        
  12.         fifoData :  inout STD_LOGIC_VECTOR (7 downto 0);
  13.         fifoRxE :   in STD_LOGIC;
  14.         fifoTxE :   in STD_LOGIC;
  15.         fifoWr :    out STD_LOGIC;
  16.         fifoRd :    out STD_LOGIC;
  17.         fifoSlp :   in STD_LOGIC);
  18. end clockportFifo;
  19.  
  20. architecture Behavioral of clockportFifo is
  21.     signal address : STD_LOGIC_VECTOR (3 downto 0);
  22.     signal cpRead : STD_LOGIC;
  23.     signal cpWrite : STD_LOGIC;
  24.  
  25.     signal ctrlReg : STD_LOGIC_VECTOR (7 downto 0);
  26.     signal ctrlFifoWr : STD_LOGIC := '1';
  27.     signal ctrlFifoRd : STD_LOGIC := '1';
  28.     signal dataTmp : STD_LOGIC_VECTOR (7 downto 0);
  29. begin
  30.  
  31.     cpRead <= '0' when cs = '0' and iord = '0' else '1';
  32.     cpWrite <= '0' when cs = '0' and iowr = '0' else '1';
  33.     address <= addressIn when cs = '0' and (iord = '0' or iowr = '0');
  34.    
  35.     ctrlReg <= "0" & ctrlFifoRd & "000" & fifoRxE & fifoTxE & fifoSlp;
  36.    
  37.     fifoRd <= ctrlFifoRd;
  38.  
  39.     process (cpRead, address)
  40.     begin
  41.         ctrlFifoRd <= '1';
  42.         if cpRead = '0' and address = "0000" then
  43.             data <= "00000000";
  44.         elsif cpRead = '0' and address = "0001" then
  45.             data <= ctrlReg;
  46.         elsif cpRead = '0' and address = "0010" and fifoRxE = '0' and ctrlFifoRd = '0' then
  47.             ctrlFifoRd <= '0';
  48.             data <= fifoData;
  49.         else
  50.             data <= "ZZZZZZZZ";
  51.         end if;
  52.     end process;
  53.    
  54.     process (cpWrite, address)
  55.     begin
  56.         fifoData <= "ZZZZZZZZ";
  57.         fifoWr <= '1';
  58.         if cpWrite = '0' and address = "0001" then
  59.             ctrlFifoRd <= data(6);
  60.         elsif cpWrite = '0' and address = "0010" then
  61.             fifoWr <= '0';
  62.             fifoData <= data;
  63.         end if;
  64.     end process;
  65.    
  66. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement