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

Subversion Repositories openrisc_me

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

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
// $Log: not supported by cvs2svn $
47
// Revision 1.1  2002/08/18 19:53:08  lampret
48
// Added store buffer.
49
//
50
//
51
 
52
// synopsys translate_off
53
`include "timescale.v"
54
// synopsys translate_on
55
`include "or1200_defines.v"
56
 
57
module or1200_sb(
58
        // RISC clock, reset
59
        clk, rst,
60
 
61
        // Internal RISC bus (DC<->SB)
62
        dcsb_dat_i, dcsb_adr_i, dcsb_cyc_i, dcsb_stb_i, dcsb_we_i, dcsb_sel_i, dcsb_cab_i,
63
        dcsb_dat_o, dcsb_ack_o, dcsb_err_o,
64
 
65
        // BIU bus
66
        sbbiu_dat_o, sbbiu_adr_o, sbbiu_cyc_o, sbbiu_stb_o, sbbiu_we_o, sbbiu_sel_o, sbbiu_cab_o,
67
        sbbiu_dat_i, sbbiu_ack_i, sbbiu_err_i
68
);
69
 
70
parameter dw = `OR1200_OPERAND_WIDTH;
71
parameter aw = `OR1200_OPERAND_WIDTH;
72
 
73
//
74
// RISC clock, reset
75
//
76
input                   clk;            // RISC clock
77
input                   rst;            // RISC reset
78
 
79
//
80
// Internal RISC bus (DC<->SB)
81
//
82
input   [dw-1:0] dcsb_dat_i;     // input data bus
83
input   [aw-1:0] dcsb_adr_i;     // address bus
84
input                   dcsb_cyc_i;     // WB cycle
85
input                   dcsb_stb_i;     // WB strobe
86
input                   dcsb_we_i;      // WB write enable
87
input                   dcsb_cab_i;     // CAB input
88
input   [3:0]            dcsb_sel_i;     // byte selects
89
output  [dw-1:0] dcsb_dat_o;     // output data bus
90
output                  dcsb_ack_o;     // ack output
91
output                  dcsb_err_o;     // err output
92
 
93
//
94
// BIU bus
95
//
96
output  [dw-1:0] sbbiu_dat_o;    // output data bus
97
output  [aw-1:0] sbbiu_adr_o;    // address bus
98
output                  sbbiu_cyc_o;    // WB cycle
99
output                  sbbiu_stb_o;    // WB strobe
100
output                  sbbiu_we_o;     // WB write enable
101
output                  sbbiu_cab_o;    // CAB input
102
output  [3:0]            sbbiu_sel_o;    // byte selects
103
input   [dw-1:0] sbbiu_dat_i;    // input data bus
104
input                   sbbiu_ack_i;    // ack output
105
input                   sbbiu_err_i;    // err output
106
 
107
`ifdef OR1200_SB_IMPLEMENTED
108
 
109
//
110
// Internal wires and regs
111
//
112
wire    [4+dw+aw-1:0]    fifo_dat_i;     // FIFO data in
113
wire    [4+dw+aw-1:0]    fifo_dat_o;     // FIFO data out
114
wire                    fifo_wr;
115
wire                    fifo_rd;
116
wire                    fifo_full;
117
wire                    fifo_empty;
118
wire                    sel_sb;
119
reg                     outstanding_store;
120
reg                     fifo_wr_ack;
121
 
122
//
123
// FIFO data in/out
124
//
125
assign fifo_dat_i = {dcsb_sel_i, dcsb_dat_i, dcsb_adr_i};
126
assign {sbbiu_sel_o, sbbiu_dat_o, sbbiu_adr_o} = sel_sb ? fifo_dat_o : {dcsb_sel_i, dcsb_dat_i, dcsb_adr_i};
127
 
128
//
129
// Control
130
//
131
assign fifo_wr = dcsb_cyc_i & dcsb_stb_i & dcsb_we_i & ~fifo_full & ~fifo_wr_ack;
132
assign fifo_rd = ~outstanding_store;
133
assign dcsb_dat_o = sbbiu_dat_i;
134
assign dcsb_ack_o = sel_sb ? fifo_wr_ack : sbbiu_ack_i;
135
assign dcsb_err_o = sel_sb ? 1'b0 : sbbiu_err_i;        // SB never returns error
136
assign sbbiu_cyc_o = sel_sb ? outstanding_store : dcsb_cyc_i;
137
assign sbbiu_stb_o = sel_sb ? outstanding_store : dcsb_stb_i;
138
assign sbbiu_we_o = sel_sb ? 1'b1 : dcsb_we_i;
139
assign sbbiu_cab_o = sel_sb ? 1'b0 : dcsb_cab_i;
140
assign sel_sb = ~fifo_empty | (fifo_empty & outstanding_store); // | fifo_wr;
141
 
142
//
143
// Store buffer FIFO instantiation
144
//
145
or1200_sb_fifo or1200_sb_fifo (
146
        .clk_i(clk),
147
        .rst_i(rst),
148
        .dat_i(fifo_dat_i),
149
        .wr_i(fifo_wr),
150
        .rd_i(fifo_rd),
151
        .dat_o(fifo_dat_o),
152
        .full_o(fifo_full),
153
        .empty_o(fifo_empty)
154
);
155
 
156
//
157
// fifo_rd
158
//
159
always @(posedge clk or posedge rst)
160
        if (rst)
161
                outstanding_store <= #1 1'b0;
162
        else if (sbbiu_ack_i)
163
                outstanding_store <= #1 1'b0;
164
        else if (sel_sb | fifo_wr)
165
                outstanding_store <= #1 1'b1;
166
 
167
//
168
// fifo_wr_ack
169
//
170
always @(posedge clk or posedge rst)
171
        if (rst)
172
                fifo_wr_ack <= #1 1'b0;
173
        else if (fifo_wr)
174
                fifo_wr_ack <= #1 1'b1;
175
        else
176
                fifo_wr_ack <= #1 1'b0;
177
 
178
`else   // !OR1200_SB_IMPLEMENTED
179
 
180
assign sbbiu_dat_o = dcsb_dat_i;
181
assign sbbiu_adr_o = dcsb_adr_i;
182
assign sbbiu_cyc_o = dcsb_cyc_i;
183
assign sbbiu_stb_o = dcsb_stb_i;
184
assign sbbiu_we_o = dcsb_we_i;
185
assign sbbiu_cab_o = dcsb_cab_i;
186
assign sbbiu_sel_o = dcsb_sel_i;
187
assign dcsb_dat_o = sbbiu_dat_i;
188
assign dcsb_ack_o = sbbiu_ack_i;
189
assign dcsb_err_o = sbbiu_err_i;
190
 
191
`endif
192
 
193
endmodule

powered by: WebSVN 2.1.0

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