text
stringlengths
938
1.05M
/* * * Copyright (c) 2011 [email protected] * * * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ `timescale 1ns/1ps module e0 (x, y); input [31:0] x; output [31:0] y; assign y = {x[1:0],x[31:2]} ^ {x[12:0],x[31:13]} ^ {x[21:0],x[31:22]}; endmodule module e1 (x, y); input [31:0] x; output [31:0] y; assign y = {x[5:0],x[31:6]} ^ {x[10:0],x[31:11]} ^ {x[24:0],x[31:25]}; endmodule module ch (x, y, z, o); input [31:0] x, y, z; output [31:0] o; assign o = z ^ (x & (y ^ z)); endmodule module maj (x, y, z, o); input [31:0] x, y, z; output [31:0] o; assign o = (x & y) | (z & (x | y)); endmodule module s0 (x, y); input [31:0] x; output [31:0] y; assign y[31:29] = x[6:4] ^ x[17:15]; assign y[28:0] = {x[3:0], x[31:7]} ^ {x[14:0],x[31:18]} ^ x[31:3]; endmodule module s1 (x, y); input [31:0] x; output [31:0] y; assign y[31:22] = x[16:7] ^ x[18:9]; assign y[21:0] = {x[6:0],x[31:17]} ^ {x[8:0],x[31:19]} ^ x[31:10]; endmodule
/* * * Copyright (c) 2011 [email protected] * * * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ `timescale 1ns/1ps module e0 (x, y); input [31:0] x; output [31:0] y; assign y = {x[1:0],x[31:2]} ^ {x[12:0],x[31:13]} ^ {x[21:0],x[31:22]}; endmodule module e1 (x, y); input [31:0] x; output [31:0] y; assign y = {x[5:0],x[31:6]} ^ {x[10:0],x[31:11]} ^ {x[24:0],x[31:25]}; endmodule module ch (x, y, z, o); input [31:0] x, y, z; output [31:0] o; assign o = z ^ (x & (y ^ z)); endmodule module maj (x, y, z, o); input [31:0] x, y, z; output [31:0] o; assign o = (x & y) | (z & (x | y)); endmodule module s0 (x, y); input [31:0] x; output [31:0] y; assign y[31:29] = x[6:4] ^ x[17:15]; assign y[28:0] = {x[3:0], x[31:7]} ^ {x[14:0],x[31:18]} ^ x[31:3]; endmodule module s1 (x, y); input [31:0] x; output [31:0] y; assign y[31:22] = x[16:7] ^ x[18:9]; assign y[21:0] = {x[6:0],x[31:17]} ^ {x[8:0],x[31:19]} ^ x[31:10]; endmodule
/* * * Copyright (c) 2011 [email protected] * * * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ `timescale 1ns/1ps module e0 (x, y); input [31:0] x; output [31:0] y; assign y = {x[1:0],x[31:2]} ^ {x[12:0],x[31:13]} ^ {x[21:0],x[31:22]}; endmodule module e1 (x, y); input [31:0] x; output [31:0] y; assign y = {x[5:0],x[31:6]} ^ {x[10:0],x[31:11]} ^ {x[24:0],x[31:25]}; endmodule module ch (x, y, z, o); input [31:0] x, y, z; output [31:0] o; assign o = z ^ (x & (y ^ z)); endmodule module maj (x, y, z, o); input [31:0] x, y, z; output [31:0] o; assign o = (x & y) | (z & (x | y)); endmodule module s0 (x, y); input [31:0] x; output [31:0] y; assign y[31:29] = x[6:4] ^ x[17:15]; assign y[28:0] = {x[3:0], x[31:7]} ^ {x[14:0],x[31:18]} ^ x[31:3]; endmodule module s1 (x, y); input [31:0] x; output [31:0] y; assign y[31:22] = x[16:7] ^ x[18:9]; assign y[21:0] = {x[6:0],x[31:17]} ^ {x[8:0],x[31:19]} ^ x[31:10]; endmodule
/* * * Copyright (c) 2011 [email protected] * * * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ `timescale 1ns/1ps module e0 (x, y); input [31:0] x; output [31:0] y; assign y = {x[1:0],x[31:2]} ^ {x[12:0],x[31:13]} ^ {x[21:0],x[31:22]}; endmodule module e1 (x, y); input [31:0] x; output [31:0] y; assign y = {x[5:0],x[31:6]} ^ {x[10:0],x[31:11]} ^ {x[24:0],x[31:25]}; endmodule module ch (x, y, z, o); input [31:0] x, y, z; output [31:0] o; assign o = z ^ (x & (y ^ z)); endmodule module maj (x, y, z, o); input [31:0] x, y, z; output [31:0] o; assign o = (x & y) | (z & (x | y)); endmodule module s0 (x, y); input [31:0] x; output [31:0] y; assign y[31:29] = x[6:4] ^ x[17:15]; assign y[28:0] = {x[3:0], x[31:7]} ^ {x[14:0],x[31:18]} ^ x[31:3]; endmodule module s1 (x, y); input [31:0] x; output [31:0] y; assign y[31:22] = x[16:7] ^ x[18:9]; assign y[21:0] = {x[6:0],x[31:17]} ^ {x[8:0],x[31:19]} ^ x[31:10]; endmodule
/* * * Copyright (c) 2011 [email protected] * * * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ `timescale 1ns/1ps module e0 (x, y); input [31:0] x; output [31:0] y; assign y = {x[1:0],x[31:2]} ^ {x[12:0],x[31:13]} ^ {x[21:0],x[31:22]}; endmodule module e1 (x, y); input [31:0] x; output [31:0] y; assign y = {x[5:0],x[31:6]} ^ {x[10:0],x[31:11]} ^ {x[24:0],x[31:25]}; endmodule module ch (x, y, z, o); input [31:0] x, y, z; output [31:0] o; assign o = z ^ (x & (y ^ z)); endmodule module maj (x, y, z, o); input [31:0] x, y, z; output [31:0] o; assign o = (x & y) | (z & (x | y)); endmodule module s0 (x, y); input [31:0] x; output [31:0] y; assign y[31:29] = x[6:4] ^ x[17:15]; assign y[28:0] = {x[3:0], x[31:7]} ^ {x[14:0],x[31:18]} ^ x[31:3]; endmodule module s1 (x, y); input [31:0] x; output [31:0] y; assign y[31:22] = x[16:7] ^ x[18:9]; assign y[21:0] = {x[6:0],x[31:17]} ^ {x[8:0],x[31:19]} ^ x[31:10]; endmodule
/* * * Copyright (c) 2011 [email protected] * * * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ `timescale 1ns/1ps module e0 (x, y); input [31:0] x; output [31:0] y; assign y = {x[1:0],x[31:2]} ^ {x[12:0],x[31:13]} ^ {x[21:0],x[31:22]}; endmodule module e1 (x, y); input [31:0] x; output [31:0] y; assign y = {x[5:0],x[31:6]} ^ {x[10:0],x[31:11]} ^ {x[24:0],x[31:25]}; endmodule module ch (x, y, z, o); input [31:0] x, y, z; output [31:0] o; assign o = z ^ (x & (y ^ z)); endmodule module maj (x, y, z, o); input [31:0] x, y, z; output [31:0] o; assign o = (x & y) | (z & (x | y)); endmodule module s0 (x, y); input [31:0] x; output [31:0] y; assign y[31:29] = x[6:4] ^ x[17:15]; assign y[28:0] = {x[3:0], x[31:7]} ^ {x[14:0],x[31:18]} ^ x[31:3]; endmodule module s1 (x, y); input [31:0] x; output [31:0] y; assign y[31:22] = x[16:7] ^ x[18:9]; assign y[21:0] = {x[6:0],x[31:17]} ^ {x[8:0],x[31:19]} ^ x[31:10]; endmodule
/* * * Copyright (c) 2011 [email protected] * * * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ `timescale 1ns/1ps module e0 (x, y); input [31:0] x; output [31:0] y; assign y = {x[1:0],x[31:2]} ^ {x[12:0],x[31:13]} ^ {x[21:0],x[31:22]}; endmodule module e1 (x, y); input [31:0] x; output [31:0] y; assign y = {x[5:0],x[31:6]} ^ {x[10:0],x[31:11]} ^ {x[24:0],x[31:25]}; endmodule module ch (x, y, z, o); input [31:0] x, y, z; output [31:0] o; assign o = z ^ (x & (y ^ z)); endmodule module maj (x, y, z, o); input [31:0] x, y, z; output [31:0] o; assign o = (x & y) | (z & (x | y)); endmodule module s0 (x, y); input [31:0] x; output [31:0] y; assign y[31:29] = x[6:4] ^ x[17:15]; assign y[28:0] = {x[3:0], x[31:7]} ^ {x[14:0],x[31:18]} ^ x[31:3]; endmodule module s1 (x, y); input [31:0] x; output [31:0] y; assign y[31:22] = x[16:7] ^ x[18:9]; assign y[21:0] = {x[6:0],x[31:17]} ^ {x[8:0],x[31:19]} ^ x[31:10]; endmodule
// -- (c) Copyright 2012 -2013 Xilinx, Inc. All rights reserved. // -- // -- This file contains confidential and proprietary information // -- of Xilinx, Inc. and is protected under U.S. and // -- international copyright and other intellectual property // -- laws. // -- // -- DISCLAIMER // -- This disclaimer is not a license and does not grant any // -- rights to the materials distributed herewith. Except as // -- otherwise provided in a valid license issued to you by // -- Xilinx, and to the maximum extent permitted by applicable // -- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND // -- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES // -- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING // -- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- // -- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and // -- (2) Xilinx shall not be liable (whether in contract or tort, // -- including negligence, or under any other theory of // -- liability) for any loss or damage of any kind or nature // -- related to, arising under or in connection with these // -- materials, including for any direct, or any indirect, // -- special, incidental, or consequential loss or damage // -- (including loss of data, profits, goodwill, or any type of // -- loss or damage suffered as a result of any action brought // -- by a third party) even if such damage or loss was // -- reasonably foreseeable or Xilinx had been advised of the // -- possibility of the same. // -- // -- CRITICAL APPLICATIONS // -- Xilinx products are not designed or intended to be fail- // -- safe, or for use in any application requiring fail-safe // -- performance, such as life-support or safety devices or // -- systems, Class III medical devices, nuclear facilities, // -- applications related to the deployment of airbags, or any // -- other applications that could lead to death, personal // -- injury, or severe property or environmental damage // -- (individually and collectively, "Critical // -- Applications"). Customer assumes the sole risk and // -- liability of any use of Xilinx products in Critical // -- Applications, subject only to applicable laws and // -- regulations governing limitations on product liability. // -- // -- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS // -- PART OF THIS FILE AT ALL TIMES. //----------------------------------------------------------------------------- // // File name: axi_protocol_converter.v // // Description: // This module is a bank of AXI4-Lite and AXI3 protocol converters for a vectored AXI interface. // The interface of this module consists of a vectored slave and master interface // which are each concatenations of upper-level AXI pathways, // plus various vectored parameters. // This module instantiates a set of individual protocol converter modules. // //----------------------------------------------------------------------------- `timescale 1ps/1ps `default_nettype none (* DowngradeIPIdentifiedWarnings="yes" *) module axi_protocol_converter_v2_1_axi_protocol_converter #( parameter C_FAMILY = "virtex6", parameter integer C_M_AXI_PROTOCOL = 0, parameter integer C_S_AXI_PROTOCOL = 0, parameter integer C_IGNORE_ID = 0, // 0 = RID/BID are stored by axilite_conv. // 1 = RID/BID have already been stored in an upstream device, like SASD crossbar. parameter integer C_AXI_ID_WIDTH = 4, parameter integer C_AXI_ADDR_WIDTH = 32, parameter integer C_AXI_DATA_WIDTH = 32, parameter integer C_AXI_SUPPORTS_WRITE = 1, parameter integer C_AXI_SUPPORTS_READ = 1, parameter integer C_AXI_SUPPORTS_USER_SIGNALS = 0, // 1 = Propagate all USER signals, 0 = Don’t propagate. parameter integer C_AXI_AWUSER_WIDTH = 1, parameter integer C_AXI_ARUSER_WIDTH = 1, parameter integer C_AXI_WUSER_WIDTH = 1, parameter integer C_AXI_RUSER_WIDTH = 1, parameter integer C_AXI_BUSER_WIDTH = 1, parameter integer C_TRANSLATION_MODE = 1 // 0 (Unprotected) = Disable all error checking; master is well-behaved. // 1 (Protection) = Detect SI transaction violations, but perform no splitting. // AXI4 -> AXI3 must be <= 16 beats; AXI4/3 -> AXI4LITE must be single. // 2 (Conversion) = Include transaction splitting logic ) ( // Global Signals input wire aclk, input wire aresetn, // Slave Interface Write Address Ports input wire [C_AXI_ID_WIDTH-1:0] s_axi_awid, input wire [C_AXI_ADDR_WIDTH-1:0] s_axi_awaddr, input wire [((C_S_AXI_PROTOCOL == 1) ? 4 : 8)-1:0] s_axi_awlen, input wire [3-1:0] s_axi_awsize, input wire [2-1:0] s_axi_awburst, input wire [((C_S_AXI_PROTOCOL == 1) ? 2 : 1)-1:0] s_axi_awlock, input wire [4-1:0] s_axi_awcache, input wire [3-1:0] s_axi_awprot, input wire [4-1:0] s_axi_awregion, input wire [4-1:0] s_axi_awqos, input wire [C_AXI_AWUSER_WIDTH-1:0] s_axi_awuser, input wire s_axi_awvalid, output wire s_axi_awready, // Slave Interface Write Data Ports input wire [C_AXI_ID_WIDTH-1:0] s_axi_wid, input wire [C_AXI_DATA_WIDTH-1:0] s_axi_wdata, input wire [C_AXI_DATA_WIDTH/8-1:0] s_axi_wstrb, input wire s_axi_wlast, input wire [C_AXI_WUSER_WIDTH-1:0] s_axi_wuser, input wire s_axi_wvalid, output wire s_axi_wready, // Slave Interface Write Response Ports output wire [C_AXI_ID_WIDTH-1:0] s_axi_bid, output wire [2-1:0] s_axi_bresp, output wire [C_AXI_BUSER_WIDTH-1:0] s_axi_buser, output wire s_axi_bvalid, input wire s_axi_bready, // Slave Interface Read Address Ports input wire [C_AXI_ID_WIDTH-1:0] s_axi_arid, input wire [C_AXI_ADDR_WIDTH-1:0] s_axi_araddr, input wire [((C_S_AXI_PROTOCOL == 1) ? 4 : 8)-1:0] s_axi_arlen, input wire [3-1:0] s_axi_arsize, input wire [2-1:0] s_axi_arburst, input wire [((C_S_AXI_PROTOCOL == 1) ? 2 : 1)-1:0] s_axi_arlock, input wire [4-1:0] s_axi_arcache, input wire [3-1:0] s_axi_arprot, input wire [4-1:0] s_axi_arregion, input wire [4-1:0] s_axi_arqos, input wire [C_AXI_ARUSER_WIDTH-1:0] s_axi_aruser, input wire s_axi_arvalid, output wire s_axi_arready, // Slave Interface Read Data Ports output wire [C_AXI_ID_WIDTH-1:0] s_axi_rid, output wire [C_AXI_DATA_WIDTH-1:0] s_axi_rdata, output wire [2-1:0] s_axi_rresp, output wire s_axi_rlast, output wire [C_AXI_RUSER_WIDTH-1:0] s_axi_ruser, output wire s_axi_rvalid, input wire s_axi_rready, // Master Interface Write Address Port output wire [C_AXI_ID_WIDTH-1:0] m_axi_awid, output wire [C_AXI_ADDR_WIDTH-1:0] m_axi_awaddr, output wire [((C_M_AXI_PROTOCOL == 1) ? 4 : 8)-1:0] m_axi_awlen, output wire [3-1:0] m_axi_awsize, output wire [2-1:0] m_axi_awburst, output wire [((C_M_AXI_PROTOCOL == 1) ? 2 : 1)-1:0] m_axi_awlock, output wire [4-1:0] m_axi_awcache, output wire [3-1:0] m_axi_awprot, output wire [4-1:0] m_axi_awregion, output wire [4-1:0] m_axi_awqos, output wire [C_AXI_AWUSER_WIDTH-1:0] m_axi_awuser, output wire m_axi_awvalid, input wire m_axi_awready, // Master Interface Write Data Ports output wire [C_AXI_ID_WIDTH-1:0] m_axi_wid, output wire [C_AXI_DATA_WIDTH-1:0] m_axi_wdata, output wire [C_AXI_DATA_WIDTH/8-1:0] m_axi_wstrb, output wire m_axi_wlast, output wire [C_AXI_WUSER_WIDTH-1:0] m_axi_wuser, output wire m_axi_wvalid, input wire m_axi_wready, // Master Interface Write Response Ports input wire [C_AXI_ID_WIDTH-1:0] m_axi_bid, input wire [2-1:0] m_axi_bresp, input wire [C_AXI_BUSER_WIDTH-1:0] m_axi_buser, input wire m_axi_bvalid, output wire m_axi_bready, // Master Interface Read Address Port output wire [C_AXI_ID_WIDTH-1:0] m_axi_arid, output wire [C_AXI_ADDR_WIDTH-1:0] m_axi_araddr, output wire [((C_M_AXI_PROTOCOL == 1) ? 4 : 8)-1:0] m_axi_arlen, output wire [3-1:0] m_axi_arsize, output wire [2-1:0] m_axi_arburst, output wire [((C_M_AXI_PROTOCOL == 1) ? 2 : 1)-1:0] m_axi_arlock, output wire [4-1:0] m_axi_arcache, output wire [3-1:0] m_axi_arprot, output wire [4-1:0] m_axi_arregion, output wire [4-1:0] m_axi_arqos, output wire [C_AXI_ARUSER_WIDTH-1:0] m_axi_aruser, output wire m_axi_arvalid, input wire m_axi_arready, // Master Interface Read Data Ports input wire [C_AXI_ID_WIDTH-1:0] m_axi_rid, input wire [C_AXI_DATA_WIDTH-1:0] m_axi_rdata, input wire [2-1:0] m_axi_rresp, input wire m_axi_rlast, input wire [C_AXI_RUSER_WIDTH-1:0] m_axi_ruser, input wire m_axi_rvalid, output wire m_axi_rready ); localparam P_AXI4 = 32'h0; localparam P_AXI3 = 32'h1; localparam P_AXILITE = 32'h2; localparam P_AXILITE_SIZE = (C_AXI_DATA_WIDTH == 32) ? 3'b010 : 3'b011; localparam P_INCR = 2'b01; localparam P_DECERR = 2'b11; localparam P_SLVERR = 2'b10; localparam integer P_PROTECTION = 1; localparam integer P_CONVERSION = 2; wire s_awvalid_i; wire s_arvalid_i; wire s_wvalid_i ; wire s_bready_i ; wire s_rready_i ; wire s_awready_i; wire s_wready_i; wire s_bvalid_i; wire [C_AXI_ID_WIDTH-1:0] s_bid_i; wire [1:0] s_bresp_i; wire [C_AXI_BUSER_WIDTH-1:0] s_buser_i; wire s_arready_i; wire s_rvalid_i; wire [C_AXI_ID_WIDTH-1:0] s_rid_i; wire [1:0] s_rresp_i; wire [C_AXI_RUSER_WIDTH-1:0] s_ruser_i; wire [C_AXI_DATA_WIDTH-1:0] s_rdata_i; wire s_rlast_i; generate if ((C_M_AXI_PROTOCOL == P_AXILITE) || (C_S_AXI_PROTOCOL == P_AXILITE)) begin : gen_axilite assign m_axi_awid = 0; assign m_axi_awlen = 0; assign m_axi_awsize = P_AXILITE_SIZE; assign m_axi_awburst = P_INCR; assign m_axi_awlock = 0; assign m_axi_awcache = 0; assign m_axi_awregion = 0; assign m_axi_awqos = 0; assign m_axi_awuser = 0; assign m_axi_wid = 0; assign m_axi_wlast = 1'b1; assign m_axi_wuser = 0; assign m_axi_arid = 0; assign m_axi_arlen = 0; assign m_axi_arsize = P_AXILITE_SIZE; assign m_axi_arburst = P_INCR; assign m_axi_arlock = 0; assign m_axi_arcache = 0; assign m_axi_arregion = 0; assign m_axi_arqos = 0; assign m_axi_aruser = 0; if (((C_IGNORE_ID == 1) && (C_TRANSLATION_MODE != P_CONVERSION)) || (C_S_AXI_PROTOCOL == P_AXILITE)) begin : gen_axilite_passthru assign m_axi_awaddr = s_axi_awaddr; assign m_axi_awprot = s_axi_awprot; assign m_axi_awvalid = s_awvalid_i; assign s_awready_i = m_axi_awready; assign m_axi_wdata = s_axi_wdata; assign m_axi_wstrb = s_axi_wstrb; assign m_axi_wvalid = s_wvalid_i; assign s_wready_i = m_axi_wready; assign s_bid_i = 0; assign s_bresp_i = m_axi_bresp; assign s_buser_i = 0; assign s_bvalid_i = m_axi_bvalid; assign m_axi_bready = s_bready_i; assign m_axi_araddr = s_axi_araddr; assign m_axi_arprot = s_axi_arprot; assign m_axi_arvalid = s_arvalid_i; assign s_arready_i = m_axi_arready; assign s_rid_i = 0; assign s_rdata_i = m_axi_rdata; assign s_rresp_i = m_axi_rresp; assign s_rlast_i = 1'b1; assign s_ruser_i = 0; assign s_rvalid_i = m_axi_rvalid; assign m_axi_rready = s_rready_i; end else if (C_TRANSLATION_MODE == P_CONVERSION) begin : gen_b2s_conv assign s_buser_i = {C_AXI_BUSER_WIDTH{1'b0}}; assign s_ruser_i = {C_AXI_RUSER_WIDTH{1'b0}}; axi_protocol_converter_v2_1_b2s #( .C_S_AXI_PROTOCOL (C_S_AXI_PROTOCOL), .C_AXI_ID_WIDTH (C_AXI_ID_WIDTH), .C_AXI_ADDR_WIDTH (C_AXI_ADDR_WIDTH), .C_AXI_DATA_WIDTH (C_AXI_DATA_WIDTH), .C_AXI_SUPPORTS_WRITE (C_AXI_SUPPORTS_WRITE), .C_AXI_SUPPORTS_READ (C_AXI_SUPPORTS_READ) ) axilite_b2s ( .aresetn (aresetn), .aclk (aclk), .s_axi_awid (s_axi_awid), .s_axi_awaddr (s_axi_awaddr), .s_axi_awlen (s_axi_awlen), .s_axi_awsize (s_axi_awsize), .s_axi_awburst (s_axi_awburst), .s_axi_awprot (s_axi_awprot), .s_axi_awvalid (s_awvalid_i), .s_axi_awready (s_awready_i), .s_axi_wdata (s_axi_wdata), .s_axi_wstrb (s_axi_wstrb), .s_axi_wlast (s_axi_wlast), .s_axi_wvalid (s_wvalid_i), .s_axi_wready (s_wready_i), .s_axi_bid (s_bid_i), .s_axi_bresp (s_bresp_i), .s_axi_bvalid (s_bvalid_i), .s_axi_bready (s_bready_i), .s_axi_arid (s_axi_arid), .s_axi_araddr (s_axi_araddr), .s_axi_arlen (s_axi_arlen), .s_axi_arsize (s_axi_arsize), .s_axi_arburst (s_axi_arburst), .s_axi_arprot (s_axi_arprot), .s_axi_arvalid (s_arvalid_i), .s_axi_arready (s_arready_i), .s_axi_rid (s_rid_i), .s_axi_rdata (s_rdata_i), .s_axi_rresp (s_rresp_i), .s_axi_rlast (s_rlast_i), .s_axi_rvalid (s_rvalid_i), .s_axi_rready (s_rready_i), .m_axi_awaddr (m_axi_awaddr), .m_axi_awprot (m_axi_awprot), .m_axi_awvalid (m_axi_awvalid), .m_axi_awready (m_axi_awready), .m_axi_wdata (m_axi_wdata), .m_axi_wstrb (m_axi_wstrb), .m_axi_wvalid (m_axi_wvalid), .m_axi_wready (m_axi_wready), .m_axi_bresp (m_axi_bresp), .m_axi_bvalid (m_axi_bvalid), .m_axi_bready (m_axi_bready), .m_axi_araddr (m_axi_araddr), .m_axi_arprot (m_axi_arprot), .m_axi_arvalid (m_axi_arvalid), .m_axi_arready (m_axi_arready), .m_axi_rdata (m_axi_rdata), .m_axi_rresp (m_axi_rresp), .m_axi_rvalid (m_axi_rvalid), .m_axi_rready (m_axi_rready) ); end else begin : gen_axilite_conv axi_protocol_converter_v2_1_axilite_conv #( .C_FAMILY (C_FAMILY), .C_AXI_ID_WIDTH (C_AXI_ID_WIDTH), .C_AXI_ADDR_WIDTH (C_AXI_ADDR_WIDTH), .C_AXI_DATA_WIDTH (C_AXI_DATA_WIDTH), .C_AXI_SUPPORTS_WRITE (C_AXI_SUPPORTS_WRITE), .C_AXI_SUPPORTS_READ (C_AXI_SUPPORTS_READ), .C_AXI_RUSER_WIDTH (C_AXI_RUSER_WIDTH), .C_AXI_BUSER_WIDTH (C_AXI_BUSER_WIDTH) ) axilite_conv_inst ( .ARESETN (aresetn), .ACLK (aclk), .S_AXI_AWID (s_axi_awid), .S_AXI_AWADDR (s_axi_awaddr), .S_AXI_AWPROT (s_axi_awprot), .S_AXI_AWVALID (s_awvalid_i), .S_AXI_AWREADY (s_awready_i), .S_AXI_WDATA (s_axi_wdata), .S_AXI_WSTRB (s_axi_wstrb), .S_AXI_WVALID (s_wvalid_i), .S_AXI_WREADY (s_wready_i), .S_AXI_BID (s_bid_i), .S_AXI_BRESP (s_bresp_i), .S_AXI_BUSER (s_buser_i), .S_AXI_BVALID (s_bvalid_i), .S_AXI_BREADY (s_bready_i), .S_AXI_ARID (s_axi_arid), .S_AXI_ARADDR (s_axi_araddr), .S_AXI_ARPROT (s_axi_arprot), .S_AXI_ARVALID (s_arvalid_i), .S_AXI_ARREADY (s_arready_i), .S_AXI_RID (s_rid_i), .S_AXI_RDATA (s_rdata_i), .S_AXI_RRESP (s_rresp_i), .S_AXI_RLAST (s_rlast_i), .S_AXI_RUSER (s_ruser_i), .S_AXI_RVALID (s_rvalid_i), .S_AXI_RREADY (s_rready_i), .M_AXI_AWADDR (m_axi_awaddr), .M_AXI_AWPROT (m_axi_awprot), .M_AXI_AWVALID (m_axi_awvalid), .M_AXI_AWREADY (m_axi_awready), .M_AXI_WDATA (m_axi_wdata), .M_AXI_WSTRB (m_axi_wstrb), .M_AXI_WVALID (m_axi_wvalid), .M_AXI_WREADY (m_axi_wready), .M_AXI_BRESP (m_axi_bresp), .M_AXI_BVALID (m_axi_bvalid), .M_AXI_BREADY (m_axi_bready), .M_AXI_ARADDR (m_axi_araddr), .M_AXI_ARPROT (m_axi_arprot), .M_AXI_ARVALID (m_axi_arvalid), .M_AXI_ARREADY (m_axi_arready), .M_AXI_RDATA (m_axi_rdata), .M_AXI_RRESP (m_axi_rresp), .M_AXI_RVALID (m_axi_rvalid), .M_AXI_RREADY (m_axi_rready) ); end end else if ((C_M_AXI_PROTOCOL == P_AXI3) && (C_S_AXI_PROTOCOL == P_AXI4)) begin : gen_axi4_axi3 axi_protocol_converter_v2_1_axi3_conv #( .C_FAMILY (C_FAMILY), .C_AXI_ID_WIDTH (C_AXI_ID_WIDTH), .C_AXI_ADDR_WIDTH (C_AXI_ADDR_WIDTH), .C_AXI_DATA_WIDTH (C_AXI_DATA_WIDTH), .C_AXI_SUPPORTS_USER_SIGNALS (C_AXI_SUPPORTS_USER_SIGNALS), .C_AXI_AWUSER_WIDTH (C_AXI_AWUSER_WIDTH), .C_AXI_ARUSER_WIDTH (C_AXI_ARUSER_WIDTH), .C_AXI_WUSER_WIDTH (C_AXI_WUSER_WIDTH), .C_AXI_RUSER_WIDTH (C_AXI_RUSER_WIDTH), .C_AXI_BUSER_WIDTH (C_AXI_BUSER_WIDTH), .C_AXI_SUPPORTS_WRITE (C_AXI_SUPPORTS_WRITE), .C_AXI_SUPPORTS_READ (C_AXI_SUPPORTS_READ), .C_SUPPORT_SPLITTING ((C_TRANSLATION_MODE == P_CONVERSION) ? 1 : 0) ) axi3_conv_inst ( .ARESETN (aresetn), .ACLK (aclk), .S_AXI_AWID (s_axi_awid), .S_AXI_AWADDR (s_axi_awaddr), .S_AXI_AWLEN (s_axi_awlen), .S_AXI_AWSIZE (s_axi_awsize), .S_AXI_AWBURST (s_axi_awburst), .S_AXI_AWLOCK (s_axi_awlock), .S_AXI_AWCACHE (s_axi_awcache), .S_AXI_AWPROT (s_axi_awprot), .S_AXI_AWQOS (s_axi_awqos), .S_AXI_AWUSER (s_axi_awuser), .S_AXI_AWVALID (s_awvalid_i), .S_AXI_AWREADY (s_awready_i), .S_AXI_WDATA (s_axi_wdata), .S_AXI_WSTRB (s_axi_wstrb), .S_AXI_WLAST (s_axi_wlast), .S_AXI_WUSER (s_axi_wuser), .S_AXI_WVALID (s_wvalid_i), .S_AXI_WREADY (s_wready_i), .S_AXI_BID (s_bid_i), .S_AXI_BRESP (s_bresp_i), .S_AXI_BUSER (s_buser_i), .S_AXI_BVALID (s_bvalid_i), .S_AXI_BREADY (s_bready_i), .S_AXI_ARID (s_axi_arid), .S_AXI_ARADDR (s_axi_araddr), .S_AXI_ARLEN (s_axi_arlen), .S_AXI_ARSIZE (s_axi_arsize), .S_AXI_ARBURST (s_axi_arburst), .S_AXI_ARLOCK (s_axi_arlock), .S_AXI_ARCACHE (s_axi_arcache), .S_AXI_ARPROT (s_axi_arprot), .S_AXI_ARQOS (s_axi_arqos), .S_AXI_ARUSER (s_axi_aruser), .S_AXI_ARVALID (s_arvalid_i), .S_AXI_ARREADY (s_arready_i), .S_AXI_RID (s_rid_i), .S_AXI_RDATA (s_rdata_i), .S_AXI_RRESP (s_rresp_i), .S_AXI_RLAST (s_rlast_i), .S_AXI_RUSER (s_ruser_i), .S_AXI_RVALID (s_rvalid_i), .S_AXI_RREADY (s_rready_i), .M_AXI_AWID (m_axi_awid), .M_AXI_AWADDR (m_axi_awaddr), .M_AXI_AWLEN (m_axi_awlen), .M_AXI_AWSIZE (m_axi_awsize), .M_AXI_AWBURST (m_axi_awburst), .M_AXI_AWLOCK (m_axi_awlock), .M_AXI_AWCACHE (m_axi_awcache), .M_AXI_AWPROT (m_axi_awprot), .M_AXI_AWQOS (m_axi_awqos), .M_AXI_AWUSER (m_axi_awuser), .M_AXI_AWVALID (m_axi_awvalid), .M_AXI_AWREADY (m_axi_awready), .M_AXI_WID (m_axi_wid), .M_AXI_WDATA (m_axi_wdata), .M_AXI_WSTRB (m_axi_wstrb), .M_AXI_WLAST (m_axi_wlast), .M_AXI_WUSER (m_axi_wuser), .M_AXI_WVALID (m_axi_wvalid), .M_AXI_WREADY (m_axi_wready), .M_AXI_BID (m_axi_bid), .M_AXI_BRESP (m_axi_bresp), .M_AXI_BUSER (m_axi_buser), .M_AXI_BVALID (m_axi_bvalid), .M_AXI_BREADY (m_axi_bready), .M_AXI_ARID (m_axi_arid), .M_AXI_ARADDR (m_axi_araddr), .M_AXI_ARLEN (m_axi_arlen), .M_AXI_ARSIZE (m_axi_arsize), .M_AXI_ARBURST (m_axi_arburst), .M_AXI_ARLOCK (m_axi_arlock), .M_AXI_ARCACHE (m_axi_arcache), .M_AXI_ARPROT (m_axi_arprot), .M_AXI_ARQOS (m_axi_arqos), .M_AXI_ARUSER (m_axi_aruser), .M_AXI_ARVALID (m_axi_arvalid), .M_AXI_ARREADY (m_axi_arready), .M_AXI_RID (m_axi_rid), .M_AXI_RDATA (m_axi_rdata), .M_AXI_RRESP (m_axi_rresp), .M_AXI_RLAST (m_axi_rlast), .M_AXI_RUSER (m_axi_ruser), .M_AXI_RVALID (m_axi_rvalid), .M_AXI_RREADY (m_axi_rready) ); assign m_axi_awregion = 0; assign m_axi_arregion = 0; end else if ((C_S_AXI_PROTOCOL == P_AXI3) && (C_M_AXI_PROTOCOL == P_AXI4)) begin : gen_axi3_axi4 assign m_axi_awid = s_axi_awid; assign m_axi_awaddr = s_axi_awaddr; assign m_axi_awlen = {4'h0, s_axi_awlen[3:0]}; assign m_axi_awsize = s_axi_awsize; assign m_axi_awburst = s_axi_awburst; assign m_axi_awlock = s_axi_awlock[0]; assign m_axi_awcache = s_axi_awcache; assign m_axi_awprot = s_axi_awprot; assign m_axi_awregion = 4'h0; assign m_axi_awqos = s_axi_awqos; assign m_axi_awuser = s_axi_awuser; assign m_axi_awvalid = s_awvalid_i; assign s_awready_i = m_axi_awready; assign m_axi_wid = {C_AXI_ID_WIDTH{1'b0}} ; assign m_axi_wdata = s_axi_wdata; assign m_axi_wstrb = s_axi_wstrb; assign m_axi_wlast = s_axi_wlast; assign m_axi_wuser = s_axi_wuser; assign m_axi_wvalid = s_wvalid_i; assign s_wready_i = m_axi_wready; assign s_bid_i = m_axi_bid; assign s_bresp_i = m_axi_bresp; assign s_buser_i = m_axi_buser; assign s_bvalid_i = m_axi_bvalid; assign m_axi_bready = s_bready_i; assign m_axi_arid = s_axi_arid; assign m_axi_araddr = s_axi_araddr; assign m_axi_arlen = {4'h0, s_axi_arlen[3:0]}; assign m_axi_arsize = s_axi_arsize; assign m_axi_arburst = s_axi_arburst; assign m_axi_arlock = s_axi_arlock[0]; assign m_axi_arcache = s_axi_arcache; assign m_axi_arprot = s_axi_arprot; assign m_axi_arregion = 4'h0; assign m_axi_arqos = s_axi_arqos; assign m_axi_aruser = s_axi_aruser; assign m_axi_arvalid = s_arvalid_i; assign s_arready_i = m_axi_arready; assign s_rid_i = m_axi_rid; assign s_rdata_i = m_axi_rdata; assign s_rresp_i = m_axi_rresp; assign s_rlast_i = m_axi_rlast; assign s_ruser_i = m_axi_ruser; assign s_rvalid_i = m_axi_rvalid; assign m_axi_rready = s_rready_i; end else begin :gen_no_conv assign m_axi_awid = s_axi_awid; assign m_axi_awaddr = s_axi_awaddr; assign m_axi_awlen = s_axi_awlen; assign m_axi_awsize = s_axi_awsize; assign m_axi_awburst = s_axi_awburst; assign m_axi_awlock = s_axi_awlock; assign m_axi_awcache = s_axi_awcache; assign m_axi_awprot = s_axi_awprot; assign m_axi_awregion = s_axi_awregion; assign m_axi_awqos = s_axi_awqos; assign m_axi_awuser = s_axi_awuser; assign m_axi_awvalid = s_awvalid_i; assign s_awready_i = m_axi_awready; assign m_axi_wid = s_axi_wid; assign m_axi_wdata = s_axi_wdata; assign m_axi_wstrb = s_axi_wstrb; assign m_axi_wlast = s_axi_wlast; assign m_axi_wuser = s_axi_wuser; assign m_axi_wvalid = s_wvalid_i; assign s_wready_i = m_axi_wready; assign s_bid_i = m_axi_bid; assign s_bresp_i = m_axi_bresp; assign s_buser_i = m_axi_buser; assign s_bvalid_i = m_axi_bvalid; assign m_axi_bready = s_bready_i; assign m_axi_arid = s_axi_arid; assign m_axi_araddr = s_axi_araddr; assign m_axi_arlen = s_axi_arlen; assign m_axi_arsize = s_axi_arsize; assign m_axi_arburst = s_axi_arburst; assign m_axi_arlock = s_axi_arlock; assign m_axi_arcache = s_axi_arcache; assign m_axi_arprot = s_axi_arprot; assign m_axi_arregion = s_axi_arregion; assign m_axi_arqos = s_axi_arqos; assign m_axi_aruser = s_axi_aruser; assign m_axi_arvalid = s_arvalid_i; assign s_arready_i = m_axi_arready; assign s_rid_i = m_axi_rid; assign s_rdata_i = m_axi_rdata; assign s_rresp_i = m_axi_rresp; assign s_rlast_i = m_axi_rlast; assign s_ruser_i = m_axi_ruser; assign s_rvalid_i = m_axi_rvalid; assign m_axi_rready = s_rready_i; end if ((C_TRANSLATION_MODE == P_PROTECTION) && (((C_S_AXI_PROTOCOL != P_AXILITE) && (C_M_AXI_PROTOCOL == P_AXILITE)) || ((C_S_AXI_PROTOCOL == P_AXI4) && (C_M_AXI_PROTOCOL == P_AXI3)))) begin : gen_err_detect wire e_awvalid; reg e_awvalid_r; wire e_arvalid; reg e_arvalid_r; wire e_wvalid; wire e_bvalid; wire e_rvalid; reg e_awready; reg e_arready; wire e_wready; reg [C_AXI_ID_WIDTH-1:0] e_awid; reg [C_AXI_ID_WIDTH-1:0] e_arid; reg [8-1:0] e_arlen; wire [C_AXI_ID_WIDTH-1:0] e_bid; wire [C_AXI_ID_WIDTH-1:0] e_rid; wire e_rlast; wire w_err; wire r_err; wire busy_aw; wire busy_w; wire busy_ar; wire aw_push; wire aw_pop; wire w_pop; wire ar_push; wire ar_pop; reg s_awvalid_pending; reg s_awvalid_en; reg s_arvalid_en; reg s_awready_en; reg s_arready_en; reg [4:0] aw_cnt; reg [4:0] ar_cnt; reg [4:0] w_cnt; reg w_borrow; reg err_busy_w; reg err_busy_r; assign w_err = (C_M_AXI_PROTOCOL == P_AXILITE) ? (s_axi_awlen != 0) : ((s_axi_awlen>>4) != 0); assign r_err = (C_M_AXI_PROTOCOL == P_AXILITE) ? (s_axi_arlen != 0) : ((s_axi_arlen>>4) != 0); assign s_awvalid_i = s_axi_awvalid & s_awvalid_en & ~w_err; assign e_awvalid = e_awvalid_r & ~busy_aw & ~busy_w; assign s_arvalid_i = s_axi_arvalid & s_arvalid_en & ~r_err; assign e_arvalid = e_arvalid_r & ~busy_ar ; assign s_wvalid_i = s_axi_wvalid & (busy_w | (s_awvalid_pending & ~w_borrow)); assign e_wvalid = s_axi_wvalid & err_busy_w; assign s_bready_i = s_axi_bready & busy_aw; assign s_rready_i = s_axi_rready & busy_ar; assign s_axi_awready = (s_awready_i & s_awready_en) | e_awready; assign s_axi_wready = (s_wready_i & (busy_w | (s_awvalid_pending & ~w_borrow))) | e_wready; assign s_axi_bvalid = (s_bvalid_i & busy_aw) | e_bvalid; assign s_axi_bid = err_busy_w ? e_bid : s_bid_i; assign s_axi_bresp = err_busy_w ? P_SLVERR : s_bresp_i; assign s_axi_buser = err_busy_w ? {C_AXI_BUSER_WIDTH{1'b0}} : s_buser_i; assign s_axi_arready = (s_arready_i & s_arready_en) | e_arready; assign s_axi_rvalid = (s_rvalid_i & busy_ar) | e_rvalid; assign s_axi_rid = err_busy_r ? e_rid : s_rid_i; assign s_axi_rresp = err_busy_r ? P_SLVERR : s_rresp_i; assign s_axi_ruser = err_busy_r ? {C_AXI_RUSER_WIDTH{1'b0}} : s_ruser_i; assign s_axi_rdata = err_busy_r ? {C_AXI_DATA_WIDTH{1'b0}} : s_rdata_i; assign s_axi_rlast = err_busy_r ? e_rlast : s_rlast_i; assign busy_aw = (aw_cnt != 0); assign busy_w = (w_cnt != 0); assign busy_ar = (ar_cnt != 0); assign aw_push = s_awvalid_i & s_awready_i & s_awready_en; assign aw_pop = s_bvalid_i & s_bready_i; assign w_pop = s_wvalid_i & s_wready_i & s_axi_wlast; assign ar_push = s_arvalid_i & s_arready_i & s_arready_en; assign ar_pop = s_rvalid_i & s_rready_i & s_rlast_i; always @(posedge aclk) begin if (~aresetn) begin s_awvalid_en <= 1'b0; s_arvalid_en <= 1'b0; s_awready_en <= 1'b0; s_arready_en <= 1'b0; e_awvalid_r <= 1'b0; e_arvalid_r <= 1'b0; e_awready <= 1'b0; e_arready <= 1'b0; aw_cnt <= 0; w_cnt <= 0; ar_cnt <= 0; err_busy_w <= 1'b0; err_busy_r <= 1'b0; w_borrow <= 1'b0; s_awvalid_pending <= 1'b0; end else begin e_awready <= 1'b0; // One-cycle pulse if (e_bvalid & s_axi_bready) begin s_awvalid_en <= 1'b1; s_awready_en <= 1'b1; err_busy_w <= 1'b0; end else if (e_awvalid) begin e_awvalid_r <= 1'b0; err_busy_w <= 1'b1; end else if (s_axi_awvalid & w_err & ~e_awvalid_r & ~err_busy_w) begin e_awvalid_r <= 1'b1; e_awready <= ~(s_awready_i & s_awvalid_en); // 1-cycle pulse if awready not already asserted s_awvalid_en <= 1'b0; s_awready_en <= 1'b0; end else if ((&aw_cnt) | (&w_cnt) | aw_push) begin s_awvalid_en <= 1'b0; s_awready_en <= 1'b0; end else if (~err_busy_w & ~e_awvalid_r & ~(s_axi_awvalid & w_err)) begin s_awvalid_en <= 1'b1; s_awready_en <= 1'b1; end if (aw_push & ~aw_pop) begin aw_cnt <= aw_cnt + 1; end else if (~aw_push & aw_pop & (|aw_cnt)) begin aw_cnt <= aw_cnt - 1; end if (aw_push) begin if (~w_pop & ~w_borrow) begin w_cnt <= w_cnt + 1; end w_borrow <= 1'b0; end else if (~aw_push & w_pop) begin if (|w_cnt) begin w_cnt <= w_cnt - 1; end else begin w_borrow <= 1'b1; end end s_awvalid_pending <= s_awvalid_i & ~s_awready_i; e_arready <= 1'b0; // One-cycle pulse if (e_rvalid & s_axi_rready & e_rlast) begin s_arvalid_en <= 1'b1; s_arready_en <= 1'b1; err_busy_r <= 1'b0; end else if (e_arvalid) begin e_arvalid_r <= 1'b0; err_busy_r <= 1'b1; end else if (s_axi_arvalid & r_err & ~e_arvalid_r & ~err_busy_r) begin e_arvalid_r <= 1'b1; e_arready <= ~(s_arready_i & s_arvalid_en); // 1-cycle pulse if arready not already asserted s_arvalid_en <= 1'b0; s_arready_en <= 1'b0; end else if ((&ar_cnt) | ar_push) begin s_arvalid_en <= 1'b0; s_arready_en <= 1'b0; end else if (~err_busy_r & ~e_arvalid_r & ~(s_axi_arvalid & r_err)) begin s_arvalid_en <= 1'b1; s_arready_en <= 1'b1; end if (ar_push & ~ar_pop) begin ar_cnt <= ar_cnt + 1; end else if (~ar_push & ar_pop & (|ar_cnt)) begin ar_cnt <= ar_cnt - 1; end end end always @(posedge aclk) begin if (s_axi_awvalid & ~err_busy_w & ~e_awvalid_r ) begin e_awid <= s_axi_awid; end if (s_axi_arvalid & ~err_busy_r & ~e_arvalid_r ) begin e_arid <= s_axi_arid; e_arlen <= s_axi_arlen; end end axi_protocol_converter_v2_1_decerr_slave # ( .C_AXI_ID_WIDTH (C_AXI_ID_WIDTH), .C_AXI_DATA_WIDTH (C_AXI_DATA_WIDTH), .C_AXI_RUSER_WIDTH (C_AXI_RUSER_WIDTH), .C_AXI_BUSER_WIDTH (C_AXI_BUSER_WIDTH), .C_AXI_PROTOCOL (C_S_AXI_PROTOCOL), .C_RESP (P_SLVERR), .C_IGNORE_ID (C_IGNORE_ID) ) decerr_slave_inst ( .ACLK (aclk), .ARESETN (aresetn), .S_AXI_AWID (e_awid), .S_AXI_AWVALID (e_awvalid), .S_AXI_AWREADY (), .S_AXI_WLAST (s_axi_wlast), .S_AXI_WVALID (e_wvalid), .S_AXI_WREADY (e_wready), .S_AXI_BID (e_bid), .S_AXI_BRESP (), .S_AXI_BUSER (), .S_AXI_BVALID (e_bvalid), .S_AXI_BREADY (s_axi_bready), .S_AXI_ARID (e_arid), .S_AXI_ARLEN (e_arlen), .S_AXI_ARVALID (e_arvalid), .S_AXI_ARREADY (), .S_AXI_RID (e_rid), .S_AXI_RDATA (), .S_AXI_RRESP (), .S_AXI_RUSER (), .S_AXI_RLAST (e_rlast), .S_AXI_RVALID (e_rvalid), .S_AXI_RREADY (s_axi_rready) ); end else begin : gen_no_err_detect assign s_awvalid_i = s_axi_awvalid; assign s_arvalid_i = s_axi_arvalid; assign s_wvalid_i = s_axi_wvalid; assign s_bready_i = s_axi_bready; assign s_rready_i = s_axi_rready; assign s_axi_awready = s_awready_i; assign s_axi_wready = s_wready_i; assign s_axi_bvalid = s_bvalid_i; assign s_axi_bid = s_bid_i; assign s_axi_bresp = s_bresp_i; assign s_axi_buser = s_buser_i; assign s_axi_arready = s_arready_i; assign s_axi_rvalid = s_rvalid_i; assign s_axi_rid = s_rid_i; assign s_axi_rresp = s_rresp_i; assign s_axi_ruser = s_ruser_i; assign s_axi_rdata = s_rdata_i; assign s_axi_rlast = s_rlast_i; end // gen_err_detect endgenerate endmodule `default_nettype wire
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 03/10/2016 04:46:19 PM // Design Name: // Module Name: exp_operation // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // // Revision: // Revision 0.01 - File Created // Additional Comments: // ////////////////////////////////////////////////////////////////////////////////// module Exp_Operation #(parameter EW = 8) //Exponent Width ( input wire clk, //system clock input wire rst, //reset of the module input wire load_a_i, input wire load_b_i, input wire [EW-1:0] Data_A_i, input wire [EW-1:0] Data_B_i, input wire Add_Subt_i, ///////////////////////////////////////////////////////////////////77 output wire [EW-1:0] Data_Result_o, output wire Overflow_flag_o, output wire Underflow_flag_o ); //wire [EW-1:0] Data_B; wire [EW:0] Data_S; /////////////////////////////////////////7 //genvar j; //for (j=0; j<EW; j=j+1)begin // assign Data_B[j] = PreData_B_i[j] ^ Add_Subt_i; //end ///////////////////////////////////////// add_sub_carry_out #(.W(EW)) exp_add_subt( .op_mode (Add_Subt_i), .Data_A (Data_A_i), .Data_B (Data_B_i), .Data_S (Data_S) ); //assign Overflow_flag_o = 1'b0; //assign Underflow_flag_o = 1'b0; Comparators #(.W_Exp(EW+1)) array_comparators( .exp(Data_S), .overflow(Overflow_flag), .underflow(Underflow_flag) ); RegisterAdd #(.W(EW)) exp_result( .clk (clk), .rst (rst), .load (load_a_i), .D (Data_S[EW-1:0]), .Q (Data_Result_o) ); RegisterAdd #(.W(1)) Overflow ( .clk(clk), .rst(rst), .load(load_a_i), .D(Overflow_flag), .Q(Overflow_flag_o) ); RegisterAdd #(.W(1)) Underflow ( .clk(clk), .rst(rst), .load(load_b_i), .D(Underflow_flag), .Q(Underflow_flag_o) ); endmodule
/* * VGA top level file * Copyright (C) 2010 Zeus Gomez Marmolejo <[email protected]> * * This file is part of the Zet processor. This processor is free * hardware; you can redistribute it and/or modify it under the terms of * the GNU General Public License as published by the Free Software * Foundation; either version 3, or (at your option) any later version. * * Zet is distrubuted in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public * License for more details. * * You should have received a copy of the GNU General Public License * along with Zet; see the file COPYING. If not, see * <http://www.gnu.org/licenses/>. */ module vga ( // Wishbone signals input wb_clk_i, // 25 Mhz VDU clock input wb_rst_i, input [15:0] wb_dat_i, output [15:0] wb_dat_o, input [16:1] wb_adr_i, input wb_we_i, input wb_tga_i, input [ 1:0] wb_sel_i, input wb_stb_i, input wb_cyc_i, output wb_ack_o, // VGA pad signals output [ 3:0] vga_red_o, output [ 3:0] vga_green_o, output [ 3:0] vga_blue_o, output horiz_sync, output vert_sync, // CSR SRAM master interface output [17:1] csrm_adr_o, output [ 1:0] csrm_sel_o, output csrm_we_o, output [15:0] csrm_dat_o, input [15:0] csrm_dat_i ); // Registers and nets // // csr address reg [17:1] csr_adr_i; reg csr_stb_i; // Config wires wire [15:0] conf_wb_dat_o; wire conf_wb_ack_o; // Mem wires wire [15:0] mem_wb_dat_o; wire mem_wb_ack_o; // LCD wires wire [17:1] csr_adr_o; wire [15:0] csr_dat_i; wire csr_stb_o; wire v_retrace; wire vh_retrace; wire w_vert_sync; // VGA configuration registers wire shift_reg1; wire graphics_alpha; wire memory_mapping1; wire [ 1:0] write_mode; wire [ 1:0] raster_op; wire read_mode; wire [ 7:0] bitmask; wire [ 3:0] set_reset; wire [ 3:0] enable_set_reset; wire [ 3:0] map_mask; wire x_dotclockdiv2; wire chain_four; wire [ 1:0] read_map_select; wire [ 3:0] color_compare; wire [ 3:0] color_dont_care; // Wishbone master to SRAM wire [17:1] wbm_adr_o; wire [ 1:0] wbm_sel_o; wire wbm_we_o; wire [15:0] wbm_dat_o; wire [15:0] wbm_dat_i; wire wbm_stb_o; wire wbm_ack_i; wire stb; // CRT wires wire [ 5:0] cur_start; wire [ 5:0] cur_end; wire [15:0] start_addr; wire [ 4:0] vcursor; wire [ 6:0] hcursor; wire [ 6:0] horiz_total; wire [ 6:0] end_horiz; wire [ 6:0] st_hor_retr; wire [ 4:0] end_hor_retr; wire [ 9:0] vert_total; wire [ 9:0] end_vert; wire [ 9:0] st_ver_retr; wire [ 3:0] end_ver_retr; // attribute_ctrl wires wire [3:0] pal_addr; wire pal_we; wire [7:0] pal_read; wire [7:0] pal_write; // dac_regs wires wire dac_we; wire [1:0] dac_read_data_cycle; wire [7:0] dac_read_data_register; wire [3:0] dac_read_data; wire [1:0] dac_write_data_cycle; wire [7:0] dac_write_data_register; wire [3:0] dac_write_data; // Module instances // vga_config_iface config_iface ( .wb_clk_i (wb_clk_i), .wb_rst_i (wb_rst_i), .wb_dat_i (wb_dat_i), .wb_dat_o (conf_wb_dat_o), .wb_adr_i (wb_adr_i[4:1]), .wb_we_i (wb_we_i), .wb_sel_i (wb_sel_i), .wb_stb_i (stb & wb_tga_i), .wb_ack_o (conf_wb_ack_o), .shift_reg1 (shift_reg1), .graphics_alpha (graphics_alpha), .memory_mapping1 (memory_mapping1), .write_mode (write_mode), .raster_op (raster_op), .read_mode (read_mode), .bitmask (bitmask), .set_reset (set_reset), .enable_set_reset (enable_set_reset), .map_mask (map_mask), .x_dotclockdiv2 (x_dotclockdiv2), .chain_four (chain_four), .read_map_select (read_map_select), .color_compare (color_compare), .color_dont_care (color_dont_care), .pal_addr (pal_addr), .pal_we (pal_we), .pal_read (pal_read), .pal_write (pal_write), .dac_we (dac_we), .dac_read_data_cycle (dac_read_data_cycle), .dac_read_data_register (dac_read_data_register), .dac_read_data (dac_read_data), .dac_write_data_cycle (dac_write_data_cycle), .dac_write_data_register (dac_write_data_register), .dac_write_data (dac_write_data), .cur_start (cur_start), .cur_end (cur_end), .start_addr (start_addr), .vcursor (vcursor), .hcursor (hcursor), .horiz_total (horiz_total), .end_horiz (end_horiz), .st_hor_retr (st_hor_retr), .end_hor_retr (end_hor_retr), .vert_total (vert_total), .end_vert (end_vert), .st_ver_retr (st_ver_retr), .end_ver_retr (end_ver_retr), .v_retrace (v_retrace), .vh_retrace (vh_retrace) ); vga_lcd lcd ( .clk (wb_clk_i), .rst (wb_rst_i), .shift_reg1 (shift_reg1), .graphics_alpha (graphics_alpha), .pal_addr (pal_addr), .pal_we (pal_we), .pal_read (pal_read), .pal_write (pal_write), .dac_we (dac_we), .dac_read_data_cycle (dac_read_data_cycle), .dac_read_data_register (dac_read_data_register), .dac_read_data (dac_read_data), .dac_write_data_cycle (dac_write_data_cycle), .dac_write_data_register (dac_write_data_register), .dac_write_data (dac_write_data), .csr_adr_o (csr_adr_o), .csr_dat_i (csr_dat_i), .csr_stb_o (csr_stb_o), .vga_red_o (vga_red_o), .vga_green_o (vga_green_o), .vga_blue_o (vga_blue_o), .horiz_sync (horiz_sync), .vert_sync (w_vert_sync), .cur_start (cur_start), .cur_end (cur_end), .vcursor (vcursor), .hcursor (hcursor), .horiz_total (horiz_total), .end_horiz (end_horiz), .st_hor_retr (st_hor_retr), .end_hor_retr (end_hor_retr), .vert_total (vert_total), .end_vert (end_vert), .st_ver_retr (st_ver_retr), .end_ver_retr (end_ver_retr), .x_dotclockdiv2 (x_dotclockdiv2), .v_retrace (v_retrace), .vh_retrace (vh_retrace) ); vga_cpu_mem_iface cpu_mem_iface ( .wb_clk_i (wb_clk_i), .wb_rst_i (wb_rst_i), .wbs_adr_i (wb_adr_i), .wbs_sel_i (wb_sel_i), .wbs_we_i (wb_we_i), .wbs_dat_i (wb_dat_i), .wbs_dat_o (mem_wb_dat_o), .wbs_stb_i (stb & !wb_tga_i), .wbs_ack_o (mem_wb_ack_o), .wbm_adr_o (wbm_adr_o), .wbm_sel_o (wbm_sel_o), .wbm_we_o (wbm_we_o), .wbm_dat_o (wbm_dat_o), .wbm_dat_i (wbm_dat_i), .wbm_stb_o (wbm_stb_o), .wbm_ack_i (wbm_ack_i), .chain_four (chain_four), .memory_mapping1 (memory_mapping1), .write_mode (write_mode), .raster_op (raster_op), .read_mode (read_mode), .bitmask (bitmask), .set_reset (set_reset), .enable_set_reset (enable_set_reset), .map_mask (map_mask), .read_map_select (read_map_select), .color_compare (color_compare), .color_dont_care (color_dont_care) ); vga_mem_arbitrer mem_arbitrer ( .clk_i (wb_clk_i), .rst_i (wb_rst_i), .wb_adr_i (wbm_adr_o), .wb_sel_i (wbm_sel_o), .wb_we_i (wbm_we_o), .wb_dat_i (wbm_dat_o), .wb_dat_o (wbm_dat_i), .wb_stb_i (wbm_stb_o), .wb_ack_o (wbm_ack_i), .csr_adr_i (csr_adr_i), .csr_dat_o (csr_dat_i), .csr_stb_i (csr_stb_i), .csrm_adr_o (csrm_adr_o), .csrm_sel_o (csrm_sel_o), .csrm_we_o (csrm_we_o), .csrm_dat_o (csrm_dat_o), .csrm_dat_i (csrm_dat_i) ); // Continous assignments assign wb_dat_o = wb_tga_i ? conf_wb_dat_o : mem_wb_dat_o; assign wb_ack_o = wb_tga_i ? conf_wb_ack_o : mem_wb_ack_o; assign stb = wb_stb_i & wb_cyc_i; assign vert_sync = ~graphics_alpha ^ w_vert_sync; // Behaviour // csr_adr_i always @(posedge wb_clk_i) csr_adr_i <= wb_rst_i ? 17'h0 : csr_adr_o + start_addr[15:1]; // csr_stb_i always @(posedge wb_clk_i) csr_stb_i <= wb_rst_i ? 1'b0 : csr_stb_o; endmodule
/* * VGA top level file * Copyright (C) 2010 Zeus Gomez Marmolejo <[email protected]> * * This file is part of the Zet processor. This processor is free * hardware; you can redistribute it and/or modify it under the terms of * the GNU General Public License as published by the Free Software * Foundation; either version 3, or (at your option) any later version. * * Zet is distrubuted in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public * License for more details. * * You should have received a copy of the GNU General Public License * along with Zet; see the file COPYING. If not, see * <http://www.gnu.org/licenses/>. */ module vga ( // Wishbone signals input wb_clk_i, // 25 Mhz VDU clock input wb_rst_i, input [15:0] wb_dat_i, output [15:0] wb_dat_o, input [16:1] wb_adr_i, input wb_we_i, input wb_tga_i, input [ 1:0] wb_sel_i, input wb_stb_i, input wb_cyc_i, output wb_ack_o, // VGA pad signals output [ 3:0] vga_red_o, output [ 3:0] vga_green_o, output [ 3:0] vga_blue_o, output horiz_sync, output vert_sync, // CSR SRAM master interface output [17:1] csrm_adr_o, output [ 1:0] csrm_sel_o, output csrm_we_o, output [15:0] csrm_dat_o, input [15:0] csrm_dat_i ); // Registers and nets // // csr address reg [17:1] csr_adr_i; reg csr_stb_i; // Config wires wire [15:0] conf_wb_dat_o; wire conf_wb_ack_o; // Mem wires wire [15:0] mem_wb_dat_o; wire mem_wb_ack_o; // LCD wires wire [17:1] csr_adr_o; wire [15:0] csr_dat_i; wire csr_stb_o; wire v_retrace; wire vh_retrace; wire w_vert_sync; // VGA configuration registers wire shift_reg1; wire graphics_alpha; wire memory_mapping1; wire [ 1:0] write_mode; wire [ 1:0] raster_op; wire read_mode; wire [ 7:0] bitmask; wire [ 3:0] set_reset; wire [ 3:0] enable_set_reset; wire [ 3:0] map_mask; wire x_dotclockdiv2; wire chain_four; wire [ 1:0] read_map_select; wire [ 3:0] color_compare; wire [ 3:0] color_dont_care; // Wishbone master to SRAM wire [17:1] wbm_adr_o; wire [ 1:0] wbm_sel_o; wire wbm_we_o; wire [15:0] wbm_dat_o; wire [15:0] wbm_dat_i; wire wbm_stb_o; wire wbm_ack_i; wire stb; // CRT wires wire [ 5:0] cur_start; wire [ 5:0] cur_end; wire [15:0] start_addr; wire [ 4:0] vcursor; wire [ 6:0] hcursor; wire [ 6:0] horiz_total; wire [ 6:0] end_horiz; wire [ 6:0] st_hor_retr; wire [ 4:0] end_hor_retr; wire [ 9:0] vert_total; wire [ 9:0] end_vert; wire [ 9:0] st_ver_retr; wire [ 3:0] end_ver_retr; // attribute_ctrl wires wire [3:0] pal_addr; wire pal_we; wire [7:0] pal_read; wire [7:0] pal_write; // dac_regs wires wire dac_we; wire [1:0] dac_read_data_cycle; wire [7:0] dac_read_data_register; wire [3:0] dac_read_data; wire [1:0] dac_write_data_cycle; wire [7:0] dac_write_data_register; wire [3:0] dac_write_data; // Module instances // vga_config_iface config_iface ( .wb_clk_i (wb_clk_i), .wb_rst_i (wb_rst_i), .wb_dat_i (wb_dat_i), .wb_dat_o (conf_wb_dat_o), .wb_adr_i (wb_adr_i[4:1]), .wb_we_i (wb_we_i), .wb_sel_i (wb_sel_i), .wb_stb_i (stb & wb_tga_i), .wb_ack_o (conf_wb_ack_o), .shift_reg1 (shift_reg1), .graphics_alpha (graphics_alpha), .memory_mapping1 (memory_mapping1), .write_mode (write_mode), .raster_op (raster_op), .read_mode (read_mode), .bitmask (bitmask), .set_reset (set_reset), .enable_set_reset (enable_set_reset), .map_mask (map_mask), .x_dotclockdiv2 (x_dotclockdiv2), .chain_four (chain_four), .read_map_select (read_map_select), .color_compare (color_compare), .color_dont_care (color_dont_care), .pal_addr (pal_addr), .pal_we (pal_we), .pal_read (pal_read), .pal_write (pal_write), .dac_we (dac_we), .dac_read_data_cycle (dac_read_data_cycle), .dac_read_data_register (dac_read_data_register), .dac_read_data (dac_read_data), .dac_write_data_cycle (dac_write_data_cycle), .dac_write_data_register (dac_write_data_register), .dac_write_data (dac_write_data), .cur_start (cur_start), .cur_end (cur_end), .start_addr (start_addr), .vcursor (vcursor), .hcursor (hcursor), .horiz_total (horiz_total), .end_horiz (end_horiz), .st_hor_retr (st_hor_retr), .end_hor_retr (end_hor_retr), .vert_total (vert_total), .end_vert (end_vert), .st_ver_retr (st_ver_retr), .end_ver_retr (end_ver_retr), .v_retrace (v_retrace), .vh_retrace (vh_retrace) ); vga_lcd lcd ( .clk (wb_clk_i), .rst (wb_rst_i), .shift_reg1 (shift_reg1), .graphics_alpha (graphics_alpha), .pal_addr (pal_addr), .pal_we (pal_we), .pal_read (pal_read), .pal_write (pal_write), .dac_we (dac_we), .dac_read_data_cycle (dac_read_data_cycle), .dac_read_data_register (dac_read_data_register), .dac_read_data (dac_read_data), .dac_write_data_cycle (dac_write_data_cycle), .dac_write_data_register (dac_write_data_register), .dac_write_data (dac_write_data), .csr_adr_o (csr_adr_o), .csr_dat_i (csr_dat_i), .csr_stb_o (csr_stb_o), .vga_red_o (vga_red_o), .vga_green_o (vga_green_o), .vga_blue_o (vga_blue_o), .horiz_sync (horiz_sync), .vert_sync (w_vert_sync), .cur_start (cur_start), .cur_end (cur_end), .vcursor (vcursor), .hcursor (hcursor), .horiz_total (horiz_total), .end_horiz (end_horiz), .st_hor_retr (st_hor_retr), .end_hor_retr (end_hor_retr), .vert_total (vert_total), .end_vert (end_vert), .st_ver_retr (st_ver_retr), .end_ver_retr (end_ver_retr), .x_dotclockdiv2 (x_dotclockdiv2), .v_retrace (v_retrace), .vh_retrace (vh_retrace) ); vga_cpu_mem_iface cpu_mem_iface ( .wb_clk_i (wb_clk_i), .wb_rst_i (wb_rst_i), .wbs_adr_i (wb_adr_i), .wbs_sel_i (wb_sel_i), .wbs_we_i (wb_we_i), .wbs_dat_i (wb_dat_i), .wbs_dat_o (mem_wb_dat_o), .wbs_stb_i (stb & !wb_tga_i), .wbs_ack_o (mem_wb_ack_o), .wbm_adr_o (wbm_adr_o), .wbm_sel_o (wbm_sel_o), .wbm_we_o (wbm_we_o), .wbm_dat_o (wbm_dat_o), .wbm_dat_i (wbm_dat_i), .wbm_stb_o (wbm_stb_o), .wbm_ack_i (wbm_ack_i), .chain_four (chain_four), .memory_mapping1 (memory_mapping1), .write_mode (write_mode), .raster_op (raster_op), .read_mode (read_mode), .bitmask (bitmask), .set_reset (set_reset), .enable_set_reset (enable_set_reset), .map_mask (map_mask), .read_map_select (read_map_select), .color_compare (color_compare), .color_dont_care (color_dont_care) ); vga_mem_arbitrer mem_arbitrer ( .clk_i (wb_clk_i), .rst_i (wb_rst_i), .wb_adr_i (wbm_adr_o), .wb_sel_i (wbm_sel_o), .wb_we_i (wbm_we_o), .wb_dat_i (wbm_dat_o), .wb_dat_o (wbm_dat_i), .wb_stb_i (wbm_stb_o), .wb_ack_o (wbm_ack_i), .csr_adr_i (csr_adr_i), .csr_dat_o (csr_dat_i), .csr_stb_i (csr_stb_i), .csrm_adr_o (csrm_adr_o), .csrm_sel_o (csrm_sel_o), .csrm_we_o (csrm_we_o), .csrm_dat_o (csrm_dat_o), .csrm_dat_i (csrm_dat_i) ); // Continous assignments assign wb_dat_o = wb_tga_i ? conf_wb_dat_o : mem_wb_dat_o; assign wb_ack_o = wb_tga_i ? conf_wb_ack_o : mem_wb_ack_o; assign stb = wb_stb_i & wb_cyc_i; assign vert_sync = ~graphics_alpha ^ w_vert_sync; // Behaviour // csr_adr_i always @(posedge wb_clk_i) csr_adr_i <= wb_rst_i ? 17'h0 : csr_adr_o + start_addr[15:1]; // csr_stb_i always @(posedge wb_clk_i) csr_stb_i <= wb_rst_i ? 1'b0 : csr_stb_o; endmodule
/* * VGA top level file * Copyright (C) 2010 Zeus Gomez Marmolejo <[email protected]> * * This file is part of the Zet processor. This processor is free * hardware; you can redistribute it and/or modify it under the terms of * the GNU General Public License as published by the Free Software * Foundation; either version 3, or (at your option) any later version. * * Zet is distrubuted in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public * License for more details. * * You should have received a copy of the GNU General Public License * along with Zet; see the file COPYING. If not, see * <http://www.gnu.org/licenses/>. */ module vga ( // Wishbone signals input wb_clk_i, // 25 Mhz VDU clock input wb_rst_i, input [15:0] wb_dat_i, output [15:0] wb_dat_o, input [16:1] wb_adr_i, input wb_we_i, input wb_tga_i, input [ 1:0] wb_sel_i, input wb_stb_i, input wb_cyc_i, output wb_ack_o, // VGA pad signals output [ 3:0] vga_red_o, output [ 3:0] vga_green_o, output [ 3:0] vga_blue_o, output horiz_sync, output vert_sync, // CSR SRAM master interface output [17:1] csrm_adr_o, output [ 1:0] csrm_sel_o, output csrm_we_o, output [15:0] csrm_dat_o, input [15:0] csrm_dat_i ); // Registers and nets // // csr address reg [17:1] csr_adr_i; reg csr_stb_i; // Config wires wire [15:0] conf_wb_dat_o; wire conf_wb_ack_o; // Mem wires wire [15:0] mem_wb_dat_o; wire mem_wb_ack_o; // LCD wires wire [17:1] csr_adr_o; wire [15:0] csr_dat_i; wire csr_stb_o; wire v_retrace; wire vh_retrace; wire w_vert_sync; // VGA configuration registers wire shift_reg1; wire graphics_alpha; wire memory_mapping1; wire [ 1:0] write_mode; wire [ 1:0] raster_op; wire read_mode; wire [ 7:0] bitmask; wire [ 3:0] set_reset; wire [ 3:0] enable_set_reset; wire [ 3:0] map_mask; wire x_dotclockdiv2; wire chain_four; wire [ 1:0] read_map_select; wire [ 3:0] color_compare; wire [ 3:0] color_dont_care; // Wishbone master to SRAM wire [17:1] wbm_adr_o; wire [ 1:0] wbm_sel_o; wire wbm_we_o; wire [15:0] wbm_dat_o; wire [15:0] wbm_dat_i; wire wbm_stb_o; wire wbm_ack_i; wire stb; // CRT wires wire [ 5:0] cur_start; wire [ 5:0] cur_end; wire [15:0] start_addr; wire [ 4:0] vcursor; wire [ 6:0] hcursor; wire [ 6:0] horiz_total; wire [ 6:0] end_horiz; wire [ 6:0] st_hor_retr; wire [ 4:0] end_hor_retr; wire [ 9:0] vert_total; wire [ 9:0] end_vert; wire [ 9:0] st_ver_retr; wire [ 3:0] end_ver_retr; // attribute_ctrl wires wire [3:0] pal_addr; wire pal_we; wire [7:0] pal_read; wire [7:0] pal_write; // dac_regs wires wire dac_we; wire [1:0] dac_read_data_cycle; wire [7:0] dac_read_data_register; wire [3:0] dac_read_data; wire [1:0] dac_write_data_cycle; wire [7:0] dac_write_data_register; wire [3:0] dac_write_data; // Module instances // vga_config_iface config_iface ( .wb_clk_i (wb_clk_i), .wb_rst_i (wb_rst_i), .wb_dat_i (wb_dat_i), .wb_dat_o (conf_wb_dat_o), .wb_adr_i (wb_adr_i[4:1]), .wb_we_i (wb_we_i), .wb_sel_i (wb_sel_i), .wb_stb_i (stb & wb_tga_i), .wb_ack_o (conf_wb_ack_o), .shift_reg1 (shift_reg1), .graphics_alpha (graphics_alpha), .memory_mapping1 (memory_mapping1), .write_mode (write_mode), .raster_op (raster_op), .read_mode (read_mode), .bitmask (bitmask), .set_reset (set_reset), .enable_set_reset (enable_set_reset), .map_mask (map_mask), .x_dotclockdiv2 (x_dotclockdiv2), .chain_four (chain_four), .read_map_select (read_map_select), .color_compare (color_compare), .color_dont_care (color_dont_care), .pal_addr (pal_addr), .pal_we (pal_we), .pal_read (pal_read), .pal_write (pal_write), .dac_we (dac_we), .dac_read_data_cycle (dac_read_data_cycle), .dac_read_data_register (dac_read_data_register), .dac_read_data (dac_read_data), .dac_write_data_cycle (dac_write_data_cycle), .dac_write_data_register (dac_write_data_register), .dac_write_data (dac_write_data), .cur_start (cur_start), .cur_end (cur_end), .start_addr (start_addr), .vcursor (vcursor), .hcursor (hcursor), .horiz_total (horiz_total), .end_horiz (end_horiz), .st_hor_retr (st_hor_retr), .end_hor_retr (end_hor_retr), .vert_total (vert_total), .end_vert (end_vert), .st_ver_retr (st_ver_retr), .end_ver_retr (end_ver_retr), .v_retrace (v_retrace), .vh_retrace (vh_retrace) ); vga_lcd lcd ( .clk (wb_clk_i), .rst (wb_rst_i), .shift_reg1 (shift_reg1), .graphics_alpha (graphics_alpha), .pal_addr (pal_addr), .pal_we (pal_we), .pal_read (pal_read), .pal_write (pal_write), .dac_we (dac_we), .dac_read_data_cycle (dac_read_data_cycle), .dac_read_data_register (dac_read_data_register), .dac_read_data (dac_read_data), .dac_write_data_cycle (dac_write_data_cycle), .dac_write_data_register (dac_write_data_register), .dac_write_data (dac_write_data), .csr_adr_o (csr_adr_o), .csr_dat_i (csr_dat_i), .csr_stb_o (csr_stb_o), .vga_red_o (vga_red_o), .vga_green_o (vga_green_o), .vga_blue_o (vga_blue_o), .horiz_sync (horiz_sync), .vert_sync (w_vert_sync), .cur_start (cur_start), .cur_end (cur_end), .vcursor (vcursor), .hcursor (hcursor), .horiz_total (horiz_total), .end_horiz (end_horiz), .st_hor_retr (st_hor_retr), .end_hor_retr (end_hor_retr), .vert_total (vert_total), .end_vert (end_vert), .st_ver_retr (st_ver_retr), .end_ver_retr (end_ver_retr), .x_dotclockdiv2 (x_dotclockdiv2), .v_retrace (v_retrace), .vh_retrace (vh_retrace) ); vga_cpu_mem_iface cpu_mem_iface ( .wb_clk_i (wb_clk_i), .wb_rst_i (wb_rst_i), .wbs_adr_i (wb_adr_i), .wbs_sel_i (wb_sel_i), .wbs_we_i (wb_we_i), .wbs_dat_i (wb_dat_i), .wbs_dat_o (mem_wb_dat_o), .wbs_stb_i (stb & !wb_tga_i), .wbs_ack_o (mem_wb_ack_o), .wbm_adr_o (wbm_adr_o), .wbm_sel_o (wbm_sel_o), .wbm_we_o (wbm_we_o), .wbm_dat_o (wbm_dat_o), .wbm_dat_i (wbm_dat_i), .wbm_stb_o (wbm_stb_o), .wbm_ack_i (wbm_ack_i), .chain_four (chain_four), .memory_mapping1 (memory_mapping1), .write_mode (write_mode), .raster_op (raster_op), .read_mode (read_mode), .bitmask (bitmask), .set_reset (set_reset), .enable_set_reset (enable_set_reset), .map_mask (map_mask), .read_map_select (read_map_select), .color_compare (color_compare), .color_dont_care (color_dont_care) ); vga_mem_arbitrer mem_arbitrer ( .clk_i (wb_clk_i), .rst_i (wb_rst_i), .wb_adr_i (wbm_adr_o), .wb_sel_i (wbm_sel_o), .wb_we_i (wbm_we_o), .wb_dat_i (wbm_dat_o), .wb_dat_o (wbm_dat_i), .wb_stb_i (wbm_stb_o), .wb_ack_o (wbm_ack_i), .csr_adr_i (csr_adr_i), .csr_dat_o (csr_dat_i), .csr_stb_i (csr_stb_i), .csrm_adr_o (csrm_adr_o), .csrm_sel_o (csrm_sel_o), .csrm_we_o (csrm_we_o), .csrm_dat_o (csrm_dat_o), .csrm_dat_i (csrm_dat_i) ); // Continous assignments assign wb_dat_o = wb_tga_i ? conf_wb_dat_o : mem_wb_dat_o; assign wb_ack_o = wb_tga_i ? conf_wb_ack_o : mem_wb_ack_o; assign stb = wb_stb_i & wb_cyc_i; assign vert_sync = ~graphics_alpha ^ w_vert_sync; // Behaviour // csr_adr_i always @(posedge wb_clk_i) csr_adr_i <= wb_rst_i ? 17'h0 : csr_adr_o + start_addr[15:1]; // csr_stb_i always @(posedge wb_clk_i) csr_stb_i <= wb_rst_i ? 1'b0 : csr_stb_o; endmodule
/* * VGA top level file * Copyright (C) 2010 Zeus Gomez Marmolejo <[email protected]> * * This file is part of the Zet processor. This processor is free * hardware; you can redistribute it and/or modify it under the terms of * the GNU General Public License as published by the Free Software * Foundation; either version 3, or (at your option) any later version. * * Zet is distrubuted in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public * License for more details. * * You should have received a copy of the GNU General Public License * along with Zet; see the file COPYING. If not, see * <http://www.gnu.org/licenses/>. */ module vga ( // Wishbone signals input wb_clk_i, // 25 Mhz VDU clock input wb_rst_i, input [15:0] wb_dat_i, output [15:0] wb_dat_o, input [16:1] wb_adr_i, input wb_we_i, input wb_tga_i, input [ 1:0] wb_sel_i, input wb_stb_i, input wb_cyc_i, output wb_ack_o, // VGA pad signals output [ 3:0] vga_red_o, output [ 3:0] vga_green_o, output [ 3:0] vga_blue_o, output horiz_sync, output vert_sync, // CSR SRAM master interface output [17:1] csrm_adr_o, output [ 1:0] csrm_sel_o, output csrm_we_o, output [15:0] csrm_dat_o, input [15:0] csrm_dat_i ); // Registers and nets // // csr address reg [17:1] csr_adr_i; reg csr_stb_i; // Config wires wire [15:0] conf_wb_dat_o; wire conf_wb_ack_o; // Mem wires wire [15:0] mem_wb_dat_o; wire mem_wb_ack_o; // LCD wires wire [17:1] csr_adr_o; wire [15:0] csr_dat_i; wire csr_stb_o; wire v_retrace; wire vh_retrace; wire w_vert_sync; // VGA configuration registers wire shift_reg1; wire graphics_alpha; wire memory_mapping1; wire [ 1:0] write_mode; wire [ 1:0] raster_op; wire read_mode; wire [ 7:0] bitmask; wire [ 3:0] set_reset; wire [ 3:0] enable_set_reset; wire [ 3:0] map_mask; wire x_dotclockdiv2; wire chain_four; wire [ 1:0] read_map_select; wire [ 3:0] color_compare; wire [ 3:0] color_dont_care; // Wishbone master to SRAM wire [17:1] wbm_adr_o; wire [ 1:0] wbm_sel_o; wire wbm_we_o; wire [15:0] wbm_dat_o; wire [15:0] wbm_dat_i; wire wbm_stb_o; wire wbm_ack_i; wire stb; // CRT wires wire [ 5:0] cur_start; wire [ 5:0] cur_end; wire [15:0] start_addr; wire [ 4:0] vcursor; wire [ 6:0] hcursor; wire [ 6:0] horiz_total; wire [ 6:0] end_horiz; wire [ 6:0] st_hor_retr; wire [ 4:0] end_hor_retr; wire [ 9:0] vert_total; wire [ 9:0] end_vert; wire [ 9:0] st_ver_retr; wire [ 3:0] end_ver_retr; // attribute_ctrl wires wire [3:0] pal_addr; wire pal_we; wire [7:0] pal_read; wire [7:0] pal_write; // dac_regs wires wire dac_we; wire [1:0] dac_read_data_cycle; wire [7:0] dac_read_data_register; wire [3:0] dac_read_data; wire [1:0] dac_write_data_cycle; wire [7:0] dac_write_data_register; wire [3:0] dac_write_data; // Module instances // vga_config_iface config_iface ( .wb_clk_i (wb_clk_i), .wb_rst_i (wb_rst_i), .wb_dat_i (wb_dat_i), .wb_dat_o (conf_wb_dat_o), .wb_adr_i (wb_adr_i[4:1]), .wb_we_i (wb_we_i), .wb_sel_i (wb_sel_i), .wb_stb_i (stb & wb_tga_i), .wb_ack_o (conf_wb_ack_o), .shift_reg1 (shift_reg1), .graphics_alpha (graphics_alpha), .memory_mapping1 (memory_mapping1), .write_mode (write_mode), .raster_op (raster_op), .read_mode (read_mode), .bitmask (bitmask), .set_reset (set_reset), .enable_set_reset (enable_set_reset), .map_mask (map_mask), .x_dotclockdiv2 (x_dotclockdiv2), .chain_four (chain_four), .read_map_select (read_map_select), .color_compare (color_compare), .color_dont_care (color_dont_care), .pal_addr (pal_addr), .pal_we (pal_we), .pal_read (pal_read), .pal_write (pal_write), .dac_we (dac_we), .dac_read_data_cycle (dac_read_data_cycle), .dac_read_data_register (dac_read_data_register), .dac_read_data (dac_read_data), .dac_write_data_cycle (dac_write_data_cycle), .dac_write_data_register (dac_write_data_register), .dac_write_data (dac_write_data), .cur_start (cur_start), .cur_end (cur_end), .start_addr (start_addr), .vcursor (vcursor), .hcursor (hcursor), .horiz_total (horiz_total), .end_horiz (end_horiz), .st_hor_retr (st_hor_retr), .end_hor_retr (end_hor_retr), .vert_total (vert_total), .end_vert (end_vert), .st_ver_retr (st_ver_retr), .end_ver_retr (end_ver_retr), .v_retrace (v_retrace), .vh_retrace (vh_retrace) ); vga_lcd lcd ( .clk (wb_clk_i), .rst (wb_rst_i), .shift_reg1 (shift_reg1), .graphics_alpha (graphics_alpha), .pal_addr (pal_addr), .pal_we (pal_we), .pal_read (pal_read), .pal_write (pal_write), .dac_we (dac_we), .dac_read_data_cycle (dac_read_data_cycle), .dac_read_data_register (dac_read_data_register), .dac_read_data (dac_read_data), .dac_write_data_cycle (dac_write_data_cycle), .dac_write_data_register (dac_write_data_register), .dac_write_data (dac_write_data), .csr_adr_o (csr_adr_o), .csr_dat_i (csr_dat_i), .csr_stb_o (csr_stb_o), .vga_red_o (vga_red_o), .vga_green_o (vga_green_o), .vga_blue_o (vga_blue_o), .horiz_sync (horiz_sync), .vert_sync (w_vert_sync), .cur_start (cur_start), .cur_end (cur_end), .vcursor (vcursor), .hcursor (hcursor), .horiz_total (horiz_total), .end_horiz (end_horiz), .st_hor_retr (st_hor_retr), .end_hor_retr (end_hor_retr), .vert_total (vert_total), .end_vert (end_vert), .st_ver_retr (st_ver_retr), .end_ver_retr (end_ver_retr), .x_dotclockdiv2 (x_dotclockdiv2), .v_retrace (v_retrace), .vh_retrace (vh_retrace) ); vga_cpu_mem_iface cpu_mem_iface ( .wb_clk_i (wb_clk_i), .wb_rst_i (wb_rst_i), .wbs_adr_i (wb_adr_i), .wbs_sel_i (wb_sel_i), .wbs_we_i (wb_we_i), .wbs_dat_i (wb_dat_i), .wbs_dat_o (mem_wb_dat_o), .wbs_stb_i (stb & !wb_tga_i), .wbs_ack_o (mem_wb_ack_o), .wbm_adr_o (wbm_adr_o), .wbm_sel_o (wbm_sel_o), .wbm_we_o (wbm_we_o), .wbm_dat_o (wbm_dat_o), .wbm_dat_i (wbm_dat_i), .wbm_stb_o (wbm_stb_o), .wbm_ack_i (wbm_ack_i), .chain_four (chain_four), .memory_mapping1 (memory_mapping1), .write_mode (write_mode), .raster_op (raster_op), .read_mode (read_mode), .bitmask (bitmask), .set_reset (set_reset), .enable_set_reset (enable_set_reset), .map_mask (map_mask), .read_map_select (read_map_select), .color_compare (color_compare), .color_dont_care (color_dont_care) ); vga_mem_arbitrer mem_arbitrer ( .clk_i (wb_clk_i), .rst_i (wb_rst_i), .wb_adr_i (wbm_adr_o), .wb_sel_i (wbm_sel_o), .wb_we_i (wbm_we_o), .wb_dat_i (wbm_dat_o), .wb_dat_o (wbm_dat_i), .wb_stb_i (wbm_stb_o), .wb_ack_o (wbm_ack_i), .csr_adr_i (csr_adr_i), .csr_dat_o (csr_dat_i), .csr_stb_i (csr_stb_i), .csrm_adr_o (csrm_adr_o), .csrm_sel_o (csrm_sel_o), .csrm_we_o (csrm_we_o), .csrm_dat_o (csrm_dat_o), .csrm_dat_i (csrm_dat_i) ); // Continous assignments assign wb_dat_o = wb_tga_i ? conf_wb_dat_o : mem_wb_dat_o; assign wb_ack_o = wb_tga_i ? conf_wb_ack_o : mem_wb_ack_o; assign stb = wb_stb_i & wb_cyc_i; assign vert_sync = ~graphics_alpha ^ w_vert_sync; // Behaviour // csr_adr_i always @(posedge wb_clk_i) csr_adr_i <= wb_rst_i ? 17'h0 : csr_adr_o + start_addr[15:1]; // csr_stb_i always @(posedge wb_clk_i) csr_stb_i <= wb_rst_i ? 1'b0 : csr_stb_o; endmodule
/* * VGA top level file * Copyright (C) 2010 Zeus Gomez Marmolejo <[email protected]> * * This file is part of the Zet processor. This processor is free * hardware; you can redistribute it and/or modify it under the terms of * the GNU General Public License as published by the Free Software * Foundation; either version 3, or (at your option) any later version. * * Zet is distrubuted in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public * License for more details. * * You should have received a copy of the GNU General Public License * along with Zet; see the file COPYING. If not, see * <http://www.gnu.org/licenses/>. */ module vga ( // Wishbone signals input wb_clk_i, // 25 Mhz VDU clock input wb_rst_i, input [15:0] wb_dat_i, output [15:0] wb_dat_o, input [16:1] wb_adr_i, input wb_we_i, input wb_tga_i, input [ 1:0] wb_sel_i, input wb_stb_i, input wb_cyc_i, output wb_ack_o, // VGA pad signals output [ 3:0] vga_red_o, output [ 3:0] vga_green_o, output [ 3:0] vga_blue_o, output horiz_sync, output vert_sync, // CSR SRAM master interface output [17:1] csrm_adr_o, output [ 1:0] csrm_sel_o, output csrm_we_o, output [15:0] csrm_dat_o, input [15:0] csrm_dat_i ); // Registers and nets // // csr address reg [17:1] csr_adr_i; reg csr_stb_i; // Config wires wire [15:0] conf_wb_dat_o; wire conf_wb_ack_o; // Mem wires wire [15:0] mem_wb_dat_o; wire mem_wb_ack_o; // LCD wires wire [17:1] csr_adr_o; wire [15:0] csr_dat_i; wire csr_stb_o; wire v_retrace; wire vh_retrace; wire w_vert_sync; // VGA configuration registers wire shift_reg1; wire graphics_alpha; wire memory_mapping1; wire [ 1:0] write_mode; wire [ 1:0] raster_op; wire read_mode; wire [ 7:0] bitmask; wire [ 3:0] set_reset; wire [ 3:0] enable_set_reset; wire [ 3:0] map_mask; wire x_dotclockdiv2; wire chain_four; wire [ 1:0] read_map_select; wire [ 3:0] color_compare; wire [ 3:0] color_dont_care; // Wishbone master to SRAM wire [17:1] wbm_adr_o; wire [ 1:0] wbm_sel_o; wire wbm_we_o; wire [15:0] wbm_dat_o; wire [15:0] wbm_dat_i; wire wbm_stb_o; wire wbm_ack_i; wire stb; // CRT wires wire [ 5:0] cur_start; wire [ 5:0] cur_end; wire [15:0] start_addr; wire [ 4:0] vcursor; wire [ 6:0] hcursor; wire [ 6:0] horiz_total; wire [ 6:0] end_horiz; wire [ 6:0] st_hor_retr; wire [ 4:0] end_hor_retr; wire [ 9:0] vert_total; wire [ 9:0] end_vert; wire [ 9:0] st_ver_retr; wire [ 3:0] end_ver_retr; // attribute_ctrl wires wire [3:0] pal_addr; wire pal_we; wire [7:0] pal_read; wire [7:0] pal_write; // dac_regs wires wire dac_we; wire [1:0] dac_read_data_cycle; wire [7:0] dac_read_data_register; wire [3:0] dac_read_data; wire [1:0] dac_write_data_cycle; wire [7:0] dac_write_data_register; wire [3:0] dac_write_data; // Module instances // vga_config_iface config_iface ( .wb_clk_i (wb_clk_i), .wb_rst_i (wb_rst_i), .wb_dat_i (wb_dat_i), .wb_dat_o (conf_wb_dat_o), .wb_adr_i (wb_adr_i[4:1]), .wb_we_i (wb_we_i), .wb_sel_i (wb_sel_i), .wb_stb_i (stb & wb_tga_i), .wb_ack_o (conf_wb_ack_o), .shift_reg1 (shift_reg1), .graphics_alpha (graphics_alpha), .memory_mapping1 (memory_mapping1), .write_mode (write_mode), .raster_op (raster_op), .read_mode (read_mode), .bitmask (bitmask), .set_reset (set_reset), .enable_set_reset (enable_set_reset), .map_mask (map_mask), .x_dotclockdiv2 (x_dotclockdiv2), .chain_four (chain_four), .read_map_select (read_map_select), .color_compare (color_compare), .color_dont_care (color_dont_care), .pal_addr (pal_addr), .pal_we (pal_we), .pal_read (pal_read), .pal_write (pal_write), .dac_we (dac_we), .dac_read_data_cycle (dac_read_data_cycle), .dac_read_data_register (dac_read_data_register), .dac_read_data (dac_read_data), .dac_write_data_cycle (dac_write_data_cycle), .dac_write_data_register (dac_write_data_register), .dac_write_data (dac_write_data), .cur_start (cur_start), .cur_end (cur_end), .start_addr (start_addr), .vcursor (vcursor), .hcursor (hcursor), .horiz_total (horiz_total), .end_horiz (end_horiz), .st_hor_retr (st_hor_retr), .end_hor_retr (end_hor_retr), .vert_total (vert_total), .end_vert (end_vert), .st_ver_retr (st_ver_retr), .end_ver_retr (end_ver_retr), .v_retrace (v_retrace), .vh_retrace (vh_retrace) ); vga_lcd lcd ( .clk (wb_clk_i), .rst (wb_rst_i), .shift_reg1 (shift_reg1), .graphics_alpha (graphics_alpha), .pal_addr (pal_addr), .pal_we (pal_we), .pal_read (pal_read), .pal_write (pal_write), .dac_we (dac_we), .dac_read_data_cycle (dac_read_data_cycle), .dac_read_data_register (dac_read_data_register), .dac_read_data (dac_read_data), .dac_write_data_cycle (dac_write_data_cycle), .dac_write_data_register (dac_write_data_register), .dac_write_data (dac_write_data), .csr_adr_o (csr_adr_o), .csr_dat_i (csr_dat_i), .csr_stb_o (csr_stb_o), .vga_red_o (vga_red_o), .vga_green_o (vga_green_o), .vga_blue_o (vga_blue_o), .horiz_sync (horiz_sync), .vert_sync (w_vert_sync), .cur_start (cur_start), .cur_end (cur_end), .vcursor (vcursor), .hcursor (hcursor), .horiz_total (horiz_total), .end_horiz (end_horiz), .st_hor_retr (st_hor_retr), .end_hor_retr (end_hor_retr), .vert_total (vert_total), .end_vert (end_vert), .st_ver_retr (st_ver_retr), .end_ver_retr (end_ver_retr), .x_dotclockdiv2 (x_dotclockdiv2), .v_retrace (v_retrace), .vh_retrace (vh_retrace) ); vga_cpu_mem_iface cpu_mem_iface ( .wb_clk_i (wb_clk_i), .wb_rst_i (wb_rst_i), .wbs_adr_i (wb_adr_i), .wbs_sel_i (wb_sel_i), .wbs_we_i (wb_we_i), .wbs_dat_i (wb_dat_i), .wbs_dat_o (mem_wb_dat_o), .wbs_stb_i (stb & !wb_tga_i), .wbs_ack_o (mem_wb_ack_o), .wbm_adr_o (wbm_adr_o), .wbm_sel_o (wbm_sel_o), .wbm_we_o (wbm_we_o), .wbm_dat_o (wbm_dat_o), .wbm_dat_i (wbm_dat_i), .wbm_stb_o (wbm_stb_o), .wbm_ack_i (wbm_ack_i), .chain_four (chain_four), .memory_mapping1 (memory_mapping1), .write_mode (write_mode), .raster_op (raster_op), .read_mode (read_mode), .bitmask (bitmask), .set_reset (set_reset), .enable_set_reset (enable_set_reset), .map_mask (map_mask), .read_map_select (read_map_select), .color_compare (color_compare), .color_dont_care (color_dont_care) ); vga_mem_arbitrer mem_arbitrer ( .clk_i (wb_clk_i), .rst_i (wb_rst_i), .wb_adr_i (wbm_adr_o), .wb_sel_i (wbm_sel_o), .wb_we_i (wbm_we_o), .wb_dat_i (wbm_dat_o), .wb_dat_o (wbm_dat_i), .wb_stb_i (wbm_stb_o), .wb_ack_o (wbm_ack_i), .csr_adr_i (csr_adr_i), .csr_dat_o (csr_dat_i), .csr_stb_i (csr_stb_i), .csrm_adr_o (csrm_adr_o), .csrm_sel_o (csrm_sel_o), .csrm_we_o (csrm_we_o), .csrm_dat_o (csrm_dat_o), .csrm_dat_i (csrm_dat_i) ); // Continous assignments assign wb_dat_o = wb_tga_i ? conf_wb_dat_o : mem_wb_dat_o; assign wb_ack_o = wb_tga_i ? conf_wb_ack_o : mem_wb_ack_o; assign stb = wb_stb_i & wb_cyc_i; assign vert_sync = ~graphics_alpha ^ w_vert_sync; // Behaviour // csr_adr_i always @(posedge wb_clk_i) csr_adr_i <= wb_rst_i ? 17'h0 : csr_adr_o + start_addr[15:1]; // csr_stb_i always @(posedge wb_clk_i) csr_stb_i <= wb_rst_i ? 1'b0 : csr_stb_o; endmodule
/* * VGA top level file * Copyright (C) 2010 Zeus Gomez Marmolejo <[email protected]> * * This file is part of the Zet processor. This processor is free * hardware; you can redistribute it and/or modify it under the terms of * the GNU General Public License as published by the Free Software * Foundation; either version 3, or (at your option) any later version. * * Zet is distrubuted in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public * License for more details. * * You should have received a copy of the GNU General Public License * along with Zet; see the file COPYING. If not, see * <http://www.gnu.org/licenses/>. */ module vga ( // Wishbone signals input wb_clk_i, // 25 Mhz VDU clock input wb_rst_i, input [15:0] wb_dat_i, output [15:0] wb_dat_o, input [16:1] wb_adr_i, input wb_we_i, input wb_tga_i, input [ 1:0] wb_sel_i, input wb_stb_i, input wb_cyc_i, output wb_ack_o, // VGA pad signals output [ 3:0] vga_red_o, output [ 3:0] vga_green_o, output [ 3:0] vga_blue_o, output horiz_sync, output vert_sync, // CSR SRAM master interface output [17:1] csrm_adr_o, output [ 1:0] csrm_sel_o, output csrm_we_o, output [15:0] csrm_dat_o, input [15:0] csrm_dat_i ); // Registers and nets // // csr address reg [17:1] csr_adr_i; reg csr_stb_i; // Config wires wire [15:0] conf_wb_dat_o; wire conf_wb_ack_o; // Mem wires wire [15:0] mem_wb_dat_o; wire mem_wb_ack_o; // LCD wires wire [17:1] csr_adr_o; wire [15:0] csr_dat_i; wire csr_stb_o; wire v_retrace; wire vh_retrace; wire w_vert_sync; // VGA configuration registers wire shift_reg1; wire graphics_alpha; wire memory_mapping1; wire [ 1:0] write_mode; wire [ 1:0] raster_op; wire read_mode; wire [ 7:0] bitmask; wire [ 3:0] set_reset; wire [ 3:0] enable_set_reset; wire [ 3:0] map_mask; wire x_dotclockdiv2; wire chain_four; wire [ 1:0] read_map_select; wire [ 3:0] color_compare; wire [ 3:0] color_dont_care; // Wishbone master to SRAM wire [17:1] wbm_adr_o; wire [ 1:0] wbm_sel_o; wire wbm_we_o; wire [15:0] wbm_dat_o; wire [15:0] wbm_dat_i; wire wbm_stb_o; wire wbm_ack_i; wire stb; // CRT wires wire [ 5:0] cur_start; wire [ 5:0] cur_end; wire [15:0] start_addr; wire [ 4:0] vcursor; wire [ 6:0] hcursor; wire [ 6:0] horiz_total; wire [ 6:0] end_horiz; wire [ 6:0] st_hor_retr; wire [ 4:0] end_hor_retr; wire [ 9:0] vert_total; wire [ 9:0] end_vert; wire [ 9:0] st_ver_retr; wire [ 3:0] end_ver_retr; // attribute_ctrl wires wire [3:0] pal_addr; wire pal_we; wire [7:0] pal_read; wire [7:0] pal_write; // dac_regs wires wire dac_we; wire [1:0] dac_read_data_cycle; wire [7:0] dac_read_data_register; wire [3:0] dac_read_data; wire [1:0] dac_write_data_cycle; wire [7:0] dac_write_data_register; wire [3:0] dac_write_data; // Module instances // vga_config_iface config_iface ( .wb_clk_i (wb_clk_i), .wb_rst_i (wb_rst_i), .wb_dat_i (wb_dat_i), .wb_dat_o (conf_wb_dat_o), .wb_adr_i (wb_adr_i[4:1]), .wb_we_i (wb_we_i), .wb_sel_i (wb_sel_i), .wb_stb_i (stb & wb_tga_i), .wb_ack_o (conf_wb_ack_o), .shift_reg1 (shift_reg1), .graphics_alpha (graphics_alpha), .memory_mapping1 (memory_mapping1), .write_mode (write_mode), .raster_op (raster_op), .read_mode (read_mode), .bitmask (bitmask), .set_reset (set_reset), .enable_set_reset (enable_set_reset), .map_mask (map_mask), .x_dotclockdiv2 (x_dotclockdiv2), .chain_four (chain_four), .read_map_select (read_map_select), .color_compare (color_compare), .color_dont_care (color_dont_care), .pal_addr (pal_addr), .pal_we (pal_we), .pal_read (pal_read), .pal_write (pal_write), .dac_we (dac_we), .dac_read_data_cycle (dac_read_data_cycle), .dac_read_data_register (dac_read_data_register), .dac_read_data (dac_read_data), .dac_write_data_cycle (dac_write_data_cycle), .dac_write_data_register (dac_write_data_register), .dac_write_data (dac_write_data), .cur_start (cur_start), .cur_end (cur_end), .start_addr (start_addr), .vcursor (vcursor), .hcursor (hcursor), .horiz_total (horiz_total), .end_horiz (end_horiz), .st_hor_retr (st_hor_retr), .end_hor_retr (end_hor_retr), .vert_total (vert_total), .end_vert (end_vert), .st_ver_retr (st_ver_retr), .end_ver_retr (end_ver_retr), .v_retrace (v_retrace), .vh_retrace (vh_retrace) ); vga_lcd lcd ( .clk (wb_clk_i), .rst (wb_rst_i), .shift_reg1 (shift_reg1), .graphics_alpha (graphics_alpha), .pal_addr (pal_addr), .pal_we (pal_we), .pal_read (pal_read), .pal_write (pal_write), .dac_we (dac_we), .dac_read_data_cycle (dac_read_data_cycle), .dac_read_data_register (dac_read_data_register), .dac_read_data (dac_read_data), .dac_write_data_cycle (dac_write_data_cycle), .dac_write_data_register (dac_write_data_register), .dac_write_data (dac_write_data), .csr_adr_o (csr_adr_o), .csr_dat_i (csr_dat_i), .csr_stb_o (csr_stb_o), .vga_red_o (vga_red_o), .vga_green_o (vga_green_o), .vga_blue_o (vga_blue_o), .horiz_sync (horiz_sync), .vert_sync (w_vert_sync), .cur_start (cur_start), .cur_end (cur_end), .vcursor (vcursor), .hcursor (hcursor), .horiz_total (horiz_total), .end_horiz (end_horiz), .st_hor_retr (st_hor_retr), .end_hor_retr (end_hor_retr), .vert_total (vert_total), .end_vert (end_vert), .st_ver_retr (st_ver_retr), .end_ver_retr (end_ver_retr), .x_dotclockdiv2 (x_dotclockdiv2), .v_retrace (v_retrace), .vh_retrace (vh_retrace) ); vga_cpu_mem_iface cpu_mem_iface ( .wb_clk_i (wb_clk_i), .wb_rst_i (wb_rst_i), .wbs_adr_i (wb_adr_i), .wbs_sel_i (wb_sel_i), .wbs_we_i (wb_we_i), .wbs_dat_i (wb_dat_i), .wbs_dat_o (mem_wb_dat_o), .wbs_stb_i (stb & !wb_tga_i), .wbs_ack_o (mem_wb_ack_o), .wbm_adr_o (wbm_adr_o), .wbm_sel_o (wbm_sel_o), .wbm_we_o (wbm_we_o), .wbm_dat_o (wbm_dat_o), .wbm_dat_i (wbm_dat_i), .wbm_stb_o (wbm_stb_o), .wbm_ack_i (wbm_ack_i), .chain_four (chain_four), .memory_mapping1 (memory_mapping1), .write_mode (write_mode), .raster_op (raster_op), .read_mode (read_mode), .bitmask (bitmask), .set_reset (set_reset), .enable_set_reset (enable_set_reset), .map_mask (map_mask), .read_map_select (read_map_select), .color_compare (color_compare), .color_dont_care (color_dont_care) ); vga_mem_arbitrer mem_arbitrer ( .clk_i (wb_clk_i), .rst_i (wb_rst_i), .wb_adr_i (wbm_adr_o), .wb_sel_i (wbm_sel_o), .wb_we_i (wbm_we_o), .wb_dat_i (wbm_dat_o), .wb_dat_o (wbm_dat_i), .wb_stb_i (wbm_stb_o), .wb_ack_o (wbm_ack_i), .csr_adr_i (csr_adr_i), .csr_dat_o (csr_dat_i), .csr_stb_i (csr_stb_i), .csrm_adr_o (csrm_adr_o), .csrm_sel_o (csrm_sel_o), .csrm_we_o (csrm_we_o), .csrm_dat_o (csrm_dat_o), .csrm_dat_i (csrm_dat_i) ); // Continous assignments assign wb_dat_o = wb_tga_i ? conf_wb_dat_o : mem_wb_dat_o; assign wb_ack_o = wb_tga_i ? conf_wb_ack_o : mem_wb_ack_o; assign stb = wb_stb_i & wb_cyc_i; assign vert_sync = ~graphics_alpha ^ w_vert_sync; // Behaviour // csr_adr_i always @(posedge wb_clk_i) csr_adr_i <= wb_rst_i ? 17'h0 : csr_adr_o + start_addr[15:1]; // csr_stb_i always @(posedge wb_clk_i) csr_stb_i <= wb_rst_i ? 1'b0 : csr_stb_o; endmodule
/* * VGA top level file * Copyright (C) 2010 Zeus Gomez Marmolejo <[email protected]> * * This file is part of the Zet processor. This processor is free * hardware; you can redistribute it and/or modify it under the terms of * the GNU General Public License as published by the Free Software * Foundation; either version 3, or (at your option) any later version. * * Zet is distrubuted in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public * License for more details. * * You should have received a copy of the GNU General Public License * along with Zet; see the file COPYING. If not, see * <http://www.gnu.org/licenses/>. */ module vga ( // Wishbone signals input wb_clk_i, // 25 Mhz VDU clock input wb_rst_i, input [15:0] wb_dat_i, output [15:0] wb_dat_o, input [16:1] wb_adr_i, input wb_we_i, input wb_tga_i, input [ 1:0] wb_sel_i, input wb_stb_i, input wb_cyc_i, output wb_ack_o, // VGA pad signals output [ 3:0] vga_red_o, output [ 3:0] vga_green_o, output [ 3:0] vga_blue_o, output horiz_sync, output vert_sync, // CSR SRAM master interface output [17:1] csrm_adr_o, output [ 1:0] csrm_sel_o, output csrm_we_o, output [15:0] csrm_dat_o, input [15:0] csrm_dat_i ); // Registers and nets // // csr address reg [17:1] csr_adr_i; reg csr_stb_i; // Config wires wire [15:0] conf_wb_dat_o; wire conf_wb_ack_o; // Mem wires wire [15:0] mem_wb_dat_o; wire mem_wb_ack_o; // LCD wires wire [17:1] csr_adr_o; wire [15:0] csr_dat_i; wire csr_stb_o; wire v_retrace; wire vh_retrace; wire w_vert_sync; // VGA configuration registers wire shift_reg1; wire graphics_alpha; wire memory_mapping1; wire [ 1:0] write_mode; wire [ 1:0] raster_op; wire read_mode; wire [ 7:0] bitmask; wire [ 3:0] set_reset; wire [ 3:0] enable_set_reset; wire [ 3:0] map_mask; wire x_dotclockdiv2; wire chain_four; wire [ 1:0] read_map_select; wire [ 3:0] color_compare; wire [ 3:0] color_dont_care; // Wishbone master to SRAM wire [17:1] wbm_adr_o; wire [ 1:0] wbm_sel_o; wire wbm_we_o; wire [15:0] wbm_dat_o; wire [15:0] wbm_dat_i; wire wbm_stb_o; wire wbm_ack_i; wire stb; // CRT wires wire [ 5:0] cur_start; wire [ 5:0] cur_end; wire [15:0] start_addr; wire [ 4:0] vcursor; wire [ 6:0] hcursor; wire [ 6:0] horiz_total; wire [ 6:0] end_horiz; wire [ 6:0] st_hor_retr; wire [ 4:0] end_hor_retr; wire [ 9:0] vert_total; wire [ 9:0] end_vert; wire [ 9:0] st_ver_retr; wire [ 3:0] end_ver_retr; // attribute_ctrl wires wire [3:0] pal_addr; wire pal_we; wire [7:0] pal_read; wire [7:0] pal_write; // dac_regs wires wire dac_we; wire [1:0] dac_read_data_cycle; wire [7:0] dac_read_data_register; wire [3:0] dac_read_data; wire [1:0] dac_write_data_cycle; wire [7:0] dac_write_data_register; wire [3:0] dac_write_data; // Module instances // vga_config_iface config_iface ( .wb_clk_i (wb_clk_i), .wb_rst_i (wb_rst_i), .wb_dat_i (wb_dat_i), .wb_dat_o (conf_wb_dat_o), .wb_adr_i (wb_adr_i[4:1]), .wb_we_i (wb_we_i), .wb_sel_i (wb_sel_i), .wb_stb_i (stb & wb_tga_i), .wb_ack_o (conf_wb_ack_o), .shift_reg1 (shift_reg1), .graphics_alpha (graphics_alpha), .memory_mapping1 (memory_mapping1), .write_mode (write_mode), .raster_op (raster_op), .read_mode (read_mode), .bitmask (bitmask), .set_reset (set_reset), .enable_set_reset (enable_set_reset), .map_mask (map_mask), .x_dotclockdiv2 (x_dotclockdiv2), .chain_four (chain_four), .read_map_select (read_map_select), .color_compare (color_compare), .color_dont_care (color_dont_care), .pal_addr (pal_addr), .pal_we (pal_we), .pal_read (pal_read), .pal_write (pal_write), .dac_we (dac_we), .dac_read_data_cycle (dac_read_data_cycle), .dac_read_data_register (dac_read_data_register), .dac_read_data (dac_read_data), .dac_write_data_cycle (dac_write_data_cycle), .dac_write_data_register (dac_write_data_register), .dac_write_data (dac_write_data), .cur_start (cur_start), .cur_end (cur_end), .start_addr (start_addr), .vcursor (vcursor), .hcursor (hcursor), .horiz_total (horiz_total), .end_horiz (end_horiz), .st_hor_retr (st_hor_retr), .end_hor_retr (end_hor_retr), .vert_total (vert_total), .end_vert (end_vert), .st_ver_retr (st_ver_retr), .end_ver_retr (end_ver_retr), .v_retrace (v_retrace), .vh_retrace (vh_retrace) ); vga_lcd lcd ( .clk (wb_clk_i), .rst (wb_rst_i), .shift_reg1 (shift_reg1), .graphics_alpha (graphics_alpha), .pal_addr (pal_addr), .pal_we (pal_we), .pal_read (pal_read), .pal_write (pal_write), .dac_we (dac_we), .dac_read_data_cycle (dac_read_data_cycle), .dac_read_data_register (dac_read_data_register), .dac_read_data (dac_read_data), .dac_write_data_cycle (dac_write_data_cycle), .dac_write_data_register (dac_write_data_register), .dac_write_data (dac_write_data), .csr_adr_o (csr_adr_o), .csr_dat_i (csr_dat_i), .csr_stb_o (csr_stb_o), .vga_red_o (vga_red_o), .vga_green_o (vga_green_o), .vga_blue_o (vga_blue_o), .horiz_sync (horiz_sync), .vert_sync (w_vert_sync), .cur_start (cur_start), .cur_end (cur_end), .vcursor (vcursor), .hcursor (hcursor), .horiz_total (horiz_total), .end_horiz (end_horiz), .st_hor_retr (st_hor_retr), .end_hor_retr (end_hor_retr), .vert_total (vert_total), .end_vert (end_vert), .st_ver_retr (st_ver_retr), .end_ver_retr (end_ver_retr), .x_dotclockdiv2 (x_dotclockdiv2), .v_retrace (v_retrace), .vh_retrace (vh_retrace) ); vga_cpu_mem_iface cpu_mem_iface ( .wb_clk_i (wb_clk_i), .wb_rst_i (wb_rst_i), .wbs_adr_i (wb_adr_i), .wbs_sel_i (wb_sel_i), .wbs_we_i (wb_we_i), .wbs_dat_i (wb_dat_i), .wbs_dat_o (mem_wb_dat_o), .wbs_stb_i (stb & !wb_tga_i), .wbs_ack_o (mem_wb_ack_o), .wbm_adr_o (wbm_adr_o), .wbm_sel_o (wbm_sel_o), .wbm_we_o (wbm_we_o), .wbm_dat_o (wbm_dat_o), .wbm_dat_i (wbm_dat_i), .wbm_stb_o (wbm_stb_o), .wbm_ack_i (wbm_ack_i), .chain_four (chain_four), .memory_mapping1 (memory_mapping1), .write_mode (write_mode), .raster_op (raster_op), .read_mode (read_mode), .bitmask (bitmask), .set_reset (set_reset), .enable_set_reset (enable_set_reset), .map_mask (map_mask), .read_map_select (read_map_select), .color_compare (color_compare), .color_dont_care (color_dont_care) ); vga_mem_arbitrer mem_arbitrer ( .clk_i (wb_clk_i), .rst_i (wb_rst_i), .wb_adr_i (wbm_adr_o), .wb_sel_i (wbm_sel_o), .wb_we_i (wbm_we_o), .wb_dat_i (wbm_dat_o), .wb_dat_o (wbm_dat_i), .wb_stb_i (wbm_stb_o), .wb_ack_o (wbm_ack_i), .csr_adr_i (csr_adr_i), .csr_dat_o (csr_dat_i), .csr_stb_i (csr_stb_i), .csrm_adr_o (csrm_adr_o), .csrm_sel_o (csrm_sel_o), .csrm_we_o (csrm_we_o), .csrm_dat_o (csrm_dat_o), .csrm_dat_i (csrm_dat_i) ); // Continous assignments assign wb_dat_o = wb_tga_i ? conf_wb_dat_o : mem_wb_dat_o; assign wb_ack_o = wb_tga_i ? conf_wb_ack_o : mem_wb_ack_o; assign stb = wb_stb_i & wb_cyc_i; assign vert_sync = ~graphics_alpha ^ w_vert_sync; // Behaviour // csr_adr_i always @(posedge wb_clk_i) csr_adr_i <= wb_rst_i ? 17'h0 : csr_adr_o + start_addr[15:1]; // csr_stb_i always @(posedge wb_clk_i) csr_stb_i <= wb_rst_i ? 1'b0 : csr_stb_o; endmodule
/* * VGA top level file * Copyright (C) 2010 Zeus Gomez Marmolejo <[email protected]> * * This file is part of the Zet processor. This processor is free * hardware; you can redistribute it and/or modify it under the terms of * the GNU General Public License as published by the Free Software * Foundation; either version 3, or (at your option) any later version. * * Zet is distrubuted in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public * License for more details. * * You should have received a copy of the GNU General Public License * along with Zet; see the file COPYING. If not, see * <http://www.gnu.org/licenses/>. */ module vga ( // Wishbone signals input wb_clk_i, // 25 Mhz VDU clock input wb_rst_i, input [15:0] wb_dat_i, output [15:0] wb_dat_o, input [16:1] wb_adr_i, input wb_we_i, input wb_tga_i, input [ 1:0] wb_sel_i, input wb_stb_i, input wb_cyc_i, output wb_ack_o, // VGA pad signals output [ 3:0] vga_red_o, output [ 3:0] vga_green_o, output [ 3:0] vga_blue_o, output horiz_sync, output vert_sync, // CSR SRAM master interface output [17:1] csrm_adr_o, output [ 1:0] csrm_sel_o, output csrm_we_o, output [15:0] csrm_dat_o, input [15:0] csrm_dat_i ); // Registers and nets // // csr address reg [17:1] csr_adr_i; reg csr_stb_i; // Config wires wire [15:0] conf_wb_dat_o; wire conf_wb_ack_o; // Mem wires wire [15:0] mem_wb_dat_o; wire mem_wb_ack_o; // LCD wires wire [17:1] csr_adr_o; wire [15:0] csr_dat_i; wire csr_stb_o; wire v_retrace; wire vh_retrace; wire w_vert_sync; // VGA configuration registers wire shift_reg1; wire graphics_alpha; wire memory_mapping1; wire [ 1:0] write_mode; wire [ 1:0] raster_op; wire read_mode; wire [ 7:0] bitmask; wire [ 3:0] set_reset; wire [ 3:0] enable_set_reset; wire [ 3:0] map_mask; wire x_dotclockdiv2; wire chain_four; wire [ 1:0] read_map_select; wire [ 3:0] color_compare; wire [ 3:0] color_dont_care; // Wishbone master to SRAM wire [17:1] wbm_adr_o; wire [ 1:0] wbm_sel_o; wire wbm_we_o; wire [15:0] wbm_dat_o; wire [15:0] wbm_dat_i; wire wbm_stb_o; wire wbm_ack_i; wire stb; // CRT wires wire [ 5:0] cur_start; wire [ 5:0] cur_end; wire [15:0] start_addr; wire [ 4:0] vcursor; wire [ 6:0] hcursor; wire [ 6:0] horiz_total; wire [ 6:0] end_horiz; wire [ 6:0] st_hor_retr; wire [ 4:0] end_hor_retr; wire [ 9:0] vert_total; wire [ 9:0] end_vert; wire [ 9:0] st_ver_retr; wire [ 3:0] end_ver_retr; // attribute_ctrl wires wire [3:0] pal_addr; wire pal_we; wire [7:0] pal_read; wire [7:0] pal_write; // dac_regs wires wire dac_we; wire [1:0] dac_read_data_cycle; wire [7:0] dac_read_data_register; wire [3:0] dac_read_data; wire [1:0] dac_write_data_cycle; wire [7:0] dac_write_data_register; wire [3:0] dac_write_data; // Module instances // vga_config_iface config_iface ( .wb_clk_i (wb_clk_i), .wb_rst_i (wb_rst_i), .wb_dat_i (wb_dat_i), .wb_dat_o (conf_wb_dat_o), .wb_adr_i (wb_adr_i[4:1]), .wb_we_i (wb_we_i), .wb_sel_i (wb_sel_i), .wb_stb_i (stb & wb_tga_i), .wb_ack_o (conf_wb_ack_o), .shift_reg1 (shift_reg1), .graphics_alpha (graphics_alpha), .memory_mapping1 (memory_mapping1), .write_mode (write_mode), .raster_op (raster_op), .read_mode (read_mode), .bitmask (bitmask), .set_reset (set_reset), .enable_set_reset (enable_set_reset), .map_mask (map_mask), .x_dotclockdiv2 (x_dotclockdiv2), .chain_four (chain_four), .read_map_select (read_map_select), .color_compare (color_compare), .color_dont_care (color_dont_care), .pal_addr (pal_addr), .pal_we (pal_we), .pal_read (pal_read), .pal_write (pal_write), .dac_we (dac_we), .dac_read_data_cycle (dac_read_data_cycle), .dac_read_data_register (dac_read_data_register), .dac_read_data (dac_read_data), .dac_write_data_cycle (dac_write_data_cycle), .dac_write_data_register (dac_write_data_register), .dac_write_data (dac_write_data), .cur_start (cur_start), .cur_end (cur_end), .start_addr (start_addr), .vcursor (vcursor), .hcursor (hcursor), .horiz_total (horiz_total), .end_horiz (end_horiz), .st_hor_retr (st_hor_retr), .end_hor_retr (end_hor_retr), .vert_total (vert_total), .end_vert (end_vert), .st_ver_retr (st_ver_retr), .end_ver_retr (end_ver_retr), .v_retrace (v_retrace), .vh_retrace (vh_retrace) ); vga_lcd lcd ( .clk (wb_clk_i), .rst (wb_rst_i), .shift_reg1 (shift_reg1), .graphics_alpha (graphics_alpha), .pal_addr (pal_addr), .pal_we (pal_we), .pal_read (pal_read), .pal_write (pal_write), .dac_we (dac_we), .dac_read_data_cycle (dac_read_data_cycle), .dac_read_data_register (dac_read_data_register), .dac_read_data (dac_read_data), .dac_write_data_cycle (dac_write_data_cycle), .dac_write_data_register (dac_write_data_register), .dac_write_data (dac_write_data), .csr_adr_o (csr_adr_o), .csr_dat_i (csr_dat_i), .csr_stb_o (csr_stb_o), .vga_red_o (vga_red_o), .vga_green_o (vga_green_o), .vga_blue_o (vga_blue_o), .horiz_sync (horiz_sync), .vert_sync (w_vert_sync), .cur_start (cur_start), .cur_end (cur_end), .vcursor (vcursor), .hcursor (hcursor), .horiz_total (horiz_total), .end_horiz (end_horiz), .st_hor_retr (st_hor_retr), .end_hor_retr (end_hor_retr), .vert_total (vert_total), .end_vert (end_vert), .st_ver_retr (st_ver_retr), .end_ver_retr (end_ver_retr), .x_dotclockdiv2 (x_dotclockdiv2), .v_retrace (v_retrace), .vh_retrace (vh_retrace) ); vga_cpu_mem_iface cpu_mem_iface ( .wb_clk_i (wb_clk_i), .wb_rst_i (wb_rst_i), .wbs_adr_i (wb_adr_i), .wbs_sel_i (wb_sel_i), .wbs_we_i (wb_we_i), .wbs_dat_i (wb_dat_i), .wbs_dat_o (mem_wb_dat_o), .wbs_stb_i (stb & !wb_tga_i), .wbs_ack_o (mem_wb_ack_o), .wbm_adr_o (wbm_adr_o), .wbm_sel_o (wbm_sel_o), .wbm_we_o (wbm_we_o), .wbm_dat_o (wbm_dat_o), .wbm_dat_i (wbm_dat_i), .wbm_stb_o (wbm_stb_o), .wbm_ack_i (wbm_ack_i), .chain_four (chain_four), .memory_mapping1 (memory_mapping1), .write_mode (write_mode), .raster_op (raster_op), .read_mode (read_mode), .bitmask (bitmask), .set_reset (set_reset), .enable_set_reset (enable_set_reset), .map_mask (map_mask), .read_map_select (read_map_select), .color_compare (color_compare), .color_dont_care (color_dont_care) ); vga_mem_arbitrer mem_arbitrer ( .clk_i (wb_clk_i), .rst_i (wb_rst_i), .wb_adr_i (wbm_adr_o), .wb_sel_i (wbm_sel_o), .wb_we_i (wbm_we_o), .wb_dat_i (wbm_dat_o), .wb_dat_o (wbm_dat_i), .wb_stb_i (wbm_stb_o), .wb_ack_o (wbm_ack_i), .csr_adr_i (csr_adr_i), .csr_dat_o (csr_dat_i), .csr_stb_i (csr_stb_i), .csrm_adr_o (csrm_adr_o), .csrm_sel_o (csrm_sel_o), .csrm_we_o (csrm_we_o), .csrm_dat_o (csrm_dat_o), .csrm_dat_i (csrm_dat_i) ); // Continous assignments assign wb_dat_o = wb_tga_i ? conf_wb_dat_o : mem_wb_dat_o; assign wb_ack_o = wb_tga_i ? conf_wb_ack_o : mem_wb_ack_o; assign stb = wb_stb_i & wb_cyc_i; assign vert_sync = ~graphics_alpha ^ w_vert_sync; // Behaviour // csr_adr_i always @(posedge wb_clk_i) csr_adr_i <= wb_rst_i ? 17'h0 : csr_adr_o + start_addr[15:1]; // csr_stb_i always @(posedge wb_clk_i) csr_stb_i <= wb_rst_i ? 1'b0 : csr_stb_o; endmodule
/* * VGA top level file * Copyright (C) 2010 Zeus Gomez Marmolejo <[email protected]> * * This file is part of the Zet processor. This processor is free * hardware; you can redistribute it and/or modify it under the terms of * the GNU General Public License as published by the Free Software * Foundation; either version 3, or (at your option) any later version. * * Zet is distrubuted in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public * License for more details. * * You should have received a copy of the GNU General Public License * along with Zet; see the file COPYING. If not, see * <http://www.gnu.org/licenses/>. */ module vga ( // Wishbone signals input wb_clk_i, // 25 Mhz VDU clock input wb_rst_i, input [15:0] wb_dat_i, output [15:0] wb_dat_o, input [16:1] wb_adr_i, input wb_we_i, input wb_tga_i, input [ 1:0] wb_sel_i, input wb_stb_i, input wb_cyc_i, output wb_ack_o, // VGA pad signals output [ 3:0] vga_red_o, output [ 3:0] vga_green_o, output [ 3:0] vga_blue_o, output horiz_sync, output vert_sync, // CSR SRAM master interface output [17:1] csrm_adr_o, output [ 1:0] csrm_sel_o, output csrm_we_o, output [15:0] csrm_dat_o, input [15:0] csrm_dat_i ); // Registers and nets // // csr address reg [17:1] csr_adr_i; reg csr_stb_i; // Config wires wire [15:0] conf_wb_dat_o; wire conf_wb_ack_o; // Mem wires wire [15:0] mem_wb_dat_o; wire mem_wb_ack_o; // LCD wires wire [17:1] csr_adr_o; wire [15:0] csr_dat_i; wire csr_stb_o; wire v_retrace; wire vh_retrace; wire w_vert_sync; // VGA configuration registers wire shift_reg1; wire graphics_alpha; wire memory_mapping1; wire [ 1:0] write_mode; wire [ 1:0] raster_op; wire read_mode; wire [ 7:0] bitmask; wire [ 3:0] set_reset; wire [ 3:0] enable_set_reset; wire [ 3:0] map_mask; wire x_dotclockdiv2; wire chain_four; wire [ 1:0] read_map_select; wire [ 3:0] color_compare; wire [ 3:0] color_dont_care; // Wishbone master to SRAM wire [17:1] wbm_adr_o; wire [ 1:0] wbm_sel_o; wire wbm_we_o; wire [15:0] wbm_dat_o; wire [15:0] wbm_dat_i; wire wbm_stb_o; wire wbm_ack_i; wire stb; // CRT wires wire [ 5:0] cur_start; wire [ 5:0] cur_end; wire [15:0] start_addr; wire [ 4:0] vcursor; wire [ 6:0] hcursor; wire [ 6:0] horiz_total; wire [ 6:0] end_horiz; wire [ 6:0] st_hor_retr; wire [ 4:0] end_hor_retr; wire [ 9:0] vert_total; wire [ 9:0] end_vert; wire [ 9:0] st_ver_retr; wire [ 3:0] end_ver_retr; // attribute_ctrl wires wire [3:0] pal_addr; wire pal_we; wire [7:0] pal_read; wire [7:0] pal_write; // dac_regs wires wire dac_we; wire [1:0] dac_read_data_cycle; wire [7:0] dac_read_data_register; wire [3:0] dac_read_data; wire [1:0] dac_write_data_cycle; wire [7:0] dac_write_data_register; wire [3:0] dac_write_data; // Module instances // vga_config_iface config_iface ( .wb_clk_i (wb_clk_i), .wb_rst_i (wb_rst_i), .wb_dat_i (wb_dat_i), .wb_dat_o (conf_wb_dat_o), .wb_adr_i (wb_adr_i[4:1]), .wb_we_i (wb_we_i), .wb_sel_i (wb_sel_i), .wb_stb_i (stb & wb_tga_i), .wb_ack_o (conf_wb_ack_o), .shift_reg1 (shift_reg1), .graphics_alpha (graphics_alpha), .memory_mapping1 (memory_mapping1), .write_mode (write_mode), .raster_op (raster_op), .read_mode (read_mode), .bitmask (bitmask), .set_reset (set_reset), .enable_set_reset (enable_set_reset), .map_mask (map_mask), .x_dotclockdiv2 (x_dotclockdiv2), .chain_four (chain_four), .read_map_select (read_map_select), .color_compare (color_compare), .color_dont_care (color_dont_care), .pal_addr (pal_addr), .pal_we (pal_we), .pal_read (pal_read), .pal_write (pal_write), .dac_we (dac_we), .dac_read_data_cycle (dac_read_data_cycle), .dac_read_data_register (dac_read_data_register), .dac_read_data (dac_read_data), .dac_write_data_cycle (dac_write_data_cycle), .dac_write_data_register (dac_write_data_register), .dac_write_data (dac_write_data), .cur_start (cur_start), .cur_end (cur_end), .start_addr (start_addr), .vcursor (vcursor), .hcursor (hcursor), .horiz_total (horiz_total), .end_horiz (end_horiz), .st_hor_retr (st_hor_retr), .end_hor_retr (end_hor_retr), .vert_total (vert_total), .end_vert (end_vert), .st_ver_retr (st_ver_retr), .end_ver_retr (end_ver_retr), .v_retrace (v_retrace), .vh_retrace (vh_retrace) ); vga_lcd lcd ( .clk (wb_clk_i), .rst (wb_rst_i), .shift_reg1 (shift_reg1), .graphics_alpha (graphics_alpha), .pal_addr (pal_addr), .pal_we (pal_we), .pal_read (pal_read), .pal_write (pal_write), .dac_we (dac_we), .dac_read_data_cycle (dac_read_data_cycle), .dac_read_data_register (dac_read_data_register), .dac_read_data (dac_read_data), .dac_write_data_cycle (dac_write_data_cycle), .dac_write_data_register (dac_write_data_register), .dac_write_data (dac_write_data), .csr_adr_o (csr_adr_o), .csr_dat_i (csr_dat_i), .csr_stb_o (csr_stb_o), .vga_red_o (vga_red_o), .vga_green_o (vga_green_o), .vga_blue_o (vga_blue_o), .horiz_sync (horiz_sync), .vert_sync (w_vert_sync), .cur_start (cur_start), .cur_end (cur_end), .vcursor (vcursor), .hcursor (hcursor), .horiz_total (horiz_total), .end_horiz (end_horiz), .st_hor_retr (st_hor_retr), .end_hor_retr (end_hor_retr), .vert_total (vert_total), .end_vert (end_vert), .st_ver_retr (st_ver_retr), .end_ver_retr (end_ver_retr), .x_dotclockdiv2 (x_dotclockdiv2), .v_retrace (v_retrace), .vh_retrace (vh_retrace) ); vga_cpu_mem_iface cpu_mem_iface ( .wb_clk_i (wb_clk_i), .wb_rst_i (wb_rst_i), .wbs_adr_i (wb_adr_i), .wbs_sel_i (wb_sel_i), .wbs_we_i (wb_we_i), .wbs_dat_i (wb_dat_i), .wbs_dat_o (mem_wb_dat_o), .wbs_stb_i (stb & !wb_tga_i), .wbs_ack_o (mem_wb_ack_o), .wbm_adr_o (wbm_adr_o), .wbm_sel_o (wbm_sel_o), .wbm_we_o (wbm_we_o), .wbm_dat_o (wbm_dat_o), .wbm_dat_i (wbm_dat_i), .wbm_stb_o (wbm_stb_o), .wbm_ack_i (wbm_ack_i), .chain_four (chain_four), .memory_mapping1 (memory_mapping1), .write_mode (write_mode), .raster_op (raster_op), .read_mode (read_mode), .bitmask (bitmask), .set_reset (set_reset), .enable_set_reset (enable_set_reset), .map_mask (map_mask), .read_map_select (read_map_select), .color_compare (color_compare), .color_dont_care (color_dont_care) ); vga_mem_arbitrer mem_arbitrer ( .clk_i (wb_clk_i), .rst_i (wb_rst_i), .wb_adr_i (wbm_adr_o), .wb_sel_i (wbm_sel_o), .wb_we_i (wbm_we_o), .wb_dat_i (wbm_dat_o), .wb_dat_o (wbm_dat_i), .wb_stb_i (wbm_stb_o), .wb_ack_o (wbm_ack_i), .csr_adr_i (csr_adr_i), .csr_dat_o (csr_dat_i), .csr_stb_i (csr_stb_i), .csrm_adr_o (csrm_adr_o), .csrm_sel_o (csrm_sel_o), .csrm_we_o (csrm_we_o), .csrm_dat_o (csrm_dat_o), .csrm_dat_i (csrm_dat_i) ); // Continous assignments assign wb_dat_o = wb_tga_i ? conf_wb_dat_o : mem_wb_dat_o; assign wb_ack_o = wb_tga_i ? conf_wb_ack_o : mem_wb_ack_o; assign stb = wb_stb_i & wb_cyc_i; assign vert_sync = ~graphics_alpha ^ w_vert_sync; // Behaviour // csr_adr_i always @(posedge wb_clk_i) csr_adr_i <= wb_rst_i ? 17'h0 : csr_adr_o + start_addr[15:1]; // csr_stb_i always @(posedge wb_clk_i) csr_stb_i <= wb_rst_i ? 1'b0 : csr_stb_o; endmodule
/* * VGA top level file * Copyright (C) 2010 Zeus Gomez Marmolejo <[email protected]> * * This file is part of the Zet processor. This processor is free * hardware; you can redistribute it and/or modify it under the terms of * the GNU General Public License as published by the Free Software * Foundation; either version 3, or (at your option) any later version. * * Zet is distrubuted in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public * License for more details. * * You should have received a copy of the GNU General Public License * along with Zet; see the file COPYING. If not, see * <http://www.gnu.org/licenses/>. */ module vga ( // Wishbone signals input wb_clk_i, // 25 Mhz VDU clock input wb_rst_i, input [15:0] wb_dat_i, output [15:0] wb_dat_o, input [16:1] wb_adr_i, input wb_we_i, input wb_tga_i, input [ 1:0] wb_sel_i, input wb_stb_i, input wb_cyc_i, output wb_ack_o, // VGA pad signals output [ 3:0] vga_red_o, output [ 3:0] vga_green_o, output [ 3:0] vga_blue_o, output horiz_sync, output vert_sync, // CSR SRAM master interface output [17:1] csrm_adr_o, output [ 1:0] csrm_sel_o, output csrm_we_o, output [15:0] csrm_dat_o, input [15:0] csrm_dat_i ); // Registers and nets // // csr address reg [17:1] csr_adr_i; reg csr_stb_i; // Config wires wire [15:0] conf_wb_dat_o; wire conf_wb_ack_o; // Mem wires wire [15:0] mem_wb_dat_o; wire mem_wb_ack_o; // LCD wires wire [17:1] csr_adr_o; wire [15:0] csr_dat_i; wire csr_stb_o; wire v_retrace; wire vh_retrace; wire w_vert_sync; // VGA configuration registers wire shift_reg1; wire graphics_alpha; wire memory_mapping1; wire [ 1:0] write_mode; wire [ 1:0] raster_op; wire read_mode; wire [ 7:0] bitmask; wire [ 3:0] set_reset; wire [ 3:0] enable_set_reset; wire [ 3:0] map_mask; wire x_dotclockdiv2; wire chain_four; wire [ 1:0] read_map_select; wire [ 3:0] color_compare; wire [ 3:0] color_dont_care; // Wishbone master to SRAM wire [17:1] wbm_adr_o; wire [ 1:0] wbm_sel_o; wire wbm_we_o; wire [15:0] wbm_dat_o; wire [15:0] wbm_dat_i; wire wbm_stb_o; wire wbm_ack_i; wire stb; // CRT wires wire [ 5:0] cur_start; wire [ 5:0] cur_end; wire [15:0] start_addr; wire [ 4:0] vcursor; wire [ 6:0] hcursor; wire [ 6:0] horiz_total; wire [ 6:0] end_horiz; wire [ 6:0] st_hor_retr; wire [ 4:0] end_hor_retr; wire [ 9:0] vert_total; wire [ 9:0] end_vert; wire [ 9:0] st_ver_retr; wire [ 3:0] end_ver_retr; // attribute_ctrl wires wire [3:0] pal_addr; wire pal_we; wire [7:0] pal_read; wire [7:0] pal_write; // dac_regs wires wire dac_we; wire [1:0] dac_read_data_cycle; wire [7:0] dac_read_data_register; wire [3:0] dac_read_data; wire [1:0] dac_write_data_cycle; wire [7:0] dac_write_data_register; wire [3:0] dac_write_data; // Module instances // vga_config_iface config_iface ( .wb_clk_i (wb_clk_i), .wb_rst_i (wb_rst_i), .wb_dat_i (wb_dat_i), .wb_dat_o (conf_wb_dat_o), .wb_adr_i (wb_adr_i[4:1]), .wb_we_i (wb_we_i), .wb_sel_i (wb_sel_i), .wb_stb_i (stb & wb_tga_i), .wb_ack_o (conf_wb_ack_o), .shift_reg1 (shift_reg1), .graphics_alpha (graphics_alpha), .memory_mapping1 (memory_mapping1), .write_mode (write_mode), .raster_op (raster_op), .read_mode (read_mode), .bitmask (bitmask), .set_reset (set_reset), .enable_set_reset (enable_set_reset), .map_mask (map_mask), .x_dotclockdiv2 (x_dotclockdiv2), .chain_four (chain_four), .read_map_select (read_map_select), .color_compare (color_compare), .color_dont_care (color_dont_care), .pal_addr (pal_addr), .pal_we (pal_we), .pal_read (pal_read), .pal_write (pal_write), .dac_we (dac_we), .dac_read_data_cycle (dac_read_data_cycle), .dac_read_data_register (dac_read_data_register), .dac_read_data (dac_read_data), .dac_write_data_cycle (dac_write_data_cycle), .dac_write_data_register (dac_write_data_register), .dac_write_data (dac_write_data), .cur_start (cur_start), .cur_end (cur_end), .start_addr (start_addr), .vcursor (vcursor), .hcursor (hcursor), .horiz_total (horiz_total), .end_horiz (end_horiz), .st_hor_retr (st_hor_retr), .end_hor_retr (end_hor_retr), .vert_total (vert_total), .end_vert (end_vert), .st_ver_retr (st_ver_retr), .end_ver_retr (end_ver_retr), .v_retrace (v_retrace), .vh_retrace (vh_retrace) ); vga_lcd lcd ( .clk (wb_clk_i), .rst (wb_rst_i), .shift_reg1 (shift_reg1), .graphics_alpha (graphics_alpha), .pal_addr (pal_addr), .pal_we (pal_we), .pal_read (pal_read), .pal_write (pal_write), .dac_we (dac_we), .dac_read_data_cycle (dac_read_data_cycle), .dac_read_data_register (dac_read_data_register), .dac_read_data (dac_read_data), .dac_write_data_cycle (dac_write_data_cycle), .dac_write_data_register (dac_write_data_register), .dac_write_data (dac_write_data), .csr_adr_o (csr_adr_o), .csr_dat_i (csr_dat_i), .csr_stb_o (csr_stb_o), .vga_red_o (vga_red_o), .vga_green_o (vga_green_o), .vga_blue_o (vga_blue_o), .horiz_sync (horiz_sync), .vert_sync (w_vert_sync), .cur_start (cur_start), .cur_end (cur_end), .vcursor (vcursor), .hcursor (hcursor), .horiz_total (horiz_total), .end_horiz (end_horiz), .st_hor_retr (st_hor_retr), .end_hor_retr (end_hor_retr), .vert_total (vert_total), .end_vert (end_vert), .st_ver_retr (st_ver_retr), .end_ver_retr (end_ver_retr), .x_dotclockdiv2 (x_dotclockdiv2), .v_retrace (v_retrace), .vh_retrace (vh_retrace) ); vga_cpu_mem_iface cpu_mem_iface ( .wb_clk_i (wb_clk_i), .wb_rst_i (wb_rst_i), .wbs_adr_i (wb_adr_i), .wbs_sel_i (wb_sel_i), .wbs_we_i (wb_we_i), .wbs_dat_i (wb_dat_i), .wbs_dat_o (mem_wb_dat_o), .wbs_stb_i (stb & !wb_tga_i), .wbs_ack_o (mem_wb_ack_o), .wbm_adr_o (wbm_adr_o), .wbm_sel_o (wbm_sel_o), .wbm_we_o (wbm_we_o), .wbm_dat_o (wbm_dat_o), .wbm_dat_i (wbm_dat_i), .wbm_stb_o (wbm_stb_o), .wbm_ack_i (wbm_ack_i), .chain_four (chain_four), .memory_mapping1 (memory_mapping1), .write_mode (write_mode), .raster_op (raster_op), .read_mode (read_mode), .bitmask (bitmask), .set_reset (set_reset), .enable_set_reset (enable_set_reset), .map_mask (map_mask), .read_map_select (read_map_select), .color_compare (color_compare), .color_dont_care (color_dont_care) ); vga_mem_arbitrer mem_arbitrer ( .clk_i (wb_clk_i), .rst_i (wb_rst_i), .wb_adr_i (wbm_adr_o), .wb_sel_i (wbm_sel_o), .wb_we_i (wbm_we_o), .wb_dat_i (wbm_dat_o), .wb_dat_o (wbm_dat_i), .wb_stb_i (wbm_stb_o), .wb_ack_o (wbm_ack_i), .csr_adr_i (csr_adr_i), .csr_dat_o (csr_dat_i), .csr_stb_i (csr_stb_i), .csrm_adr_o (csrm_adr_o), .csrm_sel_o (csrm_sel_o), .csrm_we_o (csrm_we_o), .csrm_dat_o (csrm_dat_o), .csrm_dat_i (csrm_dat_i) ); // Continous assignments assign wb_dat_o = wb_tga_i ? conf_wb_dat_o : mem_wb_dat_o; assign wb_ack_o = wb_tga_i ? conf_wb_ack_o : mem_wb_ack_o; assign stb = wb_stb_i & wb_cyc_i; assign vert_sync = ~graphics_alpha ^ w_vert_sync; // Behaviour // csr_adr_i always @(posedge wb_clk_i) csr_adr_i <= wb_rst_i ? 17'h0 : csr_adr_o + start_addr[15:1]; // csr_stb_i always @(posedge wb_clk_i) csr_stb_i <= wb_rst_i ? 1'b0 : csr_stb_o; endmodule
/* * VGA top level file * Copyright (C) 2010 Zeus Gomez Marmolejo <[email protected]> * * This file is part of the Zet processor. This processor is free * hardware; you can redistribute it and/or modify it under the terms of * the GNU General Public License as published by the Free Software * Foundation; either version 3, or (at your option) any later version. * * Zet is distrubuted in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public * License for more details. * * You should have received a copy of the GNU General Public License * along with Zet; see the file COPYING. If not, see * <http://www.gnu.org/licenses/>. */ module vga ( // Wishbone signals input wb_clk_i, // 25 Mhz VDU clock input wb_rst_i, input [15:0] wb_dat_i, output [15:0] wb_dat_o, input [16:1] wb_adr_i, input wb_we_i, input wb_tga_i, input [ 1:0] wb_sel_i, input wb_stb_i, input wb_cyc_i, output wb_ack_o, // VGA pad signals output [ 3:0] vga_red_o, output [ 3:0] vga_green_o, output [ 3:0] vga_blue_o, output horiz_sync, output vert_sync, // CSR SRAM master interface output [17:1] csrm_adr_o, output [ 1:0] csrm_sel_o, output csrm_we_o, output [15:0] csrm_dat_o, input [15:0] csrm_dat_i ); // Registers and nets // // csr address reg [17:1] csr_adr_i; reg csr_stb_i; // Config wires wire [15:0] conf_wb_dat_o; wire conf_wb_ack_o; // Mem wires wire [15:0] mem_wb_dat_o; wire mem_wb_ack_o; // LCD wires wire [17:1] csr_adr_o; wire [15:0] csr_dat_i; wire csr_stb_o; wire v_retrace; wire vh_retrace; wire w_vert_sync; // VGA configuration registers wire shift_reg1; wire graphics_alpha; wire memory_mapping1; wire [ 1:0] write_mode; wire [ 1:0] raster_op; wire read_mode; wire [ 7:0] bitmask; wire [ 3:0] set_reset; wire [ 3:0] enable_set_reset; wire [ 3:0] map_mask; wire x_dotclockdiv2; wire chain_four; wire [ 1:0] read_map_select; wire [ 3:0] color_compare; wire [ 3:0] color_dont_care; // Wishbone master to SRAM wire [17:1] wbm_adr_o; wire [ 1:0] wbm_sel_o; wire wbm_we_o; wire [15:0] wbm_dat_o; wire [15:0] wbm_dat_i; wire wbm_stb_o; wire wbm_ack_i; wire stb; // CRT wires wire [ 5:0] cur_start; wire [ 5:0] cur_end; wire [15:0] start_addr; wire [ 4:0] vcursor; wire [ 6:0] hcursor; wire [ 6:0] horiz_total; wire [ 6:0] end_horiz; wire [ 6:0] st_hor_retr; wire [ 4:0] end_hor_retr; wire [ 9:0] vert_total; wire [ 9:0] end_vert; wire [ 9:0] st_ver_retr; wire [ 3:0] end_ver_retr; // attribute_ctrl wires wire [3:0] pal_addr; wire pal_we; wire [7:0] pal_read; wire [7:0] pal_write; // dac_regs wires wire dac_we; wire [1:0] dac_read_data_cycle; wire [7:0] dac_read_data_register; wire [3:0] dac_read_data; wire [1:0] dac_write_data_cycle; wire [7:0] dac_write_data_register; wire [3:0] dac_write_data; // Module instances // vga_config_iface config_iface ( .wb_clk_i (wb_clk_i), .wb_rst_i (wb_rst_i), .wb_dat_i (wb_dat_i), .wb_dat_o (conf_wb_dat_o), .wb_adr_i (wb_adr_i[4:1]), .wb_we_i (wb_we_i), .wb_sel_i (wb_sel_i), .wb_stb_i (stb & wb_tga_i), .wb_ack_o (conf_wb_ack_o), .shift_reg1 (shift_reg1), .graphics_alpha (graphics_alpha), .memory_mapping1 (memory_mapping1), .write_mode (write_mode), .raster_op (raster_op), .read_mode (read_mode), .bitmask (bitmask), .set_reset (set_reset), .enable_set_reset (enable_set_reset), .map_mask (map_mask), .x_dotclockdiv2 (x_dotclockdiv2), .chain_four (chain_four), .read_map_select (read_map_select), .color_compare (color_compare), .color_dont_care (color_dont_care), .pal_addr (pal_addr), .pal_we (pal_we), .pal_read (pal_read), .pal_write (pal_write), .dac_we (dac_we), .dac_read_data_cycle (dac_read_data_cycle), .dac_read_data_register (dac_read_data_register), .dac_read_data (dac_read_data), .dac_write_data_cycle (dac_write_data_cycle), .dac_write_data_register (dac_write_data_register), .dac_write_data (dac_write_data), .cur_start (cur_start), .cur_end (cur_end), .start_addr (start_addr), .vcursor (vcursor), .hcursor (hcursor), .horiz_total (horiz_total), .end_horiz (end_horiz), .st_hor_retr (st_hor_retr), .end_hor_retr (end_hor_retr), .vert_total (vert_total), .end_vert (end_vert), .st_ver_retr (st_ver_retr), .end_ver_retr (end_ver_retr), .v_retrace (v_retrace), .vh_retrace (vh_retrace) ); vga_lcd lcd ( .clk (wb_clk_i), .rst (wb_rst_i), .shift_reg1 (shift_reg1), .graphics_alpha (graphics_alpha), .pal_addr (pal_addr), .pal_we (pal_we), .pal_read (pal_read), .pal_write (pal_write), .dac_we (dac_we), .dac_read_data_cycle (dac_read_data_cycle), .dac_read_data_register (dac_read_data_register), .dac_read_data (dac_read_data), .dac_write_data_cycle (dac_write_data_cycle), .dac_write_data_register (dac_write_data_register), .dac_write_data (dac_write_data), .csr_adr_o (csr_adr_o), .csr_dat_i (csr_dat_i), .csr_stb_o (csr_stb_o), .vga_red_o (vga_red_o), .vga_green_o (vga_green_o), .vga_blue_o (vga_blue_o), .horiz_sync (horiz_sync), .vert_sync (w_vert_sync), .cur_start (cur_start), .cur_end (cur_end), .vcursor (vcursor), .hcursor (hcursor), .horiz_total (horiz_total), .end_horiz (end_horiz), .st_hor_retr (st_hor_retr), .end_hor_retr (end_hor_retr), .vert_total (vert_total), .end_vert (end_vert), .st_ver_retr (st_ver_retr), .end_ver_retr (end_ver_retr), .x_dotclockdiv2 (x_dotclockdiv2), .v_retrace (v_retrace), .vh_retrace (vh_retrace) ); vga_cpu_mem_iface cpu_mem_iface ( .wb_clk_i (wb_clk_i), .wb_rst_i (wb_rst_i), .wbs_adr_i (wb_adr_i), .wbs_sel_i (wb_sel_i), .wbs_we_i (wb_we_i), .wbs_dat_i (wb_dat_i), .wbs_dat_o (mem_wb_dat_o), .wbs_stb_i (stb & !wb_tga_i), .wbs_ack_o (mem_wb_ack_o), .wbm_adr_o (wbm_adr_o), .wbm_sel_o (wbm_sel_o), .wbm_we_o (wbm_we_o), .wbm_dat_o (wbm_dat_o), .wbm_dat_i (wbm_dat_i), .wbm_stb_o (wbm_stb_o), .wbm_ack_i (wbm_ack_i), .chain_four (chain_four), .memory_mapping1 (memory_mapping1), .write_mode (write_mode), .raster_op (raster_op), .read_mode (read_mode), .bitmask (bitmask), .set_reset (set_reset), .enable_set_reset (enable_set_reset), .map_mask (map_mask), .read_map_select (read_map_select), .color_compare (color_compare), .color_dont_care (color_dont_care) ); vga_mem_arbitrer mem_arbitrer ( .clk_i (wb_clk_i), .rst_i (wb_rst_i), .wb_adr_i (wbm_adr_o), .wb_sel_i (wbm_sel_o), .wb_we_i (wbm_we_o), .wb_dat_i (wbm_dat_o), .wb_dat_o (wbm_dat_i), .wb_stb_i (wbm_stb_o), .wb_ack_o (wbm_ack_i), .csr_adr_i (csr_adr_i), .csr_dat_o (csr_dat_i), .csr_stb_i (csr_stb_i), .csrm_adr_o (csrm_adr_o), .csrm_sel_o (csrm_sel_o), .csrm_we_o (csrm_we_o), .csrm_dat_o (csrm_dat_o), .csrm_dat_i (csrm_dat_i) ); // Continous assignments assign wb_dat_o = wb_tga_i ? conf_wb_dat_o : mem_wb_dat_o; assign wb_ack_o = wb_tga_i ? conf_wb_ack_o : mem_wb_ack_o; assign stb = wb_stb_i & wb_cyc_i; assign vert_sync = ~graphics_alpha ^ w_vert_sync; // Behaviour // csr_adr_i always @(posedge wb_clk_i) csr_adr_i <= wb_rst_i ? 17'h0 : csr_adr_o + start_addr[15:1]; // csr_stb_i always @(posedge wb_clk_i) csr_stb_i <= wb_rst_i ? 1'b0 : csr_stb_o; endmodule
// This is a component of pluto_servo, a PWM servo driver and quadrature // counter for emc2 // Copyright 2006 Jeff Epler <[email protected]> // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA module main(clk, led, nConfig, epp_nReset, pport_data, nWrite, nWait, nDataStr, nAddrStr, dout, din, step, dir); parameter W=10; parameter F=11; parameter T=4; input clk; output led, nConfig; inout [7:0] pport_data; input nWrite; output nWait; input nDataStr, nAddrStr, epp_nReset; input [15:0] din; reg Spolarity; reg[13:0] real_dout; output [13:0] dout = do_tristate ? 14'bZ : real_dout; wire[3:0] real_step; output [3:0] step = do_tristate ? 4'bZ : real_step ^ {4{Spolarity}}; wire[3:0] real_dir; output [3:0] dir = do_tristate ? 4'bZ : real_dir; wire [W+F-1:0] pos0, pos1, pos2, pos3; reg [F:0] vel0, vel1, vel2, vel3; reg [T-1:0] dirtime, steptime; reg [1:0] tap; reg [10:0] div2048; wire stepcnt = ~|(div2048[5:0]); always @(posedge clk) begin div2048 <= div2048 + 1'd1; end wire do_enable_wdt, do_tristate; wdt w(clk, do_enable_wdt, &div2048, do_tristate); stepgen #(W,F,T) s0(clk, stepcnt, pos0, vel0, dirtime, steptime, real_step[0], real_dir[0], tap); stepgen #(W,F,T) s1(clk, stepcnt, pos1, vel1, dirtime, steptime, real_step[1], real_dir[1], tap); stepgen #(W,F,T) s2(clk, stepcnt, pos2, vel2, dirtime, steptime, real_step[2], real_dir[2], tap); stepgen #(W,F,T) s3(clk, stepcnt, pos3, vel3, dirtime, steptime, real_step[3], real_dir[3], tap); // EPP stuff wire EPP_write = ~nWrite; wire EPP_read = nWrite; wire EPP_addr_strobe = ~nAddrStr; wire EPP_data_strobe = ~nDataStr; wire EPP_strobe = EPP_data_strobe | EPP_addr_strobe; wire EPP_wait; assign nWait = ~EPP_wait; wire [7:0] EPP_datain = pport_data; wire [7:0] EPP_dataout; assign pport_data = EPP_dataout; reg [4:0] EPP_strobe_reg; always @(posedge clk) EPP_strobe_reg <= {EPP_strobe_reg[3:0], EPP_strobe}; wire EPP_strobe_edge1 = (EPP_strobe_reg[2:1]==2'b01); // reg led; assign EPP_wait = EPP_strobe_reg[4]; wire[15:0] EPP_dataword = {EPP_datain, lowbyte}; reg[4:0] addr_reg; reg[7:0] lowbyte; always @(posedge clk) if(EPP_strobe_edge1 & EPP_write & EPP_addr_strobe) begin addr_reg <= EPP_datain[4:0]; end else if(EPP_strobe_edge1 & !EPP_addr_strobe) addr_reg <= addr_reg + 4'd1; always @(posedge clk) begin if(EPP_strobe_edge1 & EPP_write & EPP_data_strobe) begin if(addr_reg[3:0] == 4'd1) vel0 <= EPP_dataword[F:0]; else if(addr_reg[3:0] == 4'd3) vel1 <= EPP_dataword[F:0]; else if(addr_reg[3:0] == 4'd5) vel2 <= EPP_dataword[F:0]; else if(addr_reg[3:0] == 4'd7) vel3 <= EPP_dataword[F:0]; else if(addr_reg[3:0] == 4'd9) begin real_dout <= { EPP_datain[5:0], lowbyte }; end else if(addr_reg[3:0] == 4'd11) begin tap <= lowbyte[7:6]; steptime <= lowbyte[T-1:0]; Spolarity <= EPP_datain[7]; // EPP_datain[6] is do_enable_wdt dirtime <= EPP_datain[T-1:0]; end else lowbyte <= EPP_datain; end end reg [31:0] data_buf; always @(posedge clk) begin if(EPP_strobe_edge1 & EPP_read && addr_reg[1:0] == 2'd0) begin if(addr_reg[4:2] == 3'd0) data_buf <= pos0; else if(addr_reg[4:2] == 3'd1) data_buf <= pos1; else if(addr_reg[4:2] == 3'd2) data_buf <= pos2; else if(addr_reg[4:2] == 3'd3) data_buf <= pos3; else if(addr_reg[4:2] == 3'd4) data_buf <= din; end end // the addr_reg test looks funny because it is auto-incremented in an always // block so "1" reads the low byte, "2 and "3" read middle bytes, and "0" // reads the high byte I have a feeling that I'm doing this in the wrong way. wire [7:0] data_reg = addr_reg[1:0] == 2'd1 ? data_buf[7:0] : (addr_reg[1:0] == 2'd2 ? data_buf[15:8] : (addr_reg[1:0] == 2'd3 ? data_buf[23:16] : data_buf[31:24])); wire [7:0] EPP_data_mux = data_reg; assign EPP_dataout = (EPP_read & EPP_wait) ? EPP_data_mux : 8'hZZ; // assign do_enable_wdt = EPP_strobe_edge1 & EPP_write & EPP_data_strobe & (addr_reg[3:0] == 4'd9) & EPP_datain[6]; // assign led = do_tristate ? 1'BZ : (real_step[0] ^ real_dir[0]); assign led = do_tristate ? 1'bZ : (real_step[0] ^ real_dir[0]); assign nConfig = epp_nReset; // 1'b1; assign do_enable_wdt = EPP_strobe_edge1 & EPP_write & EPP_data_strobe & (addr_reg[3:0] == 4'd9) & EPP_datain[6]; endmodule
/////////////////////////////////////////////////////////////////////////////// // // File name: axi_protocol_converter_v2_1_b2s_rd_cmd_fsm.v // /////////////////////////////////////////////////////////////////////////////// `timescale 1ps/1ps `default_nettype none (* DowngradeIPIdentifiedWarnings="yes" *) module axi_protocol_converter_v2_1_b2s_rd_cmd_fsm ( /////////////////////////////////////////////////////////////////////////////// // Port Declarations /////////////////////////////////////////////////////////////////////////////// input wire clk , input wire reset , output wire s_arready , input wire s_arvalid , input wire [7:0] s_arlen , output wire m_arvalid , input wire m_arready , // signal to increment to the next mc transaction output wire next , // signal to the fsm there is another transaction required input wire next_pending , // Write Data portion has completed or Read FIFO has a slot available (not // full) input wire data_ready , // status signal for w_channel when command is written. output wire a_push , output wire r_push ); //////////////////////////////////////////////////////////////////////////////// // Local parameters //////////////////////////////////////////////////////////////////////////////// // States localparam SM_IDLE = 2'b00; localparam SM_CMD_EN = 2'b01; localparam SM_CMD_ACCEPTED = 2'b10; localparam SM_DONE = 2'b11; //////////////////////////////////////////////////////////////////////////////// // Wires/Reg declarations //////////////////////////////////////////////////////////////////////////////// reg [1:0] state; // synthesis attribute MAX_FANOUT of state is 20; reg [1:0] state_r1; reg [1:0] next_state; reg [7:0] s_arlen_r; //////////////////////////////////////////////////////////////////////////////// // BEGIN RTL /////////////////////////////////////////////////////////////////////////////// // register for timing always @(posedge clk) begin if (reset) begin state <= SM_IDLE; state_r1 <= SM_IDLE; s_arlen_r <= 0; end else begin state <= next_state; state_r1 <= state; s_arlen_r <= s_arlen; end end // Next state transitions. always @( * ) begin next_state = state; case (state) SM_IDLE: if (s_arvalid & data_ready) begin next_state = SM_CMD_EN; end else begin next_state = state; end SM_CMD_EN: /////////////////////////////////////////////////////////////////// // Drive m_arvalid downstream in this state /////////////////////////////////////////////////////////////////// //If there is no fifo space if (~data_ready & m_arready & next_pending) begin /////////////////////////////////////////////////////////////////// //There is more to do, wait until data space is available drop valid next_state = SM_CMD_ACCEPTED; end else if (m_arready & ~next_pending)begin next_state = SM_DONE; end else if (m_arready & next_pending) begin next_state = SM_CMD_EN; end else begin next_state = state; end SM_CMD_ACCEPTED: if (data_ready) begin next_state = SM_CMD_EN; end else begin next_state = state; end SM_DONE: next_state = SM_IDLE; default: next_state = SM_IDLE; endcase end // Assign outputs based on current state. assign m_arvalid = (state == SM_CMD_EN); assign next = m_arready && (state == SM_CMD_EN); assign r_push = next; assign a_push = (state == SM_IDLE); assign s_arready = ((state == SM_CMD_EN) || (state == SM_DONE)) && (next_state == SM_IDLE); endmodule `default_nettype wire
/////////////////////////////////////////////////////////////////////////////// // // File name: axi_protocol_converter_v2_1_b2s_rd_cmd_fsm.v // /////////////////////////////////////////////////////////////////////////////// `timescale 1ps/1ps `default_nettype none (* DowngradeIPIdentifiedWarnings="yes" *) module axi_protocol_converter_v2_1_b2s_rd_cmd_fsm ( /////////////////////////////////////////////////////////////////////////////// // Port Declarations /////////////////////////////////////////////////////////////////////////////// input wire clk , input wire reset , output wire s_arready , input wire s_arvalid , input wire [7:0] s_arlen , output wire m_arvalid , input wire m_arready , // signal to increment to the next mc transaction output wire next , // signal to the fsm there is another transaction required input wire next_pending , // Write Data portion has completed or Read FIFO has a slot available (not // full) input wire data_ready , // status signal for w_channel when command is written. output wire a_push , output wire r_push ); //////////////////////////////////////////////////////////////////////////////// // Local parameters //////////////////////////////////////////////////////////////////////////////// // States localparam SM_IDLE = 2'b00; localparam SM_CMD_EN = 2'b01; localparam SM_CMD_ACCEPTED = 2'b10; localparam SM_DONE = 2'b11; //////////////////////////////////////////////////////////////////////////////// // Wires/Reg declarations //////////////////////////////////////////////////////////////////////////////// reg [1:0] state; // synthesis attribute MAX_FANOUT of state is 20; reg [1:0] state_r1; reg [1:0] next_state; reg [7:0] s_arlen_r; //////////////////////////////////////////////////////////////////////////////// // BEGIN RTL /////////////////////////////////////////////////////////////////////////////// // register for timing always @(posedge clk) begin if (reset) begin state <= SM_IDLE; state_r1 <= SM_IDLE; s_arlen_r <= 0; end else begin state <= next_state; state_r1 <= state; s_arlen_r <= s_arlen; end end // Next state transitions. always @( * ) begin next_state = state; case (state) SM_IDLE: if (s_arvalid & data_ready) begin next_state = SM_CMD_EN; end else begin next_state = state; end SM_CMD_EN: /////////////////////////////////////////////////////////////////// // Drive m_arvalid downstream in this state /////////////////////////////////////////////////////////////////// //If there is no fifo space if (~data_ready & m_arready & next_pending) begin /////////////////////////////////////////////////////////////////// //There is more to do, wait until data space is available drop valid next_state = SM_CMD_ACCEPTED; end else if (m_arready & ~next_pending)begin next_state = SM_DONE; end else if (m_arready & next_pending) begin next_state = SM_CMD_EN; end else begin next_state = state; end SM_CMD_ACCEPTED: if (data_ready) begin next_state = SM_CMD_EN; end else begin next_state = state; end SM_DONE: next_state = SM_IDLE; default: next_state = SM_IDLE; endcase end // Assign outputs based on current state. assign m_arvalid = (state == SM_CMD_EN); assign next = m_arready && (state == SM_CMD_EN); assign r_push = next; assign a_push = (state == SM_IDLE); assign s_arready = ((state == SM_CMD_EN) || (state == SM_DONE)) && (next_state == SM_IDLE); endmodule `default_nettype wire
/////////////////////////////////////////////////////////////////////////////// // // File name: axi_protocol_converter_v2_1_b2s_rd_cmd_fsm.v // /////////////////////////////////////////////////////////////////////////////// `timescale 1ps/1ps `default_nettype none (* DowngradeIPIdentifiedWarnings="yes" *) module axi_protocol_converter_v2_1_b2s_rd_cmd_fsm ( /////////////////////////////////////////////////////////////////////////////// // Port Declarations /////////////////////////////////////////////////////////////////////////////// input wire clk , input wire reset , output wire s_arready , input wire s_arvalid , input wire [7:0] s_arlen , output wire m_arvalid , input wire m_arready , // signal to increment to the next mc transaction output wire next , // signal to the fsm there is another transaction required input wire next_pending , // Write Data portion has completed or Read FIFO has a slot available (not // full) input wire data_ready , // status signal for w_channel when command is written. output wire a_push , output wire r_push ); //////////////////////////////////////////////////////////////////////////////// // Local parameters //////////////////////////////////////////////////////////////////////////////// // States localparam SM_IDLE = 2'b00; localparam SM_CMD_EN = 2'b01; localparam SM_CMD_ACCEPTED = 2'b10; localparam SM_DONE = 2'b11; //////////////////////////////////////////////////////////////////////////////// // Wires/Reg declarations //////////////////////////////////////////////////////////////////////////////// reg [1:0] state; // synthesis attribute MAX_FANOUT of state is 20; reg [1:0] state_r1; reg [1:0] next_state; reg [7:0] s_arlen_r; //////////////////////////////////////////////////////////////////////////////// // BEGIN RTL /////////////////////////////////////////////////////////////////////////////// // register for timing always @(posedge clk) begin if (reset) begin state <= SM_IDLE; state_r1 <= SM_IDLE; s_arlen_r <= 0; end else begin state <= next_state; state_r1 <= state; s_arlen_r <= s_arlen; end end // Next state transitions. always @( * ) begin next_state = state; case (state) SM_IDLE: if (s_arvalid & data_ready) begin next_state = SM_CMD_EN; end else begin next_state = state; end SM_CMD_EN: /////////////////////////////////////////////////////////////////// // Drive m_arvalid downstream in this state /////////////////////////////////////////////////////////////////// //If there is no fifo space if (~data_ready & m_arready & next_pending) begin /////////////////////////////////////////////////////////////////// //There is more to do, wait until data space is available drop valid next_state = SM_CMD_ACCEPTED; end else if (m_arready & ~next_pending)begin next_state = SM_DONE; end else if (m_arready & next_pending) begin next_state = SM_CMD_EN; end else begin next_state = state; end SM_CMD_ACCEPTED: if (data_ready) begin next_state = SM_CMD_EN; end else begin next_state = state; end SM_DONE: next_state = SM_IDLE; default: next_state = SM_IDLE; endcase end // Assign outputs based on current state. assign m_arvalid = (state == SM_CMD_EN); assign next = m_arready && (state == SM_CMD_EN); assign r_push = next; assign a_push = (state == SM_IDLE); assign s_arready = ((state == SM_CMD_EN) || (state == SM_DONE)) && (next_state == SM_IDLE); endmodule `default_nettype wire
/////////////////////////////////////////////////////////////////////////////// // // File name: axi_protocol_converter_v2_1_b2s_rd_cmd_fsm.v // /////////////////////////////////////////////////////////////////////////////// `timescale 1ps/1ps `default_nettype none (* DowngradeIPIdentifiedWarnings="yes" *) module axi_protocol_converter_v2_1_b2s_rd_cmd_fsm ( /////////////////////////////////////////////////////////////////////////////// // Port Declarations /////////////////////////////////////////////////////////////////////////////// input wire clk , input wire reset , output wire s_arready , input wire s_arvalid , input wire [7:0] s_arlen , output wire m_arvalid , input wire m_arready , // signal to increment to the next mc transaction output wire next , // signal to the fsm there is another transaction required input wire next_pending , // Write Data portion has completed or Read FIFO has a slot available (not // full) input wire data_ready , // status signal for w_channel when command is written. output wire a_push , output wire r_push ); //////////////////////////////////////////////////////////////////////////////// // Local parameters //////////////////////////////////////////////////////////////////////////////// // States localparam SM_IDLE = 2'b00; localparam SM_CMD_EN = 2'b01; localparam SM_CMD_ACCEPTED = 2'b10; localparam SM_DONE = 2'b11; //////////////////////////////////////////////////////////////////////////////// // Wires/Reg declarations //////////////////////////////////////////////////////////////////////////////// reg [1:0] state; // synthesis attribute MAX_FANOUT of state is 20; reg [1:0] state_r1; reg [1:0] next_state; reg [7:0] s_arlen_r; //////////////////////////////////////////////////////////////////////////////// // BEGIN RTL /////////////////////////////////////////////////////////////////////////////// // register for timing always @(posedge clk) begin if (reset) begin state <= SM_IDLE; state_r1 <= SM_IDLE; s_arlen_r <= 0; end else begin state <= next_state; state_r1 <= state; s_arlen_r <= s_arlen; end end // Next state transitions. always @( * ) begin next_state = state; case (state) SM_IDLE: if (s_arvalid & data_ready) begin next_state = SM_CMD_EN; end else begin next_state = state; end SM_CMD_EN: /////////////////////////////////////////////////////////////////// // Drive m_arvalid downstream in this state /////////////////////////////////////////////////////////////////// //If there is no fifo space if (~data_ready & m_arready & next_pending) begin /////////////////////////////////////////////////////////////////// //There is more to do, wait until data space is available drop valid next_state = SM_CMD_ACCEPTED; end else if (m_arready & ~next_pending)begin next_state = SM_DONE; end else if (m_arready & next_pending) begin next_state = SM_CMD_EN; end else begin next_state = state; end SM_CMD_ACCEPTED: if (data_ready) begin next_state = SM_CMD_EN; end else begin next_state = state; end SM_DONE: next_state = SM_IDLE; default: next_state = SM_IDLE; endcase end // Assign outputs based on current state. assign m_arvalid = (state == SM_CMD_EN); assign next = m_arready && (state == SM_CMD_EN); assign r_push = next; assign a_push = (state == SM_IDLE); assign s_arready = ((state == SM_CMD_EN) || (state == SM_DONE)) && (next_state == SM_IDLE); endmodule `default_nettype wire
/////////////////////////////////////////////////////////////////////////////// // // File name: axi_protocol_converter_v2_1_b2s_rd_cmd_fsm.v // /////////////////////////////////////////////////////////////////////////////// `timescale 1ps/1ps `default_nettype none (* DowngradeIPIdentifiedWarnings="yes" *) module axi_protocol_converter_v2_1_b2s_rd_cmd_fsm ( /////////////////////////////////////////////////////////////////////////////// // Port Declarations /////////////////////////////////////////////////////////////////////////////// input wire clk , input wire reset , output wire s_arready , input wire s_arvalid , input wire [7:0] s_arlen , output wire m_arvalid , input wire m_arready , // signal to increment to the next mc transaction output wire next , // signal to the fsm there is another transaction required input wire next_pending , // Write Data portion has completed or Read FIFO has a slot available (not // full) input wire data_ready , // status signal for w_channel when command is written. output wire a_push , output wire r_push ); //////////////////////////////////////////////////////////////////////////////// // Local parameters //////////////////////////////////////////////////////////////////////////////// // States localparam SM_IDLE = 2'b00; localparam SM_CMD_EN = 2'b01; localparam SM_CMD_ACCEPTED = 2'b10; localparam SM_DONE = 2'b11; //////////////////////////////////////////////////////////////////////////////// // Wires/Reg declarations //////////////////////////////////////////////////////////////////////////////// reg [1:0] state; // synthesis attribute MAX_FANOUT of state is 20; reg [1:0] state_r1; reg [1:0] next_state; reg [7:0] s_arlen_r; //////////////////////////////////////////////////////////////////////////////// // BEGIN RTL /////////////////////////////////////////////////////////////////////////////// // register for timing always @(posedge clk) begin if (reset) begin state <= SM_IDLE; state_r1 <= SM_IDLE; s_arlen_r <= 0; end else begin state <= next_state; state_r1 <= state; s_arlen_r <= s_arlen; end end // Next state transitions. always @( * ) begin next_state = state; case (state) SM_IDLE: if (s_arvalid & data_ready) begin next_state = SM_CMD_EN; end else begin next_state = state; end SM_CMD_EN: /////////////////////////////////////////////////////////////////// // Drive m_arvalid downstream in this state /////////////////////////////////////////////////////////////////// //If there is no fifo space if (~data_ready & m_arready & next_pending) begin /////////////////////////////////////////////////////////////////// //There is more to do, wait until data space is available drop valid next_state = SM_CMD_ACCEPTED; end else if (m_arready & ~next_pending)begin next_state = SM_DONE; end else if (m_arready & next_pending) begin next_state = SM_CMD_EN; end else begin next_state = state; end SM_CMD_ACCEPTED: if (data_ready) begin next_state = SM_CMD_EN; end else begin next_state = state; end SM_DONE: next_state = SM_IDLE; default: next_state = SM_IDLE; endcase end // Assign outputs based on current state. assign m_arvalid = (state == SM_CMD_EN); assign next = m_arready && (state == SM_CMD_EN); assign r_push = next; assign a_push = (state == SM_IDLE); assign s_arready = ((state == SM_CMD_EN) || (state == SM_DONE)) && (next_state == SM_IDLE); endmodule `default_nettype wire
// -*- verilog -*- // // USRP - Universal Software Radio Peripheral // // Copyright (C) 2003 Matt Ettus // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Boston, MA 02110-1301 USA // // DDC block module ddc(input clock, input reset, input enable, input [3:0] rate1, input [3:0] rate2, output strobe, input [31:0] freq, input [15:0] i_in, input [15:0] q_in, output [15:0] i_out, output [15:0] q_out ); parameter bw = 16; parameter zw = 16; wire [15:0] i_cordic_out, q_cordic_out; wire [31:0] phase; wire strobe1, strobe2; reg [3:0] strobe_ctr1,strobe_ctr2; always @(posedge clock) if(reset | ~enable) strobe_ctr2 <= #1 4'd0; else if(strobe2) strobe_ctr2 <= #1 4'd0; else strobe_ctr2 <= #1 strobe_ctr2 + 4'd1; always @(posedge clock) if(reset | ~enable) strobe_ctr1 <= #1 4'd0; else if(strobe1) strobe_ctr1 <= #1 4'd0; else if(strobe2) strobe_ctr1 <= #1 strobe_ctr1 + 4'd1; assign strobe2 = enable & ( strobe_ctr2 == rate2 ); assign strobe1 = strobe2 & ( strobe_ctr1 == rate1 ); assign strobe = strobe1; function [2:0] log_ceil; input [3:0] val; log_ceil = val[3] ? 3'd4 : val[2] ? 3'd3 : val[1] ? 3'd2 : 3'd1; endfunction wire [2:0] shift1 = log_ceil(rate1); wire [2:0] shift2 = log_ceil(rate2); cordic #(.bitwidth(bw),.zwidth(zw),.stages(16)) cordic(.clock(clock), .reset(reset), .enable(enable), .xi(i_in), .yi(q_in), .zi(phase[31:32-zw]), .xo(i_cordic_out), .yo(q_cordic_out), .zo() ); cic_decim_2stage #(.bw(bw),.N(4)) decim_i(.clock(clock),.reset(reset),.enable(enable), .strobe1(1'b1),.strobe2(strobe2),.strobe3(strobe1),.shift1(shift2),.shift2(shift1), .signal_in(i_cordic_out),.signal_out(i_out)); cic_decim_2stage #(.bw(bw),.N(4)) decim_q(.clock(clock),.reset(reset),.enable(enable), .strobe1(1'b1),.strobe2(strobe2),.strobe3(strobe1),.shift1(shift2),.shift2(shift1), .signal_in(q_cordic_out),.signal_out(q_out)); phase_acc #(.resolution(32)) nco (.clk(clock),.reset(reset),.enable(enable), .freq(freq),.phase(phase)); endmodule
`timescale 1ns / 1ps // Copyright (C) 2008 Schuyler Eldridge, Boston University // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. module mux(opA,opB,sum,dsp_sel,out); input [3:0] opA,opB; input [4:0] sum; input [1:0] dsp_sel; output [3:0] out; reg cout; always @ (sum) begin if (sum[4] == 1) cout <= 4'b0001; else cout <= 4'b0000; end reg out; always @(dsp_sel,sum,cout,opB,opA) begin if (dsp_sel == 2'b00) out <= sum[3:0]; else if (dsp_sel == 2'b01) out <= cout; else if (dsp_sel == 2'b10) out <= opB; else if (dsp_sel == 2'b11) out <= opA; end endmodule
`timescale 1ns / 1ps // Copyright (C) 2008 Schuyler Eldridge, Boston University // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. module mux(opA,opB,sum,dsp_sel,out); input [3:0] opA,opB; input [4:0] sum; input [1:0] dsp_sel; output [3:0] out; reg cout; always @ (sum) begin if (sum[4] == 1) cout <= 4'b0001; else cout <= 4'b0000; end reg out; always @(dsp_sel,sum,cout,opB,opA) begin if (dsp_sel == 2'b00) out <= sum[3:0]; else if (dsp_sel == 2'b01) out <= cout; else if (dsp_sel == 2'b10) out <= opB; else if (dsp_sel == 2'b11) out <= opA; end endmodule
`timescale 1ns / 1ps // Copyright (C) 2008 Schuyler Eldridge, Boston University // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. module mux(opA,opB,sum,dsp_sel,out); input [3:0] opA,opB; input [4:0] sum; input [1:0] dsp_sel; output [3:0] out; reg cout; always @ (sum) begin if (sum[4] == 1) cout <= 4'b0001; else cout <= 4'b0000; end reg out; always @(dsp_sel,sum,cout,opB,opA) begin if (dsp_sel == 2'b00) out <= sum[3:0]; else if (dsp_sel == 2'b01) out <= cout; else if (dsp_sel == 2'b10) out <= opB; else if (dsp_sel == 2'b11) out <= opA; end endmodule
`timescale 1ns / 1ps // Copyright (C) 2008 Schuyler Eldridge, Boston University // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. module mux(opA,opB,sum,dsp_sel,out); input [3:0] opA,opB; input [4:0] sum; input [1:0] dsp_sel; output [3:0] out; reg cout; always @ (sum) begin if (sum[4] == 1) cout <= 4'b0001; else cout <= 4'b0000; end reg out; always @(dsp_sel,sum,cout,opB,opA) begin if (dsp_sel == 2'b00) out <= sum[3:0]; else if (dsp_sel == 2'b01) out <= cout; else if (dsp_sel == 2'b10) out <= opB; else if (dsp_sel == 2'b11) out <= opA; end endmodule
`timescale 1ns / 1ps // Copyright (C) 2008 Schuyler Eldridge, Boston University // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. module mux(opA,opB,sum,dsp_sel,out); input [3:0] opA,opB; input [4:0] sum; input [1:0] dsp_sel; output [3:0] out; reg cout; always @ (sum) begin if (sum[4] == 1) cout <= 4'b0001; else cout <= 4'b0000; end reg out; always @(dsp_sel,sum,cout,opB,opA) begin if (dsp_sel == 2'b00) out <= sum[3:0]; else if (dsp_sel == 2'b01) out <= cout; else if (dsp_sel == 2'b10) out <= opB; else if (dsp_sel == 2'b11) out <= opA; end endmodule
`timescale 1ns / 1ps // Copyright (C) 2008 Schuyler Eldridge, Boston University // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. module mux(opA,opB,sum,dsp_sel,out); input [3:0] opA,opB; input [4:0] sum; input [1:0] dsp_sel; output [3:0] out; reg cout; always @ (sum) begin if (sum[4] == 1) cout <= 4'b0001; else cout <= 4'b0000; end reg out; always @(dsp_sel,sum,cout,opB,opA) begin if (dsp_sel == 2'b00) out <= sum[3:0]; else if (dsp_sel == 2'b01) out <= cout; else if (dsp_sel == 2'b10) out <= opB; else if (dsp_sel == 2'b11) out <= opA; end endmodule
`timescale 1ns / 1ps // Copyright (C) 2008 Schuyler Eldridge, Boston University // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. module mux(opA,opB,sum,dsp_sel,out); input [3:0] opA,opB; input [4:0] sum; input [1:0] dsp_sel; output [3:0] out; reg cout; always @ (sum) begin if (sum[4] == 1) cout <= 4'b0001; else cout <= 4'b0000; end reg out; always @(dsp_sel,sum,cout,opB,opA) begin if (dsp_sel == 2'b00) out <= sum[3:0]; else if (dsp_sel == 2'b01) out <= cout; else if (dsp_sel == 2'b10) out <= opB; else if (dsp_sel == 2'b11) out <= opA; end endmodule
`timescale 1ns / 1ps // Copyright (C) 2008 Schuyler Eldridge, Boston University // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. module mux(opA,opB,sum,dsp_sel,out); input [3:0] opA,opB; input [4:0] sum; input [1:0] dsp_sel; output [3:0] out; reg cout; always @ (sum) begin if (sum[4] == 1) cout <= 4'b0001; else cout <= 4'b0000; end reg out; always @(dsp_sel,sum,cout,opB,opA) begin if (dsp_sel == 2'b00) out <= sum[3:0]; else if (dsp_sel == 2'b01) out <= cout; else if (dsp_sel == 2'b10) out <= opB; else if (dsp_sel == 2'b11) out <= opA; end endmodule
`timescale 1ns / 1ps // Copyright (C) 2008 Schuyler Eldridge, Boston University // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. module mux(opA,opB,sum,dsp_sel,out); input [3:0] opA,opB; input [4:0] sum; input [1:0] dsp_sel; output [3:0] out; reg cout; always @ (sum) begin if (sum[4] == 1) cout <= 4'b0001; else cout <= 4'b0000; end reg out; always @(dsp_sel,sum,cout,opB,opA) begin if (dsp_sel == 2'b00) out <= sum[3:0]; else if (dsp_sel == 2'b01) out <= cout; else if (dsp_sel == 2'b10) out <= opB; else if (dsp_sel == 2'b11) out <= opA; end endmodule
`timescale 1ns / 1ps // Copyright (C) 2008 Schuyler Eldridge, Boston University // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. module mux(opA,opB,sum,dsp_sel,out); input [3:0] opA,opB; input [4:0] sum; input [1:0] dsp_sel; output [3:0] out; reg cout; always @ (sum) begin if (sum[4] == 1) cout <= 4'b0001; else cout <= 4'b0000; end reg out; always @(dsp_sel,sum,cout,opB,opA) begin if (dsp_sel == 2'b00) out <= sum[3:0]; else if (dsp_sel == 2'b01) out <= cout; else if (dsp_sel == 2'b10) out <= opB; else if (dsp_sel == 2'b11) out <= opA; end endmodule
`timescale 1ns / 1ps // Copyright (C) 2008 Schuyler Eldridge, Boston University // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. module mux(opA,opB,sum,dsp_sel,out); input [3:0] opA,opB; input [4:0] sum; input [1:0] dsp_sel; output [3:0] out; reg cout; always @ (sum) begin if (sum[4] == 1) cout <= 4'b0001; else cout <= 4'b0000; end reg out; always @(dsp_sel,sum,cout,opB,opA) begin if (dsp_sel == 2'b00) out <= sum[3:0]; else if (dsp_sel == 2'b01) out <= cout; else if (dsp_sel == 2'b10) out <= opB; else if (dsp_sel == 2'b11) out <= opA; end endmodule
`timescale 1ns / 1ps // Copyright (C) 2008 Schuyler Eldridge, Boston University // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. module mux(opA,opB,sum,dsp_sel,out); input [3:0] opA,opB; input [4:0] sum; input [1:0] dsp_sel; output [3:0] out; reg cout; always @ (sum) begin if (sum[4] == 1) cout <= 4'b0001; else cout <= 4'b0000; end reg out; always @(dsp_sel,sum,cout,opB,opA) begin if (dsp_sel == 2'b00) out <= sum[3:0]; else if (dsp_sel == 2'b01) out <= cout; else if (dsp_sel == 2'b10) out <= opB; else if (dsp_sel == 2'b11) out <= opA; end endmodule
`timescale 1ns / 1ps // Copyright (C) 2008 Schuyler Eldridge, Boston University // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. module mux(opA,opB,sum,dsp_sel,out); input [3:0] opA,opB; input [4:0] sum; input [1:0] dsp_sel; output [3:0] out; reg cout; always @ (sum) begin if (sum[4] == 1) cout <= 4'b0001; else cout <= 4'b0000; end reg out; always @(dsp_sel,sum,cout,opB,opA) begin if (dsp_sel == 2'b00) out <= sum[3:0]; else if (dsp_sel == 2'b01) out <= cout; else if (dsp_sel == 2'b10) out <= opB; else if (dsp_sel == 2'b11) out <= opA; end endmodule
`timescale 1ns / 1ps // Copyright (C) 2008 Schuyler Eldridge, Boston University // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. module mux(opA,opB,sum,dsp_sel,out); input [3:0] opA,opB; input [4:0] sum; input [1:0] dsp_sel; output [3:0] out; reg cout; always @ (sum) begin if (sum[4] == 1) cout <= 4'b0001; else cout <= 4'b0000; end reg out; always @(dsp_sel,sum,cout,opB,opA) begin if (dsp_sel == 2'b00) out <= sum[3:0]; else if (dsp_sel == 2'b01) out <= cout; else if (dsp_sel == 2'b10) out <= opB; else if (dsp_sel == 2'b11) out <= opA; end endmodule
`timescale 1ns / 1ps // Copyright (C) 2008 Schuyler Eldridge, Boston University // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. module mux(opA,opB,sum,dsp_sel,out); input [3:0] opA,opB; input [4:0] sum; input [1:0] dsp_sel; output [3:0] out; reg cout; always @ (sum) begin if (sum[4] == 1) cout <= 4'b0001; else cout <= 4'b0000; end reg out; always @(dsp_sel,sum,cout,opB,opA) begin if (dsp_sel == 2'b00) out <= sum[3:0]; else if (dsp_sel == 2'b01) out <= cout; else if (dsp_sel == 2'b10) out <= opB; else if (dsp_sel == 2'b11) out <= opA; end endmodule
`timescale 1ns / 1ps // Copyright (C) 2008 Schuyler Eldridge, Boston University // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. module mux(opA,opB,sum,dsp_sel,out); input [3:0] opA,opB; input [4:0] sum; input [1:0] dsp_sel; output [3:0] out; reg cout; always @ (sum) begin if (sum[4] == 1) cout <= 4'b0001; else cout <= 4'b0000; end reg out; always @(dsp_sel,sum,cout,opB,opA) begin if (dsp_sel == 2'b00) out <= sum[3:0]; else if (dsp_sel == 2'b01) out <= cout; else if (dsp_sel == 2'b10) out <= opB; else if (dsp_sel == 2'b11) out <= opA; end endmodule
`timescale 1ns / 1ps // Copyright (C) 2008 Schuyler Eldridge, Boston University // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. module mux(opA,opB,sum,dsp_sel,out); input [3:0] opA,opB; input [4:0] sum; input [1:0] dsp_sel; output [3:0] out; reg cout; always @ (sum) begin if (sum[4] == 1) cout <= 4'b0001; else cout <= 4'b0000; end reg out; always @(dsp_sel,sum,cout,opB,opA) begin if (dsp_sel == 2'b00) out <= sum[3:0]; else if (dsp_sel == 2'b01) out <= cout; else if (dsp_sel == 2'b10) out <= opB; else if (dsp_sel == 2'b11) out <= opA; end endmodule
`timescale 1ns / 1ps // Copyright (C) 2008 Schuyler Eldridge, Boston University // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. module mux(opA,opB,sum,dsp_sel,out); input [3:0] opA,opB; input [4:0] sum; input [1:0] dsp_sel; output [3:0] out; reg cout; always @ (sum) begin if (sum[4] == 1) cout <= 4'b0001; else cout <= 4'b0000; end reg out; always @(dsp_sel,sum,cout,opB,opA) begin if (dsp_sel == 2'b00) out <= sum[3:0]; else if (dsp_sel == 2'b01) out <= cout; else if (dsp_sel == 2'b10) out <= opB; else if (dsp_sel == 2'b11) out <= opA; end endmodule
`timescale 1ns / 1ps // Copyright (C) 2008 Schuyler Eldridge, Boston University // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. module mux(opA,opB,sum,dsp_sel,out); input [3:0] opA,opB; input [4:0] sum; input [1:0] dsp_sel; output [3:0] out; reg cout; always @ (sum) begin if (sum[4] == 1) cout <= 4'b0001; else cout <= 4'b0000; end reg out; always @(dsp_sel,sum,cout,opB,opA) begin if (dsp_sel == 2'b00) out <= sum[3:0]; else if (dsp_sel == 2'b01) out <= cout; else if (dsp_sel == 2'b10) out <= opB; else if (dsp_sel == 2'b11) out <= opA; end endmodule
// -- (c) Copyright 2010 - 2011 Xilinx, Inc. All rights reserved. // -- // -- This file contains confidential and proprietary information // -- of Xilinx, Inc. and is protected under U.S. and // -- international copyright and other intellectual property // -- laws. // -- // -- DISCLAIMER // -- This disclaimer is not a license and does not grant any // -- rights to the materials distributed herewith. Except as // -- otherwise provided in a valid license issued to you by // -- Xilinx, and to the maximum extent permitted by applicable // -- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND // -- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES // -- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING // -- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- // -- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and // -- (2) Xilinx shall not be liable (whether in contract or tort, // -- including negligence, or under any other theory of // -- liability) for any loss or damage of any kind or nature // -- related to, arising under or in connection with these // -- materials, including for any direct, or any indirect, // -- special, incidental, or consequential loss or damage // -- (including loss of data, profits, goodwill, or any type of // -- loss or damage suffered as a result of any action brought // -- by a third party) even if such damage or loss was // -- reasonably foreseeable or Xilinx had been advised of the // -- possibility of the same. // -- // -- CRITICAL APPLICATIONS // -- Xilinx products are not designed or intended to be fail- // -- safe, or for use in any application requiring fail-safe // -- performance, such as life-support or safety devices or // -- systems, Class III medical devices, nuclear facilities, // -- applications related to the deployment of airbags, or any // -- other applications that could lead to death, personal // -- injury, or severe property or environmental damage // -- (individually and collectively, "Critical // -- Applications"). Customer assumes the sole risk and // -- liability of any use of Xilinx products in Critical // -- Applications, subject only to applicable laws and // -- regulations governing limitations on product liability. // -- // -- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS // -- PART OF THIS FILE AT ALL TIMES. //----------------------------------------------------------------------------- // // Description: Address AXI3 Slave Converter // // // Verilog-standard: Verilog 2001 //-------------------------------------------------------------------------- // // Structure: // a_axi3_conv // axic_fifo // //-------------------------------------------------------------------------- `timescale 1ps/1ps (* DowngradeIPIdentifiedWarnings="yes" *) module axi_protocol_converter_v2_1_a_axi3_conv # ( parameter C_FAMILY = "none", parameter integer C_AXI_ID_WIDTH = 1, parameter integer C_AXI_ADDR_WIDTH = 32, parameter integer C_AXI_DATA_WIDTH = 32, parameter integer C_AXI_SUPPORTS_USER_SIGNALS = 0, parameter integer C_AXI_AUSER_WIDTH = 1, parameter integer C_AXI_CHANNEL = 0, // 0 = AXI AW Channel. // 1 = AXI AR Channel. parameter integer C_SUPPORT_SPLITTING = 1, // Implement transaction splitting logic. // Disabled whan all connected masters are AXI3 and have same or narrower data width. parameter integer C_SUPPORT_BURSTS = 1, // Disabled when all connected masters are AxiLite, // allowing logic to be simplified. parameter integer C_SINGLE_THREAD = 1 // 0 = Ignore ID when propagating transactions (assume all responses are in order). // 1 = Enforce single-threading (one ID at a time) when any outstanding or // requested transaction requires splitting. // While no split is ongoing any new non-split transaction will pass immediately regardless // off ID. // A split transaction will stall if there are multiple ID (non-split) transactions // ongoing, once it has been forwarded only transactions with the same ID is allowed // (split or not) until all ongoing split transactios has been completed. ) ( // System Signals input wire ACLK, input wire ARESET, // Command Interface (W/R) output wire cmd_valid, output wire cmd_split, output wire [C_AXI_ID_WIDTH-1:0] cmd_id, output wire [4-1:0] cmd_length, input wire cmd_ready, // Command Interface (B) output wire cmd_b_valid, output wire cmd_b_split, output wire [4-1:0] cmd_b_repeat, input wire cmd_b_ready, // Slave Interface Write Address Ports input wire [C_AXI_ID_WIDTH-1:0] S_AXI_AID, input wire [C_AXI_ADDR_WIDTH-1:0] S_AXI_AADDR, input wire [8-1:0] S_AXI_ALEN, input wire [3-1:0] S_AXI_ASIZE, input wire [2-1:0] S_AXI_ABURST, input wire [1-1:0] S_AXI_ALOCK, input wire [4-1:0] S_AXI_ACACHE, input wire [3-1:0] S_AXI_APROT, input wire [4-1:0] S_AXI_AQOS, input wire [C_AXI_AUSER_WIDTH-1:0] S_AXI_AUSER, input wire S_AXI_AVALID, output wire S_AXI_AREADY, // Master Interface Write Address Port output wire [C_AXI_ID_WIDTH-1:0] M_AXI_AID, output wire [C_AXI_ADDR_WIDTH-1:0] M_AXI_AADDR, output wire [4-1:0] M_AXI_ALEN, output wire [3-1:0] M_AXI_ASIZE, output wire [2-1:0] M_AXI_ABURST, output wire [2-1:0] M_AXI_ALOCK, output wire [4-1:0] M_AXI_ACACHE, output wire [3-1:0] M_AXI_APROT, output wire [4-1:0] M_AXI_AQOS, output wire [C_AXI_AUSER_WIDTH-1:0] M_AXI_AUSER, output wire M_AXI_AVALID, input wire M_AXI_AREADY ); ///////////////////////////////////////////////////////////////////////////// // Variables for generating parameter controlled instances. ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// // Local params ///////////////////////////////////////////////////////////////////////////// // Constants for burst types. localparam [2-1:0] C_FIX_BURST = 2'b00; localparam [2-1:0] C_INCR_BURST = 2'b01; localparam [2-1:0] C_WRAP_BURST = 2'b10; // Depth for command FIFO. localparam integer C_FIFO_DEPTH_LOG = 5; // Constants used to generate size mask. localparam [C_AXI_ADDR_WIDTH+8-1:0] C_SIZE_MASK = {{C_AXI_ADDR_WIDTH{1'b1}}, 8'b0000_0000}; ///////////////////////////////////////////////////////////////////////////// // Functions ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// // Internal signals ///////////////////////////////////////////////////////////////////////////// // Access decoding related signals. wire access_is_incr; wire [4-1:0] num_transactions; wire incr_need_to_split; reg [C_AXI_ADDR_WIDTH-1:0] next_mi_addr; reg split_ongoing; reg [4-1:0] pushed_commands; reg [16-1:0] addr_step; reg [16-1:0] first_step; wire [8-1:0] first_beats; reg [C_AXI_ADDR_WIDTH-1:0] size_mask; // Access decoding related signals for internal pipestage. reg access_is_incr_q; reg incr_need_to_split_q; wire need_to_split_q; reg [4-1:0] num_transactions_q; reg [16-1:0] addr_step_q; reg [16-1:0] first_step_q; reg [C_AXI_ADDR_WIDTH-1:0] size_mask_q; // Command buffer help signals. reg [C_FIFO_DEPTH_LOG:0] cmd_depth; reg cmd_empty; reg [C_AXI_ID_WIDTH-1:0] queue_id; wire id_match; wire cmd_id_check; wire s_ready; wire cmd_full; wire allow_this_cmd; wire allow_new_cmd; wire cmd_push; reg cmd_push_block; reg [C_FIFO_DEPTH_LOG:0] cmd_b_depth; reg cmd_b_empty; wire cmd_b_full; wire cmd_b_push; reg cmd_b_push_block; wire pushed_new_cmd; wire last_incr_split; wire last_split; wire first_split; wire no_cmd; wire allow_split_cmd; wire almost_empty; wire no_b_cmd; wire allow_non_split_cmd; wire almost_b_empty; reg multiple_id_non_split; reg split_in_progress; // Internal Command Interface signals (W/R). wire cmd_split_i; wire [C_AXI_ID_WIDTH-1:0] cmd_id_i; reg [4-1:0] cmd_length_i; // Internal Command Interface signals (B). wire cmd_b_split_i; wire [4-1:0] cmd_b_repeat_i; // Throttling help signals. wire mi_stalling; reg command_ongoing; // Internal SI-side signals. reg [C_AXI_ID_WIDTH-1:0] S_AXI_AID_Q; reg [C_AXI_ADDR_WIDTH-1:0] S_AXI_AADDR_Q; reg [8-1:0] S_AXI_ALEN_Q; reg [3-1:0] S_AXI_ASIZE_Q; reg [2-1:0] S_AXI_ABURST_Q; reg [2-1:0] S_AXI_ALOCK_Q; reg [4-1:0] S_AXI_ACACHE_Q; reg [3-1:0] S_AXI_APROT_Q; reg [4-1:0] S_AXI_AQOS_Q; reg [C_AXI_AUSER_WIDTH-1:0] S_AXI_AUSER_Q; reg S_AXI_AREADY_I; // Internal MI-side signals. wire [C_AXI_ID_WIDTH-1:0] M_AXI_AID_I; reg [C_AXI_ADDR_WIDTH-1:0] M_AXI_AADDR_I; reg [8-1:0] M_AXI_ALEN_I; wire [3-1:0] M_AXI_ASIZE_I; wire [2-1:0] M_AXI_ABURST_I; reg [2-1:0] M_AXI_ALOCK_I; wire [4-1:0] M_AXI_ACACHE_I; wire [3-1:0] M_AXI_APROT_I; wire [4-1:0] M_AXI_AQOS_I; wire [C_AXI_AUSER_WIDTH-1:0] M_AXI_AUSER_I; wire M_AXI_AVALID_I; wire M_AXI_AREADY_I; reg [1:0] areset_d; // Reset delay register always @(posedge ACLK) begin areset_d <= {areset_d[0], ARESET}; end ///////////////////////////////////////////////////////////////////////////// // Capture SI-Side signals. // ///////////////////////////////////////////////////////////////////////////// // Register SI-Side signals. always @ (posedge ACLK) begin if ( ARESET ) begin S_AXI_AID_Q <= {C_AXI_ID_WIDTH{1'b0}}; S_AXI_AADDR_Q <= {C_AXI_ADDR_WIDTH{1'b0}}; S_AXI_ALEN_Q <= 8'b0; S_AXI_ASIZE_Q <= 3'b0; S_AXI_ABURST_Q <= 2'b0; S_AXI_ALOCK_Q <= 2'b0; S_AXI_ACACHE_Q <= 4'b0; S_AXI_APROT_Q <= 3'b0; S_AXI_AQOS_Q <= 4'b0; S_AXI_AUSER_Q <= {C_AXI_AUSER_WIDTH{1'b0}}; end else begin if ( S_AXI_AREADY_I ) begin S_AXI_AID_Q <= S_AXI_AID; S_AXI_AADDR_Q <= S_AXI_AADDR; S_AXI_ALEN_Q <= S_AXI_ALEN; S_AXI_ASIZE_Q <= S_AXI_ASIZE; S_AXI_ABURST_Q <= S_AXI_ABURST; S_AXI_ALOCK_Q <= S_AXI_ALOCK; S_AXI_ACACHE_Q <= S_AXI_ACACHE; S_AXI_APROT_Q <= S_AXI_APROT; S_AXI_AQOS_Q <= S_AXI_AQOS; S_AXI_AUSER_Q <= S_AXI_AUSER; end end end ///////////////////////////////////////////////////////////////////////////// // Decode the Incoming Transaction. // // Extract transaction type and the number of splits that may be needed. // // Calculate the step size so that the address for each part of a split can // can be calculated. // ///////////////////////////////////////////////////////////////////////////// // Transaction burst type. assign access_is_incr = ( S_AXI_ABURST == C_INCR_BURST ); // Get number of transactions for split INCR. assign num_transactions = S_AXI_ALEN[4 +: 4]; assign first_beats = {3'b0, S_AXI_ALEN[0 +: 4]} + 7'b01; // Generate address increment of first split transaction. always @ * begin case (S_AXI_ASIZE) 3'b000: first_step = first_beats << 0; 3'b001: first_step = first_beats << 1; 3'b010: first_step = first_beats << 2; 3'b011: first_step = first_beats << 3; 3'b100: first_step = first_beats << 4; 3'b101: first_step = first_beats << 5; 3'b110: first_step = first_beats << 6; 3'b111: first_step = first_beats << 7; endcase end // Generate address increment for remaining split transactions. always @ * begin case (S_AXI_ASIZE) 3'b000: addr_step = 16'h0010; 3'b001: addr_step = 16'h0020; 3'b010: addr_step = 16'h0040; 3'b011: addr_step = 16'h0080; 3'b100: addr_step = 16'h0100; 3'b101: addr_step = 16'h0200; 3'b110: addr_step = 16'h0400; 3'b111: addr_step = 16'h0800; endcase end // Generate address mask bits to remove split transaction unalignment. always @ * begin case (S_AXI_ASIZE) 3'b000: size_mask = C_SIZE_MASK[8 +: C_AXI_ADDR_WIDTH]; 3'b001: size_mask = C_SIZE_MASK[7 +: C_AXI_ADDR_WIDTH]; 3'b010: size_mask = C_SIZE_MASK[6 +: C_AXI_ADDR_WIDTH]; 3'b011: size_mask = C_SIZE_MASK[5 +: C_AXI_ADDR_WIDTH]; 3'b100: size_mask = C_SIZE_MASK[4 +: C_AXI_ADDR_WIDTH]; 3'b101: size_mask = C_SIZE_MASK[3 +: C_AXI_ADDR_WIDTH]; 3'b110: size_mask = C_SIZE_MASK[2 +: C_AXI_ADDR_WIDTH]; 3'b111: size_mask = C_SIZE_MASK[1 +: C_AXI_ADDR_WIDTH]; endcase end ///////////////////////////////////////////////////////////////////////////// // Transfer SI-Side signals to internal Pipeline Stage. // ///////////////////////////////////////////////////////////////////////////// always @ (posedge ACLK) begin if ( ARESET ) begin access_is_incr_q <= 1'b0; incr_need_to_split_q <= 1'b0; num_transactions_q <= 4'b0; addr_step_q <= 16'b0; first_step_q <= 16'b0; size_mask_q <= {C_AXI_ADDR_WIDTH{1'b0}}; end else begin if ( S_AXI_AREADY_I ) begin access_is_incr_q <= access_is_incr; incr_need_to_split_q <= incr_need_to_split; num_transactions_q <= num_transactions; addr_step_q <= addr_step; first_step_q <= first_step; size_mask_q <= size_mask; end end end ///////////////////////////////////////////////////////////////////////////// // Generate Command Information. // // Detect if current transation needs to be split, and keep track of all // the generated split transactions. // // ///////////////////////////////////////////////////////////////////////////// // Detect when INCR must be split. assign incr_need_to_split = access_is_incr & ( num_transactions != 0 ) & ( C_SUPPORT_SPLITTING == 1 ) & ( C_SUPPORT_BURSTS == 1 ); // Detect when a command has to be split. assign need_to_split_q = incr_need_to_split_q; // Handle progress of split transactions. always @ (posedge ACLK) begin if ( ARESET ) begin split_ongoing <= 1'b0; end else begin if ( pushed_new_cmd ) begin split_ongoing <= need_to_split_q & ~last_split; end end end // Keep track of number of transactions generated. always @ (posedge ACLK) begin if ( ARESET ) begin pushed_commands <= 4'b0; end else begin if ( S_AXI_AREADY_I ) begin pushed_commands <= 4'b0; end else if ( pushed_new_cmd ) begin pushed_commands <= pushed_commands + 4'b1; end end end // Detect last part of a command, split or not. assign last_incr_split = access_is_incr_q & ( num_transactions_q == pushed_commands ); assign last_split = last_incr_split | ~access_is_incr_q | ( C_SUPPORT_SPLITTING == 0 ) | ( C_SUPPORT_BURSTS == 0 ); assign first_split = (pushed_commands == 4'b0); // Calculate base for next address. always @ (posedge ACLK) begin if ( ARESET ) begin next_mi_addr = {C_AXI_ADDR_WIDTH{1'b0}}; end else if ( pushed_new_cmd ) begin next_mi_addr = M_AXI_AADDR_I + (first_split ? first_step_q : addr_step_q); end end ///////////////////////////////////////////////////////////////////////////// // Translating Transaction. // // Set Split transaction information on all part except last for a transaction // that needs splitting. // The B Channel will only get one command for a Split transaction and in // the Split bflag will be set in that case. // // The AWID is extracted and applied to all commands generated for the current // incomming SI-Side transaction. // // The address is increased for each part of a Split transaction, the amount // depends on the siSIZE for the transaction. // // The length has to be changed for Split transactions. All part except tha // last one will have 0xF, the last one uses the 4 lsb bits from the SI-side // transaction as length. // // Non-Split has untouched address and length information. // // Exclusive access are diasabled for a Split transaction because it is not // possible to guarantee concistency between all the parts. // ///////////////////////////////////////////////////////////////////////////// // Assign Split signals. assign cmd_split_i = need_to_split_q & ~last_split; assign cmd_b_split_i = need_to_split_q & ~last_split; // Copy AW ID to W. assign cmd_id_i = S_AXI_AID_Q; // Set B Responses to merge. assign cmd_b_repeat_i = num_transactions_q; // Select new size or remaining size. always @ * begin if ( split_ongoing & access_is_incr_q ) begin M_AXI_AADDR_I = next_mi_addr & size_mask_q; end else begin M_AXI_AADDR_I = S_AXI_AADDR_Q; end end // Generate the base length for each transaction. always @ * begin if ( first_split | ~need_to_split_q ) begin M_AXI_ALEN_I = S_AXI_ALEN_Q[0 +: 4]; cmd_length_i = S_AXI_ALEN_Q[0 +: 4]; end else begin M_AXI_ALEN_I = 4'hF; cmd_length_i = 4'hF; end end // Kill Exclusive for Split transactions. always @ * begin if ( need_to_split_q ) begin M_AXI_ALOCK_I = 2'b00; end else begin M_AXI_ALOCK_I = {1'b0, S_AXI_ALOCK_Q}; end end ///////////////////////////////////////////////////////////////////////////// // Forward the command to the MI-side interface. // // It is determined that this is an allowed command/access when there is // room in the command queue (and it passes ID and Split checks as required). // ///////////////////////////////////////////////////////////////////////////// // Move SI-side transaction to internal pipe stage. always @ (posedge ACLK) begin if (ARESET) begin command_ongoing <= 1'b0; S_AXI_AREADY_I <= 1'b0; end else begin if (areset_d == 2'b10) begin S_AXI_AREADY_I <= 1'b1; end else begin if ( S_AXI_AVALID & S_AXI_AREADY_I ) begin command_ongoing <= 1'b1; S_AXI_AREADY_I <= 1'b0; end else if ( pushed_new_cmd & last_split ) begin command_ongoing <= 1'b0; S_AXI_AREADY_I <= 1'b1; end end end end // Generate ready signal. assign S_AXI_AREADY = S_AXI_AREADY_I; // Only allowed to forward translated command when command queue is ok with it. assign M_AXI_AVALID_I = allow_new_cmd & command_ongoing; // Detect when MI-side is stalling. assign mi_stalling = M_AXI_AVALID_I & ~M_AXI_AREADY_I; ///////////////////////////////////////////////////////////////////////////// // Simple transfer of paramters that doesn't need to be adjusted. // // ID - Transaction still recognized with the same ID. // CACHE - No need to change the chache features. Even if the modyfiable // bit is overridden (forcefully) there is no need to let downstream // component beleive it is ok to modify it further. // PROT - Security level of access is not changed when upsizing. // QOS - Quality of Service is static 0. // USER - User bits remains the same. // ///////////////////////////////////////////////////////////////////////////// assign M_AXI_AID_I = S_AXI_AID_Q; assign M_AXI_ASIZE_I = S_AXI_ASIZE_Q; assign M_AXI_ABURST_I = S_AXI_ABURST_Q; assign M_AXI_ACACHE_I = S_AXI_ACACHE_Q; assign M_AXI_APROT_I = S_AXI_APROT_Q; assign M_AXI_AQOS_I = S_AXI_AQOS_Q; assign M_AXI_AUSER_I = ( C_AXI_SUPPORTS_USER_SIGNALS ) ? S_AXI_AUSER_Q : {C_AXI_AUSER_WIDTH{1'b0}}; ///////////////////////////////////////////////////////////////////////////// // Control command queue to W/R channel. // // Commands can be pushed into the Cmd FIFO even if MI-side is stalling. // A flag is set if MI-side is stalling when Command is pushed to the // Cmd FIFO. This will prevent multiple push of the same Command as well as // keeping the MI-side Valid signal if the Allow Cmd requirement has been // updated to disable furter Commands (I.e. it is made sure that the SI-side // Command has been forwarded to both Cmd FIFO and MI-side). // // It is allowed to continue pushing new commands as long as // * There is room in the queue(s) // * The ID is the same as previously queued. Since data is not reordered // for the same ID it is always OK to let them proceed. // Or, if no split transaction is ongoing any ID can be allowed. // ///////////////////////////////////////////////////////////////////////////// // Keep track of current ID in queue. always @ (posedge ACLK) begin if (ARESET) begin queue_id <= {C_AXI_ID_WIDTH{1'b0}}; multiple_id_non_split <= 1'b0; split_in_progress <= 1'b0; end else begin if ( cmd_push ) begin // Store ID (it will be matching ID or a "new beginning"). queue_id <= S_AXI_AID_Q; end if ( no_cmd & no_b_cmd ) begin multiple_id_non_split <= 1'b0; end else if ( cmd_push & allow_non_split_cmd & ~id_match ) begin multiple_id_non_split <= 1'b1; end if ( no_cmd & no_b_cmd ) begin split_in_progress <= 1'b0; end else if ( cmd_push & allow_split_cmd ) begin split_in_progress <= 1'b1; end end end // Determine if the command FIFOs are empty. assign no_cmd = almost_empty & cmd_ready | cmd_empty; assign no_b_cmd = almost_b_empty & cmd_b_ready | cmd_b_empty; // Check ID to make sure this command is allowed. assign id_match = ( C_SINGLE_THREAD == 0 ) | ( queue_id == S_AXI_AID_Q); assign cmd_id_check = (cmd_empty & cmd_b_empty) | ( id_match & (~cmd_empty | ~cmd_b_empty) ); // Command type affects possibility to push immediately or wait. assign allow_split_cmd = need_to_split_q & cmd_id_check & ~multiple_id_non_split; assign allow_non_split_cmd = ~need_to_split_q & (cmd_id_check | ~split_in_progress); assign allow_this_cmd = allow_split_cmd | allow_non_split_cmd | ( C_SINGLE_THREAD == 0 ); // Check if it is allowed to push more commands. assign allow_new_cmd = (~cmd_full & ~cmd_b_full & allow_this_cmd) | cmd_push_block; // Push new command when allowed and MI-side is able to receive the command. assign cmd_push = M_AXI_AVALID_I & ~cmd_push_block; assign cmd_b_push = M_AXI_AVALID_I & ~cmd_b_push_block & (C_AXI_CHANNEL == 0); // Block furter push until command has been forwarded to MI-side. always @ (posedge ACLK) begin if (ARESET) begin cmd_push_block <= 1'b0; end else begin if ( pushed_new_cmd ) begin cmd_push_block <= 1'b0; end else if ( cmd_push & mi_stalling ) begin cmd_push_block <= 1'b1; end end end // Block furter push until command has been forwarded to MI-side. always @ (posedge ACLK) begin if (ARESET) begin cmd_b_push_block <= 1'b0; end else begin if ( S_AXI_AREADY_I ) begin cmd_b_push_block <= 1'b0; end else if ( cmd_b_push ) begin cmd_b_push_block <= 1'b1; end end end // Acknowledge command when we can push it into queue (and forward it). assign pushed_new_cmd = M_AXI_AVALID_I & M_AXI_AREADY_I; ///////////////////////////////////////////////////////////////////////////// // Command Queue (W/R): // // Instantiate a FIFO as the queue and adjust the control signals. // // The features from Command FIFO can be reduced depending on configuration: // Read Channel only need the split information. // Write Channel always require ID information. When bursts are supported // Split and Length information is also used. // ///////////////////////////////////////////////////////////////////////////// // Instantiated queue. generate if ( C_AXI_CHANNEL == 1 && C_SUPPORT_SPLITTING == 1 && C_SUPPORT_BURSTS == 1 ) begin : USE_R_CHANNEL axi_data_fifo_v2_1_axic_fifo # ( .C_FAMILY(C_FAMILY), .C_FIFO_DEPTH_LOG(C_FIFO_DEPTH_LOG), .C_FIFO_WIDTH(1), .C_FIFO_TYPE("lut") ) cmd_queue ( .ACLK(ACLK), .ARESET(ARESET), .S_MESG({cmd_split_i}), .S_VALID(cmd_push), .S_READY(s_ready), .M_MESG({cmd_split}), .M_VALID(cmd_valid), .M_READY(cmd_ready) ); assign cmd_id = {C_AXI_ID_WIDTH{1'b0}}; assign cmd_length = 4'b0; end else if (C_SUPPORT_BURSTS == 1) begin : USE_BURSTS axi_data_fifo_v2_1_axic_fifo # ( .C_FAMILY(C_FAMILY), .C_FIFO_DEPTH_LOG(C_FIFO_DEPTH_LOG), .C_FIFO_WIDTH(C_AXI_ID_WIDTH+4), .C_FIFO_TYPE("lut") ) cmd_queue ( .ACLK(ACLK), .ARESET(ARESET), .S_MESG({cmd_id_i, cmd_length_i}), .S_VALID(cmd_push), .S_READY(s_ready), .M_MESG({cmd_id, cmd_length}), .M_VALID(cmd_valid), .M_READY(cmd_ready) ); assign cmd_split = 1'b0; end else begin : NO_BURSTS axi_data_fifo_v2_1_axic_fifo # ( .C_FAMILY(C_FAMILY), .C_FIFO_DEPTH_LOG(C_FIFO_DEPTH_LOG), .C_FIFO_WIDTH(C_AXI_ID_WIDTH), .C_FIFO_TYPE("lut") ) cmd_queue ( .ACLK(ACLK), .ARESET(ARESET), .S_MESG({cmd_id_i}), .S_VALID(cmd_push), .S_READY(s_ready), .M_MESG({cmd_id}), .M_VALID(cmd_valid), .M_READY(cmd_ready) ); assign cmd_split = 1'b0; assign cmd_length = 4'b0; end endgenerate // Queue is concidered full when not ready. assign cmd_full = ~s_ready; // Queue is empty when no data at output port. always @ (posedge ACLK) begin if (ARESET) begin cmd_empty <= 1'b1; cmd_depth <= {C_FIFO_DEPTH_LOG+1{1'b0}}; end else begin if ( cmd_push & ~cmd_ready ) begin // Push only => Increase depth. cmd_depth <= cmd_depth + 1'b1; cmd_empty <= 1'b0; end else if ( ~cmd_push & cmd_ready ) begin // Pop only => Decrease depth. cmd_depth <= cmd_depth - 1'b1; cmd_empty <= almost_empty; end end end assign almost_empty = ( cmd_depth == 1 ); ///////////////////////////////////////////////////////////////////////////// // Command Queue (B): // // Add command queue for B channel only when it is AW channel and both burst // and splitting is supported. // // When turned off the command appears always empty. // ///////////////////////////////////////////////////////////////////////////// // Instantiated queue. generate if ( C_AXI_CHANNEL == 0 && C_SUPPORT_SPLITTING == 1 && C_SUPPORT_BURSTS == 1 ) begin : USE_B_CHANNEL wire cmd_b_valid_i; wire s_b_ready; axi_data_fifo_v2_1_axic_fifo # ( .C_FAMILY(C_FAMILY), .C_FIFO_DEPTH_LOG(C_FIFO_DEPTH_LOG), .C_FIFO_WIDTH(1+4), .C_FIFO_TYPE("lut") ) cmd_b_queue ( .ACLK(ACLK), .ARESET(ARESET), .S_MESG({cmd_b_split_i, cmd_b_repeat_i}), .S_VALID(cmd_b_push), .S_READY(s_b_ready), .M_MESG({cmd_b_split, cmd_b_repeat}), .M_VALID(cmd_b_valid_i), .M_READY(cmd_b_ready) ); // Queue is concidered full when not ready. assign cmd_b_full = ~s_b_ready; // Queue is empty when no data at output port. always @ (posedge ACLK) begin if (ARESET) begin cmd_b_empty <= 1'b1; cmd_b_depth <= {C_FIFO_DEPTH_LOG+1{1'b0}}; end else begin if ( cmd_b_push & ~cmd_b_ready ) begin // Push only => Increase depth. cmd_b_depth <= cmd_b_depth + 1'b1; cmd_b_empty <= 1'b0; end else if ( ~cmd_b_push & cmd_b_ready ) begin // Pop only => Decrease depth. cmd_b_depth <= cmd_b_depth - 1'b1; cmd_b_empty <= ( cmd_b_depth == 1 ); end end end assign almost_b_empty = ( cmd_b_depth == 1 ); // Assign external signal. assign cmd_b_valid = cmd_b_valid_i; end else begin : NO_B_CHANNEL // Assign external command signals. assign cmd_b_valid = 1'b0; assign cmd_b_split = 1'b0; assign cmd_b_repeat = 4'b0; // Assign internal command FIFO signals. assign cmd_b_full = 1'b0; assign almost_b_empty = 1'b0; always @ (posedge ACLK) begin if (ARESET) begin cmd_b_empty <= 1'b1; cmd_b_depth <= {C_FIFO_DEPTH_LOG+1{1'b0}}; end else begin // Constant FF due to ModelSim behavior. cmd_b_empty <= 1'b1; cmd_b_depth <= {C_FIFO_DEPTH_LOG+1{1'b0}}; end end end endgenerate ///////////////////////////////////////////////////////////////////////////// // MI-side output handling // ///////////////////////////////////////////////////////////////////////////// assign M_AXI_AID = M_AXI_AID_I; assign M_AXI_AADDR = M_AXI_AADDR_I; assign M_AXI_ALEN = M_AXI_ALEN_I; assign M_AXI_ASIZE = M_AXI_ASIZE_I; assign M_AXI_ABURST = M_AXI_ABURST_I; assign M_AXI_ALOCK = M_AXI_ALOCK_I; assign M_AXI_ACACHE = M_AXI_ACACHE_I; assign M_AXI_APROT = M_AXI_APROT_I; assign M_AXI_AQOS = M_AXI_AQOS_I; assign M_AXI_AUSER = M_AXI_AUSER_I; assign M_AXI_AVALID = M_AXI_AVALID_I; assign M_AXI_AREADY_I = M_AXI_AREADY; endmodule
// -- (c) Copyright 2010 - 2011 Xilinx, Inc. All rights reserved. // -- // -- This file contains confidential and proprietary information // -- of Xilinx, Inc. and is protected under U.S. and // -- international copyright and other intellectual property // -- laws. // -- // -- DISCLAIMER // -- This disclaimer is not a license and does not grant any // -- rights to the materials distributed herewith. Except as // -- otherwise provided in a valid license issued to you by // -- Xilinx, and to the maximum extent permitted by applicable // -- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND // -- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES // -- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING // -- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- // -- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and // -- (2) Xilinx shall not be liable (whether in contract or tort, // -- including negligence, or under any other theory of // -- liability) for any loss or damage of any kind or nature // -- related to, arising under or in connection with these // -- materials, including for any direct, or any indirect, // -- special, incidental, or consequential loss or damage // -- (including loss of data, profits, goodwill, or any type of // -- loss or damage suffered as a result of any action brought // -- by a third party) even if such damage or loss was // -- reasonably foreseeable or Xilinx had been advised of the // -- possibility of the same. // -- // -- CRITICAL APPLICATIONS // -- Xilinx products are not designed or intended to be fail- // -- safe, or for use in any application requiring fail-safe // -- performance, such as life-support or safety devices or // -- systems, Class III medical devices, nuclear facilities, // -- applications related to the deployment of airbags, or any // -- other applications that could lead to death, personal // -- injury, or severe property or environmental damage // -- (individually and collectively, "Critical // -- Applications"). Customer assumes the sole risk and // -- liability of any use of Xilinx products in Critical // -- Applications, subject only to applicable laws and // -- regulations governing limitations on product liability. // -- // -- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS // -- PART OF THIS FILE AT ALL TIMES. //----------------------------------------------------------------------------- // // Description: Address AXI3 Slave Converter // // // Verilog-standard: Verilog 2001 //-------------------------------------------------------------------------- // // Structure: // a_axi3_conv // axic_fifo // //-------------------------------------------------------------------------- `timescale 1ps/1ps (* DowngradeIPIdentifiedWarnings="yes" *) module axi_protocol_converter_v2_1_a_axi3_conv # ( parameter C_FAMILY = "none", parameter integer C_AXI_ID_WIDTH = 1, parameter integer C_AXI_ADDR_WIDTH = 32, parameter integer C_AXI_DATA_WIDTH = 32, parameter integer C_AXI_SUPPORTS_USER_SIGNALS = 0, parameter integer C_AXI_AUSER_WIDTH = 1, parameter integer C_AXI_CHANNEL = 0, // 0 = AXI AW Channel. // 1 = AXI AR Channel. parameter integer C_SUPPORT_SPLITTING = 1, // Implement transaction splitting logic. // Disabled whan all connected masters are AXI3 and have same or narrower data width. parameter integer C_SUPPORT_BURSTS = 1, // Disabled when all connected masters are AxiLite, // allowing logic to be simplified. parameter integer C_SINGLE_THREAD = 1 // 0 = Ignore ID when propagating transactions (assume all responses are in order). // 1 = Enforce single-threading (one ID at a time) when any outstanding or // requested transaction requires splitting. // While no split is ongoing any new non-split transaction will pass immediately regardless // off ID. // A split transaction will stall if there are multiple ID (non-split) transactions // ongoing, once it has been forwarded only transactions with the same ID is allowed // (split or not) until all ongoing split transactios has been completed. ) ( // System Signals input wire ACLK, input wire ARESET, // Command Interface (W/R) output wire cmd_valid, output wire cmd_split, output wire [C_AXI_ID_WIDTH-1:0] cmd_id, output wire [4-1:0] cmd_length, input wire cmd_ready, // Command Interface (B) output wire cmd_b_valid, output wire cmd_b_split, output wire [4-1:0] cmd_b_repeat, input wire cmd_b_ready, // Slave Interface Write Address Ports input wire [C_AXI_ID_WIDTH-1:0] S_AXI_AID, input wire [C_AXI_ADDR_WIDTH-1:0] S_AXI_AADDR, input wire [8-1:0] S_AXI_ALEN, input wire [3-1:0] S_AXI_ASIZE, input wire [2-1:0] S_AXI_ABURST, input wire [1-1:0] S_AXI_ALOCK, input wire [4-1:0] S_AXI_ACACHE, input wire [3-1:0] S_AXI_APROT, input wire [4-1:0] S_AXI_AQOS, input wire [C_AXI_AUSER_WIDTH-1:0] S_AXI_AUSER, input wire S_AXI_AVALID, output wire S_AXI_AREADY, // Master Interface Write Address Port output wire [C_AXI_ID_WIDTH-1:0] M_AXI_AID, output wire [C_AXI_ADDR_WIDTH-1:0] M_AXI_AADDR, output wire [4-1:0] M_AXI_ALEN, output wire [3-1:0] M_AXI_ASIZE, output wire [2-1:0] M_AXI_ABURST, output wire [2-1:0] M_AXI_ALOCK, output wire [4-1:0] M_AXI_ACACHE, output wire [3-1:0] M_AXI_APROT, output wire [4-1:0] M_AXI_AQOS, output wire [C_AXI_AUSER_WIDTH-1:0] M_AXI_AUSER, output wire M_AXI_AVALID, input wire M_AXI_AREADY ); ///////////////////////////////////////////////////////////////////////////// // Variables for generating parameter controlled instances. ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// // Local params ///////////////////////////////////////////////////////////////////////////// // Constants for burst types. localparam [2-1:0] C_FIX_BURST = 2'b00; localparam [2-1:0] C_INCR_BURST = 2'b01; localparam [2-1:0] C_WRAP_BURST = 2'b10; // Depth for command FIFO. localparam integer C_FIFO_DEPTH_LOG = 5; // Constants used to generate size mask. localparam [C_AXI_ADDR_WIDTH+8-1:0] C_SIZE_MASK = {{C_AXI_ADDR_WIDTH{1'b1}}, 8'b0000_0000}; ///////////////////////////////////////////////////////////////////////////// // Functions ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// // Internal signals ///////////////////////////////////////////////////////////////////////////// // Access decoding related signals. wire access_is_incr; wire [4-1:0] num_transactions; wire incr_need_to_split; reg [C_AXI_ADDR_WIDTH-1:0] next_mi_addr; reg split_ongoing; reg [4-1:0] pushed_commands; reg [16-1:0] addr_step; reg [16-1:0] first_step; wire [8-1:0] first_beats; reg [C_AXI_ADDR_WIDTH-1:0] size_mask; // Access decoding related signals for internal pipestage. reg access_is_incr_q; reg incr_need_to_split_q; wire need_to_split_q; reg [4-1:0] num_transactions_q; reg [16-1:0] addr_step_q; reg [16-1:0] first_step_q; reg [C_AXI_ADDR_WIDTH-1:0] size_mask_q; // Command buffer help signals. reg [C_FIFO_DEPTH_LOG:0] cmd_depth; reg cmd_empty; reg [C_AXI_ID_WIDTH-1:0] queue_id; wire id_match; wire cmd_id_check; wire s_ready; wire cmd_full; wire allow_this_cmd; wire allow_new_cmd; wire cmd_push; reg cmd_push_block; reg [C_FIFO_DEPTH_LOG:0] cmd_b_depth; reg cmd_b_empty; wire cmd_b_full; wire cmd_b_push; reg cmd_b_push_block; wire pushed_new_cmd; wire last_incr_split; wire last_split; wire first_split; wire no_cmd; wire allow_split_cmd; wire almost_empty; wire no_b_cmd; wire allow_non_split_cmd; wire almost_b_empty; reg multiple_id_non_split; reg split_in_progress; // Internal Command Interface signals (W/R). wire cmd_split_i; wire [C_AXI_ID_WIDTH-1:0] cmd_id_i; reg [4-1:0] cmd_length_i; // Internal Command Interface signals (B). wire cmd_b_split_i; wire [4-1:0] cmd_b_repeat_i; // Throttling help signals. wire mi_stalling; reg command_ongoing; // Internal SI-side signals. reg [C_AXI_ID_WIDTH-1:0] S_AXI_AID_Q; reg [C_AXI_ADDR_WIDTH-1:0] S_AXI_AADDR_Q; reg [8-1:0] S_AXI_ALEN_Q; reg [3-1:0] S_AXI_ASIZE_Q; reg [2-1:0] S_AXI_ABURST_Q; reg [2-1:0] S_AXI_ALOCK_Q; reg [4-1:0] S_AXI_ACACHE_Q; reg [3-1:0] S_AXI_APROT_Q; reg [4-1:0] S_AXI_AQOS_Q; reg [C_AXI_AUSER_WIDTH-1:0] S_AXI_AUSER_Q; reg S_AXI_AREADY_I; // Internal MI-side signals. wire [C_AXI_ID_WIDTH-1:0] M_AXI_AID_I; reg [C_AXI_ADDR_WIDTH-1:0] M_AXI_AADDR_I; reg [8-1:0] M_AXI_ALEN_I; wire [3-1:0] M_AXI_ASIZE_I; wire [2-1:0] M_AXI_ABURST_I; reg [2-1:0] M_AXI_ALOCK_I; wire [4-1:0] M_AXI_ACACHE_I; wire [3-1:0] M_AXI_APROT_I; wire [4-1:0] M_AXI_AQOS_I; wire [C_AXI_AUSER_WIDTH-1:0] M_AXI_AUSER_I; wire M_AXI_AVALID_I; wire M_AXI_AREADY_I; reg [1:0] areset_d; // Reset delay register always @(posedge ACLK) begin areset_d <= {areset_d[0], ARESET}; end ///////////////////////////////////////////////////////////////////////////// // Capture SI-Side signals. // ///////////////////////////////////////////////////////////////////////////// // Register SI-Side signals. always @ (posedge ACLK) begin if ( ARESET ) begin S_AXI_AID_Q <= {C_AXI_ID_WIDTH{1'b0}}; S_AXI_AADDR_Q <= {C_AXI_ADDR_WIDTH{1'b0}}; S_AXI_ALEN_Q <= 8'b0; S_AXI_ASIZE_Q <= 3'b0; S_AXI_ABURST_Q <= 2'b0; S_AXI_ALOCK_Q <= 2'b0; S_AXI_ACACHE_Q <= 4'b0; S_AXI_APROT_Q <= 3'b0; S_AXI_AQOS_Q <= 4'b0; S_AXI_AUSER_Q <= {C_AXI_AUSER_WIDTH{1'b0}}; end else begin if ( S_AXI_AREADY_I ) begin S_AXI_AID_Q <= S_AXI_AID; S_AXI_AADDR_Q <= S_AXI_AADDR; S_AXI_ALEN_Q <= S_AXI_ALEN; S_AXI_ASIZE_Q <= S_AXI_ASIZE; S_AXI_ABURST_Q <= S_AXI_ABURST; S_AXI_ALOCK_Q <= S_AXI_ALOCK; S_AXI_ACACHE_Q <= S_AXI_ACACHE; S_AXI_APROT_Q <= S_AXI_APROT; S_AXI_AQOS_Q <= S_AXI_AQOS; S_AXI_AUSER_Q <= S_AXI_AUSER; end end end ///////////////////////////////////////////////////////////////////////////// // Decode the Incoming Transaction. // // Extract transaction type and the number of splits that may be needed. // // Calculate the step size so that the address for each part of a split can // can be calculated. // ///////////////////////////////////////////////////////////////////////////// // Transaction burst type. assign access_is_incr = ( S_AXI_ABURST == C_INCR_BURST ); // Get number of transactions for split INCR. assign num_transactions = S_AXI_ALEN[4 +: 4]; assign first_beats = {3'b0, S_AXI_ALEN[0 +: 4]} + 7'b01; // Generate address increment of first split transaction. always @ * begin case (S_AXI_ASIZE) 3'b000: first_step = first_beats << 0; 3'b001: first_step = first_beats << 1; 3'b010: first_step = first_beats << 2; 3'b011: first_step = first_beats << 3; 3'b100: first_step = first_beats << 4; 3'b101: first_step = first_beats << 5; 3'b110: first_step = first_beats << 6; 3'b111: first_step = first_beats << 7; endcase end // Generate address increment for remaining split transactions. always @ * begin case (S_AXI_ASIZE) 3'b000: addr_step = 16'h0010; 3'b001: addr_step = 16'h0020; 3'b010: addr_step = 16'h0040; 3'b011: addr_step = 16'h0080; 3'b100: addr_step = 16'h0100; 3'b101: addr_step = 16'h0200; 3'b110: addr_step = 16'h0400; 3'b111: addr_step = 16'h0800; endcase end // Generate address mask bits to remove split transaction unalignment. always @ * begin case (S_AXI_ASIZE) 3'b000: size_mask = C_SIZE_MASK[8 +: C_AXI_ADDR_WIDTH]; 3'b001: size_mask = C_SIZE_MASK[7 +: C_AXI_ADDR_WIDTH]; 3'b010: size_mask = C_SIZE_MASK[6 +: C_AXI_ADDR_WIDTH]; 3'b011: size_mask = C_SIZE_MASK[5 +: C_AXI_ADDR_WIDTH]; 3'b100: size_mask = C_SIZE_MASK[4 +: C_AXI_ADDR_WIDTH]; 3'b101: size_mask = C_SIZE_MASK[3 +: C_AXI_ADDR_WIDTH]; 3'b110: size_mask = C_SIZE_MASK[2 +: C_AXI_ADDR_WIDTH]; 3'b111: size_mask = C_SIZE_MASK[1 +: C_AXI_ADDR_WIDTH]; endcase end ///////////////////////////////////////////////////////////////////////////// // Transfer SI-Side signals to internal Pipeline Stage. // ///////////////////////////////////////////////////////////////////////////// always @ (posedge ACLK) begin if ( ARESET ) begin access_is_incr_q <= 1'b0; incr_need_to_split_q <= 1'b0; num_transactions_q <= 4'b0; addr_step_q <= 16'b0; first_step_q <= 16'b0; size_mask_q <= {C_AXI_ADDR_WIDTH{1'b0}}; end else begin if ( S_AXI_AREADY_I ) begin access_is_incr_q <= access_is_incr; incr_need_to_split_q <= incr_need_to_split; num_transactions_q <= num_transactions; addr_step_q <= addr_step; first_step_q <= first_step; size_mask_q <= size_mask; end end end ///////////////////////////////////////////////////////////////////////////// // Generate Command Information. // // Detect if current transation needs to be split, and keep track of all // the generated split transactions. // // ///////////////////////////////////////////////////////////////////////////// // Detect when INCR must be split. assign incr_need_to_split = access_is_incr & ( num_transactions != 0 ) & ( C_SUPPORT_SPLITTING == 1 ) & ( C_SUPPORT_BURSTS == 1 ); // Detect when a command has to be split. assign need_to_split_q = incr_need_to_split_q; // Handle progress of split transactions. always @ (posedge ACLK) begin if ( ARESET ) begin split_ongoing <= 1'b0; end else begin if ( pushed_new_cmd ) begin split_ongoing <= need_to_split_q & ~last_split; end end end // Keep track of number of transactions generated. always @ (posedge ACLK) begin if ( ARESET ) begin pushed_commands <= 4'b0; end else begin if ( S_AXI_AREADY_I ) begin pushed_commands <= 4'b0; end else if ( pushed_new_cmd ) begin pushed_commands <= pushed_commands + 4'b1; end end end // Detect last part of a command, split or not. assign last_incr_split = access_is_incr_q & ( num_transactions_q == pushed_commands ); assign last_split = last_incr_split | ~access_is_incr_q | ( C_SUPPORT_SPLITTING == 0 ) | ( C_SUPPORT_BURSTS == 0 ); assign first_split = (pushed_commands == 4'b0); // Calculate base for next address. always @ (posedge ACLK) begin if ( ARESET ) begin next_mi_addr = {C_AXI_ADDR_WIDTH{1'b0}}; end else if ( pushed_new_cmd ) begin next_mi_addr = M_AXI_AADDR_I + (first_split ? first_step_q : addr_step_q); end end ///////////////////////////////////////////////////////////////////////////// // Translating Transaction. // // Set Split transaction information on all part except last for a transaction // that needs splitting. // The B Channel will only get one command for a Split transaction and in // the Split bflag will be set in that case. // // The AWID is extracted and applied to all commands generated for the current // incomming SI-Side transaction. // // The address is increased for each part of a Split transaction, the amount // depends on the siSIZE for the transaction. // // The length has to be changed for Split transactions. All part except tha // last one will have 0xF, the last one uses the 4 lsb bits from the SI-side // transaction as length. // // Non-Split has untouched address and length information. // // Exclusive access are diasabled for a Split transaction because it is not // possible to guarantee concistency between all the parts. // ///////////////////////////////////////////////////////////////////////////// // Assign Split signals. assign cmd_split_i = need_to_split_q & ~last_split; assign cmd_b_split_i = need_to_split_q & ~last_split; // Copy AW ID to W. assign cmd_id_i = S_AXI_AID_Q; // Set B Responses to merge. assign cmd_b_repeat_i = num_transactions_q; // Select new size or remaining size. always @ * begin if ( split_ongoing & access_is_incr_q ) begin M_AXI_AADDR_I = next_mi_addr & size_mask_q; end else begin M_AXI_AADDR_I = S_AXI_AADDR_Q; end end // Generate the base length for each transaction. always @ * begin if ( first_split | ~need_to_split_q ) begin M_AXI_ALEN_I = S_AXI_ALEN_Q[0 +: 4]; cmd_length_i = S_AXI_ALEN_Q[0 +: 4]; end else begin M_AXI_ALEN_I = 4'hF; cmd_length_i = 4'hF; end end // Kill Exclusive for Split transactions. always @ * begin if ( need_to_split_q ) begin M_AXI_ALOCK_I = 2'b00; end else begin M_AXI_ALOCK_I = {1'b0, S_AXI_ALOCK_Q}; end end ///////////////////////////////////////////////////////////////////////////// // Forward the command to the MI-side interface. // // It is determined that this is an allowed command/access when there is // room in the command queue (and it passes ID and Split checks as required). // ///////////////////////////////////////////////////////////////////////////// // Move SI-side transaction to internal pipe stage. always @ (posedge ACLK) begin if (ARESET) begin command_ongoing <= 1'b0; S_AXI_AREADY_I <= 1'b0; end else begin if (areset_d == 2'b10) begin S_AXI_AREADY_I <= 1'b1; end else begin if ( S_AXI_AVALID & S_AXI_AREADY_I ) begin command_ongoing <= 1'b1; S_AXI_AREADY_I <= 1'b0; end else if ( pushed_new_cmd & last_split ) begin command_ongoing <= 1'b0; S_AXI_AREADY_I <= 1'b1; end end end end // Generate ready signal. assign S_AXI_AREADY = S_AXI_AREADY_I; // Only allowed to forward translated command when command queue is ok with it. assign M_AXI_AVALID_I = allow_new_cmd & command_ongoing; // Detect when MI-side is stalling. assign mi_stalling = M_AXI_AVALID_I & ~M_AXI_AREADY_I; ///////////////////////////////////////////////////////////////////////////// // Simple transfer of paramters that doesn't need to be adjusted. // // ID - Transaction still recognized with the same ID. // CACHE - No need to change the chache features. Even if the modyfiable // bit is overridden (forcefully) there is no need to let downstream // component beleive it is ok to modify it further. // PROT - Security level of access is not changed when upsizing. // QOS - Quality of Service is static 0. // USER - User bits remains the same. // ///////////////////////////////////////////////////////////////////////////// assign M_AXI_AID_I = S_AXI_AID_Q; assign M_AXI_ASIZE_I = S_AXI_ASIZE_Q; assign M_AXI_ABURST_I = S_AXI_ABURST_Q; assign M_AXI_ACACHE_I = S_AXI_ACACHE_Q; assign M_AXI_APROT_I = S_AXI_APROT_Q; assign M_AXI_AQOS_I = S_AXI_AQOS_Q; assign M_AXI_AUSER_I = ( C_AXI_SUPPORTS_USER_SIGNALS ) ? S_AXI_AUSER_Q : {C_AXI_AUSER_WIDTH{1'b0}}; ///////////////////////////////////////////////////////////////////////////// // Control command queue to W/R channel. // // Commands can be pushed into the Cmd FIFO even if MI-side is stalling. // A flag is set if MI-side is stalling when Command is pushed to the // Cmd FIFO. This will prevent multiple push of the same Command as well as // keeping the MI-side Valid signal if the Allow Cmd requirement has been // updated to disable furter Commands (I.e. it is made sure that the SI-side // Command has been forwarded to both Cmd FIFO and MI-side). // // It is allowed to continue pushing new commands as long as // * There is room in the queue(s) // * The ID is the same as previously queued. Since data is not reordered // for the same ID it is always OK to let them proceed. // Or, if no split transaction is ongoing any ID can be allowed. // ///////////////////////////////////////////////////////////////////////////// // Keep track of current ID in queue. always @ (posedge ACLK) begin if (ARESET) begin queue_id <= {C_AXI_ID_WIDTH{1'b0}}; multiple_id_non_split <= 1'b0; split_in_progress <= 1'b0; end else begin if ( cmd_push ) begin // Store ID (it will be matching ID or a "new beginning"). queue_id <= S_AXI_AID_Q; end if ( no_cmd & no_b_cmd ) begin multiple_id_non_split <= 1'b0; end else if ( cmd_push & allow_non_split_cmd & ~id_match ) begin multiple_id_non_split <= 1'b1; end if ( no_cmd & no_b_cmd ) begin split_in_progress <= 1'b0; end else if ( cmd_push & allow_split_cmd ) begin split_in_progress <= 1'b1; end end end // Determine if the command FIFOs are empty. assign no_cmd = almost_empty & cmd_ready | cmd_empty; assign no_b_cmd = almost_b_empty & cmd_b_ready | cmd_b_empty; // Check ID to make sure this command is allowed. assign id_match = ( C_SINGLE_THREAD == 0 ) | ( queue_id == S_AXI_AID_Q); assign cmd_id_check = (cmd_empty & cmd_b_empty) | ( id_match & (~cmd_empty | ~cmd_b_empty) ); // Command type affects possibility to push immediately or wait. assign allow_split_cmd = need_to_split_q & cmd_id_check & ~multiple_id_non_split; assign allow_non_split_cmd = ~need_to_split_q & (cmd_id_check | ~split_in_progress); assign allow_this_cmd = allow_split_cmd | allow_non_split_cmd | ( C_SINGLE_THREAD == 0 ); // Check if it is allowed to push more commands. assign allow_new_cmd = (~cmd_full & ~cmd_b_full & allow_this_cmd) | cmd_push_block; // Push new command when allowed and MI-side is able to receive the command. assign cmd_push = M_AXI_AVALID_I & ~cmd_push_block; assign cmd_b_push = M_AXI_AVALID_I & ~cmd_b_push_block & (C_AXI_CHANNEL == 0); // Block furter push until command has been forwarded to MI-side. always @ (posedge ACLK) begin if (ARESET) begin cmd_push_block <= 1'b0; end else begin if ( pushed_new_cmd ) begin cmd_push_block <= 1'b0; end else if ( cmd_push & mi_stalling ) begin cmd_push_block <= 1'b1; end end end // Block furter push until command has been forwarded to MI-side. always @ (posedge ACLK) begin if (ARESET) begin cmd_b_push_block <= 1'b0; end else begin if ( S_AXI_AREADY_I ) begin cmd_b_push_block <= 1'b0; end else if ( cmd_b_push ) begin cmd_b_push_block <= 1'b1; end end end // Acknowledge command when we can push it into queue (and forward it). assign pushed_new_cmd = M_AXI_AVALID_I & M_AXI_AREADY_I; ///////////////////////////////////////////////////////////////////////////// // Command Queue (W/R): // // Instantiate a FIFO as the queue and adjust the control signals. // // The features from Command FIFO can be reduced depending on configuration: // Read Channel only need the split information. // Write Channel always require ID information. When bursts are supported // Split and Length information is also used. // ///////////////////////////////////////////////////////////////////////////// // Instantiated queue. generate if ( C_AXI_CHANNEL == 1 && C_SUPPORT_SPLITTING == 1 && C_SUPPORT_BURSTS == 1 ) begin : USE_R_CHANNEL axi_data_fifo_v2_1_axic_fifo # ( .C_FAMILY(C_FAMILY), .C_FIFO_DEPTH_LOG(C_FIFO_DEPTH_LOG), .C_FIFO_WIDTH(1), .C_FIFO_TYPE("lut") ) cmd_queue ( .ACLK(ACLK), .ARESET(ARESET), .S_MESG({cmd_split_i}), .S_VALID(cmd_push), .S_READY(s_ready), .M_MESG({cmd_split}), .M_VALID(cmd_valid), .M_READY(cmd_ready) ); assign cmd_id = {C_AXI_ID_WIDTH{1'b0}}; assign cmd_length = 4'b0; end else if (C_SUPPORT_BURSTS == 1) begin : USE_BURSTS axi_data_fifo_v2_1_axic_fifo # ( .C_FAMILY(C_FAMILY), .C_FIFO_DEPTH_LOG(C_FIFO_DEPTH_LOG), .C_FIFO_WIDTH(C_AXI_ID_WIDTH+4), .C_FIFO_TYPE("lut") ) cmd_queue ( .ACLK(ACLK), .ARESET(ARESET), .S_MESG({cmd_id_i, cmd_length_i}), .S_VALID(cmd_push), .S_READY(s_ready), .M_MESG({cmd_id, cmd_length}), .M_VALID(cmd_valid), .M_READY(cmd_ready) ); assign cmd_split = 1'b0; end else begin : NO_BURSTS axi_data_fifo_v2_1_axic_fifo # ( .C_FAMILY(C_FAMILY), .C_FIFO_DEPTH_LOG(C_FIFO_DEPTH_LOG), .C_FIFO_WIDTH(C_AXI_ID_WIDTH), .C_FIFO_TYPE("lut") ) cmd_queue ( .ACLK(ACLK), .ARESET(ARESET), .S_MESG({cmd_id_i}), .S_VALID(cmd_push), .S_READY(s_ready), .M_MESG({cmd_id}), .M_VALID(cmd_valid), .M_READY(cmd_ready) ); assign cmd_split = 1'b0; assign cmd_length = 4'b0; end endgenerate // Queue is concidered full when not ready. assign cmd_full = ~s_ready; // Queue is empty when no data at output port. always @ (posedge ACLK) begin if (ARESET) begin cmd_empty <= 1'b1; cmd_depth <= {C_FIFO_DEPTH_LOG+1{1'b0}}; end else begin if ( cmd_push & ~cmd_ready ) begin // Push only => Increase depth. cmd_depth <= cmd_depth + 1'b1; cmd_empty <= 1'b0; end else if ( ~cmd_push & cmd_ready ) begin // Pop only => Decrease depth. cmd_depth <= cmd_depth - 1'b1; cmd_empty <= almost_empty; end end end assign almost_empty = ( cmd_depth == 1 ); ///////////////////////////////////////////////////////////////////////////// // Command Queue (B): // // Add command queue for B channel only when it is AW channel and both burst // and splitting is supported. // // When turned off the command appears always empty. // ///////////////////////////////////////////////////////////////////////////// // Instantiated queue. generate if ( C_AXI_CHANNEL == 0 && C_SUPPORT_SPLITTING == 1 && C_SUPPORT_BURSTS == 1 ) begin : USE_B_CHANNEL wire cmd_b_valid_i; wire s_b_ready; axi_data_fifo_v2_1_axic_fifo # ( .C_FAMILY(C_FAMILY), .C_FIFO_DEPTH_LOG(C_FIFO_DEPTH_LOG), .C_FIFO_WIDTH(1+4), .C_FIFO_TYPE("lut") ) cmd_b_queue ( .ACLK(ACLK), .ARESET(ARESET), .S_MESG({cmd_b_split_i, cmd_b_repeat_i}), .S_VALID(cmd_b_push), .S_READY(s_b_ready), .M_MESG({cmd_b_split, cmd_b_repeat}), .M_VALID(cmd_b_valid_i), .M_READY(cmd_b_ready) ); // Queue is concidered full when not ready. assign cmd_b_full = ~s_b_ready; // Queue is empty when no data at output port. always @ (posedge ACLK) begin if (ARESET) begin cmd_b_empty <= 1'b1; cmd_b_depth <= {C_FIFO_DEPTH_LOG+1{1'b0}}; end else begin if ( cmd_b_push & ~cmd_b_ready ) begin // Push only => Increase depth. cmd_b_depth <= cmd_b_depth + 1'b1; cmd_b_empty <= 1'b0; end else if ( ~cmd_b_push & cmd_b_ready ) begin // Pop only => Decrease depth. cmd_b_depth <= cmd_b_depth - 1'b1; cmd_b_empty <= ( cmd_b_depth == 1 ); end end end assign almost_b_empty = ( cmd_b_depth == 1 ); // Assign external signal. assign cmd_b_valid = cmd_b_valid_i; end else begin : NO_B_CHANNEL // Assign external command signals. assign cmd_b_valid = 1'b0; assign cmd_b_split = 1'b0; assign cmd_b_repeat = 4'b0; // Assign internal command FIFO signals. assign cmd_b_full = 1'b0; assign almost_b_empty = 1'b0; always @ (posedge ACLK) begin if (ARESET) begin cmd_b_empty <= 1'b1; cmd_b_depth <= {C_FIFO_DEPTH_LOG+1{1'b0}}; end else begin // Constant FF due to ModelSim behavior. cmd_b_empty <= 1'b1; cmd_b_depth <= {C_FIFO_DEPTH_LOG+1{1'b0}}; end end end endgenerate ///////////////////////////////////////////////////////////////////////////// // MI-side output handling // ///////////////////////////////////////////////////////////////////////////// assign M_AXI_AID = M_AXI_AID_I; assign M_AXI_AADDR = M_AXI_AADDR_I; assign M_AXI_ALEN = M_AXI_ALEN_I; assign M_AXI_ASIZE = M_AXI_ASIZE_I; assign M_AXI_ABURST = M_AXI_ABURST_I; assign M_AXI_ALOCK = M_AXI_ALOCK_I; assign M_AXI_ACACHE = M_AXI_ACACHE_I; assign M_AXI_APROT = M_AXI_APROT_I; assign M_AXI_AQOS = M_AXI_AQOS_I; assign M_AXI_AUSER = M_AXI_AUSER_I; assign M_AXI_AVALID = M_AXI_AVALID_I; assign M_AXI_AREADY_I = M_AXI_AREADY; endmodule
// -- (c) Copyright 2010 - 2011 Xilinx, Inc. All rights reserved. // -- // -- This file contains confidential and proprietary information // -- of Xilinx, Inc. and is protected under U.S. and // -- international copyright and other intellectual property // -- laws. // -- // -- DISCLAIMER // -- This disclaimer is not a license and does not grant any // -- rights to the materials distributed herewith. Except as // -- otherwise provided in a valid license issued to you by // -- Xilinx, and to the maximum extent permitted by applicable // -- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND // -- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES // -- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING // -- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- // -- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and // -- (2) Xilinx shall not be liable (whether in contract or tort, // -- including negligence, or under any other theory of // -- liability) for any loss or damage of any kind or nature // -- related to, arising under or in connection with these // -- materials, including for any direct, or any indirect, // -- special, incidental, or consequential loss or damage // -- (including loss of data, profits, goodwill, or any type of // -- loss or damage suffered as a result of any action brought // -- by a third party) even if such damage or loss was // -- reasonably foreseeable or Xilinx had been advised of the // -- possibility of the same. // -- // -- CRITICAL APPLICATIONS // -- Xilinx products are not designed or intended to be fail- // -- safe, or for use in any application requiring fail-safe // -- performance, such as life-support or safety devices or // -- systems, Class III medical devices, nuclear facilities, // -- applications related to the deployment of airbags, or any // -- other applications that could lead to death, personal // -- injury, or severe property or environmental damage // -- (individually and collectively, "Critical // -- Applications"). Customer assumes the sole risk and // -- liability of any use of Xilinx products in Critical // -- Applications, subject only to applicable laws and // -- regulations governing limitations on product liability. // -- // -- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS // -- PART OF THIS FILE AT ALL TIMES. //----------------------------------------------------------------------------- // // Description: Address AXI3 Slave Converter // // // Verilog-standard: Verilog 2001 //-------------------------------------------------------------------------- // // Structure: // a_axi3_conv // axic_fifo // //-------------------------------------------------------------------------- `timescale 1ps/1ps (* DowngradeIPIdentifiedWarnings="yes" *) module axi_protocol_converter_v2_1_a_axi3_conv # ( parameter C_FAMILY = "none", parameter integer C_AXI_ID_WIDTH = 1, parameter integer C_AXI_ADDR_WIDTH = 32, parameter integer C_AXI_DATA_WIDTH = 32, parameter integer C_AXI_SUPPORTS_USER_SIGNALS = 0, parameter integer C_AXI_AUSER_WIDTH = 1, parameter integer C_AXI_CHANNEL = 0, // 0 = AXI AW Channel. // 1 = AXI AR Channel. parameter integer C_SUPPORT_SPLITTING = 1, // Implement transaction splitting logic. // Disabled whan all connected masters are AXI3 and have same or narrower data width. parameter integer C_SUPPORT_BURSTS = 1, // Disabled when all connected masters are AxiLite, // allowing logic to be simplified. parameter integer C_SINGLE_THREAD = 1 // 0 = Ignore ID when propagating transactions (assume all responses are in order). // 1 = Enforce single-threading (one ID at a time) when any outstanding or // requested transaction requires splitting. // While no split is ongoing any new non-split transaction will pass immediately regardless // off ID. // A split transaction will stall if there are multiple ID (non-split) transactions // ongoing, once it has been forwarded only transactions with the same ID is allowed // (split or not) until all ongoing split transactios has been completed. ) ( // System Signals input wire ACLK, input wire ARESET, // Command Interface (W/R) output wire cmd_valid, output wire cmd_split, output wire [C_AXI_ID_WIDTH-1:0] cmd_id, output wire [4-1:0] cmd_length, input wire cmd_ready, // Command Interface (B) output wire cmd_b_valid, output wire cmd_b_split, output wire [4-1:0] cmd_b_repeat, input wire cmd_b_ready, // Slave Interface Write Address Ports input wire [C_AXI_ID_WIDTH-1:0] S_AXI_AID, input wire [C_AXI_ADDR_WIDTH-1:0] S_AXI_AADDR, input wire [8-1:0] S_AXI_ALEN, input wire [3-1:0] S_AXI_ASIZE, input wire [2-1:0] S_AXI_ABURST, input wire [1-1:0] S_AXI_ALOCK, input wire [4-1:0] S_AXI_ACACHE, input wire [3-1:0] S_AXI_APROT, input wire [4-1:0] S_AXI_AQOS, input wire [C_AXI_AUSER_WIDTH-1:0] S_AXI_AUSER, input wire S_AXI_AVALID, output wire S_AXI_AREADY, // Master Interface Write Address Port output wire [C_AXI_ID_WIDTH-1:0] M_AXI_AID, output wire [C_AXI_ADDR_WIDTH-1:0] M_AXI_AADDR, output wire [4-1:0] M_AXI_ALEN, output wire [3-1:0] M_AXI_ASIZE, output wire [2-1:0] M_AXI_ABURST, output wire [2-1:0] M_AXI_ALOCK, output wire [4-1:0] M_AXI_ACACHE, output wire [3-1:0] M_AXI_APROT, output wire [4-1:0] M_AXI_AQOS, output wire [C_AXI_AUSER_WIDTH-1:0] M_AXI_AUSER, output wire M_AXI_AVALID, input wire M_AXI_AREADY ); ///////////////////////////////////////////////////////////////////////////// // Variables for generating parameter controlled instances. ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// // Local params ///////////////////////////////////////////////////////////////////////////// // Constants for burst types. localparam [2-1:0] C_FIX_BURST = 2'b00; localparam [2-1:0] C_INCR_BURST = 2'b01; localparam [2-1:0] C_WRAP_BURST = 2'b10; // Depth for command FIFO. localparam integer C_FIFO_DEPTH_LOG = 5; // Constants used to generate size mask. localparam [C_AXI_ADDR_WIDTH+8-1:0] C_SIZE_MASK = {{C_AXI_ADDR_WIDTH{1'b1}}, 8'b0000_0000}; ///////////////////////////////////////////////////////////////////////////// // Functions ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// // Internal signals ///////////////////////////////////////////////////////////////////////////// // Access decoding related signals. wire access_is_incr; wire [4-1:0] num_transactions; wire incr_need_to_split; reg [C_AXI_ADDR_WIDTH-1:0] next_mi_addr; reg split_ongoing; reg [4-1:0] pushed_commands; reg [16-1:0] addr_step; reg [16-1:0] first_step; wire [8-1:0] first_beats; reg [C_AXI_ADDR_WIDTH-1:0] size_mask; // Access decoding related signals for internal pipestage. reg access_is_incr_q; reg incr_need_to_split_q; wire need_to_split_q; reg [4-1:0] num_transactions_q; reg [16-1:0] addr_step_q; reg [16-1:0] first_step_q; reg [C_AXI_ADDR_WIDTH-1:0] size_mask_q; // Command buffer help signals. reg [C_FIFO_DEPTH_LOG:0] cmd_depth; reg cmd_empty; reg [C_AXI_ID_WIDTH-1:0] queue_id; wire id_match; wire cmd_id_check; wire s_ready; wire cmd_full; wire allow_this_cmd; wire allow_new_cmd; wire cmd_push; reg cmd_push_block; reg [C_FIFO_DEPTH_LOG:0] cmd_b_depth; reg cmd_b_empty; wire cmd_b_full; wire cmd_b_push; reg cmd_b_push_block; wire pushed_new_cmd; wire last_incr_split; wire last_split; wire first_split; wire no_cmd; wire allow_split_cmd; wire almost_empty; wire no_b_cmd; wire allow_non_split_cmd; wire almost_b_empty; reg multiple_id_non_split; reg split_in_progress; // Internal Command Interface signals (W/R). wire cmd_split_i; wire [C_AXI_ID_WIDTH-1:0] cmd_id_i; reg [4-1:0] cmd_length_i; // Internal Command Interface signals (B). wire cmd_b_split_i; wire [4-1:0] cmd_b_repeat_i; // Throttling help signals. wire mi_stalling; reg command_ongoing; // Internal SI-side signals. reg [C_AXI_ID_WIDTH-1:0] S_AXI_AID_Q; reg [C_AXI_ADDR_WIDTH-1:0] S_AXI_AADDR_Q; reg [8-1:0] S_AXI_ALEN_Q; reg [3-1:0] S_AXI_ASIZE_Q; reg [2-1:0] S_AXI_ABURST_Q; reg [2-1:0] S_AXI_ALOCK_Q; reg [4-1:0] S_AXI_ACACHE_Q; reg [3-1:0] S_AXI_APROT_Q; reg [4-1:0] S_AXI_AQOS_Q; reg [C_AXI_AUSER_WIDTH-1:0] S_AXI_AUSER_Q; reg S_AXI_AREADY_I; // Internal MI-side signals. wire [C_AXI_ID_WIDTH-1:0] M_AXI_AID_I; reg [C_AXI_ADDR_WIDTH-1:0] M_AXI_AADDR_I; reg [8-1:0] M_AXI_ALEN_I; wire [3-1:0] M_AXI_ASIZE_I; wire [2-1:0] M_AXI_ABURST_I; reg [2-1:0] M_AXI_ALOCK_I; wire [4-1:0] M_AXI_ACACHE_I; wire [3-1:0] M_AXI_APROT_I; wire [4-1:0] M_AXI_AQOS_I; wire [C_AXI_AUSER_WIDTH-1:0] M_AXI_AUSER_I; wire M_AXI_AVALID_I; wire M_AXI_AREADY_I; reg [1:0] areset_d; // Reset delay register always @(posedge ACLK) begin areset_d <= {areset_d[0], ARESET}; end ///////////////////////////////////////////////////////////////////////////// // Capture SI-Side signals. // ///////////////////////////////////////////////////////////////////////////// // Register SI-Side signals. always @ (posedge ACLK) begin if ( ARESET ) begin S_AXI_AID_Q <= {C_AXI_ID_WIDTH{1'b0}}; S_AXI_AADDR_Q <= {C_AXI_ADDR_WIDTH{1'b0}}; S_AXI_ALEN_Q <= 8'b0; S_AXI_ASIZE_Q <= 3'b0; S_AXI_ABURST_Q <= 2'b0; S_AXI_ALOCK_Q <= 2'b0; S_AXI_ACACHE_Q <= 4'b0; S_AXI_APROT_Q <= 3'b0; S_AXI_AQOS_Q <= 4'b0; S_AXI_AUSER_Q <= {C_AXI_AUSER_WIDTH{1'b0}}; end else begin if ( S_AXI_AREADY_I ) begin S_AXI_AID_Q <= S_AXI_AID; S_AXI_AADDR_Q <= S_AXI_AADDR; S_AXI_ALEN_Q <= S_AXI_ALEN; S_AXI_ASIZE_Q <= S_AXI_ASIZE; S_AXI_ABURST_Q <= S_AXI_ABURST; S_AXI_ALOCK_Q <= S_AXI_ALOCK; S_AXI_ACACHE_Q <= S_AXI_ACACHE; S_AXI_APROT_Q <= S_AXI_APROT; S_AXI_AQOS_Q <= S_AXI_AQOS; S_AXI_AUSER_Q <= S_AXI_AUSER; end end end ///////////////////////////////////////////////////////////////////////////// // Decode the Incoming Transaction. // // Extract transaction type and the number of splits that may be needed. // // Calculate the step size so that the address for each part of a split can // can be calculated. // ///////////////////////////////////////////////////////////////////////////// // Transaction burst type. assign access_is_incr = ( S_AXI_ABURST == C_INCR_BURST ); // Get number of transactions for split INCR. assign num_transactions = S_AXI_ALEN[4 +: 4]; assign first_beats = {3'b0, S_AXI_ALEN[0 +: 4]} + 7'b01; // Generate address increment of first split transaction. always @ * begin case (S_AXI_ASIZE) 3'b000: first_step = first_beats << 0; 3'b001: first_step = first_beats << 1; 3'b010: first_step = first_beats << 2; 3'b011: first_step = first_beats << 3; 3'b100: first_step = first_beats << 4; 3'b101: first_step = first_beats << 5; 3'b110: first_step = first_beats << 6; 3'b111: first_step = first_beats << 7; endcase end // Generate address increment for remaining split transactions. always @ * begin case (S_AXI_ASIZE) 3'b000: addr_step = 16'h0010; 3'b001: addr_step = 16'h0020; 3'b010: addr_step = 16'h0040; 3'b011: addr_step = 16'h0080; 3'b100: addr_step = 16'h0100; 3'b101: addr_step = 16'h0200; 3'b110: addr_step = 16'h0400; 3'b111: addr_step = 16'h0800; endcase end // Generate address mask bits to remove split transaction unalignment. always @ * begin case (S_AXI_ASIZE) 3'b000: size_mask = C_SIZE_MASK[8 +: C_AXI_ADDR_WIDTH]; 3'b001: size_mask = C_SIZE_MASK[7 +: C_AXI_ADDR_WIDTH]; 3'b010: size_mask = C_SIZE_MASK[6 +: C_AXI_ADDR_WIDTH]; 3'b011: size_mask = C_SIZE_MASK[5 +: C_AXI_ADDR_WIDTH]; 3'b100: size_mask = C_SIZE_MASK[4 +: C_AXI_ADDR_WIDTH]; 3'b101: size_mask = C_SIZE_MASK[3 +: C_AXI_ADDR_WIDTH]; 3'b110: size_mask = C_SIZE_MASK[2 +: C_AXI_ADDR_WIDTH]; 3'b111: size_mask = C_SIZE_MASK[1 +: C_AXI_ADDR_WIDTH]; endcase end ///////////////////////////////////////////////////////////////////////////// // Transfer SI-Side signals to internal Pipeline Stage. // ///////////////////////////////////////////////////////////////////////////// always @ (posedge ACLK) begin if ( ARESET ) begin access_is_incr_q <= 1'b0; incr_need_to_split_q <= 1'b0; num_transactions_q <= 4'b0; addr_step_q <= 16'b0; first_step_q <= 16'b0; size_mask_q <= {C_AXI_ADDR_WIDTH{1'b0}}; end else begin if ( S_AXI_AREADY_I ) begin access_is_incr_q <= access_is_incr; incr_need_to_split_q <= incr_need_to_split; num_transactions_q <= num_transactions; addr_step_q <= addr_step; first_step_q <= first_step; size_mask_q <= size_mask; end end end ///////////////////////////////////////////////////////////////////////////// // Generate Command Information. // // Detect if current transation needs to be split, and keep track of all // the generated split transactions. // // ///////////////////////////////////////////////////////////////////////////// // Detect when INCR must be split. assign incr_need_to_split = access_is_incr & ( num_transactions != 0 ) & ( C_SUPPORT_SPLITTING == 1 ) & ( C_SUPPORT_BURSTS == 1 ); // Detect when a command has to be split. assign need_to_split_q = incr_need_to_split_q; // Handle progress of split transactions. always @ (posedge ACLK) begin if ( ARESET ) begin split_ongoing <= 1'b0; end else begin if ( pushed_new_cmd ) begin split_ongoing <= need_to_split_q & ~last_split; end end end // Keep track of number of transactions generated. always @ (posedge ACLK) begin if ( ARESET ) begin pushed_commands <= 4'b0; end else begin if ( S_AXI_AREADY_I ) begin pushed_commands <= 4'b0; end else if ( pushed_new_cmd ) begin pushed_commands <= pushed_commands + 4'b1; end end end // Detect last part of a command, split or not. assign last_incr_split = access_is_incr_q & ( num_transactions_q == pushed_commands ); assign last_split = last_incr_split | ~access_is_incr_q | ( C_SUPPORT_SPLITTING == 0 ) | ( C_SUPPORT_BURSTS == 0 ); assign first_split = (pushed_commands == 4'b0); // Calculate base for next address. always @ (posedge ACLK) begin if ( ARESET ) begin next_mi_addr = {C_AXI_ADDR_WIDTH{1'b0}}; end else if ( pushed_new_cmd ) begin next_mi_addr = M_AXI_AADDR_I + (first_split ? first_step_q : addr_step_q); end end ///////////////////////////////////////////////////////////////////////////// // Translating Transaction. // // Set Split transaction information on all part except last for a transaction // that needs splitting. // The B Channel will only get one command for a Split transaction and in // the Split bflag will be set in that case. // // The AWID is extracted and applied to all commands generated for the current // incomming SI-Side transaction. // // The address is increased for each part of a Split transaction, the amount // depends on the siSIZE for the transaction. // // The length has to be changed for Split transactions. All part except tha // last one will have 0xF, the last one uses the 4 lsb bits from the SI-side // transaction as length. // // Non-Split has untouched address and length information. // // Exclusive access are diasabled for a Split transaction because it is not // possible to guarantee concistency between all the parts. // ///////////////////////////////////////////////////////////////////////////// // Assign Split signals. assign cmd_split_i = need_to_split_q & ~last_split; assign cmd_b_split_i = need_to_split_q & ~last_split; // Copy AW ID to W. assign cmd_id_i = S_AXI_AID_Q; // Set B Responses to merge. assign cmd_b_repeat_i = num_transactions_q; // Select new size or remaining size. always @ * begin if ( split_ongoing & access_is_incr_q ) begin M_AXI_AADDR_I = next_mi_addr & size_mask_q; end else begin M_AXI_AADDR_I = S_AXI_AADDR_Q; end end // Generate the base length for each transaction. always @ * begin if ( first_split | ~need_to_split_q ) begin M_AXI_ALEN_I = S_AXI_ALEN_Q[0 +: 4]; cmd_length_i = S_AXI_ALEN_Q[0 +: 4]; end else begin M_AXI_ALEN_I = 4'hF; cmd_length_i = 4'hF; end end // Kill Exclusive for Split transactions. always @ * begin if ( need_to_split_q ) begin M_AXI_ALOCK_I = 2'b00; end else begin M_AXI_ALOCK_I = {1'b0, S_AXI_ALOCK_Q}; end end ///////////////////////////////////////////////////////////////////////////// // Forward the command to the MI-side interface. // // It is determined that this is an allowed command/access when there is // room in the command queue (and it passes ID and Split checks as required). // ///////////////////////////////////////////////////////////////////////////// // Move SI-side transaction to internal pipe stage. always @ (posedge ACLK) begin if (ARESET) begin command_ongoing <= 1'b0; S_AXI_AREADY_I <= 1'b0; end else begin if (areset_d == 2'b10) begin S_AXI_AREADY_I <= 1'b1; end else begin if ( S_AXI_AVALID & S_AXI_AREADY_I ) begin command_ongoing <= 1'b1; S_AXI_AREADY_I <= 1'b0; end else if ( pushed_new_cmd & last_split ) begin command_ongoing <= 1'b0; S_AXI_AREADY_I <= 1'b1; end end end end // Generate ready signal. assign S_AXI_AREADY = S_AXI_AREADY_I; // Only allowed to forward translated command when command queue is ok with it. assign M_AXI_AVALID_I = allow_new_cmd & command_ongoing; // Detect when MI-side is stalling. assign mi_stalling = M_AXI_AVALID_I & ~M_AXI_AREADY_I; ///////////////////////////////////////////////////////////////////////////// // Simple transfer of paramters that doesn't need to be adjusted. // // ID - Transaction still recognized with the same ID. // CACHE - No need to change the chache features. Even if the modyfiable // bit is overridden (forcefully) there is no need to let downstream // component beleive it is ok to modify it further. // PROT - Security level of access is not changed when upsizing. // QOS - Quality of Service is static 0. // USER - User bits remains the same. // ///////////////////////////////////////////////////////////////////////////// assign M_AXI_AID_I = S_AXI_AID_Q; assign M_AXI_ASIZE_I = S_AXI_ASIZE_Q; assign M_AXI_ABURST_I = S_AXI_ABURST_Q; assign M_AXI_ACACHE_I = S_AXI_ACACHE_Q; assign M_AXI_APROT_I = S_AXI_APROT_Q; assign M_AXI_AQOS_I = S_AXI_AQOS_Q; assign M_AXI_AUSER_I = ( C_AXI_SUPPORTS_USER_SIGNALS ) ? S_AXI_AUSER_Q : {C_AXI_AUSER_WIDTH{1'b0}}; ///////////////////////////////////////////////////////////////////////////// // Control command queue to W/R channel. // // Commands can be pushed into the Cmd FIFO even if MI-side is stalling. // A flag is set if MI-side is stalling when Command is pushed to the // Cmd FIFO. This will prevent multiple push of the same Command as well as // keeping the MI-side Valid signal if the Allow Cmd requirement has been // updated to disable furter Commands (I.e. it is made sure that the SI-side // Command has been forwarded to both Cmd FIFO and MI-side). // // It is allowed to continue pushing new commands as long as // * There is room in the queue(s) // * The ID is the same as previously queued. Since data is not reordered // for the same ID it is always OK to let them proceed. // Or, if no split transaction is ongoing any ID can be allowed. // ///////////////////////////////////////////////////////////////////////////// // Keep track of current ID in queue. always @ (posedge ACLK) begin if (ARESET) begin queue_id <= {C_AXI_ID_WIDTH{1'b0}}; multiple_id_non_split <= 1'b0; split_in_progress <= 1'b0; end else begin if ( cmd_push ) begin // Store ID (it will be matching ID or a "new beginning"). queue_id <= S_AXI_AID_Q; end if ( no_cmd & no_b_cmd ) begin multiple_id_non_split <= 1'b0; end else if ( cmd_push & allow_non_split_cmd & ~id_match ) begin multiple_id_non_split <= 1'b1; end if ( no_cmd & no_b_cmd ) begin split_in_progress <= 1'b0; end else if ( cmd_push & allow_split_cmd ) begin split_in_progress <= 1'b1; end end end // Determine if the command FIFOs are empty. assign no_cmd = almost_empty & cmd_ready | cmd_empty; assign no_b_cmd = almost_b_empty & cmd_b_ready | cmd_b_empty; // Check ID to make sure this command is allowed. assign id_match = ( C_SINGLE_THREAD == 0 ) | ( queue_id == S_AXI_AID_Q); assign cmd_id_check = (cmd_empty & cmd_b_empty) | ( id_match & (~cmd_empty | ~cmd_b_empty) ); // Command type affects possibility to push immediately or wait. assign allow_split_cmd = need_to_split_q & cmd_id_check & ~multiple_id_non_split; assign allow_non_split_cmd = ~need_to_split_q & (cmd_id_check | ~split_in_progress); assign allow_this_cmd = allow_split_cmd | allow_non_split_cmd | ( C_SINGLE_THREAD == 0 ); // Check if it is allowed to push more commands. assign allow_new_cmd = (~cmd_full & ~cmd_b_full & allow_this_cmd) | cmd_push_block; // Push new command when allowed and MI-side is able to receive the command. assign cmd_push = M_AXI_AVALID_I & ~cmd_push_block; assign cmd_b_push = M_AXI_AVALID_I & ~cmd_b_push_block & (C_AXI_CHANNEL == 0); // Block furter push until command has been forwarded to MI-side. always @ (posedge ACLK) begin if (ARESET) begin cmd_push_block <= 1'b0; end else begin if ( pushed_new_cmd ) begin cmd_push_block <= 1'b0; end else if ( cmd_push & mi_stalling ) begin cmd_push_block <= 1'b1; end end end // Block furter push until command has been forwarded to MI-side. always @ (posedge ACLK) begin if (ARESET) begin cmd_b_push_block <= 1'b0; end else begin if ( S_AXI_AREADY_I ) begin cmd_b_push_block <= 1'b0; end else if ( cmd_b_push ) begin cmd_b_push_block <= 1'b1; end end end // Acknowledge command when we can push it into queue (and forward it). assign pushed_new_cmd = M_AXI_AVALID_I & M_AXI_AREADY_I; ///////////////////////////////////////////////////////////////////////////// // Command Queue (W/R): // // Instantiate a FIFO as the queue and adjust the control signals. // // The features from Command FIFO can be reduced depending on configuration: // Read Channel only need the split information. // Write Channel always require ID information. When bursts are supported // Split and Length information is also used. // ///////////////////////////////////////////////////////////////////////////// // Instantiated queue. generate if ( C_AXI_CHANNEL == 1 && C_SUPPORT_SPLITTING == 1 && C_SUPPORT_BURSTS == 1 ) begin : USE_R_CHANNEL axi_data_fifo_v2_1_axic_fifo # ( .C_FAMILY(C_FAMILY), .C_FIFO_DEPTH_LOG(C_FIFO_DEPTH_LOG), .C_FIFO_WIDTH(1), .C_FIFO_TYPE("lut") ) cmd_queue ( .ACLK(ACLK), .ARESET(ARESET), .S_MESG({cmd_split_i}), .S_VALID(cmd_push), .S_READY(s_ready), .M_MESG({cmd_split}), .M_VALID(cmd_valid), .M_READY(cmd_ready) ); assign cmd_id = {C_AXI_ID_WIDTH{1'b0}}; assign cmd_length = 4'b0; end else if (C_SUPPORT_BURSTS == 1) begin : USE_BURSTS axi_data_fifo_v2_1_axic_fifo # ( .C_FAMILY(C_FAMILY), .C_FIFO_DEPTH_LOG(C_FIFO_DEPTH_LOG), .C_FIFO_WIDTH(C_AXI_ID_WIDTH+4), .C_FIFO_TYPE("lut") ) cmd_queue ( .ACLK(ACLK), .ARESET(ARESET), .S_MESG({cmd_id_i, cmd_length_i}), .S_VALID(cmd_push), .S_READY(s_ready), .M_MESG({cmd_id, cmd_length}), .M_VALID(cmd_valid), .M_READY(cmd_ready) ); assign cmd_split = 1'b0; end else begin : NO_BURSTS axi_data_fifo_v2_1_axic_fifo # ( .C_FAMILY(C_FAMILY), .C_FIFO_DEPTH_LOG(C_FIFO_DEPTH_LOG), .C_FIFO_WIDTH(C_AXI_ID_WIDTH), .C_FIFO_TYPE("lut") ) cmd_queue ( .ACLK(ACLK), .ARESET(ARESET), .S_MESG({cmd_id_i}), .S_VALID(cmd_push), .S_READY(s_ready), .M_MESG({cmd_id}), .M_VALID(cmd_valid), .M_READY(cmd_ready) ); assign cmd_split = 1'b0; assign cmd_length = 4'b0; end endgenerate // Queue is concidered full when not ready. assign cmd_full = ~s_ready; // Queue is empty when no data at output port. always @ (posedge ACLK) begin if (ARESET) begin cmd_empty <= 1'b1; cmd_depth <= {C_FIFO_DEPTH_LOG+1{1'b0}}; end else begin if ( cmd_push & ~cmd_ready ) begin // Push only => Increase depth. cmd_depth <= cmd_depth + 1'b1; cmd_empty <= 1'b0; end else if ( ~cmd_push & cmd_ready ) begin // Pop only => Decrease depth. cmd_depth <= cmd_depth - 1'b1; cmd_empty <= almost_empty; end end end assign almost_empty = ( cmd_depth == 1 ); ///////////////////////////////////////////////////////////////////////////// // Command Queue (B): // // Add command queue for B channel only when it is AW channel and both burst // and splitting is supported. // // When turned off the command appears always empty. // ///////////////////////////////////////////////////////////////////////////// // Instantiated queue. generate if ( C_AXI_CHANNEL == 0 && C_SUPPORT_SPLITTING == 1 && C_SUPPORT_BURSTS == 1 ) begin : USE_B_CHANNEL wire cmd_b_valid_i; wire s_b_ready; axi_data_fifo_v2_1_axic_fifo # ( .C_FAMILY(C_FAMILY), .C_FIFO_DEPTH_LOG(C_FIFO_DEPTH_LOG), .C_FIFO_WIDTH(1+4), .C_FIFO_TYPE("lut") ) cmd_b_queue ( .ACLK(ACLK), .ARESET(ARESET), .S_MESG({cmd_b_split_i, cmd_b_repeat_i}), .S_VALID(cmd_b_push), .S_READY(s_b_ready), .M_MESG({cmd_b_split, cmd_b_repeat}), .M_VALID(cmd_b_valid_i), .M_READY(cmd_b_ready) ); // Queue is concidered full when not ready. assign cmd_b_full = ~s_b_ready; // Queue is empty when no data at output port. always @ (posedge ACLK) begin if (ARESET) begin cmd_b_empty <= 1'b1; cmd_b_depth <= {C_FIFO_DEPTH_LOG+1{1'b0}}; end else begin if ( cmd_b_push & ~cmd_b_ready ) begin // Push only => Increase depth. cmd_b_depth <= cmd_b_depth + 1'b1; cmd_b_empty <= 1'b0; end else if ( ~cmd_b_push & cmd_b_ready ) begin // Pop only => Decrease depth. cmd_b_depth <= cmd_b_depth - 1'b1; cmd_b_empty <= ( cmd_b_depth == 1 ); end end end assign almost_b_empty = ( cmd_b_depth == 1 ); // Assign external signal. assign cmd_b_valid = cmd_b_valid_i; end else begin : NO_B_CHANNEL // Assign external command signals. assign cmd_b_valid = 1'b0; assign cmd_b_split = 1'b0; assign cmd_b_repeat = 4'b0; // Assign internal command FIFO signals. assign cmd_b_full = 1'b0; assign almost_b_empty = 1'b0; always @ (posedge ACLK) begin if (ARESET) begin cmd_b_empty <= 1'b1; cmd_b_depth <= {C_FIFO_DEPTH_LOG+1{1'b0}}; end else begin // Constant FF due to ModelSim behavior. cmd_b_empty <= 1'b1; cmd_b_depth <= {C_FIFO_DEPTH_LOG+1{1'b0}}; end end end endgenerate ///////////////////////////////////////////////////////////////////////////// // MI-side output handling // ///////////////////////////////////////////////////////////////////////////// assign M_AXI_AID = M_AXI_AID_I; assign M_AXI_AADDR = M_AXI_AADDR_I; assign M_AXI_ALEN = M_AXI_ALEN_I; assign M_AXI_ASIZE = M_AXI_ASIZE_I; assign M_AXI_ABURST = M_AXI_ABURST_I; assign M_AXI_ALOCK = M_AXI_ALOCK_I; assign M_AXI_ACACHE = M_AXI_ACACHE_I; assign M_AXI_APROT = M_AXI_APROT_I; assign M_AXI_AQOS = M_AXI_AQOS_I; assign M_AXI_AUSER = M_AXI_AUSER_I; assign M_AXI_AVALID = M_AXI_AVALID_I; assign M_AXI_AREADY_I = M_AXI_AREADY; endmodule
// This is a component of pluto_servo, a PWM servo driver and quadrature // counter for emc2 // Copyright 2006 Jeff Epler <[email protected]> // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1507 USA module quad(clk, A, B, Z, zr, out); parameter W=14; input clk, A, B, Z, zr; reg [(W-1):0] c, i; reg zl; output [2*W:0] out = { zl, i, c }; // reg [(W-1):0] c, i; reg zl; reg [2:0] Ad, Bd; reg [2:0] Zc; always @(posedge clk) Ad <= {Ad[1:0], A}; always @(posedge clk) Bd <= {Bd[1:0], B}; wire good_one = &Zc; wire good_zero = ~|Zc; reg last_good; wire index_pulse = good_one && ! last_good; wire count_enable = Ad[1] ^ Ad[2] ^ Bd[1] ^ Bd[2]; wire count_direction = Ad[1] ^ Bd[2]; always @(posedge clk) begin if(Z && !good_one) Zc <= Zc + 2'b1; else if(!good_zero) Zc <= Zc - 2'b1; if(good_one) last_good <= 1; else if(good_zero) last_good <= 0; if(count_enable) begin if(count_direction) c <= c + 1'd1; else c <= c - 1'd1; end if(index_pulse) begin i <= c; zl <= 1; end else if(zr) begin zl <= 0; end end endmodule
// This is a component of pluto_servo, a PWM servo driver and quadrature // counter for emc2 // Copyright 2006 Jeff Epler <[email protected]> // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1507 USA module quad(clk, A, B, Z, zr, out); parameter W=14; input clk, A, B, Z, zr; reg [(W-1):0] c, i; reg zl; output [2*W:0] out = { zl, i, c }; // reg [(W-1):0] c, i; reg zl; reg [2:0] Ad, Bd; reg [2:0] Zc; always @(posedge clk) Ad <= {Ad[1:0], A}; always @(posedge clk) Bd <= {Bd[1:0], B}; wire good_one = &Zc; wire good_zero = ~|Zc; reg last_good; wire index_pulse = good_one && ! last_good; wire count_enable = Ad[1] ^ Ad[2] ^ Bd[1] ^ Bd[2]; wire count_direction = Ad[1] ^ Bd[2]; always @(posedge clk) begin if(Z && !good_one) Zc <= Zc + 2'b1; else if(!good_zero) Zc <= Zc - 2'b1; if(good_one) last_good <= 1; else if(good_zero) last_good <= 0; if(count_enable) begin if(count_direction) c <= c + 1'd1; else c <= c - 1'd1; end if(index_pulse) begin i <= c; zl <= 1; end else if(zr) begin zl <= 0; end end endmodule
// This is a component of pluto_servo, a PWM servo driver and quadrature // counter for emc2 // Copyright 2006 Jeff Epler <[email protected]> // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1507 USA module quad(clk, A, B, Z, zr, out); parameter W=14; input clk, A, B, Z, zr; reg [(W-1):0] c, i; reg zl; output [2*W:0] out = { zl, i, c }; // reg [(W-1):0] c, i; reg zl; reg [2:0] Ad, Bd; reg [2:0] Zc; always @(posedge clk) Ad <= {Ad[1:0], A}; always @(posedge clk) Bd <= {Bd[1:0], B}; wire good_one = &Zc; wire good_zero = ~|Zc; reg last_good; wire index_pulse = good_one && ! last_good; wire count_enable = Ad[1] ^ Ad[2] ^ Bd[1] ^ Bd[2]; wire count_direction = Ad[1] ^ Bd[2]; always @(posedge clk) begin if(Z && !good_one) Zc <= Zc + 2'b1; else if(!good_zero) Zc <= Zc - 2'b1; if(good_one) last_good <= 1; else if(good_zero) last_good <= 0; if(count_enable) begin if(count_direction) c <= c + 1'd1; else c <= c - 1'd1; end if(index_pulse) begin i <= c; zl <= 1; end else if(zr) begin zl <= 0; end end endmodule
// This is a component of pluto_servo, a PWM servo driver and quadrature // counter for emc2 // Copyright 2006 Jeff Epler <[email protected]> // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1507 USA module quad(clk, A, B, Z, zr, out); parameter W=14; input clk, A, B, Z, zr; reg [(W-1):0] c, i; reg zl; output [2*W:0] out = { zl, i, c }; // reg [(W-1):0] c, i; reg zl; reg [2:0] Ad, Bd; reg [2:0] Zc; always @(posedge clk) Ad <= {Ad[1:0], A}; always @(posedge clk) Bd <= {Bd[1:0], B}; wire good_one = &Zc; wire good_zero = ~|Zc; reg last_good; wire index_pulse = good_one && ! last_good; wire count_enable = Ad[1] ^ Ad[2] ^ Bd[1] ^ Bd[2]; wire count_direction = Ad[1] ^ Bd[2]; always @(posedge clk) begin if(Z && !good_one) Zc <= Zc + 2'b1; else if(!good_zero) Zc <= Zc - 2'b1; if(good_one) last_good <= 1; else if(good_zero) last_good <= 0; if(count_enable) begin if(count_direction) c <= c + 1'd1; else c <= c - 1'd1; end if(index_pulse) begin i <= c; zl <= 1; end else if(zr) begin zl <= 0; end end endmodule
// This is a component of pluto_servo, a PWM servo driver and quadrature // counter for emc2 // Copyright 2006 Jeff Epler <[email protected]> // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1507 USA module quad(clk, A, B, Z, zr, out); parameter W=14; input clk, A, B, Z, zr; reg [(W-1):0] c, i; reg zl; output [2*W:0] out = { zl, i, c }; // reg [(W-1):0] c, i; reg zl; reg [2:0] Ad, Bd; reg [2:0] Zc; always @(posedge clk) Ad <= {Ad[1:0], A}; always @(posedge clk) Bd <= {Bd[1:0], B}; wire good_one = &Zc; wire good_zero = ~|Zc; reg last_good; wire index_pulse = good_one && ! last_good; wire count_enable = Ad[1] ^ Ad[2] ^ Bd[1] ^ Bd[2]; wire count_direction = Ad[1] ^ Bd[2]; always @(posedge clk) begin if(Z && !good_one) Zc <= Zc + 2'b1; else if(!good_zero) Zc <= Zc - 2'b1; if(good_one) last_good <= 1; else if(good_zero) last_good <= 0; if(count_enable) begin if(count_direction) c <= c + 1'd1; else c <= c - 1'd1; end if(index_pulse) begin i <= c; zl <= 1; end else if(zr) begin zl <= 0; end end endmodule
/////////////////////////////////////////////////////////////////////////////// // // File name: axi_protocol_converter_v2_1_b2s_wr_cmd_fsm.v // /////////////////////////////////////////////////////////////////////////////// `timescale 1ps/1ps `default_nettype none (* DowngradeIPIdentifiedWarnings="yes" *) module axi_protocol_converter_v2_1_b2s_wr_cmd_fsm ( /////////////////////////////////////////////////////////////////////////////// // Port Declarations /////////////////////////////////////////////////////////////////////////////// input wire clk , input wire reset , output wire s_awready , input wire s_awvalid , output wire m_awvalid , input wire m_awready , // signal to increment to the next mc transaction output wire next , // signal to the fsm there is another transaction required input wire next_pending , // Write Data portion has completed or Read FIFO has a slot available (not // full) output wire b_push , input wire b_full , output wire a_push ); //////////////////////////////////////////////////////////////////////////////// // Local parameters //////////////////////////////////////////////////////////////////////////////// // States localparam SM_IDLE = 2'b00; localparam SM_CMD_EN = 2'b01; localparam SM_CMD_ACCEPTED = 2'b10; localparam SM_DONE_WAIT = 2'b11; //////////////////////////////////////////////////////////////////////////////// // Wires/Reg declarations //////////////////////////////////////////////////////////////////////////////// reg [1:0] state; // synthesis attribute MAX_FANOUT of state is 20; reg [1:0] next_state; //////////////////////////////////////////////////////////////////////////////// // BEGIN RTL /////////////////////////////////////////////////////////////////////////////// always @(posedge clk) begin if (reset) begin state <= SM_IDLE; end else begin state <= next_state; end end // Next state transitions. always @( * ) begin next_state = state; case (state) SM_IDLE: if (s_awvalid) begin next_state = SM_CMD_EN; end else next_state = state; SM_CMD_EN: if (m_awready & next_pending) next_state = SM_CMD_ACCEPTED; else if (m_awready & ~next_pending & b_full) next_state = SM_DONE_WAIT; else if (m_awready & ~next_pending & ~b_full) next_state = SM_IDLE; else next_state = state; SM_CMD_ACCEPTED: next_state = SM_CMD_EN; SM_DONE_WAIT: if (!b_full) next_state = SM_IDLE; else next_state = state; default: next_state = SM_IDLE; endcase end // Assign outputs based on current state. assign m_awvalid = (state == SM_CMD_EN); assign next = ((state == SM_CMD_ACCEPTED) | (((state == SM_CMD_EN) | (state == SM_DONE_WAIT)) & (next_state == SM_IDLE))) ; assign a_push = (state == SM_IDLE); assign s_awready = ((state == SM_CMD_EN) | (state == SM_DONE_WAIT)) & (next_state == SM_IDLE); assign b_push = ((state == SM_CMD_EN) | (state == SM_DONE_WAIT)) & (next_state == SM_IDLE); endmodule `default_nettype wire
/////////////////////////////////////////////////////////////////////////////// // // File name: axi_protocol_converter_v2_1_b2s_wr_cmd_fsm.v // /////////////////////////////////////////////////////////////////////////////// `timescale 1ps/1ps `default_nettype none (* DowngradeIPIdentifiedWarnings="yes" *) module axi_protocol_converter_v2_1_b2s_wr_cmd_fsm ( /////////////////////////////////////////////////////////////////////////////// // Port Declarations /////////////////////////////////////////////////////////////////////////////// input wire clk , input wire reset , output wire s_awready , input wire s_awvalid , output wire m_awvalid , input wire m_awready , // signal to increment to the next mc transaction output wire next , // signal to the fsm there is another transaction required input wire next_pending , // Write Data portion has completed or Read FIFO has a slot available (not // full) output wire b_push , input wire b_full , output wire a_push ); //////////////////////////////////////////////////////////////////////////////// // Local parameters //////////////////////////////////////////////////////////////////////////////// // States localparam SM_IDLE = 2'b00; localparam SM_CMD_EN = 2'b01; localparam SM_CMD_ACCEPTED = 2'b10; localparam SM_DONE_WAIT = 2'b11; //////////////////////////////////////////////////////////////////////////////// // Wires/Reg declarations //////////////////////////////////////////////////////////////////////////////// reg [1:0] state; // synthesis attribute MAX_FANOUT of state is 20; reg [1:0] next_state; //////////////////////////////////////////////////////////////////////////////// // BEGIN RTL /////////////////////////////////////////////////////////////////////////////// always @(posedge clk) begin if (reset) begin state <= SM_IDLE; end else begin state <= next_state; end end // Next state transitions. always @( * ) begin next_state = state; case (state) SM_IDLE: if (s_awvalid) begin next_state = SM_CMD_EN; end else next_state = state; SM_CMD_EN: if (m_awready & next_pending) next_state = SM_CMD_ACCEPTED; else if (m_awready & ~next_pending & b_full) next_state = SM_DONE_WAIT; else if (m_awready & ~next_pending & ~b_full) next_state = SM_IDLE; else next_state = state; SM_CMD_ACCEPTED: next_state = SM_CMD_EN; SM_DONE_WAIT: if (!b_full) next_state = SM_IDLE; else next_state = state; default: next_state = SM_IDLE; endcase end // Assign outputs based on current state. assign m_awvalid = (state == SM_CMD_EN); assign next = ((state == SM_CMD_ACCEPTED) | (((state == SM_CMD_EN) | (state == SM_DONE_WAIT)) & (next_state == SM_IDLE))) ; assign a_push = (state == SM_IDLE); assign s_awready = ((state == SM_CMD_EN) | (state == SM_DONE_WAIT)) & (next_state == SM_IDLE); assign b_push = ((state == SM_CMD_EN) | (state == SM_DONE_WAIT)) & (next_state == SM_IDLE); endmodule `default_nettype wire
/////////////////////////////////////////////////////////////////////////////// // // File name: axi_protocol_converter_v2_1_b2s_wr_cmd_fsm.v // /////////////////////////////////////////////////////////////////////////////// `timescale 1ps/1ps `default_nettype none (* DowngradeIPIdentifiedWarnings="yes" *) module axi_protocol_converter_v2_1_b2s_wr_cmd_fsm ( /////////////////////////////////////////////////////////////////////////////// // Port Declarations /////////////////////////////////////////////////////////////////////////////// input wire clk , input wire reset , output wire s_awready , input wire s_awvalid , output wire m_awvalid , input wire m_awready , // signal to increment to the next mc transaction output wire next , // signal to the fsm there is another transaction required input wire next_pending , // Write Data portion has completed or Read FIFO has a slot available (not // full) output wire b_push , input wire b_full , output wire a_push ); //////////////////////////////////////////////////////////////////////////////// // Local parameters //////////////////////////////////////////////////////////////////////////////// // States localparam SM_IDLE = 2'b00; localparam SM_CMD_EN = 2'b01; localparam SM_CMD_ACCEPTED = 2'b10; localparam SM_DONE_WAIT = 2'b11; //////////////////////////////////////////////////////////////////////////////// // Wires/Reg declarations //////////////////////////////////////////////////////////////////////////////// reg [1:0] state; // synthesis attribute MAX_FANOUT of state is 20; reg [1:0] next_state; //////////////////////////////////////////////////////////////////////////////// // BEGIN RTL /////////////////////////////////////////////////////////////////////////////// always @(posedge clk) begin if (reset) begin state <= SM_IDLE; end else begin state <= next_state; end end // Next state transitions. always @( * ) begin next_state = state; case (state) SM_IDLE: if (s_awvalid) begin next_state = SM_CMD_EN; end else next_state = state; SM_CMD_EN: if (m_awready & next_pending) next_state = SM_CMD_ACCEPTED; else if (m_awready & ~next_pending & b_full) next_state = SM_DONE_WAIT; else if (m_awready & ~next_pending & ~b_full) next_state = SM_IDLE; else next_state = state; SM_CMD_ACCEPTED: next_state = SM_CMD_EN; SM_DONE_WAIT: if (!b_full) next_state = SM_IDLE; else next_state = state; default: next_state = SM_IDLE; endcase end // Assign outputs based on current state. assign m_awvalid = (state == SM_CMD_EN); assign next = ((state == SM_CMD_ACCEPTED) | (((state == SM_CMD_EN) | (state == SM_DONE_WAIT)) & (next_state == SM_IDLE))) ; assign a_push = (state == SM_IDLE); assign s_awready = ((state == SM_CMD_EN) | (state == SM_DONE_WAIT)) & (next_state == SM_IDLE); assign b_push = ((state == SM_CMD_EN) | (state == SM_DONE_WAIT)) & (next_state == SM_IDLE); endmodule `default_nettype wire
/////////////////////////////////////////////////////////////////////////////// // // File name: axi_protocol_converter_v2_1_b2s_wr_cmd_fsm.v // /////////////////////////////////////////////////////////////////////////////// `timescale 1ps/1ps `default_nettype none (* DowngradeIPIdentifiedWarnings="yes" *) module axi_protocol_converter_v2_1_b2s_wr_cmd_fsm ( /////////////////////////////////////////////////////////////////////////////// // Port Declarations /////////////////////////////////////////////////////////////////////////////// input wire clk , input wire reset , output wire s_awready , input wire s_awvalid , output wire m_awvalid , input wire m_awready , // signal to increment to the next mc transaction output wire next , // signal to the fsm there is another transaction required input wire next_pending , // Write Data portion has completed or Read FIFO has a slot available (not // full) output wire b_push , input wire b_full , output wire a_push ); //////////////////////////////////////////////////////////////////////////////// // Local parameters //////////////////////////////////////////////////////////////////////////////// // States localparam SM_IDLE = 2'b00; localparam SM_CMD_EN = 2'b01; localparam SM_CMD_ACCEPTED = 2'b10; localparam SM_DONE_WAIT = 2'b11; //////////////////////////////////////////////////////////////////////////////// // Wires/Reg declarations //////////////////////////////////////////////////////////////////////////////// reg [1:0] state; // synthesis attribute MAX_FANOUT of state is 20; reg [1:0] next_state; //////////////////////////////////////////////////////////////////////////////// // BEGIN RTL /////////////////////////////////////////////////////////////////////////////// always @(posedge clk) begin if (reset) begin state <= SM_IDLE; end else begin state <= next_state; end end // Next state transitions. always @( * ) begin next_state = state; case (state) SM_IDLE: if (s_awvalid) begin next_state = SM_CMD_EN; end else next_state = state; SM_CMD_EN: if (m_awready & next_pending) next_state = SM_CMD_ACCEPTED; else if (m_awready & ~next_pending & b_full) next_state = SM_DONE_WAIT; else if (m_awready & ~next_pending & ~b_full) next_state = SM_IDLE; else next_state = state; SM_CMD_ACCEPTED: next_state = SM_CMD_EN; SM_DONE_WAIT: if (!b_full) next_state = SM_IDLE; else next_state = state; default: next_state = SM_IDLE; endcase end // Assign outputs based on current state. assign m_awvalid = (state == SM_CMD_EN); assign next = ((state == SM_CMD_ACCEPTED) | (((state == SM_CMD_EN) | (state == SM_DONE_WAIT)) & (next_state == SM_IDLE))) ; assign a_push = (state == SM_IDLE); assign s_awready = ((state == SM_CMD_EN) | (state == SM_DONE_WAIT)) & (next_state == SM_IDLE); assign b_push = ((state == SM_CMD_EN) | (state == SM_DONE_WAIT)) & (next_state == SM_IDLE); endmodule `default_nettype wire
/////////////////////////////////////////////////////////////////////////////// // // File name: axi_protocol_converter_v2_1_b2s_incr_cmd.v // /////////////////////////////////////////////////////////////////////////////// `timescale 1ps/1ps `default_nettype none (* DowngradeIPIdentifiedWarnings="yes" *) module axi_protocol_converter_v2_1_b2s_incr_cmd # ( /////////////////////////////////////////////////////////////////////////////// // Parameter Definitions /////////////////////////////////////////////////////////////////////////////// // Width of AxADDR // Range: 32. parameter integer C_AXI_ADDR_WIDTH = 32 ) ( /////////////////////////////////////////////////////////////////////////////// // Port Declarations /////////////////////////////////////////////////////////////////////////////// input wire clk , input wire reset , input wire [C_AXI_ADDR_WIDTH-1:0] axaddr , input wire [7:0] axlen , input wire [2:0] axsize , // axhandshake = axvalid & axready input wire axhandshake , output wire [C_AXI_ADDR_WIDTH-1:0] cmd_byte_addr , // Connections to/from fsm module // signal to increment to the next mc transaction input wire next , // signal to the fsm there is another transaction required output reg next_pending ); //////////////////////////////////////////////////////////////////////////////// // Wire and register declarations //////////////////////////////////////////////////////////////////////////////// reg sel_first; reg [11:0] axaddr_incr; reg [8:0] axlen_cnt; reg next_pending_r; wire [3:0] axsize_shift; wire [11:0] axsize_mask; localparam L_AXI_ADDR_LOW_BIT = (C_AXI_ADDR_WIDTH >= 12) ? 12 : 11; //////////////////////////////////////////////////////////////////////////////// // BEGIN RTL //////////////////////////////////////////////////////////////////////////////// // calculate cmd_byte_addr generate if (C_AXI_ADDR_WIDTH > 12) begin : ADDR_GT_4K assign cmd_byte_addr = (sel_first) ? axaddr : {axaddr[C_AXI_ADDR_WIDTH-1:L_AXI_ADDR_LOW_BIT],axaddr_incr[11:0]}; end else begin : ADDR_4K assign cmd_byte_addr = (sel_first) ? axaddr : axaddr_incr[11:0]; end endgenerate assign axsize_shift = (1 << axsize[1:0]); assign axsize_mask = ~(axsize_shift - 1'b1); // Incremented version of axaddr always @(posedge clk) begin if (sel_first) begin if(~next) begin axaddr_incr <= axaddr[11:0] & axsize_mask; end else begin axaddr_incr <= (axaddr[11:0] & axsize_mask) + axsize_shift; end end else if (next) begin axaddr_incr <= axaddr_incr + axsize_shift; end end always @(posedge clk) begin if (axhandshake)begin axlen_cnt <= axlen; next_pending_r <= (axlen >= 1); end else if (next) begin if (axlen_cnt > 1) begin axlen_cnt <= axlen_cnt - 1; next_pending_r <= ((axlen_cnt - 1) >= 1); end else begin axlen_cnt <= 9'd0; next_pending_r <= 1'b0; end end end always @( * ) begin if (axhandshake)begin next_pending = (axlen >= 1); end else if (next) begin if (axlen_cnt > 1) begin next_pending = ((axlen_cnt - 1) >= 1); end else begin next_pending = 1'b0; end end else begin next_pending = next_pending_r; end end // last and ignore signals to data channel. These signals are used for // BL8 to ignore and insert data for even len transactions with offset // and odd len transactions // For odd len transactions with no offset the last read is ignored and // last write is masked // For odd len transactions with offset the first read is ignored and // first write is masked // For even len transactions with offset the last & first read is ignored and // last& first write is masked // For even len transactions no ingnores or masks. // Indicates if we are on the first transaction of a mc translation with more // than 1 transaction. always @(posedge clk) begin if (reset | axhandshake) begin sel_first <= 1'b1; end else if (next) begin sel_first <= 1'b0; end end endmodule `default_nettype wire
/////////////////////////////////////////////////////////////////////////////// // // File name: axi_protocol_converter_v2_1_b2s_incr_cmd.v // /////////////////////////////////////////////////////////////////////////////// `timescale 1ps/1ps `default_nettype none (* DowngradeIPIdentifiedWarnings="yes" *) module axi_protocol_converter_v2_1_b2s_incr_cmd # ( /////////////////////////////////////////////////////////////////////////////// // Parameter Definitions /////////////////////////////////////////////////////////////////////////////// // Width of AxADDR // Range: 32. parameter integer C_AXI_ADDR_WIDTH = 32 ) ( /////////////////////////////////////////////////////////////////////////////// // Port Declarations /////////////////////////////////////////////////////////////////////////////// input wire clk , input wire reset , input wire [C_AXI_ADDR_WIDTH-1:0] axaddr , input wire [7:0] axlen , input wire [2:0] axsize , // axhandshake = axvalid & axready input wire axhandshake , output wire [C_AXI_ADDR_WIDTH-1:0] cmd_byte_addr , // Connections to/from fsm module // signal to increment to the next mc transaction input wire next , // signal to the fsm there is another transaction required output reg next_pending ); //////////////////////////////////////////////////////////////////////////////// // Wire and register declarations //////////////////////////////////////////////////////////////////////////////// reg sel_first; reg [11:0] axaddr_incr; reg [8:0] axlen_cnt; reg next_pending_r; wire [3:0] axsize_shift; wire [11:0] axsize_mask; localparam L_AXI_ADDR_LOW_BIT = (C_AXI_ADDR_WIDTH >= 12) ? 12 : 11; //////////////////////////////////////////////////////////////////////////////// // BEGIN RTL //////////////////////////////////////////////////////////////////////////////// // calculate cmd_byte_addr generate if (C_AXI_ADDR_WIDTH > 12) begin : ADDR_GT_4K assign cmd_byte_addr = (sel_first) ? axaddr : {axaddr[C_AXI_ADDR_WIDTH-1:L_AXI_ADDR_LOW_BIT],axaddr_incr[11:0]}; end else begin : ADDR_4K assign cmd_byte_addr = (sel_first) ? axaddr : axaddr_incr[11:0]; end endgenerate assign axsize_shift = (1 << axsize[1:0]); assign axsize_mask = ~(axsize_shift - 1'b1); // Incremented version of axaddr always @(posedge clk) begin if (sel_first) begin if(~next) begin axaddr_incr <= axaddr[11:0] & axsize_mask; end else begin axaddr_incr <= (axaddr[11:0] & axsize_mask) + axsize_shift; end end else if (next) begin axaddr_incr <= axaddr_incr + axsize_shift; end end always @(posedge clk) begin if (axhandshake)begin axlen_cnt <= axlen; next_pending_r <= (axlen >= 1); end else if (next) begin if (axlen_cnt > 1) begin axlen_cnt <= axlen_cnt - 1; next_pending_r <= ((axlen_cnt - 1) >= 1); end else begin axlen_cnt <= 9'd0; next_pending_r <= 1'b0; end end end always @( * ) begin if (axhandshake)begin next_pending = (axlen >= 1); end else if (next) begin if (axlen_cnt > 1) begin next_pending = ((axlen_cnt - 1) >= 1); end else begin next_pending = 1'b0; end end else begin next_pending = next_pending_r; end end // last and ignore signals to data channel. These signals are used for // BL8 to ignore and insert data for even len transactions with offset // and odd len transactions // For odd len transactions with no offset the last read is ignored and // last write is masked // For odd len transactions with offset the first read is ignored and // first write is masked // For even len transactions with offset the last & first read is ignored and // last& first write is masked // For even len transactions no ingnores or masks. // Indicates if we are on the first transaction of a mc translation with more // than 1 transaction. always @(posedge clk) begin if (reset | axhandshake) begin sel_first <= 1'b1; end else if (next) begin sel_first <= 1'b0; end end endmodule `default_nettype wire
/****************************************************************************** -- (c) Copyright 2006 - 2013 Xilinx, Inc. All rights reserved. -- -- This file contains confidential and proprietary information -- of Xilinx, Inc. and is protected under U.S. and -- international copyright and other intellectual property -- laws. -- -- DISCLAIMER -- This disclaimer is not a license and does not grant any -- rights to the materials distributed herewith. Except as -- otherwise provided in a valid license issued to you by -- Xilinx, and to the maximum extent permitted by applicable -- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND -- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES -- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING -- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- -- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and -- (2) Xilinx shall not be liable (whether in contract or tort, -- including negligence, or under any other theory of -- liability) for any loss or damage of any kind or nature -- related to, arising under or in connection with these -- materials, including for any direct, or any indirect, -- special, incidental, or consequential loss or damage -- (including loss of data, profits, goodwill, or any type of -- loss or damage suffered as a result of any action brought -- by a third party) even if such damage or loss was -- reasonably foreseeable or Xilinx had been advised of the -- possibility of the same. -- -- CRITICAL APPLICATIONS -- Xilinx products are not designed or intended to be fail- -- safe, or for use in any application requiring fail-safe -- performance, such as life-support or safety devices or -- systems, Class III medical devices, nuclear facilities, -- applications related to the deployment of airbags, or any -- other applications that could lead to death, personal -- injury, or severe property or environmental damage -- (individually and collectively, "Critical -- Applications"). Customer assumes the sole risk and -- liability of any use of Xilinx products in Critical -- Applications, subject only to applicable laws and -- regulations governing limitations on product liability. -- -- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS -- PART OF THIS FILE AT ALL TIMES. -- ***************************************************************************** * * Filename: BLK_MEM_GEN_v8_2.v * * Description: * This file is the Verilog behvarial model for the * Block Memory Generator Core. * ***************************************************************************** * Author: Xilinx * * History: Jan 11, 2006 Initial revision * Jun 11, 2007 Added independent register stages for * Port A and Port B (IP1_Jm/v2.5) * Aug 28, 2007 Added mux pipeline stages feature (IP2_Jm/v2.6) * Mar 13, 2008 Behavioral model optimizations * April 07, 2009 : Added support for Spartan-6 and Virtex-6 * features, including the following: * (i) error injection, detection and/or correction * (ii) reset priority * (iii) special reset behavior * *****************************************************************************/ `timescale 1ps/1ps module STATE_LOGIC_v8_2 (O, I0, I1, I2, I3, I4, I5); parameter INIT = 64'h0000000000000000; input I0, I1, I2, I3, I4, I5; output O; reg O; reg tmp; always @( I5 or I4 or I3 or I2 or I1 or I0 ) begin tmp = I0 ^ I1 ^ I2 ^ I3 ^ I4 ^ I5; if ( tmp == 0 || tmp == 1) O = INIT[{I5, I4, I3, I2, I1, I0}]; end endmodule module beh_vlog_muxf7_v8_2 (O, I0, I1, S); output O; reg O; input I0, I1, S; always @(I0 or I1 or S) if (S) O = I1; else O = I0; endmodule module beh_vlog_ff_clr_v8_2 (Q, C, CLR, D); parameter INIT = 0; localparam FLOP_DELAY = 100; output Q; input C, CLR, D; reg Q; initial Q= 1'b0; always @(posedge C ) if (CLR) Q<= 1'b0; else Q<= #FLOP_DELAY D; endmodule module beh_vlog_ff_pre_v8_2 (Q, C, D, PRE); parameter INIT = 0; localparam FLOP_DELAY = 100; output Q; input C, D, PRE; reg Q; initial Q= 1'b0; always @(posedge C ) if (PRE) Q <= 1'b1; else Q <= #FLOP_DELAY D; endmodule module beh_vlog_ff_ce_clr_v8_2 (Q, C, CE, CLR, D); parameter INIT = 0; localparam FLOP_DELAY = 100; output Q; input C, CE, CLR, D; reg Q; initial Q= 1'b0; always @(posedge C ) if (CLR) Q <= 1'b0; else if (CE) Q <= #FLOP_DELAY D; endmodule module write_netlist_v8_2 #( parameter C_AXI_TYPE = 0 ) ( S_ACLK, S_ARESETN, S_AXI_AWVALID, S_AXI_WVALID, S_AXI_BREADY, w_last_c, bready_timeout_c, aw_ready_r, S_AXI_WREADY, S_AXI_BVALID, S_AXI_WR_EN, addr_en_c, incr_addr_c, bvalid_c ); input S_ACLK; input S_ARESETN; input S_AXI_AWVALID; input S_AXI_WVALID; input S_AXI_BREADY; input w_last_c; input bready_timeout_c; output aw_ready_r; output S_AXI_WREADY; output S_AXI_BVALID; output S_AXI_WR_EN; output addr_en_c; output incr_addr_c; output bvalid_c; //------------------------------------------------------------------------- //AXI LITE //------------------------------------------------------------------------- generate if (C_AXI_TYPE == 0 ) begin : gbeh_axi_lite_sm wire w_ready_r_7; wire w_ready_c; wire aw_ready_c; wire NlwRenamedSignal_bvalid_c; wire NlwRenamedSignal_incr_addr_c; wire present_state_FSM_FFd3_13; wire present_state_FSM_FFd2_14; wire present_state_FSM_FFd1_15; wire present_state_FSM_FFd4_16; wire present_state_FSM_FFd4_In; wire present_state_FSM_FFd3_In; wire present_state_FSM_FFd2_In; wire present_state_FSM_FFd1_In; wire present_state_FSM_FFd4_In1_21; wire [0:0] Mmux_aw_ready_c ; begin assign S_AXI_WREADY = w_ready_r_7, S_AXI_BVALID = NlwRenamedSignal_incr_addr_c, S_AXI_WR_EN = NlwRenamedSignal_bvalid_c, incr_addr_c = NlwRenamedSignal_incr_addr_c, bvalid_c = NlwRenamedSignal_bvalid_c; assign NlwRenamedSignal_incr_addr_c = 1'b0; beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) aw_ready_r_2 ( .C ( S_ACLK), .CLR ( S_ARESETN), .D ( aw_ready_c), .Q ( aw_ready_r) ); beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) w_ready_r ( .C ( S_ACLK), .CLR ( S_ARESETN), .D ( w_ready_c), .Q ( w_ready_r_7) ); beh_vlog_ff_pre_v8_2 #( .INIT (1'b1)) present_state_FSM_FFd4 ( .C ( S_ACLK), .D ( present_state_FSM_FFd4_In), .PRE ( S_ARESETN), .Q ( present_state_FSM_FFd4_16) ); beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) present_state_FSM_FFd3 ( .C ( S_ACLK), .CLR ( S_ARESETN), .D ( present_state_FSM_FFd3_In), .Q ( present_state_FSM_FFd3_13) ); beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) present_state_FSM_FFd2 ( .C ( S_ACLK), .CLR ( S_ARESETN), .D ( present_state_FSM_FFd2_In), .Q ( present_state_FSM_FFd2_14) ); beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) present_state_FSM_FFd1 ( .C ( S_ACLK), .CLR ( S_ARESETN), .D ( present_state_FSM_FFd1_In), .Q ( present_state_FSM_FFd1_15) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000055554440)) present_state_FSM_FFd3_In1 ( .I0 ( S_AXI_WVALID), .I1 ( S_AXI_AWVALID), .I2 ( present_state_FSM_FFd2_14), .I3 ( present_state_FSM_FFd4_16), .I4 ( present_state_FSM_FFd3_13), .I5 (1'b0), .O ( present_state_FSM_FFd3_In) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000088880800)) present_state_FSM_FFd2_In1 ( .I0 ( S_AXI_AWVALID), .I1 ( S_AXI_WVALID), .I2 ( bready_timeout_c), .I3 ( present_state_FSM_FFd2_14), .I4 ( present_state_FSM_FFd4_16), .I5 (1'b0), .O ( present_state_FSM_FFd2_In) ); STATE_LOGIC_v8_2 #( .INIT (64'h00000000AAAA2000)) Mmux_addr_en_c_0_1 ( .I0 ( S_AXI_AWVALID), .I1 ( bready_timeout_c), .I2 ( present_state_FSM_FFd2_14), .I3 ( S_AXI_WVALID), .I4 ( present_state_FSM_FFd4_16), .I5 (1'b0), .O ( addr_en_c) ); STATE_LOGIC_v8_2 #( .INIT (64'hF5F07570F5F05500)) Mmux_w_ready_c_0_1 ( .I0 ( S_AXI_WVALID), .I1 ( bready_timeout_c), .I2 ( S_AXI_AWVALID), .I3 ( present_state_FSM_FFd3_13), .I4 ( present_state_FSM_FFd4_16), .I5 ( present_state_FSM_FFd2_14), .O ( w_ready_c) ); STATE_LOGIC_v8_2 #( .INIT (64'h88808880FFFF8880)) present_state_FSM_FFd1_In1 ( .I0 ( S_AXI_WVALID), .I1 ( bready_timeout_c), .I2 ( present_state_FSM_FFd3_13), .I3 ( present_state_FSM_FFd2_14), .I4 ( present_state_FSM_FFd1_15), .I5 ( S_AXI_BREADY), .O ( present_state_FSM_FFd1_In) ); STATE_LOGIC_v8_2 #( .INIT (64'h00000000000000A8)) Mmux_S_AXI_WR_EN_0_1 ( .I0 ( S_AXI_WVALID), .I1 ( present_state_FSM_FFd2_14), .I2 ( present_state_FSM_FFd3_13), .I3 (1'b0), .I4 (1'b0), .I5 (1'b0), .O ( NlwRenamedSignal_bvalid_c) ); STATE_LOGIC_v8_2 #( .INIT (64'h2F0F27072F0F2200)) present_state_FSM_FFd4_In1 ( .I0 ( S_AXI_WVALID), .I1 ( bready_timeout_c), .I2 ( S_AXI_AWVALID), .I3 ( present_state_FSM_FFd3_13), .I4 ( present_state_FSM_FFd4_16), .I5 ( present_state_FSM_FFd2_14), .O ( present_state_FSM_FFd4_In1_21) ); STATE_LOGIC_v8_2 #( .INIT (64'h00000000000000F8)) present_state_FSM_FFd4_In2 ( .I0 ( present_state_FSM_FFd1_15), .I1 ( S_AXI_BREADY), .I2 ( present_state_FSM_FFd4_In1_21), .I3 (1'b0), .I4 (1'b0), .I5 (1'b0), .O ( present_state_FSM_FFd4_In) ); STATE_LOGIC_v8_2 #( .INIT (64'h7535753575305500)) Mmux_aw_ready_c_0_1 ( .I0 ( S_AXI_AWVALID), .I1 ( bready_timeout_c), .I2 ( S_AXI_WVALID), .I3 ( present_state_FSM_FFd4_16), .I4 ( present_state_FSM_FFd3_13), .I5 ( present_state_FSM_FFd2_14), .O ( Mmux_aw_ready_c[0]) ); STATE_LOGIC_v8_2 #( .INIT (64'h00000000000000F8)) Mmux_aw_ready_c_0_2 ( .I0 ( present_state_FSM_FFd1_15), .I1 ( S_AXI_BREADY), .I2 ( Mmux_aw_ready_c[0]), .I3 (1'b0), .I4 (1'b0), .I5 (1'b0), .O ( aw_ready_c) ); end end endgenerate //--------------------------------------------------------------------- // AXI FULL //--------------------------------------------------------------------- generate if (C_AXI_TYPE == 1 ) begin : gbeh_axi_full_sm wire w_ready_r_8; wire w_ready_c; wire aw_ready_c; wire NlwRenamedSig_OI_bvalid_c; wire present_state_FSM_FFd1_16; wire present_state_FSM_FFd4_17; wire present_state_FSM_FFd3_18; wire present_state_FSM_FFd2_19; wire present_state_FSM_FFd4_In; wire present_state_FSM_FFd3_In; wire present_state_FSM_FFd2_In; wire present_state_FSM_FFd1_In; wire present_state_FSM_FFd2_In1_24; wire present_state_FSM_FFd4_In1_25; wire N2; wire N4; begin assign S_AXI_WREADY = w_ready_r_8, bvalid_c = NlwRenamedSig_OI_bvalid_c, S_AXI_BVALID = 1'b0; beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) aw_ready_r_2 ( .C ( S_ACLK), .CLR ( S_ARESETN), .D ( aw_ready_c), .Q ( aw_ready_r) ); beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) w_ready_r ( .C ( S_ACLK), .CLR ( S_ARESETN), .D ( w_ready_c), .Q ( w_ready_r_8) ); beh_vlog_ff_pre_v8_2 #( .INIT (1'b1)) present_state_FSM_FFd4 ( .C ( S_ACLK), .D ( present_state_FSM_FFd4_In), .PRE ( S_ARESETN), .Q ( present_state_FSM_FFd4_17) ); beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) present_state_FSM_FFd3 ( .C ( S_ACLK), .CLR ( S_ARESETN), .D ( present_state_FSM_FFd3_In), .Q ( present_state_FSM_FFd3_18) ); beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) present_state_FSM_FFd2 ( .C ( S_ACLK), .CLR ( S_ARESETN), .D ( present_state_FSM_FFd2_In), .Q ( present_state_FSM_FFd2_19) ); beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) present_state_FSM_FFd1 ( .C ( S_ACLK), .CLR ( S_ARESETN), .D ( present_state_FSM_FFd1_In), .Q ( present_state_FSM_FFd1_16) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000000005540)) present_state_FSM_FFd3_In1 ( .I0 ( S_AXI_WVALID), .I1 ( present_state_FSM_FFd4_17), .I2 ( S_AXI_AWVALID), .I3 ( present_state_FSM_FFd3_18), .I4 (1'b0), .I5 (1'b0), .O ( present_state_FSM_FFd3_In) ); STATE_LOGIC_v8_2 #( .INIT (64'hBF3FBB33AF0FAA00)) Mmux_aw_ready_c_0_2 ( .I0 ( S_AXI_BREADY), .I1 ( bready_timeout_c), .I2 ( S_AXI_AWVALID), .I3 ( present_state_FSM_FFd1_16), .I4 ( present_state_FSM_FFd4_17), .I5 ( NlwRenamedSig_OI_bvalid_c), .O ( aw_ready_c) ); STATE_LOGIC_v8_2 #( .INIT (64'hAAAAAAAA20000000)) Mmux_addr_en_c_0_1 ( .I0 ( S_AXI_AWVALID), .I1 ( bready_timeout_c), .I2 ( present_state_FSM_FFd2_19), .I3 ( S_AXI_WVALID), .I4 ( w_last_c), .I5 ( present_state_FSM_FFd4_17), .O ( addr_en_c) ); STATE_LOGIC_v8_2 #( .INIT (64'h00000000000000A8)) Mmux_S_AXI_WR_EN_0_1 ( .I0 ( S_AXI_WVALID), .I1 ( present_state_FSM_FFd2_19), .I2 ( present_state_FSM_FFd3_18), .I3 (1'b0), .I4 (1'b0), .I5 (1'b0), .O ( S_AXI_WR_EN) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000000002220)) Mmux_incr_addr_c_0_1 ( .I0 ( S_AXI_WVALID), .I1 ( w_last_c), .I2 ( present_state_FSM_FFd2_19), .I3 ( present_state_FSM_FFd3_18), .I4 (1'b0), .I5 (1'b0), .O ( incr_addr_c) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000000008880)) Mmux_aw_ready_c_0_11 ( .I0 ( S_AXI_WVALID), .I1 ( w_last_c), .I2 ( present_state_FSM_FFd2_19), .I3 ( present_state_FSM_FFd3_18), .I4 (1'b0), .I5 (1'b0), .O ( NlwRenamedSig_OI_bvalid_c) ); STATE_LOGIC_v8_2 #( .INIT (64'h000000000000D5C0)) present_state_FSM_FFd2_In1 ( .I0 ( w_last_c), .I1 ( S_AXI_AWVALID), .I2 ( present_state_FSM_FFd4_17), .I3 ( present_state_FSM_FFd3_18), .I4 (1'b0), .I5 (1'b0), .O ( present_state_FSM_FFd2_In1_24) ); STATE_LOGIC_v8_2 #( .INIT (64'hFFFFAAAA08AAAAAA)) present_state_FSM_FFd2_In2 ( .I0 ( present_state_FSM_FFd2_19), .I1 ( S_AXI_AWVALID), .I2 ( bready_timeout_c), .I3 ( w_last_c), .I4 ( S_AXI_WVALID), .I5 ( present_state_FSM_FFd2_In1_24), .O ( present_state_FSM_FFd2_In) ); STATE_LOGIC_v8_2 #( .INIT (64'h00C0004000C00000)) present_state_FSM_FFd4_In1 ( .I0 ( S_AXI_AWVALID), .I1 ( w_last_c), .I2 ( S_AXI_WVALID), .I3 ( bready_timeout_c), .I4 ( present_state_FSM_FFd3_18), .I5 ( present_state_FSM_FFd2_19), .O ( present_state_FSM_FFd4_In1_25) ); STATE_LOGIC_v8_2 #( .INIT (64'h00000000FFFF88F8)) present_state_FSM_FFd4_In2 ( .I0 ( present_state_FSM_FFd1_16), .I1 ( S_AXI_BREADY), .I2 ( present_state_FSM_FFd4_17), .I3 ( S_AXI_AWVALID), .I4 ( present_state_FSM_FFd4_In1_25), .I5 (1'b0), .O ( present_state_FSM_FFd4_In) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000000000007)) Mmux_w_ready_c_0_SW0 ( .I0 ( w_last_c), .I1 ( S_AXI_WVALID), .I2 (1'b0), .I3 (1'b0), .I4 (1'b0), .I5 (1'b0), .O ( N2) ); STATE_LOGIC_v8_2 #( .INIT (64'hFABAFABAFAAAF000)) Mmux_w_ready_c_0_Q ( .I0 ( N2), .I1 ( bready_timeout_c), .I2 ( S_AXI_AWVALID), .I3 ( present_state_FSM_FFd4_17), .I4 ( present_state_FSM_FFd3_18), .I5 ( present_state_FSM_FFd2_19), .O ( w_ready_c) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000000000008)) Mmux_aw_ready_c_0_11_SW0 ( .I0 ( bready_timeout_c), .I1 ( S_AXI_WVALID), .I2 (1'b0), .I3 (1'b0), .I4 (1'b0), .I5 (1'b0), .O ( N4) ); STATE_LOGIC_v8_2 #( .INIT (64'h88808880FFFF8880)) present_state_FSM_FFd1_In1 ( .I0 ( w_last_c), .I1 ( N4), .I2 ( present_state_FSM_FFd2_19), .I3 ( present_state_FSM_FFd3_18), .I4 ( present_state_FSM_FFd1_16), .I5 ( S_AXI_BREADY), .O ( present_state_FSM_FFd1_In) ); end end endgenerate endmodule module read_netlist_v8_2 #( parameter C_AXI_TYPE = 1, parameter C_ADDRB_WIDTH = 12 ) ( S_AXI_R_LAST_INT, S_ACLK, S_ARESETN, S_AXI_ARVALID, S_AXI_RREADY,S_AXI_INCR_ADDR,S_AXI_ADDR_EN, S_AXI_SINGLE_TRANS,S_AXI_MUX_SEL, S_AXI_R_LAST, S_AXI_ARREADY, S_AXI_RLAST, S_AXI_RVALID, S_AXI_RD_EN, S_AXI_ARLEN); input S_AXI_R_LAST_INT; input S_ACLK; input S_ARESETN; input S_AXI_ARVALID; input S_AXI_RREADY; output S_AXI_INCR_ADDR; output S_AXI_ADDR_EN; output S_AXI_SINGLE_TRANS; output S_AXI_MUX_SEL; output S_AXI_R_LAST; output S_AXI_ARREADY; output S_AXI_RLAST; output S_AXI_RVALID; output S_AXI_RD_EN; input [7:0] S_AXI_ARLEN; wire present_state_FSM_FFd1_13 ; wire present_state_FSM_FFd2_14 ; wire gaxi_full_sm_outstanding_read_r_15 ; wire gaxi_full_sm_ar_ready_r_16 ; wire gaxi_full_sm_r_last_r_17 ; wire NlwRenamedSig_OI_gaxi_full_sm_r_valid_r ; wire gaxi_full_sm_r_valid_c ; wire S_AXI_RREADY_gaxi_full_sm_r_valid_r_OR_9_o ; wire gaxi_full_sm_ar_ready_c ; wire gaxi_full_sm_outstanding_read_c ; wire NlwRenamedSig_OI_S_AXI_R_LAST ; wire S_AXI_ARLEN_7_GND_8_o_equal_1_o ; wire present_state_FSM_FFd2_In ; wire present_state_FSM_FFd1_In ; wire Mmux_S_AXI_R_LAST13 ; wire N01 ; wire N2 ; wire Mmux_gaxi_full_sm_ar_ready_c11 ; wire N4 ; wire N8 ; wire N9 ; wire N10 ; wire N11 ; wire N12 ; wire N13 ; assign S_AXI_R_LAST = NlwRenamedSig_OI_S_AXI_R_LAST, S_AXI_ARREADY = gaxi_full_sm_ar_ready_r_16, S_AXI_RLAST = gaxi_full_sm_r_last_r_17, S_AXI_RVALID = NlwRenamedSig_OI_gaxi_full_sm_r_valid_r; beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) gaxi_full_sm_outstanding_read_r ( .C (S_ACLK), .CLR(S_ARESETN), .D(gaxi_full_sm_outstanding_read_c), .Q(gaxi_full_sm_outstanding_read_r_15) ); beh_vlog_ff_ce_clr_v8_2 #( .INIT (1'b0)) gaxi_full_sm_r_valid_r ( .C (S_ACLK), .CE (S_AXI_RREADY_gaxi_full_sm_r_valid_r_OR_9_o), .CLR (S_ARESETN), .D (gaxi_full_sm_r_valid_c), .Q (NlwRenamedSig_OI_gaxi_full_sm_r_valid_r) ); beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) gaxi_full_sm_ar_ready_r ( .C (S_ACLK), .CLR (S_ARESETN), .D (gaxi_full_sm_ar_ready_c), .Q (gaxi_full_sm_ar_ready_r_16) ); beh_vlog_ff_ce_clr_v8_2 #( .INIT(1'b0)) gaxi_full_sm_r_last_r ( .C (S_ACLK), .CE (S_AXI_RREADY_gaxi_full_sm_r_valid_r_OR_9_o), .CLR (S_ARESETN), .D (NlwRenamedSig_OI_S_AXI_R_LAST), .Q (gaxi_full_sm_r_last_r_17) ); beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) present_state_FSM_FFd2 ( .C ( S_ACLK), .CLR ( S_ARESETN), .D ( present_state_FSM_FFd2_In), .Q ( present_state_FSM_FFd2_14) ); beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) present_state_FSM_FFd1 ( .C (S_ACLK), .CLR (S_ARESETN), .D (present_state_FSM_FFd1_In), .Q (present_state_FSM_FFd1_13) ); STATE_LOGIC_v8_2 #( .INIT (64'h000000000000000B)) S_AXI_RREADY_gaxi_full_sm_r_valid_r_OR_9_o1 ( .I0 ( S_AXI_RREADY), .I1 ( NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .I2 (1'b0), .I3 (1'b0), .I4 (1'b0), .I5 (1'b0), .O (S_AXI_RREADY_gaxi_full_sm_r_valid_r_OR_9_o) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000000000008)) Mmux_S_AXI_SINGLE_TRANS11 ( .I0 (S_AXI_ARVALID), .I1 (S_AXI_ARLEN_7_GND_8_o_equal_1_o), .I2 (1'b0), .I3 (1'b0), .I4 (1'b0), .I5 (1'b0), .O (S_AXI_SINGLE_TRANS) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000000000004)) Mmux_S_AXI_ADDR_EN11 ( .I0 (present_state_FSM_FFd1_13), .I1 (S_AXI_ARVALID), .I2 (1'b0), .I3 (1'b0), .I4 (1'b0), .I5 (1'b0), .O (S_AXI_ADDR_EN) ); STATE_LOGIC_v8_2 #( .INIT (64'hECEE2022EEEE2022)) present_state_FSM_FFd2_In1 ( .I0 ( S_AXI_ARVALID), .I1 ( present_state_FSM_FFd1_13), .I2 ( S_AXI_RREADY), .I3 ( S_AXI_ARLEN_7_GND_8_o_equal_1_o), .I4 ( present_state_FSM_FFd2_14), .I5 ( NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .O ( present_state_FSM_FFd2_In) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000044440444)) Mmux_S_AXI_R_LAST131 ( .I0 ( present_state_FSM_FFd1_13), .I1 ( S_AXI_ARVALID), .I2 ( present_state_FSM_FFd2_14), .I3 ( NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .I4 ( S_AXI_RREADY), .I5 (1'b0), .O ( Mmux_S_AXI_R_LAST13) ); STATE_LOGIC_v8_2 #( .INIT (64'h4000FFFF40004000)) Mmux_S_AXI_INCR_ADDR11 ( .I0 ( S_AXI_R_LAST_INT), .I1 ( S_AXI_RREADY_gaxi_full_sm_r_valid_r_OR_9_o), .I2 ( present_state_FSM_FFd2_14), .I3 ( present_state_FSM_FFd1_13), .I4 ( S_AXI_ARLEN_7_GND_8_o_equal_1_o), .I5 ( Mmux_S_AXI_R_LAST13), .O ( S_AXI_INCR_ADDR) ); STATE_LOGIC_v8_2 #( .INIT (64'h00000000000000FE)) S_AXI_ARLEN_7_GND_8_o_equal_1_o_7_SW0 ( .I0 ( S_AXI_ARLEN[2]), .I1 ( S_AXI_ARLEN[1]), .I2 ( S_AXI_ARLEN[0]), .I3 ( 1'b0), .I4 ( 1'b0), .I5 ( 1'b0), .O ( N01) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000000000001)) S_AXI_ARLEN_7_GND_8_o_equal_1_o_7_Q ( .I0 ( S_AXI_ARLEN[7]), .I1 ( S_AXI_ARLEN[6]), .I2 ( S_AXI_ARLEN[5]), .I3 ( S_AXI_ARLEN[4]), .I4 ( S_AXI_ARLEN[3]), .I5 ( N01), .O ( S_AXI_ARLEN_7_GND_8_o_equal_1_o) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000000000007)) Mmux_gaxi_full_sm_outstanding_read_c1_SW0 ( .I0 ( S_AXI_ARVALID), .I1 ( S_AXI_ARLEN_7_GND_8_o_equal_1_o), .I2 ( 1'b0), .I3 ( 1'b0), .I4 ( 1'b0), .I5 ( 1'b0), .O ( N2) ); STATE_LOGIC_v8_2 #( .INIT (64'h0020000002200200)) Mmux_gaxi_full_sm_outstanding_read_c1 ( .I0 ( NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .I1 ( S_AXI_RREADY), .I2 ( present_state_FSM_FFd1_13), .I3 ( present_state_FSM_FFd2_14), .I4 ( gaxi_full_sm_outstanding_read_r_15), .I5 ( N2), .O ( gaxi_full_sm_outstanding_read_c) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000000004555)) Mmux_gaxi_full_sm_ar_ready_c12 ( .I0 ( S_AXI_ARVALID), .I1 ( S_AXI_RREADY), .I2 ( present_state_FSM_FFd2_14), .I3 ( NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .I4 ( 1'b0), .I5 ( 1'b0), .O ( Mmux_gaxi_full_sm_ar_ready_c11) ); STATE_LOGIC_v8_2 #( .INIT (64'h00000000000000EF)) Mmux_S_AXI_R_LAST11_SW0 ( .I0 ( S_AXI_ARLEN_7_GND_8_o_equal_1_o), .I1 ( S_AXI_RREADY), .I2 ( NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .I3 ( 1'b0), .I4 ( 1'b0), .I5 ( 1'b0), .O ( N4) ); STATE_LOGIC_v8_2 #( .INIT (64'hFCAAFC0A00AA000A)) Mmux_S_AXI_R_LAST11 ( .I0 ( S_AXI_ARVALID), .I1 ( gaxi_full_sm_outstanding_read_r_15), .I2 ( present_state_FSM_FFd2_14), .I3 ( present_state_FSM_FFd1_13), .I4 ( N4), .I5 ( S_AXI_RREADY_gaxi_full_sm_r_valid_r_OR_9_o), .O ( gaxi_full_sm_r_valid_c) ); STATE_LOGIC_v8_2 #( .INIT (64'h00000000AAAAAA08)) S_AXI_MUX_SEL1 ( .I0 (present_state_FSM_FFd1_13), .I1 (NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .I2 (S_AXI_RREADY), .I3 (present_state_FSM_FFd2_14), .I4 (gaxi_full_sm_outstanding_read_r_15), .I5 (1'b0), .O (S_AXI_MUX_SEL) ); STATE_LOGIC_v8_2 #( .INIT (64'hF3F3F755A2A2A200)) Mmux_S_AXI_RD_EN11 ( .I0 ( present_state_FSM_FFd1_13), .I1 ( NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .I2 ( S_AXI_RREADY), .I3 ( gaxi_full_sm_outstanding_read_r_15), .I4 ( present_state_FSM_FFd2_14), .I5 ( S_AXI_ARVALID), .O ( S_AXI_RD_EN) ); beh_vlog_muxf7_v8_2 present_state_FSM_FFd1_In3 ( .I0 ( N8), .I1 ( N9), .S ( present_state_FSM_FFd1_13), .O ( present_state_FSM_FFd1_In) ); STATE_LOGIC_v8_2 #( .INIT (64'h000000005410F4F0)) present_state_FSM_FFd1_In3_F ( .I0 ( S_AXI_RREADY), .I1 ( present_state_FSM_FFd2_14), .I2 ( S_AXI_ARVALID), .I3 ( NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .I4 ( S_AXI_ARLEN_7_GND_8_o_equal_1_o), .I5 ( 1'b0), .O ( N8) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000072FF7272)) present_state_FSM_FFd1_In3_G ( .I0 ( present_state_FSM_FFd2_14), .I1 ( S_AXI_R_LAST_INT), .I2 ( gaxi_full_sm_outstanding_read_r_15), .I3 ( S_AXI_RREADY), .I4 ( NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .I5 ( 1'b0), .O ( N9) ); beh_vlog_muxf7_v8_2 Mmux_gaxi_full_sm_ar_ready_c14 ( .I0 ( N10), .I1 ( N11), .S ( present_state_FSM_FFd1_13), .O ( gaxi_full_sm_ar_ready_c) ); STATE_LOGIC_v8_2 #( .INIT (64'h00000000FFFF88A8)) Mmux_gaxi_full_sm_ar_ready_c14_F ( .I0 ( S_AXI_ARLEN_7_GND_8_o_equal_1_o), .I1 ( S_AXI_RREADY), .I2 ( present_state_FSM_FFd2_14), .I3 ( NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .I4 ( Mmux_gaxi_full_sm_ar_ready_c11), .I5 ( 1'b0), .O ( N10) ); STATE_LOGIC_v8_2 #( .INIT (64'h000000008D008D8D)) Mmux_gaxi_full_sm_ar_ready_c14_G ( .I0 ( present_state_FSM_FFd2_14), .I1 ( S_AXI_R_LAST_INT), .I2 ( gaxi_full_sm_outstanding_read_r_15), .I3 ( S_AXI_RREADY), .I4 ( NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .I5 ( 1'b0), .O ( N11) ); beh_vlog_muxf7_v8_2 Mmux_S_AXI_R_LAST1 ( .I0 ( N12), .I1 ( N13), .S ( present_state_FSM_FFd1_13), .O ( NlwRenamedSig_OI_S_AXI_R_LAST) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000088088888)) Mmux_S_AXI_R_LAST1_F ( .I0 ( S_AXI_ARLEN_7_GND_8_o_equal_1_o), .I1 ( S_AXI_ARVALID), .I2 ( present_state_FSM_FFd2_14), .I3 ( S_AXI_RREADY), .I4 ( NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .I5 ( 1'b0), .O ( N12) ); STATE_LOGIC_v8_2 #( .INIT (64'h00000000E400E4E4)) Mmux_S_AXI_R_LAST1_G ( .I0 ( present_state_FSM_FFd2_14), .I1 ( gaxi_full_sm_outstanding_read_r_15), .I2 ( S_AXI_R_LAST_INT), .I3 ( S_AXI_RREADY), .I4 ( NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .I5 ( 1'b0), .O ( N13) ); endmodule module blk_mem_axi_write_wrapper_beh_v8_2 # ( // AXI Interface related parameters start here parameter C_INTERFACE_TYPE = 0, // 0: Native Interface; 1: AXI Interface parameter C_AXI_TYPE = 0, // 0: AXI Lite; 1: AXI Full; parameter C_AXI_SLAVE_TYPE = 0, // 0: MEMORY SLAVE; 1: PERIPHERAL SLAVE; parameter C_MEMORY_TYPE = 0, // 0: SP-RAM, 1: SDP-RAM; 2: TDP-RAM; 3: DP-ROM; parameter C_WRITE_DEPTH_A = 0, parameter C_AXI_AWADDR_WIDTH = 32, parameter C_ADDRA_WIDTH = 12, parameter C_AXI_WDATA_WIDTH = 32, parameter C_HAS_AXI_ID = 0, parameter C_AXI_ID_WIDTH = 4, // AXI OUTSTANDING WRITES parameter C_AXI_OS_WR = 2 ) ( // AXI Global Signals input S_ACLK, input S_ARESETN, // AXI Full/Lite Slave Write Channel (write side) input [C_AXI_ID_WIDTH-1:0] S_AXI_AWID, input [C_AXI_AWADDR_WIDTH-1:0] S_AXI_AWADDR, input [8-1:0] S_AXI_AWLEN, input [2:0] S_AXI_AWSIZE, input [1:0] S_AXI_AWBURST, input S_AXI_AWVALID, output S_AXI_AWREADY, input S_AXI_WVALID, output S_AXI_WREADY, output reg [C_AXI_ID_WIDTH-1:0] S_AXI_BID = 0, output S_AXI_BVALID, input S_AXI_BREADY, // Signals for BMG interface output [C_ADDRA_WIDTH-1:0] S_AXI_AWADDR_OUT, output S_AXI_WR_EN ); localparam FLOP_DELAY = 100; // 100 ps localparam C_RANGE = ((C_AXI_WDATA_WIDTH == 8)?0: ((C_AXI_WDATA_WIDTH==16)?1: ((C_AXI_WDATA_WIDTH==32)?2: ((C_AXI_WDATA_WIDTH==64)?3: ((C_AXI_WDATA_WIDTH==128)?4: ((C_AXI_WDATA_WIDTH==256)?5:0)))))); wire bvalid_c ; reg bready_timeout_c = 0; wire [1:0] bvalid_rd_cnt_c; reg bvalid_r = 0; reg [2:0] bvalid_count_r = 0; reg [((C_AXI_TYPE == 1 && C_AXI_SLAVE_TYPE == 0)? C_AXI_AWADDR_WIDTH:C_ADDRA_WIDTH)-1:0] awaddr_reg = 0; reg [1:0] bvalid_wr_cnt_r = 0; reg [1:0] bvalid_rd_cnt_r = 0; wire w_last_c ; wire addr_en_c ; wire incr_addr_c ; wire aw_ready_r ; wire dec_alen_c ; reg bvalid_d1_c = 0; reg [7:0] awlen_cntr_r = 0; reg [7:0] awlen_int = 0; reg [1:0] awburst_int = 0; integer total_bytes = 0; integer wrap_boundary = 0; integer wrap_base_addr = 0; integer num_of_bytes_c = 0; integer num_of_bytes_r = 0; // Array to store BIDs reg [C_AXI_ID_WIDTH-1:0] axi_bid_array[3:0] ; wire S_AXI_BVALID_axi_wr_fsm; //------------------------------------- //AXI WRITE FSM COMPONENT INSTANTIATION //------------------------------------- write_netlist_v8_2 #(.C_AXI_TYPE(C_AXI_TYPE)) axi_wr_fsm ( .S_ACLK(S_ACLK), .S_ARESETN(S_ARESETN), .S_AXI_AWVALID(S_AXI_AWVALID), .aw_ready_r(aw_ready_r), .S_AXI_WVALID(S_AXI_WVALID), .S_AXI_WREADY(S_AXI_WREADY), .S_AXI_BREADY(S_AXI_BREADY), .S_AXI_WR_EN(S_AXI_WR_EN), .w_last_c(w_last_c), .bready_timeout_c(bready_timeout_c), .addr_en_c(addr_en_c), .incr_addr_c(incr_addr_c), .bvalid_c(bvalid_c), .S_AXI_BVALID (S_AXI_BVALID_axi_wr_fsm) ); //Wrap Address boundary calculation always@(*) begin num_of_bytes_c = 2**((C_AXI_TYPE == 1 && C_AXI_SLAVE_TYPE == 0)?S_AXI_AWSIZE:0); total_bytes = (num_of_bytes_r)*(awlen_int+1); wrap_base_addr = ((awaddr_reg)/((total_bytes==0)?1:total_bytes))*(total_bytes); wrap_boundary = wrap_base_addr+total_bytes; end //------------------------------------------------------------------------- // BMG address generation //------------------------------------------------------------------------- always @(posedge S_ACLK or S_ARESETN) begin if (S_ARESETN == 1'b1) begin awaddr_reg <= 0; num_of_bytes_r <= 0; awburst_int <= 0; end else begin if (addr_en_c == 1'b1) begin awaddr_reg <= #FLOP_DELAY S_AXI_AWADDR ; num_of_bytes_r <= num_of_bytes_c; awburst_int <= ((C_AXI_TYPE == 1 && C_AXI_SLAVE_TYPE == 0)?S_AXI_AWBURST:2'b01); end else if (incr_addr_c == 1'b1) begin if (awburst_int == 2'b10) begin if(awaddr_reg == (wrap_boundary-num_of_bytes_r)) begin awaddr_reg <= wrap_base_addr; end else begin awaddr_reg <= awaddr_reg + num_of_bytes_r; end end else if (awburst_int == 2'b01 || awburst_int == 2'b11) begin awaddr_reg <= awaddr_reg + num_of_bytes_r; end end end end assign S_AXI_AWADDR_OUT = ((C_AXI_TYPE == 1 && C_AXI_SLAVE_TYPE == 0)? awaddr_reg[C_AXI_AWADDR_WIDTH-1:C_RANGE]:awaddr_reg); //------------------------------------------------------------------------- // AXI wlast generation //------------------------------------------------------------------------- always @(posedge S_ACLK or S_ARESETN) begin if (S_ARESETN == 1'b1) begin awlen_cntr_r <= 0; awlen_int <= 0; end else begin if (addr_en_c == 1'b1) begin awlen_int <= #FLOP_DELAY (C_AXI_TYPE == 0?0:S_AXI_AWLEN) ; awlen_cntr_r <= #FLOP_DELAY (C_AXI_TYPE == 0?0:S_AXI_AWLEN) ; end else if (dec_alen_c == 1'b1) begin awlen_cntr_r <= #FLOP_DELAY awlen_cntr_r - 1 ; end end end assign w_last_c = (awlen_cntr_r == 0 && S_AXI_WVALID == 1'b1)?1'b1:1'b0; assign dec_alen_c = (incr_addr_c | w_last_c); //------------------------------------------------------------------------- // Generation of bvalid counter for outstanding transactions //------------------------------------------------------------------------- always @(posedge S_ACLK or S_ARESETN) begin if (S_ARESETN == 1'b1) begin bvalid_count_r <= 0; end else begin // bvalid_count_r generation if (bvalid_c == 1'b1 && bvalid_r == 1'b1 && S_AXI_BREADY == 1'b1) begin bvalid_count_r <= #FLOP_DELAY bvalid_count_r ; end else if (bvalid_c == 1'b1) begin bvalid_count_r <= #FLOP_DELAY bvalid_count_r + 1 ; end else if (bvalid_r == 1'b1 && S_AXI_BREADY == 1'b1 && bvalid_count_r != 0) begin bvalid_count_r <= #FLOP_DELAY bvalid_count_r - 1 ; end end end //------------------------------------------------------------------------- // Generation of bvalid when BID is used //------------------------------------------------------------------------- generate if (C_HAS_AXI_ID == 1) begin:gaxi_bvalid_id_r always @(posedge S_ACLK or S_ARESETN) begin if (S_ARESETN == 1'b1) begin bvalid_r <= 0; bvalid_d1_c <= 0; end else begin // Delay the generation o bvalid_r for generation for BID bvalid_d1_c <= bvalid_c; //external bvalid signal generation if (bvalid_d1_c == 1'b1) begin bvalid_r <= #FLOP_DELAY 1'b1 ; end else if (bvalid_count_r <= 1 && S_AXI_BREADY == 1'b1) begin bvalid_r <= #FLOP_DELAY 0 ; end end end end endgenerate //------------------------------------------------------------------------- // Generation of bvalid when BID is not used //------------------------------------------------------------------------- generate if(C_HAS_AXI_ID == 0) begin:gaxi_bvalid_noid_r always @(posedge S_ACLK or S_ARESETN) begin if (S_ARESETN == 1'b1) begin bvalid_r <= 0; end else begin //external bvalid signal generation if (bvalid_c == 1'b1) begin bvalid_r <= #FLOP_DELAY 1'b1 ; end else if (bvalid_count_r <= 1 && S_AXI_BREADY == 1'b1) begin bvalid_r <= #FLOP_DELAY 0 ; end end end end endgenerate //------------------------------------------------------------------------- // Generation of Bready timeout //------------------------------------------------------------------------- always @(bvalid_count_r) begin // bready_timeout_c generation if(bvalid_count_r == C_AXI_OS_WR-1) begin bready_timeout_c <= 1'b1; end else begin bready_timeout_c <= 1'b0; end end //------------------------------------------------------------------------- // Generation of BID //------------------------------------------------------------------------- generate if(C_HAS_AXI_ID == 1) begin:gaxi_bid_gen always @(posedge S_ACLK or S_ARESETN) begin if (S_ARESETN == 1'b1) begin bvalid_wr_cnt_r <= 0; bvalid_rd_cnt_r <= 0; end else begin // STORE AWID IN AN ARRAY if(bvalid_c == 1'b1) begin bvalid_wr_cnt_r <= bvalid_wr_cnt_r + 1; end // generate BID FROM AWID ARRAY bvalid_rd_cnt_r <= #FLOP_DELAY bvalid_rd_cnt_c ; S_AXI_BID <= axi_bid_array[bvalid_rd_cnt_c]; end end assign bvalid_rd_cnt_c = (bvalid_r == 1'b1 && S_AXI_BREADY == 1'b1)?bvalid_rd_cnt_r+1:bvalid_rd_cnt_r; //------------------------------------------------------------------------- // Storing AWID for generation of BID //------------------------------------------------------------------------- always @(posedge S_ACLK or S_ARESETN) begin if(S_ARESETN == 1'b1) begin axi_bid_array[0] = 0; axi_bid_array[1] = 0; axi_bid_array[2] = 0; axi_bid_array[3] = 0; end else if(aw_ready_r == 1'b1 && S_AXI_AWVALID == 1'b1) begin axi_bid_array[bvalid_wr_cnt_r] <= S_AXI_AWID; end end end endgenerate assign S_AXI_BVALID = bvalid_r; assign S_AXI_AWREADY = aw_ready_r; endmodule module blk_mem_axi_read_wrapper_beh_v8_2 # ( //// AXI Interface related parameters start here parameter C_INTERFACE_TYPE = 0, parameter C_AXI_TYPE = 0, parameter C_AXI_SLAVE_TYPE = 0, parameter C_MEMORY_TYPE = 0, parameter C_WRITE_WIDTH_A = 4, parameter C_WRITE_DEPTH_A = 32, parameter C_ADDRA_WIDTH = 12, parameter C_AXI_PIPELINE_STAGES = 0, parameter C_AXI_ARADDR_WIDTH = 12, parameter C_HAS_AXI_ID = 0, parameter C_AXI_ID_WIDTH = 4, parameter C_ADDRB_WIDTH = 12 ) ( //// AXI Global Signals input S_ACLK, input S_ARESETN, //// AXI Full/Lite Slave Read (Read side) input [C_AXI_ARADDR_WIDTH-1:0] S_AXI_ARADDR, input [7:0] S_AXI_ARLEN, input [2:0] S_AXI_ARSIZE, input [1:0] S_AXI_ARBURST, input S_AXI_ARVALID, output S_AXI_ARREADY, output S_AXI_RLAST, output S_AXI_RVALID, input S_AXI_RREADY, input [C_AXI_ID_WIDTH-1:0] S_AXI_ARID, output reg [C_AXI_ID_WIDTH-1:0] S_AXI_RID = 0, //// AXI Full/Lite Read Address Signals to BRAM output [C_ADDRB_WIDTH-1:0] S_AXI_ARADDR_OUT, output S_AXI_RD_EN ); localparam FLOP_DELAY = 100; // 100 ps localparam C_RANGE = ((C_WRITE_WIDTH_A == 8)?0: ((C_WRITE_WIDTH_A==16)?1: ((C_WRITE_WIDTH_A==32)?2: ((C_WRITE_WIDTH_A==64)?3: ((C_WRITE_WIDTH_A==128)?4: ((C_WRITE_WIDTH_A==256)?5:0)))))); reg [C_AXI_ID_WIDTH-1:0] ar_id_r=0; wire addr_en_c; wire rd_en_c; wire incr_addr_c; wire single_trans_c; wire dec_alen_c; wire mux_sel_c; wire r_last_c; wire r_last_int_c; wire [C_ADDRB_WIDTH-1 : 0] araddr_out; reg [7:0] arlen_int_r=0; reg [7:0] arlen_cntr=8'h01; reg [1:0] arburst_int_c=0; reg [1:0] arburst_int_r=0; reg [((C_AXI_TYPE == 1 && C_AXI_SLAVE_TYPE == 0)? C_AXI_ARADDR_WIDTH:C_ADDRA_WIDTH)-1:0] araddr_reg =0; integer num_of_bytes_c = 0; integer total_bytes = 0; integer num_of_bytes_r = 0; integer wrap_base_addr_r = 0; integer wrap_boundary_r = 0; reg [7:0] arlen_int_c=0; integer total_bytes_c = 0; integer wrap_base_addr_c = 0; integer wrap_boundary_c = 0; assign dec_alen_c = incr_addr_c | r_last_int_c; read_netlist_v8_2 #(.C_AXI_TYPE (1), .C_ADDRB_WIDTH (C_ADDRB_WIDTH)) axi_read_fsm ( .S_AXI_INCR_ADDR(incr_addr_c), .S_AXI_ADDR_EN(addr_en_c), .S_AXI_SINGLE_TRANS(single_trans_c), .S_AXI_MUX_SEL(mux_sel_c), .S_AXI_R_LAST(r_last_c), .S_AXI_R_LAST_INT(r_last_int_c), //// AXI Global Signals .S_ACLK(S_ACLK), .S_ARESETN(S_ARESETN), //// AXI Full/Lite Slave Read (Read side) .S_AXI_ARLEN(S_AXI_ARLEN), .S_AXI_ARVALID(S_AXI_ARVALID), .S_AXI_ARREADY(S_AXI_ARREADY), .S_AXI_RLAST(S_AXI_RLAST), .S_AXI_RVALID(S_AXI_RVALID), .S_AXI_RREADY(S_AXI_RREADY), //// AXI Full/Lite Read Address Signals to BRAM .S_AXI_RD_EN(rd_en_c) ); always@(*) begin num_of_bytes_c = 2**((C_AXI_TYPE == 1 && C_AXI_SLAVE_TYPE == 0)?S_AXI_ARSIZE:0); total_bytes = (num_of_bytes_r)*(arlen_int_r+1); wrap_base_addr_r = ((araddr_reg)/(total_bytes==0?1:total_bytes))*(total_bytes); wrap_boundary_r = wrap_base_addr_r+total_bytes; //////// combinatorial from interface arlen_int_c = (C_AXI_TYPE == 0?0:S_AXI_ARLEN); total_bytes_c = (num_of_bytes_c)*(arlen_int_c+1); wrap_base_addr_c = ((S_AXI_ARADDR)/(total_bytes_c==0?1:total_bytes_c))*(total_bytes_c); wrap_boundary_c = wrap_base_addr_c+total_bytes_c; arburst_int_c = ((C_AXI_TYPE == 1 && C_AXI_SLAVE_TYPE == 0)?S_AXI_ARBURST:1); end ////------------------------------------------------------------------------- //// BMG address generation ////------------------------------------------------------------------------- always @(posedge S_ACLK or S_ARESETN) begin if (S_ARESETN == 1'b1) begin araddr_reg <= 0; arburst_int_r <= 0; num_of_bytes_r <= 0; end else begin if (incr_addr_c == 1'b1 && addr_en_c == 1'b1 && single_trans_c == 1'b0) begin arburst_int_r <= arburst_int_c; num_of_bytes_r <= num_of_bytes_c; if (arburst_int_c == 2'b10) begin if(S_AXI_ARADDR == (wrap_boundary_c-num_of_bytes_c)) begin araddr_reg <= wrap_base_addr_c; end else begin araddr_reg <= S_AXI_ARADDR + num_of_bytes_c; end end else if (arburst_int_c == 2'b01 || arburst_int_c == 2'b11) begin araddr_reg <= S_AXI_ARADDR + num_of_bytes_c; end end else if (addr_en_c == 1'b1) begin araddr_reg <= S_AXI_ARADDR; num_of_bytes_r <= num_of_bytes_c; arburst_int_r <= arburst_int_c; end else if (incr_addr_c == 1'b1) begin if (arburst_int_r == 2'b10) begin if(araddr_reg == (wrap_boundary_r-num_of_bytes_r)) begin araddr_reg <= wrap_base_addr_r; end else begin araddr_reg <= araddr_reg + num_of_bytes_r; end end else if (arburst_int_r == 2'b01 || arburst_int_r == 2'b11) begin araddr_reg <= araddr_reg + num_of_bytes_r; end end end end assign araddr_out = ((C_AXI_TYPE == 1 && C_AXI_SLAVE_TYPE == 0)?araddr_reg[C_AXI_ARADDR_WIDTH-1:C_RANGE]:araddr_reg); ////----------------------------------------------------------------------- //// Counter to generate r_last_int_c from registered ARLEN - AXI FULL FSM ////----------------------------------------------------------------------- always @(posedge S_ACLK or S_ARESETN) begin if (S_ARESETN == 1'b1) begin arlen_cntr <= 8'h01; arlen_int_r <= 0; end else begin if (addr_en_c == 1'b1 && dec_alen_c == 1'b1 && single_trans_c == 1'b0) begin arlen_int_r <= (C_AXI_TYPE == 0?0:S_AXI_ARLEN) ; arlen_cntr <= S_AXI_ARLEN - 1'b1; end else if (addr_en_c == 1'b1) begin arlen_int_r <= (C_AXI_TYPE == 0?0:S_AXI_ARLEN) ; arlen_cntr <= (C_AXI_TYPE == 0?0:S_AXI_ARLEN) ; end else if (dec_alen_c == 1'b1) begin arlen_cntr <= arlen_cntr - 1'b1 ; end else begin arlen_cntr <= arlen_cntr; end end end assign r_last_int_c = (arlen_cntr == 0 && S_AXI_RREADY == 1'b1)?1'b1:1'b0; ////------------------------------------------------------------------------ //// AXI FULL FSM //// Mux Selection of ARADDR //// ARADDR is driven out from the read fsm based on the mux_sel_c //// Based on mux_sel either ARADDR is given out or the latched ARADDR is //// given out to BRAM ////------------------------------------------------------------------------ assign S_AXI_ARADDR_OUT = (mux_sel_c == 1'b0)?((C_AXI_TYPE == 1 && C_AXI_SLAVE_TYPE == 0)?S_AXI_ARADDR[C_AXI_ARADDR_WIDTH-1:C_RANGE]:S_AXI_ARADDR):araddr_out; ////------------------------------------------------------------------------ //// Assign output signals - AXI FULL FSM ////------------------------------------------------------------------------ assign S_AXI_RD_EN = rd_en_c; generate if (C_HAS_AXI_ID == 1) begin:gaxi_bvalid_id_r always @(posedge S_ACLK or S_ARESETN) begin if (S_ARESETN == 1'b1) begin S_AXI_RID <= 0; ar_id_r <= 0; end else begin if (addr_en_c == 1'b1 && rd_en_c == 1'b1) begin S_AXI_RID <= S_AXI_ARID; ar_id_r <= S_AXI_ARID; end else if (addr_en_c == 1'b1 && rd_en_c == 1'b0) begin ar_id_r <= S_AXI_ARID; end else if (rd_en_c == 1'b1) begin S_AXI_RID <= ar_id_r; end end end end endgenerate endmodule module blk_mem_axi_regs_fwd_v8_2 #(parameter C_DATA_WIDTH = 8 )( input ACLK, input ARESET, input S_VALID, output S_READY, input [C_DATA_WIDTH-1:0] S_PAYLOAD_DATA, output M_VALID, input M_READY, output reg [C_DATA_WIDTH-1:0] M_PAYLOAD_DATA ); reg [C_DATA_WIDTH-1:0] STORAGE_DATA; wire S_READY_I; reg M_VALID_I; reg [1:0] ARESET_D; //assign local signal to its output signal assign S_READY = S_READY_I; assign M_VALID = M_VALID_I; always @(posedge ACLK) begin ARESET_D <= {ARESET_D[0], ARESET}; end //Save payload data whenever we have a transaction on the slave side always @(posedge ACLK or ARESET) begin if (ARESET == 1'b1) begin STORAGE_DATA <= 0; end else begin if(S_VALID == 1'b1 && S_READY_I == 1'b1 ) begin STORAGE_DATA <= S_PAYLOAD_DATA; end end end always @(posedge ACLK) begin M_PAYLOAD_DATA = STORAGE_DATA; end //M_Valid set to high when we have a completed transfer on slave side //Is removed on a M_READY except if we have a new transfer on the slave side always @(posedge ACLK or ARESET_D) begin if (ARESET_D != 2'b00) begin M_VALID_I <= 1'b0; end else begin if (S_VALID == 1'b1) begin //Always set M_VALID_I when slave side is valid M_VALID_I <= 1'b1; end else if (M_READY == 1'b1 ) begin //Clear (or keep) when no slave side is valid but master side is ready M_VALID_I <= 1'b0; end end end //Slave Ready is either when Master side drives M_READY or we have space in our storage data assign S_READY_I = (M_READY || (!M_VALID_I)) && !(|(ARESET_D)); endmodule //***************************************************************************** // Output Register Stage module // // This module builds the output register stages of the memory. This module is // instantiated in the main memory module (BLK_MEM_GEN_v8_2) which is // declared/implemented further down in this file. //***************************************************************************** module BLK_MEM_GEN_v8_2_output_stage #(parameter C_FAMILY = "virtex7", parameter C_XDEVICEFAMILY = "virtex7", parameter C_RST_TYPE = "SYNC", parameter C_HAS_RST = 0, parameter C_RSTRAM = 0, parameter C_RST_PRIORITY = "CE", parameter C_INIT_VAL = "0", parameter C_HAS_EN = 0, parameter C_HAS_REGCE = 0, parameter C_DATA_WIDTH = 32, parameter C_ADDRB_WIDTH = 10, parameter C_HAS_MEM_OUTPUT_REGS = 0, parameter C_USE_SOFTECC = 0, parameter C_USE_ECC = 0, parameter NUM_STAGES = 1, parameter C_EN_ECC_PIPE = 0, parameter FLOP_DELAY = 100 ) ( input CLK, input RST, input EN, input REGCE, input [C_DATA_WIDTH-1:0] DIN_I, output reg [C_DATA_WIDTH-1:0] DOUT, input SBITERR_IN_I, input DBITERR_IN_I, output reg SBITERR, output reg DBITERR, input [C_ADDRB_WIDTH-1:0] RDADDRECC_IN_I, input ECCPIPECE, output reg [C_ADDRB_WIDTH-1:0] RDADDRECC ); //****************************** // Port and Generic Definitions //****************************** ////////////////////////////////////////////////////////////////////////// // Generic Definitions ////////////////////////////////////////////////////////////////////////// // C_FAMILY,C_XDEVICEFAMILY: Designates architecture targeted. The following // options are available - "spartan3", "spartan6", // "virtex4", "virtex5", "virtex6" and "virtex6l". // C_RST_TYPE : Type of reset - Synchronous or Asynchronous // C_HAS_RST : Determines the presence of the RST port // C_RSTRAM : Determines if special reset behavior is used // C_RST_PRIORITY : Determines the priority between CE and SR // C_INIT_VAL : Initialization value // C_HAS_EN : Determines the presence of the EN port // C_HAS_REGCE : Determines the presence of the REGCE port // C_DATA_WIDTH : Memory write/read width // C_ADDRB_WIDTH : Width of the ADDRB input port // C_HAS_MEM_OUTPUT_REGS : Designates the use of a register at the output // of the RAM primitive // C_USE_SOFTECC : Determines if the Soft ECC feature is used or // not. Only applicable Spartan-6 // C_USE_ECC : Determines if the ECC feature is used or // not. Only applicable for V5 and V6 // NUM_STAGES : Determines the number of output stages // FLOP_DELAY : Constant delay for register assignments ////////////////////////////////////////////////////////////////////////// // Port Definitions ////////////////////////////////////////////////////////////////////////// // CLK : Clock to synchronize all read and write operations // RST : Reset input to reset memory outputs to a user-defined // reset state // EN : Enable all read and write operations // REGCE : Register Clock Enable to control each pipeline output // register stages // DIN : Data input to the Output stage. // DOUT : Final Data output // SBITERR_IN : SBITERR input signal to the Output stage. // SBITERR : Final SBITERR Output signal. // DBITERR_IN : DBITERR input signal to the Output stage. // DBITERR : Final DBITERR Output signal. // RDADDRECC_IN : RDADDRECC input signal to the Output stage. // RDADDRECC : Final RDADDRECC Output signal. ////////////////////////////////////////////////////////////////////////// // Fix for CR-509792 localparam REG_STAGES = (NUM_STAGES < 2) ? 1 : NUM_STAGES-1; // Declare the pipeline registers // (includes mem output reg, mux pipeline stages, and mux output reg) reg [C_DATA_WIDTH*REG_STAGES-1:0] out_regs; reg [C_ADDRB_WIDTH*REG_STAGES-1:0] rdaddrecc_regs; reg [REG_STAGES-1:0] sbiterr_regs; reg [REG_STAGES-1:0] dbiterr_regs; reg [C_DATA_WIDTH*8-1:0] init_str = C_INIT_VAL; reg [C_DATA_WIDTH-1:0] init_val ; //********************************************* // Wire off optional inputs based on parameters //********************************************* wire en_i; wire regce_i; wire rst_i; // Internal signals reg [C_DATA_WIDTH-1:0] DIN; reg [C_ADDRB_WIDTH-1:0] RDADDRECC_IN; reg SBITERR_IN; reg DBITERR_IN; // Internal enable for output registers is tied to user EN or '1' depending // on parameters assign en_i = (C_HAS_EN==0 || EN); // Internal register enable for output registers is tied to user REGCE, EN or // '1' depending on parameters // For V4 ECC, REGCE is always 1 // Virtex-4 ECC Not Yet Supported assign regce_i = ((C_HAS_REGCE==1) && REGCE) || ((C_HAS_REGCE==0) && (C_HAS_EN==0 || EN)); //Internal SRR is tied to user RST or '0' depending on parameters assign rst_i = (C_HAS_RST==1) && RST; //**************************************************** // Power on: load up the output registers and latches //**************************************************** initial begin if (!($sscanf(init_str, "%h", init_val))) begin init_val = 0; end DOUT = init_val; RDADDRECC = 0; SBITERR = 1'b0; DBITERR = 1'b0; DIN = {(C_DATA_WIDTH){1'b0}}; RDADDRECC_IN = 0; SBITERR_IN = 0; DBITERR_IN = 0; // This will be one wider than need, but 0 is an error out_regs = {(REG_STAGES+1){init_val}}; rdaddrecc_regs = 0; sbiterr_regs = {(REG_STAGES+1){1'b0}}; dbiterr_regs = {(REG_STAGES+1){1'b0}}; end //*********************************************** // NUM_STAGES = 0 (No output registers. RAM only) //*********************************************** generate if (NUM_STAGES == 0) begin : zero_stages always @* begin DOUT = DIN; RDADDRECC = RDADDRECC_IN; SBITERR = SBITERR_IN; DBITERR = DBITERR_IN; end end endgenerate generate if (C_EN_ECC_PIPE == 0) begin : no_ecc_pipe_reg always @* begin DIN = DIN_I; SBITERR_IN = SBITERR_IN_I; DBITERR_IN = DBITERR_IN_I; RDADDRECC_IN = RDADDRECC_IN_I; end end endgenerate generate if (C_EN_ECC_PIPE == 1) begin : with_ecc_pipe_reg always @(posedge CLK) begin if(ECCPIPECE == 1) begin DIN <= #FLOP_DELAY DIN_I; SBITERR_IN <= #FLOP_DELAY SBITERR_IN_I; DBITERR_IN <= #FLOP_DELAY DBITERR_IN_I; RDADDRECC_IN <= #FLOP_DELAY RDADDRECC_IN_I; end end end endgenerate //*********************************************** // NUM_STAGES = 1 // (Mem Output Reg only or Mux Output Reg only) //*********************************************** // Possible valid combinations: // Note: C_HAS_MUX_OUTPUT_REGS_*=0 when (C_RSTRAM_*=1) // +-----------------------------------------+ // | C_RSTRAM_* | Reset Behavior | // +----------------+------------------------+ // | 0 | Normal Behavior | // +----------------+------------------------+ // | 1 | Special Behavior | // +----------------+------------------------+ // // Normal = REGCE gates reset, as in the case of all families except S3ADSP. // Special = EN gates reset, as in the case of S3ADSP. generate if (NUM_STAGES == 1 && (C_RSTRAM == 0 || (C_RSTRAM == 1 && (C_XDEVICEFAMILY != "spartan3adsp" && C_XDEVICEFAMILY != "aspartan3adsp" )) || C_HAS_MEM_OUTPUT_REGS == 0 || C_HAS_RST == 0)) begin : one_stages_norm always @(posedge CLK) begin if (C_RST_PRIORITY == "CE") begin //REGCE has priority if (regce_i && rst_i) begin DOUT <= #FLOP_DELAY init_val; RDADDRECC <= #FLOP_DELAY 0; SBITERR <= #FLOP_DELAY 1'b0; DBITERR <= #FLOP_DELAY 1'b0; end else if (regce_i) begin DOUT <= #FLOP_DELAY DIN; RDADDRECC <= #FLOP_DELAY RDADDRECC_IN; SBITERR <= #FLOP_DELAY SBITERR_IN; DBITERR <= #FLOP_DELAY DBITERR_IN; end //Output signal assignments end else begin //RST has priority if (rst_i) begin DOUT <= #FLOP_DELAY init_val; RDADDRECC <= #FLOP_DELAY RDADDRECC_IN; SBITERR <= #FLOP_DELAY 1'b0; DBITERR <= #FLOP_DELAY 1'b0; end else if (regce_i) begin DOUT <= #FLOP_DELAY DIN; RDADDRECC <= #FLOP_DELAY RDADDRECC_IN; SBITERR <= #FLOP_DELAY SBITERR_IN; DBITERR <= #FLOP_DELAY DBITERR_IN; end //Output signal assignments end //end Priority conditions end //end RST Type conditions end //end one_stages_norm generate statement endgenerate // Special Reset Behavior for S3ADSP generate if (NUM_STAGES == 1 && C_RSTRAM == 1 && (C_XDEVICEFAMILY =="spartan3adsp" || C_XDEVICEFAMILY =="aspartan3adsp")) begin : one_stage_splbhv always @(posedge CLK) begin if (en_i && rst_i) begin DOUT <= #FLOP_DELAY init_val; end else if (regce_i && !rst_i) begin DOUT <= #FLOP_DELAY DIN; end //Output signal assignments end //end CLK end //end one_stage_splbhv generate statement endgenerate //************************************************************ // NUM_STAGES > 1 // Mem Output Reg + Mux Output Reg // or // Mem Output Reg + Mux Pipeline Stages (>0) + Mux Output Reg // or // Mux Pipeline Stages (>0) + Mux Output Reg //************************************************************* generate if (NUM_STAGES > 1) begin : multi_stage //Asynchronous Reset always @(posedge CLK) begin if (C_RST_PRIORITY == "CE") begin //REGCE has priority if (regce_i && rst_i) begin DOUT <= #FLOP_DELAY init_val; RDADDRECC <= #FLOP_DELAY 0; SBITERR <= #FLOP_DELAY 1'b0; DBITERR <= #FLOP_DELAY 1'b0; end else if (regce_i) begin DOUT <= #FLOP_DELAY out_regs[C_DATA_WIDTH*(NUM_STAGES-2)+:C_DATA_WIDTH]; RDADDRECC <= #FLOP_DELAY rdaddrecc_regs[C_ADDRB_WIDTH*(NUM_STAGES-2)+:C_ADDRB_WIDTH]; SBITERR <= #FLOP_DELAY sbiterr_regs[NUM_STAGES-2]; DBITERR <= #FLOP_DELAY dbiterr_regs[NUM_STAGES-2]; end //Output signal assignments end else begin //RST has priority if (rst_i) begin DOUT <= #FLOP_DELAY init_val; RDADDRECC <= #FLOP_DELAY 0; SBITERR <= #FLOP_DELAY 1'b0; DBITERR <= #FLOP_DELAY 1'b0; end else if (regce_i) begin DOUT <= #FLOP_DELAY out_regs[C_DATA_WIDTH*(NUM_STAGES-2)+:C_DATA_WIDTH]; RDADDRECC <= #FLOP_DELAY rdaddrecc_regs[C_ADDRB_WIDTH*(NUM_STAGES-2)+:C_ADDRB_WIDTH]; SBITERR <= #FLOP_DELAY sbiterr_regs[NUM_STAGES-2]; DBITERR <= #FLOP_DELAY dbiterr_regs[NUM_STAGES-2]; end //Output signal assignments end //end Priority conditions // Shift the data through the output stages if (en_i) begin out_regs <= #FLOP_DELAY (out_regs << C_DATA_WIDTH) | DIN; rdaddrecc_regs <= #FLOP_DELAY (rdaddrecc_regs << C_ADDRB_WIDTH) | RDADDRECC_IN; sbiterr_regs <= #FLOP_DELAY (sbiterr_regs << 1) | SBITERR_IN; dbiterr_regs <= #FLOP_DELAY (dbiterr_regs << 1) | DBITERR_IN; end end //end CLK end //end multi_stage generate statement endgenerate endmodule module BLK_MEM_GEN_v8_2_softecc_output_reg_stage #(parameter C_DATA_WIDTH = 32, parameter C_ADDRB_WIDTH = 10, parameter C_HAS_SOFTECC_OUTPUT_REGS_B= 0, parameter C_USE_SOFTECC = 0, parameter FLOP_DELAY = 100 ) ( input CLK, input [C_DATA_WIDTH-1:0] DIN, output reg [C_DATA_WIDTH-1:0] DOUT, input SBITERR_IN, input DBITERR_IN, output reg SBITERR, output reg DBITERR, input [C_ADDRB_WIDTH-1:0] RDADDRECC_IN, output reg [C_ADDRB_WIDTH-1:0] RDADDRECC ); //****************************** // Port and Generic Definitions //****************************** ////////////////////////////////////////////////////////////////////////// // Generic Definitions ////////////////////////////////////////////////////////////////////////// // C_DATA_WIDTH : Memory write/read width // C_ADDRB_WIDTH : Width of the ADDRB input port // C_HAS_SOFTECC_OUTPUT_REGS_B : Designates the use of a register at the output // of the RAM primitive // C_USE_SOFTECC : Determines if the Soft ECC feature is used or // not. Only applicable Spartan-6 // FLOP_DELAY : Constant delay for register assignments ////////////////////////////////////////////////////////////////////////// // Port Definitions ////////////////////////////////////////////////////////////////////////// // CLK : Clock to synchronize all read and write operations // DIN : Data input to the Output stage. // DOUT : Final Data output // SBITERR_IN : SBITERR input signal to the Output stage. // SBITERR : Final SBITERR Output signal. // DBITERR_IN : DBITERR input signal to the Output stage. // DBITERR : Final DBITERR Output signal. // RDADDRECC_IN : RDADDRECC input signal to the Output stage. // RDADDRECC : Final RDADDRECC Output signal. ////////////////////////////////////////////////////////////////////////// reg [C_DATA_WIDTH-1:0] dout_i = 0; reg sbiterr_i = 0; reg dbiterr_i = 0; reg [C_ADDRB_WIDTH-1:0] rdaddrecc_i = 0; //*********************************************** // NO OUTPUT REGISTERS. //*********************************************** generate if (C_HAS_SOFTECC_OUTPUT_REGS_B==0) begin : no_output_stage always @* begin DOUT = DIN; RDADDRECC = RDADDRECC_IN; SBITERR = SBITERR_IN; DBITERR = DBITERR_IN; end end endgenerate //*********************************************** // WITH OUTPUT REGISTERS. //*********************************************** generate if (C_HAS_SOFTECC_OUTPUT_REGS_B==1) begin : has_output_stage always @(posedge CLK) begin dout_i <= #FLOP_DELAY DIN; rdaddrecc_i <= #FLOP_DELAY RDADDRECC_IN; sbiterr_i <= #FLOP_DELAY SBITERR_IN; dbiterr_i <= #FLOP_DELAY DBITERR_IN; end always @* begin DOUT = dout_i; RDADDRECC = rdaddrecc_i; SBITERR = sbiterr_i; DBITERR = dbiterr_i; end //end always end //end in_or_out_stage generate statement endgenerate endmodule //***************************************************************************** // Main Memory module // // This module is the top-level behavioral model and this implements the RAM //***************************************************************************** module BLK_MEM_GEN_v8_2_mem_module #(parameter C_CORENAME = "blk_mem_gen_v8_2", parameter C_FAMILY = "virtex7", parameter C_XDEVICEFAMILY = "virtex7", parameter C_MEM_TYPE = 2, parameter C_BYTE_SIZE = 9, parameter C_USE_BRAM_BLOCK = 0, parameter C_ALGORITHM = 1, parameter C_PRIM_TYPE = 3, parameter C_LOAD_INIT_FILE = 0, parameter C_INIT_FILE_NAME = "", parameter C_INIT_FILE = "", parameter C_USE_DEFAULT_DATA = 0, parameter C_DEFAULT_DATA = "0", parameter C_RST_TYPE = "SYNC", parameter C_HAS_RSTA = 0, parameter C_RST_PRIORITY_A = "CE", parameter C_RSTRAM_A = 0, parameter C_INITA_VAL = "0", parameter C_HAS_ENA = 1, parameter C_HAS_REGCEA = 0, parameter C_USE_BYTE_WEA = 0, parameter C_WEA_WIDTH = 1, parameter C_WRITE_MODE_A = "WRITE_FIRST", parameter C_WRITE_WIDTH_A = 32, parameter C_READ_WIDTH_A = 32, parameter C_WRITE_DEPTH_A = 64, parameter C_READ_DEPTH_A = 64, parameter C_ADDRA_WIDTH = 5, parameter C_HAS_RSTB = 0, parameter C_RST_PRIORITY_B = "CE", parameter C_RSTRAM_B = 0, parameter C_INITB_VAL = "", parameter C_HAS_ENB = 1, parameter C_HAS_REGCEB = 0, parameter C_USE_BYTE_WEB = 0, parameter C_WEB_WIDTH = 1, parameter C_WRITE_MODE_B = "WRITE_FIRST", parameter C_WRITE_WIDTH_B = 32, parameter C_READ_WIDTH_B = 32, parameter C_WRITE_DEPTH_B = 64, parameter C_READ_DEPTH_B = 64, parameter C_ADDRB_WIDTH = 5, parameter C_HAS_MEM_OUTPUT_REGS_A = 0, parameter C_HAS_MEM_OUTPUT_REGS_B = 0, parameter C_HAS_MUX_OUTPUT_REGS_A = 0, parameter C_HAS_MUX_OUTPUT_REGS_B = 0, parameter C_HAS_SOFTECC_INPUT_REGS_A = 0, parameter C_HAS_SOFTECC_OUTPUT_REGS_B= 0, parameter C_MUX_PIPELINE_STAGES = 0, parameter C_USE_SOFTECC = 0, parameter C_USE_ECC = 0, parameter C_HAS_INJECTERR = 0, parameter C_SIM_COLLISION_CHECK = "NONE", parameter C_COMMON_CLK = 1, parameter FLOP_DELAY = 100, parameter C_DISABLE_WARN_BHV_COLL = 0, parameter C_EN_ECC_PIPE = 0, parameter C_DISABLE_WARN_BHV_RANGE = 0 ) (input CLKA, input RSTA, input ENA, input REGCEA, input [C_WEA_WIDTH-1:0] WEA, input [C_ADDRA_WIDTH-1:0] ADDRA, input [C_WRITE_WIDTH_A-1:0] DINA, output [C_READ_WIDTH_A-1:0] DOUTA, input CLKB, input RSTB, input ENB, input REGCEB, input [C_WEB_WIDTH-1:0] WEB, input [C_ADDRB_WIDTH-1:0] ADDRB, input [C_WRITE_WIDTH_B-1:0] DINB, output [C_READ_WIDTH_B-1:0] DOUTB, input INJECTSBITERR, input INJECTDBITERR, input ECCPIPECE, input SLEEP, output SBITERR, output DBITERR, output [C_ADDRB_WIDTH-1:0] RDADDRECC ); //****************************** // Port and Generic Definitions //****************************** ////////////////////////////////////////////////////////////////////////// // Generic Definitions ////////////////////////////////////////////////////////////////////////// // C_CORENAME : Instance name of the Block Memory Generator core // C_FAMILY,C_XDEVICEFAMILY: Designates architecture targeted. The following // options are available - "spartan3", "spartan6", // "virtex4", "virtex5", "virtex6" and "virtex6l". // C_MEM_TYPE : Designates memory type. // It can be // 0 - Single Port Memory // 1 - Simple Dual Port Memory // 2 - True Dual Port Memory // 3 - Single Port Read Only Memory // 4 - Dual Port Read Only Memory // C_BYTE_SIZE : Size of a byte (8 or 9 bits) // C_ALGORITHM : Designates the algorithm method used // for constructing the memory. // It can be Fixed_Primitives, Minimum_Area or // Low_Power // C_PRIM_TYPE : Designates the user selected primitive used to // construct the memory. // // C_LOAD_INIT_FILE : Designates the use of an initialization file to // initialize memory contents. // C_INIT_FILE_NAME : Memory initialization file name. // C_USE_DEFAULT_DATA : Designates whether to fill remaining // initialization space with default data // C_DEFAULT_DATA : Default value of all memory locations // not initialized by the memory // initialization file. // C_RST_TYPE : Type of reset - Synchronous or Asynchronous // C_HAS_RSTA : Determines the presence of the RSTA port // C_RST_PRIORITY_A : Determines the priority between CE and SR for // Port A. // C_RSTRAM_A : Determines if special reset behavior is used for // Port A // C_INITA_VAL : The initialization value for Port A // C_HAS_ENA : Determines the presence of the ENA port // C_HAS_REGCEA : Determines the presence of the REGCEA port // C_USE_BYTE_WEA : Determines if the Byte Write is used or not. // C_WEA_WIDTH : The width of the WEA port // C_WRITE_MODE_A : Configurable write mode for Port A. It can be // WRITE_FIRST, READ_FIRST or NO_CHANGE. // C_WRITE_WIDTH_A : Memory write width for Port A. // C_READ_WIDTH_A : Memory read width for Port A. // C_WRITE_DEPTH_A : Memory write depth for Port A. // C_READ_DEPTH_A : Memory read depth for Port A. // C_ADDRA_WIDTH : Width of the ADDRA input port // C_HAS_RSTB : Determines the presence of the RSTB port // C_RST_PRIORITY_B : Determines the priority between CE and SR for // Port B. // C_RSTRAM_B : Determines if special reset behavior is used for // Port B // C_INITB_VAL : The initialization value for Port B // C_HAS_ENB : Determines the presence of the ENB port // C_HAS_REGCEB : Determines the presence of the REGCEB port // C_USE_BYTE_WEB : Determines if the Byte Write is used or not. // C_WEB_WIDTH : The width of the WEB port // C_WRITE_MODE_B : Configurable write mode for Port B. It can be // WRITE_FIRST, READ_FIRST or NO_CHANGE. // C_WRITE_WIDTH_B : Memory write width for Port B. // C_READ_WIDTH_B : Memory read width for Port B. // C_WRITE_DEPTH_B : Memory write depth for Port B. // C_READ_DEPTH_B : Memory read depth for Port B. // C_ADDRB_WIDTH : Width of the ADDRB input port // C_HAS_MEM_OUTPUT_REGS_A : Designates the use of a register at the output // of the RAM primitive for Port A. // C_HAS_MEM_OUTPUT_REGS_B : Designates the use of a register at the output // of the RAM primitive for Port B. // C_HAS_MUX_OUTPUT_REGS_A : Designates the use of a register at the output // of the MUX for Port A. // C_HAS_MUX_OUTPUT_REGS_B : Designates the use of a register at the output // of the MUX for Port B. // C_MUX_PIPELINE_STAGES : Designates the number of pipeline stages in // between the muxes. // C_USE_SOFTECC : Determines if the Soft ECC feature is used or // not. Only applicable Spartan-6 // C_USE_ECC : Determines if the ECC feature is used or // not. Only applicable for V5 and V6 // C_HAS_INJECTERR : Determines if the error injection pins // are present or not. If the ECC feature // is not used, this value is defaulted to // 0, else the following are the allowed // values: // 0 : No INJECTSBITERR or INJECTDBITERR pins // 1 : Only INJECTSBITERR pin exists // 2 : Only INJECTDBITERR pin exists // 3 : Both INJECTSBITERR and INJECTDBITERR pins exist // C_SIM_COLLISION_CHECK : Controls the disabling of Unisim model collision // warnings. It can be "ALL", "NONE", // "Warnings_Only" or "Generate_X_Only". // C_COMMON_CLK : Determins if the core has a single CLK input. // C_DISABLE_WARN_BHV_COLL : Controls the Behavioral Model Collision warnings // C_DISABLE_WARN_BHV_RANGE: Controls the Behavioral Model Out of Range // warnings ////////////////////////////////////////////////////////////////////////// // Port Definitions ////////////////////////////////////////////////////////////////////////// // CLKA : Clock to synchronize all read and write operations of Port A. // RSTA : Reset input to reset memory outputs to a user-defined // reset state for Port A. // ENA : Enable all read and write operations of Port A. // REGCEA : Register Clock Enable to control each pipeline output // register stages for Port A. // WEA : Write Enable to enable all write operations of Port A. // ADDRA : Address of Port A. // DINA : Data input of Port A. // DOUTA : Data output of Port A. // CLKB : Clock to synchronize all read and write operations of Port B. // RSTB : Reset input to reset memory outputs to a user-defined // reset state for Port B. // ENB : Enable all read and write operations of Port B. // REGCEB : Register Clock Enable to control each pipeline output // register stages for Port B. // WEB : Write Enable to enable all write operations of Port B. // ADDRB : Address of Port B. // DINB : Data input of Port B. // DOUTB : Data output of Port B. // INJECTSBITERR : Single Bit ECC Error Injection Pin. // INJECTDBITERR : Double Bit ECC Error Injection Pin. // SBITERR : Output signal indicating that a Single Bit ECC Error has been // detected and corrected. // DBITERR : Output signal indicating that a Double Bit ECC Error has been // detected. // RDADDRECC : Read Address Output signal indicating address at which an // ECC error has occurred. ////////////////////////////////////////////////////////////////////////// // Note: C_CORENAME parameter is hard-coded to "blk_mem_gen_v8_2" and it is // only used by this module to print warning messages. It is neither passed // down from blk_mem_gen_v8_2_xst.v nor present in the instantiation template // coregen generates //*************************************************************************** // constants for the core behavior //*************************************************************************** // file handles for logging //-------------------------------------------------- localparam ADDRFILE = 32'h8000_0001; //stdout for addr out of range localparam COLLFILE = 32'h8000_0001; //stdout for coll detection localparam ERRFILE = 32'h8000_0001; //stdout for file I/O errors // other constants //-------------------------------------------------- localparam COLL_DELAY = 100; // 100 ps // locally derived parameters to determine memory shape //----------------------------------------------------- localparam CHKBIT_WIDTH = (C_WRITE_WIDTH_A>57 ? 8 : (C_WRITE_WIDTH_A>26 ? 7 : (C_WRITE_WIDTH_A>11 ? 6 : (C_WRITE_WIDTH_A>4 ? 5 : (C_WRITE_WIDTH_A<5 ? 4 :0))))); localparam MIN_WIDTH_A = (C_WRITE_WIDTH_A < C_READ_WIDTH_A) ? C_WRITE_WIDTH_A : C_READ_WIDTH_A; localparam MIN_WIDTH_B = (C_WRITE_WIDTH_B < C_READ_WIDTH_B) ? C_WRITE_WIDTH_B : C_READ_WIDTH_B; localparam MIN_WIDTH = (MIN_WIDTH_A < MIN_WIDTH_B) ? MIN_WIDTH_A : MIN_WIDTH_B; localparam MAX_DEPTH_A = (C_WRITE_DEPTH_A > C_READ_DEPTH_A) ? C_WRITE_DEPTH_A : C_READ_DEPTH_A; localparam MAX_DEPTH_B = (C_WRITE_DEPTH_B > C_READ_DEPTH_B) ? C_WRITE_DEPTH_B : C_READ_DEPTH_B; localparam MAX_DEPTH = (MAX_DEPTH_A > MAX_DEPTH_B) ? MAX_DEPTH_A : MAX_DEPTH_B; // locally derived parameters to assist memory access //---------------------------------------------------- // Calculate the width ratios of each port with respect to the narrowest // port localparam WRITE_WIDTH_RATIO_A = C_WRITE_WIDTH_A/MIN_WIDTH; localparam READ_WIDTH_RATIO_A = C_READ_WIDTH_A/MIN_WIDTH; localparam WRITE_WIDTH_RATIO_B = C_WRITE_WIDTH_B/MIN_WIDTH; localparam READ_WIDTH_RATIO_B = C_READ_WIDTH_B/MIN_WIDTH; // To modify the LSBs of the 'wider' data to the actual // address value //---------------------------------------------------- localparam WRITE_ADDR_A_DIV = C_WRITE_WIDTH_A/MIN_WIDTH_A; localparam READ_ADDR_A_DIV = C_READ_WIDTH_A/MIN_WIDTH_A; localparam WRITE_ADDR_B_DIV = C_WRITE_WIDTH_B/MIN_WIDTH_B; localparam READ_ADDR_B_DIV = C_READ_WIDTH_B/MIN_WIDTH_B; // If byte writes aren't being used, make sure BYTE_SIZE is not // wider than the memory elements to avoid compilation warnings localparam BYTE_SIZE = (C_BYTE_SIZE < MIN_WIDTH) ? C_BYTE_SIZE : MIN_WIDTH; // The memory reg [MIN_WIDTH-1:0] memory [0:MAX_DEPTH-1]; reg [MIN_WIDTH-1:0] temp_mem_array [0:MAX_DEPTH-1]; reg [C_WRITE_WIDTH_A+CHKBIT_WIDTH-1:0] doublebit_error = 3; // ECC error arrays reg sbiterr_arr [0:MAX_DEPTH-1]; reg dbiterr_arr [0:MAX_DEPTH-1]; reg softecc_sbiterr_arr [0:MAX_DEPTH-1]; reg softecc_dbiterr_arr [0:MAX_DEPTH-1]; // Memory output 'latches' reg [C_READ_WIDTH_A-1:0] memory_out_a; reg [C_READ_WIDTH_B-1:0] memory_out_b; // ECC error inputs and outputs from output_stage module: reg sbiterr_in; wire sbiterr_sdp; reg dbiterr_in; wire dbiterr_sdp; wire [C_READ_WIDTH_B-1:0] dout_i; wire dbiterr_i; wire sbiterr_i; wire [C_ADDRB_WIDTH-1:0] rdaddrecc_i; reg [C_ADDRB_WIDTH-1:0] rdaddrecc_in; wire [C_ADDRB_WIDTH-1:0] rdaddrecc_sdp; // Reset values reg [C_READ_WIDTH_A-1:0] inita_val; reg [C_READ_WIDTH_B-1:0] initb_val; // Collision detect reg is_collision; reg is_collision_a, is_collision_delay_a; reg is_collision_b, is_collision_delay_b; // Temporary variables for initialization //--------------------------------------- integer status; integer initfile; integer meminitfile; // data input buffer reg [C_WRITE_WIDTH_A-1:0] mif_data; reg [C_WRITE_WIDTH_A-1:0] mem_data; // string values in hex reg [C_READ_WIDTH_A*8-1:0] inita_str = C_INITA_VAL; reg [C_READ_WIDTH_B*8-1:0] initb_str = C_INITB_VAL; reg [C_WRITE_WIDTH_A*8-1:0] default_data_str = C_DEFAULT_DATA; // initialization filename reg [1023*8-1:0] init_file_str = C_INIT_FILE_NAME; reg [1023*8-1:0] mem_init_file_str = C_INIT_FILE; //Constants used to calculate the effective address widths for each of the //four ports. integer cnt = 1; integer write_addr_a_width, read_addr_a_width; integer write_addr_b_width, read_addr_b_width; localparam C_FAMILY_LOCALPARAM = (C_FAMILY=="virtexu"?"virtex7":(C_FAMILY=="kintexu" ? "virtex7":(C_FAMILY=="virtex7" ? "virtex7" : (C_FAMILY=="virtex7l" ? "virtex7" : (C_FAMILY=="qvirtex7" ? "virtex7" : (C_FAMILY=="qvirtex7l" ? "virtex7" : (C_FAMILY=="kintex7" ? "virtex7" : (C_FAMILY=="kintex7l" ? "virtex7" : (C_FAMILY=="qkintex7" ? "virtex7" : (C_FAMILY=="qkintex7l" ? "virtex7" : (C_FAMILY=="artix7" ? "virtex7" : (C_FAMILY=="artix7l" ? "virtex7" : (C_FAMILY=="qartix7" ? "virtex7" : (C_FAMILY=="qartix7l" ? "virtex7" : (C_FAMILY=="aartix7" ? "virtex7" : (C_FAMILY=="zynq" ? "virtex7" : (C_FAMILY=="azynq" ? "virtex7" : (C_FAMILY=="qzynq" ? "virtex7" : C_FAMILY)))))))))))))))))); // Internal configuration parameters //--------------------------------------------- localparam SINGLE_PORT = (C_MEM_TYPE==0 || C_MEM_TYPE==3); localparam IS_ROM = (C_MEM_TYPE==3 || C_MEM_TYPE==4); localparam HAS_A_WRITE = (!IS_ROM); localparam HAS_B_WRITE = (C_MEM_TYPE==2); localparam HAS_A_READ = (C_MEM_TYPE!=1); localparam HAS_B_READ = (!SINGLE_PORT); localparam HAS_B_PORT = (HAS_B_READ || HAS_B_WRITE); // Calculate the mux pipeline register stages for Port A and Port B //------------------------------------------------------------------ localparam MUX_PIPELINE_STAGES_A = (C_HAS_MUX_OUTPUT_REGS_A) ? C_MUX_PIPELINE_STAGES : 0; localparam MUX_PIPELINE_STAGES_B = (C_HAS_MUX_OUTPUT_REGS_B) ? C_MUX_PIPELINE_STAGES : 0; // Calculate total number of register stages in the core // ----------------------------------------------------- localparam NUM_OUTPUT_STAGES_A = (C_HAS_MEM_OUTPUT_REGS_A+MUX_PIPELINE_STAGES_A+C_HAS_MUX_OUTPUT_REGS_A); localparam NUM_OUTPUT_STAGES_B = (C_HAS_MEM_OUTPUT_REGS_B+MUX_PIPELINE_STAGES_B+C_HAS_MUX_OUTPUT_REGS_B); wire ena_i; wire enb_i; wire reseta_i; wire resetb_i; wire [C_WEA_WIDTH-1:0] wea_i; wire [C_WEB_WIDTH-1:0] web_i; wire rea_i; wire reb_i; wire rsta_outp_stage; wire rstb_outp_stage; // ECC SBITERR/DBITERR Outputs // The ECC Behavior is modeled by the behavioral models only for Virtex-6. // For Virtex-5, these outputs will be tied to 0. assign SBITERR = ((C_MEM_TYPE == 1 && C_USE_ECC == 1) || C_USE_SOFTECC == 1)?sbiterr_sdp:0; assign DBITERR = ((C_MEM_TYPE == 1 && C_USE_ECC == 1) || C_USE_SOFTECC == 1)?dbiterr_sdp:0; assign RDADDRECC = (((C_FAMILY_LOCALPARAM == "virtex7") && C_MEM_TYPE == 1 && C_USE_ECC == 1) || C_USE_SOFTECC == 1)?rdaddrecc_sdp:0; // This effectively wires off optional inputs assign ena_i = (C_HAS_ENA==0) || ENA; assign enb_i = ((C_HAS_ENB==0) || ENB) && HAS_B_PORT; assign wea_i = (HAS_A_WRITE && ena_i) ? WEA : 'b0; assign web_i = (HAS_B_WRITE && enb_i) ? WEB : 'b0; assign rea_i = (HAS_A_READ) ? ena_i : 'b0; assign reb_i = (HAS_B_READ) ? enb_i : 'b0; // These signals reset the memory latches assign reseta_i = ((C_HAS_RSTA==1 && RSTA && NUM_OUTPUT_STAGES_A==0) || (C_HAS_RSTA==1 && RSTA && C_RSTRAM_A==1)); assign resetb_i = ((C_HAS_RSTB==1 && RSTB && NUM_OUTPUT_STAGES_B==0) || (C_HAS_RSTB==1 && RSTB && C_RSTRAM_B==1)); // Tasks to access the memory //--------------------------- //************** // write_a //************** task write_a (input reg [C_ADDRA_WIDTH-1:0] addr, input reg [C_WEA_WIDTH-1:0] byte_en, input reg [C_WRITE_WIDTH_A-1:0] data, input inj_sbiterr, input inj_dbiterr); reg [C_WRITE_WIDTH_A-1:0] current_contents; reg [C_ADDRA_WIDTH-1:0] address; integer i; begin // Shift the address by the ratio address = (addr/WRITE_ADDR_A_DIV); if (address >= C_WRITE_DEPTH_A) begin if (!C_DISABLE_WARN_BHV_RANGE) begin $fdisplay(ADDRFILE, "%0s WARNING: Address %0h is outside range for A Write", C_CORENAME, addr); end // valid address end else begin // Combine w/ byte writes if (C_USE_BYTE_WEA) begin // Get the current memory contents if (WRITE_WIDTH_RATIO_A == 1) begin // Workaround for IUS 5.5 part-select issue current_contents = memory[address]; end else begin for (i = 0; i < WRITE_WIDTH_RATIO_A; i = i + 1) begin current_contents[MIN_WIDTH*i+:MIN_WIDTH] = memory[address*WRITE_WIDTH_RATIO_A + i]; end end // Apply incoming bytes if (C_WEA_WIDTH == 1) begin // Workaround for IUS 5.5 part-select issue if (byte_en[0]) begin current_contents = data; end end else begin for (i = 0; i < C_WEA_WIDTH; i = i + 1) begin if (byte_en[i]) begin current_contents[BYTE_SIZE*i+:BYTE_SIZE] = data[BYTE_SIZE*i+:BYTE_SIZE]; end end end // No byte-writes, overwrite the whole word end else begin current_contents = data; end // Insert double bit errors: if (C_USE_ECC == 1) begin if ((C_HAS_INJECTERR == 2 || C_HAS_INJECTERR == 3) && inj_dbiterr == 1'b1) begin current_contents[0] = !(current_contents[0]); current_contents[1] = !(current_contents[1]); end end // Insert softecc double bit errors: if (C_USE_SOFTECC == 1) begin if ((C_HAS_INJECTERR == 2 || C_HAS_INJECTERR == 3) && inj_dbiterr == 1'b1) begin doublebit_error[C_WRITE_WIDTH_A+CHKBIT_WIDTH-1:2] = doublebit_error[C_WRITE_WIDTH_A+CHKBIT_WIDTH-3:0]; doublebit_error[0] = doublebit_error[C_WRITE_WIDTH_A+CHKBIT_WIDTH-1]; doublebit_error[1] = doublebit_error[C_WRITE_WIDTH_A+CHKBIT_WIDTH-2]; current_contents = current_contents ^ doublebit_error[C_WRITE_WIDTH_A-1:0]; end end // Write data to memory if (WRITE_WIDTH_RATIO_A == 1) begin // Workaround for IUS 5.5 part-select issue memory[address*WRITE_WIDTH_RATIO_A] = current_contents; end else begin for (i = 0; i < WRITE_WIDTH_RATIO_A; i = i + 1) begin memory[address*WRITE_WIDTH_RATIO_A + i] = current_contents[MIN_WIDTH*i+:MIN_WIDTH]; end end // Store the address at which error is injected: if ((C_FAMILY_LOCALPARAM == "virtex7") && C_USE_ECC == 1) begin if ((C_HAS_INJECTERR == 1 && inj_sbiterr == 1'b1) || (C_HAS_INJECTERR == 3 && inj_sbiterr == 1'b1 && inj_dbiterr != 1'b1)) begin sbiterr_arr[addr] = 1; end else begin sbiterr_arr[addr] = 0; end if ((C_HAS_INJECTERR == 2 || C_HAS_INJECTERR == 3) && inj_dbiterr == 1'b1) begin dbiterr_arr[addr] = 1; end else begin dbiterr_arr[addr] = 0; end end // Store the address at which softecc error is injected: if (C_USE_SOFTECC == 1) begin if ((C_HAS_INJECTERR == 1 && inj_sbiterr == 1'b1) || (C_HAS_INJECTERR == 3 && inj_sbiterr == 1'b1 && inj_dbiterr != 1'b1)) begin softecc_sbiterr_arr[addr] = 1; end else begin softecc_sbiterr_arr[addr] = 0; end if ((C_HAS_INJECTERR == 2 || C_HAS_INJECTERR == 3) && inj_dbiterr == 1'b1) begin softecc_dbiterr_arr[addr] = 1; end else begin softecc_dbiterr_arr[addr] = 0; end end end end endtask //************** // write_b //************** task write_b (input reg [C_ADDRB_WIDTH-1:0] addr, input reg [C_WEB_WIDTH-1:0] byte_en, input reg [C_WRITE_WIDTH_B-1:0] data); reg [C_WRITE_WIDTH_B-1:0] current_contents; reg [C_ADDRB_WIDTH-1:0] address; integer i; begin // Shift the address by the ratio address = (addr/WRITE_ADDR_B_DIV); if (address >= C_WRITE_DEPTH_B) begin if (!C_DISABLE_WARN_BHV_RANGE) begin $fdisplay(ADDRFILE, "%0s WARNING: Address %0h is outside range for B Write", C_CORENAME, addr); end // valid address end else begin // Combine w/ byte writes if (C_USE_BYTE_WEB) begin // Get the current memory contents if (WRITE_WIDTH_RATIO_B == 1) begin // Workaround for IUS 5.5 part-select issue current_contents = memory[address]; end else begin for (i = 0; i < WRITE_WIDTH_RATIO_B; i = i + 1) begin current_contents[MIN_WIDTH*i+:MIN_WIDTH] = memory[address*WRITE_WIDTH_RATIO_B + i]; end end // Apply incoming bytes if (C_WEB_WIDTH == 1) begin // Workaround for IUS 5.5 part-select issue if (byte_en[0]) begin current_contents = data; end end else begin for (i = 0; i < C_WEB_WIDTH; i = i + 1) begin if (byte_en[i]) begin current_contents[BYTE_SIZE*i+:BYTE_SIZE] = data[BYTE_SIZE*i+:BYTE_SIZE]; end end end // No byte-writes, overwrite the whole word end else begin current_contents = data; end // Write data to memory if (WRITE_WIDTH_RATIO_B == 1) begin // Workaround for IUS 5.5 part-select issue memory[address*WRITE_WIDTH_RATIO_B] = current_contents; end else begin for (i = 0; i < WRITE_WIDTH_RATIO_B; i = i + 1) begin memory[address*WRITE_WIDTH_RATIO_B + i] = current_contents[MIN_WIDTH*i+:MIN_WIDTH]; end end end end endtask //************** // read_a //************** task read_a (input reg [C_ADDRA_WIDTH-1:0] addr, input reg reset); reg [C_ADDRA_WIDTH-1:0] address; integer i; begin if (reset) begin memory_out_a <= #FLOP_DELAY inita_val; end else begin // Shift the address by the ratio address = (addr/READ_ADDR_A_DIV); if (address >= C_READ_DEPTH_A) begin if (!C_DISABLE_WARN_BHV_RANGE) begin $fdisplay(ADDRFILE, "%0s WARNING: Address %0h is outside range for A Read", C_CORENAME, addr); end memory_out_a <= #FLOP_DELAY 'bX; // valid address end else begin if (READ_WIDTH_RATIO_A==1) begin memory_out_a <= #FLOP_DELAY memory[address*READ_WIDTH_RATIO_A]; end else begin // Increment through the 'partial' words in the memory for (i = 0; i < READ_WIDTH_RATIO_A; i = i + 1) begin memory_out_a[MIN_WIDTH*i+:MIN_WIDTH] <= #FLOP_DELAY memory[address*READ_WIDTH_RATIO_A + i]; end end //end READ_WIDTH_RATIO_A==1 loop end //end valid address loop end //end reset-data assignment loops end endtask //************** // read_b //************** task read_b (input reg [C_ADDRB_WIDTH-1:0] addr, input reg reset); reg [C_ADDRB_WIDTH-1:0] address; integer i; begin if (reset) begin memory_out_b <= #FLOP_DELAY initb_val; sbiterr_in <= #FLOP_DELAY 1'b0; dbiterr_in <= #FLOP_DELAY 1'b0; rdaddrecc_in <= #FLOP_DELAY 0; end else begin // Shift the address address = (addr/READ_ADDR_B_DIV); if (address >= C_READ_DEPTH_B) begin if (!C_DISABLE_WARN_BHV_RANGE) begin $fdisplay(ADDRFILE, "%0s WARNING: Address %0h is outside range for B Read", C_CORENAME, addr); end memory_out_b <= #FLOP_DELAY 'bX; sbiterr_in <= #FLOP_DELAY 1'bX; dbiterr_in <= #FLOP_DELAY 1'bX; rdaddrecc_in <= #FLOP_DELAY 'bX; // valid address end else begin if (READ_WIDTH_RATIO_B==1) begin memory_out_b <= #FLOP_DELAY memory[address*READ_WIDTH_RATIO_B]; end else begin // Increment through the 'partial' words in the memory for (i = 0; i < READ_WIDTH_RATIO_B; i = i + 1) begin memory_out_b[MIN_WIDTH*i+:MIN_WIDTH] <= #FLOP_DELAY memory[address*READ_WIDTH_RATIO_B + i]; end end if ((C_FAMILY_LOCALPARAM == "virtex7") && C_USE_ECC == 1) begin rdaddrecc_in <= #FLOP_DELAY addr; if (sbiterr_arr[addr] == 1) begin sbiterr_in <= #FLOP_DELAY 1'b1; end else begin sbiterr_in <= #FLOP_DELAY 1'b0; end if (dbiterr_arr[addr] == 1) begin dbiterr_in <= #FLOP_DELAY 1'b1; end else begin dbiterr_in <= #FLOP_DELAY 1'b0; end end else if (C_USE_SOFTECC == 1) begin rdaddrecc_in <= #FLOP_DELAY addr; if (softecc_sbiterr_arr[addr] == 1) begin sbiterr_in <= #FLOP_DELAY 1'b1; end else begin sbiterr_in <= #FLOP_DELAY 1'b0; end if (softecc_dbiterr_arr[addr] == 1) begin dbiterr_in <= #FLOP_DELAY 1'b1; end else begin dbiterr_in <= #FLOP_DELAY 1'b0; end end else begin rdaddrecc_in <= #FLOP_DELAY 0; dbiterr_in <= #FLOP_DELAY 1'b0; sbiterr_in <= #FLOP_DELAY 1'b0; end //end SOFTECC Loop end //end Valid address loop end //end reset-data assignment loops end endtask //************** // reset_a //************** task reset_a (input reg reset); begin if (reset) memory_out_a <= #FLOP_DELAY inita_val; end endtask //************** // reset_b //************** task reset_b (input reg reset); begin if (reset) memory_out_b <= #FLOP_DELAY initb_val; end endtask //************** // init_memory //************** task init_memory; integer i, j, addr_step; integer status; reg [C_WRITE_WIDTH_A-1:0] default_data; begin default_data = 0; //Display output message indicating that the behavioral model is being //initialized if (C_USE_DEFAULT_DATA || C_LOAD_INIT_FILE) $display(" Block Memory Generator module loading initial data..."); // Convert the default to hex if (C_USE_DEFAULT_DATA) begin if (default_data_str == "") begin $fdisplay(ERRFILE, "%0s ERROR: C_DEFAULT_DATA is empty!", C_CORENAME); $finish; end else begin status = $sscanf(default_data_str, "%h", default_data); if (status == 0) begin $fdisplay(ERRFILE, {"%0s ERROR: Unsuccessful hexadecimal read", "from C_DEFAULT_DATA: %0s"}, C_CORENAME, C_DEFAULT_DATA); $finish; end end end // Step by WRITE_ADDR_A_DIV through the memory via the // Port A write interface to hit every location once addr_step = WRITE_ADDR_A_DIV; // 'write' to every location with default (or 0) for (i = 0; i < C_WRITE_DEPTH_A*addr_step; i = i + addr_step) begin write_a(i, {C_WEA_WIDTH{1'b1}}, default_data, 1'b0, 1'b0); end // Get specialized data from the MIF file if (C_LOAD_INIT_FILE) begin if (init_file_str == "") begin $fdisplay(ERRFILE, "%0s ERROR: C_INIT_FILE_NAME is empty!", C_CORENAME); $finish; end else begin initfile = $fopen(init_file_str, "r"); if (initfile == 0) begin $fdisplay(ERRFILE, {"%0s, ERROR: Problem opening", "C_INIT_FILE_NAME: %0s!"}, C_CORENAME, init_file_str); $finish; end else begin // loop through the mif file, loading in the data for (i = 0; i < C_WRITE_DEPTH_A*addr_step; i = i + addr_step) begin status = $fscanf(initfile, "%b", mif_data); if (status > 0) begin write_a(i, {C_WEA_WIDTH{1'b1}}, mif_data, 1'b0, 1'b0); end end $fclose(initfile); end //initfile end //init_file_str end //C_LOAD_INIT_FILE if (C_USE_BRAM_BLOCK) begin // Get specialized data from the MIF file if (C_INIT_FILE != "NONE") begin if (mem_init_file_str == "") begin $fdisplay(ERRFILE, "%0s ERROR: C_INIT_FILE is empty!", C_CORENAME); $finish; end else begin meminitfile = $fopen(mem_init_file_str, "r"); if (meminitfile == 0) begin $fdisplay(ERRFILE, {"%0s, ERROR: Problem opening", "C_INIT_FILE: %0s!"}, C_CORENAME, mem_init_file_str); $finish; end else begin // loop through the mif file, loading in the data $readmemh(mem_init_file_str, memory ); for (j = 0; j < MAX_DEPTH-1 ; j = j + 1) begin end $fclose(meminitfile); end //meminitfile end //mem_init_file_str end //C_INIT_FILE end //C_USE_BRAM_BLOCK //Display output message indicating that the behavioral model is done //initializing if (C_USE_DEFAULT_DATA || C_LOAD_INIT_FILE) $display(" Block Memory Generator data initialization complete."); end endtask //************** // log2roundup //************** function integer log2roundup (input integer data_value); integer width; integer cnt; begin width = 0; if (data_value > 1) begin for(cnt=1 ; cnt < data_value ; cnt = cnt * 2) begin width = width + 1; end //loop end //if log2roundup = width; end //log2roundup endfunction //******************* // collision_check //******************* function integer collision_check (input reg [C_ADDRA_WIDTH-1:0] addr_a, input integer iswrite_a, input reg [C_ADDRB_WIDTH-1:0] addr_b, input integer iswrite_b); reg c_aw_bw, c_aw_br, c_ar_bw; integer scaled_addra_to_waddrb_width; integer scaled_addrb_to_waddrb_width; integer scaled_addra_to_waddra_width; integer scaled_addrb_to_waddra_width; integer scaled_addra_to_raddrb_width; integer scaled_addrb_to_raddrb_width; integer scaled_addra_to_raddra_width; integer scaled_addrb_to_raddra_width; begin c_aw_bw = 0; c_aw_br = 0; c_ar_bw = 0; //If write_addr_b_width is smaller, scale both addresses to that width for //comparing write_addr_a and write_addr_b; addr_a starts as C_ADDRA_WIDTH, //scale it down to write_addr_b_width. addr_b starts as C_ADDRB_WIDTH, //scale it down to write_addr_b_width. Once both are scaled to //write_addr_b_width, compare. scaled_addra_to_waddrb_width = ((addr_a)/ 2**(C_ADDRA_WIDTH-write_addr_b_width)); scaled_addrb_to_waddrb_width = ((addr_b)/ 2**(C_ADDRB_WIDTH-write_addr_b_width)); //If write_addr_a_width is smaller, scale both addresses to that width for //comparing write_addr_a and write_addr_b; addr_a starts as C_ADDRA_WIDTH, //scale it down to write_addr_a_width. addr_b starts as C_ADDRB_WIDTH, //scale it down to write_addr_a_width. Once both are scaled to //write_addr_a_width, compare. scaled_addra_to_waddra_width = ((addr_a)/ 2**(C_ADDRA_WIDTH-write_addr_a_width)); scaled_addrb_to_waddra_width = ((addr_b)/ 2**(C_ADDRB_WIDTH-write_addr_a_width)); //If read_addr_b_width is smaller, scale both addresses to that width for //comparing write_addr_a and read_addr_b; addr_a starts as C_ADDRA_WIDTH, //scale it down to read_addr_b_width. addr_b starts as C_ADDRB_WIDTH, //scale it down to read_addr_b_width. Once both are scaled to //read_addr_b_width, compare. scaled_addra_to_raddrb_width = ((addr_a)/ 2**(C_ADDRA_WIDTH-read_addr_b_width)); scaled_addrb_to_raddrb_width = ((addr_b)/ 2**(C_ADDRB_WIDTH-read_addr_b_width)); //If read_addr_a_width is smaller, scale both addresses to that width for //comparing read_addr_a and write_addr_b; addr_a starts as C_ADDRA_WIDTH, //scale it down to read_addr_a_width. addr_b starts as C_ADDRB_WIDTH, //scale it down to read_addr_a_width. Once both are scaled to //read_addr_a_width, compare. scaled_addra_to_raddra_width = ((addr_a)/ 2**(C_ADDRA_WIDTH-read_addr_a_width)); scaled_addrb_to_raddra_width = ((addr_b)/ 2**(C_ADDRB_WIDTH-read_addr_a_width)); //Look for a write-write collision. In order for a write-write //collision to exist, both ports must have a write transaction. if (iswrite_a && iswrite_b) begin if (write_addr_a_width > write_addr_b_width) begin if (scaled_addra_to_waddrb_width == scaled_addrb_to_waddrb_width) begin c_aw_bw = 1; end else begin c_aw_bw = 0; end end else begin if (scaled_addrb_to_waddra_width == scaled_addra_to_waddra_width) begin c_aw_bw = 1; end else begin c_aw_bw = 0; end end //width end //iswrite_a and iswrite_b //If the B port is reading (which means it is enabled - so could be //a TX_WRITE or TX_READ), then check for a write-read collision). //This could happen whether or not a write-write collision exists due //to asymmetric write/read ports. if (iswrite_a) begin if (write_addr_a_width > read_addr_b_width) begin if (scaled_addra_to_raddrb_width == scaled_addrb_to_raddrb_width) begin c_aw_br = 1; end else begin c_aw_br = 0; end end else begin if (scaled_addrb_to_waddra_width == scaled_addra_to_waddra_width) begin c_aw_br = 1; end else begin c_aw_br = 0; end end //width end //iswrite_a //If the A port is reading (which means it is enabled - so could be // a TX_WRITE or TX_READ), then check for a write-read collision). //This could happen whether or not a write-write collision exists due // to asymmetric write/read ports. if (iswrite_b) begin if (read_addr_a_width > write_addr_b_width) begin if (scaled_addra_to_waddrb_width == scaled_addrb_to_waddrb_width) begin c_ar_bw = 1; end else begin c_ar_bw = 0; end end else begin if (scaled_addrb_to_raddra_width == scaled_addra_to_raddra_width) begin c_ar_bw = 1; end else begin c_ar_bw = 0; end end //width end //iswrite_b collision_check = c_aw_bw | c_aw_br | c_ar_bw; end endfunction //******************************* // power on values //******************************* initial begin // Load up the memory init_memory; // Load up the output registers and latches if ($sscanf(inita_str, "%h", inita_val)) begin memory_out_a = inita_val; end else begin memory_out_a = 0; end if ($sscanf(initb_str, "%h", initb_val)) begin memory_out_b = initb_val; end else begin memory_out_b = 0; end sbiterr_in = 1'b0; dbiterr_in = 1'b0; rdaddrecc_in = 0; // Determine the effective address widths for each of the 4 ports write_addr_a_width = C_ADDRA_WIDTH - log2roundup(WRITE_ADDR_A_DIV); read_addr_a_width = C_ADDRA_WIDTH - log2roundup(READ_ADDR_A_DIV); write_addr_b_width = C_ADDRB_WIDTH - log2roundup(WRITE_ADDR_B_DIV); read_addr_b_width = C_ADDRB_WIDTH - log2roundup(READ_ADDR_B_DIV); $display("Block Memory Generator module %m is using a behavioral model for simulation which will not precisely model memory collision behavior."); end //*************************************************************************** // These are the main blocks which schedule read and write operations // Note that the reset priority feature at the latch stage is only supported // for Spartan-6. For other families, the default priority at the latch stage // is "CE" //*************************************************************************** // Synchronous clocks: schedule port operations with respect to // both write operating modes generate if(C_COMMON_CLK && (C_WRITE_MODE_A == "WRITE_FIRST") && (C_WRITE_MODE_B == "WRITE_FIRST")) begin : com_clk_sched_wf_wf always @(posedge CLKA) begin //Write A if (wea_i) write_a(ADDRA, wea_i, DINA, INJECTSBITERR, INJECTDBITERR); //Write B if (web_i) write_b(ADDRB, web_i, DINB); if (rea_i) read_a(ADDRA, reseta_i); //Read B if (reb_i) read_b(ADDRB, resetb_i); end end else if(C_COMMON_CLK && (C_WRITE_MODE_A == "READ_FIRST") && (C_WRITE_MODE_B == "WRITE_FIRST")) begin : com_clk_sched_rf_wf always @(posedge CLKA) begin //Write B if (web_i) write_b(ADDRB, web_i, DINB); //Read B if (reb_i) read_b(ADDRB, resetb_i); //Read A if (rea_i) read_a(ADDRA, reseta_i); //Write A if (wea_i) write_a(ADDRA, wea_i, DINA, INJECTSBITERR, INJECTDBITERR); end end else if(C_COMMON_CLK && (C_WRITE_MODE_A == "WRITE_FIRST") && (C_WRITE_MODE_B == "READ_FIRST")) begin : com_clk_sched_wf_rf always @(posedge CLKA) begin //Write A if (wea_i) write_a(ADDRA, wea_i, DINA, INJECTSBITERR, INJECTDBITERR); //Read A if (rea_i) read_a(ADDRA, reseta_i); //Read B if (reb_i) read_b(ADDRB, resetb_i); //Write B if (web_i) write_b(ADDRB, web_i, DINB); end end else if(C_COMMON_CLK && (C_WRITE_MODE_A == "READ_FIRST") && (C_WRITE_MODE_B == "READ_FIRST")) begin : com_clk_sched_rf_rf always @(posedge CLKA) begin //Read A if (rea_i) read_a(ADDRA, reseta_i); //Read B if (reb_i) read_b(ADDRB, resetb_i); //Write A if (wea_i) write_a(ADDRA, wea_i, DINA, INJECTSBITERR, INJECTDBITERR); //Write B if (web_i) write_b(ADDRB, web_i, DINB); end end else if(C_COMMON_CLK && (C_WRITE_MODE_A =="WRITE_FIRST") && (C_WRITE_MODE_B == "NO_CHANGE")) begin : com_clk_sched_wf_nc always @(posedge CLKA) begin //Write A if (wea_i) write_a(ADDRA, wea_i, DINA, INJECTSBITERR, INJECTDBITERR); //Read A if (rea_i) read_a(ADDRA, reseta_i); //Read B if (reb_i && (!web_i || resetb_i)) read_b(ADDRB, resetb_i); //Write B if (web_i) write_b(ADDRB, web_i, DINB); end end else if(C_COMMON_CLK && (C_WRITE_MODE_A =="READ_FIRST") && (C_WRITE_MODE_B == "NO_CHANGE")) begin : com_clk_sched_rf_nc always @(posedge CLKA) begin //Read A if (rea_i) read_a(ADDRA, reseta_i); //Read B if (reb_i && (!web_i || resetb_i)) read_b(ADDRB, resetb_i); //Write A if (wea_i) write_a(ADDRA, wea_i, DINA, INJECTSBITERR, INJECTDBITERR); //Write B if (web_i) write_b(ADDRB, web_i, DINB); end end else if(C_COMMON_CLK && (C_WRITE_MODE_A =="NO_CHANGE") && (C_WRITE_MODE_B == "WRITE_FIRST")) begin : com_clk_sched_nc_wf always @(posedge CLKA) begin //Write A if (wea_i) write_a(ADDRA, wea_i, DINA, INJECTSBITERR, INJECTDBITERR); //Write B if (web_i) write_b(ADDRB, web_i, DINB); //Read A if (rea_i && (!wea_i || reseta_i)) read_a(ADDRA, reseta_i); //Read B if (reb_i) read_b(ADDRB, resetb_i); end end else if(C_COMMON_CLK && (C_WRITE_MODE_A =="NO_CHANGE") && (C_WRITE_MODE_B == "READ_FIRST")) begin : com_clk_sched_nc_rf always @(posedge CLKA) begin //Read B if (reb_i) read_b(ADDRB, resetb_i); //Read A if (rea_i && (!wea_i || reseta_i)) read_a(ADDRA, reseta_i); //Write A if (wea_i) write_a(ADDRA, wea_i, DINA, INJECTSBITERR, INJECTDBITERR); //Write B if (web_i) write_b(ADDRB, web_i, DINB); end end else if(C_COMMON_CLK && (C_WRITE_MODE_A =="NO_CHANGE") && (C_WRITE_MODE_B == "NO_CHANGE")) begin : com_clk_sched_nc_nc always @(posedge CLKA) begin //Write A if (wea_i) write_a(ADDRA, wea_i, DINA, INJECTSBITERR, INJECTDBITERR); //Write B if (web_i) write_b(ADDRB, web_i, DINB); //Read A if (rea_i && (!wea_i || reseta_i)) read_a(ADDRA, reseta_i); //Read B if (reb_i && (!web_i || resetb_i)) read_b(ADDRB, resetb_i); end end else if(C_COMMON_CLK) begin: com_clk_sched_default always @(posedge CLKA) begin //Write A if (wea_i) write_a(ADDRA, wea_i, DINA, INJECTSBITERR, INJECTDBITERR); //Write B if (web_i) write_b(ADDRB, web_i, DINB); //Read A if (rea_i) read_a(ADDRA, reseta_i); //Read B if (reb_i) read_b(ADDRB, resetb_i); end end endgenerate // Asynchronous clocks: port operation is independent generate if((!C_COMMON_CLK) && (C_WRITE_MODE_A == "WRITE_FIRST")) begin : async_clk_sched_clka_wf always @(posedge CLKA) begin //Write A if (wea_i) write_a(ADDRA, wea_i, DINA, INJECTSBITERR, INJECTDBITERR); //Read A if (rea_i) read_a(ADDRA, reseta_i); end end else if((!C_COMMON_CLK) && (C_WRITE_MODE_A == "READ_FIRST")) begin : async_clk_sched_clka_rf always @(posedge CLKA) begin //Read A if (rea_i) read_a(ADDRA, reseta_i); //Write A if (wea_i) write_a(ADDRA, wea_i, DINA, INJECTSBITERR, INJECTDBITERR); end end else if((!C_COMMON_CLK) && (C_WRITE_MODE_A == "NO_CHANGE")) begin : async_clk_sched_clka_nc always @(posedge CLKA) begin //Write A if (wea_i) write_a(ADDRA, wea_i, DINA, INJECTSBITERR, INJECTDBITERR); //Read A if (rea_i && (!wea_i || reseta_i)) read_a(ADDRA, reseta_i); end end endgenerate generate if ((!C_COMMON_CLK) && (C_WRITE_MODE_B == "WRITE_FIRST")) begin: async_clk_sched_clkb_wf always @(posedge CLKB) begin //Write B if (web_i) write_b(ADDRB, web_i, DINB); //Read B if (reb_i) read_b(ADDRB, resetb_i); end end else if ((!C_COMMON_CLK) && (C_WRITE_MODE_B == "READ_FIRST")) begin: async_clk_sched_clkb_rf always @(posedge CLKB) begin //Read B if (reb_i) read_b(ADDRB, resetb_i); //Write B if (web_i) write_b(ADDRB, web_i, DINB); end end else if ((!C_COMMON_CLK) && (C_WRITE_MODE_B == "NO_CHANGE")) begin: async_clk_sched_clkb_nc always @(posedge CLKB) begin //Write B if (web_i) write_b(ADDRB, web_i, DINB); //Read B if (reb_i && (!web_i || resetb_i)) read_b(ADDRB, resetb_i); end end endgenerate //*************************************************************** // Instantiate the variable depth output register stage module //*************************************************************** // Port A assign rsta_outp_stage = RSTA & (~SLEEP); BLK_MEM_GEN_v8_2_output_stage #(.C_FAMILY (C_FAMILY), .C_XDEVICEFAMILY (C_XDEVICEFAMILY), .C_RST_TYPE ("SYNC"), .C_HAS_RST (C_HAS_RSTA), .C_RSTRAM (C_RSTRAM_A), .C_RST_PRIORITY (C_RST_PRIORITY_A), .C_INIT_VAL (C_INITA_VAL), .C_HAS_EN (C_HAS_ENA), .C_HAS_REGCE (C_HAS_REGCEA), .C_DATA_WIDTH (C_READ_WIDTH_A), .C_ADDRB_WIDTH (C_ADDRB_WIDTH), .C_HAS_MEM_OUTPUT_REGS (C_HAS_MEM_OUTPUT_REGS_A), .C_USE_SOFTECC (C_USE_SOFTECC), .C_USE_ECC (C_USE_ECC), .NUM_STAGES (NUM_OUTPUT_STAGES_A), .C_EN_ECC_PIPE (0), .FLOP_DELAY (FLOP_DELAY)) reg_a (.CLK (CLKA), .RST (rsta_outp_stage),//(RSTA), .EN (ENA), .REGCE (REGCEA), .DIN_I (memory_out_a), .DOUT (DOUTA), .SBITERR_IN_I (1'b0), .DBITERR_IN_I (1'b0), .SBITERR (), .DBITERR (), .RDADDRECC_IN_I ({C_ADDRB_WIDTH{1'b0}}), .ECCPIPECE (1'b0), .RDADDRECC () ); assign rstb_outp_stage = RSTB & (~SLEEP); // Port B BLK_MEM_GEN_v8_2_output_stage #(.C_FAMILY (C_FAMILY), .C_XDEVICEFAMILY (C_XDEVICEFAMILY), .C_RST_TYPE ("SYNC"), .C_HAS_RST (C_HAS_RSTB), .C_RSTRAM (C_RSTRAM_B), .C_RST_PRIORITY (C_RST_PRIORITY_B), .C_INIT_VAL (C_INITB_VAL), .C_HAS_EN (C_HAS_ENB), .C_HAS_REGCE (C_HAS_REGCEB), .C_DATA_WIDTH (C_READ_WIDTH_B), .C_ADDRB_WIDTH (C_ADDRB_WIDTH), .C_HAS_MEM_OUTPUT_REGS (C_HAS_MEM_OUTPUT_REGS_B), .C_USE_SOFTECC (C_USE_SOFTECC), .C_USE_ECC (C_USE_ECC), .NUM_STAGES (NUM_OUTPUT_STAGES_B), .C_EN_ECC_PIPE (C_EN_ECC_PIPE), .FLOP_DELAY (FLOP_DELAY)) reg_b (.CLK (CLKB), .RST (rstb_outp_stage),//(RSTB), .EN (ENB), .REGCE (REGCEB), .DIN_I (memory_out_b), .DOUT (dout_i), .SBITERR_IN_I (sbiterr_in), .DBITERR_IN_I (dbiterr_in), .SBITERR (sbiterr_i), .DBITERR (dbiterr_i), .RDADDRECC_IN_I (rdaddrecc_in), .ECCPIPECE (ECCPIPECE), .RDADDRECC (rdaddrecc_i) ); //*************************************************************** // Instantiate the Input and Output register stages //*************************************************************** BLK_MEM_GEN_v8_2_softecc_output_reg_stage #(.C_DATA_WIDTH (C_READ_WIDTH_B), .C_ADDRB_WIDTH (C_ADDRB_WIDTH), .C_HAS_SOFTECC_OUTPUT_REGS_B (C_HAS_SOFTECC_OUTPUT_REGS_B), .C_USE_SOFTECC (C_USE_SOFTECC), .FLOP_DELAY (FLOP_DELAY)) has_softecc_output_reg_stage (.CLK (CLKB), .DIN (dout_i), .DOUT (DOUTB), .SBITERR_IN (sbiterr_i), .DBITERR_IN (dbiterr_i), .SBITERR (sbiterr_sdp), .DBITERR (dbiterr_sdp), .RDADDRECC_IN (rdaddrecc_i), .RDADDRECC (rdaddrecc_sdp) ); //**************************************************** // Synchronous collision checks //**************************************************** // CR 780544 : To make verilog model's collison warnings in consistant with // vhdl model, the non-blocking assignments are replaced with blocking // assignments. generate if (!C_DISABLE_WARN_BHV_COLL && C_COMMON_CLK) begin : sync_coll always @(posedge CLKA) begin // Possible collision if both are enabled and the addresses match if (ena_i && enb_i) begin if (wea_i || web_i) begin is_collision = collision_check(ADDRA, wea_i, ADDRB, web_i); end else begin is_collision = 0; end end else begin is_collision = 0; end // If the write port is in READ_FIRST mode, there is no collision if (C_WRITE_MODE_A=="READ_FIRST" && wea_i && !web_i) begin is_collision = 0; end if (C_WRITE_MODE_B=="READ_FIRST" && web_i && !wea_i) begin is_collision = 0; end // Only flag if one of the accesses is a write if (is_collision && (wea_i || web_i)) begin $fwrite(COLLFILE, "%0s collision detected at time: %0d, ", C_CORENAME, $time); $fwrite(COLLFILE, "A %0s address: %0h, B %0s address: %0h\n", wea_i ? "write" : "read", ADDRA, web_i ? "write" : "read", ADDRB); end end //**************************************************** // Asynchronous collision checks //**************************************************** end else if (!C_DISABLE_WARN_BHV_COLL && !C_COMMON_CLK) begin : async_coll // Delay A and B addresses in order to mimic setup/hold times wire [C_ADDRA_WIDTH-1:0] #COLL_DELAY addra_delay = ADDRA; wire [0:0] #COLL_DELAY wea_delay = wea_i; wire #COLL_DELAY ena_delay = ena_i; wire [C_ADDRB_WIDTH-1:0] #COLL_DELAY addrb_delay = ADDRB; wire [0:0] #COLL_DELAY web_delay = web_i; wire #COLL_DELAY enb_delay = enb_i; // Do the checks w/rt A always @(posedge CLKA) begin // Possible collision if both are enabled and the addresses match if (ena_i && enb_i) begin if (wea_i || web_i) begin is_collision_a = collision_check(ADDRA, wea_i, ADDRB, web_i); end else begin is_collision_a = 0; end end else begin is_collision_a = 0; end if (ena_i && enb_delay) begin if(wea_i || web_delay) begin is_collision_delay_a = collision_check(ADDRA, wea_i, addrb_delay, web_delay); end else begin is_collision_delay_a = 0; end end else begin is_collision_delay_a = 0; end // Only flag if B access is a write if (is_collision_a && web_i) begin $fwrite(COLLFILE, "%0s collision detected at time: %0d, ", C_CORENAME, $time); $fwrite(COLLFILE, "A %0s address: %0h, B write address: %0h\n", wea_i ? "write" : "read", ADDRA, ADDRB); end else if (is_collision_delay_a && web_delay) begin $fwrite(COLLFILE, "%0s collision detected at time: %0d, ", C_CORENAME, $time); $fwrite(COLLFILE, "A %0s address: %0h, B write address: %0h\n", wea_i ? "write" : "read", ADDRA, addrb_delay); end end // Do the checks w/rt B always @(posedge CLKB) begin // Possible collision if both are enabled and the addresses match if (ena_i && enb_i) begin if (wea_i || web_i) begin is_collision_b = collision_check(ADDRA, wea_i, ADDRB, web_i); end else begin is_collision_b = 0; end end else begin is_collision_b = 0; end if (ena_delay && enb_i) begin if (wea_delay || web_i) begin is_collision_delay_b = collision_check(addra_delay, wea_delay, ADDRB, web_i); end else begin is_collision_delay_b = 0; end end else begin is_collision_delay_b = 0; end // Only flag if A access is a write if (is_collision_b && wea_i) begin $fwrite(COLLFILE, "%0s collision detected at time: %0d, ", C_CORENAME, $time); $fwrite(COLLFILE, "A write address: %0h, B %s address: %0h\n", ADDRA, web_i ? "write" : "read", ADDRB); end else if (is_collision_delay_b && wea_delay) begin $fwrite(COLLFILE, "%0s collision detected at time: %0d, ", C_CORENAME, $time); $fwrite(COLLFILE, "A write address: %0h, B %s address: %0h\n", addra_delay, web_i ? "write" : "read", ADDRB); end end end endgenerate endmodule //***************************************************************************** // Top module wraps Input register and Memory module // // This module is the top-level behavioral model and this implements the memory // module and the input registers //***************************************************************************** module blk_mem_gen_v8_2 #(parameter C_CORENAME = "blk_mem_gen_v8_2", parameter C_FAMILY = "virtex7", parameter C_XDEVICEFAMILY = "virtex7", parameter C_ELABORATION_DIR = "", parameter C_INTERFACE_TYPE = 0, parameter C_USE_BRAM_BLOCK = 0, parameter C_CTRL_ECC_ALGO = "NONE", parameter C_ENABLE_32BIT_ADDRESS = 0, parameter C_AXI_TYPE = 0, parameter C_AXI_SLAVE_TYPE = 0, parameter C_HAS_AXI_ID = 0, parameter C_AXI_ID_WIDTH = 4, parameter C_MEM_TYPE = 2, parameter C_BYTE_SIZE = 9, parameter C_ALGORITHM = 1, parameter C_PRIM_TYPE = 3, parameter C_LOAD_INIT_FILE = 0, parameter C_INIT_FILE_NAME = "", parameter C_INIT_FILE = "", parameter C_USE_DEFAULT_DATA = 0, parameter C_DEFAULT_DATA = "0", //parameter C_RST_TYPE = "SYNC", parameter C_HAS_RSTA = 0, parameter C_RST_PRIORITY_A = "CE", parameter C_RSTRAM_A = 0, parameter C_INITA_VAL = "0", parameter C_HAS_ENA = 1, parameter C_HAS_REGCEA = 0, parameter C_USE_BYTE_WEA = 0, parameter C_WEA_WIDTH = 1, parameter C_WRITE_MODE_A = "WRITE_FIRST", parameter C_WRITE_WIDTH_A = 32, parameter C_READ_WIDTH_A = 32, parameter C_WRITE_DEPTH_A = 64, parameter C_READ_DEPTH_A = 64, parameter C_ADDRA_WIDTH = 5, parameter C_HAS_RSTB = 0, parameter C_RST_PRIORITY_B = "CE", parameter C_RSTRAM_B = 0, parameter C_INITB_VAL = "", parameter C_HAS_ENB = 1, parameter C_HAS_REGCEB = 0, parameter C_USE_BYTE_WEB = 0, parameter C_WEB_WIDTH = 1, parameter C_WRITE_MODE_B = "WRITE_FIRST", parameter C_WRITE_WIDTH_B = 32, parameter C_READ_WIDTH_B = 32, parameter C_WRITE_DEPTH_B = 64, parameter C_READ_DEPTH_B = 64, parameter C_ADDRB_WIDTH = 5, parameter C_HAS_MEM_OUTPUT_REGS_A = 0, parameter C_HAS_MEM_OUTPUT_REGS_B = 0, parameter C_HAS_MUX_OUTPUT_REGS_A = 0, parameter C_HAS_MUX_OUTPUT_REGS_B = 0, parameter C_HAS_SOFTECC_INPUT_REGS_A = 0, parameter C_HAS_SOFTECC_OUTPUT_REGS_B= 0, parameter C_MUX_PIPELINE_STAGES = 0, parameter C_USE_SOFTECC = 0, parameter C_USE_ECC = 0, parameter C_EN_ECC_PIPE = 0, parameter C_HAS_INJECTERR = 0, parameter C_SIM_COLLISION_CHECK = "NONE", parameter C_COMMON_CLK = 1, parameter C_DISABLE_WARN_BHV_COLL = 0, parameter C_EN_SLEEP_PIN = 0, parameter C_USE_URAM = 0, parameter C_EN_RDADDRA_CHG = 0, parameter C_EN_RDADDRB_CHG = 0, parameter C_EN_DEEPSLEEP_PIN = 0, parameter C_EN_SHUTDOWN_PIN = 0, parameter C_DISABLE_WARN_BHV_RANGE = 0, parameter C_COUNT_36K_BRAM = "", parameter C_COUNT_18K_BRAM = "", parameter C_EST_POWER_SUMMARY = "" ) (input clka, input rsta, input ena, input regcea, input [C_WEA_WIDTH-1:0] wea, input [C_ADDRA_WIDTH-1:0] addra, input [C_WRITE_WIDTH_A-1:0] dina, output [C_READ_WIDTH_A-1:0] douta, input clkb, input rstb, input enb, input regceb, input [C_WEB_WIDTH-1:0] web, input [C_ADDRB_WIDTH-1:0] addrb, input [C_WRITE_WIDTH_B-1:0] dinb, output [C_READ_WIDTH_B-1:0] doutb, input injectsbiterr, input injectdbiterr, output sbiterr, output dbiterr, output [C_ADDRB_WIDTH-1:0] rdaddrecc, input eccpipece, input sleep, input deepsleep, input shutdown, //AXI BMG Input and Output Port Declarations //AXI Global Signals input s_aclk, input s_aresetn, //AXI Full/lite slave write (write side) input [C_AXI_ID_WIDTH-1:0] s_axi_awid, input [31:0] s_axi_awaddr, input [7:0] s_axi_awlen, input [2:0] s_axi_awsize, input [1:0] s_axi_awburst, input s_axi_awvalid, output s_axi_awready, input [C_WRITE_WIDTH_A-1:0] s_axi_wdata, input [C_WEA_WIDTH-1:0] s_axi_wstrb, input s_axi_wlast, input s_axi_wvalid, output s_axi_wready, output [C_AXI_ID_WIDTH-1:0] s_axi_bid, output [1:0] s_axi_bresp, output s_axi_bvalid, input s_axi_bready, //AXI Full/lite slave read (write side) input [C_AXI_ID_WIDTH-1:0] s_axi_arid, input [31:0] s_axi_araddr, input [7:0] s_axi_arlen, input [2:0] s_axi_arsize, input [1:0] s_axi_arburst, input s_axi_arvalid, output s_axi_arready, output [C_AXI_ID_WIDTH-1:0] s_axi_rid, output [C_WRITE_WIDTH_B-1:0] s_axi_rdata, output [1:0] s_axi_rresp, output s_axi_rlast, output s_axi_rvalid, input s_axi_rready, //AXI Full/lite sideband signals input s_axi_injectsbiterr, input s_axi_injectdbiterr, output s_axi_sbiterr, output s_axi_dbiterr, output [C_ADDRB_WIDTH-1:0] s_axi_rdaddrecc ); //****************************** // Port and Generic Definitions //****************************** ////////////////////////////////////////////////////////////////////////// // Generic Definitions ////////////////////////////////////////////////////////////////////////// // C_CORENAME : Instance name of the Block Memory Generator core // C_FAMILY,C_XDEVICEFAMILY: Designates architecture targeted. The following // options are available - "spartan3", "spartan6", // "virtex4", "virtex5", "virtex6" and "virtex6l". // C_MEM_TYPE : Designates memory type. // It can be // 0 - Single Port Memory // 1 - Simple Dual Port Memory // 2 - True Dual Port Memory // 3 - Single Port Read Only Memory // 4 - Dual Port Read Only Memory // C_BYTE_SIZE : Size of a byte (8 or 9 bits) // C_ALGORITHM : Designates the algorithm method used // for constructing the memory. // It can be Fixed_Primitives, Minimum_Area or // Low_Power // C_PRIM_TYPE : Designates the user selected primitive used to // construct the memory. // // C_LOAD_INIT_FILE : Designates the use of an initialization file to // initialize memory contents. // C_INIT_FILE_NAME : Memory initialization file name. // C_USE_DEFAULT_DATA : Designates whether to fill remaining // initialization space with default data // C_DEFAULT_DATA : Default value of all memory locations // not initialized by the memory // initialization file. // C_RST_TYPE : Type of reset - Synchronous or Asynchronous // C_HAS_RSTA : Determines the presence of the RSTA port // C_RST_PRIORITY_A : Determines the priority between CE and SR for // Port A. // C_RSTRAM_A : Determines if special reset behavior is used for // Port A // C_INITA_VAL : The initialization value for Port A // C_HAS_ENA : Determines the presence of the ENA port // C_HAS_REGCEA : Determines the presence of the REGCEA port // C_USE_BYTE_WEA : Determines if the Byte Write is used or not. // C_WEA_WIDTH : The width of the WEA port // C_WRITE_MODE_A : Configurable write mode for Port A. It can be // WRITE_FIRST, READ_FIRST or NO_CHANGE. // C_WRITE_WIDTH_A : Memory write width for Port A. // C_READ_WIDTH_A : Memory read width for Port A. // C_WRITE_DEPTH_A : Memory write depth for Port A. // C_READ_DEPTH_A : Memory read depth for Port A. // C_ADDRA_WIDTH : Width of the ADDRA input port // C_HAS_RSTB : Determines the presence of the RSTB port // C_RST_PRIORITY_B : Determines the priority between CE and SR for // Port B. // C_RSTRAM_B : Determines if special reset behavior is used for // Port B // C_INITB_VAL : The initialization value for Port B // C_HAS_ENB : Determines the presence of the ENB port // C_HAS_REGCEB : Determines the presence of the REGCEB port // C_USE_BYTE_WEB : Determines if the Byte Write is used or not. // C_WEB_WIDTH : The width of the WEB port // C_WRITE_MODE_B : Configurable write mode for Port B. It can be // WRITE_FIRST, READ_FIRST or NO_CHANGE. // C_WRITE_WIDTH_B : Memory write width for Port B. // C_READ_WIDTH_B : Memory read width for Port B. // C_WRITE_DEPTH_B : Memory write depth for Port B. // C_READ_DEPTH_B : Memory read depth for Port B. // C_ADDRB_WIDTH : Width of the ADDRB input port // C_HAS_MEM_OUTPUT_REGS_A : Designates the use of a register at the output // of the RAM primitive for Port A. // C_HAS_MEM_OUTPUT_REGS_B : Designates the use of a register at the output // of the RAM primitive for Port B. // C_HAS_MUX_OUTPUT_REGS_A : Designates the use of a register at the output // of the MUX for Port A. // C_HAS_MUX_OUTPUT_REGS_B : Designates the use of a register at the output // of the MUX for Port B. // C_HAS_SOFTECC_INPUT_REGS_A : // C_HAS_SOFTECC_OUTPUT_REGS_B : // C_MUX_PIPELINE_STAGES : Designates the number of pipeline stages in // between the muxes. // C_USE_SOFTECC : Determines if the Soft ECC feature is used or // not. Only applicable Spartan-6 // C_USE_ECC : Determines if the ECC feature is used or // not. Only applicable for V5 and V6 // C_HAS_INJECTERR : Determines if the error injection pins // are present or not. If the ECC feature // is not used, this value is defaulted to // 0, else the following are the allowed // values: // 0 : No INJECTSBITERR or INJECTDBITERR pins // 1 : Only INJECTSBITERR pin exists // 2 : Only INJECTDBITERR pin exists // 3 : Both INJECTSBITERR and INJECTDBITERR pins exist // C_SIM_COLLISION_CHECK : Controls the disabling of Unisim model collision // warnings. It can be "ALL", "NONE", // "Warnings_Only" or "Generate_X_Only". // C_COMMON_CLK : Determins if the core has a single CLK input. // C_DISABLE_WARN_BHV_COLL : Controls the Behavioral Model Collision warnings // C_DISABLE_WARN_BHV_RANGE: Controls the Behavioral Model Out of Range // warnings ////////////////////////////////////////////////////////////////////////// // Port Definitions ////////////////////////////////////////////////////////////////////////// // CLKA : Clock to synchronize all read and write operations of Port A. // RSTA : Reset input to reset memory outputs to a user-defined // reset state for Port A. // ENA : Enable all read and write operations of Port A. // REGCEA : Register Clock Enable to control each pipeline output // register stages for Port A. // WEA : Write Enable to enable all write operations of Port A. // ADDRA : Address of Port A. // DINA : Data input of Port A. // DOUTA : Data output of Port A. // CLKB : Clock to synchronize all read and write operations of Port B. // RSTB : Reset input to reset memory outputs to a user-defined // reset state for Port B. // ENB : Enable all read and write operations of Port B. // REGCEB : Register Clock Enable to control each pipeline output // register stages for Port B. // WEB : Write Enable to enable all write operations of Port B. // ADDRB : Address of Port B. // DINB : Data input of Port B. // DOUTB : Data output of Port B. // INJECTSBITERR : Single Bit ECC Error Injection Pin. // INJECTDBITERR : Double Bit ECC Error Injection Pin. // SBITERR : Output signal indicating that a Single Bit ECC Error has been // detected and corrected. // DBITERR : Output signal indicating that a Double Bit ECC Error has been // detected. // RDADDRECC : Read Address Output signal indicating address at which an // ECC error has occurred. ////////////////////////////////////////////////////////////////////////// wire SBITERR; wire DBITERR; wire S_AXI_AWREADY; wire S_AXI_WREADY; wire S_AXI_BVALID; wire S_AXI_ARREADY; wire S_AXI_RLAST; wire S_AXI_RVALID; wire S_AXI_SBITERR; wire S_AXI_DBITERR; wire [C_WEA_WIDTH-1:0] WEA = wea; wire [C_ADDRA_WIDTH-1:0] ADDRA = addra; wire [C_WRITE_WIDTH_A-1:0] DINA = dina; wire [C_READ_WIDTH_A-1:0] DOUTA; wire [C_WEB_WIDTH-1:0] WEB = web; wire [C_ADDRB_WIDTH-1:0] ADDRB = addrb; wire [C_WRITE_WIDTH_B-1:0] DINB = dinb; wire [C_READ_WIDTH_B-1:0] DOUTB; wire [C_ADDRB_WIDTH-1:0] RDADDRECC; wire [C_AXI_ID_WIDTH-1:0] S_AXI_AWID = s_axi_awid; wire [31:0] S_AXI_AWADDR = s_axi_awaddr; wire [7:0] S_AXI_AWLEN = s_axi_awlen; wire [2:0] S_AXI_AWSIZE = s_axi_awsize; wire [1:0] S_AXI_AWBURST = s_axi_awburst; wire [C_WRITE_WIDTH_A-1:0] S_AXI_WDATA = s_axi_wdata; wire [C_WEA_WIDTH-1:0] S_AXI_WSTRB = s_axi_wstrb; wire [C_AXI_ID_WIDTH-1:0] S_AXI_BID; wire [1:0] S_AXI_BRESP; wire [C_AXI_ID_WIDTH-1:0] S_AXI_ARID = s_axi_arid; wire [31:0] S_AXI_ARADDR = s_axi_araddr; wire [7:0] S_AXI_ARLEN = s_axi_arlen; wire [2:0] S_AXI_ARSIZE = s_axi_arsize; wire [1:0] S_AXI_ARBURST = s_axi_arburst; wire [C_AXI_ID_WIDTH-1:0] S_AXI_RID; wire [C_WRITE_WIDTH_B-1:0] S_AXI_RDATA; wire [1:0] S_AXI_RRESP; wire [C_ADDRB_WIDTH-1:0] S_AXI_RDADDRECC; // Added to fix the simulation warning #CR731605 wire [C_WEB_WIDTH-1:0] WEB_parameterized = 0; wire ECCPIPECE; wire SLEEP; assign CLKA = clka; assign RSTA = rsta; assign ENA = ena; assign REGCEA = regcea; assign CLKB = clkb; assign RSTB = rstb; assign ENB = enb; assign REGCEB = regceb; assign INJECTSBITERR = injectsbiterr; assign INJECTDBITERR = injectdbiterr; assign ECCPIPECE = eccpipece; assign SLEEP = sleep; assign sbiterr = SBITERR; assign dbiterr = DBITERR; assign S_ACLK = s_aclk; assign S_ARESETN = s_aresetn; assign S_AXI_AWVALID = s_axi_awvalid; assign s_axi_awready = S_AXI_AWREADY; assign S_AXI_WLAST = s_axi_wlast; assign S_AXI_WVALID = s_axi_wvalid; assign s_axi_wready = S_AXI_WREADY; assign s_axi_bvalid = S_AXI_BVALID; assign S_AXI_BREADY = s_axi_bready; assign S_AXI_ARVALID = s_axi_arvalid; assign s_axi_arready = S_AXI_ARREADY; assign s_axi_rlast = S_AXI_RLAST; assign s_axi_rvalid = S_AXI_RVALID; assign S_AXI_RREADY = s_axi_rready; assign S_AXI_INJECTSBITERR = s_axi_injectsbiterr; assign S_AXI_INJECTDBITERR = s_axi_injectdbiterr; assign s_axi_sbiterr = S_AXI_SBITERR; assign s_axi_dbiterr = S_AXI_DBITERR; assign doutb = DOUTB; assign douta = DOUTA; assign rdaddrecc = RDADDRECC; assign s_axi_bid = S_AXI_BID; assign s_axi_bresp = S_AXI_BRESP; assign s_axi_rid = S_AXI_RID; assign s_axi_rdata = S_AXI_RDATA; assign s_axi_rresp = S_AXI_RRESP; assign s_axi_rdaddrecc = S_AXI_RDADDRECC; localparam FLOP_DELAY = 100; // 100 ps reg injectsbiterr_in; reg injectdbiterr_in; reg rsta_in; reg ena_in; reg regcea_in; reg [C_WEA_WIDTH-1:0] wea_in; reg [C_ADDRA_WIDTH-1:0] addra_in; reg [C_WRITE_WIDTH_A-1:0] dina_in; wire [C_ADDRA_WIDTH-1:0] s_axi_awaddr_out_c; wire [C_ADDRB_WIDTH-1:0] s_axi_araddr_out_c; wire s_axi_wr_en_c; wire s_axi_rd_en_c; wire s_aresetn_a_c; wire [7:0] s_axi_arlen_c ; wire [C_AXI_ID_WIDTH-1 : 0] s_axi_rid_c; wire [C_WRITE_WIDTH_B-1 : 0] s_axi_rdata_c; wire [1:0] s_axi_rresp_c; wire s_axi_rlast_c; wire s_axi_rvalid_c; wire s_axi_rready_c; wire regceb_c; localparam C_AXI_PAYLOAD = (C_HAS_MUX_OUTPUT_REGS_B == 1)?C_WRITE_WIDTH_B+C_AXI_ID_WIDTH+3:C_AXI_ID_WIDTH+3; wire [C_AXI_PAYLOAD-1 : 0] s_axi_payload_c; wire [C_AXI_PAYLOAD-1 : 0] m_axi_payload_c; //************** // log2roundup //************** function integer log2roundup (input integer data_value); integer width; integer cnt; begin width = 0; if (data_value > 1) begin for(cnt=1 ; cnt < data_value ; cnt = cnt * 2) begin width = width + 1; end //loop end //if log2roundup = width; end //log2roundup endfunction //************** // log2int //************** function integer log2int (input integer data_value); integer width; integer cnt; begin width = 0; cnt= data_value; for(cnt=data_value ; cnt >1 ; cnt = cnt / 2) begin width = width + 1; end //loop log2int = width; end //log2int endfunction //************************************************************************** // FUNCTION : divroundup // Returns the ceiling value of the division // Data_value - the quantity to be divided, dividend // Divisor - the value to divide the data_value by //************************************************************************** function integer divroundup (input integer data_value,input integer divisor); integer div; begin div = data_value/divisor; if ((data_value % divisor) != 0) begin div = div+1; end //if divroundup = div; end //if endfunction localparam AXI_FULL_MEMORY_SLAVE = ((C_AXI_SLAVE_TYPE == 0 && C_AXI_TYPE == 1)?1:0); localparam C_AXI_ADDR_WIDTH_MSB = C_ADDRA_WIDTH+log2roundup(C_WRITE_WIDTH_A/8); localparam C_AXI_ADDR_WIDTH = C_AXI_ADDR_WIDTH_MSB; //Data Width Number of LSB address bits to be discarded //1 to 16 1 //17 to 32 2 //33 to 64 3 //65 to 128 4 //129 to 256 5 //257 to 512 6 //513 to 1024 7 // The following two constants determine this. localparam LOWER_BOUND_VAL = (log2roundup(divroundup(C_WRITE_WIDTH_A,8) == 0))?0:(log2roundup(divroundup(C_WRITE_WIDTH_A,8))); localparam C_AXI_ADDR_WIDTH_LSB = ((AXI_FULL_MEMORY_SLAVE == 1)?0:LOWER_BOUND_VAL); localparam C_AXI_OS_WR = 2; //*********************************************** // INPUT REGISTERS. //*********************************************** generate if (C_HAS_SOFTECC_INPUT_REGS_A==0) begin : no_softecc_input_reg_stage always @* begin injectsbiterr_in = INJECTSBITERR; injectdbiterr_in = INJECTDBITERR; rsta_in = RSTA; ena_in = ENA; regcea_in = REGCEA; wea_in = WEA; addra_in = ADDRA; dina_in = DINA; end //end always end //end no_softecc_input_reg_stage endgenerate generate if (C_HAS_SOFTECC_INPUT_REGS_A==1) begin : has_softecc_input_reg_stage always @(posedge CLKA) begin injectsbiterr_in <= #FLOP_DELAY INJECTSBITERR; injectdbiterr_in <= #FLOP_DELAY INJECTDBITERR; rsta_in <= #FLOP_DELAY RSTA; ena_in <= #FLOP_DELAY ENA; regcea_in <= #FLOP_DELAY REGCEA; wea_in <= #FLOP_DELAY WEA; addra_in <= #FLOP_DELAY ADDRA; dina_in <= #FLOP_DELAY DINA; end //end always end //end input_reg_stages generate statement endgenerate generate if ((C_INTERFACE_TYPE == 0) && (C_ENABLE_32BIT_ADDRESS == 0)) begin : native_mem_module BLK_MEM_GEN_v8_2_mem_module #(.C_CORENAME (C_CORENAME), .C_FAMILY (C_FAMILY), .C_XDEVICEFAMILY (C_XDEVICEFAMILY), .C_MEM_TYPE (C_MEM_TYPE), .C_BYTE_SIZE (C_BYTE_SIZE), .C_ALGORITHM (C_ALGORITHM), .C_USE_BRAM_BLOCK (C_USE_BRAM_BLOCK), .C_PRIM_TYPE (C_PRIM_TYPE), .C_LOAD_INIT_FILE (C_LOAD_INIT_FILE), .C_INIT_FILE_NAME (C_INIT_FILE_NAME), .C_INIT_FILE (C_INIT_FILE), .C_USE_DEFAULT_DATA (C_USE_DEFAULT_DATA), .C_DEFAULT_DATA (C_DEFAULT_DATA), .C_RST_TYPE ("SYNC"), .C_HAS_RSTA (C_HAS_RSTA), .C_RST_PRIORITY_A (C_RST_PRIORITY_A), .C_RSTRAM_A (C_RSTRAM_A), .C_INITA_VAL (C_INITA_VAL), .C_HAS_ENA (C_HAS_ENA), .C_HAS_REGCEA (C_HAS_REGCEA), .C_USE_BYTE_WEA (C_USE_BYTE_WEA), .C_WEA_WIDTH (C_WEA_WIDTH), .C_WRITE_MODE_A (C_WRITE_MODE_A), .C_WRITE_WIDTH_A (C_WRITE_WIDTH_A), .C_READ_WIDTH_A (C_READ_WIDTH_A), .C_WRITE_DEPTH_A (C_WRITE_DEPTH_A), .C_READ_DEPTH_A (C_READ_DEPTH_A), .C_ADDRA_WIDTH (C_ADDRA_WIDTH), .C_HAS_RSTB (C_HAS_RSTB), .C_RST_PRIORITY_B (C_RST_PRIORITY_B), .C_RSTRAM_B (C_RSTRAM_B), .C_INITB_VAL (C_INITB_VAL), .C_HAS_ENB (C_HAS_ENB), .C_HAS_REGCEB (C_HAS_REGCEB), .C_USE_BYTE_WEB (C_USE_BYTE_WEB), .C_WEB_WIDTH (C_WEB_WIDTH), .C_WRITE_MODE_B (C_WRITE_MODE_B), .C_WRITE_WIDTH_B (C_WRITE_WIDTH_B), .C_READ_WIDTH_B (C_READ_WIDTH_B), .C_WRITE_DEPTH_B (C_WRITE_DEPTH_B), .C_READ_DEPTH_B (C_READ_DEPTH_B), .C_ADDRB_WIDTH (C_ADDRB_WIDTH), .C_HAS_MEM_OUTPUT_REGS_A (C_HAS_MEM_OUTPUT_REGS_A), .C_HAS_MEM_OUTPUT_REGS_B (C_HAS_MEM_OUTPUT_REGS_B), .C_HAS_MUX_OUTPUT_REGS_A (C_HAS_MUX_OUTPUT_REGS_A), .C_HAS_MUX_OUTPUT_REGS_B (C_HAS_MUX_OUTPUT_REGS_B), .C_HAS_SOFTECC_INPUT_REGS_A (C_HAS_SOFTECC_INPUT_REGS_A), .C_HAS_SOFTECC_OUTPUT_REGS_B (C_HAS_SOFTECC_OUTPUT_REGS_B), .C_MUX_PIPELINE_STAGES (C_MUX_PIPELINE_STAGES), .C_USE_SOFTECC (C_USE_SOFTECC), .C_USE_ECC (C_USE_ECC), .C_HAS_INJECTERR (C_HAS_INJECTERR), .C_SIM_COLLISION_CHECK (C_SIM_COLLISION_CHECK), .C_COMMON_CLK (C_COMMON_CLK), .FLOP_DELAY (FLOP_DELAY), .C_DISABLE_WARN_BHV_COLL (C_DISABLE_WARN_BHV_COLL), .C_EN_ECC_PIPE (C_EN_ECC_PIPE), .C_DISABLE_WARN_BHV_RANGE (C_DISABLE_WARN_BHV_RANGE)) blk_mem_gen_v8_2_inst (.CLKA (CLKA), .RSTA (rsta_in), .ENA (ena_in), .REGCEA (regcea_in), .WEA (wea_in), .ADDRA (addra_in), .DINA (dina_in), .DOUTA (DOUTA), .CLKB (CLKB), .RSTB (RSTB), .ENB (ENB), .REGCEB (REGCEB), .WEB (WEB), .ADDRB (ADDRB), .DINB (DINB), .DOUTB (DOUTB), .INJECTSBITERR (injectsbiterr_in), .INJECTDBITERR (injectdbiterr_in), .ECCPIPECE (ECCPIPECE), .SLEEP (SLEEP), .SBITERR (SBITERR), .DBITERR (DBITERR), .RDADDRECC (RDADDRECC) ); end endgenerate generate if((C_INTERFACE_TYPE == 0) && (C_ENABLE_32BIT_ADDRESS == 1)) begin : native_mem_mapped_module localparam C_ADDRA_WIDTH_ACTUAL = log2roundup(C_WRITE_DEPTH_A); localparam C_ADDRB_WIDTH_ACTUAL = log2roundup(C_WRITE_DEPTH_B); localparam C_ADDRA_WIDTH_MSB = C_ADDRA_WIDTH_ACTUAL+log2int(C_WRITE_WIDTH_A/8); localparam C_ADDRB_WIDTH_MSB = C_ADDRB_WIDTH_ACTUAL+log2int(C_WRITE_WIDTH_B/8); // localparam C_ADDRA_WIDTH_MSB = C_ADDRA_WIDTH_ACTUAL+log2roundup(C_WRITE_WIDTH_A/8); // localparam C_ADDRB_WIDTH_MSB = C_ADDRB_WIDTH_ACTUAL+log2roundup(C_WRITE_WIDTH_B/8); localparam C_MEM_MAP_ADDRA_WIDTH_MSB = C_ADDRA_WIDTH_MSB; localparam C_MEM_MAP_ADDRB_WIDTH_MSB = C_ADDRB_WIDTH_MSB; // Data Width Number of LSB address bits to be discarded // 1 to 16 1 // 17 to 32 2 // 33 to 64 3 // 65 to 128 4 // 129 to 256 5 // 257 to 512 6 // 513 to 1024 7 // The following two constants determine this. localparam MEM_MAP_LOWER_BOUND_VAL_A = (log2int(divroundup(C_WRITE_WIDTH_A,8)==0)) ? 0:(log2int(divroundup(C_WRITE_WIDTH_A,8))); localparam MEM_MAP_LOWER_BOUND_VAL_B = (log2int(divroundup(C_WRITE_WIDTH_A,8)==0)) ? 0:(log2int(divroundup(C_WRITE_WIDTH_A,8))); localparam C_MEM_MAP_ADDRA_WIDTH_LSB = MEM_MAP_LOWER_BOUND_VAL_A; localparam C_MEM_MAP_ADDRB_WIDTH_LSB = MEM_MAP_LOWER_BOUND_VAL_B; wire [C_ADDRB_WIDTH_ACTUAL-1 :0] rdaddrecc_i; wire [C_ADDRB_WIDTH-1:C_MEM_MAP_ADDRB_WIDTH_MSB] msb_zero_i; wire [C_MEM_MAP_ADDRB_WIDTH_LSB-1:0] lsb_zero_i; assign msb_zero_i = 0; assign lsb_zero_i = 0; assign RDADDRECC = {msb_zero_i,rdaddrecc_i,lsb_zero_i}; BLK_MEM_GEN_v8_2_mem_module #(.C_CORENAME (C_CORENAME), .C_FAMILY (C_FAMILY), .C_XDEVICEFAMILY (C_XDEVICEFAMILY), .C_MEM_TYPE (C_MEM_TYPE), .C_BYTE_SIZE (C_BYTE_SIZE), .C_USE_BRAM_BLOCK (C_USE_BRAM_BLOCK), .C_ALGORITHM (C_ALGORITHM), .C_PRIM_TYPE (C_PRIM_TYPE), .C_LOAD_INIT_FILE (C_LOAD_INIT_FILE), .C_INIT_FILE_NAME (C_INIT_FILE_NAME), .C_INIT_FILE (C_INIT_FILE), .C_USE_DEFAULT_DATA (C_USE_DEFAULT_DATA), .C_DEFAULT_DATA (C_DEFAULT_DATA), .C_RST_TYPE ("SYNC"), .C_HAS_RSTA (C_HAS_RSTA), .C_RST_PRIORITY_A (C_RST_PRIORITY_A), .C_RSTRAM_A (C_RSTRAM_A), .C_INITA_VAL (C_INITA_VAL), .C_HAS_ENA (C_HAS_ENA), .C_HAS_REGCEA (C_HAS_REGCEA), .C_USE_BYTE_WEA (C_USE_BYTE_WEA), .C_WEA_WIDTH (C_WEA_WIDTH), .C_WRITE_MODE_A (C_WRITE_MODE_A), .C_WRITE_WIDTH_A (C_WRITE_WIDTH_A), .C_READ_WIDTH_A (C_READ_WIDTH_A), .C_WRITE_DEPTH_A (C_WRITE_DEPTH_A), .C_READ_DEPTH_A (C_READ_DEPTH_A), .C_ADDRA_WIDTH (C_ADDRA_WIDTH_ACTUAL), .C_HAS_RSTB (C_HAS_RSTB), .C_RST_PRIORITY_B (C_RST_PRIORITY_B), .C_RSTRAM_B (C_RSTRAM_B), .C_INITB_VAL (C_INITB_VAL), .C_HAS_ENB (C_HAS_ENB), .C_HAS_REGCEB (C_HAS_REGCEB), .C_USE_BYTE_WEB (C_USE_BYTE_WEB), .C_WEB_WIDTH (C_WEB_WIDTH), .C_WRITE_MODE_B (C_WRITE_MODE_B), .C_WRITE_WIDTH_B (C_WRITE_WIDTH_B), .C_READ_WIDTH_B (C_READ_WIDTH_B), .C_WRITE_DEPTH_B (C_WRITE_DEPTH_B), .C_READ_DEPTH_B (C_READ_DEPTH_B), .C_ADDRB_WIDTH (C_ADDRB_WIDTH_ACTUAL), .C_HAS_MEM_OUTPUT_REGS_A (C_HAS_MEM_OUTPUT_REGS_A), .C_HAS_MEM_OUTPUT_REGS_B (C_HAS_MEM_OUTPUT_REGS_B), .C_HAS_MUX_OUTPUT_REGS_A (C_HAS_MUX_OUTPUT_REGS_A), .C_HAS_MUX_OUTPUT_REGS_B (C_HAS_MUX_OUTPUT_REGS_B), .C_HAS_SOFTECC_INPUT_REGS_A (C_HAS_SOFTECC_INPUT_REGS_A), .C_HAS_SOFTECC_OUTPUT_REGS_B (C_HAS_SOFTECC_OUTPUT_REGS_B), .C_MUX_PIPELINE_STAGES (C_MUX_PIPELINE_STAGES), .C_USE_SOFTECC (C_USE_SOFTECC), .C_USE_ECC (C_USE_ECC), .C_HAS_INJECTERR (C_HAS_INJECTERR), .C_SIM_COLLISION_CHECK (C_SIM_COLLISION_CHECK), .C_COMMON_CLK (C_COMMON_CLK), .FLOP_DELAY (FLOP_DELAY), .C_DISABLE_WARN_BHV_COLL (C_DISABLE_WARN_BHV_COLL), .C_EN_ECC_PIPE (C_EN_ECC_PIPE), .C_DISABLE_WARN_BHV_RANGE (C_DISABLE_WARN_BHV_RANGE)) blk_mem_gen_v8_2_inst (.CLKA (CLKA), .RSTA (rsta_in), .ENA (ena_in), .REGCEA (regcea_in), .WEA (wea_in), .ADDRA (addra_in[C_MEM_MAP_ADDRA_WIDTH_MSB-1:C_MEM_MAP_ADDRA_WIDTH_LSB]), .DINA (dina_in), .DOUTA (DOUTA), .CLKB (CLKB), .RSTB (RSTB), .ENB (ENB), .REGCEB (REGCEB), .WEB (WEB), .ADDRB (ADDRB[C_MEM_MAP_ADDRB_WIDTH_MSB-1:C_MEM_MAP_ADDRB_WIDTH_LSB]), .DINB (DINB), .DOUTB (DOUTB), .INJECTSBITERR (injectsbiterr_in), .INJECTDBITERR (injectdbiterr_in), .ECCPIPECE (ECCPIPECE), .SLEEP (SLEEP), .SBITERR (SBITERR), .DBITERR (DBITERR), .RDADDRECC (rdaddrecc_i) ); end endgenerate generate if (C_HAS_MEM_OUTPUT_REGS_B == 0 && C_HAS_MUX_OUTPUT_REGS_B == 0 ) begin : no_regs assign S_AXI_RDATA = s_axi_rdata_c; assign S_AXI_RLAST = s_axi_rlast_c; assign S_AXI_RVALID = s_axi_rvalid_c; assign S_AXI_RID = s_axi_rid_c; assign S_AXI_RRESP = s_axi_rresp_c; assign s_axi_rready_c = S_AXI_RREADY; end endgenerate generate if (C_HAS_MEM_OUTPUT_REGS_B == 1) begin : has_regceb assign regceb_c = s_axi_rvalid_c && s_axi_rready_c; end endgenerate generate if (C_HAS_MEM_OUTPUT_REGS_B == 0) begin : no_regceb assign regceb_c = REGCEB; end endgenerate generate if (C_HAS_MUX_OUTPUT_REGS_B == 1) begin : only_core_op_regs assign s_axi_payload_c = {s_axi_rid_c,s_axi_rdata_c,s_axi_rresp_c,s_axi_rlast_c}; assign S_AXI_RID = m_axi_payload_c[C_AXI_PAYLOAD-1 : C_AXI_PAYLOAD-C_AXI_ID_WIDTH]; assign S_AXI_RDATA = m_axi_payload_c[C_AXI_PAYLOAD-C_AXI_ID_WIDTH-1 : C_AXI_PAYLOAD-C_AXI_ID_WIDTH-C_WRITE_WIDTH_B]; assign S_AXI_RRESP = m_axi_payload_c[2:1]; assign S_AXI_RLAST = m_axi_payload_c[0]; end endgenerate generate if (C_HAS_MEM_OUTPUT_REGS_B == 1) begin : only_emb_op_regs assign s_axi_payload_c = {s_axi_rid_c,s_axi_rresp_c,s_axi_rlast_c}; assign S_AXI_RDATA = s_axi_rdata_c; assign S_AXI_RID = m_axi_payload_c[C_AXI_PAYLOAD-1 : C_AXI_PAYLOAD-C_AXI_ID_WIDTH]; assign S_AXI_RRESP = m_axi_payload_c[2:1]; assign S_AXI_RLAST = m_axi_payload_c[0]; end endgenerate generate if (C_HAS_MUX_OUTPUT_REGS_B == 1 || C_HAS_MEM_OUTPUT_REGS_B == 1) begin : has_regs_fwd blk_mem_axi_regs_fwd_v8_2 #(.C_DATA_WIDTH (C_AXI_PAYLOAD)) axi_regs_inst ( .ACLK (S_ACLK), .ARESET (s_aresetn_a_c), .S_VALID (s_axi_rvalid_c), .S_READY (s_axi_rready_c), .S_PAYLOAD_DATA (s_axi_payload_c), .M_VALID (S_AXI_RVALID), .M_READY (S_AXI_RREADY), .M_PAYLOAD_DATA (m_axi_payload_c) ); end endgenerate generate if (C_INTERFACE_TYPE == 1) begin : axi_mem_module assign s_aresetn_a_c = !S_ARESETN; assign S_AXI_BRESP = 2'b00; assign s_axi_rresp_c = 2'b00; assign s_axi_arlen_c = (C_AXI_TYPE == 1)?S_AXI_ARLEN:8'h0; blk_mem_axi_write_wrapper_beh_v8_2 #(.C_INTERFACE_TYPE (C_INTERFACE_TYPE), .C_AXI_TYPE (C_AXI_TYPE), .C_AXI_SLAVE_TYPE (C_AXI_SLAVE_TYPE), .C_MEMORY_TYPE (C_MEM_TYPE), .C_WRITE_DEPTH_A (C_WRITE_DEPTH_A), .C_AXI_AWADDR_WIDTH ((AXI_FULL_MEMORY_SLAVE == 1)?C_AXI_ADDR_WIDTH:C_AXI_ADDR_WIDTH-C_AXI_ADDR_WIDTH_LSB), .C_HAS_AXI_ID (C_HAS_AXI_ID), .C_AXI_ID_WIDTH (C_AXI_ID_WIDTH), .C_ADDRA_WIDTH (C_ADDRA_WIDTH), .C_AXI_WDATA_WIDTH (C_WRITE_WIDTH_A), .C_AXI_OS_WR (C_AXI_OS_WR)) axi_wr_fsm ( // AXI Global Signals .S_ACLK (S_ACLK), .S_ARESETN (s_aresetn_a_c), // AXI Full/Lite Slave Write interface .S_AXI_AWADDR (S_AXI_AWADDR[C_AXI_ADDR_WIDTH_MSB-1:C_AXI_ADDR_WIDTH_LSB]), .S_AXI_AWLEN (S_AXI_AWLEN), .S_AXI_AWID (S_AXI_AWID), .S_AXI_AWSIZE (S_AXI_AWSIZE), .S_AXI_AWBURST (S_AXI_AWBURST), .S_AXI_AWVALID (S_AXI_AWVALID), .S_AXI_AWREADY (S_AXI_AWREADY), .S_AXI_WVALID (S_AXI_WVALID), .S_AXI_WREADY (S_AXI_WREADY), .S_AXI_BVALID (S_AXI_BVALID), .S_AXI_BREADY (S_AXI_BREADY), .S_AXI_BID (S_AXI_BID), // Signals for BRAM interfac( .S_AXI_AWADDR_OUT (s_axi_awaddr_out_c), .S_AXI_WR_EN (s_axi_wr_en_c) ); blk_mem_axi_read_wrapper_beh_v8_2 #(.C_INTERFACE_TYPE (C_INTERFACE_TYPE), .C_AXI_TYPE (C_AXI_TYPE), .C_AXI_SLAVE_TYPE (C_AXI_SLAVE_TYPE), .C_MEMORY_TYPE (C_MEM_TYPE), .C_WRITE_WIDTH_A (C_WRITE_WIDTH_A), .C_ADDRA_WIDTH (C_ADDRA_WIDTH), .C_AXI_PIPELINE_STAGES (1), .C_AXI_ARADDR_WIDTH ((AXI_FULL_MEMORY_SLAVE == 1)?C_AXI_ADDR_WIDTH:C_AXI_ADDR_WIDTH-C_AXI_ADDR_WIDTH_LSB), .C_HAS_AXI_ID (C_HAS_AXI_ID), .C_AXI_ID_WIDTH (C_AXI_ID_WIDTH), .C_ADDRB_WIDTH (C_ADDRB_WIDTH)) axi_rd_sm( //AXI Global Signals .S_ACLK (S_ACLK), .S_ARESETN (s_aresetn_a_c), //AXI Full/Lite Read Side .S_AXI_ARADDR (S_AXI_ARADDR[C_AXI_ADDR_WIDTH_MSB-1:C_AXI_ADDR_WIDTH_LSB]), .S_AXI_ARLEN (s_axi_arlen_c), .S_AXI_ARSIZE (S_AXI_ARSIZE), .S_AXI_ARBURST (S_AXI_ARBURST), .S_AXI_ARVALID (S_AXI_ARVALID), .S_AXI_ARREADY (S_AXI_ARREADY), .S_AXI_RLAST (s_axi_rlast_c), .S_AXI_RVALID (s_axi_rvalid_c), .S_AXI_RREADY (s_axi_rready_c), .S_AXI_ARID (S_AXI_ARID), .S_AXI_RID (s_axi_rid_c), //AXI Full/Lite Read FSM Outputs .S_AXI_ARADDR_OUT (s_axi_araddr_out_c), .S_AXI_RD_EN (s_axi_rd_en_c) ); BLK_MEM_GEN_v8_2_mem_module #(.C_CORENAME (C_CORENAME), .C_FAMILY (C_FAMILY), .C_XDEVICEFAMILY (C_XDEVICEFAMILY), .C_MEM_TYPE (C_MEM_TYPE), .C_BYTE_SIZE (C_BYTE_SIZE), .C_USE_BRAM_BLOCK (C_USE_BRAM_BLOCK), .C_ALGORITHM (C_ALGORITHM), .C_PRIM_TYPE (C_PRIM_TYPE), .C_LOAD_INIT_FILE (C_LOAD_INIT_FILE), .C_INIT_FILE_NAME (C_INIT_FILE_NAME), .C_INIT_FILE (C_INIT_FILE), .C_USE_DEFAULT_DATA (C_USE_DEFAULT_DATA), .C_DEFAULT_DATA (C_DEFAULT_DATA), .C_RST_TYPE ("SYNC"), .C_HAS_RSTA (C_HAS_RSTA), .C_RST_PRIORITY_A (C_RST_PRIORITY_A), .C_RSTRAM_A (C_RSTRAM_A), .C_INITA_VAL (C_INITA_VAL), .C_HAS_ENA (1), .C_HAS_REGCEA (C_HAS_REGCEA), .C_USE_BYTE_WEA (1), .C_WEA_WIDTH (C_WEA_WIDTH), .C_WRITE_MODE_A (C_WRITE_MODE_A), .C_WRITE_WIDTH_A (C_WRITE_WIDTH_A), .C_READ_WIDTH_A (C_READ_WIDTH_A), .C_WRITE_DEPTH_A (C_WRITE_DEPTH_A), .C_READ_DEPTH_A (C_READ_DEPTH_A), .C_ADDRA_WIDTH (C_ADDRA_WIDTH), .C_HAS_RSTB (C_HAS_RSTB), .C_RST_PRIORITY_B (C_RST_PRIORITY_B), .C_RSTRAM_B (C_RSTRAM_B), .C_INITB_VAL (C_INITB_VAL), .C_HAS_ENB (1), .C_HAS_REGCEB (C_HAS_MEM_OUTPUT_REGS_B), .C_USE_BYTE_WEB (1), .C_WEB_WIDTH (C_WEB_WIDTH), .C_WRITE_MODE_B (C_WRITE_MODE_B), .C_WRITE_WIDTH_B (C_WRITE_WIDTH_B), .C_READ_WIDTH_B (C_READ_WIDTH_B), .C_WRITE_DEPTH_B (C_WRITE_DEPTH_B), .C_READ_DEPTH_B (C_READ_DEPTH_B), .C_ADDRB_WIDTH (C_ADDRB_WIDTH), .C_HAS_MEM_OUTPUT_REGS_A (0), .C_HAS_MEM_OUTPUT_REGS_B (C_HAS_MEM_OUTPUT_REGS_B), .C_HAS_MUX_OUTPUT_REGS_A (0), .C_HAS_MUX_OUTPUT_REGS_B (0), .C_HAS_SOFTECC_INPUT_REGS_A (C_HAS_SOFTECC_INPUT_REGS_A), .C_HAS_SOFTECC_OUTPUT_REGS_B (C_HAS_SOFTECC_OUTPUT_REGS_B), .C_MUX_PIPELINE_STAGES (C_MUX_PIPELINE_STAGES), .C_USE_SOFTECC (C_USE_SOFTECC), .C_USE_ECC (C_USE_ECC), .C_HAS_INJECTERR (C_HAS_INJECTERR), .C_SIM_COLLISION_CHECK (C_SIM_COLLISION_CHECK), .C_COMMON_CLK (C_COMMON_CLK), .FLOP_DELAY (FLOP_DELAY), .C_DISABLE_WARN_BHV_COLL (C_DISABLE_WARN_BHV_COLL), .C_EN_ECC_PIPE (0), .C_DISABLE_WARN_BHV_RANGE (C_DISABLE_WARN_BHV_RANGE)) blk_mem_gen_v8_2_inst (.CLKA (S_ACLK), .RSTA (s_aresetn_a_c), .ENA (s_axi_wr_en_c), .REGCEA (regcea_in), .WEA (S_AXI_WSTRB), .ADDRA (s_axi_awaddr_out_c), .DINA (S_AXI_WDATA), .DOUTA (DOUTA), .CLKB (S_ACLK), .RSTB (s_aresetn_a_c), .ENB (s_axi_rd_en_c), .REGCEB (regceb_c), .WEB (WEB_parameterized), .ADDRB (s_axi_araddr_out_c), .DINB (DINB), .DOUTB (s_axi_rdata_c), .INJECTSBITERR (injectsbiterr_in), .INJECTDBITERR (injectdbiterr_in), .SBITERR (SBITERR), .DBITERR (DBITERR), .ECCPIPECE (1'b0), .SLEEP (1'b0), .RDADDRECC (RDADDRECC) ); end endgenerate endmodule
/****************************************************************************** -- (c) Copyright 2006 - 2013 Xilinx, Inc. All rights reserved. -- -- This file contains confidential and proprietary information -- of Xilinx, Inc. and is protected under U.S. and -- international copyright and other intellectual property -- laws. -- -- DISCLAIMER -- This disclaimer is not a license and does not grant any -- rights to the materials distributed herewith. Except as -- otherwise provided in a valid license issued to you by -- Xilinx, and to the maximum extent permitted by applicable -- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND -- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES -- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING -- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- -- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and -- (2) Xilinx shall not be liable (whether in contract or tort, -- including negligence, or under any other theory of -- liability) for any loss or damage of any kind or nature -- related to, arising under or in connection with these -- materials, including for any direct, or any indirect, -- special, incidental, or consequential loss or damage -- (including loss of data, profits, goodwill, or any type of -- loss or damage suffered as a result of any action brought -- by a third party) even if such damage or loss was -- reasonably foreseeable or Xilinx had been advised of the -- possibility of the same. -- -- CRITICAL APPLICATIONS -- Xilinx products are not designed or intended to be fail- -- safe, or for use in any application requiring fail-safe -- performance, such as life-support or safety devices or -- systems, Class III medical devices, nuclear facilities, -- applications related to the deployment of airbags, or any -- other applications that could lead to death, personal -- injury, or severe property or environmental damage -- (individually and collectively, "Critical -- Applications"). Customer assumes the sole risk and -- liability of any use of Xilinx products in Critical -- Applications, subject only to applicable laws and -- regulations governing limitations on product liability. -- -- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS -- PART OF THIS FILE AT ALL TIMES. -- ***************************************************************************** * * Filename: BLK_MEM_GEN_v8_2.v * * Description: * This file is the Verilog behvarial model for the * Block Memory Generator Core. * ***************************************************************************** * Author: Xilinx * * History: Jan 11, 2006 Initial revision * Jun 11, 2007 Added independent register stages for * Port A and Port B (IP1_Jm/v2.5) * Aug 28, 2007 Added mux pipeline stages feature (IP2_Jm/v2.6) * Mar 13, 2008 Behavioral model optimizations * April 07, 2009 : Added support for Spartan-6 and Virtex-6 * features, including the following: * (i) error injection, detection and/or correction * (ii) reset priority * (iii) special reset behavior * *****************************************************************************/ `timescale 1ps/1ps module STATE_LOGIC_v8_2 (O, I0, I1, I2, I3, I4, I5); parameter INIT = 64'h0000000000000000; input I0, I1, I2, I3, I4, I5; output O; reg O; reg tmp; always @( I5 or I4 or I3 or I2 or I1 or I0 ) begin tmp = I0 ^ I1 ^ I2 ^ I3 ^ I4 ^ I5; if ( tmp == 0 || tmp == 1) O = INIT[{I5, I4, I3, I2, I1, I0}]; end endmodule module beh_vlog_muxf7_v8_2 (O, I0, I1, S); output O; reg O; input I0, I1, S; always @(I0 or I1 or S) if (S) O = I1; else O = I0; endmodule module beh_vlog_ff_clr_v8_2 (Q, C, CLR, D); parameter INIT = 0; localparam FLOP_DELAY = 100; output Q; input C, CLR, D; reg Q; initial Q= 1'b0; always @(posedge C ) if (CLR) Q<= 1'b0; else Q<= #FLOP_DELAY D; endmodule module beh_vlog_ff_pre_v8_2 (Q, C, D, PRE); parameter INIT = 0; localparam FLOP_DELAY = 100; output Q; input C, D, PRE; reg Q; initial Q= 1'b0; always @(posedge C ) if (PRE) Q <= 1'b1; else Q <= #FLOP_DELAY D; endmodule module beh_vlog_ff_ce_clr_v8_2 (Q, C, CE, CLR, D); parameter INIT = 0; localparam FLOP_DELAY = 100; output Q; input C, CE, CLR, D; reg Q; initial Q= 1'b0; always @(posedge C ) if (CLR) Q <= 1'b0; else if (CE) Q <= #FLOP_DELAY D; endmodule module write_netlist_v8_2 #( parameter C_AXI_TYPE = 0 ) ( S_ACLK, S_ARESETN, S_AXI_AWVALID, S_AXI_WVALID, S_AXI_BREADY, w_last_c, bready_timeout_c, aw_ready_r, S_AXI_WREADY, S_AXI_BVALID, S_AXI_WR_EN, addr_en_c, incr_addr_c, bvalid_c ); input S_ACLK; input S_ARESETN; input S_AXI_AWVALID; input S_AXI_WVALID; input S_AXI_BREADY; input w_last_c; input bready_timeout_c; output aw_ready_r; output S_AXI_WREADY; output S_AXI_BVALID; output S_AXI_WR_EN; output addr_en_c; output incr_addr_c; output bvalid_c; //------------------------------------------------------------------------- //AXI LITE //------------------------------------------------------------------------- generate if (C_AXI_TYPE == 0 ) begin : gbeh_axi_lite_sm wire w_ready_r_7; wire w_ready_c; wire aw_ready_c; wire NlwRenamedSignal_bvalid_c; wire NlwRenamedSignal_incr_addr_c; wire present_state_FSM_FFd3_13; wire present_state_FSM_FFd2_14; wire present_state_FSM_FFd1_15; wire present_state_FSM_FFd4_16; wire present_state_FSM_FFd4_In; wire present_state_FSM_FFd3_In; wire present_state_FSM_FFd2_In; wire present_state_FSM_FFd1_In; wire present_state_FSM_FFd4_In1_21; wire [0:0] Mmux_aw_ready_c ; begin assign S_AXI_WREADY = w_ready_r_7, S_AXI_BVALID = NlwRenamedSignal_incr_addr_c, S_AXI_WR_EN = NlwRenamedSignal_bvalid_c, incr_addr_c = NlwRenamedSignal_incr_addr_c, bvalid_c = NlwRenamedSignal_bvalid_c; assign NlwRenamedSignal_incr_addr_c = 1'b0; beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) aw_ready_r_2 ( .C ( S_ACLK), .CLR ( S_ARESETN), .D ( aw_ready_c), .Q ( aw_ready_r) ); beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) w_ready_r ( .C ( S_ACLK), .CLR ( S_ARESETN), .D ( w_ready_c), .Q ( w_ready_r_7) ); beh_vlog_ff_pre_v8_2 #( .INIT (1'b1)) present_state_FSM_FFd4 ( .C ( S_ACLK), .D ( present_state_FSM_FFd4_In), .PRE ( S_ARESETN), .Q ( present_state_FSM_FFd4_16) ); beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) present_state_FSM_FFd3 ( .C ( S_ACLK), .CLR ( S_ARESETN), .D ( present_state_FSM_FFd3_In), .Q ( present_state_FSM_FFd3_13) ); beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) present_state_FSM_FFd2 ( .C ( S_ACLK), .CLR ( S_ARESETN), .D ( present_state_FSM_FFd2_In), .Q ( present_state_FSM_FFd2_14) ); beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) present_state_FSM_FFd1 ( .C ( S_ACLK), .CLR ( S_ARESETN), .D ( present_state_FSM_FFd1_In), .Q ( present_state_FSM_FFd1_15) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000055554440)) present_state_FSM_FFd3_In1 ( .I0 ( S_AXI_WVALID), .I1 ( S_AXI_AWVALID), .I2 ( present_state_FSM_FFd2_14), .I3 ( present_state_FSM_FFd4_16), .I4 ( present_state_FSM_FFd3_13), .I5 (1'b0), .O ( present_state_FSM_FFd3_In) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000088880800)) present_state_FSM_FFd2_In1 ( .I0 ( S_AXI_AWVALID), .I1 ( S_AXI_WVALID), .I2 ( bready_timeout_c), .I3 ( present_state_FSM_FFd2_14), .I4 ( present_state_FSM_FFd4_16), .I5 (1'b0), .O ( present_state_FSM_FFd2_In) ); STATE_LOGIC_v8_2 #( .INIT (64'h00000000AAAA2000)) Mmux_addr_en_c_0_1 ( .I0 ( S_AXI_AWVALID), .I1 ( bready_timeout_c), .I2 ( present_state_FSM_FFd2_14), .I3 ( S_AXI_WVALID), .I4 ( present_state_FSM_FFd4_16), .I5 (1'b0), .O ( addr_en_c) ); STATE_LOGIC_v8_2 #( .INIT (64'hF5F07570F5F05500)) Mmux_w_ready_c_0_1 ( .I0 ( S_AXI_WVALID), .I1 ( bready_timeout_c), .I2 ( S_AXI_AWVALID), .I3 ( present_state_FSM_FFd3_13), .I4 ( present_state_FSM_FFd4_16), .I5 ( present_state_FSM_FFd2_14), .O ( w_ready_c) ); STATE_LOGIC_v8_2 #( .INIT (64'h88808880FFFF8880)) present_state_FSM_FFd1_In1 ( .I0 ( S_AXI_WVALID), .I1 ( bready_timeout_c), .I2 ( present_state_FSM_FFd3_13), .I3 ( present_state_FSM_FFd2_14), .I4 ( present_state_FSM_FFd1_15), .I5 ( S_AXI_BREADY), .O ( present_state_FSM_FFd1_In) ); STATE_LOGIC_v8_2 #( .INIT (64'h00000000000000A8)) Mmux_S_AXI_WR_EN_0_1 ( .I0 ( S_AXI_WVALID), .I1 ( present_state_FSM_FFd2_14), .I2 ( present_state_FSM_FFd3_13), .I3 (1'b0), .I4 (1'b0), .I5 (1'b0), .O ( NlwRenamedSignal_bvalid_c) ); STATE_LOGIC_v8_2 #( .INIT (64'h2F0F27072F0F2200)) present_state_FSM_FFd4_In1 ( .I0 ( S_AXI_WVALID), .I1 ( bready_timeout_c), .I2 ( S_AXI_AWVALID), .I3 ( present_state_FSM_FFd3_13), .I4 ( present_state_FSM_FFd4_16), .I5 ( present_state_FSM_FFd2_14), .O ( present_state_FSM_FFd4_In1_21) ); STATE_LOGIC_v8_2 #( .INIT (64'h00000000000000F8)) present_state_FSM_FFd4_In2 ( .I0 ( present_state_FSM_FFd1_15), .I1 ( S_AXI_BREADY), .I2 ( present_state_FSM_FFd4_In1_21), .I3 (1'b0), .I4 (1'b0), .I5 (1'b0), .O ( present_state_FSM_FFd4_In) ); STATE_LOGIC_v8_2 #( .INIT (64'h7535753575305500)) Mmux_aw_ready_c_0_1 ( .I0 ( S_AXI_AWVALID), .I1 ( bready_timeout_c), .I2 ( S_AXI_WVALID), .I3 ( present_state_FSM_FFd4_16), .I4 ( present_state_FSM_FFd3_13), .I5 ( present_state_FSM_FFd2_14), .O ( Mmux_aw_ready_c[0]) ); STATE_LOGIC_v8_2 #( .INIT (64'h00000000000000F8)) Mmux_aw_ready_c_0_2 ( .I0 ( present_state_FSM_FFd1_15), .I1 ( S_AXI_BREADY), .I2 ( Mmux_aw_ready_c[0]), .I3 (1'b0), .I4 (1'b0), .I5 (1'b0), .O ( aw_ready_c) ); end end endgenerate //--------------------------------------------------------------------- // AXI FULL //--------------------------------------------------------------------- generate if (C_AXI_TYPE == 1 ) begin : gbeh_axi_full_sm wire w_ready_r_8; wire w_ready_c; wire aw_ready_c; wire NlwRenamedSig_OI_bvalid_c; wire present_state_FSM_FFd1_16; wire present_state_FSM_FFd4_17; wire present_state_FSM_FFd3_18; wire present_state_FSM_FFd2_19; wire present_state_FSM_FFd4_In; wire present_state_FSM_FFd3_In; wire present_state_FSM_FFd2_In; wire present_state_FSM_FFd1_In; wire present_state_FSM_FFd2_In1_24; wire present_state_FSM_FFd4_In1_25; wire N2; wire N4; begin assign S_AXI_WREADY = w_ready_r_8, bvalid_c = NlwRenamedSig_OI_bvalid_c, S_AXI_BVALID = 1'b0; beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) aw_ready_r_2 ( .C ( S_ACLK), .CLR ( S_ARESETN), .D ( aw_ready_c), .Q ( aw_ready_r) ); beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) w_ready_r ( .C ( S_ACLK), .CLR ( S_ARESETN), .D ( w_ready_c), .Q ( w_ready_r_8) ); beh_vlog_ff_pre_v8_2 #( .INIT (1'b1)) present_state_FSM_FFd4 ( .C ( S_ACLK), .D ( present_state_FSM_FFd4_In), .PRE ( S_ARESETN), .Q ( present_state_FSM_FFd4_17) ); beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) present_state_FSM_FFd3 ( .C ( S_ACLK), .CLR ( S_ARESETN), .D ( present_state_FSM_FFd3_In), .Q ( present_state_FSM_FFd3_18) ); beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) present_state_FSM_FFd2 ( .C ( S_ACLK), .CLR ( S_ARESETN), .D ( present_state_FSM_FFd2_In), .Q ( present_state_FSM_FFd2_19) ); beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) present_state_FSM_FFd1 ( .C ( S_ACLK), .CLR ( S_ARESETN), .D ( present_state_FSM_FFd1_In), .Q ( present_state_FSM_FFd1_16) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000000005540)) present_state_FSM_FFd3_In1 ( .I0 ( S_AXI_WVALID), .I1 ( present_state_FSM_FFd4_17), .I2 ( S_AXI_AWVALID), .I3 ( present_state_FSM_FFd3_18), .I4 (1'b0), .I5 (1'b0), .O ( present_state_FSM_FFd3_In) ); STATE_LOGIC_v8_2 #( .INIT (64'hBF3FBB33AF0FAA00)) Mmux_aw_ready_c_0_2 ( .I0 ( S_AXI_BREADY), .I1 ( bready_timeout_c), .I2 ( S_AXI_AWVALID), .I3 ( present_state_FSM_FFd1_16), .I4 ( present_state_FSM_FFd4_17), .I5 ( NlwRenamedSig_OI_bvalid_c), .O ( aw_ready_c) ); STATE_LOGIC_v8_2 #( .INIT (64'hAAAAAAAA20000000)) Mmux_addr_en_c_0_1 ( .I0 ( S_AXI_AWVALID), .I1 ( bready_timeout_c), .I2 ( present_state_FSM_FFd2_19), .I3 ( S_AXI_WVALID), .I4 ( w_last_c), .I5 ( present_state_FSM_FFd4_17), .O ( addr_en_c) ); STATE_LOGIC_v8_2 #( .INIT (64'h00000000000000A8)) Mmux_S_AXI_WR_EN_0_1 ( .I0 ( S_AXI_WVALID), .I1 ( present_state_FSM_FFd2_19), .I2 ( present_state_FSM_FFd3_18), .I3 (1'b0), .I4 (1'b0), .I5 (1'b0), .O ( S_AXI_WR_EN) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000000002220)) Mmux_incr_addr_c_0_1 ( .I0 ( S_AXI_WVALID), .I1 ( w_last_c), .I2 ( present_state_FSM_FFd2_19), .I3 ( present_state_FSM_FFd3_18), .I4 (1'b0), .I5 (1'b0), .O ( incr_addr_c) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000000008880)) Mmux_aw_ready_c_0_11 ( .I0 ( S_AXI_WVALID), .I1 ( w_last_c), .I2 ( present_state_FSM_FFd2_19), .I3 ( present_state_FSM_FFd3_18), .I4 (1'b0), .I5 (1'b0), .O ( NlwRenamedSig_OI_bvalid_c) ); STATE_LOGIC_v8_2 #( .INIT (64'h000000000000D5C0)) present_state_FSM_FFd2_In1 ( .I0 ( w_last_c), .I1 ( S_AXI_AWVALID), .I2 ( present_state_FSM_FFd4_17), .I3 ( present_state_FSM_FFd3_18), .I4 (1'b0), .I5 (1'b0), .O ( present_state_FSM_FFd2_In1_24) ); STATE_LOGIC_v8_2 #( .INIT (64'hFFFFAAAA08AAAAAA)) present_state_FSM_FFd2_In2 ( .I0 ( present_state_FSM_FFd2_19), .I1 ( S_AXI_AWVALID), .I2 ( bready_timeout_c), .I3 ( w_last_c), .I4 ( S_AXI_WVALID), .I5 ( present_state_FSM_FFd2_In1_24), .O ( present_state_FSM_FFd2_In) ); STATE_LOGIC_v8_2 #( .INIT (64'h00C0004000C00000)) present_state_FSM_FFd4_In1 ( .I0 ( S_AXI_AWVALID), .I1 ( w_last_c), .I2 ( S_AXI_WVALID), .I3 ( bready_timeout_c), .I4 ( present_state_FSM_FFd3_18), .I5 ( present_state_FSM_FFd2_19), .O ( present_state_FSM_FFd4_In1_25) ); STATE_LOGIC_v8_2 #( .INIT (64'h00000000FFFF88F8)) present_state_FSM_FFd4_In2 ( .I0 ( present_state_FSM_FFd1_16), .I1 ( S_AXI_BREADY), .I2 ( present_state_FSM_FFd4_17), .I3 ( S_AXI_AWVALID), .I4 ( present_state_FSM_FFd4_In1_25), .I5 (1'b0), .O ( present_state_FSM_FFd4_In) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000000000007)) Mmux_w_ready_c_0_SW0 ( .I0 ( w_last_c), .I1 ( S_AXI_WVALID), .I2 (1'b0), .I3 (1'b0), .I4 (1'b0), .I5 (1'b0), .O ( N2) ); STATE_LOGIC_v8_2 #( .INIT (64'hFABAFABAFAAAF000)) Mmux_w_ready_c_0_Q ( .I0 ( N2), .I1 ( bready_timeout_c), .I2 ( S_AXI_AWVALID), .I3 ( present_state_FSM_FFd4_17), .I4 ( present_state_FSM_FFd3_18), .I5 ( present_state_FSM_FFd2_19), .O ( w_ready_c) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000000000008)) Mmux_aw_ready_c_0_11_SW0 ( .I0 ( bready_timeout_c), .I1 ( S_AXI_WVALID), .I2 (1'b0), .I3 (1'b0), .I4 (1'b0), .I5 (1'b0), .O ( N4) ); STATE_LOGIC_v8_2 #( .INIT (64'h88808880FFFF8880)) present_state_FSM_FFd1_In1 ( .I0 ( w_last_c), .I1 ( N4), .I2 ( present_state_FSM_FFd2_19), .I3 ( present_state_FSM_FFd3_18), .I4 ( present_state_FSM_FFd1_16), .I5 ( S_AXI_BREADY), .O ( present_state_FSM_FFd1_In) ); end end endgenerate endmodule module read_netlist_v8_2 #( parameter C_AXI_TYPE = 1, parameter C_ADDRB_WIDTH = 12 ) ( S_AXI_R_LAST_INT, S_ACLK, S_ARESETN, S_AXI_ARVALID, S_AXI_RREADY,S_AXI_INCR_ADDR,S_AXI_ADDR_EN, S_AXI_SINGLE_TRANS,S_AXI_MUX_SEL, S_AXI_R_LAST, S_AXI_ARREADY, S_AXI_RLAST, S_AXI_RVALID, S_AXI_RD_EN, S_AXI_ARLEN); input S_AXI_R_LAST_INT; input S_ACLK; input S_ARESETN; input S_AXI_ARVALID; input S_AXI_RREADY; output S_AXI_INCR_ADDR; output S_AXI_ADDR_EN; output S_AXI_SINGLE_TRANS; output S_AXI_MUX_SEL; output S_AXI_R_LAST; output S_AXI_ARREADY; output S_AXI_RLAST; output S_AXI_RVALID; output S_AXI_RD_EN; input [7:0] S_AXI_ARLEN; wire present_state_FSM_FFd1_13 ; wire present_state_FSM_FFd2_14 ; wire gaxi_full_sm_outstanding_read_r_15 ; wire gaxi_full_sm_ar_ready_r_16 ; wire gaxi_full_sm_r_last_r_17 ; wire NlwRenamedSig_OI_gaxi_full_sm_r_valid_r ; wire gaxi_full_sm_r_valid_c ; wire S_AXI_RREADY_gaxi_full_sm_r_valid_r_OR_9_o ; wire gaxi_full_sm_ar_ready_c ; wire gaxi_full_sm_outstanding_read_c ; wire NlwRenamedSig_OI_S_AXI_R_LAST ; wire S_AXI_ARLEN_7_GND_8_o_equal_1_o ; wire present_state_FSM_FFd2_In ; wire present_state_FSM_FFd1_In ; wire Mmux_S_AXI_R_LAST13 ; wire N01 ; wire N2 ; wire Mmux_gaxi_full_sm_ar_ready_c11 ; wire N4 ; wire N8 ; wire N9 ; wire N10 ; wire N11 ; wire N12 ; wire N13 ; assign S_AXI_R_LAST = NlwRenamedSig_OI_S_AXI_R_LAST, S_AXI_ARREADY = gaxi_full_sm_ar_ready_r_16, S_AXI_RLAST = gaxi_full_sm_r_last_r_17, S_AXI_RVALID = NlwRenamedSig_OI_gaxi_full_sm_r_valid_r; beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) gaxi_full_sm_outstanding_read_r ( .C (S_ACLK), .CLR(S_ARESETN), .D(gaxi_full_sm_outstanding_read_c), .Q(gaxi_full_sm_outstanding_read_r_15) ); beh_vlog_ff_ce_clr_v8_2 #( .INIT (1'b0)) gaxi_full_sm_r_valid_r ( .C (S_ACLK), .CE (S_AXI_RREADY_gaxi_full_sm_r_valid_r_OR_9_o), .CLR (S_ARESETN), .D (gaxi_full_sm_r_valid_c), .Q (NlwRenamedSig_OI_gaxi_full_sm_r_valid_r) ); beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) gaxi_full_sm_ar_ready_r ( .C (S_ACLK), .CLR (S_ARESETN), .D (gaxi_full_sm_ar_ready_c), .Q (gaxi_full_sm_ar_ready_r_16) ); beh_vlog_ff_ce_clr_v8_2 #( .INIT(1'b0)) gaxi_full_sm_r_last_r ( .C (S_ACLK), .CE (S_AXI_RREADY_gaxi_full_sm_r_valid_r_OR_9_o), .CLR (S_ARESETN), .D (NlwRenamedSig_OI_S_AXI_R_LAST), .Q (gaxi_full_sm_r_last_r_17) ); beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) present_state_FSM_FFd2 ( .C ( S_ACLK), .CLR ( S_ARESETN), .D ( present_state_FSM_FFd2_In), .Q ( present_state_FSM_FFd2_14) ); beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) present_state_FSM_FFd1 ( .C (S_ACLK), .CLR (S_ARESETN), .D (present_state_FSM_FFd1_In), .Q (present_state_FSM_FFd1_13) ); STATE_LOGIC_v8_2 #( .INIT (64'h000000000000000B)) S_AXI_RREADY_gaxi_full_sm_r_valid_r_OR_9_o1 ( .I0 ( S_AXI_RREADY), .I1 ( NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .I2 (1'b0), .I3 (1'b0), .I4 (1'b0), .I5 (1'b0), .O (S_AXI_RREADY_gaxi_full_sm_r_valid_r_OR_9_o) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000000000008)) Mmux_S_AXI_SINGLE_TRANS11 ( .I0 (S_AXI_ARVALID), .I1 (S_AXI_ARLEN_7_GND_8_o_equal_1_o), .I2 (1'b0), .I3 (1'b0), .I4 (1'b0), .I5 (1'b0), .O (S_AXI_SINGLE_TRANS) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000000000004)) Mmux_S_AXI_ADDR_EN11 ( .I0 (present_state_FSM_FFd1_13), .I1 (S_AXI_ARVALID), .I2 (1'b0), .I3 (1'b0), .I4 (1'b0), .I5 (1'b0), .O (S_AXI_ADDR_EN) ); STATE_LOGIC_v8_2 #( .INIT (64'hECEE2022EEEE2022)) present_state_FSM_FFd2_In1 ( .I0 ( S_AXI_ARVALID), .I1 ( present_state_FSM_FFd1_13), .I2 ( S_AXI_RREADY), .I3 ( S_AXI_ARLEN_7_GND_8_o_equal_1_o), .I4 ( present_state_FSM_FFd2_14), .I5 ( NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .O ( present_state_FSM_FFd2_In) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000044440444)) Mmux_S_AXI_R_LAST131 ( .I0 ( present_state_FSM_FFd1_13), .I1 ( S_AXI_ARVALID), .I2 ( present_state_FSM_FFd2_14), .I3 ( NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .I4 ( S_AXI_RREADY), .I5 (1'b0), .O ( Mmux_S_AXI_R_LAST13) ); STATE_LOGIC_v8_2 #( .INIT (64'h4000FFFF40004000)) Mmux_S_AXI_INCR_ADDR11 ( .I0 ( S_AXI_R_LAST_INT), .I1 ( S_AXI_RREADY_gaxi_full_sm_r_valid_r_OR_9_o), .I2 ( present_state_FSM_FFd2_14), .I3 ( present_state_FSM_FFd1_13), .I4 ( S_AXI_ARLEN_7_GND_8_o_equal_1_o), .I5 ( Mmux_S_AXI_R_LAST13), .O ( S_AXI_INCR_ADDR) ); STATE_LOGIC_v8_2 #( .INIT (64'h00000000000000FE)) S_AXI_ARLEN_7_GND_8_o_equal_1_o_7_SW0 ( .I0 ( S_AXI_ARLEN[2]), .I1 ( S_AXI_ARLEN[1]), .I2 ( S_AXI_ARLEN[0]), .I3 ( 1'b0), .I4 ( 1'b0), .I5 ( 1'b0), .O ( N01) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000000000001)) S_AXI_ARLEN_7_GND_8_o_equal_1_o_7_Q ( .I0 ( S_AXI_ARLEN[7]), .I1 ( S_AXI_ARLEN[6]), .I2 ( S_AXI_ARLEN[5]), .I3 ( S_AXI_ARLEN[4]), .I4 ( S_AXI_ARLEN[3]), .I5 ( N01), .O ( S_AXI_ARLEN_7_GND_8_o_equal_1_o) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000000000007)) Mmux_gaxi_full_sm_outstanding_read_c1_SW0 ( .I0 ( S_AXI_ARVALID), .I1 ( S_AXI_ARLEN_7_GND_8_o_equal_1_o), .I2 ( 1'b0), .I3 ( 1'b0), .I4 ( 1'b0), .I5 ( 1'b0), .O ( N2) ); STATE_LOGIC_v8_2 #( .INIT (64'h0020000002200200)) Mmux_gaxi_full_sm_outstanding_read_c1 ( .I0 ( NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .I1 ( S_AXI_RREADY), .I2 ( present_state_FSM_FFd1_13), .I3 ( present_state_FSM_FFd2_14), .I4 ( gaxi_full_sm_outstanding_read_r_15), .I5 ( N2), .O ( gaxi_full_sm_outstanding_read_c) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000000004555)) Mmux_gaxi_full_sm_ar_ready_c12 ( .I0 ( S_AXI_ARVALID), .I1 ( S_AXI_RREADY), .I2 ( present_state_FSM_FFd2_14), .I3 ( NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .I4 ( 1'b0), .I5 ( 1'b0), .O ( Mmux_gaxi_full_sm_ar_ready_c11) ); STATE_LOGIC_v8_2 #( .INIT (64'h00000000000000EF)) Mmux_S_AXI_R_LAST11_SW0 ( .I0 ( S_AXI_ARLEN_7_GND_8_o_equal_1_o), .I1 ( S_AXI_RREADY), .I2 ( NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .I3 ( 1'b0), .I4 ( 1'b0), .I5 ( 1'b0), .O ( N4) ); STATE_LOGIC_v8_2 #( .INIT (64'hFCAAFC0A00AA000A)) Mmux_S_AXI_R_LAST11 ( .I0 ( S_AXI_ARVALID), .I1 ( gaxi_full_sm_outstanding_read_r_15), .I2 ( present_state_FSM_FFd2_14), .I3 ( present_state_FSM_FFd1_13), .I4 ( N4), .I5 ( S_AXI_RREADY_gaxi_full_sm_r_valid_r_OR_9_o), .O ( gaxi_full_sm_r_valid_c) ); STATE_LOGIC_v8_2 #( .INIT (64'h00000000AAAAAA08)) S_AXI_MUX_SEL1 ( .I0 (present_state_FSM_FFd1_13), .I1 (NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .I2 (S_AXI_RREADY), .I3 (present_state_FSM_FFd2_14), .I4 (gaxi_full_sm_outstanding_read_r_15), .I5 (1'b0), .O (S_AXI_MUX_SEL) ); STATE_LOGIC_v8_2 #( .INIT (64'hF3F3F755A2A2A200)) Mmux_S_AXI_RD_EN11 ( .I0 ( present_state_FSM_FFd1_13), .I1 ( NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .I2 ( S_AXI_RREADY), .I3 ( gaxi_full_sm_outstanding_read_r_15), .I4 ( present_state_FSM_FFd2_14), .I5 ( S_AXI_ARVALID), .O ( S_AXI_RD_EN) ); beh_vlog_muxf7_v8_2 present_state_FSM_FFd1_In3 ( .I0 ( N8), .I1 ( N9), .S ( present_state_FSM_FFd1_13), .O ( present_state_FSM_FFd1_In) ); STATE_LOGIC_v8_2 #( .INIT (64'h000000005410F4F0)) present_state_FSM_FFd1_In3_F ( .I0 ( S_AXI_RREADY), .I1 ( present_state_FSM_FFd2_14), .I2 ( S_AXI_ARVALID), .I3 ( NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .I4 ( S_AXI_ARLEN_7_GND_8_o_equal_1_o), .I5 ( 1'b0), .O ( N8) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000072FF7272)) present_state_FSM_FFd1_In3_G ( .I0 ( present_state_FSM_FFd2_14), .I1 ( S_AXI_R_LAST_INT), .I2 ( gaxi_full_sm_outstanding_read_r_15), .I3 ( S_AXI_RREADY), .I4 ( NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .I5 ( 1'b0), .O ( N9) ); beh_vlog_muxf7_v8_2 Mmux_gaxi_full_sm_ar_ready_c14 ( .I0 ( N10), .I1 ( N11), .S ( present_state_FSM_FFd1_13), .O ( gaxi_full_sm_ar_ready_c) ); STATE_LOGIC_v8_2 #( .INIT (64'h00000000FFFF88A8)) Mmux_gaxi_full_sm_ar_ready_c14_F ( .I0 ( S_AXI_ARLEN_7_GND_8_o_equal_1_o), .I1 ( S_AXI_RREADY), .I2 ( present_state_FSM_FFd2_14), .I3 ( NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .I4 ( Mmux_gaxi_full_sm_ar_ready_c11), .I5 ( 1'b0), .O ( N10) ); STATE_LOGIC_v8_2 #( .INIT (64'h000000008D008D8D)) Mmux_gaxi_full_sm_ar_ready_c14_G ( .I0 ( present_state_FSM_FFd2_14), .I1 ( S_AXI_R_LAST_INT), .I2 ( gaxi_full_sm_outstanding_read_r_15), .I3 ( S_AXI_RREADY), .I4 ( NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .I5 ( 1'b0), .O ( N11) ); beh_vlog_muxf7_v8_2 Mmux_S_AXI_R_LAST1 ( .I0 ( N12), .I1 ( N13), .S ( present_state_FSM_FFd1_13), .O ( NlwRenamedSig_OI_S_AXI_R_LAST) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000088088888)) Mmux_S_AXI_R_LAST1_F ( .I0 ( S_AXI_ARLEN_7_GND_8_o_equal_1_o), .I1 ( S_AXI_ARVALID), .I2 ( present_state_FSM_FFd2_14), .I3 ( S_AXI_RREADY), .I4 ( NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .I5 ( 1'b0), .O ( N12) ); STATE_LOGIC_v8_2 #( .INIT (64'h00000000E400E4E4)) Mmux_S_AXI_R_LAST1_G ( .I0 ( present_state_FSM_FFd2_14), .I1 ( gaxi_full_sm_outstanding_read_r_15), .I2 ( S_AXI_R_LAST_INT), .I3 ( S_AXI_RREADY), .I4 ( NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .I5 ( 1'b0), .O ( N13) ); endmodule module blk_mem_axi_write_wrapper_beh_v8_2 # ( // AXI Interface related parameters start here parameter C_INTERFACE_TYPE = 0, // 0: Native Interface; 1: AXI Interface parameter C_AXI_TYPE = 0, // 0: AXI Lite; 1: AXI Full; parameter C_AXI_SLAVE_TYPE = 0, // 0: MEMORY SLAVE; 1: PERIPHERAL SLAVE; parameter C_MEMORY_TYPE = 0, // 0: SP-RAM, 1: SDP-RAM; 2: TDP-RAM; 3: DP-ROM; parameter C_WRITE_DEPTH_A = 0, parameter C_AXI_AWADDR_WIDTH = 32, parameter C_ADDRA_WIDTH = 12, parameter C_AXI_WDATA_WIDTH = 32, parameter C_HAS_AXI_ID = 0, parameter C_AXI_ID_WIDTH = 4, // AXI OUTSTANDING WRITES parameter C_AXI_OS_WR = 2 ) ( // AXI Global Signals input S_ACLK, input S_ARESETN, // AXI Full/Lite Slave Write Channel (write side) input [C_AXI_ID_WIDTH-1:0] S_AXI_AWID, input [C_AXI_AWADDR_WIDTH-1:0] S_AXI_AWADDR, input [8-1:0] S_AXI_AWLEN, input [2:0] S_AXI_AWSIZE, input [1:0] S_AXI_AWBURST, input S_AXI_AWVALID, output S_AXI_AWREADY, input S_AXI_WVALID, output S_AXI_WREADY, output reg [C_AXI_ID_WIDTH-1:0] S_AXI_BID = 0, output S_AXI_BVALID, input S_AXI_BREADY, // Signals for BMG interface output [C_ADDRA_WIDTH-1:0] S_AXI_AWADDR_OUT, output S_AXI_WR_EN ); localparam FLOP_DELAY = 100; // 100 ps localparam C_RANGE = ((C_AXI_WDATA_WIDTH == 8)?0: ((C_AXI_WDATA_WIDTH==16)?1: ((C_AXI_WDATA_WIDTH==32)?2: ((C_AXI_WDATA_WIDTH==64)?3: ((C_AXI_WDATA_WIDTH==128)?4: ((C_AXI_WDATA_WIDTH==256)?5:0)))))); wire bvalid_c ; reg bready_timeout_c = 0; wire [1:0] bvalid_rd_cnt_c; reg bvalid_r = 0; reg [2:0] bvalid_count_r = 0; reg [((C_AXI_TYPE == 1 && C_AXI_SLAVE_TYPE == 0)? C_AXI_AWADDR_WIDTH:C_ADDRA_WIDTH)-1:0] awaddr_reg = 0; reg [1:0] bvalid_wr_cnt_r = 0; reg [1:0] bvalid_rd_cnt_r = 0; wire w_last_c ; wire addr_en_c ; wire incr_addr_c ; wire aw_ready_r ; wire dec_alen_c ; reg bvalid_d1_c = 0; reg [7:0] awlen_cntr_r = 0; reg [7:0] awlen_int = 0; reg [1:0] awburst_int = 0; integer total_bytes = 0; integer wrap_boundary = 0; integer wrap_base_addr = 0; integer num_of_bytes_c = 0; integer num_of_bytes_r = 0; // Array to store BIDs reg [C_AXI_ID_WIDTH-1:0] axi_bid_array[3:0] ; wire S_AXI_BVALID_axi_wr_fsm; //------------------------------------- //AXI WRITE FSM COMPONENT INSTANTIATION //------------------------------------- write_netlist_v8_2 #(.C_AXI_TYPE(C_AXI_TYPE)) axi_wr_fsm ( .S_ACLK(S_ACLK), .S_ARESETN(S_ARESETN), .S_AXI_AWVALID(S_AXI_AWVALID), .aw_ready_r(aw_ready_r), .S_AXI_WVALID(S_AXI_WVALID), .S_AXI_WREADY(S_AXI_WREADY), .S_AXI_BREADY(S_AXI_BREADY), .S_AXI_WR_EN(S_AXI_WR_EN), .w_last_c(w_last_c), .bready_timeout_c(bready_timeout_c), .addr_en_c(addr_en_c), .incr_addr_c(incr_addr_c), .bvalid_c(bvalid_c), .S_AXI_BVALID (S_AXI_BVALID_axi_wr_fsm) ); //Wrap Address boundary calculation always@(*) begin num_of_bytes_c = 2**((C_AXI_TYPE == 1 && C_AXI_SLAVE_TYPE == 0)?S_AXI_AWSIZE:0); total_bytes = (num_of_bytes_r)*(awlen_int+1); wrap_base_addr = ((awaddr_reg)/((total_bytes==0)?1:total_bytes))*(total_bytes); wrap_boundary = wrap_base_addr+total_bytes; end //------------------------------------------------------------------------- // BMG address generation //------------------------------------------------------------------------- always @(posedge S_ACLK or S_ARESETN) begin if (S_ARESETN == 1'b1) begin awaddr_reg <= 0; num_of_bytes_r <= 0; awburst_int <= 0; end else begin if (addr_en_c == 1'b1) begin awaddr_reg <= #FLOP_DELAY S_AXI_AWADDR ; num_of_bytes_r <= num_of_bytes_c; awburst_int <= ((C_AXI_TYPE == 1 && C_AXI_SLAVE_TYPE == 0)?S_AXI_AWBURST:2'b01); end else if (incr_addr_c == 1'b1) begin if (awburst_int == 2'b10) begin if(awaddr_reg == (wrap_boundary-num_of_bytes_r)) begin awaddr_reg <= wrap_base_addr; end else begin awaddr_reg <= awaddr_reg + num_of_bytes_r; end end else if (awburst_int == 2'b01 || awburst_int == 2'b11) begin awaddr_reg <= awaddr_reg + num_of_bytes_r; end end end end assign S_AXI_AWADDR_OUT = ((C_AXI_TYPE == 1 && C_AXI_SLAVE_TYPE == 0)? awaddr_reg[C_AXI_AWADDR_WIDTH-1:C_RANGE]:awaddr_reg); //------------------------------------------------------------------------- // AXI wlast generation //------------------------------------------------------------------------- always @(posedge S_ACLK or S_ARESETN) begin if (S_ARESETN == 1'b1) begin awlen_cntr_r <= 0; awlen_int <= 0; end else begin if (addr_en_c == 1'b1) begin awlen_int <= #FLOP_DELAY (C_AXI_TYPE == 0?0:S_AXI_AWLEN) ; awlen_cntr_r <= #FLOP_DELAY (C_AXI_TYPE == 0?0:S_AXI_AWLEN) ; end else if (dec_alen_c == 1'b1) begin awlen_cntr_r <= #FLOP_DELAY awlen_cntr_r - 1 ; end end end assign w_last_c = (awlen_cntr_r == 0 && S_AXI_WVALID == 1'b1)?1'b1:1'b0; assign dec_alen_c = (incr_addr_c | w_last_c); //------------------------------------------------------------------------- // Generation of bvalid counter for outstanding transactions //------------------------------------------------------------------------- always @(posedge S_ACLK or S_ARESETN) begin if (S_ARESETN == 1'b1) begin bvalid_count_r <= 0; end else begin // bvalid_count_r generation if (bvalid_c == 1'b1 && bvalid_r == 1'b1 && S_AXI_BREADY == 1'b1) begin bvalid_count_r <= #FLOP_DELAY bvalid_count_r ; end else if (bvalid_c == 1'b1) begin bvalid_count_r <= #FLOP_DELAY bvalid_count_r + 1 ; end else if (bvalid_r == 1'b1 && S_AXI_BREADY == 1'b1 && bvalid_count_r != 0) begin bvalid_count_r <= #FLOP_DELAY bvalid_count_r - 1 ; end end end //------------------------------------------------------------------------- // Generation of bvalid when BID is used //------------------------------------------------------------------------- generate if (C_HAS_AXI_ID == 1) begin:gaxi_bvalid_id_r always @(posedge S_ACLK or S_ARESETN) begin if (S_ARESETN == 1'b1) begin bvalid_r <= 0; bvalid_d1_c <= 0; end else begin // Delay the generation o bvalid_r for generation for BID bvalid_d1_c <= bvalid_c; //external bvalid signal generation if (bvalid_d1_c == 1'b1) begin bvalid_r <= #FLOP_DELAY 1'b1 ; end else if (bvalid_count_r <= 1 && S_AXI_BREADY == 1'b1) begin bvalid_r <= #FLOP_DELAY 0 ; end end end end endgenerate //------------------------------------------------------------------------- // Generation of bvalid when BID is not used //------------------------------------------------------------------------- generate if(C_HAS_AXI_ID == 0) begin:gaxi_bvalid_noid_r always @(posedge S_ACLK or S_ARESETN) begin if (S_ARESETN == 1'b1) begin bvalid_r <= 0; end else begin //external bvalid signal generation if (bvalid_c == 1'b1) begin bvalid_r <= #FLOP_DELAY 1'b1 ; end else if (bvalid_count_r <= 1 && S_AXI_BREADY == 1'b1) begin bvalid_r <= #FLOP_DELAY 0 ; end end end end endgenerate //------------------------------------------------------------------------- // Generation of Bready timeout //------------------------------------------------------------------------- always @(bvalid_count_r) begin // bready_timeout_c generation if(bvalid_count_r == C_AXI_OS_WR-1) begin bready_timeout_c <= 1'b1; end else begin bready_timeout_c <= 1'b0; end end //------------------------------------------------------------------------- // Generation of BID //------------------------------------------------------------------------- generate if(C_HAS_AXI_ID == 1) begin:gaxi_bid_gen always @(posedge S_ACLK or S_ARESETN) begin if (S_ARESETN == 1'b1) begin bvalid_wr_cnt_r <= 0; bvalid_rd_cnt_r <= 0; end else begin // STORE AWID IN AN ARRAY if(bvalid_c == 1'b1) begin bvalid_wr_cnt_r <= bvalid_wr_cnt_r + 1; end // generate BID FROM AWID ARRAY bvalid_rd_cnt_r <= #FLOP_DELAY bvalid_rd_cnt_c ; S_AXI_BID <= axi_bid_array[bvalid_rd_cnt_c]; end end assign bvalid_rd_cnt_c = (bvalid_r == 1'b1 && S_AXI_BREADY == 1'b1)?bvalid_rd_cnt_r+1:bvalid_rd_cnt_r; //------------------------------------------------------------------------- // Storing AWID for generation of BID //------------------------------------------------------------------------- always @(posedge S_ACLK or S_ARESETN) begin if(S_ARESETN == 1'b1) begin axi_bid_array[0] = 0; axi_bid_array[1] = 0; axi_bid_array[2] = 0; axi_bid_array[3] = 0; end else if(aw_ready_r == 1'b1 && S_AXI_AWVALID == 1'b1) begin axi_bid_array[bvalid_wr_cnt_r] <= S_AXI_AWID; end end end endgenerate assign S_AXI_BVALID = bvalid_r; assign S_AXI_AWREADY = aw_ready_r; endmodule module blk_mem_axi_read_wrapper_beh_v8_2 # ( //// AXI Interface related parameters start here parameter C_INTERFACE_TYPE = 0, parameter C_AXI_TYPE = 0, parameter C_AXI_SLAVE_TYPE = 0, parameter C_MEMORY_TYPE = 0, parameter C_WRITE_WIDTH_A = 4, parameter C_WRITE_DEPTH_A = 32, parameter C_ADDRA_WIDTH = 12, parameter C_AXI_PIPELINE_STAGES = 0, parameter C_AXI_ARADDR_WIDTH = 12, parameter C_HAS_AXI_ID = 0, parameter C_AXI_ID_WIDTH = 4, parameter C_ADDRB_WIDTH = 12 ) ( //// AXI Global Signals input S_ACLK, input S_ARESETN, //// AXI Full/Lite Slave Read (Read side) input [C_AXI_ARADDR_WIDTH-1:0] S_AXI_ARADDR, input [7:0] S_AXI_ARLEN, input [2:0] S_AXI_ARSIZE, input [1:0] S_AXI_ARBURST, input S_AXI_ARVALID, output S_AXI_ARREADY, output S_AXI_RLAST, output S_AXI_RVALID, input S_AXI_RREADY, input [C_AXI_ID_WIDTH-1:0] S_AXI_ARID, output reg [C_AXI_ID_WIDTH-1:0] S_AXI_RID = 0, //// AXI Full/Lite Read Address Signals to BRAM output [C_ADDRB_WIDTH-1:0] S_AXI_ARADDR_OUT, output S_AXI_RD_EN ); localparam FLOP_DELAY = 100; // 100 ps localparam C_RANGE = ((C_WRITE_WIDTH_A == 8)?0: ((C_WRITE_WIDTH_A==16)?1: ((C_WRITE_WIDTH_A==32)?2: ((C_WRITE_WIDTH_A==64)?3: ((C_WRITE_WIDTH_A==128)?4: ((C_WRITE_WIDTH_A==256)?5:0)))))); reg [C_AXI_ID_WIDTH-1:0] ar_id_r=0; wire addr_en_c; wire rd_en_c; wire incr_addr_c; wire single_trans_c; wire dec_alen_c; wire mux_sel_c; wire r_last_c; wire r_last_int_c; wire [C_ADDRB_WIDTH-1 : 0] araddr_out; reg [7:0] arlen_int_r=0; reg [7:0] arlen_cntr=8'h01; reg [1:0] arburst_int_c=0; reg [1:0] arburst_int_r=0; reg [((C_AXI_TYPE == 1 && C_AXI_SLAVE_TYPE == 0)? C_AXI_ARADDR_WIDTH:C_ADDRA_WIDTH)-1:0] araddr_reg =0; integer num_of_bytes_c = 0; integer total_bytes = 0; integer num_of_bytes_r = 0; integer wrap_base_addr_r = 0; integer wrap_boundary_r = 0; reg [7:0] arlen_int_c=0; integer total_bytes_c = 0; integer wrap_base_addr_c = 0; integer wrap_boundary_c = 0; assign dec_alen_c = incr_addr_c | r_last_int_c; read_netlist_v8_2 #(.C_AXI_TYPE (1), .C_ADDRB_WIDTH (C_ADDRB_WIDTH)) axi_read_fsm ( .S_AXI_INCR_ADDR(incr_addr_c), .S_AXI_ADDR_EN(addr_en_c), .S_AXI_SINGLE_TRANS(single_trans_c), .S_AXI_MUX_SEL(mux_sel_c), .S_AXI_R_LAST(r_last_c), .S_AXI_R_LAST_INT(r_last_int_c), //// AXI Global Signals .S_ACLK(S_ACLK), .S_ARESETN(S_ARESETN), //// AXI Full/Lite Slave Read (Read side) .S_AXI_ARLEN(S_AXI_ARLEN), .S_AXI_ARVALID(S_AXI_ARVALID), .S_AXI_ARREADY(S_AXI_ARREADY), .S_AXI_RLAST(S_AXI_RLAST), .S_AXI_RVALID(S_AXI_RVALID), .S_AXI_RREADY(S_AXI_RREADY), //// AXI Full/Lite Read Address Signals to BRAM .S_AXI_RD_EN(rd_en_c) ); always@(*) begin num_of_bytes_c = 2**((C_AXI_TYPE == 1 && C_AXI_SLAVE_TYPE == 0)?S_AXI_ARSIZE:0); total_bytes = (num_of_bytes_r)*(arlen_int_r+1); wrap_base_addr_r = ((araddr_reg)/(total_bytes==0?1:total_bytes))*(total_bytes); wrap_boundary_r = wrap_base_addr_r+total_bytes; //////// combinatorial from interface arlen_int_c = (C_AXI_TYPE == 0?0:S_AXI_ARLEN); total_bytes_c = (num_of_bytes_c)*(arlen_int_c+1); wrap_base_addr_c = ((S_AXI_ARADDR)/(total_bytes_c==0?1:total_bytes_c))*(total_bytes_c); wrap_boundary_c = wrap_base_addr_c+total_bytes_c; arburst_int_c = ((C_AXI_TYPE == 1 && C_AXI_SLAVE_TYPE == 0)?S_AXI_ARBURST:1); end ////------------------------------------------------------------------------- //// BMG address generation ////------------------------------------------------------------------------- always @(posedge S_ACLK or S_ARESETN) begin if (S_ARESETN == 1'b1) begin araddr_reg <= 0; arburst_int_r <= 0; num_of_bytes_r <= 0; end else begin if (incr_addr_c == 1'b1 && addr_en_c == 1'b1 && single_trans_c == 1'b0) begin arburst_int_r <= arburst_int_c; num_of_bytes_r <= num_of_bytes_c; if (arburst_int_c == 2'b10) begin if(S_AXI_ARADDR == (wrap_boundary_c-num_of_bytes_c)) begin araddr_reg <= wrap_base_addr_c; end else begin araddr_reg <= S_AXI_ARADDR + num_of_bytes_c; end end else if (arburst_int_c == 2'b01 || arburst_int_c == 2'b11) begin araddr_reg <= S_AXI_ARADDR + num_of_bytes_c; end end else if (addr_en_c == 1'b1) begin araddr_reg <= S_AXI_ARADDR; num_of_bytes_r <= num_of_bytes_c; arburst_int_r <= arburst_int_c; end else if (incr_addr_c == 1'b1) begin if (arburst_int_r == 2'b10) begin if(araddr_reg == (wrap_boundary_r-num_of_bytes_r)) begin araddr_reg <= wrap_base_addr_r; end else begin araddr_reg <= araddr_reg + num_of_bytes_r; end end else if (arburst_int_r == 2'b01 || arburst_int_r == 2'b11) begin araddr_reg <= araddr_reg + num_of_bytes_r; end end end end assign araddr_out = ((C_AXI_TYPE == 1 && C_AXI_SLAVE_TYPE == 0)?araddr_reg[C_AXI_ARADDR_WIDTH-1:C_RANGE]:araddr_reg); ////----------------------------------------------------------------------- //// Counter to generate r_last_int_c from registered ARLEN - AXI FULL FSM ////----------------------------------------------------------------------- always @(posedge S_ACLK or S_ARESETN) begin if (S_ARESETN == 1'b1) begin arlen_cntr <= 8'h01; arlen_int_r <= 0; end else begin if (addr_en_c == 1'b1 && dec_alen_c == 1'b1 && single_trans_c == 1'b0) begin arlen_int_r <= (C_AXI_TYPE == 0?0:S_AXI_ARLEN) ; arlen_cntr <= S_AXI_ARLEN - 1'b1; end else if (addr_en_c == 1'b1) begin arlen_int_r <= (C_AXI_TYPE == 0?0:S_AXI_ARLEN) ; arlen_cntr <= (C_AXI_TYPE == 0?0:S_AXI_ARLEN) ; end else if (dec_alen_c == 1'b1) begin arlen_cntr <= arlen_cntr - 1'b1 ; end else begin arlen_cntr <= arlen_cntr; end end end assign r_last_int_c = (arlen_cntr == 0 && S_AXI_RREADY == 1'b1)?1'b1:1'b0; ////------------------------------------------------------------------------ //// AXI FULL FSM //// Mux Selection of ARADDR //// ARADDR is driven out from the read fsm based on the mux_sel_c //// Based on mux_sel either ARADDR is given out or the latched ARADDR is //// given out to BRAM ////------------------------------------------------------------------------ assign S_AXI_ARADDR_OUT = (mux_sel_c == 1'b0)?((C_AXI_TYPE == 1 && C_AXI_SLAVE_TYPE == 0)?S_AXI_ARADDR[C_AXI_ARADDR_WIDTH-1:C_RANGE]:S_AXI_ARADDR):araddr_out; ////------------------------------------------------------------------------ //// Assign output signals - AXI FULL FSM ////------------------------------------------------------------------------ assign S_AXI_RD_EN = rd_en_c; generate if (C_HAS_AXI_ID == 1) begin:gaxi_bvalid_id_r always @(posedge S_ACLK or S_ARESETN) begin if (S_ARESETN == 1'b1) begin S_AXI_RID <= 0; ar_id_r <= 0; end else begin if (addr_en_c == 1'b1 && rd_en_c == 1'b1) begin S_AXI_RID <= S_AXI_ARID; ar_id_r <= S_AXI_ARID; end else if (addr_en_c == 1'b1 && rd_en_c == 1'b0) begin ar_id_r <= S_AXI_ARID; end else if (rd_en_c == 1'b1) begin S_AXI_RID <= ar_id_r; end end end end endgenerate endmodule module blk_mem_axi_regs_fwd_v8_2 #(parameter C_DATA_WIDTH = 8 )( input ACLK, input ARESET, input S_VALID, output S_READY, input [C_DATA_WIDTH-1:0] S_PAYLOAD_DATA, output M_VALID, input M_READY, output reg [C_DATA_WIDTH-1:0] M_PAYLOAD_DATA ); reg [C_DATA_WIDTH-1:0] STORAGE_DATA; wire S_READY_I; reg M_VALID_I; reg [1:0] ARESET_D; //assign local signal to its output signal assign S_READY = S_READY_I; assign M_VALID = M_VALID_I; always @(posedge ACLK) begin ARESET_D <= {ARESET_D[0], ARESET}; end //Save payload data whenever we have a transaction on the slave side always @(posedge ACLK or ARESET) begin if (ARESET == 1'b1) begin STORAGE_DATA <= 0; end else begin if(S_VALID == 1'b1 && S_READY_I == 1'b1 ) begin STORAGE_DATA <= S_PAYLOAD_DATA; end end end always @(posedge ACLK) begin M_PAYLOAD_DATA = STORAGE_DATA; end //M_Valid set to high when we have a completed transfer on slave side //Is removed on a M_READY except if we have a new transfer on the slave side always @(posedge ACLK or ARESET_D) begin if (ARESET_D != 2'b00) begin M_VALID_I <= 1'b0; end else begin if (S_VALID == 1'b1) begin //Always set M_VALID_I when slave side is valid M_VALID_I <= 1'b1; end else if (M_READY == 1'b1 ) begin //Clear (or keep) when no slave side is valid but master side is ready M_VALID_I <= 1'b0; end end end //Slave Ready is either when Master side drives M_READY or we have space in our storage data assign S_READY_I = (M_READY || (!M_VALID_I)) && !(|(ARESET_D)); endmodule //***************************************************************************** // Output Register Stage module // // This module builds the output register stages of the memory. This module is // instantiated in the main memory module (BLK_MEM_GEN_v8_2) which is // declared/implemented further down in this file. //***************************************************************************** module BLK_MEM_GEN_v8_2_output_stage #(parameter C_FAMILY = "virtex7", parameter C_XDEVICEFAMILY = "virtex7", parameter C_RST_TYPE = "SYNC", parameter C_HAS_RST = 0, parameter C_RSTRAM = 0, parameter C_RST_PRIORITY = "CE", parameter C_INIT_VAL = "0", parameter C_HAS_EN = 0, parameter C_HAS_REGCE = 0, parameter C_DATA_WIDTH = 32, parameter C_ADDRB_WIDTH = 10, parameter C_HAS_MEM_OUTPUT_REGS = 0, parameter C_USE_SOFTECC = 0, parameter C_USE_ECC = 0, parameter NUM_STAGES = 1, parameter C_EN_ECC_PIPE = 0, parameter FLOP_DELAY = 100 ) ( input CLK, input RST, input EN, input REGCE, input [C_DATA_WIDTH-1:0] DIN_I, output reg [C_DATA_WIDTH-1:0] DOUT, input SBITERR_IN_I, input DBITERR_IN_I, output reg SBITERR, output reg DBITERR, input [C_ADDRB_WIDTH-1:0] RDADDRECC_IN_I, input ECCPIPECE, output reg [C_ADDRB_WIDTH-1:0] RDADDRECC ); //****************************** // Port and Generic Definitions //****************************** ////////////////////////////////////////////////////////////////////////// // Generic Definitions ////////////////////////////////////////////////////////////////////////// // C_FAMILY,C_XDEVICEFAMILY: Designates architecture targeted. The following // options are available - "spartan3", "spartan6", // "virtex4", "virtex5", "virtex6" and "virtex6l". // C_RST_TYPE : Type of reset - Synchronous or Asynchronous // C_HAS_RST : Determines the presence of the RST port // C_RSTRAM : Determines if special reset behavior is used // C_RST_PRIORITY : Determines the priority between CE and SR // C_INIT_VAL : Initialization value // C_HAS_EN : Determines the presence of the EN port // C_HAS_REGCE : Determines the presence of the REGCE port // C_DATA_WIDTH : Memory write/read width // C_ADDRB_WIDTH : Width of the ADDRB input port // C_HAS_MEM_OUTPUT_REGS : Designates the use of a register at the output // of the RAM primitive // C_USE_SOFTECC : Determines if the Soft ECC feature is used or // not. Only applicable Spartan-6 // C_USE_ECC : Determines if the ECC feature is used or // not. Only applicable for V5 and V6 // NUM_STAGES : Determines the number of output stages // FLOP_DELAY : Constant delay for register assignments ////////////////////////////////////////////////////////////////////////// // Port Definitions ////////////////////////////////////////////////////////////////////////// // CLK : Clock to synchronize all read and write operations // RST : Reset input to reset memory outputs to a user-defined // reset state // EN : Enable all read and write operations // REGCE : Register Clock Enable to control each pipeline output // register stages // DIN : Data input to the Output stage. // DOUT : Final Data output // SBITERR_IN : SBITERR input signal to the Output stage. // SBITERR : Final SBITERR Output signal. // DBITERR_IN : DBITERR input signal to the Output stage. // DBITERR : Final DBITERR Output signal. // RDADDRECC_IN : RDADDRECC input signal to the Output stage. // RDADDRECC : Final RDADDRECC Output signal. ////////////////////////////////////////////////////////////////////////// // Fix for CR-509792 localparam REG_STAGES = (NUM_STAGES < 2) ? 1 : NUM_STAGES-1; // Declare the pipeline registers // (includes mem output reg, mux pipeline stages, and mux output reg) reg [C_DATA_WIDTH*REG_STAGES-1:0] out_regs; reg [C_ADDRB_WIDTH*REG_STAGES-1:0] rdaddrecc_regs; reg [REG_STAGES-1:0] sbiterr_regs; reg [REG_STAGES-1:0] dbiterr_regs; reg [C_DATA_WIDTH*8-1:0] init_str = C_INIT_VAL; reg [C_DATA_WIDTH-1:0] init_val ; //********************************************* // Wire off optional inputs based on parameters //********************************************* wire en_i; wire regce_i; wire rst_i; // Internal signals reg [C_DATA_WIDTH-1:0] DIN; reg [C_ADDRB_WIDTH-1:0] RDADDRECC_IN; reg SBITERR_IN; reg DBITERR_IN; // Internal enable for output registers is tied to user EN or '1' depending // on parameters assign en_i = (C_HAS_EN==0 || EN); // Internal register enable for output registers is tied to user REGCE, EN or // '1' depending on parameters // For V4 ECC, REGCE is always 1 // Virtex-4 ECC Not Yet Supported assign regce_i = ((C_HAS_REGCE==1) && REGCE) || ((C_HAS_REGCE==0) && (C_HAS_EN==0 || EN)); //Internal SRR is tied to user RST or '0' depending on parameters assign rst_i = (C_HAS_RST==1) && RST; //**************************************************** // Power on: load up the output registers and latches //**************************************************** initial begin if (!($sscanf(init_str, "%h", init_val))) begin init_val = 0; end DOUT = init_val; RDADDRECC = 0; SBITERR = 1'b0; DBITERR = 1'b0; DIN = {(C_DATA_WIDTH){1'b0}}; RDADDRECC_IN = 0; SBITERR_IN = 0; DBITERR_IN = 0; // This will be one wider than need, but 0 is an error out_regs = {(REG_STAGES+1){init_val}}; rdaddrecc_regs = 0; sbiterr_regs = {(REG_STAGES+1){1'b0}}; dbiterr_regs = {(REG_STAGES+1){1'b0}}; end //*********************************************** // NUM_STAGES = 0 (No output registers. RAM only) //*********************************************** generate if (NUM_STAGES == 0) begin : zero_stages always @* begin DOUT = DIN; RDADDRECC = RDADDRECC_IN; SBITERR = SBITERR_IN; DBITERR = DBITERR_IN; end end endgenerate generate if (C_EN_ECC_PIPE == 0) begin : no_ecc_pipe_reg always @* begin DIN = DIN_I; SBITERR_IN = SBITERR_IN_I; DBITERR_IN = DBITERR_IN_I; RDADDRECC_IN = RDADDRECC_IN_I; end end endgenerate generate if (C_EN_ECC_PIPE == 1) begin : with_ecc_pipe_reg always @(posedge CLK) begin if(ECCPIPECE == 1) begin DIN <= #FLOP_DELAY DIN_I; SBITERR_IN <= #FLOP_DELAY SBITERR_IN_I; DBITERR_IN <= #FLOP_DELAY DBITERR_IN_I; RDADDRECC_IN <= #FLOP_DELAY RDADDRECC_IN_I; end end end endgenerate //*********************************************** // NUM_STAGES = 1 // (Mem Output Reg only or Mux Output Reg only) //*********************************************** // Possible valid combinations: // Note: C_HAS_MUX_OUTPUT_REGS_*=0 when (C_RSTRAM_*=1) // +-----------------------------------------+ // | C_RSTRAM_* | Reset Behavior | // +----------------+------------------------+ // | 0 | Normal Behavior | // +----------------+------------------------+ // | 1 | Special Behavior | // +----------------+------------------------+ // // Normal = REGCE gates reset, as in the case of all families except S3ADSP. // Special = EN gates reset, as in the case of S3ADSP. generate if (NUM_STAGES == 1 && (C_RSTRAM == 0 || (C_RSTRAM == 1 && (C_XDEVICEFAMILY != "spartan3adsp" && C_XDEVICEFAMILY != "aspartan3adsp" )) || C_HAS_MEM_OUTPUT_REGS == 0 || C_HAS_RST == 0)) begin : one_stages_norm always @(posedge CLK) begin if (C_RST_PRIORITY == "CE") begin //REGCE has priority if (regce_i && rst_i) begin DOUT <= #FLOP_DELAY init_val; RDADDRECC <= #FLOP_DELAY 0; SBITERR <= #FLOP_DELAY 1'b0; DBITERR <= #FLOP_DELAY 1'b0; end else if (regce_i) begin DOUT <= #FLOP_DELAY DIN; RDADDRECC <= #FLOP_DELAY RDADDRECC_IN; SBITERR <= #FLOP_DELAY SBITERR_IN; DBITERR <= #FLOP_DELAY DBITERR_IN; end //Output signal assignments end else begin //RST has priority if (rst_i) begin DOUT <= #FLOP_DELAY init_val; RDADDRECC <= #FLOP_DELAY RDADDRECC_IN; SBITERR <= #FLOP_DELAY 1'b0; DBITERR <= #FLOP_DELAY 1'b0; end else if (regce_i) begin DOUT <= #FLOP_DELAY DIN; RDADDRECC <= #FLOP_DELAY RDADDRECC_IN; SBITERR <= #FLOP_DELAY SBITERR_IN; DBITERR <= #FLOP_DELAY DBITERR_IN; end //Output signal assignments end //end Priority conditions end //end RST Type conditions end //end one_stages_norm generate statement endgenerate // Special Reset Behavior for S3ADSP generate if (NUM_STAGES == 1 && C_RSTRAM == 1 && (C_XDEVICEFAMILY =="spartan3adsp" || C_XDEVICEFAMILY =="aspartan3adsp")) begin : one_stage_splbhv always @(posedge CLK) begin if (en_i && rst_i) begin DOUT <= #FLOP_DELAY init_val; end else if (regce_i && !rst_i) begin DOUT <= #FLOP_DELAY DIN; end //Output signal assignments end //end CLK end //end one_stage_splbhv generate statement endgenerate //************************************************************ // NUM_STAGES > 1 // Mem Output Reg + Mux Output Reg // or // Mem Output Reg + Mux Pipeline Stages (>0) + Mux Output Reg // or // Mux Pipeline Stages (>0) + Mux Output Reg //************************************************************* generate if (NUM_STAGES > 1) begin : multi_stage //Asynchronous Reset always @(posedge CLK) begin if (C_RST_PRIORITY == "CE") begin //REGCE has priority if (regce_i && rst_i) begin DOUT <= #FLOP_DELAY init_val; RDADDRECC <= #FLOP_DELAY 0; SBITERR <= #FLOP_DELAY 1'b0; DBITERR <= #FLOP_DELAY 1'b0; end else if (regce_i) begin DOUT <= #FLOP_DELAY out_regs[C_DATA_WIDTH*(NUM_STAGES-2)+:C_DATA_WIDTH]; RDADDRECC <= #FLOP_DELAY rdaddrecc_regs[C_ADDRB_WIDTH*(NUM_STAGES-2)+:C_ADDRB_WIDTH]; SBITERR <= #FLOP_DELAY sbiterr_regs[NUM_STAGES-2]; DBITERR <= #FLOP_DELAY dbiterr_regs[NUM_STAGES-2]; end //Output signal assignments end else begin //RST has priority if (rst_i) begin DOUT <= #FLOP_DELAY init_val; RDADDRECC <= #FLOP_DELAY 0; SBITERR <= #FLOP_DELAY 1'b0; DBITERR <= #FLOP_DELAY 1'b0; end else if (regce_i) begin DOUT <= #FLOP_DELAY out_regs[C_DATA_WIDTH*(NUM_STAGES-2)+:C_DATA_WIDTH]; RDADDRECC <= #FLOP_DELAY rdaddrecc_regs[C_ADDRB_WIDTH*(NUM_STAGES-2)+:C_ADDRB_WIDTH]; SBITERR <= #FLOP_DELAY sbiterr_regs[NUM_STAGES-2]; DBITERR <= #FLOP_DELAY dbiterr_regs[NUM_STAGES-2]; end //Output signal assignments end //end Priority conditions // Shift the data through the output stages if (en_i) begin out_regs <= #FLOP_DELAY (out_regs << C_DATA_WIDTH) | DIN; rdaddrecc_regs <= #FLOP_DELAY (rdaddrecc_regs << C_ADDRB_WIDTH) | RDADDRECC_IN; sbiterr_regs <= #FLOP_DELAY (sbiterr_regs << 1) | SBITERR_IN; dbiterr_regs <= #FLOP_DELAY (dbiterr_regs << 1) | DBITERR_IN; end end //end CLK end //end multi_stage generate statement endgenerate endmodule module BLK_MEM_GEN_v8_2_softecc_output_reg_stage #(parameter C_DATA_WIDTH = 32, parameter C_ADDRB_WIDTH = 10, parameter C_HAS_SOFTECC_OUTPUT_REGS_B= 0, parameter C_USE_SOFTECC = 0, parameter FLOP_DELAY = 100 ) ( input CLK, input [C_DATA_WIDTH-1:0] DIN, output reg [C_DATA_WIDTH-1:0] DOUT, input SBITERR_IN, input DBITERR_IN, output reg SBITERR, output reg DBITERR, input [C_ADDRB_WIDTH-1:0] RDADDRECC_IN, output reg [C_ADDRB_WIDTH-1:0] RDADDRECC ); //****************************** // Port and Generic Definitions //****************************** ////////////////////////////////////////////////////////////////////////// // Generic Definitions ////////////////////////////////////////////////////////////////////////// // C_DATA_WIDTH : Memory write/read width // C_ADDRB_WIDTH : Width of the ADDRB input port // C_HAS_SOFTECC_OUTPUT_REGS_B : Designates the use of a register at the output // of the RAM primitive // C_USE_SOFTECC : Determines if the Soft ECC feature is used or // not. Only applicable Spartan-6 // FLOP_DELAY : Constant delay for register assignments ////////////////////////////////////////////////////////////////////////// // Port Definitions ////////////////////////////////////////////////////////////////////////// // CLK : Clock to synchronize all read and write operations // DIN : Data input to the Output stage. // DOUT : Final Data output // SBITERR_IN : SBITERR input signal to the Output stage. // SBITERR : Final SBITERR Output signal. // DBITERR_IN : DBITERR input signal to the Output stage. // DBITERR : Final DBITERR Output signal. // RDADDRECC_IN : RDADDRECC input signal to the Output stage. // RDADDRECC : Final RDADDRECC Output signal. ////////////////////////////////////////////////////////////////////////// reg [C_DATA_WIDTH-1:0] dout_i = 0; reg sbiterr_i = 0; reg dbiterr_i = 0; reg [C_ADDRB_WIDTH-1:0] rdaddrecc_i = 0; //*********************************************** // NO OUTPUT REGISTERS. //*********************************************** generate if (C_HAS_SOFTECC_OUTPUT_REGS_B==0) begin : no_output_stage always @* begin DOUT = DIN; RDADDRECC = RDADDRECC_IN; SBITERR = SBITERR_IN; DBITERR = DBITERR_IN; end end endgenerate //*********************************************** // WITH OUTPUT REGISTERS. //*********************************************** generate if (C_HAS_SOFTECC_OUTPUT_REGS_B==1) begin : has_output_stage always @(posedge CLK) begin dout_i <= #FLOP_DELAY DIN; rdaddrecc_i <= #FLOP_DELAY RDADDRECC_IN; sbiterr_i <= #FLOP_DELAY SBITERR_IN; dbiterr_i <= #FLOP_DELAY DBITERR_IN; end always @* begin DOUT = dout_i; RDADDRECC = rdaddrecc_i; SBITERR = sbiterr_i; DBITERR = dbiterr_i; end //end always end //end in_or_out_stage generate statement endgenerate endmodule //***************************************************************************** // Main Memory module // // This module is the top-level behavioral model and this implements the RAM //***************************************************************************** module BLK_MEM_GEN_v8_2_mem_module #(parameter C_CORENAME = "blk_mem_gen_v8_2", parameter C_FAMILY = "virtex7", parameter C_XDEVICEFAMILY = "virtex7", parameter C_MEM_TYPE = 2, parameter C_BYTE_SIZE = 9, parameter C_USE_BRAM_BLOCK = 0, parameter C_ALGORITHM = 1, parameter C_PRIM_TYPE = 3, parameter C_LOAD_INIT_FILE = 0, parameter C_INIT_FILE_NAME = "", parameter C_INIT_FILE = "", parameter C_USE_DEFAULT_DATA = 0, parameter C_DEFAULT_DATA = "0", parameter C_RST_TYPE = "SYNC", parameter C_HAS_RSTA = 0, parameter C_RST_PRIORITY_A = "CE", parameter C_RSTRAM_A = 0, parameter C_INITA_VAL = "0", parameter C_HAS_ENA = 1, parameter C_HAS_REGCEA = 0, parameter C_USE_BYTE_WEA = 0, parameter C_WEA_WIDTH = 1, parameter C_WRITE_MODE_A = "WRITE_FIRST", parameter C_WRITE_WIDTH_A = 32, parameter C_READ_WIDTH_A = 32, parameter C_WRITE_DEPTH_A = 64, parameter C_READ_DEPTH_A = 64, parameter C_ADDRA_WIDTH = 5, parameter C_HAS_RSTB = 0, parameter C_RST_PRIORITY_B = "CE", parameter C_RSTRAM_B = 0, parameter C_INITB_VAL = "", parameter C_HAS_ENB = 1, parameter C_HAS_REGCEB = 0, parameter C_USE_BYTE_WEB = 0, parameter C_WEB_WIDTH = 1, parameter C_WRITE_MODE_B = "WRITE_FIRST", parameter C_WRITE_WIDTH_B = 32, parameter C_READ_WIDTH_B = 32, parameter C_WRITE_DEPTH_B = 64, parameter C_READ_DEPTH_B = 64, parameter C_ADDRB_WIDTH = 5, parameter C_HAS_MEM_OUTPUT_REGS_A = 0, parameter C_HAS_MEM_OUTPUT_REGS_B = 0, parameter C_HAS_MUX_OUTPUT_REGS_A = 0, parameter C_HAS_MUX_OUTPUT_REGS_B = 0, parameter C_HAS_SOFTECC_INPUT_REGS_A = 0, parameter C_HAS_SOFTECC_OUTPUT_REGS_B= 0, parameter C_MUX_PIPELINE_STAGES = 0, parameter C_USE_SOFTECC = 0, parameter C_USE_ECC = 0, parameter C_HAS_INJECTERR = 0, parameter C_SIM_COLLISION_CHECK = "NONE", parameter C_COMMON_CLK = 1, parameter FLOP_DELAY = 100, parameter C_DISABLE_WARN_BHV_COLL = 0, parameter C_EN_ECC_PIPE = 0, parameter C_DISABLE_WARN_BHV_RANGE = 0 ) (input CLKA, input RSTA, input ENA, input REGCEA, input [C_WEA_WIDTH-1:0] WEA, input [C_ADDRA_WIDTH-1:0] ADDRA, input [C_WRITE_WIDTH_A-1:0] DINA, output [C_READ_WIDTH_A-1:0] DOUTA, input CLKB, input RSTB, input ENB, input REGCEB, input [C_WEB_WIDTH-1:0] WEB, input [C_ADDRB_WIDTH-1:0] ADDRB, input [C_WRITE_WIDTH_B-1:0] DINB, output [C_READ_WIDTH_B-1:0] DOUTB, input INJECTSBITERR, input INJECTDBITERR, input ECCPIPECE, input SLEEP, output SBITERR, output DBITERR, output [C_ADDRB_WIDTH-1:0] RDADDRECC ); //****************************** // Port and Generic Definitions //****************************** ////////////////////////////////////////////////////////////////////////// // Generic Definitions ////////////////////////////////////////////////////////////////////////// // C_CORENAME : Instance name of the Block Memory Generator core // C_FAMILY,C_XDEVICEFAMILY: Designates architecture targeted. The following // options are available - "spartan3", "spartan6", // "virtex4", "virtex5", "virtex6" and "virtex6l". // C_MEM_TYPE : Designates memory type. // It can be // 0 - Single Port Memory // 1 - Simple Dual Port Memory // 2 - True Dual Port Memory // 3 - Single Port Read Only Memory // 4 - Dual Port Read Only Memory // C_BYTE_SIZE : Size of a byte (8 or 9 bits) // C_ALGORITHM : Designates the algorithm method used // for constructing the memory. // It can be Fixed_Primitives, Minimum_Area or // Low_Power // C_PRIM_TYPE : Designates the user selected primitive used to // construct the memory. // // C_LOAD_INIT_FILE : Designates the use of an initialization file to // initialize memory contents. // C_INIT_FILE_NAME : Memory initialization file name. // C_USE_DEFAULT_DATA : Designates whether to fill remaining // initialization space with default data // C_DEFAULT_DATA : Default value of all memory locations // not initialized by the memory // initialization file. // C_RST_TYPE : Type of reset - Synchronous or Asynchronous // C_HAS_RSTA : Determines the presence of the RSTA port // C_RST_PRIORITY_A : Determines the priority between CE and SR for // Port A. // C_RSTRAM_A : Determines if special reset behavior is used for // Port A // C_INITA_VAL : The initialization value for Port A // C_HAS_ENA : Determines the presence of the ENA port // C_HAS_REGCEA : Determines the presence of the REGCEA port // C_USE_BYTE_WEA : Determines if the Byte Write is used or not. // C_WEA_WIDTH : The width of the WEA port // C_WRITE_MODE_A : Configurable write mode for Port A. It can be // WRITE_FIRST, READ_FIRST or NO_CHANGE. // C_WRITE_WIDTH_A : Memory write width for Port A. // C_READ_WIDTH_A : Memory read width for Port A. // C_WRITE_DEPTH_A : Memory write depth for Port A. // C_READ_DEPTH_A : Memory read depth for Port A. // C_ADDRA_WIDTH : Width of the ADDRA input port // C_HAS_RSTB : Determines the presence of the RSTB port // C_RST_PRIORITY_B : Determines the priority between CE and SR for // Port B. // C_RSTRAM_B : Determines if special reset behavior is used for // Port B // C_INITB_VAL : The initialization value for Port B // C_HAS_ENB : Determines the presence of the ENB port // C_HAS_REGCEB : Determines the presence of the REGCEB port // C_USE_BYTE_WEB : Determines if the Byte Write is used or not. // C_WEB_WIDTH : The width of the WEB port // C_WRITE_MODE_B : Configurable write mode for Port B. It can be // WRITE_FIRST, READ_FIRST or NO_CHANGE. // C_WRITE_WIDTH_B : Memory write width for Port B. // C_READ_WIDTH_B : Memory read width for Port B. // C_WRITE_DEPTH_B : Memory write depth for Port B. // C_READ_DEPTH_B : Memory read depth for Port B. // C_ADDRB_WIDTH : Width of the ADDRB input port // C_HAS_MEM_OUTPUT_REGS_A : Designates the use of a register at the output // of the RAM primitive for Port A. // C_HAS_MEM_OUTPUT_REGS_B : Designates the use of a register at the output // of the RAM primitive for Port B. // C_HAS_MUX_OUTPUT_REGS_A : Designates the use of a register at the output // of the MUX for Port A. // C_HAS_MUX_OUTPUT_REGS_B : Designates the use of a register at the output // of the MUX for Port B. // C_MUX_PIPELINE_STAGES : Designates the number of pipeline stages in // between the muxes. // C_USE_SOFTECC : Determines if the Soft ECC feature is used or // not. Only applicable Spartan-6 // C_USE_ECC : Determines if the ECC feature is used or // not. Only applicable for V5 and V6 // C_HAS_INJECTERR : Determines if the error injection pins // are present or not. If the ECC feature // is not used, this value is defaulted to // 0, else the following are the allowed // values: // 0 : No INJECTSBITERR or INJECTDBITERR pins // 1 : Only INJECTSBITERR pin exists // 2 : Only INJECTDBITERR pin exists // 3 : Both INJECTSBITERR and INJECTDBITERR pins exist // C_SIM_COLLISION_CHECK : Controls the disabling of Unisim model collision // warnings. It can be "ALL", "NONE", // "Warnings_Only" or "Generate_X_Only". // C_COMMON_CLK : Determins if the core has a single CLK input. // C_DISABLE_WARN_BHV_COLL : Controls the Behavioral Model Collision warnings // C_DISABLE_WARN_BHV_RANGE: Controls the Behavioral Model Out of Range // warnings ////////////////////////////////////////////////////////////////////////// // Port Definitions ////////////////////////////////////////////////////////////////////////// // CLKA : Clock to synchronize all read and write operations of Port A. // RSTA : Reset input to reset memory outputs to a user-defined // reset state for Port A. // ENA : Enable all read and write operations of Port A. // REGCEA : Register Clock Enable to control each pipeline output // register stages for Port A. // WEA : Write Enable to enable all write operations of Port A. // ADDRA : Address of Port A. // DINA : Data input of Port A. // DOUTA : Data output of Port A. // CLKB : Clock to synchronize all read and write operations of Port B. // RSTB : Reset input to reset memory outputs to a user-defined // reset state for Port B. // ENB : Enable all read and write operations of Port B. // REGCEB : Register Clock Enable to control each pipeline output // register stages for Port B. // WEB : Write Enable to enable all write operations of Port B. // ADDRB : Address of Port B. // DINB : Data input of Port B. // DOUTB : Data output of Port B. // INJECTSBITERR : Single Bit ECC Error Injection Pin. // INJECTDBITERR : Double Bit ECC Error Injection Pin. // SBITERR : Output signal indicating that a Single Bit ECC Error has been // detected and corrected. // DBITERR : Output signal indicating that a Double Bit ECC Error has been // detected. // RDADDRECC : Read Address Output signal indicating address at which an // ECC error has occurred. ////////////////////////////////////////////////////////////////////////// // Note: C_CORENAME parameter is hard-coded to "blk_mem_gen_v8_2" and it is // only used by this module to print warning messages. It is neither passed // down from blk_mem_gen_v8_2_xst.v nor present in the instantiation template // coregen generates //*************************************************************************** // constants for the core behavior //*************************************************************************** // file handles for logging //-------------------------------------------------- localparam ADDRFILE = 32'h8000_0001; //stdout for addr out of range localparam COLLFILE = 32'h8000_0001; //stdout for coll detection localparam ERRFILE = 32'h8000_0001; //stdout for file I/O errors // other constants //-------------------------------------------------- localparam COLL_DELAY = 100; // 100 ps // locally derived parameters to determine memory shape //----------------------------------------------------- localparam CHKBIT_WIDTH = (C_WRITE_WIDTH_A>57 ? 8 : (C_WRITE_WIDTH_A>26 ? 7 : (C_WRITE_WIDTH_A>11 ? 6 : (C_WRITE_WIDTH_A>4 ? 5 : (C_WRITE_WIDTH_A<5 ? 4 :0))))); localparam MIN_WIDTH_A = (C_WRITE_WIDTH_A < C_READ_WIDTH_A) ? C_WRITE_WIDTH_A : C_READ_WIDTH_A; localparam MIN_WIDTH_B = (C_WRITE_WIDTH_B < C_READ_WIDTH_B) ? C_WRITE_WIDTH_B : C_READ_WIDTH_B; localparam MIN_WIDTH = (MIN_WIDTH_A < MIN_WIDTH_B) ? MIN_WIDTH_A : MIN_WIDTH_B; localparam MAX_DEPTH_A = (C_WRITE_DEPTH_A > C_READ_DEPTH_A) ? C_WRITE_DEPTH_A : C_READ_DEPTH_A; localparam MAX_DEPTH_B = (C_WRITE_DEPTH_B > C_READ_DEPTH_B) ? C_WRITE_DEPTH_B : C_READ_DEPTH_B; localparam MAX_DEPTH = (MAX_DEPTH_A > MAX_DEPTH_B) ? MAX_DEPTH_A : MAX_DEPTH_B; // locally derived parameters to assist memory access //---------------------------------------------------- // Calculate the width ratios of each port with respect to the narrowest // port localparam WRITE_WIDTH_RATIO_A = C_WRITE_WIDTH_A/MIN_WIDTH; localparam READ_WIDTH_RATIO_A = C_READ_WIDTH_A/MIN_WIDTH; localparam WRITE_WIDTH_RATIO_B = C_WRITE_WIDTH_B/MIN_WIDTH; localparam READ_WIDTH_RATIO_B = C_READ_WIDTH_B/MIN_WIDTH; // To modify the LSBs of the 'wider' data to the actual // address value //---------------------------------------------------- localparam WRITE_ADDR_A_DIV = C_WRITE_WIDTH_A/MIN_WIDTH_A; localparam READ_ADDR_A_DIV = C_READ_WIDTH_A/MIN_WIDTH_A; localparam WRITE_ADDR_B_DIV = C_WRITE_WIDTH_B/MIN_WIDTH_B; localparam READ_ADDR_B_DIV = C_READ_WIDTH_B/MIN_WIDTH_B; // If byte writes aren't being used, make sure BYTE_SIZE is not // wider than the memory elements to avoid compilation warnings localparam BYTE_SIZE = (C_BYTE_SIZE < MIN_WIDTH) ? C_BYTE_SIZE : MIN_WIDTH; // The memory reg [MIN_WIDTH-1:0] memory [0:MAX_DEPTH-1]; reg [MIN_WIDTH-1:0] temp_mem_array [0:MAX_DEPTH-1]; reg [C_WRITE_WIDTH_A+CHKBIT_WIDTH-1:0] doublebit_error = 3; // ECC error arrays reg sbiterr_arr [0:MAX_DEPTH-1]; reg dbiterr_arr [0:MAX_DEPTH-1]; reg softecc_sbiterr_arr [0:MAX_DEPTH-1]; reg softecc_dbiterr_arr [0:MAX_DEPTH-1]; // Memory output 'latches' reg [C_READ_WIDTH_A-1:0] memory_out_a; reg [C_READ_WIDTH_B-1:0] memory_out_b; // ECC error inputs and outputs from output_stage module: reg sbiterr_in; wire sbiterr_sdp; reg dbiterr_in; wire dbiterr_sdp; wire [C_READ_WIDTH_B-1:0] dout_i; wire dbiterr_i; wire sbiterr_i; wire [C_ADDRB_WIDTH-1:0] rdaddrecc_i; reg [C_ADDRB_WIDTH-1:0] rdaddrecc_in; wire [C_ADDRB_WIDTH-1:0] rdaddrecc_sdp; // Reset values reg [C_READ_WIDTH_A-1:0] inita_val; reg [C_READ_WIDTH_B-1:0] initb_val; // Collision detect reg is_collision; reg is_collision_a, is_collision_delay_a; reg is_collision_b, is_collision_delay_b; // Temporary variables for initialization //--------------------------------------- integer status; integer initfile; integer meminitfile; // data input buffer reg [C_WRITE_WIDTH_A-1:0] mif_data; reg [C_WRITE_WIDTH_A-1:0] mem_data; // string values in hex reg [C_READ_WIDTH_A*8-1:0] inita_str = C_INITA_VAL; reg [C_READ_WIDTH_B*8-1:0] initb_str = C_INITB_VAL; reg [C_WRITE_WIDTH_A*8-1:0] default_data_str = C_DEFAULT_DATA; // initialization filename reg [1023*8-1:0] init_file_str = C_INIT_FILE_NAME; reg [1023*8-1:0] mem_init_file_str = C_INIT_FILE; //Constants used to calculate the effective address widths for each of the //four ports. integer cnt = 1; integer write_addr_a_width, read_addr_a_width; integer write_addr_b_width, read_addr_b_width; localparam C_FAMILY_LOCALPARAM = (C_FAMILY=="virtexu"?"virtex7":(C_FAMILY=="kintexu" ? "virtex7":(C_FAMILY=="virtex7" ? "virtex7" : (C_FAMILY=="virtex7l" ? "virtex7" : (C_FAMILY=="qvirtex7" ? "virtex7" : (C_FAMILY=="qvirtex7l" ? "virtex7" : (C_FAMILY=="kintex7" ? "virtex7" : (C_FAMILY=="kintex7l" ? "virtex7" : (C_FAMILY=="qkintex7" ? "virtex7" : (C_FAMILY=="qkintex7l" ? "virtex7" : (C_FAMILY=="artix7" ? "virtex7" : (C_FAMILY=="artix7l" ? "virtex7" : (C_FAMILY=="qartix7" ? "virtex7" : (C_FAMILY=="qartix7l" ? "virtex7" : (C_FAMILY=="aartix7" ? "virtex7" : (C_FAMILY=="zynq" ? "virtex7" : (C_FAMILY=="azynq" ? "virtex7" : (C_FAMILY=="qzynq" ? "virtex7" : C_FAMILY)))))))))))))))))); // Internal configuration parameters //--------------------------------------------- localparam SINGLE_PORT = (C_MEM_TYPE==0 || C_MEM_TYPE==3); localparam IS_ROM = (C_MEM_TYPE==3 || C_MEM_TYPE==4); localparam HAS_A_WRITE = (!IS_ROM); localparam HAS_B_WRITE = (C_MEM_TYPE==2); localparam HAS_A_READ = (C_MEM_TYPE!=1); localparam HAS_B_READ = (!SINGLE_PORT); localparam HAS_B_PORT = (HAS_B_READ || HAS_B_WRITE); // Calculate the mux pipeline register stages for Port A and Port B //------------------------------------------------------------------ localparam MUX_PIPELINE_STAGES_A = (C_HAS_MUX_OUTPUT_REGS_A) ? C_MUX_PIPELINE_STAGES : 0; localparam MUX_PIPELINE_STAGES_B = (C_HAS_MUX_OUTPUT_REGS_B) ? C_MUX_PIPELINE_STAGES : 0; // Calculate total number of register stages in the core // ----------------------------------------------------- localparam NUM_OUTPUT_STAGES_A = (C_HAS_MEM_OUTPUT_REGS_A+MUX_PIPELINE_STAGES_A+C_HAS_MUX_OUTPUT_REGS_A); localparam NUM_OUTPUT_STAGES_B = (C_HAS_MEM_OUTPUT_REGS_B+MUX_PIPELINE_STAGES_B+C_HAS_MUX_OUTPUT_REGS_B); wire ena_i; wire enb_i; wire reseta_i; wire resetb_i; wire [C_WEA_WIDTH-1:0] wea_i; wire [C_WEB_WIDTH-1:0] web_i; wire rea_i; wire reb_i; wire rsta_outp_stage; wire rstb_outp_stage; // ECC SBITERR/DBITERR Outputs // The ECC Behavior is modeled by the behavioral models only for Virtex-6. // For Virtex-5, these outputs will be tied to 0. assign SBITERR = ((C_MEM_TYPE == 1 && C_USE_ECC == 1) || C_USE_SOFTECC == 1)?sbiterr_sdp:0; assign DBITERR = ((C_MEM_TYPE == 1 && C_USE_ECC == 1) || C_USE_SOFTECC == 1)?dbiterr_sdp:0; assign RDADDRECC = (((C_FAMILY_LOCALPARAM == "virtex7") && C_MEM_TYPE == 1 && C_USE_ECC == 1) || C_USE_SOFTECC == 1)?rdaddrecc_sdp:0; // This effectively wires off optional inputs assign ena_i = (C_HAS_ENA==0) || ENA; assign enb_i = ((C_HAS_ENB==0) || ENB) && HAS_B_PORT; assign wea_i = (HAS_A_WRITE && ena_i) ? WEA : 'b0; assign web_i = (HAS_B_WRITE && enb_i) ? WEB : 'b0; assign rea_i = (HAS_A_READ) ? ena_i : 'b0; assign reb_i = (HAS_B_READ) ? enb_i : 'b0; // These signals reset the memory latches assign reseta_i = ((C_HAS_RSTA==1 && RSTA && NUM_OUTPUT_STAGES_A==0) || (C_HAS_RSTA==1 && RSTA && C_RSTRAM_A==1)); assign resetb_i = ((C_HAS_RSTB==1 && RSTB && NUM_OUTPUT_STAGES_B==0) || (C_HAS_RSTB==1 && RSTB && C_RSTRAM_B==1)); // Tasks to access the memory //--------------------------- //************** // write_a //************** task write_a (input reg [C_ADDRA_WIDTH-1:0] addr, input reg [C_WEA_WIDTH-1:0] byte_en, input reg [C_WRITE_WIDTH_A-1:0] data, input inj_sbiterr, input inj_dbiterr); reg [C_WRITE_WIDTH_A-1:0] current_contents; reg [C_ADDRA_WIDTH-1:0] address; integer i; begin // Shift the address by the ratio address = (addr/WRITE_ADDR_A_DIV); if (address >= C_WRITE_DEPTH_A) begin if (!C_DISABLE_WARN_BHV_RANGE) begin $fdisplay(ADDRFILE, "%0s WARNING: Address %0h is outside range for A Write", C_CORENAME, addr); end // valid address end else begin // Combine w/ byte writes if (C_USE_BYTE_WEA) begin // Get the current memory contents if (WRITE_WIDTH_RATIO_A == 1) begin // Workaround for IUS 5.5 part-select issue current_contents = memory[address]; end else begin for (i = 0; i < WRITE_WIDTH_RATIO_A; i = i + 1) begin current_contents[MIN_WIDTH*i+:MIN_WIDTH] = memory[address*WRITE_WIDTH_RATIO_A + i]; end end // Apply incoming bytes if (C_WEA_WIDTH == 1) begin // Workaround for IUS 5.5 part-select issue if (byte_en[0]) begin current_contents = data; end end else begin for (i = 0; i < C_WEA_WIDTH; i = i + 1) begin if (byte_en[i]) begin current_contents[BYTE_SIZE*i+:BYTE_SIZE] = data[BYTE_SIZE*i+:BYTE_SIZE]; end end end // No byte-writes, overwrite the whole word end else begin current_contents = data; end // Insert double bit errors: if (C_USE_ECC == 1) begin if ((C_HAS_INJECTERR == 2 || C_HAS_INJECTERR == 3) && inj_dbiterr == 1'b1) begin current_contents[0] = !(current_contents[0]); current_contents[1] = !(current_contents[1]); end end // Insert softecc double bit errors: if (C_USE_SOFTECC == 1) begin if ((C_HAS_INJECTERR == 2 || C_HAS_INJECTERR == 3) && inj_dbiterr == 1'b1) begin doublebit_error[C_WRITE_WIDTH_A+CHKBIT_WIDTH-1:2] = doublebit_error[C_WRITE_WIDTH_A+CHKBIT_WIDTH-3:0]; doublebit_error[0] = doublebit_error[C_WRITE_WIDTH_A+CHKBIT_WIDTH-1]; doublebit_error[1] = doublebit_error[C_WRITE_WIDTH_A+CHKBIT_WIDTH-2]; current_contents = current_contents ^ doublebit_error[C_WRITE_WIDTH_A-1:0]; end end // Write data to memory if (WRITE_WIDTH_RATIO_A == 1) begin // Workaround for IUS 5.5 part-select issue memory[address*WRITE_WIDTH_RATIO_A] = current_contents; end else begin for (i = 0; i < WRITE_WIDTH_RATIO_A; i = i + 1) begin memory[address*WRITE_WIDTH_RATIO_A + i] = current_contents[MIN_WIDTH*i+:MIN_WIDTH]; end end // Store the address at which error is injected: if ((C_FAMILY_LOCALPARAM == "virtex7") && C_USE_ECC == 1) begin if ((C_HAS_INJECTERR == 1 && inj_sbiterr == 1'b1) || (C_HAS_INJECTERR == 3 && inj_sbiterr == 1'b1 && inj_dbiterr != 1'b1)) begin sbiterr_arr[addr] = 1; end else begin sbiterr_arr[addr] = 0; end if ((C_HAS_INJECTERR == 2 || C_HAS_INJECTERR == 3) && inj_dbiterr == 1'b1) begin dbiterr_arr[addr] = 1; end else begin dbiterr_arr[addr] = 0; end end // Store the address at which softecc error is injected: if (C_USE_SOFTECC == 1) begin if ((C_HAS_INJECTERR == 1 && inj_sbiterr == 1'b1) || (C_HAS_INJECTERR == 3 && inj_sbiterr == 1'b1 && inj_dbiterr != 1'b1)) begin softecc_sbiterr_arr[addr] = 1; end else begin softecc_sbiterr_arr[addr] = 0; end if ((C_HAS_INJECTERR == 2 || C_HAS_INJECTERR == 3) && inj_dbiterr == 1'b1) begin softecc_dbiterr_arr[addr] = 1; end else begin softecc_dbiterr_arr[addr] = 0; end end end end endtask //************** // write_b //************** task write_b (input reg [C_ADDRB_WIDTH-1:0] addr, input reg [C_WEB_WIDTH-1:0] byte_en, input reg [C_WRITE_WIDTH_B-1:0] data); reg [C_WRITE_WIDTH_B-1:0] current_contents; reg [C_ADDRB_WIDTH-1:0] address; integer i; begin // Shift the address by the ratio address = (addr/WRITE_ADDR_B_DIV); if (address >= C_WRITE_DEPTH_B) begin if (!C_DISABLE_WARN_BHV_RANGE) begin $fdisplay(ADDRFILE, "%0s WARNING: Address %0h is outside range for B Write", C_CORENAME, addr); end // valid address end else begin // Combine w/ byte writes if (C_USE_BYTE_WEB) begin // Get the current memory contents if (WRITE_WIDTH_RATIO_B == 1) begin // Workaround for IUS 5.5 part-select issue current_contents = memory[address]; end else begin for (i = 0; i < WRITE_WIDTH_RATIO_B; i = i + 1) begin current_contents[MIN_WIDTH*i+:MIN_WIDTH] = memory[address*WRITE_WIDTH_RATIO_B + i]; end end // Apply incoming bytes if (C_WEB_WIDTH == 1) begin // Workaround for IUS 5.5 part-select issue if (byte_en[0]) begin current_contents = data; end end else begin for (i = 0; i < C_WEB_WIDTH; i = i + 1) begin if (byte_en[i]) begin current_contents[BYTE_SIZE*i+:BYTE_SIZE] = data[BYTE_SIZE*i+:BYTE_SIZE]; end end end // No byte-writes, overwrite the whole word end else begin current_contents = data; end // Write data to memory if (WRITE_WIDTH_RATIO_B == 1) begin // Workaround for IUS 5.5 part-select issue memory[address*WRITE_WIDTH_RATIO_B] = current_contents; end else begin for (i = 0; i < WRITE_WIDTH_RATIO_B; i = i + 1) begin memory[address*WRITE_WIDTH_RATIO_B + i] = current_contents[MIN_WIDTH*i+:MIN_WIDTH]; end end end end endtask //************** // read_a //************** task read_a (input reg [C_ADDRA_WIDTH-1:0] addr, input reg reset); reg [C_ADDRA_WIDTH-1:0] address; integer i; begin if (reset) begin memory_out_a <= #FLOP_DELAY inita_val; end else begin // Shift the address by the ratio address = (addr/READ_ADDR_A_DIV); if (address >= C_READ_DEPTH_A) begin if (!C_DISABLE_WARN_BHV_RANGE) begin $fdisplay(ADDRFILE, "%0s WARNING: Address %0h is outside range for A Read", C_CORENAME, addr); end memory_out_a <= #FLOP_DELAY 'bX; // valid address end else begin if (READ_WIDTH_RATIO_A==1) begin memory_out_a <= #FLOP_DELAY memory[address*READ_WIDTH_RATIO_A]; end else begin // Increment through the 'partial' words in the memory for (i = 0; i < READ_WIDTH_RATIO_A; i = i + 1) begin memory_out_a[MIN_WIDTH*i+:MIN_WIDTH] <= #FLOP_DELAY memory[address*READ_WIDTH_RATIO_A + i]; end end //end READ_WIDTH_RATIO_A==1 loop end //end valid address loop end //end reset-data assignment loops end endtask //************** // read_b //************** task read_b (input reg [C_ADDRB_WIDTH-1:0] addr, input reg reset); reg [C_ADDRB_WIDTH-1:0] address; integer i; begin if (reset) begin memory_out_b <= #FLOP_DELAY initb_val; sbiterr_in <= #FLOP_DELAY 1'b0; dbiterr_in <= #FLOP_DELAY 1'b0; rdaddrecc_in <= #FLOP_DELAY 0; end else begin // Shift the address address = (addr/READ_ADDR_B_DIV); if (address >= C_READ_DEPTH_B) begin if (!C_DISABLE_WARN_BHV_RANGE) begin $fdisplay(ADDRFILE, "%0s WARNING: Address %0h is outside range for B Read", C_CORENAME, addr); end memory_out_b <= #FLOP_DELAY 'bX; sbiterr_in <= #FLOP_DELAY 1'bX; dbiterr_in <= #FLOP_DELAY 1'bX; rdaddrecc_in <= #FLOP_DELAY 'bX; // valid address end else begin if (READ_WIDTH_RATIO_B==1) begin memory_out_b <= #FLOP_DELAY memory[address*READ_WIDTH_RATIO_B]; end else begin // Increment through the 'partial' words in the memory for (i = 0; i < READ_WIDTH_RATIO_B; i = i + 1) begin memory_out_b[MIN_WIDTH*i+:MIN_WIDTH] <= #FLOP_DELAY memory[address*READ_WIDTH_RATIO_B + i]; end end if ((C_FAMILY_LOCALPARAM == "virtex7") && C_USE_ECC == 1) begin rdaddrecc_in <= #FLOP_DELAY addr; if (sbiterr_arr[addr] == 1) begin sbiterr_in <= #FLOP_DELAY 1'b1; end else begin sbiterr_in <= #FLOP_DELAY 1'b0; end if (dbiterr_arr[addr] == 1) begin dbiterr_in <= #FLOP_DELAY 1'b1; end else begin dbiterr_in <= #FLOP_DELAY 1'b0; end end else if (C_USE_SOFTECC == 1) begin rdaddrecc_in <= #FLOP_DELAY addr; if (softecc_sbiterr_arr[addr] == 1) begin sbiterr_in <= #FLOP_DELAY 1'b1; end else begin sbiterr_in <= #FLOP_DELAY 1'b0; end if (softecc_dbiterr_arr[addr] == 1) begin dbiterr_in <= #FLOP_DELAY 1'b1; end else begin dbiterr_in <= #FLOP_DELAY 1'b0; end end else begin rdaddrecc_in <= #FLOP_DELAY 0; dbiterr_in <= #FLOP_DELAY 1'b0; sbiterr_in <= #FLOP_DELAY 1'b0; end //end SOFTECC Loop end //end Valid address loop end //end reset-data assignment loops end endtask //************** // reset_a //************** task reset_a (input reg reset); begin if (reset) memory_out_a <= #FLOP_DELAY inita_val; end endtask //************** // reset_b //************** task reset_b (input reg reset); begin if (reset) memory_out_b <= #FLOP_DELAY initb_val; end endtask //************** // init_memory //************** task init_memory; integer i, j, addr_step; integer status; reg [C_WRITE_WIDTH_A-1:0] default_data; begin default_data = 0; //Display output message indicating that the behavioral model is being //initialized if (C_USE_DEFAULT_DATA || C_LOAD_INIT_FILE) $display(" Block Memory Generator module loading initial data..."); // Convert the default to hex if (C_USE_DEFAULT_DATA) begin if (default_data_str == "") begin $fdisplay(ERRFILE, "%0s ERROR: C_DEFAULT_DATA is empty!", C_CORENAME); $finish; end else begin status = $sscanf(default_data_str, "%h", default_data); if (status == 0) begin $fdisplay(ERRFILE, {"%0s ERROR: Unsuccessful hexadecimal read", "from C_DEFAULT_DATA: %0s"}, C_CORENAME, C_DEFAULT_DATA); $finish; end end end // Step by WRITE_ADDR_A_DIV through the memory via the // Port A write interface to hit every location once addr_step = WRITE_ADDR_A_DIV; // 'write' to every location with default (or 0) for (i = 0; i < C_WRITE_DEPTH_A*addr_step; i = i + addr_step) begin write_a(i, {C_WEA_WIDTH{1'b1}}, default_data, 1'b0, 1'b0); end // Get specialized data from the MIF file if (C_LOAD_INIT_FILE) begin if (init_file_str == "") begin $fdisplay(ERRFILE, "%0s ERROR: C_INIT_FILE_NAME is empty!", C_CORENAME); $finish; end else begin initfile = $fopen(init_file_str, "r"); if (initfile == 0) begin $fdisplay(ERRFILE, {"%0s, ERROR: Problem opening", "C_INIT_FILE_NAME: %0s!"}, C_CORENAME, init_file_str); $finish; end else begin // loop through the mif file, loading in the data for (i = 0; i < C_WRITE_DEPTH_A*addr_step; i = i + addr_step) begin status = $fscanf(initfile, "%b", mif_data); if (status > 0) begin write_a(i, {C_WEA_WIDTH{1'b1}}, mif_data, 1'b0, 1'b0); end end $fclose(initfile); end //initfile end //init_file_str end //C_LOAD_INIT_FILE if (C_USE_BRAM_BLOCK) begin // Get specialized data from the MIF file if (C_INIT_FILE != "NONE") begin if (mem_init_file_str == "") begin $fdisplay(ERRFILE, "%0s ERROR: C_INIT_FILE is empty!", C_CORENAME); $finish; end else begin meminitfile = $fopen(mem_init_file_str, "r"); if (meminitfile == 0) begin $fdisplay(ERRFILE, {"%0s, ERROR: Problem opening", "C_INIT_FILE: %0s!"}, C_CORENAME, mem_init_file_str); $finish; end else begin // loop through the mif file, loading in the data $readmemh(mem_init_file_str, memory ); for (j = 0; j < MAX_DEPTH-1 ; j = j + 1) begin end $fclose(meminitfile); end //meminitfile end //mem_init_file_str end //C_INIT_FILE end //C_USE_BRAM_BLOCK //Display output message indicating that the behavioral model is done //initializing if (C_USE_DEFAULT_DATA || C_LOAD_INIT_FILE) $display(" Block Memory Generator data initialization complete."); end endtask //************** // log2roundup //************** function integer log2roundup (input integer data_value); integer width; integer cnt; begin width = 0; if (data_value > 1) begin for(cnt=1 ; cnt < data_value ; cnt = cnt * 2) begin width = width + 1; end //loop end //if log2roundup = width; end //log2roundup endfunction //******************* // collision_check //******************* function integer collision_check (input reg [C_ADDRA_WIDTH-1:0] addr_a, input integer iswrite_a, input reg [C_ADDRB_WIDTH-1:0] addr_b, input integer iswrite_b); reg c_aw_bw, c_aw_br, c_ar_bw; integer scaled_addra_to_waddrb_width; integer scaled_addrb_to_waddrb_width; integer scaled_addra_to_waddra_width; integer scaled_addrb_to_waddra_width; integer scaled_addra_to_raddrb_width; integer scaled_addrb_to_raddrb_width; integer scaled_addra_to_raddra_width; integer scaled_addrb_to_raddra_width; begin c_aw_bw = 0; c_aw_br = 0; c_ar_bw = 0; //If write_addr_b_width is smaller, scale both addresses to that width for //comparing write_addr_a and write_addr_b; addr_a starts as C_ADDRA_WIDTH, //scale it down to write_addr_b_width. addr_b starts as C_ADDRB_WIDTH, //scale it down to write_addr_b_width. Once both are scaled to //write_addr_b_width, compare. scaled_addra_to_waddrb_width = ((addr_a)/ 2**(C_ADDRA_WIDTH-write_addr_b_width)); scaled_addrb_to_waddrb_width = ((addr_b)/ 2**(C_ADDRB_WIDTH-write_addr_b_width)); //If write_addr_a_width is smaller, scale both addresses to that width for //comparing write_addr_a and write_addr_b; addr_a starts as C_ADDRA_WIDTH, //scale it down to write_addr_a_width. addr_b starts as C_ADDRB_WIDTH, //scale it down to write_addr_a_width. Once both are scaled to //write_addr_a_width, compare. scaled_addra_to_waddra_width = ((addr_a)/ 2**(C_ADDRA_WIDTH-write_addr_a_width)); scaled_addrb_to_waddra_width = ((addr_b)/ 2**(C_ADDRB_WIDTH-write_addr_a_width)); //If read_addr_b_width is smaller, scale both addresses to that width for //comparing write_addr_a and read_addr_b; addr_a starts as C_ADDRA_WIDTH, //scale it down to read_addr_b_width. addr_b starts as C_ADDRB_WIDTH, //scale it down to read_addr_b_width. Once both are scaled to //read_addr_b_width, compare. scaled_addra_to_raddrb_width = ((addr_a)/ 2**(C_ADDRA_WIDTH-read_addr_b_width)); scaled_addrb_to_raddrb_width = ((addr_b)/ 2**(C_ADDRB_WIDTH-read_addr_b_width)); //If read_addr_a_width is smaller, scale both addresses to that width for //comparing read_addr_a and write_addr_b; addr_a starts as C_ADDRA_WIDTH, //scale it down to read_addr_a_width. addr_b starts as C_ADDRB_WIDTH, //scale it down to read_addr_a_width. Once both are scaled to //read_addr_a_width, compare. scaled_addra_to_raddra_width = ((addr_a)/ 2**(C_ADDRA_WIDTH-read_addr_a_width)); scaled_addrb_to_raddra_width = ((addr_b)/ 2**(C_ADDRB_WIDTH-read_addr_a_width)); //Look for a write-write collision. In order for a write-write //collision to exist, both ports must have a write transaction. if (iswrite_a && iswrite_b) begin if (write_addr_a_width > write_addr_b_width) begin if (scaled_addra_to_waddrb_width == scaled_addrb_to_waddrb_width) begin c_aw_bw = 1; end else begin c_aw_bw = 0; end end else begin if (scaled_addrb_to_waddra_width == scaled_addra_to_waddra_width) begin c_aw_bw = 1; end else begin c_aw_bw = 0; end end //width end //iswrite_a and iswrite_b //If the B port is reading (which means it is enabled - so could be //a TX_WRITE or TX_READ), then check for a write-read collision). //This could happen whether or not a write-write collision exists due //to asymmetric write/read ports. if (iswrite_a) begin if (write_addr_a_width > read_addr_b_width) begin if (scaled_addra_to_raddrb_width == scaled_addrb_to_raddrb_width) begin c_aw_br = 1; end else begin c_aw_br = 0; end end else begin if (scaled_addrb_to_waddra_width == scaled_addra_to_waddra_width) begin c_aw_br = 1; end else begin c_aw_br = 0; end end //width end //iswrite_a //If the A port is reading (which means it is enabled - so could be // a TX_WRITE or TX_READ), then check for a write-read collision). //This could happen whether or not a write-write collision exists due // to asymmetric write/read ports. if (iswrite_b) begin if (read_addr_a_width > write_addr_b_width) begin if (scaled_addra_to_waddrb_width == scaled_addrb_to_waddrb_width) begin c_ar_bw = 1; end else begin c_ar_bw = 0; end end else begin if (scaled_addrb_to_raddra_width == scaled_addra_to_raddra_width) begin c_ar_bw = 1; end else begin c_ar_bw = 0; end end //width end //iswrite_b collision_check = c_aw_bw | c_aw_br | c_ar_bw; end endfunction //******************************* // power on values //******************************* initial begin // Load up the memory init_memory; // Load up the output registers and latches if ($sscanf(inita_str, "%h", inita_val)) begin memory_out_a = inita_val; end else begin memory_out_a = 0; end if ($sscanf(initb_str, "%h", initb_val)) begin memory_out_b = initb_val; end else begin memory_out_b = 0; end sbiterr_in = 1'b0; dbiterr_in = 1'b0; rdaddrecc_in = 0; // Determine the effective address widths for each of the 4 ports write_addr_a_width = C_ADDRA_WIDTH - log2roundup(WRITE_ADDR_A_DIV); read_addr_a_width = C_ADDRA_WIDTH - log2roundup(READ_ADDR_A_DIV); write_addr_b_width = C_ADDRB_WIDTH - log2roundup(WRITE_ADDR_B_DIV); read_addr_b_width = C_ADDRB_WIDTH - log2roundup(READ_ADDR_B_DIV); $display("Block Memory Generator module %m is using a behavioral model for simulation which will not precisely model memory collision behavior."); end //*************************************************************************** // These are the main blocks which schedule read and write operations // Note that the reset priority feature at the latch stage is only supported // for Spartan-6. For other families, the default priority at the latch stage // is "CE" //*************************************************************************** // Synchronous clocks: schedule port operations with respect to // both write operating modes generate if(C_COMMON_CLK && (C_WRITE_MODE_A == "WRITE_FIRST") && (C_WRITE_MODE_B == "WRITE_FIRST")) begin : com_clk_sched_wf_wf always @(posedge CLKA) begin //Write A if (wea_i) write_a(ADDRA, wea_i, DINA, INJECTSBITERR, INJECTDBITERR); //Write B if (web_i) write_b(ADDRB, web_i, DINB); if (rea_i) read_a(ADDRA, reseta_i); //Read B if (reb_i) read_b(ADDRB, resetb_i); end end else if(C_COMMON_CLK && (C_WRITE_MODE_A == "READ_FIRST") && (C_WRITE_MODE_B == "WRITE_FIRST")) begin : com_clk_sched_rf_wf always @(posedge CLKA) begin //Write B if (web_i) write_b(ADDRB, web_i, DINB); //Read B if (reb_i) read_b(ADDRB, resetb_i); //Read A if (rea_i) read_a(ADDRA, reseta_i); //Write A if (wea_i) write_a(ADDRA, wea_i, DINA, INJECTSBITERR, INJECTDBITERR); end end else if(C_COMMON_CLK && (C_WRITE_MODE_A == "WRITE_FIRST") && (C_WRITE_MODE_B == "READ_FIRST")) begin : com_clk_sched_wf_rf always @(posedge CLKA) begin //Write A if (wea_i) write_a(ADDRA, wea_i, DINA, INJECTSBITERR, INJECTDBITERR); //Read A if (rea_i) read_a(ADDRA, reseta_i); //Read B if (reb_i) read_b(ADDRB, resetb_i); //Write B if (web_i) write_b(ADDRB, web_i, DINB); end end else if(C_COMMON_CLK && (C_WRITE_MODE_A == "READ_FIRST") && (C_WRITE_MODE_B == "READ_FIRST")) begin : com_clk_sched_rf_rf always @(posedge CLKA) begin //Read A if (rea_i) read_a(ADDRA, reseta_i); //Read B if (reb_i) read_b(ADDRB, resetb_i); //Write A if (wea_i) write_a(ADDRA, wea_i, DINA, INJECTSBITERR, INJECTDBITERR); //Write B if (web_i) write_b(ADDRB, web_i, DINB); end end else if(C_COMMON_CLK && (C_WRITE_MODE_A =="WRITE_FIRST") && (C_WRITE_MODE_B == "NO_CHANGE")) begin : com_clk_sched_wf_nc always @(posedge CLKA) begin //Write A if (wea_i) write_a(ADDRA, wea_i, DINA, INJECTSBITERR, INJECTDBITERR); //Read A if (rea_i) read_a(ADDRA, reseta_i); //Read B if (reb_i && (!web_i || resetb_i)) read_b(ADDRB, resetb_i); //Write B if (web_i) write_b(ADDRB, web_i, DINB); end end else if(C_COMMON_CLK && (C_WRITE_MODE_A =="READ_FIRST") && (C_WRITE_MODE_B == "NO_CHANGE")) begin : com_clk_sched_rf_nc always @(posedge CLKA) begin //Read A if (rea_i) read_a(ADDRA, reseta_i); //Read B if (reb_i && (!web_i || resetb_i)) read_b(ADDRB, resetb_i); //Write A if (wea_i) write_a(ADDRA, wea_i, DINA, INJECTSBITERR, INJECTDBITERR); //Write B if (web_i) write_b(ADDRB, web_i, DINB); end end else if(C_COMMON_CLK && (C_WRITE_MODE_A =="NO_CHANGE") && (C_WRITE_MODE_B == "WRITE_FIRST")) begin : com_clk_sched_nc_wf always @(posedge CLKA) begin //Write A if (wea_i) write_a(ADDRA, wea_i, DINA, INJECTSBITERR, INJECTDBITERR); //Write B if (web_i) write_b(ADDRB, web_i, DINB); //Read A if (rea_i && (!wea_i || reseta_i)) read_a(ADDRA, reseta_i); //Read B if (reb_i) read_b(ADDRB, resetb_i); end end else if(C_COMMON_CLK && (C_WRITE_MODE_A =="NO_CHANGE") && (C_WRITE_MODE_B == "READ_FIRST")) begin : com_clk_sched_nc_rf always @(posedge CLKA) begin //Read B if (reb_i) read_b(ADDRB, resetb_i); //Read A if (rea_i && (!wea_i || reseta_i)) read_a(ADDRA, reseta_i); //Write A if (wea_i) write_a(ADDRA, wea_i, DINA, INJECTSBITERR, INJECTDBITERR); //Write B if (web_i) write_b(ADDRB, web_i, DINB); end end else if(C_COMMON_CLK && (C_WRITE_MODE_A =="NO_CHANGE") && (C_WRITE_MODE_B == "NO_CHANGE")) begin : com_clk_sched_nc_nc always @(posedge CLKA) begin //Write A if (wea_i) write_a(ADDRA, wea_i, DINA, INJECTSBITERR, INJECTDBITERR); //Write B if (web_i) write_b(ADDRB, web_i, DINB); //Read A if (rea_i && (!wea_i || reseta_i)) read_a(ADDRA, reseta_i); //Read B if (reb_i && (!web_i || resetb_i)) read_b(ADDRB, resetb_i); end end else if(C_COMMON_CLK) begin: com_clk_sched_default always @(posedge CLKA) begin //Write A if (wea_i) write_a(ADDRA, wea_i, DINA, INJECTSBITERR, INJECTDBITERR); //Write B if (web_i) write_b(ADDRB, web_i, DINB); //Read A if (rea_i) read_a(ADDRA, reseta_i); //Read B if (reb_i) read_b(ADDRB, resetb_i); end end endgenerate // Asynchronous clocks: port operation is independent generate if((!C_COMMON_CLK) && (C_WRITE_MODE_A == "WRITE_FIRST")) begin : async_clk_sched_clka_wf always @(posedge CLKA) begin //Write A if (wea_i) write_a(ADDRA, wea_i, DINA, INJECTSBITERR, INJECTDBITERR); //Read A if (rea_i) read_a(ADDRA, reseta_i); end end else if((!C_COMMON_CLK) && (C_WRITE_MODE_A == "READ_FIRST")) begin : async_clk_sched_clka_rf always @(posedge CLKA) begin //Read A if (rea_i) read_a(ADDRA, reseta_i); //Write A if (wea_i) write_a(ADDRA, wea_i, DINA, INJECTSBITERR, INJECTDBITERR); end end else if((!C_COMMON_CLK) && (C_WRITE_MODE_A == "NO_CHANGE")) begin : async_clk_sched_clka_nc always @(posedge CLKA) begin //Write A if (wea_i) write_a(ADDRA, wea_i, DINA, INJECTSBITERR, INJECTDBITERR); //Read A if (rea_i && (!wea_i || reseta_i)) read_a(ADDRA, reseta_i); end end endgenerate generate if ((!C_COMMON_CLK) && (C_WRITE_MODE_B == "WRITE_FIRST")) begin: async_clk_sched_clkb_wf always @(posedge CLKB) begin //Write B if (web_i) write_b(ADDRB, web_i, DINB); //Read B if (reb_i) read_b(ADDRB, resetb_i); end end else if ((!C_COMMON_CLK) && (C_WRITE_MODE_B == "READ_FIRST")) begin: async_clk_sched_clkb_rf always @(posedge CLKB) begin //Read B if (reb_i) read_b(ADDRB, resetb_i); //Write B if (web_i) write_b(ADDRB, web_i, DINB); end end else if ((!C_COMMON_CLK) && (C_WRITE_MODE_B == "NO_CHANGE")) begin: async_clk_sched_clkb_nc always @(posedge CLKB) begin //Write B if (web_i) write_b(ADDRB, web_i, DINB); //Read B if (reb_i && (!web_i || resetb_i)) read_b(ADDRB, resetb_i); end end endgenerate //*************************************************************** // Instantiate the variable depth output register stage module //*************************************************************** // Port A assign rsta_outp_stage = RSTA & (~SLEEP); BLK_MEM_GEN_v8_2_output_stage #(.C_FAMILY (C_FAMILY), .C_XDEVICEFAMILY (C_XDEVICEFAMILY), .C_RST_TYPE ("SYNC"), .C_HAS_RST (C_HAS_RSTA), .C_RSTRAM (C_RSTRAM_A), .C_RST_PRIORITY (C_RST_PRIORITY_A), .C_INIT_VAL (C_INITA_VAL), .C_HAS_EN (C_HAS_ENA), .C_HAS_REGCE (C_HAS_REGCEA), .C_DATA_WIDTH (C_READ_WIDTH_A), .C_ADDRB_WIDTH (C_ADDRB_WIDTH), .C_HAS_MEM_OUTPUT_REGS (C_HAS_MEM_OUTPUT_REGS_A), .C_USE_SOFTECC (C_USE_SOFTECC), .C_USE_ECC (C_USE_ECC), .NUM_STAGES (NUM_OUTPUT_STAGES_A), .C_EN_ECC_PIPE (0), .FLOP_DELAY (FLOP_DELAY)) reg_a (.CLK (CLKA), .RST (rsta_outp_stage),//(RSTA), .EN (ENA), .REGCE (REGCEA), .DIN_I (memory_out_a), .DOUT (DOUTA), .SBITERR_IN_I (1'b0), .DBITERR_IN_I (1'b0), .SBITERR (), .DBITERR (), .RDADDRECC_IN_I ({C_ADDRB_WIDTH{1'b0}}), .ECCPIPECE (1'b0), .RDADDRECC () ); assign rstb_outp_stage = RSTB & (~SLEEP); // Port B BLK_MEM_GEN_v8_2_output_stage #(.C_FAMILY (C_FAMILY), .C_XDEVICEFAMILY (C_XDEVICEFAMILY), .C_RST_TYPE ("SYNC"), .C_HAS_RST (C_HAS_RSTB), .C_RSTRAM (C_RSTRAM_B), .C_RST_PRIORITY (C_RST_PRIORITY_B), .C_INIT_VAL (C_INITB_VAL), .C_HAS_EN (C_HAS_ENB), .C_HAS_REGCE (C_HAS_REGCEB), .C_DATA_WIDTH (C_READ_WIDTH_B), .C_ADDRB_WIDTH (C_ADDRB_WIDTH), .C_HAS_MEM_OUTPUT_REGS (C_HAS_MEM_OUTPUT_REGS_B), .C_USE_SOFTECC (C_USE_SOFTECC), .C_USE_ECC (C_USE_ECC), .NUM_STAGES (NUM_OUTPUT_STAGES_B), .C_EN_ECC_PIPE (C_EN_ECC_PIPE), .FLOP_DELAY (FLOP_DELAY)) reg_b (.CLK (CLKB), .RST (rstb_outp_stage),//(RSTB), .EN (ENB), .REGCE (REGCEB), .DIN_I (memory_out_b), .DOUT (dout_i), .SBITERR_IN_I (sbiterr_in), .DBITERR_IN_I (dbiterr_in), .SBITERR (sbiterr_i), .DBITERR (dbiterr_i), .RDADDRECC_IN_I (rdaddrecc_in), .ECCPIPECE (ECCPIPECE), .RDADDRECC (rdaddrecc_i) ); //*************************************************************** // Instantiate the Input and Output register stages //*************************************************************** BLK_MEM_GEN_v8_2_softecc_output_reg_stage #(.C_DATA_WIDTH (C_READ_WIDTH_B), .C_ADDRB_WIDTH (C_ADDRB_WIDTH), .C_HAS_SOFTECC_OUTPUT_REGS_B (C_HAS_SOFTECC_OUTPUT_REGS_B), .C_USE_SOFTECC (C_USE_SOFTECC), .FLOP_DELAY (FLOP_DELAY)) has_softecc_output_reg_stage (.CLK (CLKB), .DIN (dout_i), .DOUT (DOUTB), .SBITERR_IN (sbiterr_i), .DBITERR_IN (dbiterr_i), .SBITERR (sbiterr_sdp), .DBITERR (dbiterr_sdp), .RDADDRECC_IN (rdaddrecc_i), .RDADDRECC (rdaddrecc_sdp) ); //**************************************************** // Synchronous collision checks //**************************************************** // CR 780544 : To make verilog model's collison warnings in consistant with // vhdl model, the non-blocking assignments are replaced with blocking // assignments. generate if (!C_DISABLE_WARN_BHV_COLL && C_COMMON_CLK) begin : sync_coll always @(posedge CLKA) begin // Possible collision if both are enabled and the addresses match if (ena_i && enb_i) begin if (wea_i || web_i) begin is_collision = collision_check(ADDRA, wea_i, ADDRB, web_i); end else begin is_collision = 0; end end else begin is_collision = 0; end // If the write port is in READ_FIRST mode, there is no collision if (C_WRITE_MODE_A=="READ_FIRST" && wea_i && !web_i) begin is_collision = 0; end if (C_WRITE_MODE_B=="READ_FIRST" && web_i && !wea_i) begin is_collision = 0; end // Only flag if one of the accesses is a write if (is_collision && (wea_i || web_i)) begin $fwrite(COLLFILE, "%0s collision detected at time: %0d, ", C_CORENAME, $time); $fwrite(COLLFILE, "A %0s address: %0h, B %0s address: %0h\n", wea_i ? "write" : "read", ADDRA, web_i ? "write" : "read", ADDRB); end end //**************************************************** // Asynchronous collision checks //**************************************************** end else if (!C_DISABLE_WARN_BHV_COLL && !C_COMMON_CLK) begin : async_coll // Delay A and B addresses in order to mimic setup/hold times wire [C_ADDRA_WIDTH-1:0] #COLL_DELAY addra_delay = ADDRA; wire [0:0] #COLL_DELAY wea_delay = wea_i; wire #COLL_DELAY ena_delay = ena_i; wire [C_ADDRB_WIDTH-1:0] #COLL_DELAY addrb_delay = ADDRB; wire [0:0] #COLL_DELAY web_delay = web_i; wire #COLL_DELAY enb_delay = enb_i; // Do the checks w/rt A always @(posedge CLKA) begin // Possible collision if both are enabled and the addresses match if (ena_i && enb_i) begin if (wea_i || web_i) begin is_collision_a = collision_check(ADDRA, wea_i, ADDRB, web_i); end else begin is_collision_a = 0; end end else begin is_collision_a = 0; end if (ena_i && enb_delay) begin if(wea_i || web_delay) begin is_collision_delay_a = collision_check(ADDRA, wea_i, addrb_delay, web_delay); end else begin is_collision_delay_a = 0; end end else begin is_collision_delay_a = 0; end // Only flag if B access is a write if (is_collision_a && web_i) begin $fwrite(COLLFILE, "%0s collision detected at time: %0d, ", C_CORENAME, $time); $fwrite(COLLFILE, "A %0s address: %0h, B write address: %0h\n", wea_i ? "write" : "read", ADDRA, ADDRB); end else if (is_collision_delay_a && web_delay) begin $fwrite(COLLFILE, "%0s collision detected at time: %0d, ", C_CORENAME, $time); $fwrite(COLLFILE, "A %0s address: %0h, B write address: %0h\n", wea_i ? "write" : "read", ADDRA, addrb_delay); end end // Do the checks w/rt B always @(posedge CLKB) begin // Possible collision if both are enabled and the addresses match if (ena_i && enb_i) begin if (wea_i || web_i) begin is_collision_b = collision_check(ADDRA, wea_i, ADDRB, web_i); end else begin is_collision_b = 0; end end else begin is_collision_b = 0; end if (ena_delay && enb_i) begin if (wea_delay || web_i) begin is_collision_delay_b = collision_check(addra_delay, wea_delay, ADDRB, web_i); end else begin is_collision_delay_b = 0; end end else begin is_collision_delay_b = 0; end // Only flag if A access is a write if (is_collision_b && wea_i) begin $fwrite(COLLFILE, "%0s collision detected at time: %0d, ", C_CORENAME, $time); $fwrite(COLLFILE, "A write address: %0h, B %s address: %0h\n", ADDRA, web_i ? "write" : "read", ADDRB); end else if (is_collision_delay_b && wea_delay) begin $fwrite(COLLFILE, "%0s collision detected at time: %0d, ", C_CORENAME, $time); $fwrite(COLLFILE, "A write address: %0h, B %s address: %0h\n", addra_delay, web_i ? "write" : "read", ADDRB); end end end endgenerate endmodule //***************************************************************************** // Top module wraps Input register and Memory module // // This module is the top-level behavioral model and this implements the memory // module and the input registers //***************************************************************************** module blk_mem_gen_v8_2 #(parameter C_CORENAME = "blk_mem_gen_v8_2", parameter C_FAMILY = "virtex7", parameter C_XDEVICEFAMILY = "virtex7", parameter C_ELABORATION_DIR = "", parameter C_INTERFACE_TYPE = 0, parameter C_USE_BRAM_BLOCK = 0, parameter C_CTRL_ECC_ALGO = "NONE", parameter C_ENABLE_32BIT_ADDRESS = 0, parameter C_AXI_TYPE = 0, parameter C_AXI_SLAVE_TYPE = 0, parameter C_HAS_AXI_ID = 0, parameter C_AXI_ID_WIDTH = 4, parameter C_MEM_TYPE = 2, parameter C_BYTE_SIZE = 9, parameter C_ALGORITHM = 1, parameter C_PRIM_TYPE = 3, parameter C_LOAD_INIT_FILE = 0, parameter C_INIT_FILE_NAME = "", parameter C_INIT_FILE = "", parameter C_USE_DEFAULT_DATA = 0, parameter C_DEFAULT_DATA = "0", //parameter C_RST_TYPE = "SYNC", parameter C_HAS_RSTA = 0, parameter C_RST_PRIORITY_A = "CE", parameter C_RSTRAM_A = 0, parameter C_INITA_VAL = "0", parameter C_HAS_ENA = 1, parameter C_HAS_REGCEA = 0, parameter C_USE_BYTE_WEA = 0, parameter C_WEA_WIDTH = 1, parameter C_WRITE_MODE_A = "WRITE_FIRST", parameter C_WRITE_WIDTH_A = 32, parameter C_READ_WIDTH_A = 32, parameter C_WRITE_DEPTH_A = 64, parameter C_READ_DEPTH_A = 64, parameter C_ADDRA_WIDTH = 5, parameter C_HAS_RSTB = 0, parameter C_RST_PRIORITY_B = "CE", parameter C_RSTRAM_B = 0, parameter C_INITB_VAL = "", parameter C_HAS_ENB = 1, parameter C_HAS_REGCEB = 0, parameter C_USE_BYTE_WEB = 0, parameter C_WEB_WIDTH = 1, parameter C_WRITE_MODE_B = "WRITE_FIRST", parameter C_WRITE_WIDTH_B = 32, parameter C_READ_WIDTH_B = 32, parameter C_WRITE_DEPTH_B = 64, parameter C_READ_DEPTH_B = 64, parameter C_ADDRB_WIDTH = 5, parameter C_HAS_MEM_OUTPUT_REGS_A = 0, parameter C_HAS_MEM_OUTPUT_REGS_B = 0, parameter C_HAS_MUX_OUTPUT_REGS_A = 0, parameter C_HAS_MUX_OUTPUT_REGS_B = 0, parameter C_HAS_SOFTECC_INPUT_REGS_A = 0, parameter C_HAS_SOFTECC_OUTPUT_REGS_B= 0, parameter C_MUX_PIPELINE_STAGES = 0, parameter C_USE_SOFTECC = 0, parameter C_USE_ECC = 0, parameter C_EN_ECC_PIPE = 0, parameter C_HAS_INJECTERR = 0, parameter C_SIM_COLLISION_CHECK = "NONE", parameter C_COMMON_CLK = 1, parameter C_DISABLE_WARN_BHV_COLL = 0, parameter C_EN_SLEEP_PIN = 0, parameter C_USE_URAM = 0, parameter C_EN_RDADDRA_CHG = 0, parameter C_EN_RDADDRB_CHG = 0, parameter C_EN_DEEPSLEEP_PIN = 0, parameter C_EN_SHUTDOWN_PIN = 0, parameter C_DISABLE_WARN_BHV_RANGE = 0, parameter C_COUNT_36K_BRAM = "", parameter C_COUNT_18K_BRAM = "", parameter C_EST_POWER_SUMMARY = "" ) (input clka, input rsta, input ena, input regcea, input [C_WEA_WIDTH-1:0] wea, input [C_ADDRA_WIDTH-1:0] addra, input [C_WRITE_WIDTH_A-1:0] dina, output [C_READ_WIDTH_A-1:0] douta, input clkb, input rstb, input enb, input regceb, input [C_WEB_WIDTH-1:0] web, input [C_ADDRB_WIDTH-1:0] addrb, input [C_WRITE_WIDTH_B-1:0] dinb, output [C_READ_WIDTH_B-1:0] doutb, input injectsbiterr, input injectdbiterr, output sbiterr, output dbiterr, output [C_ADDRB_WIDTH-1:0] rdaddrecc, input eccpipece, input sleep, input deepsleep, input shutdown, //AXI BMG Input and Output Port Declarations //AXI Global Signals input s_aclk, input s_aresetn, //AXI Full/lite slave write (write side) input [C_AXI_ID_WIDTH-1:0] s_axi_awid, input [31:0] s_axi_awaddr, input [7:0] s_axi_awlen, input [2:0] s_axi_awsize, input [1:0] s_axi_awburst, input s_axi_awvalid, output s_axi_awready, input [C_WRITE_WIDTH_A-1:0] s_axi_wdata, input [C_WEA_WIDTH-1:0] s_axi_wstrb, input s_axi_wlast, input s_axi_wvalid, output s_axi_wready, output [C_AXI_ID_WIDTH-1:0] s_axi_bid, output [1:0] s_axi_bresp, output s_axi_bvalid, input s_axi_bready, //AXI Full/lite slave read (write side) input [C_AXI_ID_WIDTH-1:0] s_axi_arid, input [31:0] s_axi_araddr, input [7:0] s_axi_arlen, input [2:0] s_axi_arsize, input [1:0] s_axi_arburst, input s_axi_arvalid, output s_axi_arready, output [C_AXI_ID_WIDTH-1:0] s_axi_rid, output [C_WRITE_WIDTH_B-1:0] s_axi_rdata, output [1:0] s_axi_rresp, output s_axi_rlast, output s_axi_rvalid, input s_axi_rready, //AXI Full/lite sideband signals input s_axi_injectsbiterr, input s_axi_injectdbiterr, output s_axi_sbiterr, output s_axi_dbiterr, output [C_ADDRB_WIDTH-1:0] s_axi_rdaddrecc ); //****************************** // Port and Generic Definitions //****************************** ////////////////////////////////////////////////////////////////////////// // Generic Definitions ////////////////////////////////////////////////////////////////////////// // C_CORENAME : Instance name of the Block Memory Generator core // C_FAMILY,C_XDEVICEFAMILY: Designates architecture targeted. The following // options are available - "spartan3", "spartan6", // "virtex4", "virtex5", "virtex6" and "virtex6l". // C_MEM_TYPE : Designates memory type. // It can be // 0 - Single Port Memory // 1 - Simple Dual Port Memory // 2 - True Dual Port Memory // 3 - Single Port Read Only Memory // 4 - Dual Port Read Only Memory // C_BYTE_SIZE : Size of a byte (8 or 9 bits) // C_ALGORITHM : Designates the algorithm method used // for constructing the memory. // It can be Fixed_Primitives, Minimum_Area or // Low_Power // C_PRIM_TYPE : Designates the user selected primitive used to // construct the memory. // // C_LOAD_INIT_FILE : Designates the use of an initialization file to // initialize memory contents. // C_INIT_FILE_NAME : Memory initialization file name. // C_USE_DEFAULT_DATA : Designates whether to fill remaining // initialization space with default data // C_DEFAULT_DATA : Default value of all memory locations // not initialized by the memory // initialization file. // C_RST_TYPE : Type of reset - Synchronous or Asynchronous // C_HAS_RSTA : Determines the presence of the RSTA port // C_RST_PRIORITY_A : Determines the priority between CE and SR for // Port A. // C_RSTRAM_A : Determines if special reset behavior is used for // Port A // C_INITA_VAL : The initialization value for Port A // C_HAS_ENA : Determines the presence of the ENA port // C_HAS_REGCEA : Determines the presence of the REGCEA port // C_USE_BYTE_WEA : Determines if the Byte Write is used or not. // C_WEA_WIDTH : The width of the WEA port // C_WRITE_MODE_A : Configurable write mode for Port A. It can be // WRITE_FIRST, READ_FIRST or NO_CHANGE. // C_WRITE_WIDTH_A : Memory write width for Port A. // C_READ_WIDTH_A : Memory read width for Port A. // C_WRITE_DEPTH_A : Memory write depth for Port A. // C_READ_DEPTH_A : Memory read depth for Port A. // C_ADDRA_WIDTH : Width of the ADDRA input port // C_HAS_RSTB : Determines the presence of the RSTB port // C_RST_PRIORITY_B : Determines the priority between CE and SR for // Port B. // C_RSTRAM_B : Determines if special reset behavior is used for // Port B // C_INITB_VAL : The initialization value for Port B // C_HAS_ENB : Determines the presence of the ENB port // C_HAS_REGCEB : Determines the presence of the REGCEB port // C_USE_BYTE_WEB : Determines if the Byte Write is used or not. // C_WEB_WIDTH : The width of the WEB port // C_WRITE_MODE_B : Configurable write mode for Port B. It can be // WRITE_FIRST, READ_FIRST or NO_CHANGE. // C_WRITE_WIDTH_B : Memory write width for Port B. // C_READ_WIDTH_B : Memory read width for Port B. // C_WRITE_DEPTH_B : Memory write depth for Port B. // C_READ_DEPTH_B : Memory read depth for Port B. // C_ADDRB_WIDTH : Width of the ADDRB input port // C_HAS_MEM_OUTPUT_REGS_A : Designates the use of a register at the output // of the RAM primitive for Port A. // C_HAS_MEM_OUTPUT_REGS_B : Designates the use of a register at the output // of the RAM primitive for Port B. // C_HAS_MUX_OUTPUT_REGS_A : Designates the use of a register at the output // of the MUX for Port A. // C_HAS_MUX_OUTPUT_REGS_B : Designates the use of a register at the output // of the MUX for Port B. // C_HAS_SOFTECC_INPUT_REGS_A : // C_HAS_SOFTECC_OUTPUT_REGS_B : // C_MUX_PIPELINE_STAGES : Designates the number of pipeline stages in // between the muxes. // C_USE_SOFTECC : Determines if the Soft ECC feature is used or // not. Only applicable Spartan-6 // C_USE_ECC : Determines if the ECC feature is used or // not. Only applicable for V5 and V6 // C_HAS_INJECTERR : Determines if the error injection pins // are present or not. If the ECC feature // is not used, this value is defaulted to // 0, else the following are the allowed // values: // 0 : No INJECTSBITERR or INJECTDBITERR pins // 1 : Only INJECTSBITERR pin exists // 2 : Only INJECTDBITERR pin exists // 3 : Both INJECTSBITERR and INJECTDBITERR pins exist // C_SIM_COLLISION_CHECK : Controls the disabling of Unisim model collision // warnings. It can be "ALL", "NONE", // "Warnings_Only" or "Generate_X_Only". // C_COMMON_CLK : Determins if the core has a single CLK input. // C_DISABLE_WARN_BHV_COLL : Controls the Behavioral Model Collision warnings // C_DISABLE_WARN_BHV_RANGE: Controls the Behavioral Model Out of Range // warnings ////////////////////////////////////////////////////////////////////////// // Port Definitions ////////////////////////////////////////////////////////////////////////// // CLKA : Clock to synchronize all read and write operations of Port A. // RSTA : Reset input to reset memory outputs to a user-defined // reset state for Port A. // ENA : Enable all read and write operations of Port A. // REGCEA : Register Clock Enable to control each pipeline output // register stages for Port A. // WEA : Write Enable to enable all write operations of Port A. // ADDRA : Address of Port A. // DINA : Data input of Port A. // DOUTA : Data output of Port A. // CLKB : Clock to synchronize all read and write operations of Port B. // RSTB : Reset input to reset memory outputs to a user-defined // reset state for Port B. // ENB : Enable all read and write operations of Port B. // REGCEB : Register Clock Enable to control each pipeline output // register stages for Port B. // WEB : Write Enable to enable all write operations of Port B. // ADDRB : Address of Port B. // DINB : Data input of Port B. // DOUTB : Data output of Port B. // INJECTSBITERR : Single Bit ECC Error Injection Pin. // INJECTDBITERR : Double Bit ECC Error Injection Pin. // SBITERR : Output signal indicating that a Single Bit ECC Error has been // detected and corrected. // DBITERR : Output signal indicating that a Double Bit ECC Error has been // detected. // RDADDRECC : Read Address Output signal indicating address at which an // ECC error has occurred. ////////////////////////////////////////////////////////////////////////// wire SBITERR; wire DBITERR; wire S_AXI_AWREADY; wire S_AXI_WREADY; wire S_AXI_BVALID; wire S_AXI_ARREADY; wire S_AXI_RLAST; wire S_AXI_RVALID; wire S_AXI_SBITERR; wire S_AXI_DBITERR; wire [C_WEA_WIDTH-1:0] WEA = wea; wire [C_ADDRA_WIDTH-1:0] ADDRA = addra; wire [C_WRITE_WIDTH_A-1:0] DINA = dina; wire [C_READ_WIDTH_A-1:0] DOUTA; wire [C_WEB_WIDTH-1:0] WEB = web; wire [C_ADDRB_WIDTH-1:0] ADDRB = addrb; wire [C_WRITE_WIDTH_B-1:0] DINB = dinb; wire [C_READ_WIDTH_B-1:0] DOUTB; wire [C_ADDRB_WIDTH-1:0] RDADDRECC; wire [C_AXI_ID_WIDTH-1:0] S_AXI_AWID = s_axi_awid; wire [31:0] S_AXI_AWADDR = s_axi_awaddr; wire [7:0] S_AXI_AWLEN = s_axi_awlen; wire [2:0] S_AXI_AWSIZE = s_axi_awsize; wire [1:0] S_AXI_AWBURST = s_axi_awburst; wire [C_WRITE_WIDTH_A-1:0] S_AXI_WDATA = s_axi_wdata; wire [C_WEA_WIDTH-1:0] S_AXI_WSTRB = s_axi_wstrb; wire [C_AXI_ID_WIDTH-1:0] S_AXI_BID; wire [1:0] S_AXI_BRESP; wire [C_AXI_ID_WIDTH-1:0] S_AXI_ARID = s_axi_arid; wire [31:0] S_AXI_ARADDR = s_axi_araddr; wire [7:0] S_AXI_ARLEN = s_axi_arlen; wire [2:0] S_AXI_ARSIZE = s_axi_arsize; wire [1:0] S_AXI_ARBURST = s_axi_arburst; wire [C_AXI_ID_WIDTH-1:0] S_AXI_RID; wire [C_WRITE_WIDTH_B-1:0] S_AXI_RDATA; wire [1:0] S_AXI_RRESP; wire [C_ADDRB_WIDTH-1:0] S_AXI_RDADDRECC; // Added to fix the simulation warning #CR731605 wire [C_WEB_WIDTH-1:0] WEB_parameterized = 0; wire ECCPIPECE; wire SLEEP; assign CLKA = clka; assign RSTA = rsta; assign ENA = ena; assign REGCEA = regcea; assign CLKB = clkb; assign RSTB = rstb; assign ENB = enb; assign REGCEB = regceb; assign INJECTSBITERR = injectsbiterr; assign INJECTDBITERR = injectdbiterr; assign ECCPIPECE = eccpipece; assign SLEEP = sleep; assign sbiterr = SBITERR; assign dbiterr = DBITERR; assign S_ACLK = s_aclk; assign S_ARESETN = s_aresetn; assign S_AXI_AWVALID = s_axi_awvalid; assign s_axi_awready = S_AXI_AWREADY; assign S_AXI_WLAST = s_axi_wlast; assign S_AXI_WVALID = s_axi_wvalid; assign s_axi_wready = S_AXI_WREADY; assign s_axi_bvalid = S_AXI_BVALID; assign S_AXI_BREADY = s_axi_bready; assign S_AXI_ARVALID = s_axi_arvalid; assign s_axi_arready = S_AXI_ARREADY; assign s_axi_rlast = S_AXI_RLAST; assign s_axi_rvalid = S_AXI_RVALID; assign S_AXI_RREADY = s_axi_rready; assign S_AXI_INJECTSBITERR = s_axi_injectsbiterr; assign S_AXI_INJECTDBITERR = s_axi_injectdbiterr; assign s_axi_sbiterr = S_AXI_SBITERR; assign s_axi_dbiterr = S_AXI_DBITERR; assign doutb = DOUTB; assign douta = DOUTA; assign rdaddrecc = RDADDRECC; assign s_axi_bid = S_AXI_BID; assign s_axi_bresp = S_AXI_BRESP; assign s_axi_rid = S_AXI_RID; assign s_axi_rdata = S_AXI_RDATA; assign s_axi_rresp = S_AXI_RRESP; assign s_axi_rdaddrecc = S_AXI_RDADDRECC; localparam FLOP_DELAY = 100; // 100 ps reg injectsbiterr_in; reg injectdbiterr_in; reg rsta_in; reg ena_in; reg regcea_in; reg [C_WEA_WIDTH-1:0] wea_in; reg [C_ADDRA_WIDTH-1:0] addra_in; reg [C_WRITE_WIDTH_A-1:0] dina_in; wire [C_ADDRA_WIDTH-1:0] s_axi_awaddr_out_c; wire [C_ADDRB_WIDTH-1:0] s_axi_araddr_out_c; wire s_axi_wr_en_c; wire s_axi_rd_en_c; wire s_aresetn_a_c; wire [7:0] s_axi_arlen_c ; wire [C_AXI_ID_WIDTH-1 : 0] s_axi_rid_c; wire [C_WRITE_WIDTH_B-1 : 0] s_axi_rdata_c; wire [1:0] s_axi_rresp_c; wire s_axi_rlast_c; wire s_axi_rvalid_c; wire s_axi_rready_c; wire regceb_c; localparam C_AXI_PAYLOAD = (C_HAS_MUX_OUTPUT_REGS_B == 1)?C_WRITE_WIDTH_B+C_AXI_ID_WIDTH+3:C_AXI_ID_WIDTH+3; wire [C_AXI_PAYLOAD-1 : 0] s_axi_payload_c; wire [C_AXI_PAYLOAD-1 : 0] m_axi_payload_c; //************** // log2roundup //************** function integer log2roundup (input integer data_value); integer width; integer cnt; begin width = 0; if (data_value > 1) begin for(cnt=1 ; cnt < data_value ; cnt = cnt * 2) begin width = width + 1; end //loop end //if log2roundup = width; end //log2roundup endfunction //************** // log2int //************** function integer log2int (input integer data_value); integer width; integer cnt; begin width = 0; cnt= data_value; for(cnt=data_value ; cnt >1 ; cnt = cnt / 2) begin width = width + 1; end //loop log2int = width; end //log2int endfunction //************************************************************************** // FUNCTION : divroundup // Returns the ceiling value of the division // Data_value - the quantity to be divided, dividend // Divisor - the value to divide the data_value by //************************************************************************** function integer divroundup (input integer data_value,input integer divisor); integer div; begin div = data_value/divisor; if ((data_value % divisor) != 0) begin div = div+1; end //if divroundup = div; end //if endfunction localparam AXI_FULL_MEMORY_SLAVE = ((C_AXI_SLAVE_TYPE == 0 && C_AXI_TYPE == 1)?1:0); localparam C_AXI_ADDR_WIDTH_MSB = C_ADDRA_WIDTH+log2roundup(C_WRITE_WIDTH_A/8); localparam C_AXI_ADDR_WIDTH = C_AXI_ADDR_WIDTH_MSB; //Data Width Number of LSB address bits to be discarded //1 to 16 1 //17 to 32 2 //33 to 64 3 //65 to 128 4 //129 to 256 5 //257 to 512 6 //513 to 1024 7 // The following two constants determine this. localparam LOWER_BOUND_VAL = (log2roundup(divroundup(C_WRITE_WIDTH_A,8) == 0))?0:(log2roundup(divroundup(C_WRITE_WIDTH_A,8))); localparam C_AXI_ADDR_WIDTH_LSB = ((AXI_FULL_MEMORY_SLAVE == 1)?0:LOWER_BOUND_VAL); localparam C_AXI_OS_WR = 2; //*********************************************** // INPUT REGISTERS. //*********************************************** generate if (C_HAS_SOFTECC_INPUT_REGS_A==0) begin : no_softecc_input_reg_stage always @* begin injectsbiterr_in = INJECTSBITERR; injectdbiterr_in = INJECTDBITERR; rsta_in = RSTA; ena_in = ENA; regcea_in = REGCEA; wea_in = WEA; addra_in = ADDRA; dina_in = DINA; end //end always end //end no_softecc_input_reg_stage endgenerate generate if (C_HAS_SOFTECC_INPUT_REGS_A==1) begin : has_softecc_input_reg_stage always @(posedge CLKA) begin injectsbiterr_in <= #FLOP_DELAY INJECTSBITERR; injectdbiterr_in <= #FLOP_DELAY INJECTDBITERR; rsta_in <= #FLOP_DELAY RSTA; ena_in <= #FLOP_DELAY ENA; regcea_in <= #FLOP_DELAY REGCEA; wea_in <= #FLOP_DELAY WEA; addra_in <= #FLOP_DELAY ADDRA; dina_in <= #FLOP_DELAY DINA; end //end always end //end input_reg_stages generate statement endgenerate generate if ((C_INTERFACE_TYPE == 0) && (C_ENABLE_32BIT_ADDRESS == 0)) begin : native_mem_module BLK_MEM_GEN_v8_2_mem_module #(.C_CORENAME (C_CORENAME), .C_FAMILY (C_FAMILY), .C_XDEVICEFAMILY (C_XDEVICEFAMILY), .C_MEM_TYPE (C_MEM_TYPE), .C_BYTE_SIZE (C_BYTE_SIZE), .C_ALGORITHM (C_ALGORITHM), .C_USE_BRAM_BLOCK (C_USE_BRAM_BLOCK), .C_PRIM_TYPE (C_PRIM_TYPE), .C_LOAD_INIT_FILE (C_LOAD_INIT_FILE), .C_INIT_FILE_NAME (C_INIT_FILE_NAME), .C_INIT_FILE (C_INIT_FILE), .C_USE_DEFAULT_DATA (C_USE_DEFAULT_DATA), .C_DEFAULT_DATA (C_DEFAULT_DATA), .C_RST_TYPE ("SYNC"), .C_HAS_RSTA (C_HAS_RSTA), .C_RST_PRIORITY_A (C_RST_PRIORITY_A), .C_RSTRAM_A (C_RSTRAM_A), .C_INITA_VAL (C_INITA_VAL), .C_HAS_ENA (C_HAS_ENA), .C_HAS_REGCEA (C_HAS_REGCEA), .C_USE_BYTE_WEA (C_USE_BYTE_WEA), .C_WEA_WIDTH (C_WEA_WIDTH), .C_WRITE_MODE_A (C_WRITE_MODE_A), .C_WRITE_WIDTH_A (C_WRITE_WIDTH_A), .C_READ_WIDTH_A (C_READ_WIDTH_A), .C_WRITE_DEPTH_A (C_WRITE_DEPTH_A), .C_READ_DEPTH_A (C_READ_DEPTH_A), .C_ADDRA_WIDTH (C_ADDRA_WIDTH), .C_HAS_RSTB (C_HAS_RSTB), .C_RST_PRIORITY_B (C_RST_PRIORITY_B), .C_RSTRAM_B (C_RSTRAM_B), .C_INITB_VAL (C_INITB_VAL), .C_HAS_ENB (C_HAS_ENB), .C_HAS_REGCEB (C_HAS_REGCEB), .C_USE_BYTE_WEB (C_USE_BYTE_WEB), .C_WEB_WIDTH (C_WEB_WIDTH), .C_WRITE_MODE_B (C_WRITE_MODE_B), .C_WRITE_WIDTH_B (C_WRITE_WIDTH_B), .C_READ_WIDTH_B (C_READ_WIDTH_B), .C_WRITE_DEPTH_B (C_WRITE_DEPTH_B), .C_READ_DEPTH_B (C_READ_DEPTH_B), .C_ADDRB_WIDTH (C_ADDRB_WIDTH), .C_HAS_MEM_OUTPUT_REGS_A (C_HAS_MEM_OUTPUT_REGS_A), .C_HAS_MEM_OUTPUT_REGS_B (C_HAS_MEM_OUTPUT_REGS_B), .C_HAS_MUX_OUTPUT_REGS_A (C_HAS_MUX_OUTPUT_REGS_A), .C_HAS_MUX_OUTPUT_REGS_B (C_HAS_MUX_OUTPUT_REGS_B), .C_HAS_SOFTECC_INPUT_REGS_A (C_HAS_SOFTECC_INPUT_REGS_A), .C_HAS_SOFTECC_OUTPUT_REGS_B (C_HAS_SOFTECC_OUTPUT_REGS_B), .C_MUX_PIPELINE_STAGES (C_MUX_PIPELINE_STAGES), .C_USE_SOFTECC (C_USE_SOFTECC), .C_USE_ECC (C_USE_ECC), .C_HAS_INJECTERR (C_HAS_INJECTERR), .C_SIM_COLLISION_CHECK (C_SIM_COLLISION_CHECK), .C_COMMON_CLK (C_COMMON_CLK), .FLOP_DELAY (FLOP_DELAY), .C_DISABLE_WARN_BHV_COLL (C_DISABLE_WARN_BHV_COLL), .C_EN_ECC_PIPE (C_EN_ECC_PIPE), .C_DISABLE_WARN_BHV_RANGE (C_DISABLE_WARN_BHV_RANGE)) blk_mem_gen_v8_2_inst (.CLKA (CLKA), .RSTA (rsta_in), .ENA (ena_in), .REGCEA (regcea_in), .WEA (wea_in), .ADDRA (addra_in), .DINA (dina_in), .DOUTA (DOUTA), .CLKB (CLKB), .RSTB (RSTB), .ENB (ENB), .REGCEB (REGCEB), .WEB (WEB), .ADDRB (ADDRB), .DINB (DINB), .DOUTB (DOUTB), .INJECTSBITERR (injectsbiterr_in), .INJECTDBITERR (injectdbiterr_in), .ECCPIPECE (ECCPIPECE), .SLEEP (SLEEP), .SBITERR (SBITERR), .DBITERR (DBITERR), .RDADDRECC (RDADDRECC) ); end endgenerate generate if((C_INTERFACE_TYPE == 0) && (C_ENABLE_32BIT_ADDRESS == 1)) begin : native_mem_mapped_module localparam C_ADDRA_WIDTH_ACTUAL = log2roundup(C_WRITE_DEPTH_A); localparam C_ADDRB_WIDTH_ACTUAL = log2roundup(C_WRITE_DEPTH_B); localparam C_ADDRA_WIDTH_MSB = C_ADDRA_WIDTH_ACTUAL+log2int(C_WRITE_WIDTH_A/8); localparam C_ADDRB_WIDTH_MSB = C_ADDRB_WIDTH_ACTUAL+log2int(C_WRITE_WIDTH_B/8); // localparam C_ADDRA_WIDTH_MSB = C_ADDRA_WIDTH_ACTUAL+log2roundup(C_WRITE_WIDTH_A/8); // localparam C_ADDRB_WIDTH_MSB = C_ADDRB_WIDTH_ACTUAL+log2roundup(C_WRITE_WIDTH_B/8); localparam C_MEM_MAP_ADDRA_WIDTH_MSB = C_ADDRA_WIDTH_MSB; localparam C_MEM_MAP_ADDRB_WIDTH_MSB = C_ADDRB_WIDTH_MSB; // Data Width Number of LSB address bits to be discarded // 1 to 16 1 // 17 to 32 2 // 33 to 64 3 // 65 to 128 4 // 129 to 256 5 // 257 to 512 6 // 513 to 1024 7 // The following two constants determine this. localparam MEM_MAP_LOWER_BOUND_VAL_A = (log2int(divroundup(C_WRITE_WIDTH_A,8)==0)) ? 0:(log2int(divroundup(C_WRITE_WIDTH_A,8))); localparam MEM_MAP_LOWER_BOUND_VAL_B = (log2int(divroundup(C_WRITE_WIDTH_A,8)==0)) ? 0:(log2int(divroundup(C_WRITE_WIDTH_A,8))); localparam C_MEM_MAP_ADDRA_WIDTH_LSB = MEM_MAP_LOWER_BOUND_VAL_A; localparam C_MEM_MAP_ADDRB_WIDTH_LSB = MEM_MAP_LOWER_BOUND_VAL_B; wire [C_ADDRB_WIDTH_ACTUAL-1 :0] rdaddrecc_i; wire [C_ADDRB_WIDTH-1:C_MEM_MAP_ADDRB_WIDTH_MSB] msb_zero_i; wire [C_MEM_MAP_ADDRB_WIDTH_LSB-1:0] lsb_zero_i; assign msb_zero_i = 0; assign lsb_zero_i = 0; assign RDADDRECC = {msb_zero_i,rdaddrecc_i,lsb_zero_i}; BLK_MEM_GEN_v8_2_mem_module #(.C_CORENAME (C_CORENAME), .C_FAMILY (C_FAMILY), .C_XDEVICEFAMILY (C_XDEVICEFAMILY), .C_MEM_TYPE (C_MEM_TYPE), .C_BYTE_SIZE (C_BYTE_SIZE), .C_USE_BRAM_BLOCK (C_USE_BRAM_BLOCK), .C_ALGORITHM (C_ALGORITHM), .C_PRIM_TYPE (C_PRIM_TYPE), .C_LOAD_INIT_FILE (C_LOAD_INIT_FILE), .C_INIT_FILE_NAME (C_INIT_FILE_NAME), .C_INIT_FILE (C_INIT_FILE), .C_USE_DEFAULT_DATA (C_USE_DEFAULT_DATA), .C_DEFAULT_DATA (C_DEFAULT_DATA), .C_RST_TYPE ("SYNC"), .C_HAS_RSTA (C_HAS_RSTA), .C_RST_PRIORITY_A (C_RST_PRIORITY_A), .C_RSTRAM_A (C_RSTRAM_A), .C_INITA_VAL (C_INITA_VAL), .C_HAS_ENA (C_HAS_ENA), .C_HAS_REGCEA (C_HAS_REGCEA), .C_USE_BYTE_WEA (C_USE_BYTE_WEA), .C_WEA_WIDTH (C_WEA_WIDTH), .C_WRITE_MODE_A (C_WRITE_MODE_A), .C_WRITE_WIDTH_A (C_WRITE_WIDTH_A), .C_READ_WIDTH_A (C_READ_WIDTH_A), .C_WRITE_DEPTH_A (C_WRITE_DEPTH_A), .C_READ_DEPTH_A (C_READ_DEPTH_A), .C_ADDRA_WIDTH (C_ADDRA_WIDTH_ACTUAL), .C_HAS_RSTB (C_HAS_RSTB), .C_RST_PRIORITY_B (C_RST_PRIORITY_B), .C_RSTRAM_B (C_RSTRAM_B), .C_INITB_VAL (C_INITB_VAL), .C_HAS_ENB (C_HAS_ENB), .C_HAS_REGCEB (C_HAS_REGCEB), .C_USE_BYTE_WEB (C_USE_BYTE_WEB), .C_WEB_WIDTH (C_WEB_WIDTH), .C_WRITE_MODE_B (C_WRITE_MODE_B), .C_WRITE_WIDTH_B (C_WRITE_WIDTH_B), .C_READ_WIDTH_B (C_READ_WIDTH_B), .C_WRITE_DEPTH_B (C_WRITE_DEPTH_B), .C_READ_DEPTH_B (C_READ_DEPTH_B), .C_ADDRB_WIDTH (C_ADDRB_WIDTH_ACTUAL), .C_HAS_MEM_OUTPUT_REGS_A (C_HAS_MEM_OUTPUT_REGS_A), .C_HAS_MEM_OUTPUT_REGS_B (C_HAS_MEM_OUTPUT_REGS_B), .C_HAS_MUX_OUTPUT_REGS_A (C_HAS_MUX_OUTPUT_REGS_A), .C_HAS_MUX_OUTPUT_REGS_B (C_HAS_MUX_OUTPUT_REGS_B), .C_HAS_SOFTECC_INPUT_REGS_A (C_HAS_SOFTECC_INPUT_REGS_A), .C_HAS_SOFTECC_OUTPUT_REGS_B (C_HAS_SOFTECC_OUTPUT_REGS_B), .C_MUX_PIPELINE_STAGES (C_MUX_PIPELINE_STAGES), .C_USE_SOFTECC (C_USE_SOFTECC), .C_USE_ECC (C_USE_ECC), .C_HAS_INJECTERR (C_HAS_INJECTERR), .C_SIM_COLLISION_CHECK (C_SIM_COLLISION_CHECK), .C_COMMON_CLK (C_COMMON_CLK), .FLOP_DELAY (FLOP_DELAY), .C_DISABLE_WARN_BHV_COLL (C_DISABLE_WARN_BHV_COLL), .C_EN_ECC_PIPE (C_EN_ECC_PIPE), .C_DISABLE_WARN_BHV_RANGE (C_DISABLE_WARN_BHV_RANGE)) blk_mem_gen_v8_2_inst (.CLKA (CLKA), .RSTA (rsta_in), .ENA (ena_in), .REGCEA (regcea_in), .WEA (wea_in), .ADDRA (addra_in[C_MEM_MAP_ADDRA_WIDTH_MSB-1:C_MEM_MAP_ADDRA_WIDTH_LSB]), .DINA (dina_in), .DOUTA (DOUTA), .CLKB (CLKB), .RSTB (RSTB), .ENB (ENB), .REGCEB (REGCEB), .WEB (WEB), .ADDRB (ADDRB[C_MEM_MAP_ADDRB_WIDTH_MSB-1:C_MEM_MAP_ADDRB_WIDTH_LSB]), .DINB (DINB), .DOUTB (DOUTB), .INJECTSBITERR (injectsbiterr_in), .INJECTDBITERR (injectdbiterr_in), .ECCPIPECE (ECCPIPECE), .SLEEP (SLEEP), .SBITERR (SBITERR), .DBITERR (DBITERR), .RDADDRECC (rdaddrecc_i) ); end endgenerate generate if (C_HAS_MEM_OUTPUT_REGS_B == 0 && C_HAS_MUX_OUTPUT_REGS_B == 0 ) begin : no_regs assign S_AXI_RDATA = s_axi_rdata_c; assign S_AXI_RLAST = s_axi_rlast_c; assign S_AXI_RVALID = s_axi_rvalid_c; assign S_AXI_RID = s_axi_rid_c; assign S_AXI_RRESP = s_axi_rresp_c; assign s_axi_rready_c = S_AXI_RREADY; end endgenerate generate if (C_HAS_MEM_OUTPUT_REGS_B == 1) begin : has_regceb assign regceb_c = s_axi_rvalid_c && s_axi_rready_c; end endgenerate generate if (C_HAS_MEM_OUTPUT_REGS_B == 0) begin : no_regceb assign regceb_c = REGCEB; end endgenerate generate if (C_HAS_MUX_OUTPUT_REGS_B == 1) begin : only_core_op_regs assign s_axi_payload_c = {s_axi_rid_c,s_axi_rdata_c,s_axi_rresp_c,s_axi_rlast_c}; assign S_AXI_RID = m_axi_payload_c[C_AXI_PAYLOAD-1 : C_AXI_PAYLOAD-C_AXI_ID_WIDTH]; assign S_AXI_RDATA = m_axi_payload_c[C_AXI_PAYLOAD-C_AXI_ID_WIDTH-1 : C_AXI_PAYLOAD-C_AXI_ID_WIDTH-C_WRITE_WIDTH_B]; assign S_AXI_RRESP = m_axi_payload_c[2:1]; assign S_AXI_RLAST = m_axi_payload_c[0]; end endgenerate generate if (C_HAS_MEM_OUTPUT_REGS_B == 1) begin : only_emb_op_regs assign s_axi_payload_c = {s_axi_rid_c,s_axi_rresp_c,s_axi_rlast_c}; assign S_AXI_RDATA = s_axi_rdata_c; assign S_AXI_RID = m_axi_payload_c[C_AXI_PAYLOAD-1 : C_AXI_PAYLOAD-C_AXI_ID_WIDTH]; assign S_AXI_RRESP = m_axi_payload_c[2:1]; assign S_AXI_RLAST = m_axi_payload_c[0]; end endgenerate generate if (C_HAS_MUX_OUTPUT_REGS_B == 1 || C_HAS_MEM_OUTPUT_REGS_B == 1) begin : has_regs_fwd blk_mem_axi_regs_fwd_v8_2 #(.C_DATA_WIDTH (C_AXI_PAYLOAD)) axi_regs_inst ( .ACLK (S_ACLK), .ARESET (s_aresetn_a_c), .S_VALID (s_axi_rvalid_c), .S_READY (s_axi_rready_c), .S_PAYLOAD_DATA (s_axi_payload_c), .M_VALID (S_AXI_RVALID), .M_READY (S_AXI_RREADY), .M_PAYLOAD_DATA (m_axi_payload_c) ); end endgenerate generate if (C_INTERFACE_TYPE == 1) begin : axi_mem_module assign s_aresetn_a_c = !S_ARESETN; assign S_AXI_BRESP = 2'b00; assign s_axi_rresp_c = 2'b00; assign s_axi_arlen_c = (C_AXI_TYPE == 1)?S_AXI_ARLEN:8'h0; blk_mem_axi_write_wrapper_beh_v8_2 #(.C_INTERFACE_TYPE (C_INTERFACE_TYPE), .C_AXI_TYPE (C_AXI_TYPE), .C_AXI_SLAVE_TYPE (C_AXI_SLAVE_TYPE), .C_MEMORY_TYPE (C_MEM_TYPE), .C_WRITE_DEPTH_A (C_WRITE_DEPTH_A), .C_AXI_AWADDR_WIDTH ((AXI_FULL_MEMORY_SLAVE == 1)?C_AXI_ADDR_WIDTH:C_AXI_ADDR_WIDTH-C_AXI_ADDR_WIDTH_LSB), .C_HAS_AXI_ID (C_HAS_AXI_ID), .C_AXI_ID_WIDTH (C_AXI_ID_WIDTH), .C_ADDRA_WIDTH (C_ADDRA_WIDTH), .C_AXI_WDATA_WIDTH (C_WRITE_WIDTH_A), .C_AXI_OS_WR (C_AXI_OS_WR)) axi_wr_fsm ( // AXI Global Signals .S_ACLK (S_ACLK), .S_ARESETN (s_aresetn_a_c), // AXI Full/Lite Slave Write interface .S_AXI_AWADDR (S_AXI_AWADDR[C_AXI_ADDR_WIDTH_MSB-1:C_AXI_ADDR_WIDTH_LSB]), .S_AXI_AWLEN (S_AXI_AWLEN), .S_AXI_AWID (S_AXI_AWID), .S_AXI_AWSIZE (S_AXI_AWSIZE), .S_AXI_AWBURST (S_AXI_AWBURST), .S_AXI_AWVALID (S_AXI_AWVALID), .S_AXI_AWREADY (S_AXI_AWREADY), .S_AXI_WVALID (S_AXI_WVALID), .S_AXI_WREADY (S_AXI_WREADY), .S_AXI_BVALID (S_AXI_BVALID), .S_AXI_BREADY (S_AXI_BREADY), .S_AXI_BID (S_AXI_BID), // Signals for BRAM interfac( .S_AXI_AWADDR_OUT (s_axi_awaddr_out_c), .S_AXI_WR_EN (s_axi_wr_en_c) ); blk_mem_axi_read_wrapper_beh_v8_2 #(.C_INTERFACE_TYPE (C_INTERFACE_TYPE), .C_AXI_TYPE (C_AXI_TYPE), .C_AXI_SLAVE_TYPE (C_AXI_SLAVE_TYPE), .C_MEMORY_TYPE (C_MEM_TYPE), .C_WRITE_WIDTH_A (C_WRITE_WIDTH_A), .C_ADDRA_WIDTH (C_ADDRA_WIDTH), .C_AXI_PIPELINE_STAGES (1), .C_AXI_ARADDR_WIDTH ((AXI_FULL_MEMORY_SLAVE == 1)?C_AXI_ADDR_WIDTH:C_AXI_ADDR_WIDTH-C_AXI_ADDR_WIDTH_LSB), .C_HAS_AXI_ID (C_HAS_AXI_ID), .C_AXI_ID_WIDTH (C_AXI_ID_WIDTH), .C_ADDRB_WIDTH (C_ADDRB_WIDTH)) axi_rd_sm( //AXI Global Signals .S_ACLK (S_ACLK), .S_ARESETN (s_aresetn_a_c), //AXI Full/Lite Read Side .S_AXI_ARADDR (S_AXI_ARADDR[C_AXI_ADDR_WIDTH_MSB-1:C_AXI_ADDR_WIDTH_LSB]), .S_AXI_ARLEN (s_axi_arlen_c), .S_AXI_ARSIZE (S_AXI_ARSIZE), .S_AXI_ARBURST (S_AXI_ARBURST), .S_AXI_ARVALID (S_AXI_ARVALID), .S_AXI_ARREADY (S_AXI_ARREADY), .S_AXI_RLAST (s_axi_rlast_c), .S_AXI_RVALID (s_axi_rvalid_c), .S_AXI_RREADY (s_axi_rready_c), .S_AXI_ARID (S_AXI_ARID), .S_AXI_RID (s_axi_rid_c), //AXI Full/Lite Read FSM Outputs .S_AXI_ARADDR_OUT (s_axi_araddr_out_c), .S_AXI_RD_EN (s_axi_rd_en_c) ); BLK_MEM_GEN_v8_2_mem_module #(.C_CORENAME (C_CORENAME), .C_FAMILY (C_FAMILY), .C_XDEVICEFAMILY (C_XDEVICEFAMILY), .C_MEM_TYPE (C_MEM_TYPE), .C_BYTE_SIZE (C_BYTE_SIZE), .C_USE_BRAM_BLOCK (C_USE_BRAM_BLOCK), .C_ALGORITHM (C_ALGORITHM), .C_PRIM_TYPE (C_PRIM_TYPE), .C_LOAD_INIT_FILE (C_LOAD_INIT_FILE), .C_INIT_FILE_NAME (C_INIT_FILE_NAME), .C_INIT_FILE (C_INIT_FILE), .C_USE_DEFAULT_DATA (C_USE_DEFAULT_DATA), .C_DEFAULT_DATA (C_DEFAULT_DATA), .C_RST_TYPE ("SYNC"), .C_HAS_RSTA (C_HAS_RSTA), .C_RST_PRIORITY_A (C_RST_PRIORITY_A), .C_RSTRAM_A (C_RSTRAM_A), .C_INITA_VAL (C_INITA_VAL), .C_HAS_ENA (1), .C_HAS_REGCEA (C_HAS_REGCEA), .C_USE_BYTE_WEA (1), .C_WEA_WIDTH (C_WEA_WIDTH), .C_WRITE_MODE_A (C_WRITE_MODE_A), .C_WRITE_WIDTH_A (C_WRITE_WIDTH_A), .C_READ_WIDTH_A (C_READ_WIDTH_A), .C_WRITE_DEPTH_A (C_WRITE_DEPTH_A), .C_READ_DEPTH_A (C_READ_DEPTH_A), .C_ADDRA_WIDTH (C_ADDRA_WIDTH), .C_HAS_RSTB (C_HAS_RSTB), .C_RST_PRIORITY_B (C_RST_PRIORITY_B), .C_RSTRAM_B (C_RSTRAM_B), .C_INITB_VAL (C_INITB_VAL), .C_HAS_ENB (1), .C_HAS_REGCEB (C_HAS_MEM_OUTPUT_REGS_B), .C_USE_BYTE_WEB (1), .C_WEB_WIDTH (C_WEB_WIDTH), .C_WRITE_MODE_B (C_WRITE_MODE_B), .C_WRITE_WIDTH_B (C_WRITE_WIDTH_B), .C_READ_WIDTH_B (C_READ_WIDTH_B), .C_WRITE_DEPTH_B (C_WRITE_DEPTH_B), .C_READ_DEPTH_B (C_READ_DEPTH_B), .C_ADDRB_WIDTH (C_ADDRB_WIDTH), .C_HAS_MEM_OUTPUT_REGS_A (0), .C_HAS_MEM_OUTPUT_REGS_B (C_HAS_MEM_OUTPUT_REGS_B), .C_HAS_MUX_OUTPUT_REGS_A (0), .C_HAS_MUX_OUTPUT_REGS_B (0), .C_HAS_SOFTECC_INPUT_REGS_A (C_HAS_SOFTECC_INPUT_REGS_A), .C_HAS_SOFTECC_OUTPUT_REGS_B (C_HAS_SOFTECC_OUTPUT_REGS_B), .C_MUX_PIPELINE_STAGES (C_MUX_PIPELINE_STAGES), .C_USE_SOFTECC (C_USE_SOFTECC), .C_USE_ECC (C_USE_ECC), .C_HAS_INJECTERR (C_HAS_INJECTERR), .C_SIM_COLLISION_CHECK (C_SIM_COLLISION_CHECK), .C_COMMON_CLK (C_COMMON_CLK), .FLOP_DELAY (FLOP_DELAY), .C_DISABLE_WARN_BHV_COLL (C_DISABLE_WARN_BHV_COLL), .C_EN_ECC_PIPE (0), .C_DISABLE_WARN_BHV_RANGE (C_DISABLE_WARN_BHV_RANGE)) blk_mem_gen_v8_2_inst (.CLKA (S_ACLK), .RSTA (s_aresetn_a_c), .ENA (s_axi_wr_en_c), .REGCEA (regcea_in), .WEA (S_AXI_WSTRB), .ADDRA (s_axi_awaddr_out_c), .DINA (S_AXI_WDATA), .DOUTA (DOUTA), .CLKB (S_ACLK), .RSTB (s_aresetn_a_c), .ENB (s_axi_rd_en_c), .REGCEB (regceb_c), .WEB (WEB_parameterized), .ADDRB (s_axi_araddr_out_c), .DINB (DINB), .DOUTB (s_axi_rdata_c), .INJECTSBITERR (injectsbiterr_in), .INJECTDBITERR (injectdbiterr_in), .SBITERR (SBITERR), .DBITERR (DBITERR), .ECCPIPECE (1'b0), .SLEEP (1'b0), .RDADDRECC (RDADDRECC) ); end endgenerate endmodule
/****************************************************************************** -- (c) Copyright 2006 - 2013 Xilinx, Inc. All rights reserved. -- -- This file contains confidential and proprietary information -- of Xilinx, Inc. and is protected under U.S. and -- international copyright and other intellectual property -- laws. -- -- DISCLAIMER -- This disclaimer is not a license and does not grant any -- rights to the materials distributed herewith. Except as -- otherwise provided in a valid license issued to you by -- Xilinx, and to the maximum extent permitted by applicable -- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND -- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES -- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING -- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- -- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and -- (2) Xilinx shall not be liable (whether in contract or tort, -- including negligence, or under any other theory of -- liability) for any loss or damage of any kind or nature -- related to, arising under or in connection with these -- materials, including for any direct, or any indirect, -- special, incidental, or consequential loss or damage -- (including loss of data, profits, goodwill, or any type of -- loss or damage suffered as a result of any action brought -- by a third party) even if such damage or loss was -- reasonably foreseeable or Xilinx had been advised of the -- possibility of the same. -- -- CRITICAL APPLICATIONS -- Xilinx products are not designed or intended to be fail- -- safe, or for use in any application requiring fail-safe -- performance, such as life-support or safety devices or -- systems, Class III medical devices, nuclear facilities, -- applications related to the deployment of airbags, or any -- other applications that could lead to death, personal -- injury, or severe property or environmental damage -- (individually and collectively, "Critical -- Applications"). Customer assumes the sole risk and -- liability of any use of Xilinx products in Critical -- Applications, subject only to applicable laws and -- regulations governing limitations on product liability. -- -- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS -- PART OF THIS FILE AT ALL TIMES. -- ***************************************************************************** * * Filename: BLK_MEM_GEN_v8_2.v * * Description: * This file is the Verilog behvarial model for the * Block Memory Generator Core. * ***************************************************************************** * Author: Xilinx * * History: Jan 11, 2006 Initial revision * Jun 11, 2007 Added independent register stages for * Port A and Port B (IP1_Jm/v2.5) * Aug 28, 2007 Added mux pipeline stages feature (IP2_Jm/v2.6) * Mar 13, 2008 Behavioral model optimizations * April 07, 2009 : Added support for Spartan-6 and Virtex-6 * features, including the following: * (i) error injection, detection and/or correction * (ii) reset priority * (iii) special reset behavior * *****************************************************************************/ `timescale 1ps/1ps module STATE_LOGIC_v8_2 (O, I0, I1, I2, I3, I4, I5); parameter INIT = 64'h0000000000000000; input I0, I1, I2, I3, I4, I5; output O; reg O; reg tmp; always @( I5 or I4 or I3 or I2 or I1 or I0 ) begin tmp = I0 ^ I1 ^ I2 ^ I3 ^ I4 ^ I5; if ( tmp == 0 || tmp == 1) O = INIT[{I5, I4, I3, I2, I1, I0}]; end endmodule module beh_vlog_muxf7_v8_2 (O, I0, I1, S); output O; reg O; input I0, I1, S; always @(I0 or I1 or S) if (S) O = I1; else O = I0; endmodule module beh_vlog_ff_clr_v8_2 (Q, C, CLR, D); parameter INIT = 0; localparam FLOP_DELAY = 100; output Q; input C, CLR, D; reg Q; initial Q= 1'b0; always @(posedge C ) if (CLR) Q<= 1'b0; else Q<= #FLOP_DELAY D; endmodule module beh_vlog_ff_pre_v8_2 (Q, C, D, PRE); parameter INIT = 0; localparam FLOP_DELAY = 100; output Q; input C, D, PRE; reg Q; initial Q= 1'b0; always @(posedge C ) if (PRE) Q <= 1'b1; else Q <= #FLOP_DELAY D; endmodule module beh_vlog_ff_ce_clr_v8_2 (Q, C, CE, CLR, D); parameter INIT = 0; localparam FLOP_DELAY = 100; output Q; input C, CE, CLR, D; reg Q; initial Q= 1'b0; always @(posedge C ) if (CLR) Q <= 1'b0; else if (CE) Q <= #FLOP_DELAY D; endmodule module write_netlist_v8_2 #( parameter C_AXI_TYPE = 0 ) ( S_ACLK, S_ARESETN, S_AXI_AWVALID, S_AXI_WVALID, S_AXI_BREADY, w_last_c, bready_timeout_c, aw_ready_r, S_AXI_WREADY, S_AXI_BVALID, S_AXI_WR_EN, addr_en_c, incr_addr_c, bvalid_c ); input S_ACLK; input S_ARESETN; input S_AXI_AWVALID; input S_AXI_WVALID; input S_AXI_BREADY; input w_last_c; input bready_timeout_c; output aw_ready_r; output S_AXI_WREADY; output S_AXI_BVALID; output S_AXI_WR_EN; output addr_en_c; output incr_addr_c; output bvalid_c; //------------------------------------------------------------------------- //AXI LITE //------------------------------------------------------------------------- generate if (C_AXI_TYPE == 0 ) begin : gbeh_axi_lite_sm wire w_ready_r_7; wire w_ready_c; wire aw_ready_c; wire NlwRenamedSignal_bvalid_c; wire NlwRenamedSignal_incr_addr_c; wire present_state_FSM_FFd3_13; wire present_state_FSM_FFd2_14; wire present_state_FSM_FFd1_15; wire present_state_FSM_FFd4_16; wire present_state_FSM_FFd4_In; wire present_state_FSM_FFd3_In; wire present_state_FSM_FFd2_In; wire present_state_FSM_FFd1_In; wire present_state_FSM_FFd4_In1_21; wire [0:0] Mmux_aw_ready_c ; begin assign S_AXI_WREADY = w_ready_r_7, S_AXI_BVALID = NlwRenamedSignal_incr_addr_c, S_AXI_WR_EN = NlwRenamedSignal_bvalid_c, incr_addr_c = NlwRenamedSignal_incr_addr_c, bvalid_c = NlwRenamedSignal_bvalid_c; assign NlwRenamedSignal_incr_addr_c = 1'b0; beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) aw_ready_r_2 ( .C ( S_ACLK), .CLR ( S_ARESETN), .D ( aw_ready_c), .Q ( aw_ready_r) ); beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) w_ready_r ( .C ( S_ACLK), .CLR ( S_ARESETN), .D ( w_ready_c), .Q ( w_ready_r_7) ); beh_vlog_ff_pre_v8_2 #( .INIT (1'b1)) present_state_FSM_FFd4 ( .C ( S_ACLK), .D ( present_state_FSM_FFd4_In), .PRE ( S_ARESETN), .Q ( present_state_FSM_FFd4_16) ); beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) present_state_FSM_FFd3 ( .C ( S_ACLK), .CLR ( S_ARESETN), .D ( present_state_FSM_FFd3_In), .Q ( present_state_FSM_FFd3_13) ); beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) present_state_FSM_FFd2 ( .C ( S_ACLK), .CLR ( S_ARESETN), .D ( present_state_FSM_FFd2_In), .Q ( present_state_FSM_FFd2_14) ); beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) present_state_FSM_FFd1 ( .C ( S_ACLK), .CLR ( S_ARESETN), .D ( present_state_FSM_FFd1_In), .Q ( present_state_FSM_FFd1_15) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000055554440)) present_state_FSM_FFd3_In1 ( .I0 ( S_AXI_WVALID), .I1 ( S_AXI_AWVALID), .I2 ( present_state_FSM_FFd2_14), .I3 ( present_state_FSM_FFd4_16), .I4 ( present_state_FSM_FFd3_13), .I5 (1'b0), .O ( present_state_FSM_FFd3_In) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000088880800)) present_state_FSM_FFd2_In1 ( .I0 ( S_AXI_AWVALID), .I1 ( S_AXI_WVALID), .I2 ( bready_timeout_c), .I3 ( present_state_FSM_FFd2_14), .I4 ( present_state_FSM_FFd4_16), .I5 (1'b0), .O ( present_state_FSM_FFd2_In) ); STATE_LOGIC_v8_2 #( .INIT (64'h00000000AAAA2000)) Mmux_addr_en_c_0_1 ( .I0 ( S_AXI_AWVALID), .I1 ( bready_timeout_c), .I2 ( present_state_FSM_FFd2_14), .I3 ( S_AXI_WVALID), .I4 ( present_state_FSM_FFd4_16), .I5 (1'b0), .O ( addr_en_c) ); STATE_LOGIC_v8_2 #( .INIT (64'hF5F07570F5F05500)) Mmux_w_ready_c_0_1 ( .I0 ( S_AXI_WVALID), .I1 ( bready_timeout_c), .I2 ( S_AXI_AWVALID), .I3 ( present_state_FSM_FFd3_13), .I4 ( present_state_FSM_FFd4_16), .I5 ( present_state_FSM_FFd2_14), .O ( w_ready_c) ); STATE_LOGIC_v8_2 #( .INIT (64'h88808880FFFF8880)) present_state_FSM_FFd1_In1 ( .I0 ( S_AXI_WVALID), .I1 ( bready_timeout_c), .I2 ( present_state_FSM_FFd3_13), .I3 ( present_state_FSM_FFd2_14), .I4 ( present_state_FSM_FFd1_15), .I5 ( S_AXI_BREADY), .O ( present_state_FSM_FFd1_In) ); STATE_LOGIC_v8_2 #( .INIT (64'h00000000000000A8)) Mmux_S_AXI_WR_EN_0_1 ( .I0 ( S_AXI_WVALID), .I1 ( present_state_FSM_FFd2_14), .I2 ( present_state_FSM_FFd3_13), .I3 (1'b0), .I4 (1'b0), .I5 (1'b0), .O ( NlwRenamedSignal_bvalid_c) ); STATE_LOGIC_v8_2 #( .INIT (64'h2F0F27072F0F2200)) present_state_FSM_FFd4_In1 ( .I0 ( S_AXI_WVALID), .I1 ( bready_timeout_c), .I2 ( S_AXI_AWVALID), .I3 ( present_state_FSM_FFd3_13), .I4 ( present_state_FSM_FFd4_16), .I5 ( present_state_FSM_FFd2_14), .O ( present_state_FSM_FFd4_In1_21) ); STATE_LOGIC_v8_2 #( .INIT (64'h00000000000000F8)) present_state_FSM_FFd4_In2 ( .I0 ( present_state_FSM_FFd1_15), .I1 ( S_AXI_BREADY), .I2 ( present_state_FSM_FFd4_In1_21), .I3 (1'b0), .I4 (1'b0), .I5 (1'b0), .O ( present_state_FSM_FFd4_In) ); STATE_LOGIC_v8_2 #( .INIT (64'h7535753575305500)) Mmux_aw_ready_c_0_1 ( .I0 ( S_AXI_AWVALID), .I1 ( bready_timeout_c), .I2 ( S_AXI_WVALID), .I3 ( present_state_FSM_FFd4_16), .I4 ( present_state_FSM_FFd3_13), .I5 ( present_state_FSM_FFd2_14), .O ( Mmux_aw_ready_c[0]) ); STATE_LOGIC_v8_2 #( .INIT (64'h00000000000000F8)) Mmux_aw_ready_c_0_2 ( .I0 ( present_state_FSM_FFd1_15), .I1 ( S_AXI_BREADY), .I2 ( Mmux_aw_ready_c[0]), .I3 (1'b0), .I4 (1'b0), .I5 (1'b0), .O ( aw_ready_c) ); end end endgenerate //--------------------------------------------------------------------- // AXI FULL //--------------------------------------------------------------------- generate if (C_AXI_TYPE == 1 ) begin : gbeh_axi_full_sm wire w_ready_r_8; wire w_ready_c; wire aw_ready_c; wire NlwRenamedSig_OI_bvalid_c; wire present_state_FSM_FFd1_16; wire present_state_FSM_FFd4_17; wire present_state_FSM_FFd3_18; wire present_state_FSM_FFd2_19; wire present_state_FSM_FFd4_In; wire present_state_FSM_FFd3_In; wire present_state_FSM_FFd2_In; wire present_state_FSM_FFd1_In; wire present_state_FSM_FFd2_In1_24; wire present_state_FSM_FFd4_In1_25; wire N2; wire N4; begin assign S_AXI_WREADY = w_ready_r_8, bvalid_c = NlwRenamedSig_OI_bvalid_c, S_AXI_BVALID = 1'b0; beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) aw_ready_r_2 ( .C ( S_ACLK), .CLR ( S_ARESETN), .D ( aw_ready_c), .Q ( aw_ready_r) ); beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) w_ready_r ( .C ( S_ACLK), .CLR ( S_ARESETN), .D ( w_ready_c), .Q ( w_ready_r_8) ); beh_vlog_ff_pre_v8_2 #( .INIT (1'b1)) present_state_FSM_FFd4 ( .C ( S_ACLK), .D ( present_state_FSM_FFd4_In), .PRE ( S_ARESETN), .Q ( present_state_FSM_FFd4_17) ); beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) present_state_FSM_FFd3 ( .C ( S_ACLK), .CLR ( S_ARESETN), .D ( present_state_FSM_FFd3_In), .Q ( present_state_FSM_FFd3_18) ); beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) present_state_FSM_FFd2 ( .C ( S_ACLK), .CLR ( S_ARESETN), .D ( present_state_FSM_FFd2_In), .Q ( present_state_FSM_FFd2_19) ); beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) present_state_FSM_FFd1 ( .C ( S_ACLK), .CLR ( S_ARESETN), .D ( present_state_FSM_FFd1_In), .Q ( present_state_FSM_FFd1_16) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000000005540)) present_state_FSM_FFd3_In1 ( .I0 ( S_AXI_WVALID), .I1 ( present_state_FSM_FFd4_17), .I2 ( S_AXI_AWVALID), .I3 ( present_state_FSM_FFd3_18), .I4 (1'b0), .I5 (1'b0), .O ( present_state_FSM_FFd3_In) ); STATE_LOGIC_v8_2 #( .INIT (64'hBF3FBB33AF0FAA00)) Mmux_aw_ready_c_0_2 ( .I0 ( S_AXI_BREADY), .I1 ( bready_timeout_c), .I2 ( S_AXI_AWVALID), .I3 ( present_state_FSM_FFd1_16), .I4 ( present_state_FSM_FFd4_17), .I5 ( NlwRenamedSig_OI_bvalid_c), .O ( aw_ready_c) ); STATE_LOGIC_v8_2 #( .INIT (64'hAAAAAAAA20000000)) Mmux_addr_en_c_0_1 ( .I0 ( S_AXI_AWVALID), .I1 ( bready_timeout_c), .I2 ( present_state_FSM_FFd2_19), .I3 ( S_AXI_WVALID), .I4 ( w_last_c), .I5 ( present_state_FSM_FFd4_17), .O ( addr_en_c) ); STATE_LOGIC_v8_2 #( .INIT (64'h00000000000000A8)) Mmux_S_AXI_WR_EN_0_1 ( .I0 ( S_AXI_WVALID), .I1 ( present_state_FSM_FFd2_19), .I2 ( present_state_FSM_FFd3_18), .I3 (1'b0), .I4 (1'b0), .I5 (1'b0), .O ( S_AXI_WR_EN) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000000002220)) Mmux_incr_addr_c_0_1 ( .I0 ( S_AXI_WVALID), .I1 ( w_last_c), .I2 ( present_state_FSM_FFd2_19), .I3 ( present_state_FSM_FFd3_18), .I4 (1'b0), .I5 (1'b0), .O ( incr_addr_c) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000000008880)) Mmux_aw_ready_c_0_11 ( .I0 ( S_AXI_WVALID), .I1 ( w_last_c), .I2 ( present_state_FSM_FFd2_19), .I3 ( present_state_FSM_FFd3_18), .I4 (1'b0), .I5 (1'b0), .O ( NlwRenamedSig_OI_bvalid_c) ); STATE_LOGIC_v8_2 #( .INIT (64'h000000000000D5C0)) present_state_FSM_FFd2_In1 ( .I0 ( w_last_c), .I1 ( S_AXI_AWVALID), .I2 ( present_state_FSM_FFd4_17), .I3 ( present_state_FSM_FFd3_18), .I4 (1'b0), .I5 (1'b0), .O ( present_state_FSM_FFd2_In1_24) ); STATE_LOGIC_v8_2 #( .INIT (64'hFFFFAAAA08AAAAAA)) present_state_FSM_FFd2_In2 ( .I0 ( present_state_FSM_FFd2_19), .I1 ( S_AXI_AWVALID), .I2 ( bready_timeout_c), .I3 ( w_last_c), .I4 ( S_AXI_WVALID), .I5 ( present_state_FSM_FFd2_In1_24), .O ( present_state_FSM_FFd2_In) ); STATE_LOGIC_v8_2 #( .INIT (64'h00C0004000C00000)) present_state_FSM_FFd4_In1 ( .I0 ( S_AXI_AWVALID), .I1 ( w_last_c), .I2 ( S_AXI_WVALID), .I3 ( bready_timeout_c), .I4 ( present_state_FSM_FFd3_18), .I5 ( present_state_FSM_FFd2_19), .O ( present_state_FSM_FFd4_In1_25) ); STATE_LOGIC_v8_2 #( .INIT (64'h00000000FFFF88F8)) present_state_FSM_FFd4_In2 ( .I0 ( present_state_FSM_FFd1_16), .I1 ( S_AXI_BREADY), .I2 ( present_state_FSM_FFd4_17), .I3 ( S_AXI_AWVALID), .I4 ( present_state_FSM_FFd4_In1_25), .I5 (1'b0), .O ( present_state_FSM_FFd4_In) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000000000007)) Mmux_w_ready_c_0_SW0 ( .I0 ( w_last_c), .I1 ( S_AXI_WVALID), .I2 (1'b0), .I3 (1'b0), .I4 (1'b0), .I5 (1'b0), .O ( N2) ); STATE_LOGIC_v8_2 #( .INIT (64'hFABAFABAFAAAF000)) Mmux_w_ready_c_0_Q ( .I0 ( N2), .I1 ( bready_timeout_c), .I2 ( S_AXI_AWVALID), .I3 ( present_state_FSM_FFd4_17), .I4 ( present_state_FSM_FFd3_18), .I5 ( present_state_FSM_FFd2_19), .O ( w_ready_c) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000000000008)) Mmux_aw_ready_c_0_11_SW0 ( .I0 ( bready_timeout_c), .I1 ( S_AXI_WVALID), .I2 (1'b0), .I3 (1'b0), .I4 (1'b0), .I5 (1'b0), .O ( N4) ); STATE_LOGIC_v8_2 #( .INIT (64'h88808880FFFF8880)) present_state_FSM_FFd1_In1 ( .I0 ( w_last_c), .I1 ( N4), .I2 ( present_state_FSM_FFd2_19), .I3 ( present_state_FSM_FFd3_18), .I4 ( present_state_FSM_FFd1_16), .I5 ( S_AXI_BREADY), .O ( present_state_FSM_FFd1_In) ); end end endgenerate endmodule module read_netlist_v8_2 #( parameter C_AXI_TYPE = 1, parameter C_ADDRB_WIDTH = 12 ) ( S_AXI_R_LAST_INT, S_ACLK, S_ARESETN, S_AXI_ARVALID, S_AXI_RREADY,S_AXI_INCR_ADDR,S_AXI_ADDR_EN, S_AXI_SINGLE_TRANS,S_AXI_MUX_SEL, S_AXI_R_LAST, S_AXI_ARREADY, S_AXI_RLAST, S_AXI_RVALID, S_AXI_RD_EN, S_AXI_ARLEN); input S_AXI_R_LAST_INT; input S_ACLK; input S_ARESETN; input S_AXI_ARVALID; input S_AXI_RREADY; output S_AXI_INCR_ADDR; output S_AXI_ADDR_EN; output S_AXI_SINGLE_TRANS; output S_AXI_MUX_SEL; output S_AXI_R_LAST; output S_AXI_ARREADY; output S_AXI_RLAST; output S_AXI_RVALID; output S_AXI_RD_EN; input [7:0] S_AXI_ARLEN; wire present_state_FSM_FFd1_13 ; wire present_state_FSM_FFd2_14 ; wire gaxi_full_sm_outstanding_read_r_15 ; wire gaxi_full_sm_ar_ready_r_16 ; wire gaxi_full_sm_r_last_r_17 ; wire NlwRenamedSig_OI_gaxi_full_sm_r_valid_r ; wire gaxi_full_sm_r_valid_c ; wire S_AXI_RREADY_gaxi_full_sm_r_valid_r_OR_9_o ; wire gaxi_full_sm_ar_ready_c ; wire gaxi_full_sm_outstanding_read_c ; wire NlwRenamedSig_OI_S_AXI_R_LAST ; wire S_AXI_ARLEN_7_GND_8_o_equal_1_o ; wire present_state_FSM_FFd2_In ; wire present_state_FSM_FFd1_In ; wire Mmux_S_AXI_R_LAST13 ; wire N01 ; wire N2 ; wire Mmux_gaxi_full_sm_ar_ready_c11 ; wire N4 ; wire N8 ; wire N9 ; wire N10 ; wire N11 ; wire N12 ; wire N13 ; assign S_AXI_R_LAST = NlwRenamedSig_OI_S_AXI_R_LAST, S_AXI_ARREADY = gaxi_full_sm_ar_ready_r_16, S_AXI_RLAST = gaxi_full_sm_r_last_r_17, S_AXI_RVALID = NlwRenamedSig_OI_gaxi_full_sm_r_valid_r; beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) gaxi_full_sm_outstanding_read_r ( .C (S_ACLK), .CLR(S_ARESETN), .D(gaxi_full_sm_outstanding_read_c), .Q(gaxi_full_sm_outstanding_read_r_15) ); beh_vlog_ff_ce_clr_v8_2 #( .INIT (1'b0)) gaxi_full_sm_r_valid_r ( .C (S_ACLK), .CE (S_AXI_RREADY_gaxi_full_sm_r_valid_r_OR_9_o), .CLR (S_ARESETN), .D (gaxi_full_sm_r_valid_c), .Q (NlwRenamedSig_OI_gaxi_full_sm_r_valid_r) ); beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) gaxi_full_sm_ar_ready_r ( .C (S_ACLK), .CLR (S_ARESETN), .D (gaxi_full_sm_ar_ready_c), .Q (gaxi_full_sm_ar_ready_r_16) ); beh_vlog_ff_ce_clr_v8_2 #( .INIT(1'b0)) gaxi_full_sm_r_last_r ( .C (S_ACLK), .CE (S_AXI_RREADY_gaxi_full_sm_r_valid_r_OR_9_o), .CLR (S_ARESETN), .D (NlwRenamedSig_OI_S_AXI_R_LAST), .Q (gaxi_full_sm_r_last_r_17) ); beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) present_state_FSM_FFd2 ( .C ( S_ACLK), .CLR ( S_ARESETN), .D ( present_state_FSM_FFd2_In), .Q ( present_state_FSM_FFd2_14) ); beh_vlog_ff_clr_v8_2 #( .INIT (1'b0)) present_state_FSM_FFd1 ( .C (S_ACLK), .CLR (S_ARESETN), .D (present_state_FSM_FFd1_In), .Q (present_state_FSM_FFd1_13) ); STATE_LOGIC_v8_2 #( .INIT (64'h000000000000000B)) S_AXI_RREADY_gaxi_full_sm_r_valid_r_OR_9_o1 ( .I0 ( S_AXI_RREADY), .I1 ( NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .I2 (1'b0), .I3 (1'b0), .I4 (1'b0), .I5 (1'b0), .O (S_AXI_RREADY_gaxi_full_sm_r_valid_r_OR_9_o) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000000000008)) Mmux_S_AXI_SINGLE_TRANS11 ( .I0 (S_AXI_ARVALID), .I1 (S_AXI_ARLEN_7_GND_8_o_equal_1_o), .I2 (1'b0), .I3 (1'b0), .I4 (1'b0), .I5 (1'b0), .O (S_AXI_SINGLE_TRANS) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000000000004)) Mmux_S_AXI_ADDR_EN11 ( .I0 (present_state_FSM_FFd1_13), .I1 (S_AXI_ARVALID), .I2 (1'b0), .I3 (1'b0), .I4 (1'b0), .I5 (1'b0), .O (S_AXI_ADDR_EN) ); STATE_LOGIC_v8_2 #( .INIT (64'hECEE2022EEEE2022)) present_state_FSM_FFd2_In1 ( .I0 ( S_AXI_ARVALID), .I1 ( present_state_FSM_FFd1_13), .I2 ( S_AXI_RREADY), .I3 ( S_AXI_ARLEN_7_GND_8_o_equal_1_o), .I4 ( present_state_FSM_FFd2_14), .I5 ( NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .O ( present_state_FSM_FFd2_In) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000044440444)) Mmux_S_AXI_R_LAST131 ( .I0 ( present_state_FSM_FFd1_13), .I1 ( S_AXI_ARVALID), .I2 ( present_state_FSM_FFd2_14), .I3 ( NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .I4 ( S_AXI_RREADY), .I5 (1'b0), .O ( Mmux_S_AXI_R_LAST13) ); STATE_LOGIC_v8_2 #( .INIT (64'h4000FFFF40004000)) Mmux_S_AXI_INCR_ADDR11 ( .I0 ( S_AXI_R_LAST_INT), .I1 ( S_AXI_RREADY_gaxi_full_sm_r_valid_r_OR_9_o), .I2 ( present_state_FSM_FFd2_14), .I3 ( present_state_FSM_FFd1_13), .I4 ( S_AXI_ARLEN_7_GND_8_o_equal_1_o), .I5 ( Mmux_S_AXI_R_LAST13), .O ( S_AXI_INCR_ADDR) ); STATE_LOGIC_v8_2 #( .INIT (64'h00000000000000FE)) S_AXI_ARLEN_7_GND_8_o_equal_1_o_7_SW0 ( .I0 ( S_AXI_ARLEN[2]), .I1 ( S_AXI_ARLEN[1]), .I2 ( S_AXI_ARLEN[0]), .I3 ( 1'b0), .I4 ( 1'b0), .I5 ( 1'b0), .O ( N01) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000000000001)) S_AXI_ARLEN_7_GND_8_o_equal_1_o_7_Q ( .I0 ( S_AXI_ARLEN[7]), .I1 ( S_AXI_ARLEN[6]), .I2 ( S_AXI_ARLEN[5]), .I3 ( S_AXI_ARLEN[4]), .I4 ( S_AXI_ARLEN[3]), .I5 ( N01), .O ( S_AXI_ARLEN_7_GND_8_o_equal_1_o) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000000000007)) Mmux_gaxi_full_sm_outstanding_read_c1_SW0 ( .I0 ( S_AXI_ARVALID), .I1 ( S_AXI_ARLEN_7_GND_8_o_equal_1_o), .I2 ( 1'b0), .I3 ( 1'b0), .I4 ( 1'b0), .I5 ( 1'b0), .O ( N2) ); STATE_LOGIC_v8_2 #( .INIT (64'h0020000002200200)) Mmux_gaxi_full_sm_outstanding_read_c1 ( .I0 ( NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .I1 ( S_AXI_RREADY), .I2 ( present_state_FSM_FFd1_13), .I3 ( present_state_FSM_FFd2_14), .I4 ( gaxi_full_sm_outstanding_read_r_15), .I5 ( N2), .O ( gaxi_full_sm_outstanding_read_c) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000000004555)) Mmux_gaxi_full_sm_ar_ready_c12 ( .I0 ( S_AXI_ARVALID), .I1 ( S_AXI_RREADY), .I2 ( present_state_FSM_FFd2_14), .I3 ( NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .I4 ( 1'b0), .I5 ( 1'b0), .O ( Mmux_gaxi_full_sm_ar_ready_c11) ); STATE_LOGIC_v8_2 #( .INIT (64'h00000000000000EF)) Mmux_S_AXI_R_LAST11_SW0 ( .I0 ( S_AXI_ARLEN_7_GND_8_o_equal_1_o), .I1 ( S_AXI_RREADY), .I2 ( NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .I3 ( 1'b0), .I4 ( 1'b0), .I5 ( 1'b0), .O ( N4) ); STATE_LOGIC_v8_2 #( .INIT (64'hFCAAFC0A00AA000A)) Mmux_S_AXI_R_LAST11 ( .I0 ( S_AXI_ARVALID), .I1 ( gaxi_full_sm_outstanding_read_r_15), .I2 ( present_state_FSM_FFd2_14), .I3 ( present_state_FSM_FFd1_13), .I4 ( N4), .I5 ( S_AXI_RREADY_gaxi_full_sm_r_valid_r_OR_9_o), .O ( gaxi_full_sm_r_valid_c) ); STATE_LOGIC_v8_2 #( .INIT (64'h00000000AAAAAA08)) S_AXI_MUX_SEL1 ( .I0 (present_state_FSM_FFd1_13), .I1 (NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .I2 (S_AXI_RREADY), .I3 (present_state_FSM_FFd2_14), .I4 (gaxi_full_sm_outstanding_read_r_15), .I5 (1'b0), .O (S_AXI_MUX_SEL) ); STATE_LOGIC_v8_2 #( .INIT (64'hF3F3F755A2A2A200)) Mmux_S_AXI_RD_EN11 ( .I0 ( present_state_FSM_FFd1_13), .I1 ( NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .I2 ( S_AXI_RREADY), .I3 ( gaxi_full_sm_outstanding_read_r_15), .I4 ( present_state_FSM_FFd2_14), .I5 ( S_AXI_ARVALID), .O ( S_AXI_RD_EN) ); beh_vlog_muxf7_v8_2 present_state_FSM_FFd1_In3 ( .I0 ( N8), .I1 ( N9), .S ( present_state_FSM_FFd1_13), .O ( present_state_FSM_FFd1_In) ); STATE_LOGIC_v8_2 #( .INIT (64'h000000005410F4F0)) present_state_FSM_FFd1_In3_F ( .I0 ( S_AXI_RREADY), .I1 ( present_state_FSM_FFd2_14), .I2 ( S_AXI_ARVALID), .I3 ( NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .I4 ( S_AXI_ARLEN_7_GND_8_o_equal_1_o), .I5 ( 1'b0), .O ( N8) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000072FF7272)) present_state_FSM_FFd1_In3_G ( .I0 ( present_state_FSM_FFd2_14), .I1 ( S_AXI_R_LAST_INT), .I2 ( gaxi_full_sm_outstanding_read_r_15), .I3 ( S_AXI_RREADY), .I4 ( NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .I5 ( 1'b0), .O ( N9) ); beh_vlog_muxf7_v8_2 Mmux_gaxi_full_sm_ar_ready_c14 ( .I0 ( N10), .I1 ( N11), .S ( present_state_FSM_FFd1_13), .O ( gaxi_full_sm_ar_ready_c) ); STATE_LOGIC_v8_2 #( .INIT (64'h00000000FFFF88A8)) Mmux_gaxi_full_sm_ar_ready_c14_F ( .I0 ( S_AXI_ARLEN_7_GND_8_o_equal_1_o), .I1 ( S_AXI_RREADY), .I2 ( present_state_FSM_FFd2_14), .I3 ( NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .I4 ( Mmux_gaxi_full_sm_ar_ready_c11), .I5 ( 1'b0), .O ( N10) ); STATE_LOGIC_v8_2 #( .INIT (64'h000000008D008D8D)) Mmux_gaxi_full_sm_ar_ready_c14_G ( .I0 ( present_state_FSM_FFd2_14), .I1 ( S_AXI_R_LAST_INT), .I2 ( gaxi_full_sm_outstanding_read_r_15), .I3 ( S_AXI_RREADY), .I4 ( NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .I5 ( 1'b0), .O ( N11) ); beh_vlog_muxf7_v8_2 Mmux_S_AXI_R_LAST1 ( .I0 ( N12), .I1 ( N13), .S ( present_state_FSM_FFd1_13), .O ( NlwRenamedSig_OI_S_AXI_R_LAST) ); STATE_LOGIC_v8_2 #( .INIT (64'h0000000088088888)) Mmux_S_AXI_R_LAST1_F ( .I0 ( S_AXI_ARLEN_7_GND_8_o_equal_1_o), .I1 ( S_AXI_ARVALID), .I2 ( present_state_FSM_FFd2_14), .I3 ( S_AXI_RREADY), .I4 ( NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .I5 ( 1'b0), .O ( N12) ); STATE_LOGIC_v8_2 #( .INIT (64'h00000000E400E4E4)) Mmux_S_AXI_R_LAST1_G ( .I0 ( present_state_FSM_FFd2_14), .I1 ( gaxi_full_sm_outstanding_read_r_15), .I2 ( S_AXI_R_LAST_INT), .I3 ( S_AXI_RREADY), .I4 ( NlwRenamedSig_OI_gaxi_full_sm_r_valid_r), .I5 ( 1'b0), .O ( N13) ); endmodule module blk_mem_axi_write_wrapper_beh_v8_2 # ( // AXI Interface related parameters start here parameter C_INTERFACE_TYPE = 0, // 0: Native Interface; 1: AXI Interface parameter C_AXI_TYPE = 0, // 0: AXI Lite; 1: AXI Full; parameter C_AXI_SLAVE_TYPE = 0, // 0: MEMORY SLAVE; 1: PERIPHERAL SLAVE; parameter C_MEMORY_TYPE = 0, // 0: SP-RAM, 1: SDP-RAM; 2: TDP-RAM; 3: DP-ROM; parameter C_WRITE_DEPTH_A = 0, parameter C_AXI_AWADDR_WIDTH = 32, parameter C_ADDRA_WIDTH = 12, parameter C_AXI_WDATA_WIDTH = 32, parameter C_HAS_AXI_ID = 0, parameter C_AXI_ID_WIDTH = 4, // AXI OUTSTANDING WRITES parameter C_AXI_OS_WR = 2 ) ( // AXI Global Signals input S_ACLK, input S_ARESETN, // AXI Full/Lite Slave Write Channel (write side) input [C_AXI_ID_WIDTH-1:0] S_AXI_AWID, input [C_AXI_AWADDR_WIDTH-1:0] S_AXI_AWADDR, input [8-1:0] S_AXI_AWLEN, input [2:0] S_AXI_AWSIZE, input [1:0] S_AXI_AWBURST, input S_AXI_AWVALID, output S_AXI_AWREADY, input S_AXI_WVALID, output S_AXI_WREADY, output reg [C_AXI_ID_WIDTH-1:0] S_AXI_BID = 0, output S_AXI_BVALID, input S_AXI_BREADY, // Signals for BMG interface output [C_ADDRA_WIDTH-1:0] S_AXI_AWADDR_OUT, output S_AXI_WR_EN ); localparam FLOP_DELAY = 100; // 100 ps localparam C_RANGE = ((C_AXI_WDATA_WIDTH == 8)?0: ((C_AXI_WDATA_WIDTH==16)?1: ((C_AXI_WDATA_WIDTH==32)?2: ((C_AXI_WDATA_WIDTH==64)?3: ((C_AXI_WDATA_WIDTH==128)?4: ((C_AXI_WDATA_WIDTH==256)?5:0)))))); wire bvalid_c ; reg bready_timeout_c = 0; wire [1:0] bvalid_rd_cnt_c; reg bvalid_r = 0; reg [2:0] bvalid_count_r = 0; reg [((C_AXI_TYPE == 1 && C_AXI_SLAVE_TYPE == 0)? C_AXI_AWADDR_WIDTH:C_ADDRA_WIDTH)-1:0] awaddr_reg = 0; reg [1:0] bvalid_wr_cnt_r = 0; reg [1:0] bvalid_rd_cnt_r = 0; wire w_last_c ; wire addr_en_c ; wire incr_addr_c ; wire aw_ready_r ; wire dec_alen_c ; reg bvalid_d1_c = 0; reg [7:0] awlen_cntr_r = 0; reg [7:0] awlen_int = 0; reg [1:0] awburst_int = 0; integer total_bytes = 0; integer wrap_boundary = 0; integer wrap_base_addr = 0; integer num_of_bytes_c = 0; integer num_of_bytes_r = 0; // Array to store BIDs reg [C_AXI_ID_WIDTH-1:0] axi_bid_array[3:0] ; wire S_AXI_BVALID_axi_wr_fsm; //------------------------------------- //AXI WRITE FSM COMPONENT INSTANTIATION //------------------------------------- write_netlist_v8_2 #(.C_AXI_TYPE(C_AXI_TYPE)) axi_wr_fsm ( .S_ACLK(S_ACLK), .S_ARESETN(S_ARESETN), .S_AXI_AWVALID(S_AXI_AWVALID), .aw_ready_r(aw_ready_r), .S_AXI_WVALID(S_AXI_WVALID), .S_AXI_WREADY(S_AXI_WREADY), .S_AXI_BREADY(S_AXI_BREADY), .S_AXI_WR_EN(S_AXI_WR_EN), .w_last_c(w_last_c), .bready_timeout_c(bready_timeout_c), .addr_en_c(addr_en_c), .incr_addr_c(incr_addr_c), .bvalid_c(bvalid_c), .S_AXI_BVALID (S_AXI_BVALID_axi_wr_fsm) ); //Wrap Address boundary calculation always@(*) begin num_of_bytes_c = 2**((C_AXI_TYPE == 1 && C_AXI_SLAVE_TYPE == 0)?S_AXI_AWSIZE:0); total_bytes = (num_of_bytes_r)*(awlen_int+1); wrap_base_addr = ((awaddr_reg)/((total_bytes==0)?1:total_bytes))*(total_bytes); wrap_boundary = wrap_base_addr+total_bytes; end //------------------------------------------------------------------------- // BMG address generation //------------------------------------------------------------------------- always @(posedge S_ACLK or S_ARESETN) begin if (S_ARESETN == 1'b1) begin awaddr_reg <= 0; num_of_bytes_r <= 0; awburst_int <= 0; end else begin if (addr_en_c == 1'b1) begin awaddr_reg <= #FLOP_DELAY S_AXI_AWADDR ; num_of_bytes_r <= num_of_bytes_c; awburst_int <= ((C_AXI_TYPE == 1 && C_AXI_SLAVE_TYPE == 0)?S_AXI_AWBURST:2'b01); end else if (incr_addr_c == 1'b1) begin if (awburst_int == 2'b10) begin if(awaddr_reg == (wrap_boundary-num_of_bytes_r)) begin awaddr_reg <= wrap_base_addr; end else begin awaddr_reg <= awaddr_reg + num_of_bytes_r; end end else if (awburst_int == 2'b01 || awburst_int == 2'b11) begin awaddr_reg <= awaddr_reg + num_of_bytes_r; end end end end assign S_AXI_AWADDR_OUT = ((C_AXI_TYPE == 1 && C_AXI_SLAVE_TYPE == 0)? awaddr_reg[C_AXI_AWADDR_WIDTH-1:C_RANGE]:awaddr_reg); //------------------------------------------------------------------------- // AXI wlast generation //------------------------------------------------------------------------- always @(posedge S_ACLK or S_ARESETN) begin if (S_ARESETN == 1'b1) begin awlen_cntr_r <= 0; awlen_int <= 0; end else begin if (addr_en_c == 1'b1) begin awlen_int <= #FLOP_DELAY (C_AXI_TYPE == 0?0:S_AXI_AWLEN) ; awlen_cntr_r <= #FLOP_DELAY (C_AXI_TYPE == 0?0:S_AXI_AWLEN) ; end else if (dec_alen_c == 1'b1) begin awlen_cntr_r <= #FLOP_DELAY awlen_cntr_r - 1 ; end end end assign w_last_c = (awlen_cntr_r == 0 && S_AXI_WVALID == 1'b1)?1'b1:1'b0; assign dec_alen_c = (incr_addr_c | w_last_c); //------------------------------------------------------------------------- // Generation of bvalid counter for outstanding transactions //------------------------------------------------------------------------- always @(posedge S_ACLK or S_ARESETN) begin if (S_ARESETN == 1'b1) begin bvalid_count_r <= 0; end else begin // bvalid_count_r generation if (bvalid_c == 1'b1 && bvalid_r == 1'b1 && S_AXI_BREADY == 1'b1) begin bvalid_count_r <= #FLOP_DELAY bvalid_count_r ; end else if (bvalid_c == 1'b1) begin bvalid_count_r <= #FLOP_DELAY bvalid_count_r + 1 ; end else if (bvalid_r == 1'b1 && S_AXI_BREADY == 1'b1 && bvalid_count_r != 0) begin bvalid_count_r <= #FLOP_DELAY bvalid_count_r - 1 ; end end end //------------------------------------------------------------------------- // Generation of bvalid when BID is used //------------------------------------------------------------------------- generate if (C_HAS_AXI_ID == 1) begin:gaxi_bvalid_id_r always @(posedge S_ACLK or S_ARESETN) begin if (S_ARESETN == 1'b1) begin bvalid_r <= 0; bvalid_d1_c <= 0; end else begin // Delay the generation o bvalid_r for generation for BID bvalid_d1_c <= bvalid_c; //external bvalid signal generation if (bvalid_d1_c == 1'b1) begin bvalid_r <= #FLOP_DELAY 1'b1 ; end else if (bvalid_count_r <= 1 && S_AXI_BREADY == 1'b1) begin bvalid_r <= #FLOP_DELAY 0 ; end end end end endgenerate //------------------------------------------------------------------------- // Generation of bvalid when BID is not used //------------------------------------------------------------------------- generate if(C_HAS_AXI_ID == 0) begin:gaxi_bvalid_noid_r always @(posedge S_ACLK or S_ARESETN) begin if (S_ARESETN == 1'b1) begin bvalid_r <= 0; end else begin //external bvalid signal generation if (bvalid_c == 1'b1) begin bvalid_r <= #FLOP_DELAY 1'b1 ; end else if (bvalid_count_r <= 1 && S_AXI_BREADY == 1'b1) begin bvalid_r <= #FLOP_DELAY 0 ; end end end end endgenerate //------------------------------------------------------------------------- // Generation of Bready timeout //------------------------------------------------------------------------- always @(bvalid_count_r) begin // bready_timeout_c generation if(bvalid_count_r == C_AXI_OS_WR-1) begin bready_timeout_c <= 1'b1; end else begin bready_timeout_c <= 1'b0; end end //------------------------------------------------------------------------- // Generation of BID //------------------------------------------------------------------------- generate if(C_HAS_AXI_ID == 1) begin:gaxi_bid_gen always @(posedge S_ACLK or S_ARESETN) begin if (S_ARESETN == 1'b1) begin bvalid_wr_cnt_r <= 0; bvalid_rd_cnt_r <= 0; end else begin // STORE AWID IN AN ARRAY if(bvalid_c == 1'b1) begin bvalid_wr_cnt_r <= bvalid_wr_cnt_r + 1; end // generate BID FROM AWID ARRAY bvalid_rd_cnt_r <= #FLOP_DELAY bvalid_rd_cnt_c ; S_AXI_BID <= axi_bid_array[bvalid_rd_cnt_c]; end end assign bvalid_rd_cnt_c = (bvalid_r == 1'b1 && S_AXI_BREADY == 1'b1)?bvalid_rd_cnt_r+1:bvalid_rd_cnt_r; //------------------------------------------------------------------------- // Storing AWID for generation of BID //------------------------------------------------------------------------- always @(posedge S_ACLK or S_ARESETN) begin if(S_ARESETN == 1'b1) begin axi_bid_array[0] = 0; axi_bid_array[1] = 0; axi_bid_array[2] = 0; axi_bid_array[3] = 0; end else if(aw_ready_r == 1'b1 && S_AXI_AWVALID == 1'b1) begin axi_bid_array[bvalid_wr_cnt_r] <= S_AXI_AWID; end end end endgenerate assign S_AXI_BVALID = bvalid_r; assign S_AXI_AWREADY = aw_ready_r; endmodule module blk_mem_axi_read_wrapper_beh_v8_2 # ( //// AXI Interface related parameters start here parameter C_INTERFACE_TYPE = 0, parameter C_AXI_TYPE = 0, parameter C_AXI_SLAVE_TYPE = 0, parameter C_MEMORY_TYPE = 0, parameter C_WRITE_WIDTH_A = 4, parameter C_WRITE_DEPTH_A = 32, parameter C_ADDRA_WIDTH = 12, parameter C_AXI_PIPELINE_STAGES = 0, parameter C_AXI_ARADDR_WIDTH = 12, parameter C_HAS_AXI_ID = 0, parameter C_AXI_ID_WIDTH = 4, parameter C_ADDRB_WIDTH = 12 ) ( //// AXI Global Signals input S_ACLK, input S_ARESETN, //// AXI Full/Lite Slave Read (Read side) input [C_AXI_ARADDR_WIDTH-1:0] S_AXI_ARADDR, input [7:0] S_AXI_ARLEN, input [2:0] S_AXI_ARSIZE, input [1:0] S_AXI_ARBURST, input S_AXI_ARVALID, output S_AXI_ARREADY, output S_AXI_RLAST, output S_AXI_RVALID, input S_AXI_RREADY, input [C_AXI_ID_WIDTH-1:0] S_AXI_ARID, output reg [C_AXI_ID_WIDTH-1:0] S_AXI_RID = 0, //// AXI Full/Lite Read Address Signals to BRAM output [C_ADDRB_WIDTH-1:0] S_AXI_ARADDR_OUT, output S_AXI_RD_EN ); localparam FLOP_DELAY = 100; // 100 ps localparam C_RANGE = ((C_WRITE_WIDTH_A == 8)?0: ((C_WRITE_WIDTH_A==16)?1: ((C_WRITE_WIDTH_A==32)?2: ((C_WRITE_WIDTH_A==64)?3: ((C_WRITE_WIDTH_A==128)?4: ((C_WRITE_WIDTH_A==256)?5:0)))))); reg [C_AXI_ID_WIDTH-1:0] ar_id_r=0; wire addr_en_c; wire rd_en_c; wire incr_addr_c; wire single_trans_c; wire dec_alen_c; wire mux_sel_c; wire r_last_c; wire r_last_int_c; wire [C_ADDRB_WIDTH-1 : 0] araddr_out; reg [7:0] arlen_int_r=0; reg [7:0] arlen_cntr=8'h01; reg [1:0] arburst_int_c=0; reg [1:0] arburst_int_r=0; reg [((C_AXI_TYPE == 1 && C_AXI_SLAVE_TYPE == 0)? C_AXI_ARADDR_WIDTH:C_ADDRA_WIDTH)-1:0] araddr_reg =0; integer num_of_bytes_c = 0; integer total_bytes = 0; integer num_of_bytes_r = 0; integer wrap_base_addr_r = 0; integer wrap_boundary_r = 0; reg [7:0] arlen_int_c=0; integer total_bytes_c = 0; integer wrap_base_addr_c = 0; integer wrap_boundary_c = 0; assign dec_alen_c = incr_addr_c | r_last_int_c; read_netlist_v8_2 #(.C_AXI_TYPE (1), .C_ADDRB_WIDTH (C_ADDRB_WIDTH)) axi_read_fsm ( .S_AXI_INCR_ADDR(incr_addr_c), .S_AXI_ADDR_EN(addr_en_c), .S_AXI_SINGLE_TRANS(single_trans_c), .S_AXI_MUX_SEL(mux_sel_c), .S_AXI_R_LAST(r_last_c), .S_AXI_R_LAST_INT(r_last_int_c), //// AXI Global Signals .S_ACLK(S_ACLK), .S_ARESETN(S_ARESETN), //// AXI Full/Lite Slave Read (Read side) .S_AXI_ARLEN(S_AXI_ARLEN), .S_AXI_ARVALID(S_AXI_ARVALID), .S_AXI_ARREADY(S_AXI_ARREADY), .S_AXI_RLAST(S_AXI_RLAST), .S_AXI_RVALID(S_AXI_RVALID), .S_AXI_RREADY(S_AXI_RREADY), //// AXI Full/Lite Read Address Signals to BRAM .S_AXI_RD_EN(rd_en_c) ); always@(*) begin num_of_bytes_c = 2**((C_AXI_TYPE == 1 && C_AXI_SLAVE_TYPE == 0)?S_AXI_ARSIZE:0); total_bytes = (num_of_bytes_r)*(arlen_int_r+1); wrap_base_addr_r = ((araddr_reg)/(total_bytes==0?1:total_bytes))*(total_bytes); wrap_boundary_r = wrap_base_addr_r+total_bytes; //////// combinatorial from interface arlen_int_c = (C_AXI_TYPE == 0?0:S_AXI_ARLEN); total_bytes_c = (num_of_bytes_c)*(arlen_int_c+1); wrap_base_addr_c = ((S_AXI_ARADDR)/(total_bytes_c==0?1:total_bytes_c))*(total_bytes_c); wrap_boundary_c = wrap_base_addr_c+total_bytes_c; arburst_int_c = ((C_AXI_TYPE == 1 && C_AXI_SLAVE_TYPE == 0)?S_AXI_ARBURST:1); end ////------------------------------------------------------------------------- //// BMG address generation ////------------------------------------------------------------------------- always @(posedge S_ACLK or S_ARESETN) begin if (S_ARESETN == 1'b1) begin araddr_reg <= 0; arburst_int_r <= 0; num_of_bytes_r <= 0; end else begin if (incr_addr_c == 1'b1 && addr_en_c == 1'b1 && single_trans_c == 1'b0) begin arburst_int_r <= arburst_int_c; num_of_bytes_r <= num_of_bytes_c; if (arburst_int_c == 2'b10) begin if(S_AXI_ARADDR == (wrap_boundary_c-num_of_bytes_c)) begin araddr_reg <= wrap_base_addr_c; end else begin araddr_reg <= S_AXI_ARADDR + num_of_bytes_c; end end else if (arburst_int_c == 2'b01 || arburst_int_c == 2'b11) begin araddr_reg <= S_AXI_ARADDR + num_of_bytes_c; end end else if (addr_en_c == 1'b1) begin araddr_reg <= S_AXI_ARADDR; num_of_bytes_r <= num_of_bytes_c; arburst_int_r <= arburst_int_c; end else if (incr_addr_c == 1'b1) begin if (arburst_int_r == 2'b10) begin if(araddr_reg == (wrap_boundary_r-num_of_bytes_r)) begin araddr_reg <= wrap_base_addr_r; end else begin araddr_reg <= araddr_reg + num_of_bytes_r; end end else if (arburst_int_r == 2'b01 || arburst_int_r == 2'b11) begin araddr_reg <= araddr_reg + num_of_bytes_r; end end end end assign araddr_out = ((C_AXI_TYPE == 1 && C_AXI_SLAVE_TYPE == 0)?araddr_reg[C_AXI_ARADDR_WIDTH-1:C_RANGE]:araddr_reg); ////----------------------------------------------------------------------- //// Counter to generate r_last_int_c from registered ARLEN - AXI FULL FSM ////----------------------------------------------------------------------- always @(posedge S_ACLK or S_ARESETN) begin if (S_ARESETN == 1'b1) begin arlen_cntr <= 8'h01; arlen_int_r <= 0; end else begin if (addr_en_c == 1'b1 && dec_alen_c == 1'b1 && single_trans_c == 1'b0) begin arlen_int_r <= (C_AXI_TYPE == 0?0:S_AXI_ARLEN) ; arlen_cntr <= S_AXI_ARLEN - 1'b1; end else if (addr_en_c == 1'b1) begin arlen_int_r <= (C_AXI_TYPE == 0?0:S_AXI_ARLEN) ; arlen_cntr <= (C_AXI_TYPE == 0?0:S_AXI_ARLEN) ; end else if (dec_alen_c == 1'b1) begin arlen_cntr <= arlen_cntr - 1'b1 ; end else begin arlen_cntr <= arlen_cntr; end end end assign r_last_int_c = (arlen_cntr == 0 && S_AXI_RREADY == 1'b1)?1'b1:1'b0; ////------------------------------------------------------------------------ //// AXI FULL FSM //// Mux Selection of ARADDR //// ARADDR is driven out from the read fsm based on the mux_sel_c //// Based on mux_sel either ARADDR is given out or the latched ARADDR is //// given out to BRAM ////------------------------------------------------------------------------ assign S_AXI_ARADDR_OUT = (mux_sel_c == 1'b0)?((C_AXI_TYPE == 1 && C_AXI_SLAVE_TYPE == 0)?S_AXI_ARADDR[C_AXI_ARADDR_WIDTH-1:C_RANGE]:S_AXI_ARADDR):araddr_out; ////------------------------------------------------------------------------ //// Assign output signals - AXI FULL FSM ////------------------------------------------------------------------------ assign S_AXI_RD_EN = rd_en_c; generate if (C_HAS_AXI_ID == 1) begin:gaxi_bvalid_id_r always @(posedge S_ACLK or S_ARESETN) begin if (S_ARESETN == 1'b1) begin S_AXI_RID <= 0; ar_id_r <= 0; end else begin if (addr_en_c == 1'b1 && rd_en_c == 1'b1) begin S_AXI_RID <= S_AXI_ARID; ar_id_r <= S_AXI_ARID; end else if (addr_en_c == 1'b1 && rd_en_c == 1'b0) begin ar_id_r <= S_AXI_ARID; end else if (rd_en_c == 1'b1) begin S_AXI_RID <= ar_id_r; end end end end endgenerate endmodule module blk_mem_axi_regs_fwd_v8_2 #(parameter C_DATA_WIDTH = 8 )( input ACLK, input ARESET, input S_VALID, output S_READY, input [C_DATA_WIDTH-1:0] S_PAYLOAD_DATA, output M_VALID, input M_READY, output reg [C_DATA_WIDTH-1:0] M_PAYLOAD_DATA ); reg [C_DATA_WIDTH-1:0] STORAGE_DATA; wire S_READY_I; reg M_VALID_I; reg [1:0] ARESET_D; //assign local signal to its output signal assign S_READY = S_READY_I; assign M_VALID = M_VALID_I; always @(posedge ACLK) begin ARESET_D <= {ARESET_D[0], ARESET}; end //Save payload data whenever we have a transaction on the slave side always @(posedge ACLK or ARESET) begin if (ARESET == 1'b1) begin STORAGE_DATA <= 0; end else begin if(S_VALID == 1'b1 && S_READY_I == 1'b1 ) begin STORAGE_DATA <= S_PAYLOAD_DATA; end end end always @(posedge ACLK) begin M_PAYLOAD_DATA = STORAGE_DATA; end //M_Valid set to high when we have a completed transfer on slave side //Is removed on a M_READY except if we have a new transfer on the slave side always @(posedge ACLK or ARESET_D) begin if (ARESET_D != 2'b00) begin M_VALID_I <= 1'b0; end else begin if (S_VALID == 1'b1) begin //Always set M_VALID_I when slave side is valid M_VALID_I <= 1'b1; end else if (M_READY == 1'b1 ) begin //Clear (or keep) when no slave side is valid but master side is ready M_VALID_I <= 1'b0; end end end //Slave Ready is either when Master side drives M_READY or we have space in our storage data assign S_READY_I = (M_READY || (!M_VALID_I)) && !(|(ARESET_D)); endmodule //***************************************************************************** // Output Register Stage module // // This module builds the output register stages of the memory. This module is // instantiated in the main memory module (BLK_MEM_GEN_v8_2) which is // declared/implemented further down in this file. //***************************************************************************** module BLK_MEM_GEN_v8_2_output_stage #(parameter C_FAMILY = "virtex7", parameter C_XDEVICEFAMILY = "virtex7", parameter C_RST_TYPE = "SYNC", parameter C_HAS_RST = 0, parameter C_RSTRAM = 0, parameter C_RST_PRIORITY = "CE", parameter C_INIT_VAL = "0", parameter C_HAS_EN = 0, parameter C_HAS_REGCE = 0, parameter C_DATA_WIDTH = 32, parameter C_ADDRB_WIDTH = 10, parameter C_HAS_MEM_OUTPUT_REGS = 0, parameter C_USE_SOFTECC = 0, parameter C_USE_ECC = 0, parameter NUM_STAGES = 1, parameter C_EN_ECC_PIPE = 0, parameter FLOP_DELAY = 100 ) ( input CLK, input RST, input EN, input REGCE, input [C_DATA_WIDTH-1:0] DIN_I, output reg [C_DATA_WIDTH-1:0] DOUT, input SBITERR_IN_I, input DBITERR_IN_I, output reg SBITERR, output reg DBITERR, input [C_ADDRB_WIDTH-1:0] RDADDRECC_IN_I, input ECCPIPECE, output reg [C_ADDRB_WIDTH-1:0] RDADDRECC ); //****************************** // Port and Generic Definitions //****************************** ////////////////////////////////////////////////////////////////////////// // Generic Definitions ////////////////////////////////////////////////////////////////////////// // C_FAMILY,C_XDEVICEFAMILY: Designates architecture targeted. The following // options are available - "spartan3", "spartan6", // "virtex4", "virtex5", "virtex6" and "virtex6l". // C_RST_TYPE : Type of reset - Synchronous or Asynchronous // C_HAS_RST : Determines the presence of the RST port // C_RSTRAM : Determines if special reset behavior is used // C_RST_PRIORITY : Determines the priority between CE and SR // C_INIT_VAL : Initialization value // C_HAS_EN : Determines the presence of the EN port // C_HAS_REGCE : Determines the presence of the REGCE port // C_DATA_WIDTH : Memory write/read width // C_ADDRB_WIDTH : Width of the ADDRB input port // C_HAS_MEM_OUTPUT_REGS : Designates the use of a register at the output // of the RAM primitive // C_USE_SOFTECC : Determines if the Soft ECC feature is used or // not. Only applicable Spartan-6 // C_USE_ECC : Determines if the ECC feature is used or // not. Only applicable for V5 and V6 // NUM_STAGES : Determines the number of output stages // FLOP_DELAY : Constant delay for register assignments ////////////////////////////////////////////////////////////////////////// // Port Definitions ////////////////////////////////////////////////////////////////////////// // CLK : Clock to synchronize all read and write operations // RST : Reset input to reset memory outputs to a user-defined // reset state // EN : Enable all read and write operations // REGCE : Register Clock Enable to control each pipeline output // register stages // DIN : Data input to the Output stage. // DOUT : Final Data output // SBITERR_IN : SBITERR input signal to the Output stage. // SBITERR : Final SBITERR Output signal. // DBITERR_IN : DBITERR input signal to the Output stage. // DBITERR : Final DBITERR Output signal. // RDADDRECC_IN : RDADDRECC input signal to the Output stage. // RDADDRECC : Final RDADDRECC Output signal. ////////////////////////////////////////////////////////////////////////// // Fix for CR-509792 localparam REG_STAGES = (NUM_STAGES < 2) ? 1 : NUM_STAGES-1; // Declare the pipeline registers // (includes mem output reg, mux pipeline stages, and mux output reg) reg [C_DATA_WIDTH*REG_STAGES-1:0] out_regs; reg [C_ADDRB_WIDTH*REG_STAGES-1:0] rdaddrecc_regs; reg [REG_STAGES-1:0] sbiterr_regs; reg [REG_STAGES-1:0] dbiterr_regs; reg [C_DATA_WIDTH*8-1:0] init_str = C_INIT_VAL; reg [C_DATA_WIDTH-1:0] init_val ; //********************************************* // Wire off optional inputs based on parameters //********************************************* wire en_i; wire regce_i; wire rst_i; // Internal signals reg [C_DATA_WIDTH-1:0] DIN; reg [C_ADDRB_WIDTH-1:0] RDADDRECC_IN; reg SBITERR_IN; reg DBITERR_IN; // Internal enable for output registers is tied to user EN or '1' depending // on parameters assign en_i = (C_HAS_EN==0 || EN); // Internal register enable for output registers is tied to user REGCE, EN or // '1' depending on parameters // For V4 ECC, REGCE is always 1 // Virtex-4 ECC Not Yet Supported assign regce_i = ((C_HAS_REGCE==1) && REGCE) || ((C_HAS_REGCE==0) && (C_HAS_EN==0 || EN)); //Internal SRR is tied to user RST or '0' depending on parameters assign rst_i = (C_HAS_RST==1) && RST; //**************************************************** // Power on: load up the output registers and latches //**************************************************** initial begin if (!($sscanf(init_str, "%h", init_val))) begin init_val = 0; end DOUT = init_val; RDADDRECC = 0; SBITERR = 1'b0; DBITERR = 1'b0; DIN = {(C_DATA_WIDTH){1'b0}}; RDADDRECC_IN = 0; SBITERR_IN = 0; DBITERR_IN = 0; // This will be one wider than need, but 0 is an error out_regs = {(REG_STAGES+1){init_val}}; rdaddrecc_regs = 0; sbiterr_regs = {(REG_STAGES+1){1'b0}}; dbiterr_regs = {(REG_STAGES+1){1'b0}}; end //*********************************************** // NUM_STAGES = 0 (No output registers. RAM only) //*********************************************** generate if (NUM_STAGES == 0) begin : zero_stages always @* begin DOUT = DIN; RDADDRECC = RDADDRECC_IN; SBITERR = SBITERR_IN; DBITERR = DBITERR_IN; end end endgenerate generate if (C_EN_ECC_PIPE == 0) begin : no_ecc_pipe_reg always @* begin DIN = DIN_I; SBITERR_IN = SBITERR_IN_I; DBITERR_IN = DBITERR_IN_I; RDADDRECC_IN = RDADDRECC_IN_I; end end endgenerate generate if (C_EN_ECC_PIPE == 1) begin : with_ecc_pipe_reg always @(posedge CLK) begin if(ECCPIPECE == 1) begin DIN <= #FLOP_DELAY DIN_I; SBITERR_IN <= #FLOP_DELAY SBITERR_IN_I; DBITERR_IN <= #FLOP_DELAY DBITERR_IN_I; RDADDRECC_IN <= #FLOP_DELAY RDADDRECC_IN_I; end end end endgenerate //*********************************************** // NUM_STAGES = 1 // (Mem Output Reg only or Mux Output Reg only) //*********************************************** // Possible valid combinations: // Note: C_HAS_MUX_OUTPUT_REGS_*=0 when (C_RSTRAM_*=1) // +-----------------------------------------+ // | C_RSTRAM_* | Reset Behavior | // +----------------+------------------------+ // | 0 | Normal Behavior | // +----------------+------------------------+ // | 1 | Special Behavior | // +----------------+------------------------+ // // Normal = REGCE gates reset, as in the case of all families except S3ADSP. // Special = EN gates reset, as in the case of S3ADSP. generate if (NUM_STAGES == 1 && (C_RSTRAM == 0 || (C_RSTRAM == 1 && (C_XDEVICEFAMILY != "spartan3adsp" && C_XDEVICEFAMILY != "aspartan3adsp" )) || C_HAS_MEM_OUTPUT_REGS == 0 || C_HAS_RST == 0)) begin : one_stages_norm always @(posedge CLK) begin if (C_RST_PRIORITY == "CE") begin //REGCE has priority if (regce_i && rst_i) begin DOUT <= #FLOP_DELAY init_val; RDADDRECC <= #FLOP_DELAY 0; SBITERR <= #FLOP_DELAY 1'b0; DBITERR <= #FLOP_DELAY 1'b0; end else if (regce_i) begin DOUT <= #FLOP_DELAY DIN; RDADDRECC <= #FLOP_DELAY RDADDRECC_IN; SBITERR <= #FLOP_DELAY SBITERR_IN; DBITERR <= #FLOP_DELAY DBITERR_IN; end //Output signal assignments end else begin //RST has priority if (rst_i) begin DOUT <= #FLOP_DELAY init_val; RDADDRECC <= #FLOP_DELAY RDADDRECC_IN; SBITERR <= #FLOP_DELAY 1'b0; DBITERR <= #FLOP_DELAY 1'b0; end else if (regce_i) begin DOUT <= #FLOP_DELAY DIN; RDADDRECC <= #FLOP_DELAY RDADDRECC_IN; SBITERR <= #FLOP_DELAY SBITERR_IN; DBITERR <= #FLOP_DELAY DBITERR_IN; end //Output signal assignments end //end Priority conditions end //end RST Type conditions end //end one_stages_norm generate statement endgenerate // Special Reset Behavior for S3ADSP generate if (NUM_STAGES == 1 && C_RSTRAM == 1 && (C_XDEVICEFAMILY =="spartan3adsp" || C_XDEVICEFAMILY =="aspartan3adsp")) begin : one_stage_splbhv always @(posedge CLK) begin if (en_i && rst_i) begin DOUT <= #FLOP_DELAY init_val; end else if (regce_i && !rst_i) begin DOUT <= #FLOP_DELAY DIN; end //Output signal assignments end //end CLK end //end one_stage_splbhv generate statement endgenerate //************************************************************ // NUM_STAGES > 1 // Mem Output Reg + Mux Output Reg // or // Mem Output Reg + Mux Pipeline Stages (>0) + Mux Output Reg // or // Mux Pipeline Stages (>0) + Mux Output Reg //************************************************************* generate if (NUM_STAGES > 1) begin : multi_stage //Asynchronous Reset always @(posedge CLK) begin if (C_RST_PRIORITY == "CE") begin //REGCE has priority if (regce_i && rst_i) begin DOUT <= #FLOP_DELAY init_val; RDADDRECC <= #FLOP_DELAY 0; SBITERR <= #FLOP_DELAY 1'b0; DBITERR <= #FLOP_DELAY 1'b0; end else if (regce_i) begin DOUT <= #FLOP_DELAY out_regs[C_DATA_WIDTH*(NUM_STAGES-2)+:C_DATA_WIDTH]; RDADDRECC <= #FLOP_DELAY rdaddrecc_regs[C_ADDRB_WIDTH*(NUM_STAGES-2)+:C_ADDRB_WIDTH]; SBITERR <= #FLOP_DELAY sbiterr_regs[NUM_STAGES-2]; DBITERR <= #FLOP_DELAY dbiterr_regs[NUM_STAGES-2]; end //Output signal assignments end else begin //RST has priority if (rst_i) begin DOUT <= #FLOP_DELAY init_val; RDADDRECC <= #FLOP_DELAY 0; SBITERR <= #FLOP_DELAY 1'b0; DBITERR <= #FLOP_DELAY 1'b0; end else if (regce_i) begin DOUT <= #FLOP_DELAY out_regs[C_DATA_WIDTH*(NUM_STAGES-2)+:C_DATA_WIDTH]; RDADDRECC <= #FLOP_DELAY rdaddrecc_regs[C_ADDRB_WIDTH*(NUM_STAGES-2)+:C_ADDRB_WIDTH]; SBITERR <= #FLOP_DELAY sbiterr_regs[NUM_STAGES-2]; DBITERR <= #FLOP_DELAY dbiterr_regs[NUM_STAGES-2]; end //Output signal assignments end //end Priority conditions // Shift the data through the output stages if (en_i) begin out_regs <= #FLOP_DELAY (out_regs << C_DATA_WIDTH) | DIN; rdaddrecc_regs <= #FLOP_DELAY (rdaddrecc_regs << C_ADDRB_WIDTH) | RDADDRECC_IN; sbiterr_regs <= #FLOP_DELAY (sbiterr_regs << 1) | SBITERR_IN; dbiterr_regs <= #FLOP_DELAY (dbiterr_regs << 1) | DBITERR_IN; end end //end CLK end //end multi_stage generate statement endgenerate endmodule module BLK_MEM_GEN_v8_2_softecc_output_reg_stage #(parameter C_DATA_WIDTH = 32, parameter C_ADDRB_WIDTH = 10, parameter C_HAS_SOFTECC_OUTPUT_REGS_B= 0, parameter C_USE_SOFTECC = 0, parameter FLOP_DELAY = 100 ) ( input CLK, input [C_DATA_WIDTH-1:0] DIN, output reg [C_DATA_WIDTH-1:0] DOUT, input SBITERR_IN, input DBITERR_IN, output reg SBITERR, output reg DBITERR, input [C_ADDRB_WIDTH-1:0] RDADDRECC_IN, output reg [C_ADDRB_WIDTH-1:0] RDADDRECC ); //****************************** // Port and Generic Definitions //****************************** ////////////////////////////////////////////////////////////////////////// // Generic Definitions ////////////////////////////////////////////////////////////////////////// // C_DATA_WIDTH : Memory write/read width // C_ADDRB_WIDTH : Width of the ADDRB input port // C_HAS_SOFTECC_OUTPUT_REGS_B : Designates the use of a register at the output // of the RAM primitive // C_USE_SOFTECC : Determines if the Soft ECC feature is used or // not. Only applicable Spartan-6 // FLOP_DELAY : Constant delay for register assignments ////////////////////////////////////////////////////////////////////////// // Port Definitions ////////////////////////////////////////////////////////////////////////// // CLK : Clock to synchronize all read and write operations // DIN : Data input to the Output stage. // DOUT : Final Data output // SBITERR_IN : SBITERR input signal to the Output stage. // SBITERR : Final SBITERR Output signal. // DBITERR_IN : DBITERR input signal to the Output stage. // DBITERR : Final DBITERR Output signal. // RDADDRECC_IN : RDADDRECC input signal to the Output stage. // RDADDRECC : Final RDADDRECC Output signal. ////////////////////////////////////////////////////////////////////////// reg [C_DATA_WIDTH-1:0] dout_i = 0; reg sbiterr_i = 0; reg dbiterr_i = 0; reg [C_ADDRB_WIDTH-1:0] rdaddrecc_i = 0; //*********************************************** // NO OUTPUT REGISTERS. //*********************************************** generate if (C_HAS_SOFTECC_OUTPUT_REGS_B==0) begin : no_output_stage always @* begin DOUT = DIN; RDADDRECC = RDADDRECC_IN; SBITERR = SBITERR_IN; DBITERR = DBITERR_IN; end end endgenerate //*********************************************** // WITH OUTPUT REGISTERS. //*********************************************** generate if (C_HAS_SOFTECC_OUTPUT_REGS_B==1) begin : has_output_stage always @(posedge CLK) begin dout_i <= #FLOP_DELAY DIN; rdaddrecc_i <= #FLOP_DELAY RDADDRECC_IN; sbiterr_i <= #FLOP_DELAY SBITERR_IN; dbiterr_i <= #FLOP_DELAY DBITERR_IN; end always @* begin DOUT = dout_i; RDADDRECC = rdaddrecc_i; SBITERR = sbiterr_i; DBITERR = dbiterr_i; end //end always end //end in_or_out_stage generate statement endgenerate endmodule //***************************************************************************** // Main Memory module // // This module is the top-level behavioral model and this implements the RAM //***************************************************************************** module BLK_MEM_GEN_v8_2_mem_module #(parameter C_CORENAME = "blk_mem_gen_v8_2", parameter C_FAMILY = "virtex7", parameter C_XDEVICEFAMILY = "virtex7", parameter C_MEM_TYPE = 2, parameter C_BYTE_SIZE = 9, parameter C_USE_BRAM_BLOCK = 0, parameter C_ALGORITHM = 1, parameter C_PRIM_TYPE = 3, parameter C_LOAD_INIT_FILE = 0, parameter C_INIT_FILE_NAME = "", parameter C_INIT_FILE = "", parameter C_USE_DEFAULT_DATA = 0, parameter C_DEFAULT_DATA = "0", parameter C_RST_TYPE = "SYNC", parameter C_HAS_RSTA = 0, parameter C_RST_PRIORITY_A = "CE", parameter C_RSTRAM_A = 0, parameter C_INITA_VAL = "0", parameter C_HAS_ENA = 1, parameter C_HAS_REGCEA = 0, parameter C_USE_BYTE_WEA = 0, parameter C_WEA_WIDTH = 1, parameter C_WRITE_MODE_A = "WRITE_FIRST", parameter C_WRITE_WIDTH_A = 32, parameter C_READ_WIDTH_A = 32, parameter C_WRITE_DEPTH_A = 64, parameter C_READ_DEPTH_A = 64, parameter C_ADDRA_WIDTH = 5, parameter C_HAS_RSTB = 0, parameter C_RST_PRIORITY_B = "CE", parameter C_RSTRAM_B = 0, parameter C_INITB_VAL = "", parameter C_HAS_ENB = 1, parameter C_HAS_REGCEB = 0, parameter C_USE_BYTE_WEB = 0, parameter C_WEB_WIDTH = 1, parameter C_WRITE_MODE_B = "WRITE_FIRST", parameter C_WRITE_WIDTH_B = 32, parameter C_READ_WIDTH_B = 32, parameter C_WRITE_DEPTH_B = 64, parameter C_READ_DEPTH_B = 64, parameter C_ADDRB_WIDTH = 5, parameter C_HAS_MEM_OUTPUT_REGS_A = 0, parameter C_HAS_MEM_OUTPUT_REGS_B = 0, parameter C_HAS_MUX_OUTPUT_REGS_A = 0, parameter C_HAS_MUX_OUTPUT_REGS_B = 0, parameter C_HAS_SOFTECC_INPUT_REGS_A = 0, parameter C_HAS_SOFTECC_OUTPUT_REGS_B= 0, parameter C_MUX_PIPELINE_STAGES = 0, parameter C_USE_SOFTECC = 0, parameter C_USE_ECC = 0, parameter C_HAS_INJECTERR = 0, parameter C_SIM_COLLISION_CHECK = "NONE", parameter C_COMMON_CLK = 1, parameter FLOP_DELAY = 100, parameter C_DISABLE_WARN_BHV_COLL = 0, parameter C_EN_ECC_PIPE = 0, parameter C_DISABLE_WARN_BHV_RANGE = 0 ) (input CLKA, input RSTA, input ENA, input REGCEA, input [C_WEA_WIDTH-1:0] WEA, input [C_ADDRA_WIDTH-1:0] ADDRA, input [C_WRITE_WIDTH_A-1:0] DINA, output [C_READ_WIDTH_A-1:0] DOUTA, input CLKB, input RSTB, input ENB, input REGCEB, input [C_WEB_WIDTH-1:0] WEB, input [C_ADDRB_WIDTH-1:0] ADDRB, input [C_WRITE_WIDTH_B-1:0] DINB, output [C_READ_WIDTH_B-1:0] DOUTB, input INJECTSBITERR, input INJECTDBITERR, input ECCPIPECE, input SLEEP, output SBITERR, output DBITERR, output [C_ADDRB_WIDTH-1:0] RDADDRECC ); //****************************** // Port and Generic Definitions //****************************** ////////////////////////////////////////////////////////////////////////// // Generic Definitions ////////////////////////////////////////////////////////////////////////// // C_CORENAME : Instance name of the Block Memory Generator core // C_FAMILY,C_XDEVICEFAMILY: Designates architecture targeted. The following // options are available - "spartan3", "spartan6", // "virtex4", "virtex5", "virtex6" and "virtex6l". // C_MEM_TYPE : Designates memory type. // It can be // 0 - Single Port Memory // 1 - Simple Dual Port Memory // 2 - True Dual Port Memory // 3 - Single Port Read Only Memory // 4 - Dual Port Read Only Memory // C_BYTE_SIZE : Size of a byte (8 or 9 bits) // C_ALGORITHM : Designates the algorithm method used // for constructing the memory. // It can be Fixed_Primitives, Minimum_Area or // Low_Power // C_PRIM_TYPE : Designates the user selected primitive used to // construct the memory. // // C_LOAD_INIT_FILE : Designates the use of an initialization file to // initialize memory contents. // C_INIT_FILE_NAME : Memory initialization file name. // C_USE_DEFAULT_DATA : Designates whether to fill remaining // initialization space with default data // C_DEFAULT_DATA : Default value of all memory locations // not initialized by the memory // initialization file. // C_RST_TYPE : Type of reset - Synchronous or Asynchronous // C_HAS_RSTA : Determines the presence of the RSTA port // C_RST_PRIORITY_A : Determines the priority between CE and SR for // Port A. // C_RSTRAM_A : Determines if special reset behavior is used for // Port A // C_INITA_VAL : The initialization value for Port A // C_HAS_ENA : Determines the presence of the ENA port // C_HAS_REGCEA : Determines the presence of the REGCEA port // C_USE_BYTE_WEA : Determines if the Byte Write is used or not. // C_WEA_WIDTH : The width of the WEA port // C_WRITE_MODE_A : Configurable write mode for Port A. It can be // WRITE_FIRST, READ_FIRST or NO_CHANGE. // C_WRITE_WIDTH_A : Memory write width for Port A. // C_READ_WIDTH_A : Memory read width for Port A. // C_WRITE_DEPTH_A : Memory write depth for Port A. // C_READ_DEPTH_A : Memory read depth for Port A. // C_ADDRA_WIDTH : Width of the ADDRA input port // C_HAS_RSTB : Determines the presence of the RSTB port // C_RST_PRIORITY_B : Determines the priority between CE and SR for // Port B. // C_RSTRAM_B : Determines if special reset behavior is used for // Port B // C_INITB_VAL : The initialization value for Port B // C_HAS_ENB : Determines the presence of the ENB port // C_HAS_REGCEB : Determines the presence of the REGCEB port // C_USE_BYTE_WEB : Determines if the Byte Write is used or not. // C_WEB_WIDTH : The width of the WEB port // C_WRITE_MODE_B : Configurable write mode for Port B. It can be // WRITE_FIRST, READ_FIRST or NO_CHANGE. // C_WRITE_WIDTH_B : Memory write width for Port B. // C_READ_WIDTH_B : Memory read width for Port B. // C_WRITE_DEPTH_B : Memory write depth for Port B. // C_READ_DEPTH_B : Memory read depth for Port B. // C_ADDRB_WIDTH : Width of the ADDRB input port // C_HAS_MEM_OUTPUT_REGS_A : Designates the use of a register at the output // of the RAM primitive for Port A. // C_HAS_MEM_OUTPUT_REGS_B : Designates the use of a register at the output // of the RAM primitive for Port B. // C_HAS_MUX_OUTPUT_REGS_A : Designates the use of a register at the output // of the MUX for Port A. // C_HAS_MUX_OUTPUT_REGS_B : Designates the use of a register at the output // of the MUX for Port B. // C_MUX_PIPELINE_STAGES : Designates the number of pipeline stages in // between the muxes. // C_USE_SOFTECC : Determines if the Soft ECC feature is used or // not. Only applicable Spartan-6 // C_USE_ECC : Determines if the ECC feature is used or // not. Only applicable for V5 and V6 // C_HAS_INJECTERR : Determines if the error injection pins // are present or not. If the ECC feature // is not used, this value is defaulted to // 0, else the following are the allowed // values: // 0 : No INJECTSBITERR or INJECTDBITERR pins // 1 : Only INJECTSBITERR pin exists // 2 : Only INJECTDBITERR pin exists // 3 : Both INJECTSBITERR and INJECTDBITERR pins exist // C_SIM_COLLISION_CHECK : Controls the disabling of Unisim model collision // warnings. It can be "ALL", "NONE", // "Warnings_Only" or "Generate_X_Only". // C_COMMON_CLK : Determins if the core has a single CLK input. // C_DISABLE_WARN_BHV_COLL : Controls the Behavioral Model Collision warnings // C_DISABLE_WARN_BHV_RANGE: Controls the Behavioral Model Out of Range // warnings ////////////////////////////////////////////////////////////////////////// // Port Definitions ////////////////////////////////////////////////////////////////////////// // CLKA : Clock to synchronize all read and write operations of Port A. // RSTA : Reset input to reset memory outputs to a user-defined // reset state for Port A. // ENA : Enable all read and write operations of Port A. // REGCEA : Register Clock Enable to control each pipeline output // register stages for Port A. // WEA : Write Enable to enable all write operations of Port A. // ADDRA : Address of Port A. // DINA : Data input of Port A. // DOUTA : Data output of Port A. // CLKB : Clock to synchronize all read and write operations of Port B. // RSTB : Reset input to reset memory outputs to a user-defined // reset state for Port B. // ENB : Enable all read and write operations of Port B. // REGCEB : Register Clock Enable to control each pipeline output // register stages for Port B. // WEB : Write Enable to enable all write operations of Port B. // ADDRB : Address of Port B. // DINB : Data input of Port B. // DOUTB : Data output of Port B. // INJECTSBITERR : Single Bit ECC Error Injection Pin. // INJECTDBITERR : Double Bit ECC Error Injection Pin. // SBITERR : Output signal indicating that a Single Bit ECC Error has been // detected and corrected. // DBITERR : Output signal indicating that a Double Bit ECC Error has been // detected. // RDADDRECC : Read Address Output signal indicating address at which an // ECC error has occurred. ////////////////////////////////////////////////////////////////////////// // Note: C_CORENAME parameter is hard-coded to "blk_mem_gen_v8_2" and it is // only used by this module to print warning messages. It is neither passed // down from blk_mem_gen_v8_2_xst.v nor present in the instantiation template // coregen generates //*************************************************************************** // constants for the core behavior //*************************************************************************** // file handles for logging //-------------------------------------------------- localparam ADDRFILE = 32'h8000_0001; //stdout for addr out of range localparam COLLFILE = 32'h8000_0001; //stdout for coll detection localparam ERRFILE = 32'h8000_0001; //stdout for file I/O errors // other constants //-------------------------------------------------- localparam COLL_DELAY = 100; // 100 ps // locally derived parameters to determine memory shape //----------------------------------------------------- localparam CHKBIT_WIDTH = (C_WRITE_WIDTH_A>57 ? 8 : (C_WRITE_WIDTH_A>26 ? 7 : (C_WRITE_WIDTH_A>11 ? 6 : (C_WRITE_WIDTH_A>4 ? 5 : (C_WRITE_WIDTH_A<5 ? 4 :0))))); localparam MIN_WIDTH_A = (C_WRITE_WIDTH_A < C_READ_WIDTH_A) ? C_WRITE_WIDTH_A : C_READ_WIDTH_A; localparam MIN_WIDTH_B = (C_WRITE_WIDTH_B < C_READ_WIDTH_B) ? C_WRITE_WIDTH_B : C_READ_WIDTH_B; localparam MIN_WIDTH = (MIN_WIDTH_A < MIN_WIDTH_B) ? MIN_WIDTH_A : MIN_WIDTH_B; localparam MAX_DEPTH_A = (C_WRITE_DEPTH_A > C_READ_DEPTH_A) ? C_WRITE_DEPTH_A : C_READ_DEPTH_A; localparam MAX_DEPTH_B = (C_WRITE_DEPTH_B > C_READ_DEPTH_B) ? C_WRITE_DEPTH_B : C_READ_DEPTH_B; localparam MAX_DEPTH = (MAX_DEPTH_A > MAX_DEPTH_B) ? MAX_DEPTH_A : MAX_DEPTH_B; // locally derived parameters to assist memory access //---------------------------------------------------- // Calculate the width ratios of each port with respect to the narrowest // port localparam WRITE_WIDTH_RATIO_A = C_WRITE_WIDTH_A/MIN_WIDTH; localparam READ_WIDTH_RATIO_A = C_READ_WIDTH_A/MIN_WIDTH; localparam WRITE_WIDTH_RATIO_B = C_WRITE_WIDTH_B/MIN_WIDTH; localparam READ_WIDTH_RATIO_B = C_READ_WIDTH_B/MIN_WIDTH; // To modify the LSBs of the 'wider' data to the actual // address value //---------------------------------------------------- localparam WRITE_ADDR_A_DIV = C_WRITE_WIDTH_A/MIN_WIDTH_A; localparam READ_ADDR_A_DIV = C_READ_WIDTH_A/MIN_WIDTH_A; localparam WRITE_ADDR_B_DIV = C_WRITE_WIDTH_B/MIN_WIDTH_B; localparam READ_ADDR_B_DIV = C_READ_WIDTH_B/MIN_WIDTH_B; // If byte writes aren't being used, make sure BYTE_SIZE is not // wider than the memory elements to avoid compilation warnings localparam BYTE_SIZE = (C_BYTE_SIZE < MIN_WIDTH) ? C_BYTE_SIZE : MIN_WIDTH; // The memory reg [MIN_WIDTH-1:0] memory [0:MAX_DEPTH-1]; reg [MIN_WIDTH-1:0] temp_mem_array [0:MAX_DEPTH-1]; reg [C_WRITE_WIDTH_A+CHKBIT_WIDTH-1:0] doublebit_error = 3; // ECC error arrays reg sbiterr_arr [0:MAX_DEPTH-1]; reg dbiterr_arr [0:MAX_DEPTH-1]; reg softecc_sbiterr_arr [0:MAX_DEPTH-1]; reg softecc_dbiterr_arr [0:MAX_DEPTH-1]; // Memory output 'latches' reg [C_READ_WIDTH_A-1:0] memory_out_a; reg [C_READ_WIDTH_B-1:0] memory_out_b; // ECC error inputs and outputs from output_stage module: reg sbiterr_in; wire sbiterr_sdp; reg dbiterr_in; wire dbiterr_sdp; wire [C_READ_WIDTH_B-1:0] dout_i; wire dbiterr_i; wire sbiterr_i; wire [C_ADDRB_WIDTH-1:0] rdaddrecc_i; reg [C_ADDRB_WIDTH-1:0] rdaddrecc_in; wire [C_ADDRB_WIDTH-1:0] rdaddrecc_sdp; // Reset values reg [C_READ_WIDTH_A-1:0] inita_val; reg [C_READ_WIDTH_B-1:0] initb_val; // Collision detect reg is_collision; reg is_collision_a, is_collision_delay_a; reg is_collision_b, is_collision_delay_b; // Temporary variables for initialization //--------------------------------------- integer status; integer initfile; integer meminitfile; // data input buffer reg [C_WRITE_WIDTH_A-1:0] mif_data; reg [C_WRITE_WIDTH_A-1:0] mem_data; // string values in hex reg [C_READ_WIDTH_A*8-1:0] inita_str = C_INITA_VAL; reg [C_READ_WIDTH_B*8-1:0] initb_str = C_INITB_VAL; reg [C_WRITE_WIDTH_A*8-1:0] default_data_str = C_DEFAULT_DATA; // initialization filename reg [1023*8-1:0] init_file_str = C_INIT_FILE_NAME; reg [1023*8-1:0] mem_init_file_str = C_INIT_FILE; //Constants used to calculate the effective address widths for each of the //four ports. integer cnt = 1; integer write_addr_a_width, read_addr_a_width; integer write_addr_b_width, read_addr_b_width; localparam C_FAMILY_LOCALPARAM = (C_FAMILY=="virtexu"?"virtex7":(C_FAMILY=="kintexu" ? "virtex7":(C_FAMILY=="virtex7" ? "virtex7" : (C_FAMILY=="virtex7l" ? "virtex7" : (C_FAMILY=="qvirtex7" ? "virtex7" : (C_FAMILY=="qvirtex7l" ? "virtex7" : (C_FAMILY=="kintex7" ? "virtex7" : (C_FAMILY=="kintex7l" ? "virtex7" : (C_FAMILY=="qkintex7" ? "virtex7" : (C_FAMILY=="qkintex7l" ? "virtex7" : (C_FAMILY=="artix7" ? "virtex7" : (C_FAMILY=="artix7l" ? "virtex7" : (C_FAMILY=="qartix7" ? "virtex7" : (C_FAMILY=="qartix7l" ? "virtex7" : (C_FAMILY=="aartix7" ? "virtex7" : (C_FAMILY=="zynq" ? "virtex7" : (C_FAMILY=="azynq" ? "virtex7" : (C_FAMILY=="qzynq" ? "virtex7" : C_FAMILY)))))))))))))))))); // Internal configuration parameters //--------------------------------------------- localparam SINGLE_PORT = (C_MEM_TYPE==0 || C_MEM_TYPE==3); localparam IS_ROM = (C_MEM_TYPE==3 || C_MEM_TYPE==4); localparam HAS_A_WRITE = (!IS_ROM); localparam HAS_B_WRITE = (C_MEM_TYPE==2); localparam HAS_A_READ = (C_MEM_TYPE!=1); localparam HAS_B_READ = (!SINGLE_PORT); localparam HAS_B_PORT = (HAS_B_READ || HAS_B_WRITE); // Calculate the mux pipeline register stages for Port A and Port B //------------------------------------------------------------------ localparam MUX_PIPELINE_STAGES_A = (C_HAS_MUX_OUTPUT_REGS_A) ? C_MUX_PIPELINE_STAGES : 0; localparam MUX_PIPELINE_STAGES_B = (C_HAS_MUX_OUTPUT_REGS_B) ? C_MUX_PIPELINE_STAGES : 0; // Calculate total number of register stages in the core // ----------------------------------------------------- localparam NUM_OUTPUT_STAGES_A = (C_HAS_MEM_OUTPUT_REGS_A+MUX_PIPELINE_STAGES_A+C_HAS_MUX_OUTPUT_REGS_A); localparam NUM_OUTPUT_STAGES_B = (C_HAS_MEM_OUTPUT_REGS_B+MUX_PIPELINE_STAGES_B+C_HAS_MUX_OUTPUT_REGS_B); wire ena_i; wire enb_i; wire reseta_i; wire resetb_i; wire [C_WEA_WIDTH-1:0] wea_i; wire [C_WEB_WIDTH-1:0] web_i; wire rea_i; wire reb_i; wire rsta_outp_stage; wire rstb_outp_stage; // ECC SBITERR/DBITERR Outputs // The ECC Behavior is modeled by the behavioral models only for Virtex-6. // For Virtex-5, these outputs will be tied to 0. assign SBITERR = ((C_MEM_TYPE == 1 && C_USE_ECC == 1) || C_USE_SOFTECC == 1)?sbiterr_sdp:0; assign DBITERR = ((C_MEM_TYPE == 1 && C_USE_ECC == 1) || C_USE_SOFTECC == 1)?dbiterr_sdp:0; assign RDADDRECC = (((C_FAMILY_LOCALPARAM == "virtex7") && C_MEM_TYPE == 1 && C_USE_ECC == 1) || C_USE_SOFTECC == 1)?rdaddrecc_sdp:0; // This effectively wires off optional inputs assign ena_i = (C_HAS_ENA==0) || ENA; assign enb_i = ((C_HAS_ENB==0) || ENB) && HAS_B_PORT; assign wea_i = (HAS_A_WRITE && ena_i) ? WEA : 'b0; assign web_i = (HAS_B_WRITE && enb_i) ? WEB : 'b0; assign rea_i = (HAS_A_READ) ? ena_i : 'b0; assign reb_i = (HAS_B_READ) ? enb_i : 'b0; // These signals reset the memory latches assign reseta_i = ((C_HAS_RSTA==1 && RSTA && NUM_OUTPUT_STAGES_A==0) || (C_HAS_RSTA==1 && RSTA && C_RSTRAM_A==1)); assign resetb_i = ((C_HAS_RSTB==1 && RSTB && NUM_OUTPUT_STAGES_B==0) || (C_HAS_RSTB==1 && RSTB && C_RSTRAM_B==1)); // Tasks to access the memory //--------------------------- //************** // write_a //************** task write_a (input reg [C_ADDRA_WIDTH-1:0] addr, input reg [C_WEA_WIDTH-1:0] byte_en, input reg [C_WRITE_WIDTH_A-1:0] data, input inj_sbiterr, input inj_dbiterr); reg [C_WRITE_WIDTH_A-1:0] current_contents; reg [C_ADDRA_WIDTH-1:0] address; integer i; begin // Shift the address by the ratio address = (addr/WRITE_ADDR_A_DIV); if (address >= C_WRITE_DEPTH_A) begin if (!C_DISABLE_WARN_BHV_RANGE) begin $fdisplay(ADDRFILE, "%0s WARNING: Address %0h is outside range for A Write", C_CORENAME, addr); end // valid address end else begin // Combine w/ byte writes if (C_USE_BYTE_WEA) begin // Get the current memory contents if (WRITE_WIDTH_RATIO_A == 1) begin // Workaround for IUS 5.5 part-select issue current_contents = memory[address]; end else begin for (i = 0; i < WRITE_WIDTH_RATIO_A; i = i + 1) begin current_contents[MIN_WIDTH*i+:MIN_WIDTH] = memory[address*WRITE_WIDTH_RATIO_A + i]; end end // Apply incoming bytes if (C_WEA_WIDTH == 1) begin // Workaround for IUS 5.5 part-select issue if (byte_en[0]) begin current_contents = data; end end else begin for (i = 0; i < C_WEA_WIDTH; i = i + 1) begin if (byte_en[i]) begin current_contents[BYTE_SIZE*i+:BYTE_SIZE] = data[BYTE_SIZE*i+:BYTE_SIZE]; end end end // No byte-writes, overwrite the whole word end else begin current_contents = data; end // Insert double bit errors: if (C_USE_ECC == 1) begin if ((C_HAS_INJECTERR == 2 || C_HAS_INJECTERR == 3) && inj_dbiterr == 1'b1) begin current_contents[0] = !(current_contents[0]); current_contents[1] = !(current_contents[1]); end end // Insert softecc double bit errors: if (C_USE_SOFTECC == 1) begin if ((C_HAS_INJECTERR == 2 || C_HAS_INJECTERR == 3) && inj_dbiterr == 1'b1) begin doublebit_error[C_WRITE_WIDTH_A+CHKBIT_WIDTH-1:2] = doublebit_error[C_WRITE_WIDTH_A+CHKBIT_WIDTH-3:0]; doublebit_error[0] = doublebit_error[C_WRITE_WIDTH_A+CHKBIT_WIDTH-1]; doublebit_error[1] = doublebit_error[C_WRITE_WIDTH_A+CHKBIT_WIDTH-2]; current_contents = current_contents ^ doublebit_error[C_WRITE_WIDTH_A-1:0]; end end // Write data to memory if (WRITE_WIDTH_RATIO_A == 1) begin // Workaround for IUS 5.5 part-select issue memory[address*WRITE_WIDTH_RATIO_A] = current_contents; end else begin for (i = 0; i < WRITE_WIDTH_RATIO_A; i = i + 1) begin memory[address*WRITE_WIDTH_RATIO_A + i] = current_contents[MIN_WIDTH*i+:MIN_WIDTH]; end end // Store the address at which error is injected: if ((C_FAMILY_LOCALPARAM == "virtex7") && C_USE_ECC == 1) begin if ((C_HAS_INJECTERR == 1 && inj_sbiterr == 1'b1) || (C_HAS_INJECTERR == 3 && inj_sbiterr == 1'b1 && inj_dbiterr != 1'b1)) begin sbiterr_arr[addr] = 1; end else begin sbiterr_arr[addr] = 0; end if ((C_HAS_INJECTERR == 2 || C_HAS_INJECTERR == 3) && inj_dbiterr == 1'b1) begin dbiterr_arr[addr] = 1; end else begin dbiterr_arr[addr] = 0; end end // Store the address at which softecc error is injected: if (C_USE_SOFTECC == 1) begin if ((C_HAS_INJECTERR == 1 && inj_sbiterr == 1'b1) || (C_HAS_INJECTERR == 3 && inj_sbiterr == 1'b1 && inj_dbiterr != 1'b1)) begin softecc_sbiterr_arr[addr] = 1; end else begin softecc_sbiterr_arr[addr] = 0; end if ((C_HAS_INJECTERR == 2 || C_HAS_INJECTERR == 3) && inj_dbiterr == 1'b1) begin softecc_dbiterr_arr[addr] = 1; end else begin softecc_dbiterr_arr[addr] = 0; end end end end endtask //************** // write_b //************** task write_b (input reg [C_ADDRB_WIDTH-1:0] addr, input reg [C_WEB_WIDTH-1:0] byte_en, input reg [C_WRITE_WIDTH_B-1:0] data); reg [C_WRITE_WIDTH_B-1:0] current_contents; reg [C_ADDRB_WIDTH-1:0] address; integer i; begin // Shift the address by the ratio address = (addr/WRITE_ADDR_B_DIV); if (address >= C_WRITE_DEPTH_B) begin if (!C_DISABLE_WARN_BHV_RANGE) begin $fdisplay(ADDRFILE, "%0s WARNING: Address %0h is outside range for B Write", C_CORENAME, addr); end // valid address end else begin // Combine w/ byte writes if (C_USE_BYTE_WEB) begin // Get the current memory contents if (WRITE_WIDTH_RATIO_B == 1) begin // Workaround for IUS 5.5 part-select issue current_contents = memory[address]; end else begin for (i = 0; i < WRITE_WIDTH_RATIO_B; i = i + 1) begin current_contents[MIN_WIDTH*i+:MIN_WIDTH] = memory[address*WRITE_WIDTH_RATIO_B + i]; end end // Apply incoming bytes if (C_WEB_WIDTH == 1) begin // Workaround for IUS 5.5 part-select issue if (byte_en[0]) begin current_contents = data; end end else begin for (i = 0; i < C_WEB_WIDTH; i = i + 1) begin if (byte_en[i]) begin current_contents[BYTE_SIZE*i+:BYTE_SIZE] = data[BYTE_SIZE*i+:BYTE_SIZE]; end end end // No byte-writes, overwrite the whole word end else begin current_contents = data; end // Write data to memory if (WRITE_WIDTH_RATIO_B == 1) begin // Workaround for IUS 5.5 part-select issue memory[address*WRITE_WIDTH_RATIO_B] = current_contents; end else begin for (i = 0; i < WRITE_WIDTH_RATIO_B; i = i + 1) begin memory[address*WRITE_WIDTH_RATIO_B + i] = current_contents[MIN_WIDTH*i+:MIN_WIDTH]; end end end end endtask //************** // read_a //************** task read_a (input reg [C_ADDRA_WIDTH-1:0] addr, input reg reset); reg [C_ADDRA_WIDTH-1:0] address; integer i; begin if (reset) begin memory_out_a <= #FLOP_DELAY inita_val; end else begin // Shift the address by the ratio address = (addr/READ_ADDR_A_DIV); if (address >= C_READ_DEPTH_A) begin if (!C_DISABLE_WARN_BHV_RANGE) begin $fdisplay(ADDRFILE, "%0s WARNING: Address %0h is outside range for A Read", C_CORENAME, addr); end memory_out_a <= #FLOP_DELAY 'bX; // valid address end else begin if (READ_WIDTH_RATIO_A==1) begin memory_out_a <= #FLOP_DELAY memory[address*READ_WIDTH_RATIO_A]; end else begin // Increment through the 'partial' words in the memory for (i = 0; i < READ_WIDTH_RATIO_A; i = i + 1) begin memory_out_a[MIN_WIDTH*i+:MIN_WIDTH] <= #FLOP_DELAY memory[address*READ_WIDTH_RATIO_A + i]; end end //end READ_WIDTH_RATIO_A==1 loop end //end valid address loop end //end reset-data assignment loops end endtask //************** // read_b //************** task read_b (input reg [C_ADDRB_WIDTH-1:0] addr, input reg reset); reg [C_ADDRB_WIDTH-1:0] address; integer i; begin if (reset) begin memory_out_b <= #FLOP_DELAY initb_val; sbiterr_in <= #FLOP_DELAY 1'b0; dbiterr_in <= #FLOP_DELAY 1'b0; rdaddrecc_in <= #FLOP_DELAY 0; end else begin // Shift the address address = (addr/READ_ADDR_B_DIV); if (address >= C_READ_DEPTH_B) begin if (!C_DISABLE_WARN_BHV_RANGE) begin $fdisplay(ADDRFILE, "%0s WARNING: Address %0h is outside range for B Read", C_CORENAME, addr); end memory_out_b <= #FLOP_DELAY 'bX; sbiterr_in <= #FLOP_DELAY 1'bX; dbiterr_in <= #FLOP_DELAY 1'bX; rdaddrecc_in <= #FLOP_DELAY 'bX; // valid address end else begin if (READ_WIDTH_RATIO_B==1) begin memory_out_b <= #FLOP_DELAY memory[address*READ_WIDTH_RATIO_B]; end else begin // Increment through the 'partial' words in the memory for (i = 0; i < READ_WIDTH_RATIO_B; i = i + 1) begin memory_out_b[MIN_WIDTH*i+:MIN_WIDTH] <= #FLOP_DELAY memory[address*READ_WIDTH_RATIO_B + i]; end end if ((C_FAMILY_LOCALPARAM == "virtex7") && C_USE_ECC == 1) begin rdaddrecc_in <= #FLOP_DELAY addr; if (sbiterr_arr[addr] == 1) begin sbiterr_in <= #FLOP_DELAY 1'b1; end else begin sbiterr_in <= #FLOP_DELAY 1'b0; end if (dbiterr_arr[addr] == 1) begin dbiterr_in <= #FLOP_DELAY 1'b1; end else begin dbiterr_in <= #FLOP_DELAY 1'b0; end end else if (C_USE_SOFTECC == 1) begin rdaddrecc_in <= #FLOP_DELAY addr; if (softecc_sbiterr_arr[addr] == 1) begin sbiterr_in <= #FLOP_DELAY 1'b1; end else begin sbiterr_in <= #FLOP_DELAY 1'b0; end if (softecc_dbiterr_arr[addr] == 1) begin dbiterr_in <= #FLOP_DELAY 1'b1; end else begin dbiterr_in <= #FLOP_DELAY 1'b0; end end else begin rdaddrecc_in <= #FLOP_DELAY 0; dbiterr_in <= #FLOP_DELAY 1'b0; sbiterr_in <= #FLOP_DELAY 1'b0; end //end SOFTECC Loop end //end Valid address loop end //end reset-data assignment loops end endtask //************** // reset_a //************** task reset_a (input reg reset); begin if (reset) memory_out_a <= #FLOP_DELAY inita_val; end endtask //************** // reset_b //************** task reset_b (input reg reset); begin if (reset) memory_out_b <= #FLOP_DELAY initb_val; end endtask //************** // init_memory //************** task init_memory; integer i, j, addr_step; integer status; reg [C_WRITE_WIDTH_A-1:0] default_data; begin default_data = 0; //Display output message indicating that the behavioral model is being //initialized if (C_USE_DEFAULT_DATA || C_LOAD_INIT_FILE) $display(" Block Memory Generator module loading initial data..."); // Convert the default to hex if (C_USE_DEFAULT_DATA) begin if (default_data_str == "") begin $fdisplay(ERRFILE, "%0s ERROR: C_DEFAULT_DATA is empty!", C_CORENAME); $finish; end else begin status = $sscanf(default_data_str, "%h", default_data); if (status == 0) begin $fdisplay(ERRFILE, {"%0s ERROR: Unsuccessful hexadecimal read", "from C_DEFAULT_DATA: %0s"}, C_CORENAME, C_DEFAULT_DATA); $finish; end end end // Step by WRITE_ADDR_A_DIV through the memory via the // Port A write interface to hit every location once addr_step = WRITE_ADDR_A_DIV; // 'write' to every location with default (or 0) for (i = 0; i < C_WRITE_DEPTH_A*addr_step; i = i + addr_step) begin write_a(i, {C_WEA_WIDTH{1'b1}}, default_data, 1'b0, 1'b0); end // Get specialized data from the MIF file if (C_LOAD_INIT_FILE) begin if (init_file_str == "") begin $fdisplay(ERRFILE, "%0s ERROR: C_INIT_FILE_NAME is empty!", C_CORENAME); $finish; end else begin initfile = $fopen(init_file_str, "r"); if (initfile == 0) begin $fdisplay(ERRFILE, {"%0s, ERROR: Problem opening", "C_INIT_FILE_NAME: %0s!"}, C_CORENAME, init_file_str); $finish; end else begin // loop through the mif file, loading in the data for (i = 0; i < C_WRITE_DEPTH_A*addr_step; i = i + addr_step) begin status = $fscanf(initfile, "%b", mif_data); if (status > 0) begin write_a(i, {C_WEA_WIDTH{1'b1}}, mif_data, 1'b0, 1'b0); end end $fclose(initfile); end //initfile end //init_file_str end //C_LOAD_INIT_FILE if (C_USE_BRAM_BLOCK) begin // Get specialized data from the MIF file if (C_INIT_FILE != "NONE") begin if (mem_init_file_str == "") begin $fdisplay(ERRFILE, "%0s ERROR: C_INIT_FILE is empty!", C_CORENAME); $finish; end else begin meminitfile = $fopen(mem_init_file_str, "r"); if (meminitfile == 0) begin $fdisplay(ERRFILE, {"%0s, ERROR: Problem opening", "C_INIT_FILE: %0s!"}, C_CORENAME, mem_init_file_str); $finish; end else begin // loop through the mif file, loading in the data $readmemh(mem_init_file_str, memory ); for (j = 0; j < MAX_DEPTH-1 ; j = j + 1) begin end $fclose(meminitfile); end //meminitfile end //mem_init_file_str end //C_INIT_FILE end //C_USE_BRAM_BLOCK //Display output message indicating that the behavioral model is done //initializing if (C_USE_DEFAULT_DATA || C_LOAD_INIT_FILE) $display(" Block Memory Generator data initialization complete."); end endtask //************** // log2roundup //************** function integer log2roundup (input integer data_value); integer width; integer cnt; begin width = 0; if (data_value > 1) begin for(cnt=1 ; cnt < data_value ; cnt = cnt * 2) begin width = width + 1; end //loop end //if log2roundup = width; end //log2roundup endfunction //******************* // collision_check //******************* function integer collision_check (input reg [C_ADDRA_WIDTH-1:0] addr_a, input integer iswrite_a, input reg [C_ADDRB_WIDTH-1:0] addr_b, input integer iswrite_b); reg c_aw_bw, c_aw_br, c_ar_bw; integer scaled_addra_to_waddrb_width; integer scaled_addrb_to_waddrb_width; integer scaled_addra_to_waddra_width; integer scaled_addrb_to_waddra_width; integer scaled_addra_to_raddrb_width; integer scaled_addrb_to_raddrb_width; integer scaled_addra_to_raddra_width; integer scaled_addrb_to_raddra_width; begin c_aw_bw = 0; c_aw_br = 0; c_ar_bw = 0; //If write_addr_b_width is smaller, scale both addresses to that width for //comparing write_addr_a and write_addr_b; addr_a starts as C_ADDRA_WIDTH, //scale it down to write_addr_b_width. addr_b starts as C_ADDRB_WIDTH, //scale it down to write_addr_b_width. Once both are scaled to //write_addr_b_width, compare. scaled_addra_to_waddrb_width = ((addr_a)/ 2**(C_ADDRA_WIDTH-write_addr_b_width)); scaled_addrb_to_waddrb_width = ((addr_b)/ 2**(C_ADDRB_WIDTH-write_addr_b_width)); //If write_addr_a_width is smaller, scale both addresses to that width for //comparing write_addr_a and write_addr_b; addr_a starts as C_ADDRA_WIDTH, //scale it down to write_addr_a_width. addr_b starts as C_ADDRB_WIDTH, //scale it down to write_addr_a_width. Once both are scaled to //write_addr_a_width, compare. scaled_addra_to_waddra_width = ((addr_a)/ 2**(C_ADDRA_WIDTH-write_addr_a_width)); scaled_addrb_to_waddra_width = ((addr_b)/ 2**(C_ADDRB_WIDTH-write_addr_a_width)); //If read_addr_b_width is smaller, scale both addresses to that width for //comparing write_addr_a and read_addr_b; addr_a starts as C_ADDRA_WIDTH, //scale it down to read_addr_b_width. addr_b starts as C_ADDRB_WIDTH, //scale it down to read_addr_b_width. Once both are scaled to //read_addr_b_width, compare. scaled_addra_to_raddrb_width = ((addr_a)/ 2**(C_ADDRA_WIDTH-read_addr_b_width)); scaled_addrb_to_raddrb_width = ((addr_b)/ 2**(C_ADDRB_WIDTH-read_addr_b_width)); //If read_addr_a_width is smaller, scale both addresses to that width for //comparing read_addr_a and write_addr_b; addr_a starts as C_ADDRA_WIDTH, //scale it down to read_addr_a_width. addr_b starts as C_ADDRB_WIDTH, //scale it down to read_addr_a_width. Once both are scaled to //read_addr_a_width, compare. scaled_addra_to_raddra_width = ((addr_a)/ 2**(C_ADDRA_WIDTH-read_addr_a_width)); scaled_addrb_to_raddra_width = ((addr_b)/ 2**(C_ADDRB_WIDTH-read_addr_a_width)); //Look for a write-write collision. In order for a write-write //collision to exist, both ports must have a write transaction. if (iswrite_a && iswrite_b) begin if (write_addr_a_width > write_addr_b_width) begin if (scaled_addra_to_waddrb_width == scaled_addrb_to_waddrb_width) begin c_aw_bw = 1; end else begin c_aw_bw = 0; end end else begin if (scaled_addrb_to_waddra_width == scaled_addra_to_waddra_width) begin c_aw_bw = 1; end else begin c_aw_bw = 0; end end //width end //iswrite_a and iswrite_b //If the B port is reading (which means it is enabled - so could be //a TX_WRITE or TX_READ), then check for a write-read collision). //This could happen whether or not a write-write collision exists due //to asymmetric write/read ports. if (iswrite_a) begin if (write_addr_a_width > read_addr_b_width) begin if (scaled_addra_to_raddrb_width == scaled_addrb_to_raddrb_width) begin c_aw_br = 1; end else begin c_aw_br = 0; end end else begin if (scaled_addrb_to_waddra_width == scaled_addra_to_waddra_width) begin c_aw_br = 1; end else begin c_aw_br = 0; end end //width end //iswrite_a //If the A port is reading (which means it is enabled - so could be // a TX_WRITE or TX_READ), then check for a write-read collision). //This could happen whether or not a write-write collision exists due // to asymmetric write/read ports. if (iswrite_b) begin if (read_addr_a_width > write_addr_b_width) begin if (scaled_addra_to_waddrb_width == scaled_addrb_to_waddrb_width) begin c_ar_bw = 1; end else begin c_ar_bw = 0; end end else begin if (scaled_addrb_to_raddra_width == scaled_addra_to_raddra_width) begin c_ar_bw = 1; end else begin c_ar_bw = 0; end end //width end //iswrite_b collision_check = c_aw_bw | c_aw_br | c_ar_bw; end endfunction //******************************* // power on values //******************************* initial begin // Load up the memory init_memory; // Load up the output registers and latches if ($sscanf(inita_str, "%h", inita_val)) begin memory_out_a = inita_val; end else begin memory_out_a = 0; end if ($sscanf(initb_str, "%h", initb_val)) begin memory_out_b = initb_val; end else begin memory_out_b = 0; end sbiterr_in = 1'b0; dbiterr_in = 1'b0; rdaddrecc_in = 0; // Determine the effective address widths for each of the 4 ports write_addr_a_width = C_ADDRA_WIDTH - log2roundup(WRITE_ADDR_A_DIV); read_addr_a_width = C_ADDRA_WIDTH - log2roundup(READ_ADDR_A_DIV); write_addr_b_width = C_ADDRB_WIDTH - log2roundup(WRITE_ADDR_B_DIV); read_addr_b_width = C_ADDRB_WIDTH - log2roundup(READ_ADDR_B_DIV); $display("Block Memory Generator module %m is using a behavioral model for simulation which will not precisely model memory collision behavior."); end //*************************************************************************** // These are the main blocks which schedule read and write operations // Note that the reset priority feature at the latch stage is only supported // for Spartan-6. For other families, the default priority at the latch stage // is "CE" //*************************************************************************** // Synchronous clocks: schedule port operations with respect to // both write operating modes generate if(C_COMMON_CLK && (C_WRITE_MODE_A == "WRITE_FIRST") && (C_WRITE_MODE_B == "WRITE_FIRST")) begin : com_clk_sched_wf_wf always @(posedge CLKA) begin //Write A if (wea_i) write_a(ADDRA, wea_i, DINA, INJECTSBITERR, INJECTDBITERR); //Write B if (web_i) write_b(ADDRB, web_i, DINB); if (rea_i) read_a(ADDRA, reseta_i); //Read B if (reb_i) read_b(ADDRB, resetb_i); end end else if(C_COMMON_CLK && (C_WRITE_MODE_A == "READ_FIRST") && (C_WRITE_MODE_B == "WRITE_FIRST")) begin : com_clk_sched_rf_wf always @(posedge CLKA) begin //Write B if (web_i) write_b(ADDRB, web_i, DINB); //Read B if (reb_i) read_b(ADDRB, resetb_i); //Read A if (rea_i) read_a(ADDRA, reseta_i); //Write A if (wea_i) write_a(ADDRA, wea_i, DINA, INJECTSBITERR, INJECTDBITERR); end end else if(C_COMMON_CLK && (C_WRITE_MODE_A == "WRITE_FIRST") && (C_WRITE_MODE_B == "READ_FIRST")) begin : com_clk_sched_wf_rf always @(posedge CLKA) begin //Write A if (wea_i) write_a(ADDRA, wea_i, DINA, INJECTSBITERR, INJECTDBITERR); //Read A if (rea_i) read_a(ADDRA, reseta_i); //Read B if (reb_i) read_b(ADDRB, resetb_i); //Write B if (web_i) write_b(ADDRB, web_i, DINB); end end else if(C_COMMON_CLK && (C_WRITE_MODE_A == "READ_FIRST") && (C_WRITE_MODE_B == "READ_FIRST")) begin : com_clk_sched_rf_rf always @(posedge CLKA) begin //Read A if (rea_i) read_a(ADDRA, reseta_i); //Read B if (reb_i) read_b(ADDRB, resetb_i); //Write A if (wea_i) write_a(ADDRA, wea_i, DINA, INJECTSBITERR, INJECTDBITERR); //Write B if (web_i) write_b(ADDRB, web_i, DINB); end end else if(C_COMMON_CLK && (C_WRITE_MODE_A =="WRITE_FIRST") && (C_WRITE_MODE_B == "NO_CHANGE")) begin : com_clk_sched_wf_nc always @(posedge CLKA) begin //Write A if (wea_i) write_a(ADDRA, wea_i, DINA, INJECTSBITERR, INJECTDBITERR); //Read A if (rea_i) read_a(ADDRA, reseta_i); //Read B if (reb_i && (!web_i || resetb_i)) read_b(ADDRB, resetb_i); //Write B if (web_i) write_b(ADDRB, web_i, DINB); end end else if(C_COMMON_CLK && (C_WRITE_MODE_A =="READ_FIRST") && (C_WRITE_MODE_B == "NO_CHANGE")) begin : com_clk_sched_rf_nc always @(posedge CLKA) begin //Read A if (rea_i) read_a(ADDRA, reseta_i); //Read B if (reb_i && (!web_i || resetb_i)) read_b(ADDRB, resetb_i); //Write A if (wea_i) write_a(ADDRA, wea_i, DINA, INJECTSBITERR, INJECTDBITERR); //Write B if (web_i) write_b(ADDRB, web_i, DINB); end end else if(C_COMMON_CLK && (C_WRITE_MODE_A =="NO_CHANGE") && (C_WRITE_MODE_B == "WRITE_FIRST")) begin : com_clk_sched_nc_wf always @(posedge CLKA) begin //Write A if (wea_i) write_a(ADDRA, wea_i, DINA, INJECTSBITERR, INJECTDBITERR); //Write B if (web_i) write_b(ADDRB, web_i, DINB); //Read A if (rea_i && (!wea_i || reseta_i)) read_a(ADDRA, reseta_i); //Read B if (reb_i) read_b(ADDRB, resetb_i); end end else if(C_COMMON_CLK && (C_WRITE_MODE_A =="NO_CHANGE") && (C_WRITE_MODE_B == "READ_FIRST")) begin : com_clk_sched_nc_rf always @(posedge CLKA) begin //Read B if (reb_i) read_b(ADDRB, resetb_i); //Read A if (rea_i && (!wea_i || reseta_i)) read_a(ADDRA, reseta_i); //Write A if (wea_i) write_a(ADDRA, wea_i, DINA, INJECTSBITERR, INJECTDBITERR); //Write B if (web_i) write_b(ADDRB, web_i, DINB); end end else if(C_COMMON_CLK && (C_WRITE_MODE_A =="NO_CHANGE") && (C_WRITE_MODE_B == "NO_CHANGE")) begin : com_clk_sched_nc_nc always @(posedge CLKA) begin //Write A if (wea_i) write_a(ADDRA, wea_i, DINA, INJECTSBITERR, INJECTDBITERR); //Write B if (web_i) write_b(ADDRB, web_i, DINB); //Read A if (rea_i && (!wea_i || reseta_i)) read_a(ADDRA, reseta_i); //Read B if (reb_i && (!web_i || resetb_i)) read_b(ADDRB, resetb_i); end end else if(C_COMMON_CLK) begin: com_clk_sched_default always @(posedge CLKA) begin //Write A if (wea_i) write_a(ADDRA, wea_i, DINA, INJECTSBITERR, INJECTDBITERR); //Write B if (web_i) write_b(ADDRB, web_i, DINB); //Read A if (rea_i) read_a(ADDRA, reseta_i); //Read B if (reb_i) read_b(ADDRB, resetb_i); end end endgenerate // Asynchronous clocks: port operation is independent generate if((!C_COMMON_CLK) && (C_WRITE_MODE_A == "WRITE_FIRST")) begin : async_clk_sched_clka_wf always @(posedge CLKA) begin //Write A if (wea_i) write_a(ADDRA, wea_i, DINA, INJECTSBITERR, INJECTDBITERR); //Read A if (rea_i) read_a(ADDRA, reseta_i); end end else if((!C_COMMON_CLK) && (C_WRITE_MODE_A == "READ_FIRST")) begin : async_clk_sched_clka_rf always @(posedge CLKA) begin //Read A if (rea_i) read_a(ADDRA, reseta_i); //Write A if (wea_i) write_a(ADDRA, wea_i, DINA, INJECTSBITERR, INJECTDBITERR); end end else if((!C_COMMON_CLK) && (C_WRITE_MODE_A == "NO_CHANGE")) begin : async_clk_sched_clka_nc always @(posedge CLKA) begin //Write A if (wea_i) write_a(ADDRA, wea_i, DINA, INJECTSBITERR, INJECTDBITERR); //Read A if (rea_i && (!wea_i || reseta_i)) read_a(ADDRA, reseta_i); end end endgenerate generate if ((!C_COMMON_CLK) && (C_WRITE_MODE_B == "WRITE_FIRST")) begin: async_clk_sched_clkb_wf always @(posedge CLKB) begin //Write B if (web_i) write_b(ADDRB, web_i, DINB); //Read B if (reb_i) read_b(ADDRB, resetb_i); end end else if ((!C_COMMON_CLK) && (C_WRITE_MODE_B == "READ_FIRST")) begin: async_clk_sched_clkb_rf always @(posedge CLKB) begin //Read B if (reb_i) read_b(ADDRB, resetb_i); //Write B if (web_i) write_b(ADDRB, web_i, DINB); end end else if ((!C_COMMON_CLK) && (C_WRITE_MODE_B == "NO_CHANGE")) begin: async_clk_sched_clkb_nc always @(posedge CLKB) begin //Write B if (web_i) write_b(ADDRB, web_i, DINB); //Read B if (reb_i && (!web_i || resetb_i)) read_b(ADDRB, resetb_i); end end endgenerate //*************************************************************** // Instantiate the variable depth output register stage module //*************************************************************** // Port A assign rsta_outp_stage = RSTA & (~SLEEP); BLK_MEM_GEN_v8_2_output_stage #(.C_FAMILY (C_FAMILY), .C_XDEVICEFAMILY (C_XDEVICEFAMILY), .C_RST_TYPE ("SYNC"), .C_HAS_RST (C_HAS_RSTA), .C_RSTRAM (C_RSTRAM_A), .C_RST_PRIORITY (C_RST_PRIORITY_A), .C_INIT_VAL (C_INITA_VAL), .C_HAS_EN (C_HAS_ENA), .C_HAS_REGCE (C_HAS_REGCEA), .C_DATA_WIDTH (C_READ_WIDTH_A), .C_ADDRB_WIDTH (C_ADDRB_WIDTH), .C_HAS_MEM_OUTPUT_REGS (C_HAS_MEM_OUTPUT_REGS_A), .C_USE_SOFTECC (C_USE_SOFTECC), .C_USE_ECC (C_USE_ECC), .NUM_STAGES (NUM_OUTPUT_STAGES_A), .C_EN_ECC_PIPE (0), .FLOP_DELAY (FLOP_DELAY)) reg_a (.CLK (CLKA), .RST (rsta_outp_stage),//(RSTA), .EN (ENA), .REGCE (REGCEA), .DIN_I (memory_out_a), .DOUT (DOUTA), .SBITERR_IN_I (1'b0), .DBITERR_IN_I (1'b0), .SBITERR (), .DBITERR (), .RDADDRECC_IN_I ({C_ADDRB_WIDTH{1'b0}}), .ECCPIPECE (1'b0), .RDADDRECC () ); assign rstb_outp_stage = RSTB & (~SLEEP); // Port B BLK_MEM_GEN_v8_2_output_stage #(.C_FAMILY (C_FAMILY), .C_XDEVICEFAMILY (C_XDEVICEFAMILY), .C_RST_TYPE ("SYNC"), .C_HAS_RST (C_HAS_RSTB), .C_RSTRAM (C_RSTRAM_B), .C_RST_PRIORITY (C_RST_PRIORITY_B), .C_INIT_VAL (C_INITB_VAL), .C_HAS_EN (C_HAS_ENB), .C_HAS_REGCE (C_HAS_REGCEB), .C_DATA_WIDTH (C_READ_WIDTH_B), .C_ADDRB_WIDTH (C_ADDRB_WIDTH), .C_HAS_MEM_OUTPUT_REGS (C_HAS_MEM_OUTPUT_REGS_B), .C_USE_SOFTECC (C_USE_SOFTECC), .C_USE_ECC (C_USE_ECC), .NUM_STAGES (NUM_OUTPUT_STAGES_B), .C_EN_ECC_PIPE (C_EN_ECC_PIPE), .FLOP_DELAY (FLOP_DELAY)) reg_b (.CLK (CLKB), .RST (rstb_outp_stage),//(RSTB), .EN (ENB), .REGCE (REGCEB), .DIN_I (memory_out_b), .DOUT (dout_i), .SBITERR_IN_I (sbiterr_in), .DBITERR_IN_I (dbiterr_in), .SBITERR (sbiterr_i), .DBITERR (dbiterr_i), .RDADDRECC_IN_I (rdaddrecc_in), .ECCPIPECE (ECCPIPECE), .RDADDRECC (rdaddrecc_i) ); //*************************************************************** // Instantiate the Input and Output register stages //*************************************************************** BLK_MEM_GEN_v8_2_softecc_output_reg_stage #(.C_DATA_WIDTH (C_READ_WIDTH_B), .C_ADDRB_WIDTH (C_ADDRB_WIDTH), .C_HAS_SOFTECC_OUTPUT_REGS_B (C_HAS_SOFTECC_OUTPUT_REGS_B), .C_USE_SOFTECC (C_USE_SOFTECC), .FLOP_DELAY (FLOP_DELAY)) has_softecc_output_reg_stage (.CLK (CLKB), .DIN (dout_i), .DOUT (DOUTB), .SBITERR_IN (sbiterr_i), .DBITERR_IN (dbiterr_i), .SBITERR (sbiterr_sdp), .DBITERR (dbiterr_sdp), .RDADDRECC_IN (rdaddrecc_i), .RDADDRECC (rdaddrecc_sdp) ); //**************************************************** // Synchronous collision checks //**************************************************** // CR 780544 : To make verilog model's collison warnings in consistant with // vhdl model, the non-blocking assignments are replaced with blocking // assignments. generate if (!C_DISABLE_WARN_BHV_COLL && C_COMMON_CLK) begin : sync_coll always @(posedge CLKA) begin // Possible collision if both are enabled and the addresses match if (ena_i && enb_i) begin if (wea_i || web_i) begin is_collision = collision_check(ADDRA, wea_i, ADDRB, web_i); end else begin is_collision = 0; end end else begin is_collision = 0; end // If the write port is in READ_FIRST mode, there is no collision if (C_WRITE_MODE_A=="READ_FIRST" && wea_i && !web_i) begin is_collision = 0; end if (C_WRITE_MODE_B=="READ_FIRST" && web_i && !wea_i) begin is_collision = 0; end // Only flag if one of the accesses is a write if (is_collision && (wea_i || web_i)) begin $fwrite(COLLFILE, "%0s collision detected at time: %0d, ", C_CORENAME, $time); $fwrite(COLLFILE, "A %0s address: %0h, B %0s address: %0h\n", wea_i ? "write" : "read", ADDRA, web_i ? "write" : "read", ADDRB); end end //**************************************************** // Asynchronous collision checks //**************************************************** end else if (!C_DISABLE_WARN_BHV_COLL && !C_COMMON_CLK) begin : async_coll // Delay A and B addresses in order to mimic setup/hold times wire [C_ADDRA_WIDTH-1:0] #COLL_DELAY addra_delay = ADDRA; wire [0:0] #COLL_DELAY wea_delay = wea_i; wire #COLL_DELAY ena_delay = ena_i; wire [C_ADDRB_WIDTH-1:0] #COLL_DELAY addrb_delay = ADDRB; wire [0:0] #COLL_DELAY web_delay = web_i; wire #COLL_DELAY enb_delay = enb_i; // Do the checks w/rt A always @(posedge CLKA) begin // Possible collision if both are enabled and the addresses match if (ena_i && enb_i) begin if (wea_i || web_i) begin is_collision_a = collision_check(ADDRA, wea_i, ADDRB, web_i); end else begin is_collision_a = 0; end end else begin is_collision_a = 0; end if (ena_i && enb_delay) begin if(wea_i || web_delay) begin is_collision_delay_a = collision_check(ADDRA, wea_i, addrb_delay, web_delay); end else begin is_collision_delay_a = 0; end end else begin is_collision_delay_a = 0; end // Only flag if B access is a write if (is_collision_a && web_i) begin $fwrite(COLLFILE, "%0s collision detected at time: %0d, ", C_CORENAME, $time); $fwrite(COLLFILE, "A %0s address: %0h, B write address: %0h\n", wea_i ? "write" : "read", ADDRA, ADDRB); end else if (is_collision_delay_a && web_delay) begin $fwrite(COLLFILE, "%0s collision detected at time: %0d, ", C_CORENAME, $time); $fwrite(COLLFILE, "A %0s address: %0h, B write address: %0h\n", wea_i ? "write" : "read", ADDRA, addrb_delay); end end // Do the checks w/rt B always @(posedge CLKB) begin // Possible collision if both are enabled and the addresses match if (ena_i && enb_i) begin if (wea_i || web_i) begin is_collision_b = collision_check(ADDRA, wea_i, ADDRB, web_i); end else begin is_collision_b = 0; end end else begin is_collision_b = 0; end if (ena_delay && enb_i) begin if (wea_delay || web_i) begin is_collision_delay_b = collision_check(addra_delay, wea_delay, ADDRB, web_i); end else begin is_collision_delay_b = 0; end end else begin is_collision_delay_b = 0; end // Only flag if A access is a write if (is_collision_b && wea_i) begin $fwrite(COLLFILE, "%0s collision detected at time: %0d, ", C_CORENAME, $time); $fwrite(COLLFILE, "A write address: %0h, B %s address: %0h\n", ADDRA, web_i ? "write" : "read", ADDRB); end else if (is_collision_delay_b && wea_delay) begin $fwrite(COLLFILE, "%0s collision detected at time: %0d, ", C_CORENAME, $time); $fwrite(COLLFILE, "A write address: %0h, B %s address: %0h\n", addra_delay, web_i ? "write" : "read", ADDRB); end end end endgenerate endmodule //***************************************************************************** // Top module wraps Input register and Memory module // // This module is the top-level behavioral model and this implements the memory // module and the input registers //***************************************************************************** module blk_mem_gen_v8_2 #(parameter C_CORENAME = "blk_mem_gen_v8_2", parameter C_FAMILY = "virtex7", parameter C_XDEVICEFAMILY = "virtex7", parameter C_ELABORATION_DIR = "", parameter C_INTERFACE_TYPE = 0, parameter C_USE_BRAM_BLOCK = 0, parameter C_CTRL_ECC_ALGO = "NONE", parameter C_ENABLE_32BIT_ADDRESS = 0, parameter C_AXI_TYPE = 0, parameter C_AXI_SLAVE_TYPE = 0, parameter C_HAS_AXI_ID = 0, parameter C_AXI_ID_WIDTH = 4, parameter C_MEM_TYPE = 2, parameter C_BYTE_SIZE = 9, parameter C_ALGORITHM = 1, parameter C_PRIM_TYPE = 3, parameter C_LOAD_INIT_FILE = 0, parameter C_INIT_FILE_NAME = "", parameter C_INIT_FILE = "", parameter C_USE_DEFAULT_DATA = 0, parameter C_DEFAULT_DATA = "0", //parameter C_RST_TYPE = "SYNC", parameter C_HAS_RSTA = 0, parameter C_RST_PRIORITY_A = "CE", parameter C_RSTRAM_A = 0, parameter C_INITA_VAL = "0", parameter C_HAS_ENA = 1, parameter C_HAS_REGCEA = 0, parameter C_USE_BYTE_WEA = 0, parameter C_WEA_WIDTH = 1, parameter C_WRITE_MODE_A = "WRITE_FIRST", parameter C_WRITE_WIDTH_A = 32, parameter C_READ_WIDTH_A = 32, parameter C_WRITE_DEPTH_A = 64, parameter C_READ_DEPTH_A = 64, parameter C_ADDRA_WIDTH = 5, parameter C_HAS_RSTB = 0, parameter C_RST_PRIORITY_B = "CE", parameter C_RSTRAM_B = 0, parameter C_INITB_VAL = "", parameter C_HAS_ENB = 1, parameter C_HAS_REGCEB = 0, parameter C_USE_BYTE_WEB = 0, parameter C_WEB_WIDTH = 1, parameter C_WRITE_MODE_B = "WRITE_FIRST", parameter C_WRITE_WIDTH_B = 32, parameter C_READ_WIDTH_B = 32, parameter C_WRITE_DEPTH_B = 64, parameter C_READ_DEPTH_B = 64, parameter C_ADDRB_WIDTH = 5, parameter C_HAS_MEM_OUTPUT_REGS_A = 0, parameter C_HAS_MEM_OUTPUT_REGS_B = 0, parameter C_HAS_MUX_OUTPUT_REGS_A = 0, parameter C_HAS_MUX_OUTPUT_REGS_B = 0, parameter C_HAS_SOFTECC_INPUT_REGS_A = 0, parameter C_HAS_SOFTECC_OUTPUT_REGS_B= 0, parameter C_MUX_PIPELINE_STAGES = 0, parameter C_USE_SOFTECC = 0, parameter C_USE_ECC = 0, parameter C_EN_ECC_PIPE = 0, parameter C_HAS_INJECTERR = 0, parameter C_SIM_COLLISION_CHECK = "NONE", parameter C_COMMON_CLK = 1, parameter C_DISABLE_WARN_BHV_COLL = 0, parameter C_EN_SLEEP_PIN = 0, parameter C_USE_URAM = 0, parameter C_EN_RDADDRA_CHG = 0, parameter C_EN_RDADDRB_CHG = 0, parameter C_EN_DEEPSLEEP_PIN = 0, parameter C_EN_SHUTDOWN_PIN = 0, parameter C_DISABLE_WARN_BHV_RANGE = 0, parameter C_COUNT_36K_BRAM = "", parameter C_COUNT_18K_BRAM = "", parameter C_EST_POWER_SUMMARY = "" ) (input clka, input rsta, input ena, input regcea, input [C_WEA_WIDTH-1:0] wea, input [C_ADDRA_WIDTH-1:0] addra, input [C_WRITE_WIDTH_A-1:0] dina, output [C_READ_WIDTH_A-1:0] douta, input clkb, input rstb, input enb, input regceb, input [C_WEB_WIDTH-1:0] web, input [C_ADDRB_WIDTH-1:0] addrb, input [C_WRITE_WIDTH_B-1:0] dinb, output [C_READ_WIDTH_B-1:0] doutb, input injectsbiterr, input injectdbiterr, output sbiterr, output dbiterr, output [C_ADDRB_WIDTH-1:0] rdaddrecc, input eccpipece, input sleep, input deepsleep, input shutdown, //AXI BMG Input and Output Port Declarations //AXI Global Signals input s_aclk, input s_aresetn, //AXI Full/lite slave write (write side) input [C_AXI_ID_WIDTH-1:0] s_axi_awid, input [31:0] s_axi_awaddr, input [7:0] s_axi_awlen, input [2:0] s_axi_awsize, input [1:0] s_axi_awburst, input s_axi_awvalid, output s_axi_awready, input [C_WRITE_WIDTH_A-1:0] s_axi_wdata, input [C_WEA_WIDTH-1:0] s_axi_wstrb, input s_axi_wlast, input s_axi_wvalid, output s_axi_wready, output [C_AXI_ID_WIDTH-1:0] s_axi_bid, output [1:0] s_axi_bresp, output s_axi_bvalid, input s_axi_bready, //AXI Full/lite slave read (write side) input [C_AXI_ID_WIDTH-1:0] s_axi_arid, input [31:0] s_axi_araddr, input [7:0] s_axi_arlen, input [2:0] s_axi_arsize, input [1:0] s_axi_arburst, input s_axi_arvalid, output s_axi_arready, output [C_AXI_ID_WIDTH-1:0] s_axi_rid, output [C_WRITE_WIDTH_B-1:0] s_axi_rdata, output [1:0] s_axi_rresp, output s_axi_rlast, output s_axi_rvalid, input s_axi_rready, //AXI Full/lite sideband signals input s_axi_injectsbiterr, input s_axi_injectdbiterr, output s_axi_sbiterr, output s_axi_dbiterr, output [C_ADDRB_WIDTH-1:0] s_axi_rdaddrecc ); //****************************** // Port and Generic Definitions //****************************** ////////////////////////////////////////////////////////////////////////// // Generic Definitions ////////////////////////////////////////////////////////////////////////// // C_CORENAME : Instance name of the Block Memory Generator core // C_FAMILY,C_XDEVICEFAMILY: Designates architecture targeted. The following // options are available - "spartan3", "spartan6", // "virtex4", "virtex5", "virtex6" and "virtex6l". // C_MEM_TYPE : Designates memory type. // It can be // 0 - Single Port Memory // 1 - Simple Dual Port Memory // 2 - True Dual Port Memory // 3 - Single Port Read Only Memory // 4 - Dual Port Read Only Memory // C_BYTE_SIZE : Size of a byte (8 or 9 bits) // C_ALGORITHM : Designates the algorithm method used // for constructing the memory. // It can be Fixed_Primitives, Minimum_Area or // Low_Power // C_PRIM_TYPE : Designates the user selected primitive used to // construct the memory. // // C_LOAD_INIT_FILE : Designates the use of an initialization file to // initialize memory contents. // C_INIT_FILE_NAME : Memory initialization file name. // C_USE_DEFAULT_DATA : Designates whether to fill remaining // initialization space with default data // C_DEFAULT_DATA : Default value of all memory locations // not initialized by the memory // initialization file. // C_RST_TYPE : Type of reset - Synchronous or Asynchronous // C_HAS_RSTA : Determines the presence of the RSTA port // C_RST_PRIORITY_A : Determines the priority between CE and SR for // Port A. // C_RSTRAM_A : Determines if special reset behavior is used for // Port A // C_INITA_VAL : The initialization value for Port A // C_HAS_ENA : Determines the presence of the ENA port // C_HAS_REGCEA : Determines the presence of the REGCEA port // C_USE_BYTE_WEA : Determines if the Byte Write is used or not. // C_WEA_WIDTH : The width of the WEA port // C_WRITE_MODE_A : Configurable write mode for Port A. It can be // WRITE_FIRST, READ_FIRST or NO_CHANGE. // C_WRITE_WIDTH_A : Memory write width for Port A. // C_READ_WIDTH_A : Memory read width for Port A. // C_WRITE_DEPTH_A : Memory write depth for Port A. // C_READ_DEPTH_A : Memory read depth for Port A. // C_ADDRA_WIDTH : Width of the ADDRA input port // C_HAS_RSTB : Determines the presence of the RSTB port // C_RST_PRIORITY_B : Determines the priority between CE and SR for // Port B. // C_RSTRAM_B : Determines if special reset behavior is used for // Port B // C_INITB_VAL : The initialization value for Port B // C_HAS_ENB : Determines the presence of the ENB port // C_HAS_REGCEB : Determines the presence of the REGCEB port // C_USE_BYTE_WEB : Determines if the Byte Write is used or not. // C_WEB_WIDTH : The width of the WEB port // C_WRITE_MODE_B : Configurable write mode for Port B. It can be // WRITE_FIRST, READ_FIRST or NO_CHANGE. // C_WRITE_WIDTH_B : Memory write width for Port B. // C_READ_WIDTH_B : Memory read width for Port B. // C_WRITE_DEPTH_B : Memory write depth for Port B. // C_READ_DEPTH_B : Memory read depth for Port B. // C_ADDRB_WIDTH : Width of the ADDRB input port // C_HAS_MEM_OUTPUT_REGS_A : Designates the use of a register at the output // of the RAM primitive for Port A. // C_HAS_MEM_OUTPUT_REGS_B : Designates the use of a register at the output // of the RAM primitive for Port B. // C_HAS_MUX_OUTPUT_REGS_A : Designates the use of a register at the output // of the MUX for Port A. // C_HAS_MUX_OUTPUT_REGS_B : Designates the use of a register at the output // of the MUX for Port B. // C_HAS_SOFTECC_INPUT_REGS_A : // C_HAS_SOFTECC_OUTPUT_REGS_B : // C_MUX_PIPELINE_STAGES : Designates the number of pipeline stages in // between the muxes. // C_USE_SOFTECC : Determines if the Soft ECC feature is used or // not. Only applicable Spartan-6 // C_USE_ECC : Determines if the ECC feature is used or // not. Only applicable for V5 and V6 // C_HAS_INJECTERR : Determines if the error injection pins // are present or not. If the ECC feature // is not used, this value is defaulted to // 0, else the following are the allowed // values: // 0 : No INJECTSBITERR or INJECTDBITERR pins // 1 : Only INJECTSBITERR pin exists // 2 : Only INJECTDBITERR pin exists // 3 : Both INJECTSBITERR and INJECTDBITERR pins exist // C_SIM_COLLISION_CHECK : Controls the disabling of Unisim model collision // warnings. It can be "ALL", "NONE", // "Warnings_Only" or "Generate_X_Only". // C_COMMON_CLK : Determins if the core has a single CLK input. // C_DISABLE_WARN_BHV_COLL : Controls the Behavioral Model Collision warnings // C_DISABLE_WARN_BHV_RANGE: Controls the Behavioral Model Out of Range // warnings ////////////////////////////////////////////////////////////////////////// // Port Definitions ////////////////////////////////////////////////////////////////////////// // CLKA : Clock to synchronize all read and write operations of Port A. // RSTA : Reset input to reset memory outputs to a user-defined // reset state for Port A. // ENA : Enable all read and write operations of Port A. // REGCEA : Register Clock Enable to control each pipeline output // register stages for Port A. // WEA : Write Enable to enable all write operations of Port A. // ADDRA : Address of Port A. // DINA : Data input of Port A. // DOUTA : Data output of Port A. // CLKB : Clock to synchronize all read and write operations of Port B. // RSTB : Reset input to reset memory outputs to a user-defined // reset state for Port B. // ENB : Enable all read and write operations of Port B. // REGCEB : Register Clock Enable to control each pipeline output // register stages for Port B. // WEB : Write Enable to enable all write operations of Port B. // ADDRB : Address of Port B. // DINB : Data input of Port B. // DOUTB : Data output of Port B. // INJECTSBITERR : Single Bit ECC Error Injection Pin. // INJECTDBITERR : Double Bit ECC Error Injection Pin. // SBITERR : Output signal indicating that a Single Bit ECC Error has been // detected and corrected. // DBITERR : Output signal indicating that a Double Bit ECC Error has been // detected. // RDADDRECC : Read Address Output signal indicating address at which an // ECC error has occurred. ////////////////////////////////////////////////////////////////////////// wire SBITERR; wire DBITERR; wire S_AXI_AWREADY; wire S_AXI_WREADY; wire S_AXI_BVALID; wire S_AXI_ARREADY; wire S_AXI_RLAST; wire S_AXI_RVALID; wire S_AXI_SBITERR; wire S_AXI_DBITERR; wire [C_WEA_WIDTH-1:0] WEA = wea; wire [C_ADDRA_WIDTH-1:0] ADDRA = addra; wire [C_WRITE_WIDTH_A-1:0] DINA = dina; wire [C_READ_WIDTH_A-1:0] DOUTA; wire [C_WEB_WIDTH-1:0] WEB = web; wire [C_ADDRB_WIDTH-1:0] ADDRB = addrb; wire [C_WRITE_WIDTH_B-1:0] DINB = dinb; wire [C_READ_WIDTH_B-1:0] DOUTB; wire [C_ADDRB_WIDTH-1:0] RDADDRECC; wire [C_AXI_ID_WIDTH-1:0] S_AXI_AWID = s_axi_awid; wire [31:0] S_AXI_AWADDR = s_axi_awaddr; wire [7:0] S_AXI_AWLEN = s_axi_awlen; wire [2:0] S_AXI_AWSIZE = s_axi_awsize; wire [1:0] S_AXI_AWBURST = s_axi_awburst; wire [C_WRITE_WIDTH_A-1:0] S_AXI_WDATA = s_axi_wdata; wire [C_WEA_WIDTH-1:0] S_AXI_WSTRB = s_axi_wstrb; wire [C_AXI_ID_WIDTH-1:0] S_AXI_BID; wire [1:0] S_AXI_BRESP; wire [C_AXI_ID_WIDTH-1:0] S_AXI_ARID = s_axi_arid; wire [31:0] S_AXI_ARADDR = s_axi_araddr; wire [7:0] S_AXI_ARLEN = s_axi_arlen; wire [2:0] S_AXI_ARSIZE = s_axi_arsize; wire [1:0] S_AXI_ARBURST = s_axi_arburst; wire [C_AXI_ID_WIDTH-1:0] S_AXI_RID; wire [C_WRITE_WIDTH_B-1:0] S_AXI_RDATA; wire [1:0] S_AXI_RRESP; wire [C_ADDRB_WIDTH-1:0] S_AXI_RDADDRECC; // Added to fix the simulation warning #CR731605 wire [C_WEB_WIDTH-1:0] WEB_parameterized = 0; wire ECCPIPECE; wire SLEEP; assign CLKA = clka; assign RSTA = rsta; assign ENA = ena; assign REGCEA = regcea; assign CLKB = clkb; assign RSTB = rstb; assign ENB = enb; assign REGCEB = regceb; assign INJECTSBITERR = injectsbiterr; assign INJECTDBITERR = injectdbiterr; assign ECCPIPECE = eccpipece; assign SLEEP = sleep; assign sbiterr = SBITERR; assign dbiterr = DBITERR; assign S_ACLK = s_aclk; assign S_ARESETN = s_aresetn; assign S_AXI_AWVALID = s_axi_awvalid; assign s_axi_awready = S_AXI_AWREADY; assign S_AXI_WLAST = s_axi_wlast; assign S_AXI_WVALID = s_axi_wvalid; assign s_axi_wready = S_AXI_WREADY; assign s_axi_bvalid = S_AXI_BVALID; assign S_AXI_BREADY = s_axi_bready; assign S_AXI_ARVALID = s_axi_arvalid; assign s_axi_arready = S_AXI_ARREADY; assign s_axi_rlast = S_AXI_RLAST; assign s_axi_rvalid = S_AXI_RVALID; assign S_AXI_RREADY = s_axi_rready; assign S_AXI_INJECTSBITERR = s_axi_injectsbiterr; assign S_AXI_INJECTDBITERR = s_axi_injectdbiterr; assign s_axi_sbiterr = S_AXI_SBITERR; assign s_axi_dbiterr = S_AXI_DBITERR; assign doutb = DOUTB; assign douta = DOUTA; assign rdaddrecc = RDADDRECC; assign s_axi_bid = S_AXI_BID; assign s_axi_bresp = S_AXI_BRESP; assign s_axi_rid = S_AXI_RID; assign s_axi_rdata = S_AXI_RDATA; assign s_axi_rresp = S_AXI_RRESP; assign s_axi_rdaddrecc = S_AXI_RDADDRECC; localparam FLOP_DELAY = 100; // 100 ps reg injectsbiterr_in; reg injectdbiterr_in; reg rsta_in; reg ena_in; reg regcea_in; reg [C_WEA_WIDTH-1:0] wea_in; reg [C_ADDRA_WIDTH-1:0] addra_in; reg [C_WRITE_WIDTH_A-1:0] dina_in; wire [C_ADDRA_WIDTH-1:0] s_axi_awaddr_out_c; wire [C_ADDRB_WIDTH-1:0] s_axi_araddr_out_c; wire s_axi_wr_en_c; wire s_axi_rd_en_c; wire s_aresetn_a_c; wire [7:0] s_axi_arlen_c ; wire [C_AXI_ID_WIDTH-1 : 0] s_axi_rid_c; wire [C_WRITE_WIDTH_B-1 : 0] s_axi_rdata_c; wire [1:0] s_axi_rresp_c; wire s_axi_rlast_c; wire s_axi_rvalid_c; wire s_axi_rready_c; wire regceb_c; localparam C_AXI_PAYLOAD = (C_HAS_MUX_OUTPUT_REGS_B == 1)?C_WRITE_WIDTH_B+C_AXI_ID_WIDTH+3:C_AXI_ID_WIDTH+3; wire [C_AXI_PAYLOAD-1 : 0] s_axi_payload_c; wire [C_AXI_PAYLOAD-1 : 0] m_axi_payload_c; //************** // log2roundup //************** function integer log2roundup (input integer data_value); integer width; integer cnt; begin width = 0; if (data_value > 1) begin for(cnt=1 ; cnt < data_value ; cnt = cnt * 2) begin width = width + 1; end //loop end //if log2roundup = width; end //log2roundup endfunction //************** // log2int //************** function integer log2int (input integer data_value); integer width; integer cnt; begin width = 0; cnt= data_value; for(cnt=data_value ; cnt >1 ; cnt = cnt / 2) begin width = width + 1; end //loop log2int = width; end //log2int endfunction //************************************************************************** // FUNCTION : divroundup // Returns the ceiling value of the division // Data_value - the quantity to be divided, dividend // Divisor - the value to divide the data_value by //************************************************************************** function integer divroundup (input integer data_value,input integer divisor); integer div; begin div = data_value/divisor; if ((data_value % divisor) != 0) begin div = div+1; end //if divroundup = div; end //if endfunction localparam AXI_FULL_MEMORY_SLAVE = ((C_AXI_SLAVE_TYPE == 0 && C_AXI_TYPE == 1)?1:0); localparam C_AXI_ADDR_WIDTH_MSB = C_ADDRA_WIDTH+log2roundup(C_WRITE_WIDTH_A/8); localparam C_AXI_ADDR_WIDTH = C_AXI_ADDR_WIDTH_MSB; //Data Width Number of LSB address bits to be discarded //1 to 16 1 //17 to 32 2 //33 to 64 3 //65 to 128 4 //129 to 256 5 //257 to 512 6 //513 to 1024 7 // The following two constants determine this. localparam LOWER_BOUND_VAL = (log2roundup(divroundup(C_WRITE_WIDTH_A,8) == 0))?0:(log2roundup(divroundup(C_WRITE_WIDTH_A,8))); localparam C_AXI_ADDR_WIDTH_LSB = ((AXI_FULL_MEMORY_SLAVE == 1)?0:LOWER_BOUND_VAL); localparam C_AXI_OS_WR = 2; //*********************************************** // INPUT REGISTERS. //*********************************************** generate if (C_HAS_SOFTECC_INPUT_REGS_A==0) begin : no_softecc_input_reg_stage always @* begin injectsbiterr_in = INJECTSBITERR; injectdbiterr_in = INJECTDBITERR; rsta_in = RSTA; ena_in = ENA; regcea_in = REGCEA; wea_in = WEA; addra_in = ADDRA; dina_in = DINA; end //end always end //end no_softecc_input_reg_stage endgenerate generate if (C_HAS_SOFTECC_INPUT_REGS_A==1) begin : has_softecc_input_reg_stage always @(posedge CLKA) begin injectsbiterr_in <= #FLOP_DELAY INJECTSBITERR; injectdbiterr_in <= #FLOP_DELAY INJECTDBITERR; rsta_in <= #FLOP_DELAY RSTA; ena_in <= #FLOP_DELAY ENA; regcea_in <= #FLOP_DELAY REGCEA; wea_in <= #FLOP_DELAY WEA; addra_in <= #FLOP_DELAY ADDRA; dina_in <= #FLOP_DELAY DINA; end //end always end //end input_reg_stages generate statement endgenerate generate if ((C_INTERFACE_TYPE == 0) && (C_ENABLE_32BIT_ADDRESS == 0)) begin : native_mem_module BLK_MEM_GEN_v8_2_mem_module #(.C_CORENAME (C_CORENAME), .C_FAMILY (C_FAMILY), .C_XDEVICEFAMILY (C_XDEVICEFAMILY), .C_MEM_TYPE (C_MEM_TYPE), .C_BYTE_SIZE (C_BYTE_SIZE), .C_ALGORITHM (C_ALGORITHM), .C_USE_BRAM_BLOCK (C_USE_BRAM_BLOCK), .C_PRIM_TYPE (C_PRIM_TYPE), .C_LOAD_INIT_FILE (C_LOAD_INIT_FILE), .C_INIT_FILE_NAME (C_INIT_FILE_NAME), .C_INIT_FILE (C_INIT_FILE), .C_USE_DEFAULT_DATA (C_USE_DEFAULT_DATA), .C_DEFAULT_DATA (C_DEFAULT_DATA), .C_RST_TYPE ("SYNC"), .C_HAS_RSTA (C_HAS_RSTA), .C_RST_PRIORITY_A (C_RST_PRIORITY_A), .C_RSTRAM_A (C_RSTRAM_A), .C_INITA_VAL (C_INITA_VAL), .C_HAS_ENA (C_HAS_ENA), .C_HAS_REGCEA (C_HAS_REGCEA), .C_USE_BYTE_WEA (C_USE_BYTE_WEA), .C_WEA_WIDTH (C_WEA_WIDTH), .C_WRITE_MODE_A (C_WRITE_MODE_A), .C_WRITE_WIDTH_A (C_WRITE_WIDTH_A), .C_READ_WIDTH_A (C_READ_WIDTH_A), .C_WRITE_DEPTH_A (C_WRITE_DEPTH_A), .C_READ_DEPTH_A (C_READ_DEPTH_A), .C_ADDRA_WIDTH (C_ADDRA_WIDTH), .C_HAS_RSTB (C_HAS_RSTB), .C_RST_PRIORITY_B (C_RST_PRIORITY_B), .C_RSTRAM_B (C_RSTRAM_B), .C_INITB_VAL (C_INITB_VAL), .C_HAS_ENB (C_HAS_ENB), .C_HAS_REGCEB (C_HAS_REGCEB), .C_USE_BYTE_WEB (C_USE_BYTE_WEB), .C_WEB_WIDTH (C_WEB_WIDTH), .C_WRITE_MODE_B (C_WRITE_MODE_B), .C_WRITE_WIDTH_B (C_WRITE_WIDTH_B), .C_READ_WIDTH_B (C_READ_WIDTH_B), .C_WRITE_DEPTH_B (C_WRITE_DEPTH_B), .C_READ_DEPTH_B (C_READ_DEPTH_B), .C_ADDRB_WIDTH (C_ADDRB_WIDTH), .C_HAS_MEM_OUTPUT_REGS_A (C_HAS_MEM_OUTPUT_REGS_A), .C_HAS_MEM_OUTPUT_REGS_B (C_HAS_MEM_OUTPUT_REGS_B), .C_HAS_MUX_OUTPUT_REGS_A (C_HAS_MUX_OUTPUT_REGS_A), .C_HAS_MUX_OUTPUT_REGS_B (C_HAS_MUX_OUTPUT_REGS_B), .C_HAS_SOFTECC_INPUT_REGS_A (C_HAS_SOFTECC_INPUT_REGS_A), .C_HAS_SOFTECC_OUTPUT_REGS_B (C_HAS_SOFTECC_OUTPUT_REGS_B), .C_MUX_PIPELINE_STAGES (C_MUX_PIPELINE_STAGES), .C_USE_SOFTECC (C_USE_SOFTECC), .C_USE_ECC (C_USE_ECC), .C_HAS_INJECTERR (C_HAS_INJECTERR), .C_SIM_COLLISION_CHECK (C_SIM_COLLISION_CHECK), .C_COMMON_CLK (C_COMMON_CLK), .FLOP_DELAY (FLOP_DELAY), .C_DISABLE_WARN_BHV_COLL (C_DISABLE_WARN_BHV_COLL), .C_EN_ECC_PIPE (C_EN_ECC_PIPE), .C_DISABLE_WARN_BHV_RANGE (C_DISABLE_WARN_BHV_RANGE)) blk_mem_gen_v8_2_inst (.CLKA (CLKA), .RSTA (rsta_in), .ENA (ena_in), .REGCEA (regcea_in), .WEA (wea_in), .ADDRA (addra_in), .DINA (dina_in), .DOUTA (DOUTA), .CLKB (CLKB), .RSTB (RSTB), .ENB (ENB), .REGCEB (REGCEB), .WEB (WEB), .ADDRB (ADDRB), .DINB (DINB), .DOUTB (DOUTB), .INJECTSBITERR (injectsbiterr_in), .INJECTDBITERR (injectdbiterr_in), .ECCPIPECE (ECCPIPECE), .SLEEP (SLEEP), .SBITERR (SBITERR), .DBITERR (DBITERR), .RDADDRECC (RDADDRECC) ); end endgenerate generate if((C_INTERFACE_TYPE == 0) && (C_ENABLE_32BIT_ADDRESS == 1)) begin : native_mem_mapped_module localparam C_ADDRA_WIDTH_ACTUAL = log2roundup(C_WRITE_DEPTH_A); localparam C_ADDRB_WIDTH_ACTUAL = log2roundup(C_WRITE_DEPTH_B); localparam C_ADDRA_WIDTH_MSB = C_ADDRA_WIDTH_ACTUAL+log2int(C_WRITE_WIDTH_A/8); localparam C_ADDRB_WIDTH_MSB = C_ADDRB_WIDTH_ACTUAL+log2int(C_WRITE_WIDTH_B/8); // localparam C_ADDRA_WIDTH_MSB = C_ADDRA_WIDTH_ACTUAL+log2roundup(C_WRITE_WIDTH_A/8); // localparam C_ADDRB_WIDTH_MSB = C_ADDRB_WIDTH_ACTUAL+log2roundup(C_WRITE_WIDTH_B/8); localparam C_MEM_MAP_ADDRA_WIDTH_MSB = C_ADDRA_WIDTH_MSB; localparam C_MEM_MAP_ADDRB_WIDTH_MSB = C_ADDRB_WIDTH_MSB; // Data Width Number of LSB address bits to be discarded // 1 to 16 1 // 17 to 32 2 // 33 to 64 3 // 65 to 128 4 // 129 to 256 5 // 257 to 512 6 // 513 to 1024 7 // The following two constants determine this. localparam MEM_MAP_LOWER_BOUND_VAL_A = (log2int(divroundup(C_WRITE_WIDTH_A,8)==0)) ? 0:(log2int(divroundup(C_WRITE_WIDTH_A,8))); localparam MEM_MAP_LOWER_BOUND_VAL_B = (log2int(divroundup(C_WRITE_WIDTH_A,8)==0)) ? 0:(log2int(divroundup(C_WRITE_WIDTH_A,8))); localparam C_MEM_MAP_ADDRA_WIDTH_LSB = MEM_MAP_LOWER_BOUND_VAL_A; localparam C_MEM_MAP_ADDRB_WIDTH_LSB = MEM_MAP_LOWER_BOUND_VAL_B; wire [C_ADDRB_WIDTH_ACTUAL-1 :0] rdaddrecc_i; wire [C_ADDRB_WIDTH-1:C_MEM_MAP_ADDRB_WIDTH_MSB] msb_zero_i; wire [C_MEM_MAP_ADDRB_WIDTH_LSB-1:0] lsb_zero_i; assign msb_zero_i = 0; assign lsb_zero_i = 0; assign RDADDRECC = {msb_zero_i,rdaddrecc_i,lsb_zero_i}; BLK_MEM_GEN_v8_2_mem_module #(.C_CORENAME (C_CORENAME), .C_FAMILY (C_FAMILY), .C_XDEVICEFAMILY (C_XDEVICEFAMILY), .C_MEM_TYPE (C_MEM_TYPE), .C_BYTE_SIZE (C_BYTE_SIZE), .C_USE_BRAM_BLOCK (C_USE_BRAM_BLOCK), .C_ALGORITHM (C_ALGORITHM), .C_PRIM_TYPE (C_PRIM_TYPE), .C_LOAD_INIT_FILE (C_LOAD_INIT_FILE), .C_INIT_FILE_NAME (C_INIT_FILE_NAME), .C_INIT_FILE (C_INIT_FILE), .C_USE_DEFAULT_DATA (C_USE_DEFAULT_DATA), .C_DEFAULT_DATA (C_DEFAULT_DATA), .C_RST_TYPE ("SYNC"), .C_HAS_RSTA (C_HAS_RSTA), .C_RST_PRIORITY_A (C_RST_PRIORITY_A), .C_RSTRAM_A (C_RSTRAM_A), .C_INITA_VAL (C_INITA_VAL), .C_HAS_ENA (C_HAS_ENA), .C_HAS_REGCEA (C_HAS_REGCEA), .C_USE_BYTE_WEA (C_USE_BYTE_WEA), .C_WEA_WIDTH (C_WEA_WIDTH), .C_WRITE_MODE_A (C_WRITE_MODE_A), .C_WRITE_WIDTH_A (C_WRITE_WIDTH_A), .C_READ_WIDTH_A (C_READ_WIDTH_A), .C_WRITE_DEPTH_A (C_WRITE_DEPTH_A), .C_READ_DEPTH_A (C_READ_DEPTH_A), .C_ADDRA_WIDTH (C_ADDRA_WIDTH_ACTUAL), .C_HAS_RSTB (C_HAS_RSTB), .C_RST_PRIORITY_B (C_RST_PRIORITY_B), .C_RSTRAM_B (C_RSTRAM_B), .C_INITB_VAL (C_INITB_VAL), .C_HAS_ENB (C_HAS_ENB), .C_HAS_REGCEB (C_HAS_REGCEB), .C_USE_BYTE_WEB (C_USE_BYTE_WEB), .C_WEB_WIDTH (C_WEB_WIDTH), .C_WRITE_MODE_B (C_WRITE_MODE_B), .C_WRITE_WIDTH_B (C_WRITE_WIDTH_B), .C_READ_WIDTH_B (C_READ_WIDTH_B), .C_WRITE_DEPTH_B (C_WRITE_DEPTH_B), .C_READ_DEPTH_B (C_READ_DEPTH_B), .C_ADDRB_WIDTH (C_ADDRB_WIDTH_ACTUAL), .C_HAS_MEM_OUTPUT_REGS_A (C_HAS_MEM_OUTPUT_REGS_A), .C_HAS_MEM_OUTPUT_REGS_B (C_HAS_MEM_OUTPUT_REGS_B), .C_HAS_MUX_OUTPUT_REGS_A (C_HAS_MUX_OUTPUT_REGS_A), .C_HAS_MUX_OUTPUT_REGS_B (C_HAS_MUX_OUTPUT_REGS_B), .C_HAS_SOFTECC_INPUT_REGS_A (C_HAS_SOFTECC_INPUT_REGS_A), .C_HAS_SOFTECC_OUTPUT_REGS_B (C_HAS_SOFTECC_OUTPUT_REGS_B), .C_MUX_PIPELINE_STAGES (C_MUX_PIPELINE_STAGES), .C_USE_SOFTECC (C_USE_SOFTECC), .C_USE_ECC (C_USE_ECC), .C_HAS_INJECTERR (C_HAS_INJECTERR), .C_SIM_COLLISION_CHECK (C_SIM_COLLISION_CHECK), .C_COMMON_CLK (C_COMMON_CLK), .FLOP_DELAY (FLOP_DELAY), .C_DISABLE_WARN_BHV_COLL (C_DISABLE_WARN_BHV_COLL), .C_EN_ECC_PIPE (C_EN_ECC_PIPE), .C_DISABLE_WARN_BHV_RANGE (C_DISABLE_WARN_BHV_RANGE)) blk_mem_gen_v8_2_inst (.CLKA (CLKA), .RSTA (rsta_in), .ENA (ena_in), .REGCEA (regcea_in), .WEA (wea_in), .ADDRA (addra_in[C_MEM_MAP_ADDRA_WIDTH_MSB-1:C_MEM_MAP_ADDRA_WIDTH_LSB]), .DINA (dina_in), .DOUTA (DOUTA), .CLKB (CLKB), .RSTB (RSTB), .ENB (ENB), .REGCEB (REGCEB), .WEB (WEB), .ADDRB (ADDRB[C_MEM_MAP_ADDRB_WIDTH_MSB-1:C_MEM_MAP_ADDRB_WIDTH_LSB]), .DINB (DINB), .DOUTB (DOUTB), .INJECTSBITERR (injectsbiterr_in), .INJECTDBITERR (injectdbiterr_in), .ECCPIPECE (ECCPIPECE), .SLEEP (SLEEP), .SBITERR (SBITERR), .DBITERR (DBITERR), .RDADDRECC (rdaddrecc_i) ); end endgenerate generate if (C_HAS_MEM_OUTPUT_REGS_B == 0 && C_HAS_MUX_OUTPUT_REGS_B == 0 ) begin : no_regs assign S_AXI_RDATA = s_axi_rdata_c; assign S_AXI_RLAST = s_axi_rlast_c; assign S_AXI_RVALID = s_axi_rvalid_c; assign S_AXI_RID = s_axi_rid_c; assign S_AXI_RRESP = s_axi_rresp_c; assign s_axi_rready_c = S_AXI_RREADY; end endgenerate generate if (C_HAS_MEM_OUTPUT_REGS_B == 1) begin : has_regceb assign regceb_c = s_axi_rvalid_c && s_axi_rready_c; end endgenerate generate if (C_HAS_MEM_OUTPUT_REGS_B == 0) begin : no_regceb assign regceb_c = REGCEB; end endgenerate generate if (C_HAS_MUX_OUTPUT_REGS_B == 1) begin : only_core_op_regs assign s_axi_payload_c = {s_axi_rid_c,s_axi_rdata_c,s_axi_rresp_c,s_axi_rlast_c}; assign S_AXI_RID = m_axi_payload_c[C_AXI_PAYLOAD-1 : C_AXI_PAYLOAD-C_AXI_ID_WIDTH]; assign S_AXI_RDATA = m_axi_payload_c[C_AXI_PAYLOAD-C_AXI_ID_WIDTH-1 : C_AXI_PAYLOAD-C_AXI_ID_WIDTH-C_WRITE_WIDTH_B]; assign S_AXI_RRESP = m_axi_payload_c[2:1]; assign S_AXI_RLAST = m_axi_payload_c[0]; end endgenerate generate if (C_HAS_MEM_OUTPUT_REGS_B == 1) begin : only_emb_op_regs assign s_axi_payload_c = {s_axi_rid_c,s_axi_rresp_c,s_axi_rlast_c}; assign S_AXI_RDATA = s_axi_rdata_c; assign S_AXI_RID = m_axi_payload_c[C_AXI_PAYLOAD-1 : C_AXI_PAYLOAD-C_AXI_ID_WIDTH]; assign S_AXI_RRESP = m_axi_payload_c[2:1]; assign S_AXI_RLAST = m_axi_payload_c[0]; end endgenerate generate if (C_HAS_MUX_OUTPUT_REGS_B == 1 || C_HAS_MEM_OUTPUT_REGS_B == 1) begin : has_regs_fwd blk_mem_axi_regs_fwd_v8_2 #(.C_DATA_WIDTH (C_AXI_PAYLOAD)) axi_regs_inst ( .ACLK (S_ACLK), .ARESET (s_aresetn_a_c), .S_VALID (s_axi_rvalid_c), .S_READY (s_axi_rready_c), .S_PAYLOAD_DATA (s_axi_payload_c), .M_VALID (S_AXI_RVALID), .M_READY (S_AXI_RREADY), .M_PAYLOAD_DATA (m_axi_payload_c) ); end endgenerate generate if (C_INTERFACE_TYPE == 1) begin : axi_mem_module assign s_aresetn_a_c = !S_ARESETN; assign S_AXI_BRESP = 2'b00; assign s_axi_rresp_c = 2'b00; assign s_axi_arlen_c = (C_AXI_TYPE == 1)?S_AXI_ARLEN:8'h0; blk_mem_axi_write_wrapper_beh_v8_2 #(.C_INTERFACE_TYPE (C_INTERFACE_TYPE), .C_AXI_TYPE (C_AXI_TYPE), .C_AXI_SLAVE_TYPE (C_AXI_SLAVE_TYPE), .C_MEMORY_TYPE (C_MEM_TYPE), .C_WRITE_DEPTH_A (C_WRITE_DEPTH_A), .C_AXI_AWADDR_WIDTH ((AXI_FULL_MEMORY_SLAVE == 1)?C_AXI_ADDR_WIDTH:C_AXI_ADDR_WIDTH-C_AXI_ADDR_WIDTH_LSB), .C_HAS_AXI_ID (C_HAS_AXI_ID), .C_AXI_ID_WIDTH (C_AXI_ID_WIDTH), .C_ADDRA_WIDTH (C_ADDRA_WIDTH), .C_AXI_WDATA_WIDTH (C_WRITE_WIDTH_A), .C_AXI_OS_WR (C_AXI_OS_WR)) axi_wr_fsm ( // AXI Global Signals .S_ACLK (S_ACLK), .S_ARESETN (s_aresetn_a_c), // AXI Full/Lite Slave Write interface .S_AXI_AWADDR (S_AXI_AWADDR[C_AXI_ADDR_WIDTH_MSB-1:C_AXI_ADDR_WIDTH_LSB]), .S_AXI_AWLEN (S_AXI_AWLEN), .S_AXI_AWID (S_AXI_AWID), .S_AXI_AWSIZE (S_AXI_AWSIZE), .S_AXI_AWBURST (S_AXI_AWBURST), .S_AXI_AWVALID (S_AXI_AWVALID), .S_AXI_AWREADY (S_AXI_AWREADY), .S_AXI_WVALID (S_AXI_WVALID), .S_AXI_WREADY (S_AXI_WREADY), .S_AXI_BVALID (S_AXI_BVALID), .S_AXI_BREADY (S_AXI_BREADY), .S_AXI_BID (S_AXI_BID), // Signals for BRAM interfac( .S_AXI_AWADDR_OUT (s_axi_awaddr_out_c), .S_AXI_WR_EN (s_axi_wr_en_c) ); blk_mem_axi_read_wrapper_beh_v8_2 #(.C_INTERFACE_TYPE (C_INTERFACE_TYPE), .C_AXI_TYPE (C_AXI_TYPE), .C_AXI_SLAVE_TYPE (C_AXI_SLAVE_TYPE), .C_MEMORY_TYPE (C_MEM_TYPE), .C_WRITE_WIDTH_A (C_WRITE_WIDTH_A), .C_ADDRA_WIDTH (C_ADDRA_WIDTH), .C_AXI_PIPELINE_STAGES (1), .C_AXI_ARADDR_WIDTH ((AXI_FULL_MEMORY_SLAVE == 1)?C_AXI_ADDR_WIDTH:C_AXI_ADDR_WIDTH-C_AXI_ADDR_WIDTH_LSB), .C_HAS_AXI_ID (C_HAS_AXI_ID), .C_AXI_ID_WIDTH (C_AXI_ID_WIDTH), .C_ADDRB_WIDTH (C_ADDRB_WIDTH)) axi_rd_sm( //AXI Global Signals .S_ACLK (S_ACLK), .S_ARESETN (s_aresetn_a_c), //AXI Full/Lite Read Side .S_AXI_ARADDR (S_AXI_ARADDR[C_AXI_ADDR_WIDTH_MSB-1:C_AXI_ADDR_WIDTH_LSB]), .S_AXI_ARLEN (s_axi_arlen_c), .S_AXI_ARSIZE (S_AXI_ARSIZE), .S_AXI_ARBURST (S_AXI_ARBURST), .S_AXI_ARVALID (S_AXI_ARVALID), .S_AXI_ARREADY (S_AXI_ARREADY), .S_AXI_RLAST (s_axi_rlast_c), .S_AXI_RVALID (s_axi_rvalid_c), .S_AXI_RREADY (s_axi_rready_c), .S_AXI_ARID (S_AXI_ARID), .S_AXI_RID (s_axi_rid_c), //AXI Full/Lite Read FSM Outputs .S_AXI_ARADDR_OUT (s_axi_araddr_out_c), .S_AXI_RD_EN (s_axi_rd_en_c) ); BLK_MEM_GEN_v8_2_mem_module #(.C_CORENAME (C_CORENAME), .C_FAMILY (C_FAMILY), .C_XDEVICEFAMILY (C_XDEVICEFAMILY), .C_MEM_TYPE (C_MEM_TYPE), .C_BYTE_SIZE (C_BYTE_SIZE), .C_USE_BRAM_BLOCK (C_USE_BRAM_BLOCK), .C_ALGORITHM (C_ALGORITHM), .C_PRIM_TYPE (C_PRIM_TYPE), .C_LOAD_INIT_FILE (C_LOAD_INIT_FILE), .C_INIT_FILE_NAME (C_INIT_FILE_NAME), .C_INIT_FILE (C_INIT_FILE), .C_USE_DEFAULT_DATA (C_USE_DEFAULT_DATA), .C_DEFAULT_DATA (C_DEFAULT_DATA), .C_RST_TYPE ("SYNC"), .C_HAS_RSTA (C_HAS_RSTA), .C_RST_PRIORITY_A (C_RST_PRIORITY_A), .C_RSTRAM_A (C_RSTRAM_A), .C_INITA_VAL (C_INITA_VAL), .C_HAS_ENA (1), .C_HAS_REGCEA (C_HAS_REGCEA), .C_USE_BYTE_WEA (1), .C_WEA_WIDTH (C_WEA_WIDTH), .C_WRITE_MODE_A (C_WRITE_MODE_A), .C_WRITE_WIDTH_A (C_WRITE_WIDTH_A), .C_READ_WIDTH_A (C_READ_WIDTH_A), .C_WRITE_DEPTH_A (C_WRITE_DEPTH_A), .C_READ_DEPTH_A (C_READ_DEPTH_A), .C_ADDRA_WIDTH (C_ADDRA_WIDTH), .C_HAS_RSTB (C_HAS_RSTB), .C_RST_PRIORITY_B (C_RST_PRIORITY_B), .C_RSTRAM_B (C_RSTRAM_B), .C_INITB_VAL (C_INITB_VAL), .C_HAS_ENB (1), .C_HAS_REGCEB (C_HAS_MEM_OUTPUT_REGS_B), .C_USE_BYTE_WEB (1), .C_WEB_WIDTH (C_WEB_WIDTH), .C_WRITE_MODE_B (C_WRITE_MODE_B), .C_WRITE_WIDTH_B (C_WRITE_WIDTH_B), .C_READ_WIDTH_B (C_READ_WIDTH_B), .C_WRITE_DEPTH_B (C_WRITE_DEPTH_B), .C_READ_DEPTH_B (C_READ_DEPTH_B), .C_ADDRB_WIDTH (C_ADDRB_WIDTH), .C_HAS_MEM_OUTPUT_REGS_A (0), .C_HAS_MEM_OUTPUT_REGS_B (C_HAS_MEM_OUTPUT_REGS_B), .C_HAS_MUX_OUTPUT_REGS_A (0), .C_HAS_MUX_OUTPUT_REGS_B (0), .C_HAS_SOFTECC_INPUT_REGS_A (C_HAS_SOFTECC_INPUT_REGS_A), .C_HAS_SOFTECC_OUTPUT_REGS_B (C_HAS_SOFTECC_OUTPUT_REGS_B), .C_MUX_PIPELINE_STAGES (C_MUX_PIPELINE_STAGES), .C_USE_SOFTECC (C_USE_SOFTECC), .C_USE_ECC (C_USE_ECC), .C_HAS_INJECTERR (C_HAS_INJECTERR), .C_SIM_COLLISION_CHECK (C_SIM_COLLISION_CHECK), .C_COMMON_CLK (C_COMMON_CLK), .FLOP_DELAY (FLOP_DELAY), .C_DISABLE_WARN_BHV_COLL (C_DISABLE_WARN_BHV_COLL), .C_EN_ECC_PIPE (0), .C_DISABLE_WARN_BHV_RANGE (C_DISABLE_WARN_BHV_RANGE)) blk_mem_gen_v8_2_inst (.CLKA (S_ACLK), .RSTA (s_aresetn_a_c), .ENA (s_axi_wr_en_c), .REGCEA (regcea_in), .WEA (S_AXI_WSTRB), .ADDRA (s_axi_awaddr_out_c), .DINA (S_AXI_WDATA), .DOUTA (DOUTA), .CLKB (S_ACLK), .RSTB (s_aresetn_a_c), .ENB (s_axi_rd_en_c), .REGCEB (regceb_c), .WEB (WEB_parameterized), .ADDRB (s_axi_araddr_out_c), .DINB (DINB), .DOUTB (s_axi_rdata_c), .INJECTSBITERR (injectsbiterr_in), .INJECTDBITERR (injectdbiterr_in), .SBITERR (SBITERR), .DBITERR (DBITERR), .ECCPIPECE (1'b0), .SLEEP (1'b0), .RDADDRECC (RDADDRECC) ); end endgenerate endmodule
// -*- verilog -*- // // USRP - Universal Software Radio Peripheral // // Copyright (C) 2003 Matt Ettus // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Boston, MA 02110-1301 USA // // Sign extension "macro" // bits_out should be greater than bits_in module sign_extend (in,out); parameter bits_in=0; // FIXME Quartus insists on a default parameter bits_out=0; input [bits_in-1:0] in; output [bits_out-1:0] out; assign out = {{(bits_out-bits_in){in[bits_in-1]}},in}; endmodule
`include "lo_simulate.v" /* pck0 - input main 24Mhz clock (PLL / 4) [7:0] adc_d - input data from A/D converter pwr_lo - output to coil drivers (ssp_clk / 8) adc_clk - output A/D clock signal ssp_frame - output SSS frame indicator (goes high while the 8 bits are shifted) ssp_din - output SSP data to ARM (shifts 8 bit A/D value serially to ARM MSB first) ssp_clk - output SSP clock signal ck_1356meg - input unused ck_1356megb - input unused ssp_dout - input unused cross_hi - input unused cross_lo - input unused pwr_hi - output unused, tied low pwr_oe1 - output unused, undefined pwr_oe2 - output unused, undefined pwr_oe3 - output unused, undefined pwr_oe4 - output unused, undefined dbg - output alias for adc_clk */ module testbed_lo_simulate; reg pck0; reg [7:0] adc_d; wire pwr_lo; wire adc_clk; wire ck_1356meg; wire ck_1356megb; wire ssp_frame; wire ssp_din; wire ssp_clk; reg ssp_dout; wire pwr_hi; wire pwr_oe1; wire pwr_oe2; wire pwr_oe3; wire pwr_oe4; reg cross_lo; wire cross_hi; wire dbg; lo_simulate #(5,200) dut( .pck0(pck0), .ck_1356meg(ck_1356meg), .ck_1356megb(ck_1356megb), .pwr_lo(pwr_lo), .pwr_hi(pwr_hi), .pwr_oe1(pwr_oe1), .pwr_oe2(pwr_oe2), .pwr_oe3(pwr_oe3), .pwr_oe4(pwr_oe4), .adc_d(adc_d), .adc_clk(adc_clk), .ssp_frame(ssp_frame), .ssp_din(ssp_din), .ssp_dout(ssp_dout), .ssp_clk(ssp_clk), .cross_hi(cross_hi), .cross_lo(cross_lo), .dbg(dbg) ); integer i, counter=0; // main clock always #5 pck0 = !pck0; //cross_lo is not really synced to pck0 but it's roughly pck0/192 (24Mhz/192=125Khz) task crank_dut; begin @(posedge pck0) ; counter = counter + 1; if (counter == 192) begin counter = 0; ssp_dout = $random; cross_lo = 1; end else begin cross_lo = 0; end end endtask initial begin pck0 = 0; for (i = 0 ; i < 4096 ; i = i + 1) begin crank_dut; end $finish; end endmodule // main
`include "lo_simulate.v" /* pck0 - input main 24Mhz clock (PLL / 4) [7:0] adc_d - input data from A/D converter pwr_lo - output to coil drivers (ssp_clk / 8) adc_clk - output A/D clock signal ssp_frame - output SSS frame indicator (goes high while the 8 bits are shifted) ssp_din - output SSP data to ARM (shifts 8 bit A/D value serially to ARM MSB first) ssp_clk - output SSP clock signal ck_1356meg - input unused ck_1356megb - input unused ssp_dout - input unused cross_hi - input unused cross_lo - input unused pwr_hi - output unused, tied low pwr_oe1 - output unused, undefined pwr_oe2 - output unused, undefined pwr_oe3 - output unused, undefined pwr_oe4 - output unused, undefined dbg - output alias for adc_clk */ module testbed_lo_simulate; reg pck0; reg [7:0] adc_d; wire pwr_lo; wire adc_clk; wire ck_1356meg; wire ck_1356megb; wire ssp_frame; wire ssp_din; wire ssp_clk; reg ssp_dout; wire pwr_hi; wire pwr_oe1; wire pwr_oe2; wire pwr_oe3; wire pwr_oe4; reg cross_lo; wire cross_hi; wire dbg; lo_simulate #(5,200) dut( .pck0(pck0), .ck_1356meg(ck_1356meg), .ck_1356megb(ck_1356megb), .pwr_lo(pwr_lo), .pwr_hi(pwr_hi), .pwr_oe1(pwr_oe1), .pwr_oe2(pwr_oe2), .pwr_oe3(pwr_oe3), .pwr_oe4(pwr_oe4), .adc_d(adc_d), .adc_clk(adc_clk), .ssp_frame(ssp_frame), .ssp_din(ssp_din), .ssp_dout(ssp_dout), .ssp_clk(ssp_clk), .cross_hi(cross_hi), .cross_lo(cross_lo), .dbg(dbg) ); integer i, counter=0; // main clock always #5 pck0 = !pck0; //cross_lo is not really synced to pck0 but it's roughly pck0/192 (24Mhz/192=125Khz) task crank_dut; begin @(posedge pck0) ; counter = counter + 1; if (counter == 192) begin counter = 0; ssp_dout = $random; cross_lo = 1; end else begin cross_lo = 0; end end endtask initial begin pck0 = 0; for (i = 0 ; i < 4096 ; i = i + 1) begin crank_dut; end $finish; end endmodule // main
//Legal Notice: (C)2017 Altera Corporation. All rights reserved. Your //use of Altera Corporation's design tools, logic functions and other //software and tools, and its AMPP partner logic functions, and any //output files any of the foregoing (including device programming or //simulation files), and any associated documentation or information are //expressly subject to the terms and conditions of the Altera Program //License Subscription Agreement or other applicable license agreement, //including, without limitation, that your use is for the sole purpose //of programming logic devices manufactured by Altera and sold by Altera //or its authorized distributors. Please refer to the applicable //agreement for further details. // synthesis translate_off `timescale 1ns / 1ps // synthesis translate_on // turn off superfluous verilog processor warnings // altera message_level Level1 // altera message_off 10034 10035 10036 10037 10230 10240 10030 module soc_design_Sys_Timer ( // inputs: address, chipselect, clk, reset_n, write_n, writedata, // outputs: irq, readdata ) ; output irq; output [ 15: 0] readdata; input [ 2: 0] address; input chipselect; input clk; input reset_n; input write_n; input [ 15: 0] writedata; wire clk_en; wire control_interrupt_enable; reg control_register; wire control_wr_strobe; reg counter_is_running; wire counter_is_zero; wire [ 16: 0] counter_load_value; reg delayed_unxcounter_is_zeroxx0; wire do_start_counter; wire do_stop_counter; reg force_reload; reg [ 16: 0] internal_counter; wire irq; wire period_h_wr_strobe; wire period_l_wr_strobe; wire [ 15: 0] read_mux_out; reg [ 15: 0] readdata; wire status_wr_strobe; wire timeout_event; reg timeout_occurred; assign clk_en = 1; always @(posedge clk or negedge reset_n) begin if (reset_n == 0) internal_counter <= 17'h1869F; else if (counter_is_running || force_reload) if (counter_is_zero || force_reload) internal_counter <= counter_load_value; else internal_counter <= internal_counter - 1; end assign counter_is_zero = internal_counter == 0; assign counter_load_value = 17'h1869F; always @(posedge clk or negedge reset_n) begin if (reset_n == 0) force_reload <= 0; else if (clk_en) force_reload <= period_h_wr_strobe || period_l_wr_strobe; end assign do_start_counter = 1; assign do_stop_counter = 0; always @(posedge clk or negedge reset_n) begin if (reset_n == 0) counter_is_running <= 1'b0; else if (clk_en) if (do_start_counter) counter_is_running <= -1; else if (do_stop_counter) counter_is_running <= 0; end //delayed_unxcounter_is_zeroxx0, which is an e_register always @(posedge clk or negedge reset_n) begin if (reset_n == 0) delayed_unxcounter_is_zeroxx0 <= 0; else if (clk_en) delayed_unxcounter_is_zeroxx0 <= counter_is_zero; end assign timeout_event = (counter_is_zero) & ~(delayed_unxcounter_is_zeroxx0); always @(posedge clk or negedge reset_n) begin if (reset_n == 0) timeout_occurred <= 0; else if (clk_en) if (status_wr_strobe) timeout_occurred <= 0; else if (timeout_event) timeout_occurred <= -1; end assign irq = timeout_occurred && control_interrupt_enable; //s1, which is an e_avalon_slave assign read_mux_out = ({16 {(address == 1)}} & control_register) | ({16 {(address == 0)}} & {counter_is_running, timeout_occurred}); always @(posedge clk or negedge reset_n) begin if (reset_n == 0) readdata <= 0; else if (clk_en) readdata <= read_mux_out; end assign period_l_wr_strobe = chipselect && ~write_n && (address == 2); assign period_h_wr_strobe = chipselect && ~write_n && (address == 3); assign control_wr_strobe = chipselect && ~write_n && (address == 1); always @(posedge clk or negedge reset_n) begin if (reset_n == 0) control_register <= 0; else if (control_wr_strobe) control_register <= writedata[0]; end assign control_interrupt_enable = control_register; assign status_wr_strobe = chipselect && ~write_n && (address == 0); endmodule
//Legal Notice: (C)2017 Altera Corporation. All rights reserved. Your //use of Altera Corporation's design tools, logic functions and other //software and tools, and its AMPP partner logic functions, and any //output files any of the foregoing (including device programming or //simulation files), and any associated documentation or information are //expressly subject to the terms and conditions of the Altera Program //License Subscription Agreement or other applicable license agreement, //including, without limitation, that your use is for the sole purpose //of programming logic devices manufactured by Altera and sold by Altera //or its authorized distributors. Please refer to the applicable //agreement for further details. // synthesis translate_off `timescale 1ns / 1ps // synthesis translate_on // turn off superfluous verilog processor warnings // altera message_level Level1 // altera message_off 10034 10035 10036 10037 10230 10240 10030 module soc_design_Sys_Timer ( // inputs: address, chipselect, clk, reset_n, write_n, writedata, // outputs: irq, readdata ) ; output irq; output [ 15: 0] readdata; input [ 2: 0] address; input chipselect; input clk; input reset_n; input write_n; input [ 15: 0] writedata; wire clk_en; wire control_interrupt_enable; reg control_register; wire control_wr_strobe; reg counter_is_running; wire counter_is_zero; wire [ 16: 0] counter_load_value; reg delayed_unxcounter_is_zeroxx0; wire do_start_counter; wire do_stop_counter; reg force_reload; reg [ 16: 0] internal_counter; wire irq; wire period_h_wr_strobe; wire period_l_wr_strobe; wire [ 15: 0] read_mux_out; reg [ 15: 0] readdata; wire status_wr_strobe; wire timeout_event; reg timeout_occurred; assign clk_en = 1; always @(posedge clk or negedge reset_n) begin if (reset_n == 0) internal_counter <= 17'h1869F; else if (counter_is_running || force_reload) if (counter_is_zero || force_reload) internal_counter <= counter_load_value; else internal_counter <= internal_counter - 1; end assign counter_is_zero = internal_counter == 0; assign counter_load_value = 17'h1869F; always @(posedge clk or negedge reset_n) begin if (reset_n == 0) force_reload <= 0; else if (clk_en) force_reload <= period_h_wr_strobe || period_l_wr_strobe; end assign do_start_counter = 1; assign do_stop_counter = 0; always @(posedge clk or negedge reset_n) begin if (reset_n == 0) counter_is_running <= 1'b0; else if (clk_en) if (do_start_counter) counter_is_running <= -1; else if (do_stop_counter) counter_is_running <= 0; end //delayed_unxcounter_is_zeroxx0, which is an e_register always @(posedge clk or negedge reset_n) begin if (reset_n == 0) delayed_unxcounter_is_zeroxx0 <= 0; else if (clk_en) delayed_unxcounter_is_zeroxx0 <= counter_is_zero; end assign timeout_event = (counter_is_zero) & ~(delayed_unxcounter_is_zeroxx0); always @(posedge clk or negedge reset_n) begin if (reset_n == 0) timeout_occurred <= 0; else if (clk_en) if (status_wr_strobe) timeout_occurred <= 0; else if (timeout_event) timeout_occurred <= -1; end assign irq = timeout_occurred && control_interrupt_enable; //s1, which is an e_avalon_slave assign read_mux_out = ({16 {(address == 1)}} & control_register) | ({16 {(address == 0)}} & {counter_is_running, timeout_occurred}); always @(posedge clk or negedge reset_n) begin if (reset_n == 0) readdata <= 0; else if (clk_en) readdata <= read_mux_out; end assign period_l_wr_strobe = chipselect && ~write_n && (address == 2); assign period_h_wr_strobe = chipselect && ~write_n && (address == 3); assign control_wr_strobe = chipselect && ~write_n && (address == 1); always @(posedge clk or negedge reset_n) begin if (reset_n == 0) control_register <= 0; else if (control_wr_strobe) control_register <= writedata[0]; end assign control_interrupt_enable = control_register; assign status_wr_strobe = chipselect && ~write_n && (address == 0); endmodule
//Legal Notice: (C)2017 Altera Corporation. All rights reserved. Your //use of Altera Corporation's design tools, logic functions and other //software and tools, and its AMPP partner logic functions, and any //output files any of the foregoing (including device programming or //simulation files), and any associated documentation or information are //expressly subject to the terms and conditions of the Altera Program //License Subscription Agreement or other applicable license agreement, //including, without limitation, that your use is for the sole purpose //of programming logic devices manufactured by Altera and sold by Altera //or its authorized distributors. Please refer to the applicable //agreement for further details. // synthesis translate_off `timescale 1ns / 1ps // synthesis translate_on // turn off superfluous verilog processor warnings // altera message_level Level1 // altera message_off 10034 10035 10036 10037 10230 10240 10030 module soc_design_Sys_Timer ( // inputs: address, chipselect, clk, reset_n, write_n, writedata, // outputs: irq, readdata ) ; output irq; output [ 15: 0] readdata; input [ 2: 0] address; input chipselect; input clk; input reset_n; input write_n; input [ 15: 0] writedata; wire clk_en; wire control_interrupt_enable; reg control_register; wire control_wr_strobe; reg counter_is_running; wire counter_is_zero; wire [ 16: 0] counter_load_value; reg delayed_unxcounter_is_zeroxx0; wire do_start_counter; wire do_stop_counter; reg force_reload; reg [ 16: 0] internal_counter; wire irq; wire period_h_wr_strobe; wire period_l_wr_strobe; wire [ 15: 0] read_mux_out; reg [ 15: 0] readdata; wire status_wr_strobe; wire timeout_event; reg timeout_occurred; assign clk_en = 1; always @(posedge clk or negedge reset_n) begin if (reset_n == 0) internal_counter <= 17'h1869F; else if (counter_is_running || force_reload) if (counter_is_zero || force_reload) internal_counter <= counter_load_value; else internal_counter <= internal_counter - 1; end assign counter_is_zero = internal_counter == 0; assign counter_load_value = 17'h1869F; always @(posedge clk or negedge reset_n) begin if (reset_n == 0) force_reload <= 0; else if (clk_en) force_reload <= period_h_wr_strobe || period_l_wr_strobe; end assign do_start_counter = 1; assign do_stop_counter = 0; always @(posedge clk or negedge reset_n) begin if (reset_n == 0) counter_is_running <= 1'b0; else if (clk_en) if (do_start_counter) counter_is_running <= -1; else if (do_stop_counter) counter_is_running <= 0; end //delayed_unxcounter_is_zeroxx0, which is an e_register always @(posedge clk or negedge reset_n) begin if (reset_n == 0) delayed_unxcounter_is_zeroxx0 <= 0; else if (clk_en) delayed_unxcounter_is_zeroxx0 <= counter_is_zero; end assign timeout_event = (counter_is_zero) & ~(delayed_unxcounter_is_zeroxx0); always @(posedge clk or negedge reset_n) begin if (reset_n == 0) timeout_occurred <= 0; else if (clk_en) if (status_wr_strobe) timeout_occurred <= 0; else if (timeout_event) timeout_occurred <= -1; end assign irq = timeout_occurred && control_interrupt_enable; //s1, which is an e_avalon_slave assign read_mux_out = ({16 {(address == 1)}} & control_register) | ({16 {(address == 0)}} & {counter_is_running, timeout_occurred}); always @(posedge clk or negedge reset_n) begin if (reset_n == 0) readdata <= 0; else if (clk_en) readdata <= read_mux_out; end assign period_l_wr_strobe = chipselect && ~write_n && (address == 2); assign period_h_wr_strobe = chipselect && ~write_n && (address == 3); assign control_wr_strobe = chipselect && ~write_n && (address == 1); always @(posedge clk or negedge reset_n) begin if (reset_n == 0) control_register <= 0; else if (control_wr_strobe) control_register <= writedata[0]; end assign control_interrupt_enable = control_register; assign status_wr_strobe = chipselect && ~write_n && (address == 0); endmodule
//Legal Notice: (C)2017 Altera Corporation. All rights reserved. Your //use of Altera Corporation's design tools, logic functions and other //software and tools, and its AMPP partner logic functions, and any //output files any of the foregoing (including device programming or //simulation files), and any associated documentation or information are //expressly subject to the terms and conditions of the Altera Program //License Subscription Agreement or other applicable license agreement, //including, without limitation, that your use is for the sole purpose //of programming logic devices manufactured by Altera and sold by Altera //or its authorized distributors. Please refer to the applicable //agreement for further details. // synthesis translate_off `timescale 1ns / 1ps // synthesis translate_on // turn off superfluous verilog processor warnings // altera message_level Level1 // altera message_off 10034 10035 10036 10037 10230 10240 10030 module soc_design_Sys_Timer ( // inputs: address, chipselect, clk, reset_n, write_n, writedata, // outputs: irq, readdata ) ; output irq; output [ 15: 0] readdata; input [ 2: 0] address; input chipselect; input clk; input reset_n; input write_n; input [ 15: 0] writedata; wire clk_en; wire control_interrupt_enable; reg control_register; wire control_wr_strobe; reg counter_is_running; wire counter_is_zero; wire [ 16: 0] counter_load_value; reg delayed_unxcounter_is_zeroxx0; wire do_start_counter; wire do_stop_counter; reg force_reload; reg [ 16: 0] internal_counter; wire irq; wire period_h_wr_strobe; wire period_l_wr_strobe; wire [ 15: 0] read_mux_out; reg [ 15: 0] readdata; wire status_wr_strobe; wire timeout_event; reg timeout_occurred; assign clk_en = 1; always @(posedge clk or negedge reset_n) begin if (reset_n == 0) internal_counter <= 17'h1869F; else if (counter_is_running || force_reload) if (counter_is_zero || force_reload) internal_counter <= counter_load_value; else internal_counter <= internal_counter - 1; end assign counter_is_zero = internal_counter == 0; assign counter_load_value = 17'h1869F; always @(posedge clk or negedge reset_n) begin if (reset_n == 0) force_reload <= 0; else if (clk_en) force_reload <= period_h_wr_strobe || period_l_wr_strobe; end assign do_start_counter = 1; assign do_stop_counter = 0; always @(posedge clk or negedge reset_n) begin if (reset_n == 0) counter_is_running <= 1'b0; else if (clk_en) if (do_start_counter) counter_is_running <= -1; else if (do_stop_counter) counter_is_running <= 0; end //delayed_unxcounter_is_zeroxx0, which is an e_register always @(posedge clk or negedge reset_n) begin if (reset_n == 0) delayed_unxcounter_is_zeroxx0 <= 0; else if (clk_en) delayed_unxcounter_is_zeroxx0 <= counter_is_zero; end assign timeout_event = (counter_is_zero) & ~(delayed_unxcounter_is_zeroxx0); always @(posedge clk or negedge reset_n) begin if (reset_n == 0) timeout_occurred <= 0; else if (clk_en) if (status_wr_strobe) timeout_occurred <= 0; else if (timeout_event) timeout_occurred <= -1; end assign irq = timeout_occurred && control_interrupt_enable; //s1, which is an e_avalon_slave assign read_mux_out = ({16 {(address == 1)}} & control_register) | ({16 {(address == 0)}} & {counter_is_running, timeout_occurred}); always @(posedge clk or negedge reset_n) begin if (reset_n == 0) readdata <= 0; else if (clk_en) readdata <= read_mux_out; end assign period_l_wr_strobe = chipselect && ~write_n && (address == 2); assign period_h_wr_strobe = chipselect && ~write_n && (address == 3); assign control_wr_strobe = chipselect && ~write_n && (address == 1); always @(posedge clk or negedge reset_n) begin if (reset_n == 0) control_register <= 0; else if (control_wr_strobe) control_register <= writedata[0]; end assign control_interrupt_enable = control_register; assign status_wr_strobe = chipselect && ~write_n && (address == 0); endmodule
// -- (c) Copyright 2010 - 2011 Xilinx, Inc. All rights reserved. // -- // -- This file contains confidential and proprietary information // -- of Xilinx, Inc. and is protected under U.S. and // -- international copyright and other intellectual property // -- laws. // -- // -- DISCLAIMER // -- This disclaimer is not a license and does not grant any // -- rights to the materials distributed herewith. Except as // -- otherwise provided in a valid license issued to you by // -- Xilinx, and to the maximum extent permitted by applicable // -- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND // -- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES // -- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING // -- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- // -- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and // -- (2) Xilinx shall not be liable (whether in contract or tort, // -- including negligence, or under any other theory of // -- liability) for any loss or damage of any kind or nature // -- related to, arising under or in connection with these // -- materials, including for any direct, or any indirect, // -- special, incidental, or consequential loss or damage // -- (including loss of data, profits, goodwill, or any type of // -- loss or damage suffered as a result of any action brought // -- by a third party) even if such damage or loss was // -- reasonably foreseeable or Xilinx had been advised of the // -- possibility of the same. // -- // -- CRITICAL APPLICATIONS // -- Xilinx products are not designed or intended to be fail- // -- safe, or for use in any application requiring fail-safe // -- performance, such as life-support or safety devices or // -- systems, Class III medical devices, nuclear facilities, // -- applications related to the deployment of airbags, or any // -- other applications that could lead to death, personal // -- injury, or severe property or environmental damage // -- (individually and collectively, "Critical // -- Applications"). Customer assumes the sole risk and // -- liability of any use of Xilinx products in Critical // -- Applications, subject only to applicable laws and // -- regulations governing limitations on product liability. // -- // -- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS // -- PART OF THIS FILE AT ALL TIMES. //----------------------------------------------------------------------------- // // Description: AxiLite Slave Conversion // // Verilog-standard: Verilog 2001 //-------------------------------------------------------------------------- // // Structure: // axilite_conv // //-------------------------------------------------------------------------- `timescale 1ps/1ps (* DowngradeIPIdentifiedWarnings="yes" *) module axi_protocol_converter_v2_1_axilite_conv # ( parameter C_FAMILY = "virtex6", parameter integer C_AXI_ID_WIDTH = 1, parameter integer C_AXI_ADDR_WIDTH = 32, parameter integer C_AXI_DATA_WIDTH = 32, parameter integer C_AXI_SUPPORTS_WRITE = 1, parameter integer C_AXI_SUPPORTS_READ = 1, parameter integer C_AXI_RUSER_WIDTH = 1, parameter integer C_AXI_BUSER_WIDTH = 1 ) ( // System Signals input wire ACLK, input wire ARESETN, // Slave Interface Write Address Ports input wire [C_AXI_ID_WIDTH-1:0] S_AXI_AWID, input wire [C_AXI_ADDR_WIDTH-1:0] S_AXI_AWADDR, input wire [3-1:0] S_AXI_AWPROT, input wire S_AXI_AWVALID, output wire S_AXI_AWREADY, // Slave Interface Write Data Ports input wire [C_AXI_DATA_WIDTH-1:0] S_AXI_WDATA, input wire [C_AXI_DATA_WIDTH/8-1:0] S_AXI_WSTRB, input wire S_AXI_WVALID, output wire S_AXI_WREADY, // Slave Interface Write Response Ports output wire [C_AXI_ID_WIDTH-1:0] S_AXI_BID, output wire [2-1:0] S_AXI_BRESP, output wire [C_AXI_BUSER_WIDTH-1:0] S_AXI_BUSER, // Constant =0 output wire S_AXI_BVALID, input wire S_AXI_BREADY, // Slave Interface Read Address Ports input wire [C_AXI_ID_WIDTH-1:0] S_AXI_ARID, input wire [C_AXI_ADDR_WIDTH-1:0] S_AXI_ARADDR, input wire [3-1:0] S_AXI_ARPROT, input wire S_AXI_ARVALID, output wire S_AXI_ARREADY, // Slave Interface Read Data Ports output wire [C_AXI_ID_WIDTH-1:0] S_AXI_RID, output wire [C_AXI_DATA_WIDTH-1:0] S_AXI_RDATA, output wire [2-1:0] S_AXI_RRESP, output wire S_AXI_RLAST, // Constant =1 output wire [C_AXI_RUSER_WIDTH-1:0] S_AXI_RUSER, // Constant =0 output wire S_AXI_RVALID, input wire S_AXI_RREADY, // Master Interface Write Address Port output wire [C_AXI_ADDR_WIDTH-1:0] M_AXI_AWADDR, output wire [3-1:0] M_AXI_AWPROT, output wire M_AXI_AWVALID, input wire M_AXI_AWREADY, // Master Interface Write Data Ports output wire [C_AXI_DATA_WIDTH-1:0] M_AXI_WDATA, output wire [C_AXI_DATA_WIDTH/8-1:0] M_AXI_WSTRB, output wire M_AXI_WVALID, input wire M_AXI_WREADY, // Master Interface Write Response Ports input wire [2-1:0] M_AXI_BRESP, input wire M_AXI_BVALID, output wire M_AXI_BREADY, // Master Interface Read Address Port output wire [C_AXI_ADDR_WIDTH-1:0] M_AXI_ARADDR, output wire [3-1:0] M_AXI_ARPROT, output wire M_AXI_ARVALID, input wire M_AXI_ARREADY, // Master Interface Read Data Ports input wire [C_AXI_DATA_WIDTH-1:0] M_AXI_RDATA, input wire [2-1:0] M_AXI_RRESP, input wire M_AXI_RVALID, output wire M_AXI_RREADY ); wire s_awvalid_i; wire s_arvalid_i; wire [C_AXI_ADDR_WIDTH-1:0] m_axaddr; // Arbiter reg read_active; reg write_active; reg busy; wire read_req; wire write_req; wire read_complete; wire write_complete; reg [1:0] areset_d; // Reset delay register always @(posedge ACLK) begin areset_d <= {areset_d[0], ~ARESETN}; end assign s_awvalid_i = S_AXI_AWVALID & (C_AXI_SUPPORTS_WRITE != 0); assign s_arvalid_i = S_AXI_ARVALID & (C_AXI_SUPPORTS_READ != 0); assign read_req = s_arvalid_i & ~busy & ~|areset_d & ~write_active; assign write_req = s_awvalid_i & ~busy & ~|areset_d & ((~read_active & ~s_arvalid_i) | write_active); assign read_complete = M_AXI_RVALID & S_AXI_RREADY; assign write_complete = M_AXI_BVALID & S_AXI_BREADY; always @(posedge ACLK) begin : arbiter_read_ff if (|areset_d) read_active <= 1'b0; else if (read_complete) read_active <= 1'b0; else if (read_req) read_active <= 1'b1; end always @(posedge ACLK) begin : arbiter_write_ff if (|areset_d) write_active <= 1'b0; else if (write_complete) write_active <= 1'b0; else if (write_req) write_active <= 1'b1; end always @(posedge ACLK) begin : arbiter_busy_ff if (|areset_d) busy <= 1'b0; else if (read_complete | write_complete) busy <= 1'b0; else if ((write_req & M_AXI_AWREADY) | (read_req & M_AXI_ARREADY)) busy <= 1'b1; end assign M_AXI_ARVALID = read_req; assign S_AXI_ARREADY = M_AXI_ARREADY & read_req; assign M_AXI_AWVALID = write_req; assign S_AXI_AWREADY = M_AXI_AWREADY & write_req; assign M_AXI_RREADY = S_AXI_RREADY & read_active; assign S_AXI_RVALID = M_AXI_RVALID & read_active; assign M_AXI_BREADY = S_AXI_BREADY & write_active; assign S_AXI_BVALID = M_AXI_BVALID & write_active; // Address multiplexer assign m_axaddr = (read_req | (C_AXI_SUPPORTS_WRITE == 0)) ? S_AXI_ARADDR : S_AXI_AWADDR; // Id multiplexer and flip-flop reg [C_AXI_ID_WIDTH-1:0] s_axid; always @(posedge ACLK) begin : axid if (read_req) s_axid <= S_AXI_ARID; else if (write_req) s_axid <= S_AXI_AWID; end assign S_AXI_BID = s_axid; assign S_AXI_RID = s_axid; assign M_AXI_AWADDR = m_axaddr; assign M_AXI_ARADDR = m_axaddr; // Feed-through signals assign S_AXI_WREADY = M_AXI_WREADY & ~|areset_d; assign S_AXI_BRESP = M_AXI_BRESP; assign S_AXI_RDATA = M_AXI_RDATA; assign S_AXI_RRESP = M_AXI_RRESP; assign S_AXI_RLAST = 1'b1; assign S_AXI_BUSER = {C_AXI_BUSER_WIDTH{1'b0}}; assign S_AXI_RUSER = {C_AXI_RUSER_WIDTH{1'b0}}; assign M_AXI_AWPROT = S_AXI_AWPROT; assign M_AXI_WVALID = S_AXI_WVALID & ~|areset_d; assign M_AXI_WDATA = S_AXI_WDATA; assign M_AXI_WSTRB = S_AXI_WSTRB; assign M_AXI_ARPROT = S_AXI_ARPROT; endmodule
// -- (c) Copyright 2010 - 2011 Xilinx, Inc. All rights reserved. // -- // -- This file contains confidential and proprietary information // -- of Xilinx, Inc. and is protected under U.S. and // -- international copyright and other intellectual property // -- laws. // -- // -- DISCLAIMER // -- This disclaimer is not a license and does not grant any // -- rights to the materials distributed herewith. Except as // -- otherwise provided in a valid license issued to you by // -- Xilinx, and to the maximum extent permitted by applicable // -- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND // -- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES // -- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING // -- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- // -- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and // -- (2) Xilinx shall not be liable (whether in contract or tort, // -- including negligence, or under any other theory of // -- liability) for any loss or damage of any kind or nature // -- related to, arising under or in connection with these // -- materials, including for any direct, or any indirect, // -- special, incidental, or consequential loss or damage // -- (including loss of data, profits, goodwill, or any type of // -- loss or damage suffered as a result of any action brought // -- by a third party) even if such damage or loss was // -- reasonably foreseeable or Xilinx had been advised of the // -- possibility of the same. // -- // -- CRITICAL APPLICATIONS // -- Xilinx products are not designed or intended to be fail- // -- safe, or for use in any application requiring fail-safe // -- performance, such as life-support or safety devices or // -- systems, Class III medical devices, nuclear facilities, // -- applications related to the deployment of airbags, or any // -- other applications that could lead to death, personal // -- injury, or severe property or environmental damage // -- (individually and collectively, "Critical // -- Applications"). Customer assumes the sole risk and // -- liability of any use of Xilinx products in Critical // -- Applications, subject only to applicable laws and // -- regulations governing limitations on product liability. // -- // -- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS // -- PART OF THIS FILE AT ALL TIMES. //----------------------------------------------------------------------------- // // Description: AxiLite Slave Conversion // // Verilog-standard: Verilog 2001 //-------------------------------------------------------------------------- // // Structure: // axilite_conv // //-------------------------------------------------------------------------- `timescale 1ps/1ps (* DowngradeIPIdentifiedWarnings="yes" *) module axi_protocol_converter_v2_1_axilite_conv # ( parameter C_FAMILY = "virtex6", parameter integer C_AXI_ID_WIDTH = 1, parameter integer C_AXI_ADDR_WIDTH = 32, parameter integer C_AXI_DATA_WIDTH = 32, parameter integer C_AXI_SUPPORTS_WRITE = 1, parameter integer C_AXI_SUPPORTS_READ = 1, parameter integer C_AXI_RUSER_WIDTH = 1, parameter integer C_AXI_BUSER_WIDTH = 1 ) ( // System Signals input wire ACLK, input wire ARESETN, // Slave Interface Write Address Ports input wire [C_AXI_ID_WIDTH-1:0] S_AXI_AWID, input wire [C_AXI_ADDR_WIDTH-1:0] S_AXI_AWADDR, input wire [3-1:0] S_AXI_AWPROT, input wire S_AXI_AWVALID, output wire S_AXI_AWREADY, // Slave Interface Write Data Ports input wire [C_AXI_DATA_WIDTH-1:0] S_AXI_WDATA, input wire [C_AXI_DATA_WIDTH/8-1:0] S_AXI_WSTRB, input wire S_AXI_WVALID, output wire S_AXI_WREADY, // Slave Interface Write Response Ports output wire [C_AXI_ID_WIDTH-1:0] S_AXI_BID, output wire [2-1:0] S_AXI_BRESP, output wire [C_AXI_BUSER_WIDTH-1:0] S_AXI_BUSER, // Constant =0 output wire S_AXI_BVALID, input wire S_AXI_BREADY, // Slave Interface Read Address Ports input wire [C_AXI_ID_WIDTH-1:0] S_AXI_ARID, input wire [C_AXI_ADDR_WIDTH-1:0] S_AXI_ARADDR, input wire [3-1:0] S_AXI_ARPROT, input wire S_AXI_ARVALID, output wire S_AXI_ARREADY, // Slave Interface Read Data Ports output wire [C_AXI_ID_WIDTH-1:0] S_AXI_RID, output wire [C_AXI_DATA_WIDTH-1:0] S_AXI_RDATA, output wire [2-1:0] S_AXI_RRESP, output wire S_AXI_RLAST, // Constant =1 output wire [C_AXI_RUSER_WIDTH-1:0] S_AXI_RUSER, // Constant =0 output wire S_AXI_RVALID, input wire S_AXI_RREADY, // Master Interface Write Address Port output wire [C_AXI_ADDR_WIDTH-1:0] M_AXI_AWADDR, output wire [3-1:0] M_AXI_AWPROT, output wire M_AXI_AWVALID, input wire M_AXI_AWREADY, // Master Interface Write Data Ports output wire [C_AXI_DATA_WIDTH-1:0] M_AXI_WDATA, output wire [C_AXI_DATA_WIDTH/8-1:0] M_AXI_WSTRB, output wire M_AXI_WVALID, input wire M_AXI_WREADY, // Master Interface Write Response Ports input wire [2-1:0] M_AXI_BRESP, input wire M_AXI_BVALID, output wire M_AXI_BREADY, // Master Interface Read Address Port output wire [C_AXI_ADDR_WIDTH-1:0] M_AXI_ARADDR, output wire [3-1:0] M_AXI_ARPROT, output wire M_AXI_ARVALID, input wire M_AXI_ARREADY, // Master Interface Read Data Ports input wire [C_AXI_DATA_WIDTH-1:0] M_AXI_RDATA, input wire [2-1:0] M_AXI_RRESP, input wire M_AXI_RVALID, output wire M_AXI_RREADY ); wire s_awvalid_i; wire s_arvalid_i; wire [C_AXI_ADDR_WIDTH-1:0] m_axaddr; // Arbiter reg read_active; reg write_active; reg busy; wire read_req; wire write_req; wire read_complete; wire write_complete; reg [1:0] areset_d; // Reset delay register always @(posedge ACLK) begin areset_d <= {areset_d[0], ~ARESETN}; end assign s_awvalid_i = S_AXI_AWVALID & (C_AXI_SUPPORTS_WRITE != 0); assign s_arvalid_i = S_AXI_ARVALID & (C_AXI_SUPPORTS_READ != 0); assign read_req = s_arvalid_i & ~busy & ~|areset_d & ~write_active; assign write_req = s_awvalid_i & ~busy & ~|areset_d & ((~read_active & ~s_arvalid_i) | write_active); assign read_complete = M_AXI_RVALID & S_AXI_RREADY; assign write_complete = M_AXI_BVALID & S_AXI_BREADY; always @(posedge ACLK) begin : arbiter_read_ff if (|areset_d) read_active <= 1'b0; else if (read_complete) read_active <= 1'b0; else if (read_req) read_active <= 1'b1; end always @(posedge ACLK) begin : arbiter_write_ff if (|areset_d) write_active <= 1'b0; else if (write_complete) write_active <= 1'b0; else if (write_req) write_active <= 1'b1; end always @(posedge ACLK) begin : arbiter_busy_ff if (|areset_d) busy <= 1'b0; else if (read_complete | write_complete) busy <= 1'b0; else if ((write_req & M_AXI_AWREADY) | (read_req & M_AXI_ARREADY)) busy <= 1'b1; end assign M_AXI_ARVALID = read_req; assign S_AXI_ARREADY = M_AXI_ARREADY & read_req; assign M_AXI_AWVALID = write_req; assign S_AXI_AWREADY = M_AXI_AWREADY & write_req; assign M_AXI_RREADY = S_AXI_RREADY & read_active; assign S_AXI_RVALID = M_AXI_RVALID & read_active; assign M_AXI_BREADY = S_AXI_BREADY & write_active; assign S_AXI_BVALID = M_AXI_BVALID & write_active; // Address multiplexer assign m_axaddr = (read_req | (C_AXI_SUPPORTS_WRITE == 0)) ? S_AXI_ARADDR : S_AXI_AWADDR; // Id multiplexer and flip-flop reg [C_AXI_ID_WIDTH-1:0] s_axid; always @(posedge ACLK) begin : axid if (read_req) s_axid <= S_AXI_ARID; else if (write_req) s_axid <= S_AXI_AWID; end assign S_AXI_BID = s_axid; assign S_AXI_RID = s_axid; assign M_AXI_AWADDR = m_axaddr; assign M_AXI_ARADDR = m_axaddr; // Feed-through signals assign S_AXI_WREADY = M_AXI_WREADY & ~|areset_d; assign S_AXI_BRESP = M_AXI_BRESP; assign S_AXI_RDATA = M_AXI_RDATA; assign S_AXI_RRESP = M_AXI_RRESP; assign S_AXI_RLAST = 1'b1; assign S_AXI_BUSER = {C_AXI_BUSER_WIDTH{1'b0}}; assign S_AXI_RUSER = {C_AXI_RUSER_WIDTH{1'b0}}; assign M_AXI_AWPROT = S_AXI_AWPROT; assign M_AXI_WVALID = S_AXI_WVALID & ~|areset_d; assign M_AXI_WDATA = S_AXI_WDATA; assign M_AXI_WSTRB = S_AXI_WSTRB; assign M_AXI_ARPROT = S_AXI_ARPROT; endmodule
// -- (c) Copyright 2010 - 2011 Xilinx, Inc. All rights reserved. // -- // -- This file contains confidential and proprietary information // -- of Xilinx, Inc. and is protected under U.S. and // -- international copyright and other intellectual property // -- laws. // -- // -- DISCLAIMER // -- This disclaimer is not a license and does not grant any // -- rights to the materials distributed herewith. Except as // -- otherwise provided in a valid license issued to you by // -- Xilinx, and to the maximum extent permitted by applicable // -- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND // -- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES // -- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING // -- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- // -- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and // -- (2) Xilinx shall not be liable (whether in contract or tort, // -- including negligence, or under any other theory of // -- liability) for any loss or damage of any kind or nature // -- related to, arising under or in connection with these // -- materials, including for any direct, or any indirect, // -- special, incidental, or consequential loss or damage // -- (including loss of data, profits, goodwill, or any type of // -- loss or damage suffered as a result of any action brought // -- by a third party) even if such damage or loss was // -- reasonably foreseeable or Xilinx had been advised of the // -- possibility of the same. // -- // -- CRITICAL APPLICATIONS // -- Xilinx products are not designed or intended to be fail- // -- safe, or for use in any application requiring fail-safe // -- performance, such as life-support or safety devices or // -- systems, Class III medical devices, nuclear facilities, // -- applications related to the deployment of airbags, or any // -- other applications that could lead to death, personal // -- injury, or severe property or environmental damage // -- (individually and collectively, "Critical // -- Applications"). Customer assumes the sole risk and // -- liability of any use of Xilinx products in Critical // -- Applications, subject only to applicable laws and // -- regulations governing limitations on product liability. // -- // -- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS // -- PART OF THIS FILE AT ALL TIMES. //----------------------------------------------------------------------------- // // Description: AxiLite Slave Conversion // // Verilog-standard: Verilog 2001 //-------------------------------------------------------------------------- // // Structure: // axilite_conv // //-------------------------------------------------------------------------- `timescale 1ps/1ps (* DowngradeIPIdentifiedWarnings="yes" *) module axi_protocol_converter_v2_1_axilite_conv # ( parameter C_FAMILY = "virtex6", parameter integer C_AXI_ID_WIDTH = 1, parameter integer C_AXI_ADDR_WIDTH = 32, parameter integer C_AXI_DATA_WIDTH = 32, parameter integer C_AXI_SUPPORTS_WRITE = 1, parameter integer C_AXI_SUPPORTS_READ = 1, parameter integer C_AXI_RUSER_WIDTH = 1, parameter integer C_AXI_BUSER_WIDTH = 1 ) ( // System Signals input wire ACLK, input wire ARESETN, // Slave Interface Write Address Ports input wire [C_AXI_ID_WIDTH-1:0] S_AXI_AWID, input wire [C_AXI_ADDR_WIDTH-1:0] S_AXI_AWADDR, input wire [3-1:0] S_AXI_AWPROT, input wire S_AXI_AWVALID, output wire S_AXI_AWREADY, // Slave Interface Write Data Ports input wire [C_AXI_DATA_WIDTH-1:0] S_AXI_WDATA, input wire [C_AXI_DATA_WIDTH/8-1:0] S_AXI_WSTRB, input wire S_AXI_WVALID, output wire S_AXI_WREADY, // Slave Interface Write Response Ports output wire [C_AXI_ID_WIDTH-1:0] S_AXI_BID, output wire [2-1:0] S_AXI_BRESP, output wire [C_AXI_BUSER_WIDTH-1:0] S_AXI_BUSER, // Constant =0 output wire S_AXI_BVALID, input wire S_AXI_BREADY, // Slave Interface Read Address Ports input wire [C_AXI_ID_WIDTH-1:0] S_AXI_ARID, input wire [C_AXI_ADDR_WIDTH-1:0] S_AXI_ARADDR, input wire [3-1:0] S_AXI_ARPROT, input wire S_AXI_ARVALID, output wire S_AXI_ARREADY, // Slave Interface Read Data Ports output wire [C_AXI_ID_WIDTH-1:0] S_AXI_RID, output wire [C_AXI_DATA_WIDTH-1:0] S_AXI_RDATA, output wire [2-1:0] S_AXI_RRESP, output wire S_AXI_RLAST, // Constant =1 output wire [C_AXI_RUSER_WIDTH-1:0] S_AXI_RUSER, // Constant =0 output wire S_AXI_RVALID, input wire S_AXI_RREADY, // Master Interface Write Address Port output wire [C_AXI_ADDR_WIDTH-1:0] M_AXI_AWADDR, output wire [3-1:0] M_AXI_AWPROT, output wire M_AXI_AWVALID, input wire M_AXI_AWREADY, // Master Interface Write Data Ports output wire [C_AXI_DATA_WIDTH-1:0] M_AXI_WDATA, output wire [C_AXI_DATA_WIDTH/8-1:0] M_AXI_WSTRB, output wire M_AXI_WVALID, input wire M_AXI_WREADY, // Master Interface Write Response Ports input wire [2-1:0] M_AXI_BRESP, input wire M_AXI_BVALID, output wire M_AXI_BREADY, // Master Interface Read Address Port output wire [C_AXI_ADDR_WIDTH-1:0] M_AXI_ARADDR, output wire [3-1:0] M_AXI_ARPROT, output wire M_AXI_ARVALID, input wire M_AXI_ARREADY, // Master Interface Read Data Ports input wire [C_AXI_DATA_WIDTH-1:0] M_AXI_RDATA, input wire [2-1:0] M_AXI_RRESP, input wire M_AXI_RVALID, output wire M_AXI_RREADY ); wire s_awvalid_i; wire s_arvalid_i; wire [C_AXI_ADDR_WIDTH-1:0] m_axaddr; // Arbiter reg read_active; reg write_active; reg busy; wire read_req; wire write_req; wire read_complete; wire write_complete; reg [1:0] areset_d; // Reset delay register always @(posedge ACLK) begin areset_d <= {areset_d[0], ~ARESETN}; end assign s_awvalid_i = S_AXI_AWVALID & (C_AXI_SUPPORTS_WRITE != 0); assign s_arvalid_i = S_AXI_ARVALID & (C_AXI_SUPPORTS_READ != 0); assign read_req = s_arvalid_i & ~busy & ~|areset_d & ~write_active; assign write_req = s_awvalid_i & ~busy & ~|areset_d & ((~read_active & ~s_arvalid_i) | write_active); assign read_complete = M_AXI_RVALID & S_AXI_RREADY; assign write_complete = M_AXI_BVALID & S_AXI_BREADY; always @(posedge ACLK) begin : arbiter_read_ff if (|areset_d) read_active <= 1'b0; else if (read_complete) read_active <= 1'b0; else if (read_req) read_active <= 1'b1; end always @(posedge ACLK) begin : arbiter_write_ff if (|areset_d) write_active <= 1'b0; else if (write_complete) write_active <= 1'b0; else if (write_req) write_active <= 1'b1; end always @(posedge ACLK) begin : arbiter_busy_ff if (|areset_d) busy <= 1'b0; else if (read_complete | write_complete) busy <= 1'b0; else if ((write_req & M_AXI_AWREADY) | (read_req & M_AXI_ARREADY)) busy <= 1'b1; end assign M_AXI_ARVALID = read_req; assign S_AXI_ARREADY = M_AXI_ARREADY & read_req; assign M_AXI_AWVALID = write_req; assign S_AXI_AWREADY = M_AXI_AWREADY & write_req; assign M_AXI_RREADY = S_AXI_RREADY & read_active; assign S_AXI_RVALID = M_AXI_RVALID & read_active; assign M_AXI_BREADY = S_AXI_BREADY & write_active; assign S_AXI_BVALID = M_AXI_BVALID & write_active; // Address multiplexer assign m_axaddr = (read_req | (C_AXI_SUPPORTS_WRITE == 0)) ? S_AXI_ARADDR : S_AXI_AWADDR; // Id multiplexer and flip-flop reg [C_AXI_ID_WIDTH-1:0] s_axid; always @(posedge ACLK) begin : axid if (read_req) s_axid <= S_AXI_ARID; else if (write_req) s_axid <= S_AXI_AWID; end assign S_AXI_BID = s_axid; assign S_AXI_RID = s_axid; assign M_AXI_AWADDR = m_axaddr; assign M_AXI_ARADDR = m_axaddr; // Feed-through signals assign S_AXI_WREADY = M_AXI_WREADY & ~|areset_d; assign S_AXI_BRESP = M_AXI_BRESP; assign S_AXI_RDATA = M_AXI_RDATA; assign S_AXI_RRESP = M_AXI_RRESP; assign S_AXI_RLAST = 1'b1; assign S_AXI_BUSER = {C_AXI_BUSER_WIDTH{1'b0}}; assign S_AXI_RUSER = {C_AXI_RUSER_WIDTH{1'b0}}; assign M_AXI_AWPROT = S_AXI_AWPROT; assign M_AXI_WVALID = S_AXI_WVALID & ~|areset_d; assign M_AXI_WDATA = S_AXI_WDATA; assign M_AXI_WSTRB = S_AXI_WSTRB; assign M_AXI_ARPROT = S_AXI_ARPROT; endmodule
// -- (c) Copyright 2010 - 2011 Xilinx, Inc. All rights reserved. // -- // -- This file contains confidential and proprietary information // -- of Xilinx, Inc. and is protected under U.S. and // -- international copyright and other intellectual property // -- laws. // -- // -- DISCLAIMER // -- This disclaimer is not a license and does not grant any // -- rights to the materials distributed herewith. Except as // -- otherwise provided in a valid license issued to you by // -- Xilinx, and to the maximum extent permitted by applicable // -- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND // -- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES // -- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING // -- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- // -- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and // -- (2) Xilinx shall not be liable (whether in contract or tort, // -- including negligence, or under any other theory of // -- liability) for any loss or damage of any kind or nature // -- related to, arising under or in connection with these // -- materials, including for any direct, or any indirect, // -- special, incidental, or consequential loss or damage // -- (including loss of data, profits, goodwill, or any type of // -- loss or damage suffered as a result of any action brought // -- by a third party) even if such damage or loss was // -- reasonably foreseeable or Xilinx had been advised of the // -- possibility of the same. // -- // -- CRITICAL APPLICATIONS // -- Xilinx products are not designed or intended to be fail- // -- safe, or for use in any application requiring fail-safe // -- performance, such as life-support or safety devices or // -- systems, Class III medical devices, nuclear facilities, // -- applications related to the deployment of airbags, or any // -- other applications that could lead to death, personal // -- injury, or severe property or environmental damage // -- (individually and collectively, "Critical // -- Applications"). Customer assumes the sole risk and // -- liability of any use of Xilinx products in Critical // -- Applications, subject only to applicable laws and // -- regulations governing limitations on product liability. // -- // -- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS // -- PART OF THIS FILE AT ALL TIMES. //----------------------------------------------------------------------------- // // Description: AxiLite Slave Conversion // // Verilog-standard: Verilog 2001 //-------------------------------------------------------------------------- // // Structure: // axilite_conv // //-------------------------------------------------------------------------- `timescale 1ps/1ps (* DowngradeIPIdentifiedWarnings="yes" *) module axi_protocol_converter_v2_1_axilite_conv # ( parameter C_FAMILY = "virtex6", parameter integer C_AXI_ID_WIDTH = 1, parameter integer C_AXI_ADDR_WIDTH = 32, parameter integer C_AXI_DATA_WIDTH = 32, parameter integer C_AXI_SUPPORTS_WRITE = 1, parameter integer C_AXI_SUPPORTS_READ = 1, parameter integer C_AXI_RUSER_WIDTH = 1, parameter integer C_AXI_BUSER_WIDTH = 1 ) ( // System Signals input wire ACLK, input wire ARESETN, // Slave Interface Write Address Ports input wire [C_AXI_ID_WIDTH-1:0] S_AXI_AWID, input wire [C_AXI_ADDR_WIDTH-1:0] S_AXI_AWADDR, input wire [3-1:0] S_AXI_AWPROT, input wire S_AXI_AWVALID, output wire S_AXI_AWREADY, // Slave Interface Write Data Ports input wire [C_AXI_DATA_WIDTH-1:0] S_AXI_WDATA, input wire [C_AXI_DATA_WIDTH/8-1:0] S_AXI_WSTRB, input wire S_AXI_WVALID, output wire S_AXI_WREADY, // Slave Interface Write Response Ports output wire [C_AXI_ID_WIDTH-1:0] S_AXI_BID, output wire [2-1:0] S_AXI_BRESP, output wire [C_AXI_BUSER_WIDTH-1:0] S_AXI_BUSER, // Constant =0 output wire S_AXI_BVALID, input wire S_AXI_BREADY, // Slave Interface Read Address Ports input wire [C_AXI_ID_WIDTH-1:0] S_AXI_ARID, input wire [C_AXI_ADDR_WIDTH-1:0] S_AXI_ARADDR, input wire [3-1:0] S_AXI_ARPROT, input wire S_AXI_ARVALID, output wire S_AXI_ARREADY, // Slave Interface Read Data Ports output wire [C_AXI_ID_WIDTH-1:0] S_AXI_RID, output wire [C_AXI_DATA_WIDTH-1:0] S_AXI_RDATA, output wire [2-1:0] S_AXI_RRESP, output wire S_AXI_RLAST, // Constant =1 output wire [C_AXI_RUSER_WIDTH-1:0] S_AXI_RUSER, // Constant =0 output wire S_AXI_RVALID, input wire S_AXI_RREADY, // Master Interface Write Address Port output wire [C_AXI_ADDR_WIDTH-1:0] M_AXI_AWADDR, output wire [3-1:0] M_AXI_AWPROT, output wire M_AXI_AWVALID, input wire M_AXI_AWREADY, // Master Interface Write Data Ports output wire [C_AXI_DATA_WIDTH-1:0] M_AXI_WDATA, output wire [C_AXI_DATA_WIDTH/8-1:0] M_AXI_WSTRB, output wire M_AXI_WVALID, input wire M_AXI_WREADY, // Master Interface Write Response Ports input wire [2-1:0] M_AXI_BRESP, input wire M_AXI_BVALID, output wire M_AXI_BREADY, // Master Interface Read Address Port output wire [C_AXI_ADDR_WIDTH-1:0] M_AXI_ARADDR, output wire [3-1:0] M_AXI_ARPROT, output wire M_AXI_ARVALID, input wire M_AXI_ARREADY, // Master Interface Read Data Ports input wire [C_AXI_DATA_WIDTH-1:0] M_AXI_RDATA, input wire [2-1:0] M_AXI_RRESP, input wire M_AXI_RVALID, output wire M_AXI_RREADY ); wire s_awvalid_i; wire s_arvalid_i; wire [C_AXI_ADDR_WIDTH-1:0] m_axaddr; // Arbiter reg read_active; reg write_active; reg busy; wire read_req; wire write_req; wire read_complete; wire write_complete; reg [1:0] areset_d; // Reset delay register always @(posedge ACLK) begin areset_d <= {areset_d[0], ~ARESETN}; end assign s_awvalid_i = S_AXI_AWVALID & (C_AXI_SUPPORTS_WRITE != 0); assign s_arvalid_i = S_AXI_ARVALID & (C_AXI_SUPPORTS_READ != 0); assign read_req = s_arvalid_i & ~busy & ~|areset_d & ~write_active; assign write_req = s_awvalid_i & ~busy & ~|areset_d & ((~read_active & ~s_arvalid_i) | write_active); assign read_complete = M_AXI_RVALID & S_AXI_RREADY; assign write_complete = M_AXI_BVALID & S_AXI_BREADY; always @(posedge ACLK) begin : arbiter_read_ff if (|areset_d) read_active <= 1'b0; else if (read_complete) read_active <= 1'b0; else if (read_req) read_active <= 1'b1; end always @(posedge ACLK) begin : arbiter_write_ff if (|areset_d) write_active <= 1'b0; else if (write_complete) write_active <= 1'b0; else if (write_req) write_active <= 1'b1; end always @(posedge ACLK) begin : arbiter_busy_ff if (|areset_d) busy <= 1'b0; else if (read_complete | write_complete) busy <= 1'b0; else if ((write_req & M_AXI_AWREADY) | (read_req & M_AXI_ARREADY)) busy <= 1'b1; end assign M_AXI_ARVALID = read_req; assign S_AXI_ARREADY = M_AXI_ARREADY & read_req; assign M_AXI_AWVALID = write_req; assign S_AXI_AWREADY = M_AXI_AWREADY & write_req; assign M_AXI_RREADY = S_AXI_RREADY & read_active; assign S_AXI_RVALID = M_AXI_RVALID & read_active; assign M_AXI_BREADY = S_AXI_BREADY & write_active; assign S_AXI_BVALID = M_AXI_BVALID & write_active; // Address multiplexer assign m_axaddr = (read_req | (C_AXI_SUPPORTS_WRITE == 0)) ? S_AXI_ARADDR : S_AXI_AWADDR; // Id multiplexer and flip-flop reg [C_AXI_ID_WIDTH-1:0] s_axid; always @(posedge ACLK) begin : axid if (read_req) s_axid <= S_AXI_ARID; else if (write_req) s_axid <= S_AXI_AWID; end assign S_AXI_BID = s_axid; assign S_AXI_RID = s_axid; assign M_AXI_AWADDR = m_axaddr; assign M_AXI_ARADDR = m_axaddr; // Feed-through signals assign S_AXI_WREADY = M_AXI_WREADY & ~|areset_d; assign S_AXI_BRESP = M_AXI_BRESP; assign S_AXI_RDATA = M_AXI_RDATA; assign S_AXI_RRESP = M_AXI_RRESP; assign S_AXI_RLAST = 1'b1; assign S_AXI_BUSER = {C_AXI_BUSER_WIDTH{1'b0}}; assign S_AXI_RUSER = {C_AXI_RUSER_WIDTH{1'b0}}; assign M_AXI_AWPROT = S_AXI_AWPROT; assign M_AXI_WVALID = S_AXI_WVALID & ~|areset_d; assign M_AXI_WDATA = S_AXI_WDATA; assign M_AXI_WSTRB = S_AXI_WSTRB; assign M_AXI_ARPROT = S_AXI_ARPROT; endmodule
// -- (c) Copyright 2010 - 2011 Xilinx, Inc. All rights reserved. // -- // -- This file contains confidential and proprietary information // -- of Xilinx, Inc. and is protected under U.S. and // -- international copyright and other intellectual property // -- laws. // -- // -- DISCLAIMER // -- This disclaimer is not a license and does not grant any // -- rights to the materials distributed herewith. Except as // -- otherwise provided in a valid license issued to you by // -- Xilinx, and to the maximum extent permitted by applicable // -- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND // -- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES // -- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING // -- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- // -- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and // -- (2) Xilinx shall not be liable (whether in contract or tort, // -- including negligence, or under any other theory of // -- liability) for any loss or damage of any kind or nature // -- related to, arising under or in connection with these // -- materials, including for any direct, or any indirect, // -- special, incidental, or consequential loss or damage // -- (including loss of data, profits, goodwill, or any type of // -- loss or damage suffered as a result of any action brought // -- by a third party) even if such damage or loss was // -- reasonably foreseeable or Xilinx had been advised of the // -- possibility of the same. // -- // -- CRITICAL APPLICATIONS // -- Xilinx products are not designed or intended to be fail- // -- safe, or for use in any application requiring fail-safe // -- performance, such as life-support or safety devices or // -- systems, Class III medical devices, nuclear facilities, // -- applications related to the deployment of airbags, or any // -- other applications that could lead to death, personal // -- injury, or severe property or environmental damage // -- (individually and collectively, "Critical // -- Applications"). Customer assumes the sole risk and // -- liability of any use of Xilinx products in Critical // -- Applications, subject only to applicable laws and // -- regulations governing limitations on product liability. // -- // -- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS // -- PART OF THIS FILE AT ALL TIMES. //----------------------------------------------------------------------------- // // Description: AxiLite Slave Conversion // // Verilog-standard: Verilog 2001 //-------------------------------------------------------------------------- // // Structure: // axilite_conv // //-------------------------------------------------------------------------- `timescale 1ps/1ps (* DowngradeIPIdentifiedWarnings="yes" *) module axi_protocol_converter_v2_1_axilite_conv # ( parameter C_FAMILY = "virtex6", parameter integer C_AXI_ID_WIDTH = 1, parameter integer C_AXI_ADDR_WIDTH = 32, parameter integer C_AXI_DATA_WIDTH = 32, parameter integer C_AXI_SUPPORTS_WRITE = 1, parameter integer C_AXI_SUPPORTS_READ = 1, parameter integer C_AXI_RUSER_WIDTH = 1, parameter integer C_AXI_BUSER_WIDTH = 1 ) ( // System Signals input wire ACLK, input wire ARESETN, // Slave Interface Write Address Ports input wire [C_AXI_ID_WIDTH-1:0] S_AXI_AWID, input wire [C_AXI_ADDR_WIDTH-1:0] S_AXI_AWADDR, input wire [3-1:0] S_AXI_AWPROT, input wire S_AXI_AWVALID, output wire S_AXI_AWREADY, // Slave Interface Write Data Ports input wire [C_AXI_DATA_WIDTH-1:0] S_AXI_WDATA, input wire [C_AXI_DATA_WIDTH/8-1:0] S_AXI_WSTRB, input wire S_AXI_WVALID, output wire S_AXI_WREADY, // Slave Interface Write Response Ports output wire [C_AXI_ID_WIDTH-1:0] S_AXI_BID, output wire [2-1:0] S_AXI_BRESP, output wire [C_AXI_BUSER_WIDTH-1:0] S_AXI_BUSER, // Constant =0 output wire S_AXI_BVALID, input wire S_AXI_BREADY, // Slave Interface Read Address Ports input wire [C_AXI_ID_WIDTH-1:0] S_AXI_ARID, input wire [C_AXI_ADDR_WIDTH-1:0] S_AXI_ARADDR, input wire [3-1:0] S_AXI_ARPROT, input wire S_AXI_ARVALID, output wire S_AXI_ARREADY, // Slave Interface Read Data Ports output wire [C_AXI_ID_WIDTH-1:0] S_AXI_RID, output wire [C_AXI_DATA_WIDTH-1:0] S_AXI_RDATA, output wire [2-1:0] S_AXI_RRESP, output wire S_AXI_RLAST, // Constant =1 output wire [C_AXI_RUSER_WIDTH-1:0] S_AXI_RUSER, // Constant =0 output wire S_AXI_RVALID, input wire S_AXI_RREADY, // Master Interface Write Address Port output wire [C_AXI_ADDR_WIDTH-1:0] M_AXI_AWADDR, output wire [3-1:0] M_AXI_AWPROT, output wire M_AXI_AWVALID, input wire M_AXI_AWREADY, // Master Interface Write Data Ports output wire [C_AXI_DATA_WIDTH-1:0] M_AXI_WDATA, output wire [C_AXI_DATA_WIDTH/8-1:0] M_AXI_WSTRB, output wire M_AXI_WVALID, input wire M_AXI_WREADY, // Master Interface Write Response Ports input wire [2-1:0] M_AXI_BRESP, input wire M_AXI_BVALID, output wire M_AXI_BREADY, // Master Interface Read Address Port output wire [C_AXI_ADDR_WIDTH-1:0] M_AXI_ARADDR, output wire [3-1:0] M_AXI_ARPROT, output wire M_AXI_ARVALID, input wire M_AXI_ARREADY, // Master Interface Read Data Ports input wire [C_AXI_DATA_WIDTH-1:0] M_AXI_RDATA, input wire [2-1:0] M_AXI_RRESP, input wire M_AXI_RVALID, output wire M_AXI_RREADY ); wire s_awvalid_i; wire s_arvalid_i; wire [C_AXI_ADDR_WIDTH-1:0] m_axaddr; // Arbiter reg read_active; reg write_active; reg busy; wire read_req; wire write_req; wire read_complete; wire write_complete; reg [1:0] areset_d; // Reset delay register always @(posedge ACLK) begin areset_d <= {areset_d[0], ~ARESETN}; end assign s_awvalid_i = S_AXI_AWVALID & (C_AXI_SUPPORTS_WRITE != 0); assign s_arvalid_i = S_AXI_ARVALID & (C_AXI_SUPPORTS_READ != 0); assign read_req = s_arvalid_i & ~busy & ~|areset_d & ~write_active; assign write_req = s_awvalid_i & ~busy & ~|areset_d & ((~read_active & ~s_arvalid_i) | write_active); assign read_complete = M_AXI_RVALID & S_AXI_RREADY; assign write_complete = M_AXI_BVALID & S_AXI_BREADY; always @(posedge ACLK) begin : arbiter_read_ff if (|areset_d) read_active <= 1'b0; else if (read_complete) read_active <= 1'b0; else if (read_req) read_active <= 1'b1; end always @(posedge ACLK) begin : arbiter_write_ff if (|areset_d) write_active <= 1'b0; else if (write_complete) write_active <= 1'b0; else if (write_req) write_active <= 1'b1; end always @(posedge ACLK) begin : arbiter_busy_ff if (|areset_d) busy <= 1'b0; else if (read_complete | write_complete) busy <= 1'b0; else if ((write_req & M_AXI_AWREADY) | (read_req & M_AXI_ARREADY)) busy <= 1'b1; end assign M_AXI_ARVALID = read_req; assign S_AXI_ARREADY = M_AXI_ARREADY & read_req; assign M_AXI_AWVALID = write_req; assign S_AXI_AWREADY = M_AXI_AWREADY & write_req; assign M_AXI_RREADY = S_AXI_RREADY & read_active; assign S_AXI_RVALID = M_AXI_RVALID & read_active; assign M_AXI_BREADY = S_AXI_BREADY & write_active; assign S_AXI_BVALID = M_AXI_BVALID & write_active; // Address multiplexer assign m_axaddr = (read_req | (C_AXI_SUPPORTS_WRITE == 0)) ? S_AXI_ARADDR : S_AXI_AWADDR; // Id multiplexer and flip-flop reg [C_AXI_ID_WIDTH-1:0] s_axid; always @(posedge ACLK) begin : axid if (read_req) s_axid <= S_AXI_ARID; else if (write_req) s_axid <= S_AXI_AWID; end assign S_AXI_BID = s_axid; assign S_AXI_RID = s_axid; assign M_AXI_AWADDR = m_axaddr; assign M_AXI_ARADDR = m_axaddr; // Feed-through signals assign S_AXI_WREADY = M_AXI_WREADY & ~|areset_d; assign S_AXI_BRESP = M_AXI_BRESP; assign S_AXI_RDATA = M_AXI_RDATA; assign S_AXI_RRESP = M_AXI_RRESP; assign S_AXI_RLAST = 1'b1; assign S_AXI_BUSER = {C_AXI_BUSER_WIDTH{1'b0}}; assign S_AXI_RUSER = {C_AXI_RUSER_WIDTH{1'b0}}; assign M_AXI_AWPROT = S_AXI_AWPROT; assign M_AXI_WVALID = S_AXI_WVALID & ~|areset_d; assign M_AXI_WDATA = S_AXI_WDATA; assign M_AXI_WSTRB = S_AXI_WSTRB; assign M_AXI_ARPROT = S_AXI_ARPROT; endmodule
// -- (c) Copyright 2010 - 2011 Xilinx, Inc. All rights reserved. // -- // -- This file contains confidential and proprietary information // -- of Xilinx, Inc. and is protected under U.S. and // -- international copyright and other intellectual property // -- laws. // -- // -- DISCLAIMER // -- This disclaimer is not a license and does not grant any // -- rights to the materials distributed herewith. Except as // -- otherwise provided in a valid license issued to you by // -- Xilinx, and to the maximum extent permitted by applicable // -- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND // -- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES // -- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING // -- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- // -- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and // -- (2) Xilinx shall not be liable (whether in contract or tort, // -- including negligence, or under any other theory of // -- liability) for any loss or damage of any kind or nature // -- related to, arising under or in connection with these // -- materials, including for any direct, or any indirect, // -- special, incidental, or consequential loss or damage // -- (including loss of data, profits, goodwill, or any type of // -- loss or damage suffered as a result of any action brought // -- by a third party) even if such damage or loss was // -- reasonably foreseeable or Xilinx had been advised of the // -- possibility of the same. // -- // -- CRITICAL APPLICATIONS // -- Xilinx products are not designed or intended to be fail- // -- safe, or for use in any application requiring fail-safe // -- performance, such as life-support or safety devices or // -- systems, Class III medical devices, nuclear facilities, // -- applications related to the deployment of airbags, or any // -- other applications that could lead to death, personal // -- injury, or severe property or environmental damage // -- (individually and collectively, "Critical // -- Applications"). Customer assumes the sole risk and // -- liability of any use of Xilinx products in Critical // -- Applications, subject only to applicable laws and // -- regulations governing limitations on product liability. // -- // -- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS // -- PART OF THIS FILE AT ALL TIMES. //----------------------------------------------------------------------------- // // Description: AxiLite Slave Conversion // // Verilog-standard: Verilog 2001 //-------------------------------------------------------------------------- // // Structure: // axilite_conv // //-------------------------------------------------------------------------- `timescale 1ps/1ps (* DowngradeIPIdentifiedWarnings="yes" *) module axi_protocol_converter_v2_1_axilite_conv # ( parameter C_FAMILY = "virtex6", parameter integer C_AXI_ID_WIDTH = 1, parameter integer C_AXI_ADDR_WIDTH = 32, parameter integer C_AXI_DATA_WIDTH = 32, parameter integer C_AXI_SUPPORTS_WRITE = 1, parameter integer C_AXI_SUPPORTS_READ = 1, parameter integer C_AXI_RUSER_WIDTH = 1, parameter integer C_AXI_BUSER_WIDTH = 1 ) ( // System Signals input wire ACLK, input wire ARESETN, // Slave Interface Write Address Ports input wire [C_AXI_ID_WIDTH-1:0] S_AXI_AWID, input wire [C_AXI_ADDR_WIDTH-1:0] S_AXI_AWADDR, input wire [3-1:0] S_AXI_AWPROT, input wire S_AXI_AWVALID, output wire S_AXI_AWREADY, // Slave Interface Write Data Ports input wire [C_AXI_DATA_WIDTH-1:0] S_AXI_WDATA, input wire [C_AXI_DATA_WIDTH/8-1:0] S_AXI_WSTRB, input wire S_AXI_WVALID, output wire S_AXI_WREADY, // Slave Interface Write Response Ports output wire [C_AXI_ID_WIDTH-1:0] S_AXI_BID, output wire [2-1:0] S_AXI_BRESP, output wire [C_AXI_BUSER_WIDTH-1:0] S_AXI_BUSER, // Constant =0 output wire S_AXI_BVALID, input wire S_AXI_BREADY, // Slave Interface Read Address Ports input wire [C_AXI_ID_WIDTH-1:0] S_AXI_ARID, input wire [C_AXI_ADDR_WIDTH-1:0] S_AXI_ARADDR, input wire [3-1:0] S_AXI_ARPROT, input wire S_AXI_ARVALID, output wire S_AXI_ARREADY, // Slave Interface Read Data Ports output wire [C_AXI_ID_WIDTH-1:0] S_AXI_RID, output wire [C_AXI_DATA_WIDTH-1:0] S_AXI_RDATA, output wire [2-1:0] S_AXI_RRESP, output wire S_AXI_RLAST, // Constant =1 output wire [C_AXI_RUSER_WIDTH-1:0] S_AXI_RUSER, // Constant =0 output wire S_AXI_RVALID, input wire S_AXI_RREADY, // Master Interface Write Address Port output wire [C_AXI_ADDR_WIDTH-1:0] M_AXI_AWADDR, output wire [3-1:0] M_AXI_AWPROT, output wire M_AXI_AWVALID, input wire M_AXI_AWREADY, // Master Interface Write Data Ports output wire [C_AXI_DATA_WIDTH-1:0] M_AXI_WDATA, output wire [C_AXI_DATA_WIDTH/8-1:0] M_AXI_WSTRB, output wire M_AXI_WVALID, input wire M_AXI_WREADY, // Master Interface Write Response Ports input wire [2-1:0] M_AXI_BRESP, input wire M_AXI_BVALID, output wire M_AXI_BREADY, // Master Interface Read Address Port output wire [C_AXI_ADDR_WIDTH-1:0] M_AXI_ARADDR, output wire [3-1:0] M_AXI_ARPROT, output wire M_AXI_ARVALID, input wire M_AXI_ARREADY, // Master Interface Read Data Ports input wire [C_AXI_DATA_WIDTH-1:0] M_AXI_RDATA, input wire [2-1:0] M_AXI_RRESP, input wire M_AXI_RVALID, output wire M_AXI_RREADY ); wire s_awvalid_i; wire s_arvalid_i; wire [C_AXI_ADDR_WIDTH-1:0] m_axaddr; // Arbiter reg read_active; reg write_active; reg busy; wire read_req; wire write_req; wire read_complete; wire write_complete; reg [1:0] areset_d; // Reset delay register always @(posedge ACLK) begin areset_d <= {areset_d[0], ~ARESETN}; end assign s_awvalid_i = S_AXI_AWVALID & (C_AXI_SUPPORTS_WRITE != 0); assign s_arvalid_i = S_AXI_ARVALID & (C_AXI_SUPPORTS_READ != 0); assign read_req = s_arvalid_i & ~busy & ~|areset_d & ~write_active; assign write_req = s_awvalid_i & ~busy & ~|areset_d & ((~read_active & ~s_arvalid_i) | write_active); assign read_complete = M_AXI_RVALID & S_AXI_RREADY; assign write_complete = M_AXI_BVALID & S_AXI_BREADY; always @(posedge ACLK) begin : arbiter_read_ff if (|areset_d) read_active <= 1'b0; else if (read_complete) read_active <= 1'b0; else if (read_req) read_active <= 1'b1; end always @(posedge ACLK) begin : arbiter_write_ff if (|areset_d) write_active <= 1'b0; else if (write_complete) write_active <= 1'b0; else if (write_req) write_active <= 1'b1; end always @(posedge ACLK) begin : arbiter_busy_ff if (|areset_d) busy <= 1'b0; else if (read_complete | write_complete) busy <= 1'b0; else if ((write_req & M_AXI_AWREADY) | (read_req & M_AXI_ARREADY)) busy <= 1'b1; end assign M_AXI_ARVALID = read_req; assign S_AXI_ARREADY = M_AXI_ARREADY & read_req; assign M_AXI_AWVALID = write_req; assign S_AXI_AWREADY = M_AXI_AWREADY & write_req; assign M_AXI_RREADY = S_AXI_RREADY & read_active; assign S_AXI_RVALID = M_AXI_RVALID & read_active; assign M_AXI_BREADY = S_AXI_BREADY & write_active; assign S_AXI_BVALID = M_AXI_BVALID & write_active; // Address multiplexer assign m_axaddr = (read_req | (C_AXI_SUPPORTS_WRITE == 0)) ? S_AXI_ARADDR : S_AXI_AWADDR; // Id multiplexer and flip-flop reg [C_AXI_ID_WIDTH-1:0] s_axid; always @(posedge ACLK) begin : axid if (read_req) s_axid <= S_AXI_ARID; else if (write_req) s_axid <= S_AXI_AWID; end assign S_AXI_BID = s_axid; assign S_AXI_RID = s_axid; assign M_AXI_AWADDR = m_axaddr; assign M_AXI_ARADDR = m_axaddr; // Feed-through signals assign S_AXI_WREADY = M_AXI_WREADY & ~|areset_d; assign S_AXI_BRESP = M_AXI_BRESP; assign S_AXI_RDATA = M_AXI_RDATA; assign S_AXI_RRESP = M_AXI_RRESP; assign S_AXI_RLAST = 1'b1; assign S_AXI_BUSER = {C_AXI_BUSER_WIDTH{1'b0}}; assign S_AXI_RUSER = {C_AXI_RUSER_WIDTH{1'b0}}; assign M_AXI_AWPROT = S_AXI_AWPROT; assign M_AXI_WVALID = S_AXI_WVALID & ~|areset_d; assign M_AXI_WDATA = S_AXI_WDATA; assign M_AXI_WSTRB = S_AXI_WSTRB; assign M_AXI_ARPROT = S_AXI_ARPROT; endmodule
// This is a component of pluto_step, a hardware step waveform generator // Copyright 2007 Jeff Epler <[email protected]> // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA module stepgen(clk, enable, position, velocity, dirtime, steptime, step, dir, tap); `define STATE_STEP 0 `define STATE_DIRCHANGE 1 `define STATE_DIRWAIT 2 parameter W=12; parameter F=10; parameter T=5; input clk, enable; output [W+F-1:0] position; reg [W+F-1:0] position; input [F:0] velocity; input [T-1:0] dirtime, steptime; input [1:0] tap; output step, dir; reg step, dir; reg [T-1:0] timer; reg [1:0] state; reg ones; wire dbit = velocity[F]; wire pbit = (tap == 0 ? position[F] : (tap == 1 ? position[F+1] : (tap == 2 ? position[F+2] : position[F+3]))); wire [W+F-1:0] xvelocity = {{W{velocity[F]}}, {1{velocity[F-1:0]}}}; `ifdef TESTING // for testing: initial position = 1'b0; initial state = `STATE_STEP; initial timer = 0; initial dir = 0; initial ones = 0; `endif always @(posedge clk) begin if(enable) begin // $display("state=%d timer=%d position=%h velocity=%h dir=%d dbit=%d pbit=%d ones=%d", state, timer, position, xvelocity, dir, dbit, pbit, ones); if((dir != dbit) && (pbit == ones)) begin if(state == `STATE_DIRCHANGE) begin if(timer == 0) begin dir <= dbit; timer <= dirtime; state <= `STATE_DIRWAIT; end else begin timer <= timer - 1'd1; end end else begin if(timer == 0) begin step <= 0; timer <= dirtime; state <= `STATE_DIRCHANGE; end else begin timer <= timer - 1'd1; end end end else if(state == `STATE_DIRWAIT) begin if(timer == 0) begin state <= `STATE_STEP; end else begin timer <= timer - 1'd1; end end else begin if(timer == 0) begin if(pbit != ones) begin ones <= pbit; step <= 1'd1; timer <= steptime; end else begin step <= 0; end end else begin timer <= timer - 1'd1; end if(dir == dbit) position <= position + xvelocity; end end end endmodule
// This is a component of pluto_step, a hardware step waveform generator // Copyright 2007 Jeff Epler <[email protected]> // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA module stepgen(clk, enable, position, velocity, dirtime, steptime, step, dir, tap); `define STATE_STEP 0 `define STATE_DIRCHANGE 1 `define STATE_DIRWAIT 2 parameter W=12; parameter F=10; parameter T=5; input clk, enable; output [W+F-1:0] position; reg [W+F-1:0] position; input [F:0] velocity; input [T-1:0] dirtime, steptime; input [1:0] tap; output step, dir; reg step, dir; reg [T-1:0] timer; reg [1:0] state; reg ones; wire dbit = velocity[F]; wire pbit = (tap == 0 ? position[F] : (tap == 1 ? position[F+1] : (tap == 2 ? position[F+2] : position[F+3]))); wire [W+F-1:0] xvelocity = {{W{velocity[F]}}, {1{velocity[F-1:0]}}}; `ifdef TESTING // for testing: initial position = 1'b0; initial state = `STATE_STEP; initial timer = 0; initial dir = 0; initial ones = 0; `endif always @(posedge clk) begin if(enable) begin // $display("state=%d timer=%d position=%h velocity=%h dir=%d dbit=%d pbit=%d ones=%d", state, timer, position, xvelocity, dir, dbit, pbit, ones); if((dir != dbit) && (pbit == ones)) begin if(state == `STATE_DIRCHANGE) begin if(timer == 0) begin dir <= dbit; timer <= dirtime; state <= `STATE_DIRWAIT; end else begin timer <= timer - 1'd1; end end else begin if(timer == 0) begin step <= 0; timer <= dirtime; state <= `STATE_DIRCHANGE; end else begin timer <= timer - 1'd1; end end end else if(state == `STATE_DIRWAIT) begin if(timer == 0) begin state <= `STATE_STEP; end else begin timer <= timer - 1'd1; end end else begin if(timer == 0) begin if(pbit != ones) begin ones <= pbit; step <= 1'd1; timer <= steptime; end else begin step <= 0; end end else begin timer <= timer - 1'd1; end if(dir == dbit) position <= position + xvelocity; end end end endmodule
/* * Copyright (c) 2009 Zeus Gomez Marmolejo <[email protected]> * * This file is part of the Zet processor. This processor is free * hardware; you can redistribute it and/or modify it under the terms of * the GNU General Public License as published by the Free Software * Foundation; either version 3, or (at your option) any later version. * * Zet is distrubuted in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public * License for more details. * * You should have received a copy of the GNU General Public License * along with Zet; see the file COPYING. If not, see * <http://www.gnu.org/licenses/>. */ module hex_display ( input [15:0] num, input en, output [6:0] hex0, output [6:0] hex1, output [6:0] hex2, output [6:0] hex3 ); // Module instantiations seg_7 hex_group0 ( .num (num[3:0]), .en (en), .seg (hex0) ); seg_7 hex_group1 ( .num (num[7:4]), .en (en), .seg (hex1) ); seg_7 hex_group2 ( .num (num[11:8]), .en (en), .seg (hex2) ); seg_7 hex_group3 ( .num (num[15:12]), .en (en), .seg (hex3) ); endmodule
/* * Copyright (c) 2009 Zeus Gomez Marmolejo <[email protected]> * * This file is part of the Zet processor. This processor is free * hardware; you can redistribute it and/or modify it under the terms of * the GNU General Public License as published by the Free Software * Foundation; either version 3, or (at your option) any later version. * * Zet is distrubuted in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public * License for more details. * * You should have received a copy of the GNU General Public License * along with Zet; see the file COPYING. If not, see * <http://www.gnu.org/licenses/>. */ module hex_display ( input [15:0] num, input en, output [6:0] hex0, output [6:0] hex1, output [6:0] hex2, output [6:0] hex3 ); // Module instantiations seg_7 hex_group0 ( .num (num[3:0]), .en (en), .seg (hex0) ); seg_7 hex_group1 ( .num (num[7:4]), .en (en), .seg (hex1) ); seg_7 hex_group2 ( .num (num[11:8]), .en (en), .seg (hex2) ); seg_7 hex_group3 ( .num (num[15:12]), .en (en), .seg (hex3) ); endmodule
/* * Copyright (c) 2009 Zeus Gomez Marmolejo <[email protected]> * * This file is part of the Zet processor. This processor is free * hardware; you can redistribute it and/or modify it under the terms of * the GNU General Public License as published by the Free Software * Foundation; either version 3, or (at your option) any later version. * * Zet is distrubuted in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public * License for more details. * * You should have received a copy of the GNU General Public License * along with Zet; see the file COPYING. If not, see * <http://www.gnu.org/licenses/>. */ module hex_display ( input [15:0] num, input en, output [6:0] hex0, output [6:0] hex1, output [6:0] hex2, output [6:0] hex3 ); // Module instantiations seg_7 hex_group0 ( .num (num[3:0]), .en (en), .seg (hex0) ); seg_7 hex_group1 ( .num (num[7:4]), .en (en), .seg (hex1) ); seg_7 hex_group2 ( .num (num[11:8]), .en (en), .seg (hex2) ); seg_7 hex_group3 ( .num (num[15:12]), .en (en), .seg (hex3) ); endmodule
/* * Copyright (c) 2009 Zeus Gomez Marmolejo <[email protected]> * * This file is part of the Zet processor. This processor is free * hardware; you can redistribute it and/or modify it under the terms of * the GNU General Public License as published by the Free Software * Foundation; either version 3, or (at your option) any later version. * * Zet is distrubuted in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public * License for more details. * * You should have received a copy of the GNU General Public License * along with Zet; see the file COPYING. If not, see * <http://www.gnu.org/licenses/>. */ module hex_display ( input [15:0] num, input en, output [6:0] hex0, output [6:0] hex1, output [6:0] hex2, output [6:0] hex3 ); // Module instantiations seg_7 hex_group0 ( .num (num[3:0]), .en (en), .seg (hex0) ); seg_7 hex_group1 ( .num (num[7:4]), .en (en), .seg (hex1) ); seg_7 hex_group2 ( .num (num[11:8]), .en (en), .seg (hex2) ); seg_7 hex_group3 ( .num (num[15:12]), .en (en), .seg (hex3) ); endmodule
/* * Copyright (c) 2009 Zeus Gomez Marmolejo <[email protected]> * * This file is part of the Zet processor. This processor is free * hardware; you can redistribute it and/or modify it under the terms of * the GNU General Public License as published by the Free Software * Foundation; either version 3, or (at your option) any later version. * * Zet is distrubuted in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public * License for more details. * * You should have received a copy of the GNU General Public License * along with Zet; see the file COPYING. If not, see * <http://www.gnu.org/licenses/>. */ module hex_display ( input [15:0] num, input en, output [6:0] hex0, output [6:0] hex1, output [6:0] hex2, output [6:0] hex3 ); // Module instantiations seg_7 hex_group0 ( .num (num[3:0]), .en (en), .seg (hex0) ); seg_7 hex_group1 ( .num (num[7:4]), .en (en), .seg (hex1) ); seg_7 hex_group2 ( .num (num[11:8]), .en (en), .seg (hex2) ); seg_7 hex_group3 ( .num (num[15:12]), .en (en), .seg (hex3) ); endmodule
/* * Copyright (c) 2009 Zeus Gomez Marmolejo <[email protected]> * * This file is part of the Zet processor. This processor is free * hardware; you can redistribute it and/or modify it under the terms of * the GNU General Public License as published by the Free Software * Foundation; either version 3, or (at your option) any later version. * * Zet is distrubuted in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public * License for more details. * * You should have received a copy of the GNU General Public License * along with Zet; see the file COPYING. If not, see * <http://www.gnu.org/licenses/>. */ module hex_display ( input [15:0] num, input en, output [6:0] hex0, output [6:0] hex1, output [6:0] hex2, output [6:0] hex3 ); // Module instantiations seg_7 hex_group0 ( .num (num[3:0]), .en (en), .seg (hex0) ); seg_7 hex_group1 ( .num (num[7:4]), .en (en), .seg (hex1) ); seg_7 hex_group2 ( .num (num[11:8]), .en (en), .seg (hex2) ); seg_7 hex_group3 ( .num (num[15:12]), .en (en), .seg (hex3) ); endmodule
/* * Copyright (c) 2009 Zeus Gomez Marmolejo <[email protected]> * * This file is part of the Zet processor. This processor is free * hardware; you can redistribute it and/or modify it under the terms of * the GNU General Public License as published by the Free Software * Foundation; either version 3, or (at your option) any later version. * * Zet is distrubuted in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public * License for more details. * * You should have received a copy of the GNU General Public License * along with Zet; see the file COPYING. If not, see * <http://www.gnu.org/licenses/>. */ module hex_display ( input [15:0] num, input en, output [6:0] hex0, output [6:0] hex1, output [6:0] hex2, output [6:0] hex3 ); // Module instantiations seg_7 hex_group0 ( .num (num[3:0]), .en (en), .seg (hex0) ); seg_7 hex_group1 ( .num (num[7:4]), .en (en), .seg (hex1) ); seg_7 hex_group2 ( .num (num[11:8]), .en (en), .seg (hex2) ); seg_7 hex_group3 ( .num (num[15:12]), .en (en), .seg (hex3) ); endmodule
// (c) Copyright 2012-2013 Xilinx, Inc. All rights reserved. // // This file contains confidential and proprietary information // of Xilinx, Inc. and is protected under U.S. and // international copyright and other intellectual property // laws. // // DISCLAIMER // This disclaimer is not a license and does not grant any // rights to the materials distributed herewith. Except as // otherwise provided in a valid license issued to you by // Xilinx, and to the maximum extent permitted by applicable // law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND // WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES // AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING // BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- // INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and // (2) Xilinx shall not be liable (whether in contract or tort, // including negligence, or under any other theory of // liability) for any loss or damage of any kind or nature // related to, arising under or in connection with these // materials, including for any direct, or any indirect, // special, incidental, or consequential loss or damage // (including loss of data, profits, goodwill, or any type of // loss or damage suffered as a result of any action brought // by a third party) even if such damage or loss was // reasonably foreseeable or Xilinx had been advised of the // possibility of the same. // // CRITICAL APPLICATIONS // Xilinx products are not designed or intended to be fail- // safe, or for use in any application requiring fail-safe // performance, such as life-support or safety devices or // systems, Class III medical devices, nuclear facilities, // applications related to the deployment of airbags, or any // other applications that could lead to death, personal // injury, or severe property or environmental damage // (individually and collectively, "Critical // Applications"). Customer assumes the sole risk and // liability of any use of Xilinx products in Critical // Applications, subject only to applicable laws and // regulations governing limitations on product liability. // // THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS // PART OF THIS FILE AT ALL TIMES. //----------------------------------------------------------------------------- // Description: SRL based FIFO for AXIS/AXI Channels. //-------------------------------------------------------------------------- `timescale 1ps/1ps `default_nettype none (* DowngradeIPIdentifiedWarnings="yes" *) module axi_infrastructure_v1_1_axic_srl_fifo #( /////////////////////////////////////////////////////////////////////////////// // Parameter Definitions /////////////////////////////////////////////////////////////////////////////// parameter C_FAMILY = "virtex7", parameter integer C_PAYLOAD_WIDTH = 1, parameter integer C_FIFO_DEPTH = 16 // Range: 4-16. ) ( /////////////////////////////////////////////////////////////////////////////// // Port Declarations /////////////////////////////////////////////////////////////////////////////// input wire aclk, // Clock input wire aresetn, // Reset input wire [C_PAYLOAD_WIDTH-1:0] s_payload, // Input data input wire s_valid, // Input data valid output reg s_ready, // Input data ready output wire [C_PAYLOAD_WIDTH-1:0] m_payload, // Output data output reg m_valid, // Output data valid input wire m_ready // Output data ready ); //////////////////////////////////////////////////////////////////////////////// // Functions //////////////////////////////////////////////////////////////////////////////// // ceiling logb2 function integer f_clogb2 (input integer size); integer s; begin s = size; s = s - 1; for (f_clogb2=1; s>1; f_clogb2=f_clogb2+1) s = s >> 1; end endfunction // clogb2 //////////////////////////////////////////////////////////////////////////////// // Local parameters //////////////////////////////////////////////////////////////////////////////// localparam integer LP_LOG_FIFO_DEPTH = f_clogb2(C_FIFO_DEPTH); //////////////////////////////////////////////////////////////////////////////// // Wires/Reg declarations //////////////////////////////////////////////////////////////////////////////// reg [LP_LOG_FIFO_DEPTH-1:0] fifo_index; wire [4-1:0] fifo_addr; wire push; wire pop ; reg areset_r1; //////////////////////////////////////////////////////////////////////////////// // BEGIN RTL //////////////////////////////////////////////////////////////////////////////// always @(posedge aclk) begin areset_r1 <= ~aresetn; end always @(posedge aclk) begin if (~aresetn) begin fifo_index <= {LP_LOG_FIFO_DEPTH{1'b1}}; end else begin fifo_index <= push & ~pop ? fifo_index + 1'b1 : ~push & pop ? fifo_index - 1'b1 : fifo_index; end end assign push = s_valid & s_ready; always @(posedge aclk) begin if (~aresetn) begin s_ready <= 1'b0; end else begin s_ready <= areset_r1 ? 1'b1 : push & ~pop && (fifo_index == (C_FIFO_DEPTH - 2'd2)) ? 1'b0 : ~push & pop ? 1'b1 : s_ready; end end assign pop = m_valid & m_ready; always @(posedge aclk) begin if (~aresetn) begin m_valid <= 1'b0; end else begin m_valid <= ~push & pop && (fifo_index == {LP_LOG_FIFO_DEPTH{1'b0}}) ? 1'b0 : push & ~pop ? 1'b1 : m_valid; end end generate if (LP_LOG_FIFO_DEPTH < 4) begin : gen_pad_fifo_addr assign fifo_addr[0+:LP_LOG_FIFO_DEPTH] = fifo_index[LP_LOG_FIFO_DEPTH-1:0]; assign fifo_addr[LP_LOG_FIFO_DEPTH+:(4-LP_LOG_FIFO_DEPTH)] = {4-LP_LOG_FIFO_DEPTH{1'b0}}; end else begin : gen_fifo_addr assign fifo_addr[LP_LOG_FIFO_DEPTH-1:0] = fifo_index[LP_LOG_FIFO_DEPTH-1:0]; end endgenerate generate genvar i; for (i = 0; i < C_PAYLOAD_WIDTH; i = i + 1) begin : gen_data_bit SRL16E u_srl_fifo( .Q ( m_payload[i] ) , .A0 ( fifo_addr[0] ) , .A1 ( fifo_addr[1] ) , .A2 ( fifo_addr[2] ) , .A3 ( fifo_addr[3] ) , .CE ( push ) , .CLK ( aclk ) , .D ( s_payload[i] ) ); end endgenerate endmodule `default_nettype wire
// (c) Copyright 2012-2013 Xilinx, Inc. All rights reserved. // // This file contains confidential and proprietary information // of Xilinx, Inc. and is protected under U.S. and // international copyright and other intellectual property // laws. // // DISCLAIMER // This disclaimer is not a license and does not grant any // rights to the materials distributed herewith. Except as // otherwise provided in a valid license issued to you by // Xilinx, and to the maximum extent permitted by applicable // law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND // WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES // AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING // BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- // INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and // (2) Xilinx shall not be liable (whether in contract or tort, // including negligence, or under any other theory of // liability) for any loss or damage of any kind or nature // related to, arising under or in connection with these // materials, including for any direct, or any indirect, // special, incidental, or consequential loss or damage // (including loss of data, profits, goodwill, or any type of // loss or damage suffered as a result of any action brought // by a third party) even if such damage or loss was // reasonably foreseeable or Xilinx had been advised of the // possibility of the same. // // CRITICAL APPLICATIONS // Xilinx products are not designed or intended to be fail- // safe, or for use in any application requiring fail-safe // performance, such as life-support or safety devices or // systems, Class III medical devices, nuclear facilities, // applications related to the deployment of airbags, or any // other applications that could lead to death, personal // injury, or severe property or environmental damage // (individually and collectively, "Critical // Applications"). Customer assumes the sole risk and // liability of any use of Xilinx products in Critical // Applications, subject only to applicable laws and // regulations governing limitations on product liability. // // THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS // PART OF THIS FILE AT ALL TIMES. //----------------------------------------------------------------------------- // Description: SRL based FIFO for AXIS/AXI Channels. //-------------------------------------------------------------------------- `timescale 1ps/1ps `default_nettype none (* DowngradeIPIdentifiedWarnings="yes" *) module axi_infrastructure_v1_1_axic_srl_fifo #( /////////////////////////////////////////////////////////////////////////////// // Parameter Definitions /////////////////////////////////////////////////////////////////////////////// parameter C_FAMILY = "virtex7", parameter integer C_PAYLOAD_WIDTH = 1, parameter integer C_FIFO_DEPTH = 16 // Range: 4-16. ) ( /////////////////////////////////////////////////////////////////////////////// // Port Declarations /////////////////////////////////////////////////////////////////////////////// input wire aclk, // Clock input wire aresetn, // Reset input wire [C_PAYLOAD_WIDTH-1:0] s_payload, // Input data input wire s_valid, // Input data valid output reg s_ready, // Input data ready output wire [C_PAYLOAD_WIDTH-1:0] m_payload, // Output data output reg m_valid, // Output data valid input wire m_ready // Output data ready ); //////////////////////////////////////////////////////////////////////////////// // Functions //////////////////////////////////////////////////////////////////////////////// // ceiling logb2 function integer f_clogb2 (input integer size); integer s; begin s = size; s = s - 1; for (f_clogb2=1; s>1; f_clogb2=f_clogb2+1) s = s >> 1; end endfunction // clogb2 //////////////////////////////////////////////////////////////////////////////// // Local parameters //////////////////////////////////////////////////////////////////////////////// localparam integer LP_LOG_FIFO_DEPTH = f_clogb2(C_FIFO_DEPTH); //////////////////////////////////////////////////////////////////////////////// // Wires/Reg declarations //////////////////////////////////////////////////////////////////////////////// reg [LP_LOG_FIFO_DEPTH-1:0] fifo_index; wire [4-1:0] fifo_addr; wire push; wire pop ; reg areset_r1; //////////////////////////////////////////////////////////////////////////////// // BEGIN RTL //////////////////////////////////////////////////////////////////////////////// always @(posedge aclk) begin areset_r1 <= ~aresetn; end always @(posedge aclk) begin if (~aresetn) begin fifo_index <= {LP_LOG_FIFO_DEPTH{1'b1}}; end else begin fifo_index <= push & ~pop ? fifo_index + 1'b1 : ~push & pop ? fifo_index - 1'b1 : fifo_index; end end assign push = s_valid & s_ready; always @(posedge aclk) begin if (~aresetn) begin s_ready <= 1'b0; end else begin s_ready <= areset_r1 ? 1'b1 : push & ~pop && (fifo_index == (C_FIFO_DEPTH - 2'd2)) ? 1'b0 : ~push & pop ? 1'b1 : s_ready; end end assign pop = m_valid & m_ready; always @(posedge aclk) begin if (~aresetn) begin m_valid <= 1'b0; end else begin m_valid <= ~push & pop && (fifo_index == {LP_LOG_FIFO_DEPTH{1'b0}}) ? 1'b0 : push & ~pop ? 1'b1 : m_valid; end end generate if (LP_LOG_FIFO_DEPTH < 4) begin : gen_pad_fifo_addr assign fifo_addr[0+:LP_LOG_FIFO_DEPTH] = fifo_index[LP_LOG_FIFO_DEPTH-1:0]; assign fifo_addr[LP_LOG_FIFO_DEPTH+:(4-LP_LOG_FIFO_DEPTH)] = {4-LP_LOG_FIFO_DEPTH{1'b0}}; end else begin : gen_fifo_addr assign fifo_addr[LP_LOG_FIFO_DEPTH-1:0] = fifo_index[LP_LOG_FIFO_DEPTH-1:0]; end endgenerate generate genvar i; for (i = 0; i < C_PAYLOAD_WIDTH; i = i + 1) begin : gen_data_bit SRL16E u_srl_fifo( .Q ( m_payload[i] ) , .A0 ( fifo_addr[0] ) , .A1 ( fifo_addr[1] ) , .A2 ( fifo_addr[2] ) , .A3 ( fifo_addr[3] ) , .CE ( push ) , .CLK ( aclk ) , .D ( s_payload[i] ) ); end endgenerate endmodule `default_nettype wire
// (c) Copyright 2012-2013 Xilinx, Inc. All rights reserved. // // This file contains confidential and proprietary information // of Xilinx, Inc. and is protected under U.S. and // international copyright and other intellectual property // laws. // // DISCLAIMER // This disclaimer is not a license and does not grant any // rights to the materials distributed herewith. Except as // otherwise provided in a valid license issued to you by // Xilinx, and to the maximum extent permitted by applicable // law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND // WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES // AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING // BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- // INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and // (2) Xilinx shall not be liable (whether in contract or tort, // including negligence, or under any other theory of // liability) for any loss or damage of any kind or nature // related to, arising under or in connection with these // materials, including for any direct, or any indirect, // special, incidental, or consequential loss or damage // (including loss of data, profits, goodwill, or any type of // loss or damage suffered as a result of any action brought // by a third party) even if such damage or loss was // reasonably foreseeable or Xilinx had been advised of the // possibility of the same. // // CRITICAL APPLICATIONS // Xilinx products are not designed or intended to be fail- // safe, or for use in any application requiring fail-safe // performance, such as life-support or safety devices or // systems, Class III medical devices, nuclear facilities, // applications related to the deployment of airbags, or any // other applications that could lead to death, personal // injury, or severe property or environmental damage // (individually and collectively, "Critical // Applications"). Customer assumes the sole risk and // liability of any use of Xilinx products in Critical // Applications, subject only to applicable laws and // regulations governing limitations on product liability. // // THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS // PART OF THIS FILE AT ALL TIMES. //----------------------------------------------------------------------------- // Description: SRL based FIFO for AXIS/AXI Channels. //-------------------------------------------------------------------------- `timescale 1ps/1ps `default_nettype none (* DowngradeIPIdentifiedWarnings="yes" *) module axi_infrastructure_v1_1_axic_srl_fifo #( /////////////////////////////////////////////////////////////////////////////// // Parameter Definitions /////////////////////////////////////////////////////////////////////////////// parameter C_FAMILY = "virtex7", parameter integer C_PAYLOAD_WIDTH = 1, parameter integer C_FIFO_DEPTH = 16 // Range: 4-16. ) ( /////////////////////////////////////////////////////////////////////////////// // Port Declarations /////////////////////////////////////////////////////////////////////////////// input wire aclk, // Clock input wire aresetn, // Reset input wire [C_PAYLOAD_WIDTH-1:0] s_payload, // Input data input wire s_valid, // Input data valid output reg s_ready, // Input data ready output wire [C_PAYLOAD_WIDTH-1:0] m_payload, // Output data output reg m_valid, // Output data valid input wire m_ready // Output data ready ); //////////////////////////////////////////////////////////////////////////////// // Functions //////////////////////////////////////////////////////////////////////////////// // ceiling logb2 function integer f_clogb2 (input integer size); integer s; begin s = size; s = s - 1; for (f_clogb2=1; s>1; f_clogb2=f_clogb2+1) s = s >> 1; end endfunction // clogb2 //////////////////////////////////////////////////////////////////////////////// // Local parameters //////////////////////////////////////////////////////////////////////////////// localparam integer LP_LOG_FIFO_DEPTH = f_clogb2(C_FIFO_DEPTH); //////////////////////////////////////////////////////////////////////////////// // Wires/Reg declarations //////////////////////////////////////////////////////////////////////////////// reg [LP_LOG_FIFO_DEPTH-1:0] fifo_index; wire [4-1:0] fifo_addr; wire push; wire pop ; reg areset_r1; //////////////////////////////////////////////////////////////////////////////// // BEGIN RTL //////////////////////////////////////////////////////////////////////////////// always @(posedge aclk) begin areset_r1 <= ~aresetn; end always @(posedge aclk) begin if (~aresetn) begin fifo_index <= {LP_LOG_FIFO_DEPTH{1'b1}}; end else begin fifo_index <= push & ~pop ? fifo_index + 1'b1 : ~push & pop ? fifo_index - 1'b1 : fifo_index; end end assign push = s_valid & s_ready; always @(posedge aclk) begin if (~aresetn) begin s_ready <= 1'b0; end else begin s_ready <= areset_r1 ? 1'b1 : push & ~pop && (fifo_index == (C_FIFO_DEPTH - 2'd2)) ? 1'b0 : ~push & pop ? 1'b1 : s_ready; end end assign pop = m_valid & m_ready; always @(posedge aclk) begin if (~aresetn) begin m_valid <= 1'b0; end else begin m_valid <= ~push & pop && (fifo_index == {LP_LOG_FIFO_DEPTH{1'b0}}) ? 1'b0 : push & ~pop ? 1'b1 : m_valid; end end generate if (LP_LOG_FIFO_DEPTH < 4) begin : gen_pad_fifo_addr assign fifo_addr[0+:LP_LOG_FIFO_DEPTH] = fifo_index[LP_LOG_FIFO_DEPTH-1:0]; assign fifo_addr[LP_LOG_FIFO_DEPTH+:(4-LP_LOG_FIFO_DEPTH)] = {4-LP_LOG_FIFO_DEPTH{1'b0}}; end else begin : gen_fifo_addr assign fifo_addr[LP_LOG_FIFO_DEPTH-1:0] = fifo_index[LP_LOG_FIFO_DEPTH-1:0]; end endgenerate generate genvar i; for (i = 0; i < C_PAYLOAD_WIDTH; i = i + 1) begin : gen_data_bit SRL16E u_srl_fifo( .Q ( m_payload[i] ) , .A0 ( fifo_addr[0] ) , .A1 ( fifo_addr[1] ) , .A2 ( fifo_addr[2] ) , .A3 ( fifo_addr[3] ) , .CE ( push ) , .CLK ( aclk ) , .D ( s_payload[i] ) ); end endgenerate endmodule `default_nettype wire
// (c) Copyright 2012-2013 Xilinx, Inc. All rights reserved. // // This file contains confidential and proprietary information // of Xilinx, Inc. and is protected under U.S. and // international copyright and other intellectual property // laws. // // DISCLAIMER // This disclaimer is not a license and does not grant any // rights to the materials distributed herewith. Except as // otherwise provided in a valid license issued to you by // Xilinx, and to the maximum extent permitted by applicable // law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND // WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES // AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING // BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- // INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and // (2) Xilinx shall not be liable (whether in contract or tort, // including negligence, or under any other theory of // liability) for any loss or damage of any kind or nature // related to, arising under or in connection with these // materials, including for any direct, or any indirect, // special, incidental, or consequential loss or damage // (including loss of data, profits, goodwill, or any type of // loss or damage suffered as a result of any action brought // by a third party) even if such damage or loss was // reasonably foreseeable or Xilinx had been advised of the // possibility of the same. // // CRITICAL APPLICATIONS // Xilinx products are not designed or intended to be fail- // safe, or for use in any application requiring fail-safe // performance, such as life-support or safety devices or // systems, Class III medical devices, nuclear facilities, // applications related to the deployment of airbags, or any // other applications that could lead to death, personal // injury, or severe property or environmental damage // (individually and collectively, "Critical // Applications"). Customer assumes the sole risk and // liability of any use of Xilinx products in Critical // Applications, subject only to applicable laws and // regulations governing limitations on product liability. // // THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS // PART OF THIS FILE AT ALL TIMES. //----------------------------------------------------------------------------- // Description: SRL based FIFO for AXIS/AXI Channels. //-------------------------------------------------------------------------- `timescale 1ps/1ps `default_nettype none (* DowngradeIPIdentifiedWarnings="yes" *) module axi_infrastructure_v1_1_axic_srl_fifo #( /////////////////////////////////////////////////////////////////////////////// // Parameter Definitions /////////////////////////////////////////////////////////////////////////////// parameter C_FAMILY = "virtex7", parameter integer C_PAYLOAD_WIDTH = 1, parameter integer C_FIFO_DEPTH = 16 // Range: 4-16. ) ( /////////////////////////////////////////////////////////////////////////////// // Port Declarations /////////////////////////////////////////////////////////////////////////////// input wire aclk, // Clock input wire aresetn, // Reset input wire [C_PAYLOAD_WIDTH-1:0] s_payload, // Input data input wire s_valid, // Input data valid output reg s_ready, // Input data ready output wire [C_PAYLOAD_WIDTH-1:0] m_payload, // Output data output reg m_valid, // Output data valid input wire m_ready // Output data ready ); //////////////////////////////////////////////////////////////////////////////// // Functions //////////////////////////////////////////////////////////////////////////////// // ceiling logb2 function integer f_clogb2 (input integer size); integer s; begin s = size; s = s - 1; for (f_clogb2=1; s>1; f_clogb2=f_clogb2+1) s = s >> 1; end endfunction // clogb2 //////////////////////////////////////////////////////////////////////////////// // Local parameters //////////////////////////////////////////////////////////////////////////////// localparam integer LP_LOG_FIFO_DEPTH = f_clogb2(C_FIFO_DEPTH); //////////////////////////////////////////////////////////////////////////////// // Wires/Reg declarations //////////////////////////////////////////////////////////////////////////////// reg [LP_LOG_FIFO_DEPTH-1:0] fifo_index; wire [4-1:0] fifo_addr; wire push; wire pop ; reg areset_r1; //////////////////////////////////////////////////////////////////////////////// // BEGIN RTL //////////////////////////////////////////////////////////////////////////////// always @(posedge aclk) begin areset_r1 <= ~aresetn; end always @(posedge aclk) begin if (~aresetn) begin fifo_index <= {LP_LOG_FIFO_DEPTH{1'b1}}; end else begin fifo_index <= push & ~pop ? fifo_index + 1'b1 : ~push & pop ? fifo_index - 1'b1 : fifo_index; end end assign push = s_valid & s_ready; always @(posedge aclk) begin if (~aresetn) begin s_ready <= 1'b0; end else begin s_ready <= areset_r1 ? 1'b1 : push & ~pop && (fifo_index == (C_FIFO_DEPTH - 2'd2)) ? 1'b0 : ~push & pop ? 1'b1 : s_ready; end end assign pop = m_valid & m_ready; always @(posedge aclk) begin if (~aresetn) begin m_valid <= 1'b0; end else begin m_valid <= ~push & pop && (fifo_index == {LP_LOG_FIFO_DEPTH{1'b0}}) ? 1'b0 : push & ~pop ? 1'b1 : m_valid; end end generate if (LP_LOG_FIFO_DEPTH < 4) begin : gen_pad_fifo_addr assign fifo_addr[0+:LP_LOG_FIFO_DEPTH] = fifo_index[LP_LOG_FIFO_DEPTH-1:0]; assign fifo_addr[LP_LOG_FIFO_DEPTH+:(4-LP_LOG_FIFO_DEPTH)] = {4-LP_LOG_FIFO_DEPTH{1'b0}}; end else begin : gen_fifo_addr assign fifo_addr[LP_LOG_FIFO_DEPTH-1:0] = fifo_index[LP_LOG_FIFO_DEPTH-1:0]; end endgenerate generate genvar i; for (i = 0; i < C_PAYLOAD_WIDTH; i = i + 1) begin : gen_data_bit SRL16E u_srl_fifo( .Q ( m_payload[i] ) , .A0 ( fifo_addr[0] ) , .A1 ( fifo_addr[1] ) , .A2 ( fifo_addr[2] ) , .A3 ( fifo_addr[3] ) , .CE ( push ) , .CLK ( aclk ) , .D ( s_payload[i] ) ); end endgenerate endmodule `default_nettype wire
// (c) Copyright 2012-2013 Xilinx, Inc. All rights reserved. // // This file contains confidential and proprietary information // of Xilinx, Inc. and is protected under U.S. and // international copyright and other intellectual property // laws. // // DISCLAIMER // This disclaimer is not a license and does not grant any // rights to the materials distributed herewith. Except as // otherwise provided in a valid license issued to you by // Xilinx, and to the maximum extent permitted by applicable // law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND // WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES // AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING // BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- // INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and // (2) Xilinx shall not be liable (whether in contract or tort, // including negligence, or under any other theory of // liability) for any loss or damage of any kind or nature // related to, arising under or in connection with these // materials, including for any direct, or any indirect, // special, incidental, or consequential loss or damage // (including loss of data, profits, goodwill, or any type of // loss or damage suffered as a result of any action brought // by a third party) even if such damage or loss was // reasonably foreseeable or Xilinx had been advised of the // possibility of the same. // // CRITICAL APPLICATIONS // Xilinx products are not designed or intended to be fail- // safe, or for use in any application requiring fail-safe // performance, such as life-support or safety devices or // systems, Class III medical devices, nuclear facilities, // applications related to the deployment of airbags, or any // other applications that could lead to death, personal // injury, or severe property or environmental damage // (individually and collectively, "Critical // Applications"). Customer assumes the sole risk and // liability of any use of Xilinx products in Critical // Applications, subject only to applicable laws and // regulations governing limitations on product liability. // // THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS // PART OF THIS FILE AT ALL TIMES. //----------------------------------------------------------------------------- // Description: SRL based FIFO for AXIS/AXI Channels. //-------------------------------------------------------------------------- `timescale 1ps/1ps `default_nettype none (* DowngradeIPIdentifiedWarnings="yes" *) module axi_infrastructure_v1_1_axic_srl_fifo #( /////////////////////////////////////////////////////////////////////////////// // Parameter Definitions /////////////////////////////////////////////////////////////////////////////// parameter C_FAMILY = "virtex7", parameter integer C_PAYLOAD_WIDTH = 1, parameter integer C_FIFO_DEPTH = 16 // Range: 4-16. ) ( /////////////////////////////////////////////////////////////////////////////// // Port Declarations /////////////////////////////////////////////////////////////////////////////// input wire aclk, // Clock input wire aresetn, // Reset input wire [C_PAYLOAD_WIDTH-1:0] s_payload, // Input data input wire s_valid, // Input data valid output reg s_ready, // Input data ready output wire [C_PAYLOAD_WIDTH-1:0] m_payload, // Output data output reg m_valid, // Output data valid input wire m_ready // Output data ready ); //////////////////////////////////////////////////////////////////////////////// // Functions //////////////////////////////////////////////////////////////////////////////// // ceiling logb2 function integer f_clogb2 (input integer size); integer s; begin s = size; s = s - 1; for (f_clogb2=1; s>1; f_clogb2=f_clogb2+1) s = s >> 1; end endfunction // clogb2 //////////////////////////////////////////////////////////////////////////////// // Local parameters //////////////////////////////////////////////////////////////////////////////// localparam integer LP_LOG_FIFO_DEPTH = f_clogb2(C_FIFO_DEPTH); //////////////////////////////////////////////////////////////////////////////// // Wires/Reg declarations //////////////////////////////////////////////////////////////////////////////// reg [LP_LOG_FIFO_DEPTH-1:0] fifo_index; wire [4-1:0] fifo_addr; wire push; wire pop ; reg areset_r1; //////////////////////////////////////////////////////////////////////////////// // BEGIN RTL //////////////////////////////////////////////////////////////////////////////// always @(posedge aclk) begin areset_r1 <= ~aresetn; end always @(posedge aclk) begin if (~aresetn) begin fifo_index <= {LP_LOG_FIFO_DEPTH{1'b1}}; end else begin fifo_index <= push & ~pop ? fifo_index + 1'b1 : ~push & pop ? fifo_index - 1'b1 : fifo_index; end end assign push = s_valid & s_ready; always @(posedge aclk) begin if (~aresetn) begin s_ready <= 1'b0; end else begin s_ready <= areset_r1 ? 1'b1 : push & ~pop && (fifo_index == (C_FIFO_DEPTH - 2'd2)) ? 1'b0 : ~push & pop ? 1'b1 : s_ready; end end assign pop = m_valid & m_ready; always @(posedge aclk) begin if (~aresetn) begin m_valid <= 1'b0; end else begin m_valid <= ~push & pop && (fifo_index == {LP_LOG_FIFO_DEPTH{1'b0}}) ? 1'b0 : push & ~pop ? 1'b1 : m_valid; end end generate if (LP_LOG_FIFO_DEPTH < 4) begin : gen_pad_fifo_addr assign fifo_addr[0+:LP_LOG_FIFO_DEPTH] = fifo_index[LP_LOG_FIFO_DEPTH-1:0]; assign fifo_addr[LP_LOG_FIFO_DEPTH+:(4-LP_LOG_FIFO_DEPTH)] = {4-LP_LOG_FIFO_DEPTH{1'b0}}; end else begin : gen_fifo_addr assign fifo_addr[LP_LOG_FIFO_DEPTH-1:0] = fifo_index[LP_LOG_FIFO_DEPTH-1:0]; end endgenerate generate genvar i; for (i = 0; i < C_PAYLOAD_WIDTH; i = i + 1) begin : gen_data_bit SRL16E u_srl_fifo( .Q ( m_payload[i] ) , .A0 ( fifo_addr[0] ) , .A1 ( fifo_addr[1] ) , .A2 ( fifo_addr[2] ) , .A3 ( fifo_addr[3] ) , .CE ( push ) , .CLK ( aclk ) , .D ( s_payload[i] ) ); end endgenerate endmodule `default_nettype wire
// (c) Copyright 2012-2013 Xilinx, Inc. All rights reserved. // // This file contains confidential and proprietary information // of Xilinx, Inc. and is protected under U.S. and // international copyright and other intellectual property // laws. // // DISCLAIMER // This disclaimer is not a license and does not grant any // rights to the materials distributed herewith. Except as // otherwise provided in a valid license issued to you by // Xilinx, and to the maximum extent permitted by applicable // law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND // WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES // AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING // BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- // INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and // (2) Xilinx shall not be liable (whether in contract or tort, // including negligence, or under any other theory of // liability) for any loss or damage of any kind or nature // related to, arising under or in connection with these // materials, including for any direct, or any indirect, // special, incidental, or consequential loss or damage // (including loss of data, profits, goodwill, or any type of // loss or damage suffered as a result of any action brought // by a third party) even if such damage or loss was // reasonably foreseeable or Xilinx had been advised of the // possibility of the same. // // CRITICAL APPLICATIONS // Xilinx products are not designed or intended to be fail- // safe, or for use in any application requiring fail-safe // performance, such as life-support or safety devices or // systems, Class III medical devices, nuclear facilities, // applications related to the deployment of airbags, or any // other applications that could lead to death, personal // injury, or severe property or environmental damage // (individually and collectively, "Critical // Applications"). Customer assumes the sole risk and // liability of any use of Xilinx products in Critical // Applications, subject only to applicable laws and // regulations governing limitations on product liability. // // THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS // PART OF THIS FILE AT ALL TIMES. //----------------------------------------------------------------------------- // Description: SRL based FIFO for AXIS/AXI Channels. //-------------------------------------------------------------------------- `timescale 1ps/1ps `default_nettype none (* DowngradeIPIdentifiedWarnings="yes" *) module axi_infrastructure_v1_1_axic_srl_fifo #( /////////////////////////////////////////////////////////////////////////////// // Parameter Definitions /////////////////////////////////////////////////////////////////////////////// parameter C_FAMILY = "virtex7", parameter integer C_PAYLOAD_WIDTH = 1, parameter integer C_FIFO_DEPTH = 16 // Range: 4-16. ) ( /////////////////////////////////////////////////////////////////////////////// // Port Declarations /////////////////////////////////////////////////////////////////////////////// input wire aclk, // Clock input wire aresetn, // Reset input wire [C_PAYLOAD_WIDTH-1:0] s_payload, // Input data input wire s_valid, // Input data valid output reg s_ready, // Input data ready output wire [C_PAYLOAD_WIDTH-1:0] m_payload, // Output data output reg m_valid, // Output data valid input wire m_ready // Output data ready ); //////////////////////////////////////////////////////////////////////////////// // Functions //////////////////////////////////////////////////////////////////////////////// // ceiling logb2 function integer f_clogb2 (input integer size); integer s; begin s = size; s = s - 1; for (f_clogb2=1; s>1; f_clogb2=f_clogb2+1) s = s >> 1; end endfunction // clogb2 //////////////////////////////////////////////////////////////////////////////// // Local parameters //////////////////////////////////////////////////////////////////////////////// localparam integer LP_LOG_FIFO_DEPTH = f_clogb2(C_FIFO_DEPTH); //////////////////////////////////////////////////////////////////////////////// // Wires/Reg declarations //////////////////////////////////////////////////////////////////////////////// reg [LP_LOG_FIFO_DEPTH-1:0] fifo_index; wire [4-1:0] fifo_addr; wire push; wire pop ; reg areset_r1; //////////////////////////////////////////////////////////////////////////////// // BEGIN RTL //////////////////////////////////////////////////////////////////////////////// always @(posedge aclk) begin areset_r1 <= ~aresetn; end always @(posedge aclk) begin if (~aresetn) begin fifo_index <= {LP_LOG_FIFO_DEPTH{1'b1}}; end else begin fifo_index <= push & ~pop ? fifo_index + 1'b1 : ~push & pop ? fifo_index - 1'b1 : fifo_index; end end assign push = s_valid & s_ready; always @(posedge aclk) begin if (~aresetn) begin s_ready <= 1'b0; end else begin s_ready <= areset_r1 ? 1'b1 : push & ~pop && (fifo_index == (C_FIFO_DEPTH - 2'd2)) ? 1'b0 : ~push & pop ? 1'b1 : s_ready; end end assign pop = m_valid & m_ready; always @(posedge aclk) begin if (~aresetn) begin m_valid <= 1'b0; end else begin m_valid <= ~push & pop && (fifo_index == {LP_LOG_FIFO_DEPTH{1'b0}}) ? 1'b0 : push & ~pop ? 1'b1 : m_valid; end end generate if (LP_LOG_FIFO_DEPTH < 4) begin : gen_pad_fifo_addr assign fifo_addr[0+:LP_LOG_FIFO_DEPTH] = fifo_index[LP_LOG_FIFO_DEPTH-1:0]; assign fifo_addr[LP_LOG_FIFO_DEPTH+:(4-LP_LOG_FIFO_DEPTH)] = {4-LP_LOG_FIFO_DEPTH{1'b0}}; end else begin : gen_fifo_addr assign fifo_addr[LP_LOG_FIFO_DEPTH-1:0] = fifo_index[LP_LOG_FIFO_DEPTH-1:0]; end endgenerate generate genvar i; for (i = 0; i < C_PAYLOAD_WIDTH; i = i + 1) begin : gen_data_bit SRL16E u_srl_fifo( .Q ( m_payload[i] ) , .A0 ( fifo_addr[0] ) , .A1 ( fifo_addr[1] ) , .A2 ( fifo_addr[2] ) , .A3 ( fifo_addr[3] ) , .CE ( push ) , .CLK ( aclk ) , .D ( s_payload[i] ) ); end endgenerate endmodule `default_nettype wire
// (c) Copyright 2012-2013 Xilinx, Inc. All rights reserved. // // This file contains confidential and proprietary information // of Xilinx, Inc. and is protected under U.S. and // international copyright and other intellectual property // laws. // // DISCLAIMER // This disclaimer is not a license and does not grant any // rights to the materials distributed herewith. Except as // otherwise provided in a valid license issued to you by // Xilinx, and to the maximum extent permitted by applicable // law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND // WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES // AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING // BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- // INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and // (2) Xilinx shall not be liable (whether in contract or tort, // including negligence, or under any other theory of // liability) for any loss or damage of any kind or nature // related to, arising under or in connection with these // materials, including for any direct, or any indirect, // special, incidental, or consequential loss or damage // (including loss of data, profits, goodwill, or any type of // loss or damage suffered as a result of any action brought // by a third party) even if such damage or loss was // reasonably foreseeable or Xilinx had been advised of the // possibility of the same. // // CRITICAL APPLICATIONS // Xilinx products are not designed or intended to be fail- // safe, or for use in any application requiring fail-safe // performance, such as life-support or safety devices or // systems, Class III medical devices, nuclear facilities, // applications related to the deployment of airbags, or any // other applications that could lead to death, personal // injury, or severe property or environmental damage // (individually and collectively, "Critical // Applications"). Customer assumes the sole risk and // liability of any use of Xilinx products in Critical // Applications, subject only to applicable laws and // regulations governing limitations on product liability. // // THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS // PART OF THIS FILE AT ALL TIMES. //----------------------------------------------------------------------------- // Description: SRL based FIFO for AXIS/AXI Channels. //-------------------------------------------------------------------------- `timescale 1ps/1ps `default_nettype none (* DowngradeIPIdentifiedWarnings="yes" *) module axi_infrastructure_v1_1_axic_srl_fifo #( /////////////////////////////////////////////////////////////////////////////// // Parameter Definitions /////////////////////////////////////////////////////////////////////////////// parameter C_FAMILY = "virtex7", parameter integer C_PAYLOAD_WIDTH = 1, parameter integer C_FIFO_DEPTH = 16 // Range: 4-16. ) ( /////////////////////////////////////////////////////////////////////////////// // Port Declarations /////////////////////////////////////////////////////////////////////////////// input wire aclk, // Clock input wire aresetn, // Reset input wire [C_PAYLOAD_WIDTH-1:0] s_payload, // Input data input wire s_valid, // Input data valid output reg s_ready, // Input data ready output wire [C_PAYLOAD_WIDTH-1:0] m_payload, // Output data output reg m_valid, // Output data valid input wire m_ready // Output data ready ); //////////////////////////////////////////////////////////////////////////////// // Functions //////////////////////////////////////////////////////////////////////////////// // ceiling logb2 function integer f_clogb2 (input integer size); integer s; begin s = size; s = s - 1; for (f_clogb2=1; s>1; f_clogb2=f_clogb2+1) s = s >> 1; end endfunction // clogb2 //////////////////////////////////////////////////////////////////////////////// // Local parameters //////////////////////////////////////////////////////////////////////////////// localparam integer LP_LOG_FIFO_DEPTH = f_clogb2(C_FIFO_DEPTH); //////////////////////////////////////////////////////////////////////////////// // Wires/Reg declarations //////////////////////////////////////////////////////////////////////////////// reg [LP_LOG_FIFO_DEPTH-1:0] fifo_index; wire [4-1:0] fifo_addr; wire push; wire pop ; reg areset_r1; //////////////////////////////////////////////////////////////////////////////// // BEGIN RTL //////////////////////////////////////////////////////////////////////////////// always @(posedge aclk) begin areset_r1 <= ~aresetn; end always @(posedge aclk) begin if (~aresetn) begin fifo_index <= {LP_LOG_FIFO_DEPTH{1'b1}}; end else begin fifo_index <= push & ~pop ? fifo_index + 1'b1 : ~push & pop ? fifo_index - 1'b1 : fifo_index; end end assign push = s_valid & s_ready; always @(posedge aclk) begin if (~aresetn) begin s_ready <= 1'b0; end else begin s_ready <= areset_r1 ? 1'b1 : push & ~pop && (fifo_index == (C_FIFO_DEPTH - 2'd2)) ? 1'b0 : ~push & pop ? 1'b1 : s_ready; end end assign pop = m_valid & m_ready; always @(posedge aclk) begin if (~aresetn) begin m_valid <= 1'b0; end else begin m_valid <= ~push & pop && (fifo_index == {LP_LOG_FIFO_DEPTH{1'b0}}) ? 1'b0 : push & ~pop ? 1'b1 : m_valid; end end generate if (LP_LOG_FIFO_DEPTH < 4) begin : gen_pad_fifo_addr assign fifo_addr[0+:LP_LOG_FIFO_DEPTH] = fifo_index[LP_LOG_FIFO_DEPTH-1:0]; assign fifo_addr[LP_LOG_FIFO_DEPTH+:(4-LP_LOG_FIFO_DEPTH)] = {4-LP_LOG_FIFO_DEPTH{1'b0}}; end else begin : gen_fifo_addr assign fifo_addr[LP_LOG_FIFO_DEPTH-1:0] = fifo_index[LP_LOG_FIFO_DEPTH-1:0]; end endgenerate generate genvar i; for (i = 0; i < C_PAYLOAD_WIDTH; i = i + 1) begin : gen_data_bit SRL16E u_srl_fifo( .Q ( m_payload[i] ) , .A0 ( fifo_addr[0] ) , .A1 ( fifo_addr[1] ) , .A2 ( fifo_addr[2] ) , .A3 ( fifo_addr[3] ) , .CE ( push ) , .CLK ( aclk ) , .D ( s_payload[i] ) ); end endgenerate endmodule `default_nettype wire
// (c) Copyright 2012-2013 Xilinx, Inc. All rights reserved. // // This file contains confidential and proprietary information // of Xilinx, Inc. and is protected under U.S. and // international copyright and other intellectual property // laws. // // DISCLAIMER // This disclaimer is not a license and does not grant any // rights to the materials distributed herewith. Except as // otherwise provided in a valid license issued to you by // Xilinx, and to the maximum extent permitted by applicable // law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND // WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES // AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING // BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- // INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and // (2) Xilinx shall not be liable (whether in contract or tort, // including negligence, or under any other theory of // liability) for any loss or damage of any kind or nature // related to, arising under or in connection with these // materials, including for any direct, or any indirect, // special, incidental, or consequential loss or damage // (including loss of data, profits, goodwill, or any type of // loss or damage suffered as a result of any action brought // by a third party) even if such damage or loss was // reasonably foreseeable or Xilinx had been advised of the // possibility of the same. // // CRITICAL APPLICATIONS // Xilinx products are not designed or intended to be fail- // safe, or for use in any application requiring fail-safe // performance, such as life-support or safety devices or // systems, Class III medical devices, nuclear facilities, // applications related to the deployment of airbags, or any // other applications that could lead to death, personal // injury, or severe property or environmental damage // (individually and collectively, "Critical // Applications"). Customer assumes the sole risk and // liability of any use of Xilinx products in Critical // Applications, subject only to applicable laws and // regulations governing limitations on product liability. // // THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS // PART OF THIS FILE AT ALL TIMES. //----------------------------------------------------------------------------- // Description: SRL based FIFO for AXIS/AXI Channels. //-------------------------------------------------------------------------- `timescale 1ps/1ps `default_nettype none (* DowngradeIPIdentifiedWarnings="yes" *) module axi_infrastructure_v1_1_axic_srl_fifo #( /////////////////////////////////////////////////////////////////////////////// // Parameter Definitions /////////////////////////////////////////////////////////////////////////////// parameter C_FAMILY = "virtex7", parameter integer C_PAYLOAD_WIDTH = 1, parameter integer C_FIFO_DEPTH = 16 // Range: 4-16. ) ( /////////////////////////////////////////////////////////////////////////////// // Port Declarations /////////////////////////////////////////////////////////////////////////////// input wire aclk, // Clock input wire aresetn, // Reset input wire [C_PAYLOAD_WIDTH-1:0] s_payload, // Input data input wire s_valid, // Input data valid output reg s_ready, // Input data ready output wire [C_PAYLOAD_WIDTH-1:0] m_payload, // Output data output reg m_valid, // Output data valid input wire m_ready // Output data ready ); //////////////////////////////////////////////////////////////////////////////// // Functions //////////////////////////////////////////////////////////////////////////////// // ceiling logb2 function integer f_clogb2 (input integer size); integer s; begin s = size; s = s - 1; for (f_clogb2=1; s>1; f_clogb2=f_clogb2+1) s = s >> 1; end endfunction // clogb2 //////////////////////////////////////////////////////////////////////////////// // Local parameters //////////////////////////////////////////////////////////////////////////////// localparam integer LP_LOG_FIFO_DEPTH = f_clogb2(C_FIFO_DEPTH); //////////////////////////////////////////////////////////////////////////////// // Wires/Reg declarations //////////////////////////////////////////////////////////////////////////////// reg [LP_LOG_FIFO_DEPTH-1:0] fifo_index; wire [4-1:0] fifo_addr; wire push; wire pop ; reg areset_r1; //////////////////////////////////////////////////////////////////////////////// // BEGIN RTL //////////////////////////////////////////////////////////////////////////////// always @(posedge aclk) begin areset_r1 <= ~aresetn; end always @(posedge aclk) begin if (~aresetn) begin fifo_index <= {LP_LOG_FIFO_DEPTH{1'b1}}; end else begin fifo_index <= push & ~pop ? fifo_index + 1'b1 : ~push & pop ? fifo_index - 1'b1 : fifo_index; end end assign push = s_valid & s_ready; always @(posedge aclk) begin if (~aresetn) begin s_ready <= 1'b0; end else begin s_ready <= areset_r1 ? 1'b1 : push & ~pop && (fifo_index == (C_FIFO_DEPTH - 2'd2)) ? 1'b0 : ~push & pop ? 1'b1 : s_ready; end end assign pop = m_valid & m_ready; always @(posedge aclk) begin if (~aresetn) begin m_valid <= 1'b0; end else begin m_valid <= ~push & pop && (fifo_index == {LP_LOG_FIFO_DEPTH{1'b0}}) ? 1'b0 : push & ~pop ? 1'b1 : m_valid; end end generate if (LP_LOG_FIFO_DEPTH < 4) begin : gen_pad_fifo_addr assign fifo_addr[0+:LP_LOG_FIFO_DEPTH] = fifo_index[LP_LOG_FIFO_DEPTH-1:0]; assign fifo_addr[LP_LOG_FIFO_DEPTH+:(4-LP_LOG_FIFO_DEPTH)] = {4-LP_LOG_FIFO_DEPTH{1'b0}}; end else begin : gen_fifo_addr assign fifo_addr[LP_LOG_FIFO_DEPTH-1:0] = fifo_index[LP_LOG_FIFO_DEPTH-1:0]; end endgenerate generate genvar i; for (i = 0; i < C_PAYLOAD_WIDTH; i = i + 1) begin : gen_data_bit SRL16E u_srl_fifo( .Q ( m_payload[i] ) , .A0 ( fifo_addr[0] ) , .A1 ( fifo_addr[1] ) , .A2 ( fifo_addr[2] ) , .A3 ( fifo_addr[3] ) , .CE ( push ) , .CLK ( aclk ) , .D ( s_payload[i] ) ); end endgenerate endmodule `default_nettype wire
`include "hi_read_tx.v" /* pck0 - input main 24Mhz clock (PLL / 4) [7:0] adc_d - input data from A/D converter shallow_modulation - modulation type pwr_lo - output to coil drivers (ssp_clk / 8) adc_clk - output A/D clock signal ssp_frame - output SSS frame indicator (goes high while the 8 bits are shifted) ssp_din - output SSP data to ARM (shifts 8 bit A/D value serially to ARM MSB first) ssp_clk - output SSP clock signal ck_1356meg - input unused ck_1356megb - input unused ssp_dout - input unused cross_hi - input unused cross_lo - input unused pwr_hi - output unused, tied low pwr_oe1 - output unused, undefined pwr_oe2 - output unused, undefined pwr_oe3 - output unused, undefined pwr_oe4 - output unused, undefined dbg - output alias for adc_clk */ module testbed_hi_read_tx; reg pck0; reg [7:0] adc_d; reg shallow_modulation; wire pwr_lo; wire adc_clk; reg ck_1356meg; reg ck_1356megb; wire ssp_frame; wire ssp_din; wire ssp_clk; reg ssp_dout; wire pwr_hi; wire pwr_oe1; wire pwr_oe2; wire pwr_oe3; wire pwr_oe4; wire cross_lo; wire cross_hi; wire dbg; hi_read_tx #(5,200) dut( .pck0(pck0), .ck_1356meg(ck_1356meg), .ck_1356megb(ck_1356megb), .pwr_lo(pwr_lo), .pwr_hi(pwr_hi), .pwr_oe1(pwr_oe1), .pwr_oe2(pwr_oe2), .pwr_oe3(pwr_oe3), .pwr_oe4(pwr_oe4), .adc_d(adc_d), .adc_clk(adc_clk), .ssp_frame(ssp_frame), .ssp_din(ssp_din), .ssp_dout(ssp_dout), .ssp_clk(ssp_clk), .cross_hi(cross_hi), .cross_lo(cross_lo), .dbg(dbg), .shallow_modulation(shallow_modulation) ); integer idx, i; // main clock always #5 begin ck_1356megb = !ck_1356megb; ck_1356meg = ck_1356megb; end //crank DUT task crank_dut; begin @(posedge ssp_clk) ; ssp_dout = $random; end endtask initial begin // init inputs ck_1356megb = 0; adc_d = 0; ssp_dout=0; // shallow modulation off shallow_modulation=0; for (i = 0 ; i < 16 ; i = i + 1) begin crank_dut; end // shallow modulation on shallow_modulation=1; for (i = 0 ; i < 16 ; i = i + 1) begin crank_dut; end $finish; end endmodule // main
`include "hi_read_tx.v" /* pck0 - input main 24Mhz clock (PLL / 4) [7:0] adc_d - input data from A/D converter shallow_modulation - modulation type pwr_lo - output to coil drivers (ssp_clk / 8) adc_clk - output A/D clock signal ssp_frame - output SSS frame indicator (goes high while the 8 bits are shifted) ssp_din - output SSP data to ARM (shifts 8 bit A/D value serially to ARM MSB first) ssp_clk - output SSP clock signal ck_1356meg - input unused ck_1356megb - input unused ssp_dout - input unused cross_hi - input unused cross_lo - input unused pwr_hi - output unused, tied low pwr_oe1 - output unused, undefined pwr_oe2 - output unused, undefined pwr_oe3 - output unused, undefined pwr_oe4 - output unused, undefined dbg - output alias for adc_clk */ module testbed_hi_read_tx; reg pck0; reg [7:0] adc_d; reg shallow_modulation; wire pwr_lo; wire adc_clk; reg ck_1356meg; reg ck_1356megb; wire ssp_frame; wire ssp_din; wire ssp_clk; reg ssp_dout; wire pwr_hi; wire pwr_oe1; wire pwr_oe2; wire pwr_oe3; wire pwr_oe4; wire cross_lo; wire cross_hi; wire dbg; hi_read_tx #(5,200) dut( .pck0(pck0), .ck_1356meg(ck_1356meg), .ck_1356megb(ck_1356megb), .pwr_lo(pwr_lo), .pwr_hi(pwr_hi), .pwr_oe1(pwr_oe1), .pwr_oe2(pwr_oe2), .pwr_oe3(pwr_oe3), .pwr_oe4(pwr_oe4), .adc_d(adc_d), .adc_clk(adc_clk), .ssp_frame(ssp_frame), .ssp_din(ssp_din), .ssp_dout(ssp_dout), .ssp_clk(ssp_clk), .cross_hi(cross_hi), .cross_lo(cross_lo), .dbg(dbg), .shallow_modulation(shallow_modulation) ); integer idx, i; // main clock always #5 begin ck_1356megb = !ck_1356megb; ck_1356meg = ck_1356megb; end //crank DUT task crank_dut; begin @(posedge ssp_clk) ; ssp_dout = $random; end endtask initial begin // init inputs ck_1356megb = 0; adc_d = 0; ssp_dout=0; // shallow modulation off shallow_modulation=0; for (i = 0 ; i < 16 ; i = i + 1) begin crank_dut; end // shallow modulation on shallow_modulation=1; for (i = 0 ; i < 16 ; i = i + 1) begin crank_dut; end $finish; end endmodule // main
`include "hi_read_tx.v" /* pck0 - input main 24Mhz clock (PLL / 4) [7:0] adc_d - input data from A/D converter shallow_modulation - modulation type pwr_lo - output to coil drivers (ssp_clk / 8) adc_clk - output A/D clock signal ssp_frame - output SSS frame indicator (goes high while the 8 bits are shifted) ssp_din - output SSP data to ARM (shifts 8 bit A/D value serially to ARM MSB first) ssp_clk - output SSP clock signal ck_1356meg - input unused ck_1356megb - input unused ssp_dout - input unused cross_hi - input unused cross_lo - input unused pwr_hi - output unused, tied low pwr_oe1 - output unused, undefined pwr_oe2 - output unused, undefined pwr_oe3 - output unused, undefined pwr_oe4 - output unused, undefined dbg - output alias for adc_clk */ module testbed_hi_read_tx; reg pck0; reg [7:0] adc_d; reg shallow_modulation; wire pwr_lo; wire adc_clk; reg ck_1356meg; reg ck_1356megb; wire ssp_frame; wire ssp_din; wire ssp_clk; reg ssp_dout; wire pwr_hi; wire pwr_oe1; wire pwr_oe2; wire pwr_oe3; wire pwr_oe4; wire cross_lo; wire cross_hi; wire dbg; hi_read_tx #(5,200) dut( .pck0(pck0), .ck_1356meg(ck_1356meg), .ck_1356megb(ck_1356megb), .pwr_lo(pwr_lo), .pwr_hi(pwr_hi), .pwr_oe1(pwr_oe1), .pwr_oe2(pwr_oe2), .pwr_oe3(pwr_oe3), .pwr_oe4(pwr_oe4), .adc_d(adc_d), .adc_clk(adc_clk), .ssp_frame(ssp_frame), .ssp_din(ssp_din), .ssp_dout(ssp_dout), .ssp_clk(ssp_clk), .cross_hi(cross_hi), .cross_lo(cross_lo), .dbg(dbg), .shallow_modulation(shallow_modulation) ); integer idx, i; // main clock always #5 begin ck_1356megb = !ck_1356megb; ck_1356meg = ck_1356megb; end //crank DUT task crank_dut; begin @(posedge ssp_clk) ; ssp_dout = $random; end endtask initial begin // init inputs ck_1356megb = 0; adc_d = 0; ssp_dout=0; // shallow modulation off shallow_modulation=0; for (i = 0 ; i < 16 ; i = i + 1) begin crank_dut; end // shallow modulation on shallow_modulation=1; for (i = 0 ; i < 16 ; i = i + 1) begin crank_dut; end $finish; end endmodule // main
`timescale 1ps/1ps `default_nettype none (* DowngradeIPIdentifiedWarnings="yes" *) module axi_protocol_converter_v2_1_b2s_aw_channel # ( /////////////////////////////////////////////////////////////////////////////// // Parameter Definitions /////////////////////////////////////////////////////////////////////////////// // Width of ID signals. // Range: >= 1. parameter integer C_ID_WIDTH = 4, // Width of AxADDR // Range: 32. parameter integer C_AXI_ADDR_WIDTH = 32 ) ( /////////////////////////////////////////////////////////////////////////////// // Port Declarations /////////////////////////////////////////////////////////////////////////////// // AXI Slave Interface // Slave Interface System Signals input wire clk , input wire reset , // Slave Interface Write Address Ports input wire [C_ID_WIDTH-1:0] s_awid , input wire [C_AXI_ADDR_WIDTH-1:0] s_awaddr , input wire [7:0] s_awlen , input wire [2:0] s_awsize , input wire [1:0] s_awburst , input wire s_awvalid , output wire s_awready , output wire m_awvalid , output wire [C_AXI_ADDR_WIDTH-1:0] m_awaddr , input wire m_awready , // Connections to/from axi_protocol_converter_v2_1_b2s_b_channel module output wire b_push , output wire [C_ID_WIDTH-1:0] b_awid , output wire [7:0] b_awlen , input wire b_full ); //////////////////////////////////////////////////////////////////////////////// // Wires/Reg declarations //////////////////////////////////////////////////////////////////////////////// wire next ; wire next_pending ; wire a_push; wire incr_burst; reg [C_ID_WIDTH-1:0] s_awid_r; reg [7:0] s_awlen_r; //////////////////////////////////////////////////////////////////////////////// // BEGIN RTL //////////////////////////////////////////////////////////////////////////////// // Translate the AXI transaction to the MC transaction(s) axi_protocol_converter_v2_1_b2s_cmd_translator # ( .C_AXI_ADDR_WIDTH ( C_AXI_ADDR_WIDTH ) ) cmd_translator_0 ( .clk ( clk ) , .reset ( reset ) , .s_axaddr ( s_awaddr ) , .s_axlen ( s_awlen ) , .s_axsize ( s_awsize ) , .s_axburst ( s_awburst ) , .s_axhandshake ( s_awvalid & a_push ) , .m_axaddr ( m_awaddr ) , .incr_burst ( incr_burst ) , .next ( next ) , .next_pending ( next_pending ) ); axi_protocol_converter_v2_1_b2s_wr_cmd_fsm aw_cmd_fsm_0 ( .clk ( clk ) , .reset ( reset ) , .s_awready ( s_awready ) , .s_awvalid ( s_awvalid ) , .m_awvalid ( m_awvalid ) , .m_awready ( m_awready ) , .next ( next ) , .next_pending ( next_pending ) , .b_push ( b_push ) , .b_full ( b_full ) , .a_push ( a_push ) ); assign b_awid = s_awid_r; assign b_awlen = s_awlen_r; always @(posedge clk) begin s_awid_r <= s_awid ; s_awlen_r <= s_awlen ; end endmodule `default_nettype wire
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 03/17/2016 05:20:59 PM // Design Name: // Module Name: Priority_Codec_64 // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // // Revision: // Revision 0.01 - File Created // Additional Comments: // ////////////////////////////////////////////////////////////////////////////////// module Priority_Codec_64( input wire [54:0] Data_Dec_i, output reg [5:0] Data_Bin_o ); always @(Data_Dec_i) begin Data_Bin_o=6'b000000; if(~Data_Dec_i[54]) begin Data_Bin_o = 6'b000000;//0 end else if(~Data_Dec_i[53]) begin Data_Bin_o = 6'b000001;//1 end else if(~Data_Dec_i[52]) begin Data_Bin_o = 6'b000010;//2 end else if(~Data_Dec_i[51]) begin Data_Bin_o = 6'b000011;//3 end else if(~Data_Dec_i[50]) begin Data_Bin_o = 6'b000100;//4 end else if(~Data_Dec_i[49]) begin Data_Bin_o = 6'b000101;//5 end else if(~Data_Dec_i[48]) begin Data_Bin_o = 6'b000110;//6 end else if(~Data_Dec_i[47]) begin Data_Bin_o = 6'b000111;//7 end else if(~Data_Dec_i[46]) begin Data_Bin_o = 6'b001000;//8 end else if(~Data_Dec_i[45]) begin Data_Bin_o = 6'b001001;//9 end else if(~Data_Dec_i[44]) begin Data_Bin_o = 6'b001010;//10 end else if(~Data_Dec_i[43]) begin Data_Bin_o = 6'b001011;//11 end else if(~Data_Dec_i[42]) begin Data_Bin_o = 6'b001100;//12 end else if(~Data_Dec_i[41]) begin Data_Bin_o = 6'b001101;//13 end else if(~Data_Dec_i[40]) begin Data_Bin_o = 6'b001110;//14 end else if(~Data_Dec_i[39]) begin Data_Bin_o = 6'b001111;//15 end else if(~Data_Dec_i[38]) begin Data_Bin_o = 6'b010000;//16 end else if(~Data_Dec_i[37]) begin Data_Bin_o = 6'b010001;//17 end else if(~Data_Dec_i[36]) begin Data_Bin_o = 6'b010010;//18 end else if(~Data_Dec_i[35]) begin Data_Bin_o = 6'b010011;//19 end else if(~Data_Dec_i[34]) begin Data_Bin_o = 6'b010100;//20 end else if(~Data_Dec_i[33]) begin Data_Bin_o = 6'b010101;//21 end else if(~Data_Dec_i[32]) begin Data_Bin_o = 6'b010110;//22 end else if(~Data_Dec_i[31]) begin Data_Bin_o = 6'b010111;//23 end else if(~Data_Dec_i[30]) begin Data_Bin_o = 6'b011000;//24 end else if(~Data_Dec_i[29]) begin Data_Bin_o = 6'b010101;//25 end else if(~Data_Dec_i[28]) begin Data_Bin_o = 6'b010110;//26 end else if(~Data_Dec_i[27]) begin Data_Bin_o = 6'b010111;//27 end else if(~Data_Dec_i[26]) begin Data_Bin_o = 6'b011000;//28 end else if(~Data_Dec_i[25]) begin Data_Bin_o = 6'b011001;//29 end else if(~Data_Dec_i[24]) begin Data_Bin_o = 6'b011010;//30 end else if(~Data_Dec_i[23]) begin Data_Bin_o = 6'b011011;//31 end else if(~Data_Dec_i[22]) begin Data_Bin_o = 6'b011100;//32 end else if(~Data_Dec_i[21]) begin Data_Bin_o = 6'b011101;//33 end else if(~Data_Dec_i[20]) begin Data_Bin_o = 6'b011110;//34 end else if(~Data_Dec_i[19]) begin Data_Bin_o = 6'b011111;//35 end else if(~Data_Dec_i[18]) begin Data_Bin_o = 6'b100000;//36 end else if(~Data_Dec_i[17]) begin Data_Bin_o = 6'b100001;//37 end else if(~Data_Dec_i[16]) begin Data_Bin_o = 6'b100010;//38 end else if(~Data_Dec_i[15]) begin Data_Bin_o = 6'b100011;//39 end else if(~Data_Dec_i[14]) begin Data_Bin_o = 6'b100100;//40 end else if(~Data_Dec_i[13]) begin Data_Bin_o = 6'b100101;//41 end else if(~Data_Dec_i[12]) begin Data_Bin_o = 6'b100110;//42 end else if(~Data_Dec_i[11]) begin Data_Bin_o = 6'b100111;//43 end else if(~Data_Dec_i[10]) begin Data_Bin_o = 6'b101000;//44 end else if(~Data_Dec_i[9]) begin Data_Bin_o = 6'b101001;//45 end else if(~Data_Dec_i[8]) begin Data_Bin_o = 6'b101010;//46 end else if(~Data_Dec_i[7]) begin Data_Bin_o = 6'b101011;//47 end else if(~Data_Dec_i[6]) begin Data_Bin_o = 6'b101100;//48 end else if(~Data_Dec_i[5]) begin Data_Bin_o = 6'b101101;//49 end else if(~Data_Dec_i[4]) begin Data_Bin_o = 6'b101110;//50 end else if(~Data_Dec_i[3]) begin Data_Bin_o = 6'b101111;//51 end else if(~Data_Dec_i[2]) begin Data_Bin_o = 6'b110000;//52 end else if(~Data_Dec_i[1]) begin Data_Bin_o = 6'b110001;//53 end else if(~Data_Dec_i[0]) begin Data_Bin_o = 6'b110010;//54 end else begin Data_Bin_o = 6'b000000;//zero value end end endmodule
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 03/17/2016 05:20:59 PM // Design Name: // Module Name: Priority_Codec_64 // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // // Revision: // Revision 0.01 - File Created // Additional Comments: // ////////////////////////////////////////////////////////////////////////////////// module Priority_Codec_64( input wire [54:0] Data_Dec_i, output reg [5:0] Data_Bin_o ); always @(Data_Dec_i) begin Data_Bin_o=6'b000000; if(~Data_Dec_i[54]) begin Data_Bin_o = 6'b000000;//0 end else if(~Data_Dec_i[53]) begin Data_Bin_o = 6'b000001;//1 end else if(~Data_Dec_i[52]) begin Data_Bin_o = 6'b000010;//2 end else if(~Data_Dec_i[51]) begin Data_Bin_o = 6'b000011;//3 end else if(~Data_Dec_i[50]) begin Data_Bin_o = 6'b000100;//4 end else if(~Data_Dec_i[49]) begin Data_Bin_o = 6'b000101;//5 end else if(~Data_Dec_i[48]) begin Data_Bin_o = 6'b000110;//6 end else if(~Data_Dec_i[47]) begin Data_Bin_o = 6'b000111;//7 end else if(~Data_Dec_i[46]) begin Data_Bin_o = 6'b001000;//8 end else if(~Data_Dec_i[45]) begin Data_Bin_o = 6'b001001;//9 end else if(~Data_Dec_i[44]) begin Data_Bin_o = 6'b001010;//10 end else if(~Data_Dec_i[43]) begin Data_Bin_o = 6'b001011;//11 end else if(~Data_Dec_i[42]) begin Data_Bin_o = 6'b001100;//12 end else if(~Data_Dec_i[41]) begin Data_Bin_o = 6'b001101;//13 end else if(~Data_Dec_i[40]) begin Data_Bin_o = 6'b001110;//14 end else if(~Data_Dec_i[39]) begin Data_Bin_o = 6'b001111;//15 end else if(~Data_Dec_i[38]) begin Data_Bin_o = 6'b010000;//16 end else if(~Data_Dec_i[37]) begin Data_Bin_o = 6'b010001;//17 end else if(~Data_Dec_i[36]) begin Data_Bin_o = 6'b010010;//18 end else if(~Data_Dec_i[35]) begin Data_Bin_o = 6'b010011;//19 end else if(~Data_Dec_i[34]) begin Data_Bin_o = 6'b010100;//20 end else if(~Data_Dec_i[33]) begin Data_Bin_o = 6'b010101;//21 end else if(~Data_Dec_i[32]) begin Data_Bin_o = 6'b010110;//22 end else if(~Data_Dec_i[31]) begin Data_Bin_o = 6'b010111;//23 end else if(~Data_Dec_i[30]) begin Data_Bin_o = 6'b011000;//24 end else if(~Data_Dec_i[29]) begin Data_Bin_o = 6'b010101;//25 end else if(~Data_Dec_i[28]) begin Data_Bin_o = 6'b010110;//26 end else if(~Data_Dec_i[27]) begin Data_Bin_o = 6'b010111;//27 end else if(~Data_Dec_i[26]) begin Data_Bin_o = 6'b011000;//28 end else if(~Data_Dec_i[25]) begin Data_Bin_o = 6'b011001;//29 end else if(~Data_Dec_i[24]) begin Data_Bin_o = 6'b011010;//30 end else if(~Data_Dec_i[23]) begin Data_Bin_o = 6'b011011;//31 end else if(~Data_Dec_i[22]) begin Data_Bin_o = 6'b011100;//32 end else if(~Data_Dec_i[21]) begin Data_Bin_o = 6'b011101;//33 end else if(~Data_Dec_i[20]) begin Data_Bin_o = 6'b011110;//34 end else if(~Data_Dec_i[19]) begin Data_Bin_o = 6'b011111;//35 end else if(~Data_Dec_i[18]) begin Data_Bin_o = 6'b100000;//36 end else if(~Data_Dec_i[17]) begin Data_Bin_o = 6'b100001;//37 end else if(~Data_Dec_i[16]) begin Data_Bin_o = 6'b100010;//38 end else if(~Data_Dec_i[15]) begin Data_Bin_o = 6'b100011;//39 end else if(~Data_Dec_i[14]) begin Data_Bin_o = 6'b100100;//40 end else if(~Data_Dec_i[13]) begin Data_Bin_o = 6'b100101;//41 end else if(~Data_Dec_i[12]) begin Data_Bin_o = 6'b100110;//42 end else if(~Data_Dec_i[11]) begin Data_Bin_o = 6'b100111;//43 end else if(~Data_Dec_i[10]) begin Data_Bin_o = 6'b101000;//44 end else if(~Data_Dec_i[9]) begin Data_Bin_o = 6'b101001;//45 end else if(~Data_Dec_i[8]) begin Data_Bin_o = 6'b101010;//46 end else if(~Data_Dec_i[7]) begin Data_Bin_o = 6'b101011;//47 end else if(~Data_Dec_i[6]) begin Data_Bin_o = 6'b101100;//48 end else if(~Data_Dec_i[5]) begin Data_Bin_o = 6'b101101;//49 end else if(~Data_Dec_i[4]) begin Data_Bin_o = 6'b101110;//50 end else if(~Data_Dec_i[3]) begin Data_Bin_o = 6'b101111;//51 end else if(~Data_Dec_i[2]) begin Data_Bin_o = 6'b110000;//52 end else if(~Data_Dec_i[1]) begin Data_Bin_o = 6'b110001;//53 end else if(~Data_Dec_i[0]) begin Data_Bin_o = 6'b110010;//54 end else begin Data_Bin_o = 6'b000000;//zero value end end endmodule
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 03/17/2016 05:20:59 PM // Design Name: // Module Name: Priority_Codec_64 // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // // Revision: // Revision 0.01 - File Created // Additional Comments: // ////////////////////////////////////////////////////////////////////////////////// module Priority_Codec_64( input wire [54:0] Data_Dec_i, output reg [5:0] Data_Bin_o ); always @(Data_Dec_i) begin Data_Bin_o=6'b000000; if(~Data_Dec_i[54]) begin Data_Bin_o = 6'b000000;//0 end else if(~Data_Dec_i[53]) begin Data_Bin_o = 6'b000001;//1 end else if(~Data_Dec_i[52]) begin Data_Bin_o = 6'b000010;//2 end else if(~Data_Dec_i[51]) begin Data_Bin_o = 6'b000011;//3 end else if(~Data_Dec_i[50]) begin Data_Bin_o = 6'b000100;//4 end else if(~Data_Dec_i[49]) begin Data_Bin_o = 6'b000101;//5 end else if(~Data_Dec_i[48]) begin Data_Bin_o = 6'b000110;//6 end else if(~Data_Dec_i[47]) begin Data_Bin_o = 6'b000111;//7 end else if(~Data_Dec_i[46]) begin Data_Bin_o = 6'b001000;//8 end else if(~Data_Dec_i[45]) begin Data_Bin_o = 6'b001001;//9 end else if(~Data_Dec_i[44]) begin Data_Bin_o = 6'b001010;//10 end else if(~Data_Dec_i[43]) begin Data_Bin_o = 6'b001011;//11 end else if(~Data_Dec_i[42]) begin Data_Bin_o = 6'b001100;//12 end else if(~Data_Dec_i[41]) begin Data_Bin_o = 6'b001101;//13 end else if(~Data_Dec_i[40]) begin Data_Bin_o = 6'b001110;//14 end else if(~Data_Dec_i[39]) begin Data_Bin_o = 6'b001111;//15 end else if(~Data_Dec_i[38]) begin Data_Bin_o = 6'b010000;//16 end else if(~Data_Dec_i[37]) begin Data_Bin_o = 6'b010001;//17 end else if(~Data_Dec_i[36]) begin Data_Bin_o = 6'b010010;//18 end else if(~Data_Dec_i[35]) begin Data_Bin_o = 6'b010011;//19 end else if(~Data_Dec_i[34]) begin Data_Bin_o = 6'b010100;//20 end else if(~Data_Dec_i[33]) begin Data_Bin_o = 6'b010101;//21 end else if(~Data_Dec_i[32]) begin Data_Bin_o = 6'b010110;//22 end else if(~Data_Dec_i[31]) begin Data_Bin_o = 6'b010111;//23 end else if(~Data_Dec_i[30]) begin Data_Bin_o = 6'b011000;//24 end else if(~Data_Dec_i[29]) begin Data_Bin_o = 6'b010101;//25 end else if(~Data_Dec_i[28]) begin Data_Bin_o = 6'b010110;//26 end else if(~Data_Dec_i[27]) begin Data_Bin_o = 6'b010111;//27 end else if(~Data_Dec_i[26]) begin Data_Bin_o = 6'b011000;//28 end else if(~Data_Dec_i[25]) begin Data_Bin_o = 6'b011001;//29 end else if(~Data_Dec_i[24]) begin Data_Bin_o = 6'b011010;//30 end else if(~Data_Dec_i[23]) begin Data_Bin_o = 6'b011011;//31 end else if(~Data_Dec_i[22]) begin Data_Bin_o = 6'b011100;//32 end else if(~Data_Dec_i[21]) begin Data_Bin_o = 6'b011101;//33 end else if(~Data_Dec_i[20]) begin Data_Bin_o = 6'b011110;//34 end else if(~Data_Dec_i[19]) begin Data_Bin_o = 6'b011111;//35 end else if(~Data_Dec_i[18]) begin Data_Bin_o = 6'b100000;//36 end else if(~Data_Dec_i[17]) begin Data_Bin_o = 6'b100001;//37 end else if(~Data_Dec_i[16]) begin Data_Bin_o = 6'b100010;//38 end else if(~Data_Dec_i[15]) begin Data_Bin_o = 6'b100011;//39 end else if(~Data_Dec_i[14]) begin Data_Bin_o = 6'b100100;//40 end else if(~Data_Dec_i[13]) begin Data_Bin_o = 6'b100101;//41 end else if(~Data_Dec_i[12]) begin Data_Bin_o = 6'b100110;//42 end else if(~Data_Dec_i[11]) begin Data_Bin_o = 6'b100111;//43 end else if(~Data_Dec_i[10]) begin Data_Bin_o = 6'b101000;//44 end else if(~Data_Dec_i[9]) begin Data_Bin_o = 6'b101001;//45 end else if(~Data_Dec_i[8]) begin Data_Bin_o = 6'b101010;//46 end else if(~Data_Dec_i[7]) begin Data_Bin_o = 6'b101011;//47 end else if(~Data_Dec_i[6]) begin Data_Bin_o = 6'b101100;//48 end else if(~Data_Dec_i[5]) begin Data_Bin_o = 6'b101101;//49 end else if(~Data_Dec_i[4]) begin Data_Bin_o = 6'b101110;//50 end else if(~Data_Dec_i[3]) begin Data_Bin_o = 6'b101111;//51 end else if(~Data_Dec_i[2]) begin Data_Bin_o = 6'b110000;//52 end else if(~Data_Dec_i[1]) begin Data_Bin_o = 6'b110001;//53 end else if(~Data_Dec_i[0]) begin Data_Bin_o = 6'b110010;//54 end else begin Data_Bin_o = 6'b000000;//zero value end end endmodule