1 //-----------------------------------------------------------------------------
2 // Copyright 2017 Damien Pretet ThotIP
3 // Copyright 2018 Julius Baxter
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //-----------------------------------------------------------------------------
18 `timescale 1 ns / 1 ps
24 parameter DATASIZE = 8, // Memory data word width
25 parameter ADDRSIZE = 4, // Number of mem address bits
26 parameter FALLTHROUGH = "TRUE" // First word fall-through
29 input wire [DATASIZE-1:0] a_wdata,
30 output reg [DATASIZE-1:0] a_rdata,
31 input wire [ADDRSIZE-1:0] a_addr,
36 input wire [DATASIZE-1:0] b_wdata,
37 output reg [DATASIZE-1:0] b_rdata,
38 input wire [ADDRSIZE-1:0] b_addr,
46 localparam DEPTH = 1<<ADDRSIZE;
47 reg [DATASIZE-1:0] mem [0:DEPTH-1];
49 if (FALLTHROUGH == "TRUE")
52 always @(posedge a_clk)
54 mem[a_addr] <= a_wdata;
57 a_rdata = mem[a_addr];
59 always @(posedge b_clk)
61 mem[b_addr] <= b_wdata;
64 b_rdata = mem[b_addr];
66 end // block: fallthrough
70 wire a_en = a_rinc | a_winc;
72 always @(posedge a_clk)
76 mem[a_addr] <= a_wdata;
77 a_rdata <= mem[a_addr];
80 wire b_en = b_rinc | b_winc;
82 always @(posedge b_clk)
86 mem[b_addr] <= b_wdata;
87 b_rdata <= mem[b_addr];
89 end // block: registered