Advertisement
Guest User

latest vhd code

a guest
Oct 1st, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.24 KB | None | 0 0
  1. ------------------------------------------------------------------------------
  2. -- hw_acc - entity/architecture pair
  3. ------------------------------------------------------------------------------
  4. --
  5. -- ***************************************************************************
  6. -- ** Copyright (c) 1995-2012 Xilinx, Inc. All rights reserved. **
  7. -- ** **
  8. -- ** Xilinx, Inc. **
  9. -- ** XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" **
  10. -- ** AS A COURTESY TO YOU, SOLELY FOR USE IN DEVELOPING PROGRAMS AND **
  11. -- ** SOLUTIONS FOR XILINX DEVICES. BY PROVIDING THIS DESIGN, CODE, **
  12. -- ** OR INFORMATION AS ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE, **
  13. -- ** APPLICATION OR STANDARD, XILINX IS MAKING NO REPRESENTATION **
  14. -- ** THAT THIS IMPLEMENTATION IS FREE FROM ANY CLAIMS OF INFRINGEMENT, **
  15. -- ** AND YOU ARE RESPONSIBLE FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE **
  16. -- ** FOR YOUR IMPLEMENTATION. XILINX EXPRESSLY DISCLAIMS ANY **
  17. -- ** WARRANTY WHATSOEVER WITH RESPECT TO THE ADEQUACY OF THE **
  18. -- ** IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OR **
  19. -- ** REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE FROM CLAIMS OF **
  20. -- ** INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS **
  21. -- ** FOR A PARTICULAR PURPOSE. **
  22. -- ** **
  23. -- ***************************************************************************
  24. --
  25. ------------------------------------------------------------------------------
  26. -- Filename: hw_acc
  27. -- Version: 1.00.a
  28. -- Description: Example Axi Streaming core (VHDL).
  29. -- Date: Mon Sep 15 15:41:21 2014 (by Create and Import Peripheral Wizard)
  30. -- VHDL Standard: VHDL'93
  31. ------------------------------------------------------------------------------
  32. -- Naming Conventions:
  33. -- active low signals: "*_n"
  34. -- clock signals: "clk", "clk_div#", "clk_#x"
  35. -- reset signals: "rst", "rst_n"
  36. -- generics: "C_*"
  37. -- user defined types: "*_TYPE"
  38. -- state machine next state: "*_ns"
  39. -- state machine current state: "*_cs"
  40. -- combinatorial signals: "*_com"
  41. -- pipelined or register delay signals: "*_d#"
  42. -- counter signals: "*cnt*"
  43. -- clock enable signals: "*_ce"
  44. -- internal version of output port: "*_i"
  45. -- device pins: "*_pin"
  46. -- ports: "- Names begin with Uppercase"
  47. -- processes: "*_PROCESS"
  48. -- component instantiations: "<ENTITY_>I_<#|FUNC>"
  49. ------------------------------------------------------------------------------
  50.  
  51. library ieee;
  52. use ieee.std_logic_1164.all;
  53. use ieee.numeric_std.all;
  54. --use IEEE.numeric_bit.all;
  55. use IEEE.math_real.all;
  56. --use IEEE.math_complex.all;
  57.  
  58. -------------------------------------------------------------------------------------
  59. --
  60. --
  61. -- Definition of Ports
  62. -- ACLK : Synchronous clock
  63. -- ARESETN : System reset, active low
  64. -- S_AXIS_TREADY : Ready to accept data in
  65. -- S_AXIS_TDATA : Data in
  66. -- S_AXIS_TLAST : Optional data in qualifier
  67. -- S_AXIS_TVALID : Data in is valid
  68. -- M_AXIS_TVALID : Data out is valid
  69. -- M_AXIS_TDATA : Data Out
  70. -- M_AXIS_TLAST : Optional data out qualifier
  71. -- M_AXIS_TREADY : Connected slave device is ready to accept data out
  72. --
  73. -------------------------------------------------------------------------------
  74.  
  75. ------------------------------------------------------------------------------
  76. -- Entity Section
  77. ------------------------------------------------------------------------------
  78.  
  79. entity myip_v1_0 is
  80. port
  81. (
  82. -- DO NOT EDIT BELOW THIS LINE ---------------------
  83. -- Bus protocol ports, do not add or delete.
  84. ACLK : in std_logic;
  85. ARESETN : in std_logic;
  86. S_AXIS_TREADY : out std_logic;
  87. S_AXIS_TDATA : in std_logic_vector(31 downto 0);
  88. S_AXIS_TLAST : in std_logic;
  89. S_AXIS_TVALID : in std_logic;
  90. M_AXIS_TVALID : out std_logic;
  91. M_AXIS_TDATA : out std_logic_vector(31 downto 0);
  92. M_AXIS_TLAST : out std_logic;
  93. M_AXIS_TREADY : in std_logic
  94. -- DO EDIT ABOVE THIS LINE ---------------------
  95. );
  96.  
  97. attribute SIGIS : string;
  98. attribute SIGIS of ACLK : signal is "Clk";
  99.  
  100. end myip_v1_0;
  101.  
  102. ------------------------------------------------------------------------------
  103. -- Architecture Section
  104. ------------------------------------------------------------------------------
  105.  
  106. -- In this section, we povide an example implementation of ENTITY hw_acc
  107. -- that does the following:
  108. --
  109. -- 1. Read all inputs
  110. -- 2. Add each input to the contents of register 'product' which
  111. -- acts as an accumulator
  112. -- 3. After all the inputs have been read, write out the
  113. -- content of 'product' into the output stream NUMBER_OF_OUTPUT_WORDS times
  114. --
  115. -- You will need to modify this example or implement a new architecture for
  116. -- ENTITY hw_acc to implement your coprocessor
  117.  
  118. architecture EXAMPLE of myip_v1_0 is
  119.  
  120. -- Total number of input data.
  121. constant NUMBER_OF_INPUT_WORDS : natural := 2;
  122.  
  123. -- Total number of output data
  124. constant NUMBER_OF_OUTPUT_WORDS : natural := 2;
  125.  
  126. type STATE_TYPE is (Idle, Read_Inputs, Write_Outputs);
  127.  
  128. signal state : STATE_TYPE;
  129.  
  130. --to hold input value
  131. signal product_i : std_logic_vector(31 downto 0);
  132.  
  133. -- Accumulator to hold product of inputs read at any point in time
  134. signal product : std_logic_vector(63 downto 0);
  135.  
  136. -- Counters to store the number inputs read & outputs written
  137. signal nr_of_reads : natural range 0 to NUMBER_OF_INPUT_WORDS - 1;
  138. signal nr_of_writes : natural range 0 to NUMBER_OF_OUTPUT_WORDS - 1;
  139. begin
  140. -- CAUTION:
  141. -- The sequence in which data are read in and written out should be
  142. -- consistent with the sequence they are written and read in the
  143. -- driver's hw_acc.c file
  144.  
  145. S_AXIS_TREADY <= '1' when state = Read_Inputs else '0';
  146. M_AXIS_TVALID <= '1' when state = Write_Outputs else '0';
  147. M_AXIS_TLAST <= '1' when (state = Write_Outputs and nr_of_writes = 0) else '0';
  148.  
  149.  
  150. M_AXIS_TDATA <= product;
  151.  
  152.  
  153. The_SW_accelerator : process (ACLK) is
  154. begin -- process The_SW_accelerator
  155. if ACLK'event and ACLK = '1' then -- Rising clock edge
  156. if ARESETN = '0' then -- Synchronous reset (active low)
  157. -- CAUTION: make sure your reset polarity is consistent with the
  158. -- system reset polarity
  159. state <= Idle;
  160. nr_of_reads <= 0;
  161. nr_of_writes <= 0;
  162. product <= (others => '0');
  163. product_i <= (others => '0');
  164. else
  165. case state is
  166. when Idle =>
  167. if (S_AXIS_TVALID = '1') then
  168. state <= Read_Inputs;
  169. nr_of_reads <= NUMBER_OF_INPUT_WORDS - 1;
  170. product <= (others => '0');
  171. product_i <= (others => '0');
  172. end if;
  173.  
  174. when Read_Inputs =>
  175. if (S_AXIS_TVALID = '1') then
  176. -- Coprocessor function (Multiply) happens here
  177. product <= std_logic_vector(unsigned(product_i) * unsigned(S_AXIS_TDATA));
  178. if (nr_of_reads = 0) then
  179. state <= Write_Outputs;
  180. nr_of_writes <= NUMBER_OF_OUTPUT_WORDS - 1;
  181. else
  182. nr_of_reads <= nr_of_reads - 1;
  183. end if;
  184. end if;
  185.  
  186. when Write_Outputs =>
  187. if (M_AXIS_TREADY = '1') then
  188. if (nr_of_writes = 0) then
  189. state <= Idle;
  190. else
  191. nr_of_writes <= nr_of_writes - 1;
  192. end if;
  193. end if;
  194. end case;
  195. end if;
  196. end if;
  197. end process The_SW_accelerator;
  198. end architecture EXAMPLE;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement