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

Subversion Repositories openriscdevboard

[/] [openriscdevboard/] [trunk/] [cyc2-openrisc/] [rtl/] [or1200/] [or1200_sb.v] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 sfielding
//////////////////////////////////////////////////////////////////////
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
// $Log: not supported by cvs2svn $
47
// Revision 1.1  2006/12/21 16:46:58  vak
48
// Initial revision imported from
49
// http://www.opencores.org/cvsget.cgi/or1k/orp/orp_soc/rtl/verilog.
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
// 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
        // Internal RISC bus (DC<->SB)
69
        dcsb_dat_i, dcsb_adr_i, dcsb_cyc_i, dcsb_stb_i, dcsb_we_i, dcsb_sel_i, dcsb_cab_i,
70
        dcsb_dat_o, dcsb_ack_o, dcsb_err_o,
71
 
72
        // BIU bus
73
        sbbiu_dat_o, sbbiu_adr_o, sbbiu_cyc_o, sbbiu_stb_o, sbbiu_we_o, sbbiu_sel_o, sbbiu_cab_o,
74
        sbbiu_dat_i, sbbiu_ack_i, sbbiu_err_i
75
);
76
 
77
parameter dw = `OR1200_OPERAND_WIDTH;
78
parameter aw = `OR1200_OPERAND_WIDTH;
79
 
80
//
81
// RISC clock, reset
82
//
83
input                   clk;            // RISC clock
84
input                   rst;            // RISC reset
85
 
86
//
87
// Internal RISC bus (DC<->SB)
88
//
89
input   [dw-1:0] dcsb_dat_i;     // input data bus
90
input   [aw-1:0] dcsb_adr_i;     // address bus
91
input                   dcsb_cyc_i;     // WB cycle
92
input                   dcsb_stb_i;     // WB strobe
93
input                   dcsb_we_i;      // WB write enable
94
input                   dcsb_cab_i;     // CAB input
95
input   [3:0]            dcsb_sel_i;     // byte selects
96
output  [dw-1:0] dcsb_dat_o;     // output data bus
97
output                  dcsb_ack_o;     // ack output
98
output                  dcsb_err_o;     // err output
99
 
100
//
101
// BIU bus
102
//
103
output  [dw-1:0] sbbiu_dat_o;    // output data bus
104
output  [aw-1:0] sbbiu_adr_o;    // address bus
105
output                  sbbiu_cyc_o;    // WB cycle
106
output                  sbbiu_stb_o;    // WB strobe
107
output                  sbbiu_we_o;     // WB write enable
108
output                  sbbiu_cab_o;    // CAB input
109
output  [3:0]            sbbiu_sel_o;    // byte selects
110
input   [dw-1:0] sbbiu_dat_i;    // input data bus
111
input                   sbbiu_ack_i;    // ack output
112
input                   sbbiu_err_i;    // err output
113
 
114
`ifdef OR1200_SB_IMPLEMENTED
115
 
116
//
117
// Internal wires and regs
118
//
119
wire    [4+dw+aw-1:0]    fifo_dat_i;     // FIFO data in
120
wire    [4+dw+aw-1:0]    fifo_dat_o;     // FIFO data out
121
wire                    fifo_wr;
122
wire                    fifo_rd;
123
wire                    fifo_full;
124
wire                    fifo_empty;
125
wire                    sel_sb;
126
reg                     outstanding_store;
127
reg                     fifo_wr_ack;
128
 
129
//
130
// FIFO data in/out
131
//
132
assign fifo_dat_i = {dcsb_sel_i, dcsb_dat_i, dcsb_adr_i};
133
assign {sbbiu_sel_o, sbbiu_dat_o, sbbiu_adr_o} = sel_sb ? fifo_dat_o : {dcsb_sel_i, dcsb_dat_i, dcsb_adr_i};
134
 
135
//
136
// Control
137
//
138
assign fifo_wr = dcsb_cyc_i & dcsb_stb_i & dcsb_we_i & ~fifo_full & ~fifo_wr_ack;
139
assign fifo_rd = ~outstanding_store;
140
assign dcsb_dat_o = sbbiu_dat_i;
141
assign dcsb_ack_o = sel_sb ? fifo_wr_ack : sbbiu_ack_i;
142
assign dcsb_err_o = sel_sb ? 1'b0 : sbbiu_err_i;        // SB never returns error
143
assign sbbiu_cyc_o = sel_sb ? outstanding_store : dcsb_cyc_i;
144
assign sbbiu_stb_o = sel_sb ? outstanding_store : dcsb_stb_i;
145
assign sbbiu_we_o = sel_sb ? 1'b1 : dcsb_we_i;
146
assign sbbiu_cab_o = sel_sb ? 1'b0 : dcsb_cab_i;
147
assign sel_sb = ~fifo_empty | (fifo_empty & outstanding_store); // | fifo_wr;
148
 
149
//
150
// Store buffer FIFO instantiation
151
//
152
or1200_sb_fifo or1200_sb_fifo (
153
        .clk_i(clk),
154
        .rst_i(rst),
155
        .dat_i(fifo_dat_i),
156
        .wr_i(fifo_wr),
157
        .rd_i(fifo_rd),
158
        .dat_o(fifo_dat_o),
159
        .full_o(fifo_full),
160
        .empty_o(fifo_empty)
161
);
162
 
163
//
164
// fifo_rd
165
//
166
always @(posedge clk or posedge rst)
167
        if (rst)
168
                outstanding_store <= #1 1'b0;
169
        else if (sbbiu_ack_i)
170
                outstanding_store <= #1 1'b0;
171
        else if (sel_sb | fifo_wr)
172
                outstanding_store <= #1 1'b1;
173
 
174
//
175
// fifo_wr_ack
176
//
177
always @(posedge clk or posedge rst)
178
        if (rst)
179
                fifo_wr_ack <= #1 1'b0;
180
        else if (fifo_wr)
181
                fifo_wr_ack <= #1 1'b1;
182
        else
183
                fifo_wr_ack <= #1 1'b0;
184
 
185
`else   // !OR1200_SB_IMPLEMENTED
186
 
187
assign sbbiu_dat_o = dcsb_dat_i;
188
assign sbbiu_adr_o = dcsb_adr_i;
189
assign sbbiu_cyc_o = dcsb_cyc_i;
190
assign sbbiu_stb_o = dcsb_stb_i;
191
assign sbbiu_we_o = dcsb_we_i;
192
assign sbbiu_cab_o = dcsb_cab_i;
193
assign sbbiu_sel_o = dcsb_sel_i;
194
assign dcsb_dat_o = sbbiu_dat_i;
195
assign dcsb_ack_o = sbbiu_ack_i;
196
assign dcsb_err_o = sbbiu_err_i;
197
 
198
`endif
199
 
200
endmodule

powered by: WebSVN 2.1.0

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