|
| 1 | +/***************************************************************************** |
| 2 | + * Function: True Dual Port RAM (Two write + read ports) |
| 3 | + * Copyright: Lambda Project Authors. All rights Reserved. |
| 4 | + * License: MIT (see LICENSE file in Lambda repository) |
| 5 | + * |
| 6 | + * Docs: |
| 7 | + * |
| 8 | + * This is a wrapper for selecting from a set of hardened memory macros. |
| 9 | + * |
| 10 | + * A synthesizable reference model is used when the PROP is DEFAULT. The |
| 11 | + * synthesizable model does not implement the cfg and test interface and should |
| 12 | + * only be used for basic testing and for synthesizing for FPGA devices. |
| 13 | + * Advanced ASIC development should rely on complete functional models |
| 14 | + * supplied on a per macro basis. |
| 15 | + * |
| 16 | + * Technology specific implementations of "la_tdpram" would generally include |
| 17 | + * one or more hardcoded instantiations of RAM modules with a generate |
| 18 | + * statement relying on the "PROP" to select between the list of modules |
| 19 | + * at build time. |
| 20 | + * |
| 21 | + ****************************************************************************/ |
| 22 | + |
| 23 | +module la_tdpram_impl #( |
| 24 | + parameter DW = 32, // Memory width |
| 25 | + parameter AW = 10, // address width (derived) |
| 26 | + parameter PROP = "DEFAULT", // pass through variable for hard macro |
| 27 | + parameter CTRLW = 128, // width of asic ctrl interface |
| 28 | + parameter TESTW = 128 // width of asic test interface |
| 29 | +) ( // Write port |
| 30 | + input clk_a, // write clock |
| 31 | + input ce_a, // write chip-enable |
| 32 | + input we_a, // write enable |
| 33 | + input [DW-1:0] wmask_a, // write mask |
| 34 | + input [AW-1:0] addr_a, // write address |
| 35 | + input [DW-1:0] din_a, // write data in |
| 36 | + output reg [DW-1:0] dout_a, // read data out |
| 37 | + // B port |
| 38 | + input clk_b, // write clock |
| 39 | + input ce_b, // write chip-enable |
| 40 | + input we_b, // write enable |
| 41 | + input [DW-1:0] wmask_b, // write mask |
| 42 | + input [AW-1:0] addr_b, // write address |
| 43 | + input [DW-1:0] din_b, // write data in |
| 44 | + output reg [DW-1:0] dout_b, // read data out |
| 45 | + // Power signal |
| 46 | + input vss, // ground signal |
| 47 | + input vdd, // memory core array power |
| 48 | + input vddio, // periphery/io power |
| 49 | + // Generic interfaces |
| 50 | + input [CTRLW-1:0] ctrl, // pass through ASIC control interface |
| 51 | + input [TESTW-1:0] test // pass through ASIC test interface |
| 52 | +); |
| 53 | + |
| 54 | + // Generic RTL RAM |
| 55 | + /* verilator lint_off MULTIDRIVEN */ |
| 56 | + reg [DW-1:0] ram[(2**AW)-1:0]; |
| 57 | + /* verilator lint_on MULTIDRIVEN */ |
| 58 | + |
| 59 | + integer i; |
| 60 | + |
| 61 | + // Port A write |
| 62 | + always @(posedge clk_a) begin |
| 63 | + for (i = 0; i < DW; i = i + 1) begin |
| 64 | + if (ce_a && we_a && wmask_a[i]) begin |
| 65 | + ram[addr_a][i] <= din_a[i]; |
| 66 | + end |
| 67 | + end |
| 68 | + end |
| 69 | + |
| 70 | + // Port B write |
| 71 | + always @(posedge clk_b) begin |
| 72 | + for (i = 0; i < DW; i = i + 1) begin |
| 73 | + if (ce_b && we_b && wmask_b[i]) begin |
| 74 | + ram[addr_b][i] <= din_b[i]; |
| 75 | + end |
| 76 | + end |
| 77 | + end |
| 78 | + |
| 79 | + // Port A read |
| 80 | + always @(posedge clk_a) begin |
| 81 | + if (ce_a && ~we_a) begin |
| 82 | + dout_a <= ram[addr_a]; |
| 83 | + end |
| 84 | + end |
| 85 | + |
| 86 | + // Port B read |
| 87 | + always @(posedge clk_b) begin |
| 88 | + if (ce_b && ~we_b) begin |
| 89 | + dout_b <= ram[addr_b]; |
| 90 | + end |
| 91 | + end |
| 92 | + |
| 93 | +endmodule |
0 commit comments