Advertisement
Guest User

Dtack_generator.vhd

a guest
Feb 9th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.10 KB | None | 0 0
  1. LIBRARY ieee;
  2. USE ieee.std_logic_1164.all;
  3. use ieee.std_logic_arith.all;
  4. use ieee.std_logic_unsigned.all;
  5.  
  6. -- this circuit produces the Dtack_L signal back to the 68k
  7. -- you must ensure 68k gets a Dtack_L when it issues an address otherwise it will generate WAIT states for ever
  8.  
  9. entity Dtack_Generator is
  10. Port (
  11. AS_L : in std_logic ; -- address strobe from 68k
  12. DramSelect_H : in std_logic ; -- from address decoder
  13. FlashSelect_H : in std_logic ; -- from address decoder
  14. DramDtack_L : in std_logic ; -- from Dram controller
  15. FlashDtack_L : in std_logic ; -- from Flash controller
  16. DtackOut_L : out std_logic; -- to CPU
  17. DE2512kRamSelect_H : in std_logic
  18.  
  19. );
  20. end ;
  21.  
  22.  
  23. architecture bhvr of Dtack_Generator is
  24. Begin
  25. process(AS_L, DramSelect_H, FlashSelect_H, DramDtack_L, FlashDtack_L, DE2512kRamSelect_H)
  26. begin
  27.  
  28. DtackOut_L <= '1' ; -- default is no Dtack IN BETWEEN bus cycles (when AS_L = '1')
  29.  
  30. -- however in VHDL we can override the above "default output" with other outputs
  31. -- e.g. if the address decoder is telling us that the CPU is access say the Flash memory (e.g. FlashSelect_H above is logic 1), then we could delay
  32. -- producing a Dtack back to the CPU until sometime later (i.e. introduce wait states)
  33. --
  34. -- This would be done by getting the Flash controller to load a pre-loadable timer when AS_L is '1' and let it count down to zero when AS_L = '0'
  35. -- when the time delay elapses we could take a signal from the timer saying it has reached 0 and use this to provide the dtack back the 68k
  36. -- it could provide the DramDtack_L input that could be used to provide rthe 68k Dtack
  37.  
  38. if(AS_L = '0') then -- When AS active 68k is accessing something so we get to produce a Dtack here if we chose
  39. DtackOut_L <= '0' ; -- assume for the moment everything is fast enough, nothing needs wait states so we set DtackOut_L to low as soon as we see AS go low
  40. -- this will be the default that covers things like on chip RAM/ROM and IO devices like LEDs, switches, graphics, DMA etc
  41. -- this default may or may not work for off chip devices like Flash, Dram etc
  42.  
  43. --
  44. -- if however the memory or IO is known to be slow and thus wait states ARE needed, i.e. we cannot just produce the dtack immediately as above
  45. -- then we can override the above DtackOut_L <= '0' statement with another based on an IF test
  46. -- e.g. if Flash is being selected then take the dtack signal produced from the flash controller (which may well come from a timer/counter) and give that to the 68k
  47. -- However you only need to override the above default DtackOut_L <= '0' when you KNOW you need to introduce wait states
  48. -- For devices that are fast enough NOT to need wait states, the above default will work
  49. -- IMPORTANT - if you modify this file, realise that this circuit produces Dtack for ALL devices/chips in the system so make sure it still works for those chips after you modify this circuit
  50. -- If your system hangs after modifications, run the simulator and check whether Dtack is being produced with each access. If not - you've screwed up
  51. --
  52.  
  53. -- here's an example that show how we overrider the default DtackOut_L <= '0' above so that DtackOut_L is produced when we want (not straight away)
  54. -- in this example the dtack generator looks at the address decoder output and if the 68k is accessing the Flash chip (i.e. FlashSelect_H equals '1')
  55. -- we generate DtackOut_L as a copy of the signal produced by the Flash controller (i.e. the signal FlashDtack_L) which comes from a timer built into the flash controller
  56. -- we can add extra 'if' tests to cover all the other kinds of things that may need a dtack other than the deafult above e.g. dram controller etc
  57.  
  58. if(DE2512kRamSelect_H = '1') then
  59. DtackOut_L <= '0';
  60. end if;
  61.  
  62. if(FlashSelect_H = '1') then -- if flash is being selected and for example it needed wait states
  63. DtackOut_L <= FlashDtack_L; -- copy the timeout signal from the flash controller and give this as the dtack to the 68k
  64. end if ;
  65. end if ;
  66. end process ;
  67. END ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement