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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [or1200/] [rtl/] [verilog/] [or1200_sb.v] - Blame information for rev 232

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

Line No. Rev Author Line
1 10 unneback
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OR1200's Store Buffer                                       ////
4
////                                                              ////
5
////  This file is part of the OpenRISC 1200 project              ////
6
////  http://www.opencores.org/cores/or1k/                        ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  Implements store buffer.                                    ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////   - byte combining                                           ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Damjan Lampret, lampret@opencores.org                 ////
16
////                                                              ////
17
//////////////////////////////////////////////////////////////////////
18
////                                                              ////
19
//// Copyright (C) 2002 Authors and OPENCORES.ORG                 ////
20
////                                                              ////
21
//// This source file may be used and distributed without         ////
22
//// restriction provided that this copyright statement is not    ////
23
//// removed from the file and that any derivative work contains  ////
24
//// the original copyright notice and the associated disclaimer. ////
25
////                                                              ////
26
//// This source file is free software; you can redistribute it   ////
27
//// and/or modify it under the terms of the GNU Lesser General   ////
28
//// Public License as published by the Free Software Foundation; ////
29
//// either version 2.1 of the License, or (at your option) any   ////
30
//// later version.                                               ////
31
////                                                              ////
32
//// This source is distributed in the hope that it will be       ////
33
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
34
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
35
//// PURPOSE.  See the GNU Lesser General Public License for more ////
36
//// details.                                                     ////
37
////                                                              ////
38
//// You should have received a copy of the GNU Lesser General    ////
39
//// Public License along with this source; if not, download it   ////
40
//// from http://www.opencores.org/lgpl.shtml                     ////
41
////                                                              ////
42
//////////////////////////////////////////////////////////////////////
43
//
44
// CVS Revision History
45
//
46 141 marcus.erl
// $Log: or1200_sb.v,v $
47
// Revision 2.0  2010/06/30 11:00:00  ORSoC
48
// Minor update: 
49
// Bugs fixed. 
50
//
51
// Revision 1.2  2002/08/22 02:18:55  lampret
52
// Store buffer has been tested and it works. BY default it is still disabled until uClinux confirms correct operation on FPGA board.
53
//
54 10 unneback
// Revision 1.1  2002/08/18 19:53:08  lampret
55
// Added store buffer.
56
//
57
//
58
 
59
// synopsys translate_off
60
`include "timescale.v"
61
// synopsys translate_on
62
`include "or1200_defines.v"
63
 
64
module or1200_sb(
65
        // RISC clock, reset
66
        clk, rst,
67
 
68 141 marcus.erl
        // Internal RISC bus (SB)
69
        sb_en,
70
 
71 10 unneback
        // Internal RISC bus (DC<->SB)
72
        dcsb_dat_i, dcsb_adr_i, dcsb_cyc_i, dcsb_stb_i, dcsb_we_i, dcsb_sel_i, dcsb_cab_i,
73
        dcsb_dat_o, dcsb_ack_o, dcsb_err_o,
74
 
75
        // BIU bus
76
        sbbiu_dat_o, sbbiu_adr_o, sbbiu_cyc_o, sbbiu_stb_o, sbbiu_we_o, sbbiu_sel_o, sbbiu_cab_o,
77
        sbbiu_dat_i, sbbiu_ack_i, sbbiu_err_i
78
);
79
 
80
parameter dw = `OR1200_OPERAND_WIDTH;
81
parameter aw = `OR1200_OPERAND_WIDTH;
82
 
83
//
84
// RISC clock, reset
85
//
86
input                   clk;            // RISC clock
87
input                   rst;            // RISC reset
88
 
89
//
90 141 marcus.erl
// Internal RISC bus (SB)
91
//
92
input                   sb_en;          // SB enable
93
 
94
//
95 10 unneback
// Internal RISC bus (DC<->SB)
96
//
97
input   [dw-1:0] dcsb_dat_i;     // input data bus
98
input   [aw-1:0] dcsb_adr_i;     // address bus
99
input                   dcsb_cyc_i;     // WB cycle
100
input                   dcsb_stb_i;     // WB strobe
101
input                   dcsb_we_i;      // WB write enable
102
input                   dcsb_cab_i;     // CAB input
103
input   [3:0]            dcsb_sel_i;     // byte selects
104
output  [dw-1:0] dcsb_dat_o;     // output data bus
105
output                  dcsb_ack_o;     // ack output
106
output                  dcsb_err_o;     // err output
107
 
108
//
109
// BIU bus
110
//
111
output  [dw-1:0] sbbiu_dat_o;    // output data bus
112
output  [aw-1:0] sbbiu_adr_o;    // address bus
113
output                  sbbiu_cyc_o;    // WB cycle
114
output                  sbbiu_stb_o;    // WB strobe
115
output                  sbbiu_we_o;     // WB write enable
116
output                  sbbiu_cab_o;    // CAB input
117
output  [3:0]            sbbiu_sel_o;    // byte selects
118
input   [dw-1:0] sbbiu_dat_i;    // input data bus
119
input                   sbbiu_ack_i;    // ack output
120
input                   sbbiu_err_i;    // err output
121
 
122
`ifdef OR1200_SB_IMPLEMENTED
123
 
124
//
125
// Internal wires and regs
126
//
127
wire    [4+dw+aw-1:0]    fifo_dat_i;     // FIFO data in
128
wire    [4+dw+aw-1:0]    fifo_dat_o;     // FIFO data out
129
wire                    fifo_wr;
130
wire                    fifo_rd;
131
wire                    fifo_full;
132
wire                    fifo_empty;
133
wire                    sel_sb;
134 141 marcus.erl
reg                     sb_en_reg;
135 10 unneback
reg                     outstanding_store;
136
reg                     fifo_wr_ack;
137
 
138
//
139
// FIFO data in/out
140
//
141
assign fifo_dat_i = {dcsb_sel_i, dcsb_dat_i, dcsb_adr_i};
142
assign {sbbiu_sel_o, sbbiu_dat_o, sbbiu_adr_o} = sel_sb ? fifo_dat_o : {dcsb_sel_i, dcsb_dat_i, dcsb_adr_i};
143
 
144
//
145
// Control
146
//
147
assign fifo_wr = dcsb_cyc_i & dcsb_stb_i & dcsb_we_i & ~fifo_full & ~fifo_wr_ack;
148
assign fifo_rd = ~outstanding_store;
149
assign dcsb_dat_o = sbbiu_dat_i;
150
assign dcsb_ack_o = sel_sb ? fifo_wr_ack : sbbiu_ack_i;
151
assign dcsb_err_o = sel_sb ? 1'b0 : sbbiu_err_i;        // SB never returns error
152
assign sbbiu_cyc_o = sel_sb ? outstanding_store : dcsb_cyc_i;
153
assign sbbiu_stb_o = sel_sb ? outstanding_store : dcsb_stb_i;
154
assign sbbiu_we_o = sel_sb ? 1'b1 : dcsb_we_i;
155
assign sbbiu_cab_o = sel_sb ? 1'b0 : dcsb_cab_i;
156 141 marcus.erl
assign sel_sb = sb_en_reg & (~fifo_empty | (fifo_empty & outstanding_store));
157 10 unneback
 
158
//
159 141 marcus.erl
// SB enable
160
//
161
always @(posedge clk or posedge rst)
162
        if (rst)
163
                sb_en_reg <= 1'b0;
164
        else if (sb_en & ~dcsb_cyc_i)
165
                sb_en_reg <= #1 1'b1; // enable SB when there is no dcsb transfer in progress
166
        else if (~sb_en & (~fifo_empty | (fifo_empty & outstanding_store)))
167
                sb_en_reg <= #1 1'b0; // disable SB when there is no pending transfers from SB
168
 
169
//
170 10 unneback
// Store buffer FIFO instantiation
171
//
172
or1200_sb_fifo or1200_sb_fifo (
173
        .clk_i(clk),
174
        .rst_i(rst),
175
        .dat_i(fifo_dat_i),
176
        .wr_i(fifo_wr),
177
        .rd_i(fifo_rd),
178
        .dat_o(fifo_dat_o),
179
        .full_o(fifo_full),
180
        .empty_o(fifo_empty)
181
);
182
 
183
//
184
// fifo_rd
185
//
186
always @(posedge clk or posedge rst)
187
        if (rst)
188
                outstanding_store <= #1 1'b0;
189
        else if (sbbiu_ack_i)
190
                outstanding_store <= #1 1'b0;
191
        else if (sel_sb | fifo_wr)
192
                outstanding_store <= #1 1'b1;
193
 
194
//
195
// fifo_wr_ack
196
//
197
always @(posedge clk or posedge rst)
198
        if (rst)
199
                fifo_wr_ack <= #1 1'b0;
200
        else if (fifo_wr)
201
                fifo_wr_ack <= #1 1'b1;
202
        else
203
                fifo_wr_ack <= #1 1'b0;
204
 
205
`else   // !OR1200_SB_IMPLEMENTED
206
 
207
assign sbbiu_dat_o = dcsb_dat_i;
208
assign sbbiu_adr_o = dcsb_adr_i;
209
assign sbbiu_cyc_o = dcsb_cyc_i;
210
assign sbbiu_stb_o = dcsb_stb_i;
211
assign sbbiu_we_o = dcsb_we_i;
212
assign sbbiu_cab_o = dcsb_cab_i;
213
assign sbbiu_sel_o = dcsb_sel_i;
214
assign dcsb_dat_o = sbbiu_dat_i;
215
assign dcsb_ack_o = sbbiu_ack_i;
216
assign dcsb_err_o = sbbiu_err_i;
217
 
218
`endif
219
 
220
endmodule

powered by: WebSVN 2.1.0

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