| 1 |
408 |
julius |
//////////////////////////////////////////////////////////////////////
|
| 2 |
|
|
//// ////
|
| 3 |
|
|
//// dpMem_dc.v ////
|
| 4 |
|
|
//// ////
|
| 5 |
|
|
//// This file is part of the usbhostslave opencores effort.
|
| 6 |
|
|
//// <http://www.opencores.org/cores//> ////
|
| 7 |
|
|
//// ////
|
| 8 |
|
|
//// Module Description: ////
|
| 9 |
|
|
//// Synchronous dual port memory with dual clocks
|
| 10 |
|
|
//// ////
|
| 11 |
|
|
//// To Do: ////
|
| 12 |
|
|
////
|
| 13 |
|
|
//// ////
|
| 14 |
|
|
//// Author(s): ////
|
| 15 |
|
|
//// - Steve Fielding, sfielding@base2designs.com ////
|
| 16 |
|
|
//// ////
|
| 17 |
|
|
//////////////////////////////////////////////////////////////////////
|
| 18 |
|
|
//// ////
|
| 19 |
|
|
//// Copyright (C) 2004 Steve Fielding and OPENCORES.ORG ////
|
| 20 |
|
|
//// ////
|
| 21 |
|
|
//// This source file may be used and distributed without ////
|
| 22 |
|
|
//// restriction provided that this copyright statement is not ////
|
| 23 |
|
|
//// removed from the file and that any derivative work contains ////
|
| 24 |
|
|
//// the original copyright notice and the associated disclaimer. ////
|
| 25 |
|
|
//// ////
|
| 26 |
|
|
//// This source file is free software; you can redistribute it ////
|
| 27 |
|
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
| 28 |
|
|
//// Public License as published by the Free Software Foundation; ////
|
| 29 |
|
|
//// either version 2.1 of the License, or (at your option) any ////
|
| 30 |
|
|
//// later version. ////
|
| 31 |
|
|
//// ////
|
| 32 |
|
|
//// This source is distributed in the hope that it will be ////
|
| 33 |
|
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
| 34 |
|
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
| 35 |
|
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
| 36 |
|
|
//// details. ////
|
| 37 |
|
|
//// ////
|
| 38 |
|
|
//// You should have received a copy of the GNU Lesser General ////
|
| 39 |
|
|
//// Public License along with this source; if not, download it ////
|
| 40 |
|
|
//// from <http://www.opencores.org/lgpl.shtml> ////
|
| 41 |
|
|
//// ////
|
| 42 |
|
|
//////////////////////////////////////////////////////////////////////
|
| 43 |
|
|
//
|
| 44 |
|
|
`include "timescale.v"
|
| 45 |
|
|
|
| 46 |
|
|
module dpMem_dc_simlib( addrIn, addrOut, wrClk, rdClk, dataIn, writeEn, readEn, dataOut);
|
| 47 |
|
|
//FIFO_DEPTH = ADDR_WIDTH^2
|
| 48 |
|
|
parameter FIFO_WIDTH = 8;
|
| 49 |
|
|
parameter FIFO_DEPTH = 64;
|
| 50 |
|
|
parameter ADDR_WIDTH = 6;
|
| 51 |
|
|
|
| 52 |
|
|
input wrClk;
|
| 53 |
|
|
input rdClk;
|
| 54 |
|
|
input [FIFO_WIDTH-1:0] dataIn;
|
| 55 |
|
|
output [FIFO_WIDTH-1:0] dataOut;
|
| 56 |
|
|
input writeEn;
|
| 57 |
|
|
input readEn;
|
| 58 |
|
|
input [ADDR_WIDTH-1:0] addrIn;
|
| 59 |
|
|
input [ADDR_WIDTH-1:0] addrOut;
|
| 60 |
|
|
|
| 61 |
|
|
wire wrClk;
|
| 62 |
|
|
wire rdClk;
|
| 63 |
|
|
wire [FIFO_WIDTH-1:0] dataIn;
|
| 64 |
|
|
reg [FIFO_WIDTH-1:0] dataOut;
|
| 65 |
|
|
wire writeEn;
|
| 66 |
|
|
wire readEn;
|
| 67 |
|
|
wire [ADDR_WIDTH-1:0] addrIn;
|
| 68 |
|
|
wire [ADDR_WIDTH-1:0] addrOut;
|
| 69 |
|
|
|
| 70 |
|
|
reg [FIFO_WIDTH-1:0] buffer [0:FIFO_DEPTH-1];
|
| 71 |
|
|
|
| 72 |
|
|
// synchronous read. Introduces one clock cycle delay
|
| 73 |
|
|
always @(posedge rdClk) begin
|
| 74 |
|
|
dataOut <= buffer[addrOut];
|
| 75 |
|
|
end
|
| 76 |
|
|
|
| 77 |
|
|
// synchronous write
|
| 78 |
|
|
always @(posedge wrClk) begin
|
| 79 |
|
|
if (writeEn == 1'b1)
|
| 80 |
|
|
buffer[addrIn] <= dataIn;
|
| 81 |
|
|
end
|
| 82 |
|
|
|
| 83 |
|
|
|
| 84 |
|
|
endmodule
|