1// 2// Copyright 2011 Ettus Research LLC 3// 4// This program is free software: you can redistribute it and/or modify 5// it under the terms of the GNU General Public License as published by 6// the Free Software Foundation, either version 3 of the License, or 7// (at your option) any later version. 8// 9// This program is distributed in the hope that it will be useful, 10// but WITHOUT ANY WARRANTY; without even the implied warranty of 11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12// GNU General Public License for more details. 13// 14// You should have received a copy of the GNU General Public License 15// along with this program. If not, see <http://www.gnu.org/licenses/>. 16// 17 18 19 20module ram_2port 21 #(parameter DWIDTH=32, 22 parameter AWIDTH=9) 23 (input clka, 24 input ena, 25 input wea, 26 input [AWIDTH-1:0] addra, 27 input [DWIDTH-1:0] dia, 28 output reg [DWIDTH-1:0] doa, 29 30 input clkb, 31 input enb, 32 input web, 33 input [AWIDTH-1:0] addrb, 34 input [DWIDTH-1:0] dib, 35 output reg [DWIDTH-1:0] dob); 36 37 reg [DWIDTH-1:0] ram [(1<<AWIDTH)-1:0]; 38 integer i; 39 initial 40 for(i=0;i<(1<<AWIDTH);i=i+1) 41 ram[i] <= {DWIDTH{1'b0}}; 42 43 always @(posedge clka) begin 44 if (ena) 45 begin 46 if (wea) 47 ram[addra] <= dia; 48 doa <= ram[addra]; 49 end 50 end 51 always @(posedge clkb) begin 52 if (enb) 53 begin 54 if (web) 55 ram[addrb] <= dib; 56 dob <= ram[addrb]; 57 end 58 end 59endmodule // ram_2port 60