OpenCores
URL https://opencores.org/ocsvn/qaz_libs/qaz_libs/trunk

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [basal/] [src/] [RAM/] [bram_tdp.v] - Blame information for rev 47

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 34 qaztronic
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
//// Copyright (C) 2015 Authors and OPENCORES.ORG                 ////
4
////                                                              ////
5
//// This source file may be used and distributed without         ////
6
//// restriction provided that this copyright statement is not    ////
7
//// removed from the file and that any derivative work contains  ////
8
//// the original copyright notice and the associated disclaimer. ////
9
////                                                              ////
10
//// This source file is free software; you can redistribute it   ////
11
//// and/or modify it under the terms of the GNU Lesser General   ////
12
//// Public License as published by the Free Software Foundation; ////
13
//// either version 2.1 of the License, or (at your option) any   ////
14
//// later version.                                               ////
15
////                                                              ////
16
//// This source is distributed in the hope that it will be       ////
17
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
18
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
19
//// PURPOSE.  See the GNU Lesser General Public License for more ////
20
//// details.                                                     ////
21
////                                                              ////
22
//// You should have received a copy of the GNU Lesser General    ////
23
//// Public License along with this source; if not, download it   ////
24
//// from http://www.opencores.org/lgpl.shtml                     ////
25
////                                                              ////
26
//////////////////////////////////////////////////////////////////////
27
 
28
 
29
 
30
// --------------------------------------------------------------------
31
// A parameterized, inferable, true dual-port, dual-clock block RAM in Verilog.
32
 
33
module
34
  bram_tdp
35
  #(
36
    parameter W,
37
    parameter A
38
  )
39
  (
40
    // Port A
41
    input               a_clk,
42
    input               a_wr,
43
    input       [A-1:0] a_addr,
44
    input       [W-1:0] a_din,
45
    output  reg [W-1:0] a_dout,
46
 
47
    // Port B
48
    input               b_clk,
49
    input               b_wr,
50
    input       [A-1:0] b_addr,
51
    input       [W-1:0] b_din,
52
    output  reg [W-1:0] b_dout
53
  );
54
 
55
  // --------------------------------------------------------------------
56
  // Shared memory
57
  reg [W-1:0] mem [(2**A)-1:0];
58
 
59
 
60
  // --------------------------------------------------------------------
61
  // Port A
62
  always @(posedge a_clk)
63 37 qaztronic
  if(a_wr)
64 34 qaztronic
  begin
65 37 qaztronic
    a_dout      <= a_din;
66
    mem[a_addr] <= a_din;
67 34 qaztronic
  end
68 37 qaztronic
  else
69
    a_dout      <= mem[a_addr];
70 34 qaztronic
 
71
 
72
  // --------------------------------------------------------------------
73
  // Port B
74
  always @(posedge b_clk)
75 37 qaztronic
  if(b_wr)
76 34 qaztronic
  begin
77 37 qaztronic
    b_dout      <= b_din;
78
    mem[b_addr] <= b_din;
79 34 qaztronic
  end
80 37 qaztronic
  else
81
    b_dout      <= mem[b_addr];
82 34 qaztronic
 
83
 
84
// --------------------------------------------------------------------
85
//
86
endmodule
87
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.