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

Subversion Repositories openrisc

[/] [openrisc/] [branches/] [or1200_rel3/] [rtl/] [verilog/] [or1200_sb.v] - Blame information for rev 797

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 258 julius
////  http://opencores.org/project,or1k                           ////
7 10 unneback
////                                                              ////
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
//
45 141 marcus.erl
// $Log: or1200_sb.v,v $
46
// Revision 2.0  2010/06/30 11:00:00  ORSoC
47
// Minor update: 
48
// Bugs fixed. 
49 10 unneback
 
50
// synopsys translate_off
51
`include "timescale.v"
52
// synopsys translate_on
53
`include "or1200_defines.v"
54
 
55
module or1200_sb(
56
        // RISC clock, reset
57
        clk, rst,
58
 
59 141 marcus.erl
        // Internal RISC bus (SB)
60
        sb_en,
61
 
62 10 unneback
        // Internal RISC bus (DC<->SB)
63
        dcsb_dat_i, dcsb_adr_i, dcsb_cyc_i, dcsb_stb_i, dcsb_we_i, dcsb_sel_i, dcsb_cab_i,
64
        dcsb_dat_o, dcsb_ack_o, dcsb_err_o,
65
 
66
        // BIU bus
67
        sbbiu_dat_o, sbbiu_adr_o, sbbiu_cyc_o, sbbiu_stb_o, sbbiu_we_o, sbbiu_sel_o, sbbiu_cab_o,
68
        sbbiu_dat_i, sbbiu_ack_i, sbbiu_err_i
69
);
70
 
71
parameter dw = `OR1200_OPERAND_WIDTH;
72
parameter aw = `OR1200_OPERAND_WIDTH;
73
 
74
//
75
// RISC clock, reset
76
//
77
input                   clk;            // RISC clock
78
input                   rst;            // RISC reset
79
 
80
//
81 141 marcus.erl
// Internal RISC bus (SB)
82
//
83
input                   sb_en;          // SB enable
84
 
85
//
86 10 unneback
// Internal RISC bus (DC<->SB)
87
//
88
input   [dw-1:0] dcsb_dat_i;     // input data bus
89
input   [aw-1:0] dcsb_adr_i;     // address bus
90
input                   dcsb_cyc_i;     // WB cycle
91
input                   dcsb_stb_i;     // WB strobe
92
input                   dcsb_we_i;      // WB write enable
93
input                   dcsb_cab_i;     // CAB input
94
input   [3:0]            dcsb_sel_i;     // byte selects
95
output  [dw-1:0] dcsb_dat_o;     // output data bus
96
output                  dcsb_ack_o;     // ack output
97
output                  dcsb_err_o;     // err output
98
 
99
//
100
// BIU bus
101
//
102
output  [dw-1:0] sbbiu_dat_o;    // output data bus
103
output  [aw-1:0] sbbiu_adr_o;    // address bus
104
output                  sbbiu_cyc_o;    // WB cycle
105
output                  sbbiu_stb_o;    // WB strobe
106
output                  sbbiu_we_o;     // WB write enable
107
output                  sbbiu_cab_o;    // CAB input
108
output  [3:0]            sbbiu_sel_o;    // byte selects
109
input   [dw-1:0] sbbiu_dat_i;    // input data bus
110
input                   sbbiu_ack_i;    // ack output
111
input                   sbbiu_err_i;    // err output
112
 
113
`ifdef OR1200_SB_IMPLEMENTED
114
 
115
//
116
// Internal wires and regs
117
//
118
wire    [4+dw+aw-1:0]    fifo_dat_i;     // FIFO data in
119
wire    [4+dw+aw-1:0]    fifo_dat_o;     // FIFO data out
120
wire                    fifo_wr;
121
wire                    fifo_rd;
122
wire                    fifo_full;
123
wire                    fifo_empty;
124
wire                    sel_sb;
125 141 marcus.erl
reg                     sb_en_reg;
126 10 unneback
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 141 marcus.erl
assign sel_sb = sb_en_reg & (~fifo_empty | (fifo_empty & outstanding_store));
148 10 unneback
 
149
//
150 141 marcus.erl
// SB enable
151
//
152 358 julius
always @(posedge clk or `OR1200_RST_EVENT rst)
153
        if (rst == `OR1200_RST_VALUE)
154 141 marcus.erl
                sb_en_reg <= 1'b0;
155
        else if (sb_en & ~dcsb_cyc_i)
156 258 julius
                sb_en_reg <=  1'b1; // enable SB when there is no dcsb transfer in progress
157 141 marcus.erl
        else if (~sb_en & (~fifo_empty | (fifo_empty & outstanding_store)))
158 258 julius
                sb_en_reg <=  1'b0; // disable SB when there is no pending transfers from SB
159 141 marcus.erl
 
160
//
161 10 unneback
// Store buffer FIFO instantiation
162
//
163
or1200_sb_fifo or1200_sb_fifo (
164
        .clk_i(clk),
165
        .rst_i(rst),
166
        .dat_i(fifo_dat_i),
167
        .wr_i(fifo_wr),
168
        .rd_i(fifo_rd),
169
        .dat_o(fifo_dat_o),
170
        .full_o(fifo_full),
171
        .empty_o(fifo_empty)
172
);
173
 
174
//
175
// fifo_rd
176
//
177 358 julius
always @(posedge clk or `OR1200_RST_EVENT rst)
178
        if (rst == `OR1200_RST_VALUE)
179 258 julius
                outstanding_store <=  1'b0;
180 10 unneback
        else if (sbbiu_ack_i)
181 258 julius
                outstanding_store <=  1'b0;
182 10 unneback
        else if (sel_sb | fifo_wr)
183 258 julius
                outstanding_store <=  1'b1;
184 10 unneback
 
185
//
186
// fifo_wr_ack
187
//
188 358 julius
always @(posedge clk or `OR1200_RST_EVENT rst)
189
        if (rst == `OR1200_RST_VALUE)
190 258 julius
                fifo_wr_ack <=  1'b0;
191 10 unneback
        else if (fifo_wr)
192 258 julius
                fifo_wr_ack <=  1'b1;
193 10 unneback
        else
194 258 julius
                fifo_wr_ack <=  1'b0;
195 10 unneback
 
196
`else   // !OR1200_SB_IMPLEMENTED
197
 
198
assign sbbiu_dat_o = dcsb_dat_i;
199
assign sbbiu_adr_o = dcsb_adr_i;
200
assign sbbiu_cyc_o = dcsb_cyc_i;
201
assign sbbiu_stb_o = dcsb_stb_i;
202
assign sbbiu_we_o = dcsb_we_i;
203
assign sbbiu_cab_o = dcsb_cab_i;
204
assign sbbiu_sel_o = dcsb_sel_i;
205
assign dcsb_dat_o = sbbiu_dat_i;
206
assign dcsb_ack_o = sbbiu_ack_i;
207
assign dcsb_err_o = sbbiu_err_i;
208
 
209
`endif
210
 
211
endmodule

powered by: WebSVN 2.1.0

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