2022-09-19 02:51:11 -04:00
|
|
|
//======================================================================
|
|
|
|
//
|
|
|
|
// rom..v
|
|
|
|
// ------
|
|
|
|
// Firmware ROM module. Implemented using Embedded Block RAM
|
|
|
|
// in the FPGA.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Author: Joachim Strombergson
|
|
|
|
// Copyright (C) 2022 - Tillitis AB
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
//
|
|
|
|
//======================================================================
|
|
|
|
|
|
|
|
`default_nettype none
|
|
|
|
|
|
|
|
module rom(
|
|
|
|
input wire cs,
|
2022-10-06 07:23:30 -04:00
|
|
|
/* verilator lint_off UNUSED */
|
2022-09-19 02:51:11 -04:00
|
|
|
input wire [11 : 0] address,
|
2022-10-06 07:23:30 -04:00
|
|
|
/* verilator lint_on UNUSED */
|
2022-09-19 02:51:11 -04:00
|
|
|
output wire [31 : 0] read_data,
|
|
|
|
output wire ready
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
// Registers, memories with associated wires.
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
// Size of the sysMem Embedded Block RAM (EBR) memory primarily
|
|
|
|
// used for code storage (ROM). The size is number of
|
|
|
|
// 32-bit words. Each EBR is 4kbit in size, and (at most)
|
|
|
|
// 16-bit wide. Thus means that we use pairs of EBRs, and
|
|
|
|
// each pair store 256 32bit words.
|
|
|
|
// The size of the EBR allocated to memory must match the
|
|
|
|
// size of the firmware file generated by the Makefile.
|
2022-10-06 07:23:30 -04:00
|
|
|
//
|
|
|
|
// Max size for the ROM is 3072 words, and the address is
|
|
|
|
// 12 bits to support ROM with this number of words.
|
2022-09-19 02:51:11 -04:00
|
|
|
localparam EBR_MEM_SIZE = `BRAM_FW_SIZE;
|
|
|
|
reg [31 : 0] memory [0 : (EBR_MEM_SIZE - 1)];
|
|
|
|
initial $readmemh(`FIRMWARE_HEX, memory);
|
|
|
|
|
|
|
|
reg [31 : 0] rom_rdata;
|
|
|
|
|
|
|
|
reg rom_ready;
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
// Concurrent assignments of ports.
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
assign read_data = rom_rdata;
|
|
|
|
assign ready = rom_ready;
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
// rom_logic
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
always @*
|
|
|
|
begin : rom_logic
|
2022-10-06 07:23:30 -04:00
|
|
|
|
|
|
|
/* verilator lint_off WIDTH */
|
2023-02-20 09:20:17 -05:00
|
|
|
rom_rdata = memory[address];
|
2022-10-06 07:23:30 -04:00
|
|
|
/* verilator lint_on WIDTH */
|
2022-09-19 02:51:11 -04:00
|
|
|
rom_ready = cs;
|
|
|
|
end
|
|
|
|
|
|
|
|
endmodule // rom
|
|
|
|
|
|
|
|
//======================================================================
|
|
|
|
// EOF rom..v
|
|
|
|
//======================================================================
|