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

Subversion Repositories wf3d

[/] [wf3d/] [trunk/] [implement/] [rtl/] [fm_hvc/] [fm_cmn_ram.v] - Blame information for rev 2

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

Line No. Rev Author Line
1 2 specular
//=======================================================================
2
// Project Monophony
3
//   Wire-Frame 3D Graphics Accelerator IP Core
4
//
5
// File:
6
//   fm_cmn_ram.v
7
//
8
// Abstract:
9
//   Dualport RAM, this will be mapped to block ram
10
//   with different clocks
11
//
12
// Author:
13
//   Kenji Ishimaru (kenji.ishimaru@prtissimo.com)
14
//
15
//======================================================================
16
//
17
// Copyright (c) 2015, Kenji Ishimaru
18
// All rights reserved.
19
//
20
// Redistribution and use in source and binary forms, with or without
21
// modification, are permitted provided that the following conditions are met:
22
//
23
//  -Redistributions of source code must retain the above copyright notice,
24
//   this list of conditions and the following disclaimer.
25
//  -Redistributions in binary form must reproduce the above copyright notice,
26
//   this list of conditions and the following disclaimer in the documentation
27
//   and/or other materials provided with the distribution.
28
//
29
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
30
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
31
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
32
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
33
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
34
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
35
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
36
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
37
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
38
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
39
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40
//
41
// Revision History
42
//=======================================================================
43
//                        Project Polyphony
44
//
45
// File:
46
//   fm_cmn_bram_02.v
47
//
48
// Abstract:
49
//   Dualport RAM, this will be mapped onto block ram
50
//   with different clocks
51
//  Created:
52
//    5 November 2008
53
//======================================================================
54
//
55
// Copyright (c) 2013, Kenji Ishimaru
56
// All rights reserved.
57
//
58
// Redistribution and use in source and binary forms, with or without
59
// modification, are permitted provided that the following conditions are met:
60
//
61
//  -Redistributions of source code must retain the above copyright notice,
62
//   this list of conditions and the following disclaimer.
63
//  -Redistributions in binary form must reproduce the above copyright notice,
64
//   this list of conditions and the following disclaimer in the documentation
65
//   and/or other materials provided with the distribution.
66
//
67
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
68
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
69
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
70
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
71
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
72
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
73
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
74
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
75
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
76
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
77
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
78
//
79
// Revision History
80
// $Date: 2014-12-09 16:38:37 +0900 (Tue, 09 Dec 2014) $
81
// $Rev: 14 $
82
 
83
module fm_cmn_ram (
84
    clka,
85
    clkb,
86
    wea,
87
    addra,
88
    addrb,
89
    dia,
90
    doa,
91
    dob
92
 );
93
 
94
//////////////////////////////////
95
// parameter
96
//////////////////////////////////
97
    parameter P_RAM_TYPE="TYPE_A";
98
    parameter P_WIDTH = 32;
99
    parameter P_RANGE = 2;
100
    parameter P_DEPTH = 1 << P_RANGE;
101
//////////////////////////////////
102
// I/O port definition
103
//////////////////////////////////
104
    input                clka;
105
    input                clkb;
106
    input                wea;
107
    input  [P_RANGE-1:0] addra;
108
    input  [P_RANGE-1:0] addrb;
109
    input  [P_WIDTH-1:0] dia;
110
    output [P_WIDTH-1:0] doa;
111
    output [P_WIDTH-1:0] dob;
112
 
113
//////////////////////////////////
114
// reg 
115
//////////////////////////////////
116
    reg [P_WIDTH-1:0] ram [P_DEPTH-1:0];
117
    reg [P_WIDTH-1:0] doa;
118
    reg [P_WIDTH-1:0] dob;
119
 
120
//////////////////////////////////
121
// always
122
//////////////////////////////////
123
generate
124
  if (P_RAM_TYPE=="TYPE_A") begin
125
    always @(posedge clka) begin
126
        if (wea) ram[addra] <= dia;
127
    end
128
 
129
    always @(posedge clkb) begin
130
        dob <= ram[addrb];
131
    end
132
  end else begin
133
    // port A: write-first
134
    always @(posedge clka) begin
135
        if (wea) begin
136
            ram[addra] <= dia;
137
            doa <= dia;
138
        end else begin
139
            doa <= ram[addra];
140
        end
141
    end
142
 
143
    // port B: read-first
144
    always @(posedge clkb) begin
145
        dob <= ram[addrb];
146
    end
147
  end
148
endgenerate
149
endmodule

powered by: WebSVN 2.1.0

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