OpenCores
URL https://opencores.org/ocsvn/an-fpga-implementation-of-low-latency-noc-based-mpsoc/an-fpga-implementation-of-low-latency-noc-based-mpsoc/trunk

Subversion Repositories an-fpga-implementation-of-low-latency-noc-based-mpsoc

[/] [an-fpga-implementation-of-low-latency-noc-based-mpsoc/] [trunk/] [mpsoc/] [src_processor/] [new_lm32/] [rtl/] [lm32_dp_ram.v] - Blame information for rev 48

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 48 alirezamon
/*
2
 * LatticeMico32
3
 * True dual-ported RAM
4
 *
5
 * Copyright (c) 2012 Michael Walle <michael@walle.cc>
6
 * All rights reserved.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions
10
 * are met:
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice, this list of conditions and the following disclaimer.
13
 * 2. Redistributions in binary form must reproduce the above copyright
14
 *    notice, this list of conditions and the following disclaimer in the
15
 *    documentation and/or other materials provided with the distribution.
16
 * 3. The name of the author may not be used to endorse or promote products
17
 *    derived from this software without specific prior written permission.
18
 *
19
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
 */
30
 
31
`include "lm32_include.v"
32
 
33
/////////////////////////////////////////////////////
34
// Module interface
35
/////////////////////////////////////////////////////
36
 
37
module lm32_dp_ram (
38
    // ----- Inputs -------
39
    clk_a,
40
    clk_b,
41
    ce_a,
42
    ce_b,
43
    addr_a,
44
    addr_b,
45
    di_a,
46
    di_b,
47
    we_a,
48
    we_b,
49
    // ----- Outputs -------
50
    do_a,
51
    do_b
52
    );
53
 
54
/////////////////////////////////////////////////////
55
// Parameters
56
/////////////////////////////////////////////////////
57
 
58
parameter data_width = 1;               // Width of the data ports
59
parameter address_width = 1;            // Width of the address ports
60
parameter init_file = "NONE";           // Initialization file
61
 
62
/////////////////////////////////////////////////////
63
// Inputs
64
/////////////////////////////////////////////////////
65
 
66
input clk_a;                            // Clock port A
67
input clk_b;                            // Clock port B
68
 
69
input ce_a;                             // Clock enable port A
70
input ce_b;                             // Clock enable port B
71
input [address_width-1:0] addr_a;       // Read/write address port A
72
input [address_width-1:0] addr_b;       // Read/write address port B
73
input [data_width-1:0] di_a;            // Data input port A
74
input [data_width-1:0] di_b;            // Data input port B
75
input we_a;                             // Write enable port A
76
input we_b;                             // Write enable port B
77
 
78
/////////////////////////////////////////////////////
79
// Outputs
80
/////////////////////////////////////////////////////
81
 
82
output [data_width-1:0] do_a;           // Data output port A
83
wire   [data_width-1:0] do_a;
84
 
85
output [data_width-1:0] do_b;           // Data output port B
86
wire   [data_width-1:0] do_b;
87
 
88
/////////////////////////////////////////////////////
89
// Internal nets and registers
90
/////////////////////////////////////////////////////
91
 
92
reg [data_width-1:0]    mem[0:(1<<address_width)-1];
93
reg [address_width-1:0] ra_a;           // Registered read address port A
94
reg [address_width-1:0] ra_b;           // Registered read address port B
95
 
96
/////////////////////////////////////////////////////
97
// Functions
98
/////////////////////////////////////////////////////
99
 
100
////////////////////////////////////////////////////
101
// Instantiations
102
/////////////////////////////////////////////////////
103
 
104
/////////////////////////////////////////////////////
105
// Combinational logic
106
/////////////////////////////////////////////////////
107
 
108
// Read ports
109
assign do_a = mem[ra_a];
110
assign do_b = mem[ra_b];
111
 
112
/////////////////////////////////////////////////////
113
// Sequential logic
114
/////////////////////////////////////////////////////
115
 
116
// Write ports
117
always @(posedge clk_a)
118
    if ((ce_a == `TRUE) && (we_a == `TRUE))
119
        mem[addr_a] <= di_a;
120
 
121
always @(posedge clk_b)
122
    if ((ce_b == `TRUE) && (we_b == `TRUE))
123
        mem[addr_b] <= di_b;
124
 
125
// Register read addresses for use on next cycle
126
always @(posedge clk_a)
127
    if (ce_a == `TRUE)
128
        ra_a <= addr_a;
129
 
130
always @(posedge clk_b)
131
    if (ce_b == `TRUE)
132
        ra_b <= addr_b;
133
 
134
/////////////////////////////////////////////////////
135
// Initialization
136
/////////////////////////////////////////////////////
137
 
138
generate
139
    if (init_file != "NONE")
140
    begin
141
initial $readmemh(init_file, mem);
142
    end
143
endgenerate
144
 
145
endmodule

powered by: WebSVN 2.1.0

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