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

Subversion Repositories or1k

[/] [or1k/] [tags/] [rel_26/] [or1200/] [rtl/] [verilog/] [or1200_lsu.v] - Blame information for rev 504

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

Line No. Rev Author Line
1 504 lampret
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OR1200's Load/Store unit                                    ////
4
////                                                              ////
5
////  This file is part of the OpenRISC 1200 project              ////
6
////  http://www.opencores.org/cores/or1k/                        ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  Interface between CPU and DC.                               ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////   - make it smaller and faster                               ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Damjan Lampret, lampret@opencores.org                 ////
16
////                                                              ////
17
//////////////////////////////////////////////////////////////////////
18
////                                                              ////
19
//// Copyright (C) 2000 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.9  2001/11/30 18:59:47  simons
48
// *** empty log message ***
49
//
50
// Revision 1.8  2001/10/21 17:57:16  lampret
51
// Removed params from generic_XX.v. Added translate_off/on in sprs.v and id.v. Removed spr_addr from dc.v and ic.v. Fixed CR+LF.
52
//
53
// Revision 1.7  2001/10/14 13:12:09  lampret
54
// MP3 version.
55
//
56
// Revision 1.1.1.1  2001/10/06 10:18:36  igorm
57
// no message
58
//
59
// Revision 1.2  2001/08/09 13:39:33  lampret
60
// Major clean-up.
61
//
62
// Revision 1.1  2001/07/20 00:46:03  lampret
63
// Development version of RTL. Libraries are missing.
64
//
65
//
66
 
67
// synopsys translate_off
68
`include "timescale.v"
69
// synopsys translate_on
70
`include "or1200_defines.v"
71
 
72
module or1200_lsu(
73
        // Clock and reset
74
        clk, rst,
75
 
76
        // Internal i/f
77
        addrbase, addrofs, lsu_op, lsu_datain, lsu_dataout, lsu_stall, lsu_unstall,
78
        du_stall, except_align, except_dtlbmiss, except_dmmufault, except_dbuserr,
79
 
80
        // External i/f to DC
81
        dcpu_adr_o, dcpu_cyc_o, dcpu_stb_o, dcpu_we_o, dcpu_sel_o, dcpu_tag_o, dcpu_dat_o,
82
        dcpu_dat_i, dcpu_ack_i, dcpu_rty_i, dcpu_err_i, dcpu_tag_i
83
);
84
 
85
parameter dw = `OR1200_OPERAND_WIDTH;
86
parameter aw = `OR1200_REGFILE_ADDR_WIDTH;
87
 
88
//
89
// I/O
90
//
91
 
92
//
93
// Clock and reset
94
//
95
input                           clk;
96
input                           rst;
97
 
98
//
99
// Internal i/f
100
//
101
input   [31:0]                   addrbase;
102
input   [31:0]                   addrofs;
103
input   [`OR1200_LSUOP_WIDTH-1:0]        lsu_op;
104
input   [dw-1:0]         lsu_datain;
105
output  [dw-1:0]         lsu_dataout;
106
output                          lsu_stall;
107
output                          lsu_unstall;
108
input                           du_stall;
109
output                          except_align;
110
output                          except_dtlbmiss;
111
output                          except_dmmufault;
112
output                          except_dbuserr;
113
 
114
//
115
// External i/f to DC
116
//
117
output  [31:0]                   dcpu_adr_o;
118
output                          dcpu_cyc_o;
119
output                          dcpu_stb_o;
120
output                          dcpu_we_o;
121
output  [3:0]                    dcpu_sel_o;
122
output  [3:0]                    dcpu_tag_o;
123
output  [31:0]                   dcpu_dat_o;
124
input   [31:0]                   dcpu_dat_i;
125
input                           dcpu_ack_i;
126
input                           dcpu_rty_i;
127
input                           dcpu_err_i;
128
input   [3:0]                    dcpu_tag_i;
129
 
130
//
131
// Internal wires/regs
132
//
133
reg     [3:0]                    dcpu_sel_o;
134
 
135
//
136
// Internal I/F assignments
137
//
138
assign lsu_stall = dcpu_rty_i & dcpu_cyc_o;
139
assign lsu_unstall = dcpu_ack_i;
140
assign except_align = ((lsu_op == `OR1200_LSUOP_SH) | (lsu_op == `OR1200_LSUOP_LHZ) | (lsu_op == `OR1200_LSUOP_LHS)) & dcpu_adr_o[0]
141
                |  ((lsu_op == `OR1200_LSUOP_SW) | (lsu_op == `OR1200_LSUOP_LWZ) | (lsu_op == `OR1200_LSUOP_LWS)) & |dcpu_adr_o[1:0];
142
assign except_dtlbmiss = dcpu_err_i & (dcpu_tag_i == `OR1200_DTAG_TE);
143
assign except_dmmufault = dcpu_err_i & (dcpu_tag_i == `OR1200_DTAG_PE);
144
assign except_dbuserr = dcpu_err_i & (dcpu_tag_i == `OR1200_DTAG_BE);
145
 
146
//
147
// External I/F assignments
148
//
149
assign dcpu_adr_o = addrbase + addrofs;
150
assign dcpu_cyc_o = du_stall | lsu_unstall ? 1'b0 : |lsu_op;
151
assign dcpu_stb_o = dcpu_cyc_o;
152
assign dcpu_we_o = lsu_op[3];
153
assign dcpu_tag_o = dcpu_cyc_o ? `OR1200_DTAG_ND : `OR1200_DTAG_IDLE;
154
always @(lsu_op or dcpu_adr_o)
155
        casex({lsu_op, dcpu_adr_o[1:0]})
156
                {`OR1200_LSUOP_SB, 2'b00} : dcpu_sel_o = 4'b1000;
157
                {`OR1200_LSUOP_SB, 2'b01} : dcpu_sel_o = 4'b0100;
158
                {`OR1200_LSUOP_SB, 2'b10} : dcpu_sel_o = 4'b0010;
159
                {`OR1200_LSUOP_SB, 2'b11} : dcpu_sel_o = 4'b0001;
160
                {`OR1200_LSUOP_SH, 2'b00} : dcpu_sel_o = 4'b1100;
161
                {`OR1200_LSUOP_SH, 2'b10} : dcpu_sel_o = 4'b0011;
162
                {`OR1200_LSUOP_SW, 2'b00} : dcpu_sel_o = 4'b1111;
163
                {`OR1200_LSUOP_LBZ, 2'b00}, {`OR1200_LSUOP_LBS, 2'b00} : dcpu_sel_o = 4'b1000;
164
                {`OR1200_LSUOP_LBZ, 2'b01}, {`OR1200_LSUOP_LBS, 2'b01} : dcpu_sel_o = 4'b0100;
165
                {`OR1200_LSUOP_LBZ, 2'b10}, {`OR1200_LSUOP_LBS, 2'b10} : dcpu_sel_o = 4'b0010;
166
                {`OR1200_LSUOP_LBZ, 2'b11}, {`OR1200_LSUOP_LBS, 2'b11} : dcpu_sel_o = 4'b0001;
167
                {`OR1200_LSUOP_LHZ, 2'b00}, {`OR1200_LSUOP_LHS, 2'b00} : dcpu_sel_o = 4'b1100;
168
                {`OR1200_LSUOP_LHZ, 2'b10}, {`OR1200_LSUOP_LHS, 2'b10} : dcpu_sel_o = 4'b0011;
169
                {`OR1200_LSUOP_LWZ, 2'b00}, {`OR1200_LSUOP_LWS, 2'b00} : dcpu_sel_o = 4'b1111;
170
                default : dcpu_sel_o = 4'b0000;
171
        endcase
172
 
173
//
174
// Instantiation of Memory-to-regfile aligner
175
//
176
or1200_mem2reg or1200_mem2reg(
177
        .addr(dcpu_adr_o[1:0]),
178
        .lsu_op(lsu_op),
179
        .memdata(dcpu_dat_i),
180
        .regdata(lsu_dataout)
181
);
182
 
183
//
184
// Instantiation of Regfile-to-memory aligner
185
//
186
or1200_reg2mem or1200_reg2mem(
187
        .addr(dcpu_adr_o[1:0]),
188
        .lsu_op(lsu_op),
189
        .regdata(lsu_datain),
190
        .memdata(dcpu_dat_o)
191
);
192
 
193
endmodule

powered by: WebSVN 2.1.0

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