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 9

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 9 specular
//   Kenji Ishimaru (info.info.wf3d@gmail.com)
14 2 specular
//
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
module fm_cmn_ram (
44
    clka,
45
    clkb,
46
    wea,
47
    addra,
48
    addrb,
49
    dia,
50
    doa,
51
    dob
52
 );
53
 
54
//////////////////////////////////
55
// parameter
56
//////////////////////////////////
57
    parameter P_RAM_TYPE="TYPE_A";
58
    parameter P_WIDTH = 32;
59
    parameter P_RANGE = 2;
60
    parameter P_DEPTH = 1 << P_RANGE;
61
//////////////////////////////////
62
// I/O port definition
63
//////////////////////////////////
64
    input                clka;
65
    input                clkb;
66
    input                wea;
67
    input  [P_RANGE-1:0] addra;
68
    input  [P_RANGE-1:0] addrb;
69
    input  [P_WIDTH-1:0] dia;
70
    output [P_WIDTH-1:0] doa;
71
    output [P_WIDTH-1:0] dob;
72
 
73
//////////////////////////////////
74
// reg 
75
//////////////////////////////////
76
    reg [P_WIDTH-1:0] ram [P_DEPTH-1:0];
77
    reg [P_WIDTH-1:0] doa;
78
    reg [P_WIDTH-1:0] dob;
79
 
80
//////////////////////////////////
81
// always
82
//////////////////////////////////
83
generate
84
  if (P_RAM_TYPE=="TYPE_A") begin
85
    always @(posedge clka) begin
86
        if (wea) ram[addra] <= dia;
87
    end
88
 
89
    always @(posedge clkb) begin
90
        dob <= ram[addrb];
91
    end
92
  end else begin
93
    // port A: write-first
94
    always @(posedge clka) begin
95
        if (wea) begin
96
            ram[addra] <= dia;
97
            doa <= dia;
98
        end else begin
99
            doa <= ram[addra];
100
        end
101
    end
102
 
103
    // port B: read-first
104
    always @(posedge clkb) begin
105
        dob <= ram[addrb];
106
    end
107
  end
108
endgenerate
109
endmodule

powered by: WebSVN 2.1.0

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