Guest User

Untitled

a guest
Apr 23rd, 2021
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.25 KB | None | 0 0
  1.  
  2. library ieee ;
  3. use ieee.std_logic_1164.all;
  4. use ieee.std_logic_arith.all;
  5. use ieee.std_logic_unsigned.all;
  6.  
  7. entity targ_term is
  8. port( -- Inputs
  9. clk : in std_logic;
  10. rstn : in std_logic;
  11. l_adro : in std_logic_vector(31 downto 0);
  12. l_dato : in std_logic_vector(31 downto 0);
  13. l_beno : in std_logic_vector(3 downto 0);
  14. l_cmdo : in std_logic_vector(3 downto 0);
  15. lt_framen : in std_logic;
  16. lt_ackn : in std_logic;
  17. lt_dxfrn : in std_logic;
  18. lt_tsr : in std_logic_vector(11 downto 0);
  19. cmd_reg : in std_logic_vector(6 downto 0);
  20. stat_reg : in std_logic_vector(6 downto 0);
  21. -- Outputs
  22. l_adi : out std_logic_vector(31 downto 0);
  23. lt_rdyn : out std_logic;
  24. lt_abortn : out std_logic;
  25. lt_discn : out std_logic;
  26. lt_irqn : out std_logic
  27. );
  28. end targ_term;
  29.  
  30. architecture rtl of targ_term is
  31.  
  32. signal bar0_mem_hit : std_logic;
  33. signal pci_xfr : std_logic;
  34.  
  35. signal lt_framen_q : std_logic;
  36.  
  37. signal cycle_start : std_logic;
  38. signal cycle_end : std_logic;
  39.  
  40. signal targ_wr_rdn : std_logic; -- write = 1 and read = 0
  41.  
  42.  
  43.  
  44. begin
  45. l_adi <= mem_rd_data;
  46. lt_rdyn <= lt_rdyn_tmp;
  47.  
  48. lt_abortn <= '1'; -- Target Abort
  49. lt_irqn <= '1'; -- Irq
  50.  
  51. -- Some renames
  52. bar0_mem_hit <= lt_tsr(0);
  53. pci_xfr <= lt_tsr(10);
  54.  
  55. -- Detect the start and end of a PCI transaction
  56. -- The falling edge of lt_framen can be used to detect start of a
  57. -- PCI transaction, similarly detecting the rising edge of
  58. -- lt_framen indicates the end of the PCI transaction.
  59. process(clk, rstn)
  60. begin
  61. if (rstn='0') then
  62. lt_framen_q <= '1';
  63. elsif(clk'event and clk='1') then
  64. lt_framen_q <= lt_framen;
  65. end if;
  66. end process;
  67.  
  68. cycle_start <= (lt_framen_q and (not(lt_framen)));
  69. cycle_end <= (lt_framen and (not(lt_framen_q)));
  70.  
  71. -- Direction of Data Transfer
  72. -- Read/Write Signals
  73. process(clk)
  74. begin
  75. if (clk'event and clk='1') then
  76. targ_wr_rdn <= l_cmdo(0);
  77. end if;
  78. end process;
  79.  
  80. process(clk, rstn)
  81. begin
  82. if (rstn='0') then
  83. xfr_cntr <= x"00";
  84. elsif (clk'event and clk='1') then
  85. if (cycle_start='1') then
  86. xfr_cntr <= x"00";
  87. elsif (lt_dxfrn='0') then
  88. xfr_cntr <= xfr_cntr + 1;
  89. end if;
  90. end if;
  91. end process;
  92.  
  93. lt_discn<= (not(assert_disc and (not(lt_dxfrn) or transfer_1_dword)));
  94.  
  95. -- Interface to a sync. memory
  96. mem_wr_enable <= (not(lt_dxfrn) and targ_wr_rdn and bar0_mem_hit);
  97.  
  98. -- Generate Address
  99. mem_wr_inc <= (targ_wr_rdn and (not(lt_dxfrn)) and bar0_mem_hit);
  100. mem_rd_inc <= ((not(targ_wr_rdn)) and (not(lt_ackn)) and bar0_mem_hit);
  101.  
  102. mem_inc <= mem_wr_inc or mem_rd_inc;
  103.  
  104. process(clk)
  105. begin
  106. if (clk'event and clk='1') then
  107. if (cycle_start='1') then
  108. mem_addr <= l_adro(9 downto 2);
  109. elsif (mem_inc='1') then
  110. mem_addr <= mem_addr + 1;
  111. end if;
  112. end if;
  113. end process;
  114.  
  115. process(clk)
  116. begin
  117. if (clk'event and clk='1') then
  118. if (mem_wr_enable='1') then
  119. mem_data(conv_integer(mem_addr)) <= l_dato;
  120. end if;
  121. end if;
  122. end process;
  123.  
  124. mem_rdata <= mem_data(conv_integer(mem_addr));
  125.  
  126. process(clk)
  127. begin
  128. if (clk'event and clk='1') then
  129. if (mem_rd_inc='1') then
  130. mem_rd_data <= mem_rdata;
  131. end if;
  132. end if;
  133. end process;
  134.  
  135. end rtl;
Advertisement
Add Comment
Please, Sign In to add comment