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

Subversion Repositories openhmc

[/] [openhmc/] [trunk/] [openHMC/] [rtl/] [building_blocks/] [rams/] [openhmc_ram.v] - Blame information for rev 15

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 11 juko
/*
2
 *                              .--------------. .----------------. .------------.
3
 *                             | .------------. | .--------------. | .----------. |
4
 *                             | | ____  ____ | | | ____    ____ | | |   ______ | |
5
 *                             | ||_   ||   _|| | ||_   \  /   _|| | | .' ___  || |
6
 *       ___  _ __   ___ _ __  | |  | |__| |  | | |  |   \/   |  | | |/ .'   \_|| |
7
 *      / _ \| '_ \ / _ \ '_ \ | |  |  __  |  | | |  | |\  /| |  | | || |       | |
8
 *       (_) | |_) |  __/ | | || | _| |  | |_ | | | _| |_\/_| |_ | | |\ `.___.'\| |
9
 *      \___/| .__/ \___|_| |_|| ||____||____|| | ||_____||_____|| | | `._____.'| |
10
 *           | |               | |            | | |              | | |          | |
11
 *           |_|               | '------------' | '--------------' | '----------' |
12
 *                              '--------------' '----------------' '------------'
13
 *
14
 *  openHMC - An Open Source Hybrid Memory Cube Controller
15
 *  (C) Copyright 2014 Computer Architecture Group - University of Heidelberg
16
 *  www.ziti.uni-heidelberg.de
17
 *  B6, 26
18
 *  68159 Mannheim
19
 *  Germany
20
 *
21
 *  Contact: openhmc@ziti.uni-heidelberg.de
22
 *  http://ra.ziti.uni-heidelberg.de/openhmc
23
 *
24
 *   This source file is free software: you can redistribute it and/or modify
25
 *   it under the terms of the GNU Lesser General Public License as published by
26
 *   the Free Software Foundation, either version 3 of the License, or
27
 *   (at your option) any later version.
28
 *
29
 *   This source file is distributed in the hope that it will be useful,
30
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
31
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
32
 *   GNU Lesser General Public License for more details.
33
 *
34
 *   You should have received a copy of the GNU Lesser General Public License
35
 *   along with this source file.  If not, see <http://www.gnu.org/licenses/>.
36
 *
37
 *
38
 *  Module name: openhmc_ram
39
 *
40
 */
41
 
42
`default_nettype none
43
 
44
module openhmc_ram #(
45
        parameter DATASIZE  = 78,   // Memory data word width
46
        parameter ADDRSIZE  = 9,    // Number of memory address bits
47 15 juko
        parameter PIPELINED = 0
48 11 juko
    ) (
49
        //----------------------------------
50
        //----SYSTEM INTERFACE
51
        //----------------------------------
52
        input wire                  clk,
53
 
54
        //----------------------------------
55
        //----Signals
56
        //----------------------------------
57
        input wire                  wen,
58
        input wire [DATASIZE-1:0]   wdata,
59
        input wire [ADDRSIZE-1:0]   waddr,
60
        input wire                  ren,
61
        input wire [ADDRSIZE-1:0]   raddr,
62
        output wire [DATASIZE-1:0]  rdata
63
    );
64
 
65
//=====================================================================================================
66
//-----------------------------------------------------------------------------------------------------
67
//---------WIRING AND SIGNAL STUFF---------------------------------------------------------------------
68
//-----------------------------------------------------------------------------------------------------
69
//=====================================================================================================
70
 
71
    wire [DATASIZE-1:0] rdata_ram;
72
 
73
    generate
74
        if (PIPELINED == 0)
75
        begin
76
            assign rdata    = rdata_ram;
77
        end
78
        else
79
        begin
80
            reg [DATASIZE-1:0]  rdata_dly;
81
            reg                 ren_dly;
82
 
83
            assign rdata    = rdata_dly;
84
 
85
            always @(posedge clk)
86
            begin
87
                ren_dly         <= ren;
88
 
89
                if (ren_dly)
90
                    rdata_dly   <= rdata_ram;
91
            end
92
        end
93
    endgenerate
94
 
95
    reg [DATASIZE-1:0]  MEM [0:(2**ADDRSIZE)-1];
96 15 juko
 
97 11 juko
    reg [DATASIZE-1:0]  data_out;
98
 
99
    assign rdata_ram = data_out;
100
 
101
    always @(posedge clk)
102
    begin
103
        if (wen)
104
            MEM[waddr]  <= wdata;
105
    end
106
 
107
    always @(posedge clk)
108
    begin
109
        if (ren)
110
            data_out    <= MEM[raddr];
111
    end
112
 
113
endmodule
114
 
115
`default_nettype wire

powered by: WebSVN 2.1.0

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