当前位置:   article > 正文

AXI4总线_s_axi_awsize

s_axi_awsize

https://developer.arm.com/documentation/ihi0022/c/Signal-Descriptions/Global-signals

------------------------------------------------------------------------------------------------------------

//---------------------------------------------------------------------------------------------

Vivado下创建基于AXI-Lite的用户IP核

http://blog.eetop.cn/blog-1149070-51989.html?_dsign=2609cc76

AXI4 Slave模板[xilinx生成]

(1)、

(2)、

  1. `timescale 1 ns / 1 ps
  2. module myip_v1_0_S00_AXI #
  3. (
  4. // Users to add parameters here
  5. // User parameters ends
  6. // Do not modify the parameters beyond this line
  7. // Width of ID for for write address, write data, read address and read data
  8. parameter integer C_S_AXI_ID_WIDTH = 1,
  9. // Width of S_AXI data bus
  10. parameter integer C_S_AXI_DATA_WIDTH = 32,
  11. // Width of S_AXI address bus
  12. parameter integer C_S_AXI_ADDR_WIDTH = 6,
  13. // Width of optional user defined signal in write address channel
  14. parameter integer C_S_AXI_AWUSER_WIDTH = 0,
  15. // Width of optional user defined signal in read address channel
  16. parameter integer C_S_AXI_ARUSER_WIDTH = 0,
  17. // Width of optional user defined signal in write data channel
  18. parameter integer C_S_AXI_WUSER_WIDTH = 0,
  19. // Width of optional user defined signal in read data channel
  20. parameter integer C_S_AXI_RUSER_WIDTH = 0,
  21. // Width of optional user defined signal in write response channel
  22. parameter integer C_S_AXI_BUSER_WIDTH = 0
  23. )
  24. (
  25. // Users to add ports here
  26. // User ports ends
  27. // Do not modify the ports beyond this line
  28. // Global Clock Signal
  29. input wire S_AXI_ACLK,
  30. // Global Reset Signal. This Signal is Active LOW
  31. input wire S_AXI_ARESETN,
  32. // Write Address ID
  33. input wire [C_S_AXI_ID_WIDTH-1 : 0] S_AXI_AWID,
  34. // Write address
  35. input wire [C_S_AXI_ADDR_WIDTH-1 : 0] S_AXI_AWADDR,
  36. // Burst length. The burst length gives the exact number of transfers in a burst
  37. input wire [7 : 0] S_AXI_AWLEN,
  38. // Burst size. This signal indicates the size of each transfer in the burst
  39. input wire [2 : 0] S_AXI_AWSIZE,
  40. // Burst type. The burst type and the size information,
  41. // determine how the address for each transfer within the burst is calculated.
  42. input wire [1 : 0] S_AXI_AWBURST,
  43. // Lock type. Provides additional information about the
  44. // atomic characteristics of the transfer.
  45. input wire S_AXI_AWLOCK,
  46. // Memory type. This signal indicates how transactions
  47. // are required to progress through a system.
  48. input wire [3 : 0] S_AXI_AWCACHE,
  49. // Protection type. This signal indicates the privilege
  50. // and security level of the transaction, and whether
  51. // the transaction is a data access or an instruction access.
  52. input wire [2 : 0] S_AXI_AWPROT,
  53. // Quality of Service, QoS identifier sent for each
  54. // write transaction.
  55. input wire [3 : 0] S_AXI_AWQOS,
  56. // Region identifier. Permits a single physical interface
  57. // on a slave to be used for multiple logical interfaces.
  58. input wire [3 : 0] S_AXI_AWREGION,
  59. // Optional User-defined signal in the write address channel.
  60. input wire [C_S_AXI_AWUSER_WIDTH-1 : 0] S_AXI_AWUSER,
  61. // Write address valid. This signal indicates that
  62. // the channel is signaling valid write address and
  63. // control information.
  64. input wire S_AXI_AWVALID,
  65. // Write address ready. This signal indicates that
  66. // the slave is ready to accept an address and associated
  67. // control signals.
  68. output wire S_AXI_AWREADY,
  69. // Write Data
  70. input wire [C_S_AXI_DATA_WIDTH-1 : 0] S_AXI_WDATA,
  71. // Write strobes. This signal indicates which byte
  72. // lanes hold valid data. There is one write strobe
  73. // bit for each eight bits of the write data bus.
  74. input wire [(C_S_AXI_DATA_WIDTH/8)-1 : 0] S_AXI_WSTRB,
  75. // Write last. This signal indicates the last transfer
  76. // in a write burst.
  77. input wire S_AXI_WLAST,
  78. // Optional User-defined signal in the write data channel.
  79. input wire [C_S_AXI_WUSER_WIDTH-1 : 0] S_AXI_WUSER,
  80. // Write valid. This signal indicates that valid write
  81. // data and strobes are available.
  82. input wire S_AXI_WVALID,
  83. // Write ready. This signal indicates that the slave
  84. // can accept the write data.
  85. output wire S_AXI_WREADY,
  86. // Response ID tag. This signal is the ID tag of the
  87. // write response.
  88. output wire [C_S_AXI_ID_WIDTH-1 : 0] S_AXI_BID,
  89. // Write response. This signal indicates the status
  90. // of the write transaction.
  91. output wire [1 : 0] S_AXI_BRESP,
  92. // Optional User-defined signal in the write response channel.
  93. output wire [C_S_AXI_BUSER_WIDTH-1 : 0] S_AXI_BUSER,
  94. // Write response valid. This signal indicates that the
  95. // channel is signaling a valid write response.
  96. output wire S_AXI_BVALID,
  97. // Response ready. This signal indicates that the master
  98. // can accept a write response.
  99. input wire S_AXI_BREADY,
  100. // Read address ID. This signal is the identification
  101. // tag for the read address group of signals.
  102. input wire [C_S_AXI_ID_WIDTH-1 : 0] S_AXI_ARID,
  103. // Read address. This signal indicates the initial
  104. // address of a read burst transaction.
  105. input wire [C_S_AXI_ADDR_WIDTH-1 : 0] S_AXI_ARADDR,
  106. // Burst length. The burst length gives the exact number of transfers in a burst
  107. input wire [7 : 0] S_AXI_ARLEN,
  108. // Burst size. This signal indicates the size of each transfer in the burst
  109. input wire [2 : 0] S_AXI_ARSIZE,
  110. // Burst type. The burst type and the size information,
  111. // determine how the address for each transfer within the burst is calculated.
  112. input wire [1 : 0] S_AXI_ARBURST,
  113. // Lock type. Provides additional information about the
  114. // atomic characteristics of the transfer.
  115. input wire S_AXI_ARLOCK,
  116. // Memory type. This signal indicates how transactions
  117. // are required to progress through a system.
  118. input wire [3 : 0] S_AXI_ARCACHE,
  119. // Protection type. This signal indicates the privilege
  120. // and security level of the transaction, and whether
  121. // the transaction is a data access or an instruction access.
  122. input wire [2 : 0] S_AXI_ARPROT,
  123. // Quality of Service, QoS identifier sent for each
  124. // read transaction.
  125. input wire [3 : 0] S_AXI_ARQOS,
  126. // Region identifier. Permits a single physical interface
  127. // on a slave to be used for multiple logical interfaces.
  128. input wire [3 : 0] S_AXI_ARREGION,
  129. // Optional User-defined signal in the read address channel.
  130. input wire [C_S_AXI_ARUSER_WIDTH-1 : 0] S_AXI_ARUSER,
  131. // Write address valid. This signal indicates that
  132. // the channel is signaling valid read address and
  133. // control information.
  134. input wire S_AXI_ARVALID,
  135. // Read address ready. This signal indicates that
  136. // the slave is ready to accept an address and associated
  137. // control signals.
  138. output wire S_AXI_ARREADY,
  139. // Read ID tag. This signal is the identification tag
  140. // for the read data group of signals generated by the slave.
  141. output wire [C_S_AXI_ID_WIDTH-1 : 0] S_AXI_RID,
  142. // Read Data
  143. output wire [C_S_AXI_DATA_WIDTH-1 : 0] S_AXI_RDATA,
  144. // Read response. This signal indicates the status of
  145. // the read transfer.
  146. output wire [1 : 0] S_AXI_RRESP,
  147. // Read last. This signal indicates the last transfer
  148. // in a read burst.
  149. output wire S_AXI_RLAST,
  150. // Optional User-defined signal in the read address channel.
  151. output wire [C_S_AXI_RUSER_WIDTH-1 : 0] S_AXI_RUSER,
  152. // Read valid. This signal indicates that the channel
  153. // is signaling the required read data.
  154. output wire S_AXI_RVALID,
  155. // Read ready. This signal indicates that the master can
  156. // accept the read data and response information.
  157. input wire S_AXI_RREADY
  158. );
  159. // AXI4FULL signals
  160. reg [C_S_AXI_ADDR_WIDTH-1 : 0] axi_awaddr;
  161. reg axi_awready;
  162. reg axi_wready;
  163. reg [1 : 0] axi_bresp;
  164. reg [C_S_AXI_BUSER_WIDTH-1 : 0] axi_buser;
  165. reg axi_bvalid;
  166. reg [C_S_AXI_ADDR_WIDTH-1 : 0] axi_araddr;
  167. reg axi_arready;
  168. reg [C_S_AXI_DATA_WIDTH-1 : 0] axi_rdata;
  169. reg [1 : 0] axi_rresp;
  170. reg axi_rlast;
  171. reg [C_S_AXI_RUSER_WIDTH-1 : 0] axi_ruser;
  172. reg axi_rvalid;
  173. // aw_wrap_en determines wrap boundary and enables wrapping
  174. wire aw_wrap_en;
  175. // ar_wrap_en determines wrap boundary and enables wrapping
  176. wire ar_wrap_en;
  177. // aw_wrap_size is the size of the write transfer, the
  178. // write address wraps to a lower address if upper address
  179. // limit is reached
  180. wire [31:0] aw_wrap_size ;
  181. // ar_wrap_size is the size of the read transfer, the
  182. // read address wraps to a lower address if upper address
  183. // limit is reached
  184. wire [31:0] ar_wrap_size ;
  185. // The axi_awv_awr_flag flag marks the presence of write address valid
  186. reg axi_awv_awr_flag;
  187. //The axi_arv_arr_flag flag marks the presence of read address valid
  188. reg axi_arv_arr_flag;
  189. // The axi_awlen_cntr internal write address counter to keep track of beats in a burst transaction
  190. reg [7:0] axi_awlen_cntr;
  191. //The axi_arlen_cntr internal read address counter to keep track of beats in a burst transaction
  192. reg [7:0] axi_arlen_cntr;
  193. reg [1:0] axi_arburst;
  194. reg [1:0] axi_awburst;
  195. reg [7:0] axi_arlen;
  196. reg [7:0] axi_awlen;
  197. //local parameter for addressing 32 bit / 64 bit C_S_AXI_DATA_WIDTH
  198. //ADDR_LSB is used for addressing 32/64 bit registers/memories
  199. //ADDR_LSB = 2 for 32 bits (n downto 2)
  200. //ADDR_LSB = 3 for 42 bits (n downto 3)
  201. localparam integer ADDR_LSB = (C_S_AXI_DATA_WIDTH/32)+ 1;
  202. localparam integer OPT_MEM_ADDR_BITS = 3;
  203. localparam integer USER_NUM_MEM = 1;
  204. //----------------------------------------------
  205. //-- Signals for user logic memory space example
  206. //------------------------------------------------
  207. wire [OPT_MEM_ADDR_BITS:0] mem_address;
  208. wire [USER_NUM_MEM-1:0] mem_select;
  209. reg [C_S_AXI_DATA_WIDTH-1:0] mem_data_out[0 : USER_NUM_MEM-1];
  210. genvar i;
  211. genvar j;
  212. genvar mem_byte_index;
  213. // I/O Connections assignments
  214. assign S_AXI_AWREADY = axi_awready;
  215. assign S_AXI_WREADY = axi_wready;
  216. assign S_AXI_BRESP = axi_bresp;
  217. assign S_AXI_BUSER = axi_buser;
  218. assign S_AXI_BVALID = axi_bvalid;
  219. assign S_AXI_ARREADY = axi_arready;
  220. assign S_AXI_RDATA = axi_rdata;
  221. assign S_AXI_RRESP = axi_rresp;
  222. assign S_AXI_RLAST = axi_rlast;
  223. assign S_AXI_RUSER = axi_ruser;
  224. assign S_AXI_RVALID = axi_rvalid;
  225. assign S_AXI_BID = S_AXI_AWID;
  226. assign S_AXI_RID = S_AXI_ARID;
  227. assign aw_wrap_size = (C_S_AXI_DATA_WIDTH/8 * (axi_awlen));
  228. assign ar_wrap_size = (C_S_AXI_DATA_WIDTH/8 * (axi_arlen));
  229. assign aw_wrap_en = ((axi_awaddr & aw_wrap_size) == aw_wrap_size)? 1'b1: 1'b0;
  230. assign ar_wrap_en = ((axi_araddr & ar_wrap_size) == ar_wrap_size)? 1'b1: 1'b0;
  231. // Implement axi_awready generation
  232. // axi_awready is asserted for one S_AXI_ACLK clock cycle when both
  233. // S_AXI_AWVALID and S_AXI_WVALID are asserted. axi_awready is
  234. // de-asserted when reset is low.
  235. always @( posedge S_AXI_ACLK )
  236. begin
  237. if ( S_AXI_ARESETN == 1'b0 )
  238. begin
  239. axi_awready <= 1'b0;
  240. axi_awv_awr_flag <= 1'b0;
  241. end
  242. else
  243. begin
  244. if (~axi_awready && S_AXI_AWVALID && ~axi_awv_awr_flag && ~axi_arv_arr_flag)
  245. begin
  246. // slave is ready to accept an address and
  247. // associated control signals
  248. axi_awready <= 1'b1;
  249. axi_awv_awr_flag <= 1'b1;
  250. // used for generation of bresp() and bvalid
  251. end
  252. else if (S_AXI_WLAST && axi_wready)
  253. // preparing to accept next address after current write burst tx completion
  254. begin
  255. axi_awv_awr_flag <= 1'b0;
  256. end
  257. else
  258. begin
  259. axi_awready <= 1'b0;
  260. end
  261. end
  262. end
  263. // Implement axi_awaddr latching
  264. // This process is used to latch the address when both
  265. // S_AXI_AWVALID and S_AXI_WVALID are valid.
  266. always @( posedge S_AXI_ACLK )
  267. begin
  268. if ( S_AXI_ARESETN == 1'b0 )
  269. begin
  270. axi_awaddr <= 0;
  271. axi_awlen_cntr <= 0;
  272. axi_awburst <= 0;
  273. axi_awlen <= 0;
  274. end
  275. else
  276. begin
  277. if (~axi_awready && S_AXI_AWVALID && ~axi_awv_awr_flag)
  278. begin
  279. // address latching
  280. axi_awaddr <= S_AXI_AWADDR[C_S_AXI_ADDR_WIDTH - 1:0];
  281. axi_awburst <= S_AXI_AWBURST;
  282. axi_awlen <= S_AXI_AWLEN;
  283. // start address of transfer
  284. axi_awlen_cntr <= 0;
  285. end
  286. else if((axi_awlen_cntr <= axi_awlen) && axi_wready && S_AXI_WVALID)
  287. begin
  288. axi_awlen_cntr <= axi_awlen_cntr + 1;
  289. case (axi_awburst)
  290. 2'b00: // fixed burst
  291. // The write address for all the beats in the transaction are fixed
  292. begin
  293. axi_awaddr <= axi_awaddr;
  294. //for awsize = 4 bytes (010)
  295. end
  296. 2'b01: //incremental burst
  297. // The write address for all the beats in the transaction are increments by awsize
  298. begin
  299. axi_awaddr[C_S_AXI_ADDR_WIDTH - 1:ADDR_LSB] <= axi_awaddr[C_S_AXI_ADDR_WIDTH - 1:ADDR_LSB] + 1;
  300. //awaddr aligned to 4 byte boundary
  301. axi_awaddr[ADDR_LSB-1:0] <= {ADDR_LSB{1'b0}};
  302. //for awsize = 4 bytes (010)
  303. end
  304. 2'b10: //Wrapping burst
  305. // The write address wraps when the address reaches wrap boundary
  306. if (aw_wrap_en)
  307. begin
  308. axi_awaddr <= (axi_awaddr - aw_wrap_size);
  309. end
  310. else
  311. begin
  312. axi_awaddr[C_S_AXI_ADDR_WIDTH - 1:ADDR_LSB] <= axi_awaddr[C_S_AXI_ADDR_WIDTH - 1:ADDR_LSB] + 1;
  313. axi_awaddr[ADDR_LSB-1:0] <= {ADDR_LSB{1'b0}};
  314. end
  315. default: //reserved (incremental burst for example)
  316. begin
  317. axi_awaddr <= axi_awaddr[C_S_AXI_ADDR_WIDTH - 1:ADDR_LSB] + 1;
  318. //for awsize = 4 bytes (010)
  319. end
  320. endcase
  321. end
  322. end
  323. end
  324. // Implement axi_wready generation
  325. // axi_wready is asserted for one S_AXI_ACLK clock cycle when both
  326. // S_AXI_AWVALID and S_AXI_WVALID are asserted. axi_wready is
  327. // de-asserted when reset is low.
  328. always @( posedge S_AXI_ACLK )
  329. begin
  330. if ( S_AXI_ARESETN == 1'b0 )
  331. begin
  332. axi_wready <= 1'b0;
  333. end
  334. else
  335. begin
  336. if ( ~axi_wready && S_AXI_WVALID && axi_awv_awr_flag)
  337. begin
  338. // slave can accept the write data
  339. axi_wready <= 1'b1;
  340. end
  341. //else if (~axi_awv_awr_flag)
  342. else if (S_AXI_WLAST && axi_wready)
  343. begin
  344. axi_wready <= 1'b0;
  345. end
  346. end
  347. end
  348. // Implement write response logic generation
  349. // The write response and response valid signals are asserted by the slave
  350. // when axi_wready, S_AXI_WVALID, axi_wready and S_AXI_WVALID are asserted.
  351. // This marks the acceptance of address and indicates the status of
  352. // write transaction.
  353. always @( posedge S_AXI_ACLK )
  354. begin
  355. if ( S_AXI_ARESETN == 1'b0 )
  356. begin
  357. axi_bvalid <= 0;
  358. axi_bresp <= 2'b0;
  359. axi_buser <= 0;
  360. end
  361. else
  362. begin
  363. if (axi_awv_awr_flag && axi_wready && S_AXI_WVALID && ~axi_bvalid && S_AXI_WLAST )
  364. begin
  365. axi_bvalid <= 1'b1;
  366. axi_bresp <= 2'b0;
  367. // 'OKAY' response
  368. end
  369. else
  370. begin
  371. if (S_AXI_BREADY && axi_bvalid)
  372. //check if bready is asserted while bvalid is high)
  373. //(there is a possibility that bready is always asserted high)
  374. begin
  375. axi_bvalid <= 1'b0;
  376. end
  377. end
  378. end
  379. end
  380. // Implement axi_arready generation
  381. // axi_arready is asserted for one S_AXI_ACLK clock cycle when
  382. // S_AXI_ARVALID is asserted. axi_awready is
  383. // de-asserted when reset (active low) is asserted.
  384. // The read address is also latched when S_AXI_ARVALID is
  385. // asserted. axi_araddr is reset to zero on reset assertion.
  386. always @( posedge S_AXI_ACLK )
  387. begin
  388. if ( S_AXI_ARESETN == 1'b0 )
  389. begin
  390. axi_arready <= 1'b0;
  391. axi_arv_arr_flag <= 1'b0;
  392. end
  393. else
  394. begin
  395. if (~axi_arready && S_AXI_ARVALID && ~axi_awv_awr_flag && ~axi_arv_arr_flag)
  396. begin
  397. axi_arready <= 1'b1;
  398. axi_arv_arr_flag <= 1'b1;
  399. end
  400. else if (axi_rvalid && S_AXI_RREADY && axi_arlen_cntr == axi_arlen)
  401. // preparing to accept next address after current read completion
  402. begin
  403. axi_arv_arr_flag <= 1'b0;
  404. end
  405. else
  406. begin
  407. axi_arready <= 1'b0;
  408. end
  409. end
  410. end
  411. // Implement axi_araddr latching
  412. //This process is used to latch the address when both
  413. //S_AXI_ARVALID and S_AXI_RVALID are valid.
  414. always @( posedge S_AXI_ACLK )
  415. begin
  416. if ( S_AXI_ARESETN == 1'b0 )
  417. begin
  418. axi_araddr <= 0;
  419. axi_arlen_cntr <= 0;
  420. axi_arburst <= 0;
  421. axi_arlen <= 0;
  422. axi_rlast <= 1'b0;
  423. axi_ruser <= 0;
  424. end
  425. else
  426. begin
  427. if (~axi_arready && S_AXI_ARVALID && ~axi_arv_arr_flag)
  428. begin
  429. // address latching
  430. axi_araddr <= S_AXI_ARADDR[C_S_AXI_ADDR_WIDTH - 1:0];
  431. axi_arburst <= S_AXI_ARBURST;
  432. axi_arlen <= S_AXI_ARLEN;
  433. // start address of transfer
  434. axi_arlen_cntr <= 0;
  435. axi_rlast <= 1'b0;
  436. end
  437. else if((axi_arlen_cntr <= axi_arlen) && axi_rvalid && S_AXI_RREADY)
  438. begin
  439. axi_arlen_cntr <= axi_arlen_cntr + 1;
  440. axi_rlast <= 1'b0;
  441. case (axi_arburst)
  442. 2'b00: // fixed burst
  443. // The read address for all the beats in the transaction are fixed
  444. begin
  445. axi_araddr <= axi_araddr;
  446. //for arsize = 4 bytes (010)
  447. end
  448. 2'b01: //incremental burst
  449. // The read address for all the beats in the transaction are increments by awsize
  450. begin
  451. axi_araddr[C_S_AXI_ADDR_WIDTH - 1:ADDR_LSB] <= axi_araddr[C_S_AXI_ADDR_WIDTH - 1:ADDR_LSB] + 1;
  452. //araddr aligned to 4 byte boundary
  453. axi_araddr[ADDR_LSB-1:0] <= {ADDR_LSB{1'b0}};
  454. //for awsize = 4 bytes (010)
  455. end
  456. 2'b10: //Wrapping burst
  457. // The read address wraps when the address reaches wrap boundary
  458. if (ar_wrap_en)
  459. begin
  460. axi_araddr <= (axi_araddr - ar_wrap_size);
  461. end
  462. else
  463. begin
  464. axi_araddr[C_S_AXI_ADDR_WIDTH - 1:ADDR_LSB] <= axi_araddr[C_S_AXI_ADDR_WIDTH - 1:ADDR_LSB] + 1;
  465. //araddr aligned to 4 byte boundary
  466. axi_araddr[ADDR_LSB-1:0] <= {ADDR_LSB{1'b0}};
  467. end
  468. default: //reserved (incremental burst for example)
  469. begin
  470. axi_araddr <= axi_araddr[C_S_AXI_ADDR_WIDTH - 1:ADDR_LSB]+1;
  471. //for arsize = 4 bytes (010)
  472. end
  473. endcase
  474. end
  475. else if((axi_arlen_cntr == axi_arlen) && ~axi_rlast && axi_arv_arr_flag )
  476. begin
  477. axi_rlast <= 1'b1;
  478. end
  479. else if (S_AXI_RREADY)
  480. begin
  481. axi_rlast <= 1'b0;
  482. end
  483. end
  484. end
  485. // Implement axi_arvalid generation
  486. // axi_rvalid is asserted for one S_AXI_ACLK clock cycle when both
  487. // S_AXI_ARVALID and axi_arready are asserted. The slave registers
  488. // data are available on the axi_rdata bus at this instance. The
  489. // assertion of axi_rvalid marks the validity of read data on the
  490. // bus and axi_rresp indicates the status of read transaction.axi_rvalid
  491. // is deasserted on reset (active low). axi_rresp and axi_rdata are
  492. // cleared to zero on reset (active low).
  493. always @( posedge S_AXI_ACLK )
  494. begin
  495. if ( S_AXI_ARESETN == 1'b0 )
  496. begin
  497. axi_rvalid <= 0;
  498. axi_rresp <= 0;
  499. end
  500. else
  501. begin
  502. if (axi_arv_arr_flag && ~axi_rvalid)
  503. begin
  504. axi_rvalid <= 1'b1;
  505. axi_rresp <= 2'b0;
  506. // 'OKAY' response
  507. end
  508. else if (axi_rvalid && S_AXI_RREADY)
  509. begin
  510. axi_rvalid <= 1'b0;
  511. end
  512. end
  513. end
  514. // ------------------------------------------
  515. // -- Example code to access user logic memory region
  516. // ------------------------------------------
  517. generate
  518. if (USER_NUM_MEM >= 1)
  519. begin
  520. assign mem_select = 1;
  521. assign mem_address = (axi_arv_arr_flag? axi_araddr[ADDR_LSB+OPT_MEM_ADDR_BITS:ADDR_LSB]:(axi_awv_awr_flag? axi_awaddr[ADDR_LSB+OPT_MEM_ADDR_BITS:ADDR_LSB]:0));
  522. end
  523. endgenerate
  524. // implement Block RAM(s)
  525. generate
  526. for(i=0; i<= USER_NUM_MEM-1; i=i+1)
  527. begin:BRAM_GEN
  528. wire mem_rden;
  529. wire mem_wren;
  530. assign mem_wren = axi_wready && S_AXI_WVALID ;
  531. assign mem_rden = axi_arv_arr_flag ; //& ~axi_rvalid
  532. for(mem_byte_index=0; mem_byte_index<= (C_S_AXI_DATA_WIDTH/8-1); mem_byte_index=mem_byte_index+1)
  533. begin:BYTE_BRAM_GEN
  534. wire [8-1:0] data_in ;
  535. wire [8-1:0] data_out;
  536. reg [8-1:0] byte_ram [0 : 15];
  537. integer j;
  538. //assigning 8 bit data
  539. assign data_in = S_AXI_WDATA[(mem_byte_index*8+7) -: 8];
  540. assign data_out = byte_ram[mem_address];
  541. always @( posedge S_AXI_ACLK )
  542. begin
  543. if (mem_wren && S_AXI_WSTRB[mem_byte_index])
  544. begin
  545. byte_ram[mem_address] <= data_in;
  546. end
  547. end
  548. always @( posedge S_AXI_ACLK )
  549. begin
  550. if (mem_rden)
  551. begin
  552. mem_data_out[i][(mem_byte_index*8+7) -: 8] <= data_out;
  553. end
  554. end
  555. end
  556. end
  557. endgenerate
  558. //Output register or memory read data
  559. always @( mem_data_out, axi_rvalid)
  560. begin
  561. if (axi_rvalid)
  562. begin
  563. // Read address mux
  564. axi_rdata <= mem_data_out[0];
  565. end
  566. else
  567. begin
  568. axi_rdata <= 32'h00000000;
  569. end
  570. end
  571. // Add user logic here
  572. // User logic ends
  573. endmodule

使用AXI VIP 对 AXI4-Lite 主 (Master) 接口进行仿真

http://xilinx.eetrend.com/content/2020/100048580.html

axi vip:

https://forums.xilinx.com/t5/Xilinx-%E4%BA%A7%E5%93%81%E8%AE%BE%E8%AE%A1%E4%B8%8E%E5%8A%9F%E8%83%BD%E8%B0%83%E8%AF%95%E6%8A%80%E5%B7%A7/AXI-%E5%9F%BA%E7%A1%80%E7%AC%AC-4-%E8%AE%B2-%E4%BD%BF%E7%94%A8-AXI-VIP-%E4%BD%9C%E4%B8%BA-AXI4-%E4%B8%BB-Master-%E6%8E%A5%E5%8F%A3%E7%9A%84%E5%8D%8F%E8%AE%AE%E6%A3%80%E6%9F%A5%E5%B7%A5%E5%85%B7/ba-p/1093815

outstanding:

https://my.oschina.net/u/4584824/blog/4393587

pg174 - JTAG to AXI Master v1.2

4K边界:

https://blog.csdn.net/hit_shaoqi/article/details/53245521

AXI总线介绍:

https://cloud.tencent.com/developer/article/1661238

https://www.dazhuanlan.com/2019/12/27/5e05ab22c003e/

xilinx axi 参考:

ug761 AXI Reference Guide
https://www.xilinx.com/support/documentation/ip_documentation/ug761_axi_reference_guide.pdf

AXI和AHB对比:

http://www.vlsiip.com/amba/axi_vs_ahb.html

AMBA、AHB、APB、AXI总线介绍及对比:

https://mp.weixin.qq.com/s/d8BfkdKETpXIlrA845oH_w

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/493580?site
推荐阅读
相关标签
  

闽ICP备14008679号