// // Copyright 2021 Ettus Research, a National Instruments Brand // // SPDX-License-Identifier: LGPL-3.0-or-later // // Module: basic_regs // // Description: // Basic Registers to inform software about version and capabilities. // `default_nettype none module basic_regs #( parameter [19:0] BASE_ADDRESS = 0, parameter [19:0] SIZE_ADDRESS = 0 ) ( // Request input wire s_ctrlport_req_wr, input wire s_ctrlport_req_rd, input wire [19:0] s_ctrlport_req_addr, input wire [31:0] s_ctrlport_req_data, // Response output reg s_ctrlport_resp_ack, output reg [ 1:0] s_ctrlport_resp_status, output reg [31:0] s_ctrlport_resp_data, //reg clk domain input wire ctrlport_clk, input wire ctrlport_rst ); `include "../regmap/basic_regs_regmap_utils.vh" `include "../../../../../../lib/rfnoc/core/ctrlport.vh" //---------------------------------------------------------- // Internal registers //---------------------------------------------------------- reg [SCRATCH_REG_SIZE-1:0] scratch_reg = {SCRATCH_REG_SIZE {1'b0}}; `ifdef VARIANT_XO3 localparam VARIANT_ID = VARIANT_ID_XO3; `else localparam VARIANT_ID = VARIANT_ID_MAX10; `endif //---------------------------------------------------------- // Handling of CtrlPort //---------------------------------------------------------- wire address_in_range = (s_ctrlport_req_addr >= BASE_ADDRESS) && (s_ctrlport_req_addr < BASE_ADDRESS + SIZE_ADDRESS); always @(posedge ctrlport_clk) begin // reset internal registers and responses if (ctrlport_rst) begin scratch_reg <= {SCRATCH_REG_SIZE {1'b0}}; s_ctrlport_resp_ack <= 1'b0; s_ctrlport_resp_data <= {32{1'bx}}; s_ctrlport_resp_status <= CTRL_STS_OKAY; end else begin // write requests if (s_ctrlport_req_wr) begin // always issue an ack and no data s_ctrlport_resp_ack <= 1'b1; s_ctrlport_resp_data <= {32{1'bx}}; s_ctrlport_resp_status <= CTRL_STS_OKAY; case (s_ctrlport_req_addr) BASE_ADDRESS + SLAVE_SCRATCH: begin scratch_reg <= s_ctrlport_req_data[ SCRATCH_REG_MSB : SCRATCH_REG]; end // error on undefined address default: begin if (address_in_range) begin s_ctrlport_resp_status <= CTRL_STS_CMDERR; // no response if out of range end else begin s_ctrlport_resp_ack <= 1'b0; end end endcase // read requests end else if (s_ctrlport_req_rd) begin // default assumption: valid request s_ctrlport_resp_ack <= 1'b1; s_ctrlport_resp_status <= CTRL_STS_OKAY; s_ctrlport_resp_data <= {32{1'b0}}; case (s_ctrlport_req_addr) BASE_ADDRESS + SLAVE_SIGNATURE: begin s_ctrlport_resp_data[BOARD_ID_MSB : BOARD_ID] <= BOARD_ID_VALUE[BOARD_ID_SIZE-1:0]; end BASE_ADDRESS + SLAVE_REVISION: begin s_ctrlport_resp_data[REVISION_REG_MSB : REVISION_REG] <= CPLD_REVISION[REVISION_REG_SIZE-1:0]; end BASE_ADDRESS + SLAVE_OLDEST_REVISION: begin s_ctrlport_resp_data[OLDEST_REVISION_REG_MSB : OLDEST_REVISION_REG] <= OLDEST_CPLD_REVISION[OLDEST_REVISION_REG_SIZE-1:0]; end BASE_ADDRESS + SLAVE_SCRATCH: begin s_ctrlport_resp_data[SCRATCH_REG_MSB : SCRATCH_REG] <= scratch_reg; end BASE_ADDRESS + GIT_HASH_REGISTER: begin `ifdef GIT_HASH s_ctrlport_resp_data <= `GIT_HASH; `else s_ctrlport_resp_data <= 32'hDEADBEEF; `endif end BASE_ADDRESS + SLAVE_VARIANT: begin s_ctrlport_resp_data[VARIANT_REG_MSB : VARIANT_REG] <= VARIANT_ID[VARIANT_REG_SIZE-1:0]; end // error on undefined address default: begin s_ctrlport_resp_data <= {32{1'b0}}; if (address_in_range) begin s_ctrlport_resp_status <= CTRL_STS_CMDERR; // no response if out of range end else begin s_ctrlport_resp_ack <= 1'b0; end end endcase // no request end else begin s_ctrlport_resp_ack <= 1'b0; end end end endmodule `default_nettype wire //XmlParse xml_on // // // // This regmap contains the revision registers, signature register, a scratch register, and a slave control reg. // // // // // This enum is used to create the constants held in the basic registers in both verilog and vhdl. // // // // // // // // // // // This register contains the unique signature of the DB. This signature is the same value as the one // stored on the board ID EEPROM // // // // Board ID corresponds to the las 16 digits of the daughterboard part number. // // // // // // // This register contains the revision number of the current build // // // // Returns the revision in YYMMDDHH format // // // // // // // This register contains the revision number of the oldest compatible revision // // // // Returns the oldest compatible revision in YYMMDDHH format // // // // // // // Read/write scratch register // // // // Returns the value written here previously. // // // // // // // Git hash of commit used to build this image.{br} // Value equals 0xDEADBEEF if the git hash was not used during synthesis. // // // // 0x0 in case the git status was clean{br} // 0xF in case there were uncommitted changes // // // // 7 hex digit hash code of the commit // // // // // // Contains information pertaining the variant of the programmable. // // // // Returns the variant of the programmable based on the part vendor. // MAX10 variants return 0x583033(ASCII for MAX), while the XO3 variant // returns 0x584F33 (ASCII for XO3) // // // // // //XmlParse xml_off