📄 tg32pci.vhd
字号:
elsif DevAddr = '0' then -- deselect device DEVSEL_N <= 'Z'; STOP_N <= 'Z'; end if; elsif (CLK'Event and CLK = '1') then if ResFin = '1' then -- memory reserved mode command if MemWrite = '1' then -- master writes to target memory if TRDY_N = '0' and IRDY_N = '0' then Busy <= '0'; ResFin <= '0'; end if; elsif MemRead = '1' then -- master reads from target memory if TrnArnd = '0' and TRDY_N = '0' and IRDY_N = '0' then Busy <= '0'; ResFin <= '0'; end if; end if; end if; if devdel = true then if devtype = "Medi" then if counter = 0 then DEVSEL_N <= '0' after 8 ns; Stop_N <= '1' after 10 ns; devdel := false; end if; elsif devtype = "Slow" then if counter = 1 then DEVSEL_N <= '0' after 8 ns; Stop_N <= '1' after 10 ns; devdel := false; else counter := counter + 1; end if; end if; end if; if FRAME_N = '1' then -- end of cycle assert (IRDY_N = '0') report "Target device : FRAME signal deassertion error. IRDY is not asserted." severity Error; if TRDY_N = '0' and IRDY_N = '0' then -- finish the current cycle Busy <= '0'; end if; elsif FrameEv = '1' then -- decoding FrameEv <= '0'; assert (FRAME_N'Last_Event >= tsetup) report "Target device : Frame setup time violation in decode cycle!" severity warning; assert (AD_Bus'Last_Event >= tsetup) report "Target device : Address setup time violation in decode cycle!" severity warning; assert (C_BE_Bus'Last_Event >= tsetup) report "Target device : Command setup time violation in decode cycle!" severity warning; addr := AD_Bus; case C_BE_Bus is -- decoding the command bus when "0001" => -- Special Cycle! Used to transfer from master device the -- wait states parameters if (addr(31 downto 8) = bacfg(31 downto 8) and IDSEL ='1') then WaitWrite <= '1'; DevAddr <= '1'; Busy <= '1'; trdywaits := true; else -- this device is not the addressed one, DevAddr <= '0'; -- so it is not responding trdywaits := false; end if; cfgaddr := Byte2Int(addr(7 downto 0)); when "0010" => -- I/O Read! Master reads from target device. if addr(31 downto 8) = baio(31 downto 8) then DevAddr <= '1'; Busy <= '1'; IORead <= '1'; TrnArnd <= '1'; ioaddr := Byte2Int(addr(7 downto 0)); else -- this device is not the addressed one, DevAddr <= '0'; -- so it is not responding end if; when "0011" => -- I/O Write! Master writes to target device. if addr(31 downto 8) = baio(31 downto 8) then DevAddr <= '1'; Busy <= '1'; IOWrite <= '1'; ioaddr := Byte2Int(addr(7 downto 0)); else -- this device is not the addressed one, DevAddr <= '0'; -- so it is not responding end if; when "1100" => -- Memory Read! Master reads from target device. if addr(31 downto 8) = bamem(31 downto 8) then DevAddr <= '1'; Busy <= '1'; MemRead <= '1'; TrnArnd <= '1'; if addr(1 downto 0) = "01" then -- reserved mode ResFin <= '1'; elsif addr(1 downto 0) = "11" then -- reserved mode ResFin <= '1'; end if; memaddr := Byte2Int(addr(7 downto 0)); else -- this device is not the addressed one, DevAddr <= '0'; -- so it is not responding end if; when "1110" => -- Memory Read Line! Master reads from target device. if addr(31 downto 8) = bamem(31 downto 8) then DevAddr <= '1'; Busy <= '1'; MemRead <= '1'; TrnArnd <= '1'; if addr(1 downto 0) = "01" then -- reserved mode ResFin <= '1'; elsif addr(1 downto 0) = "11" then -- reserved mode ResFin <= '1'; end if; memaddr := Byte2Int(addr(7 downto 0)); else -- this device is not the addressed one, DevAddr <= '0'; -- so it is not responding end if; when "1111" => -- Memory Write! Master writes to target device. if addr(31 downto 8) = bamem(31 downto 8) then DevAddr <= '1'; Busy <= '1'; MemWrite <= '1'; if addr(1 downto 0) = "01" then -- reserved mode ResFin <= '1'; elsif addr(1 downto 0) = "11" then -- reserved mode ResFin <= '1'; end if; memaddr := Byte2Int(addr(7 downto 0)); else -- this device is not the addressed one, DevAddr <= '0'; -- so it is not responding end if; when "0110" => -- Memory Read! Master reads from target device. if addr(31 downto 8) = bamem(31 downto 8) then DevAddr <= '1'; Busy <= '1'; MemRead <= '1'; TrnArnd <= '1'; if addr(1 downto 0) = "01" then -- reserved mode ResFin <= '1'; elsif addr(1 downto 0) = "11" then -- reserved mode ResFin <= '1'; end if; memaddr := Byte2Int(addr(7 downto 0)); else -- this device is not the addressed one, DevAddr <= '0'; -- so it is not responding end if; when "0111" => -- Memory Write! Master writes to target device. if addr(31 downto 8) = bamem(31 downto 8) then DevAddr <= '1'; Busy <= '1'; MemWrite <= '1'; if addr(1 downto 0) = "01" then -- reserved mode ResFin <= '1'; elsif addr(1 downto 0) = "11" then -- reserved mode ResFin <= '1'; end if; memaddr := Byte2Int(addr(7 downto 0)); else -- this device is not the addressed one, DevAddr <= '0'; -- so it is not responding end if; when "1010" => -- Configuration Read! Master reads from target device. if (addr(31 downto 8) = bacfg(31 downto 8) and IDSEL = '1') then if addr(1 downto 0) = "01" then report "Target device: Type 1 configuration access on bus! Ignored." severity Note; elsif addr(1 downto 0) = "00" then CfgRead <= '1'; TrnArnd <= '1'; DevAddr <= '1'; Busy <= '1'; end if; cfgaddr := Byte2Int(addr(7 downto 0)); else -- this device is not the addressed one, DevAddr <= '0'; -- so it is not responding end if; when "1011" => -- Configuration Write! Master writes to target device. if (addr(31 downto 8) = bacfg(31 downto 8) and IDSEL = '1') then if addr(1 downto 0) = "01" then report "Target device: Type 1 configuration access on bus! Ignored." severity Note; elsif addr(1 downto 0) = "00" then CfgWrite <= '1'; DevAddr <= '1'; Busy <= '1'; end if; cfgaddr := Byte2Int(addr(7 downto 0)); else -- this device is not the addressed one, DevAddr <= '0'; -- so it is not responding end if; when "0100" => report "Target device: Reserved Command detected on C/BE bus! Target will not respond." severity Warning; when "0101" => report "Target device: Reserved Command detected on C/BE bus! Target will not respond." severity Warning; when "1000" => report "Target device: Reserved Command detected on C/BE bus! Target will not respond." severity Warning; when "1001" => report "Target device: Reserved Command detected on C/BE bus! Target will not respond." severity Warning; when "ZZZZ" => null; when others => report "Target device: Unknown or invalid command on C/BE bus! Ignored." severity Error; end case; end if; -- elsif (Frame_N'Event and Frame_N = '1') then end if; end process; --------------------------------------------------------------------- -- Implementation of Write command. -- Master writes to Target device. --------------------------------------------------------------------- WriteProc : process(CLK,RST_N) variable waitreg : Std_Logic_Vector(15 downto 0) := x"0000"; variable Char3_2,Char1,Char0 : Std_Logic_Vector(7 downto 0) := x"00"; begin if (CLK'Event and CLK = '1' and ((IRDY_N = '0' and TRDY_N = '0') or FRAME_N = '1')) then assert (AD_Bus'Last_Event >= tsetup) report "Target device : Data setup time violation in decode cycle!" severity warning; assert (C_BE_Bus'Last_Event >= tsetup) report "Target device : Byte Enables setup time violation in decode cycle!" severity warning; if (WaitWrite = '1') then Char3_2 := AD_Bus(15 downto 8); Char1 := "0000" & AD_Bus(7 downto 4); Char0 := "0000" & AD_Bus(3 downto 0); trdy_loop := Byte2Int(Char3_2) ; trdy_nr := Byte2Int(Char1); -- + 1; trdy_st := Byte2Int(Char0); elsif IOWrite = '1' then -- Master writes to target I/O space case addr(1 downto 0) is when "00" => if C_BE_Bus = "0000" then IOmem(ioaddr) := AD_Bus; elsif C_BE_Bus = "1000" then IOmem(ioaddr)(23 downto 0) := AD_Bus(23 downto 0); elsif C_BE_Bus = "0100" then IOmem(ioaddr)(31 downto 24) := AD_Bus(31 downto 24); IOmem(ioaddr)(15 downto 0) := AD_Bus(15 downto 0); elsif C_BE_Bus = "1100" then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -