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

Subversion Repositories minsoc

[/] [minsoc/] [trunk/] [bench/] [verilog/] [minsoc_memory_model.v] - Blame information for rev 27

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

Line No. Rev Author Line
1 2 rfajardo
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////         Wishbone Single-Port Synchronous RAM                                 ////
4
////                    Memory Model                                      ////
5
////                                                              ////
6
////  This file is part of memory library available from          ////
7
////  http://www.opencores.org/cvsweb.shtml/minsoc/                       ////
8
////                                                              ////
9
////  Description                                                 ////
10
////  This Wishbone controller connects to the wrapper of         ////
11
////  the single-port synchronous memory interface.               ////
12
////  Besides universal memory due to onchip_ram it provides a    ////
13
////  generic way to set the depth of the memory.                 ////
14
////                                                              ////
15
////  To Do:                                                      ////
16
////                                                              ////
17
////  Author(s):                                                  ////
18
////      - Raul Fajardo, rfajardo@gmail.com                      ////
19
////                                                              ////
20
//////////////////////////////////////////////////////////////////////
21
////                                                              ////
22
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
23
////                                                              ////
24
//// This source file may be used and distributed without         ////
25
//// restriction provided that this copyright statement is not    ////
26
//// removed from the file and that any derivative work contains  ////
27
//// the original copyright notice and the associated disclaimer. ////
28
////                                                              ////
29
//// This source file is free software; you can redistribute it   ////
30
//// and/or modify it under the terms of the GNU Lesser General   ////
31
//// Public License as published by the Free Software Foundation; ////
32
//// either version 2.1 of the License, or (at your option) any   ////
33
//// later version.                                               ////
34
////                                                              ////
35
//// This source is distributed in the hope that it will be       ////
36
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
37
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
38
//// PURPOSE.  See the GNU Lesser General Public License for more ////
39
//// details.                                                     ////
40
////                                                              ////
41
//// You should have received a copy of the GNU Lesser General    ////
42
//// Public License along with this source; if not, download it   ////
43
//// from http://www.gnu.org/licenses/lgpl.html                   ////
44
////                                                              ////
45
//////////////////////////////////////////////////////////////////////
46
//
47
// Revision History
48
//
49
//
50
// Revision 1.0 2009/08/18 15:15:00   fajardo
51
// Created interface and tested
52
//
53
 
54
 
55
module minsoc_onchip_ram_top (
56
  wb_clk_i, wb_rst_i,
57
 
58
  wb_dat_i, wb_dat_o, wb_adr_i, wb_sel_i, wb_we_i, wb_cyc_i,
59
  wb_stb_i, wb_ack_o, wb_err_o
60
);
61
 
62
// 
63
// Parameters 
64
//
65
parameter    adr_width = 2;
66
 
67
// 
68
// I/O Ports 
69
// 
70
input      wb_clk_i;
71
input      wb_rst_i;
72
 
73
// 
74
// WB slave i/f 
75
// 
76
input  [31:0]   wb_dat_i;
77
output [31:0]   wb_dat_o;
78
input  [31:0]   wb_adr_i;
79
input  [3:0]    wb_sel_i;
80
input      wb_we_i;
81
input      wb_cyc_i;
82
input      wb_stb_i;
83
output     wb_ack_o;
84
output     wb_err_o;
85
 
86
// 
87
// Internal regs and wires 
88
// 
89
wire    we;
90
wire [3:0]  be_i;
91
wire [31:0]  wb_dat_o;
92
reg    ack_we;
93
reg    ack_re;
94
// 
95
// Aliases and simple assignments 
96
// 
97
assign wb_ack_o = ack_re | ack_we;
98
assign wb_err_o = wb_cyc_i & wb_stb_i & (|wb_adr_i[23:adr_width+2]);  // If Access to > (8-bit leading prefix ignored) 
99
assign we = wb_cyc_i & wb_stb_i & wb_we_i & (|wb_sel_i[3:0]);
100
assign be_i = (wb_cyc_i & wb_stb_i) * wb_sel_i;
101
 
102
// 
103
// Write acknowledge 
104
// 
105
always @ (negedge wb_clk_i or posedge wb_rst_i)
106
begin
107
if (wb_rst_i)
108
    ack_we <= 1'b0;
109
  else
110
  if (wb_cyc_i & wb_stb_i & wb_we_i & ~ack_we)
111
    ack_we <= #1 1'b1;
112
  else
113
    ack_we <= #1 1'b0;
114
end
115
 
116
// 
117
// read acknowledge 
118
// 
119
always @ (posedge wb_clk_i or posedge wb_rst_i)
120
begin
121
  if (wb_rst_i)
122
    ack_re <= 1'b0;
123
  else
124
  if (wb_cyc_i & wb_stb_i & ~wb_err_o & ~wb_we_i & ~ack_re)
125
    ack_re <= #1 1'b1;
126
  else
127
    ack_re <= #1 1'b0;
128
end
129
 
130
    minsoc_onchip_ram #
131
        (
132
                .aw(adr_width)
133
        )
134
        block_ram_0 (
135
        .clk(wb_clk_i),
136
        .rst(wb_rst_i),
137
        .addr(wb_adr_i[adr_width+1:2]),
138
        .di(wb_dat_i[7:0]),
139
        .doq(wb_dat_o[7:0]),
140
        .we(we),
141
        .oe(1'b1),
142
        .ce(be_i[0]));
143
 
144
    minsoc_onchip_ram #
145
        (
146
                .aw(adr_width)
147
        )
148
        block_ram_1 (
149
        .clk(wb_clk_i),
150
        .rst(wb_rst_i),
151
        .addr(wb_adr_i[adr_width+1:2]),
152
        .di(wb_dat_i[15:8]),
153
        .doq(wb_dat_o[15:8]),
154
        .we(we),
155
        .oe(1'b1),
156
        .ce(be_i[1]));
157
 
158
    minsoc_onchip_ram #
159
        (
160
                .aw(adr_width)
161
        )
162
        block_ram_2 (
163
        .clk(wb_clk_i),
164
        .rst(wb_rst_i),
165
        .addr(wb_adr_i[adr_width+1:2]),
166
        .di(wb_dat_i[23:16]),
167
        .doq(wb_dat_o[23:16]),
168
        .we(we),
169
        .oe(1'b1),
170
        .ce(be_i[2]));
171
 
172
    minsoc_onchip_ram #
173
        (
174
                .aw(adr_width)
175
        )
176
        block_ram_3 (
177
        .clk(wb_clk_i),
178
        .rst(wb_rst_i),
179
        .addr(wb_adr_i[adr_width+1:2]),
180
        .di(wb_dat_i[31:24]),
181
        .doq(wb_dat_o[31:24]),
182
        .we(we),
183
        .oe(1'b1),
184
        .ce(be_i[3]));
185
 
186
endmodule
187
 

powered by: WebSVN 2.1.0

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