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

Subversion Repositories aemb

[/] [aemb/] [trunk/] [rtl/] [verilog/] [aeMB2_dwbif.v] - Blame information for rev 127

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

Line No. Rev Author Line
1 127 sybreon
/* $Id: aeMB2_dwbif.v,v 1.4 2008-04-23 14:18:52 sybreon Exp $
2 118 sybreon
**
3
** AEMB2 EDK 6.2 COMPATIBLE CORE
4
** Copyright (C) 2004-2008 Shawn Tan <shawn.tan@aeste.net>
5
**
6
** This file is part of AEMB.
7
**
8
** AEMB is free software: you can redistribute it and/or modify it
9
** under the terms of the GNU Lesser General Public License as
10
** published by the Free Software Foundation, either version 3 of the
11
** License, or (at your option) any later version.
12
**
13
** AEMB is distributed in the hope that it will be useful, but WITHOUT
14
** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15
** or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
16
** Public License for more details.
17
**
18
** You should have received a copy of the GNU Lesser General Public
19
** License along with AEMB. If not, see <http:**www.gnu.org/licenses/>.
20
*/
21
 
22
/**
23
 * Data Wishbone Interface
24
 * @file aeMB2_dwbif.v
25
 
26
 * This sets up the Wishbone control signals for the DATA bus
27
   interfaces. Bus transactions are independent of the pipeline.
28
 
29
 */
30
 
31
module aeMB2_dwbif (/*AUTOARG*/
32
   // Outputs
33
   dwb_adr_o, dwb_sel_o, dwb_stb_o, dwb_cyc_o, dwb_tag_o, dwb_wre_o,
34
   dwb_dat_o, dwb_fb, sel_mx, dwb_mx,
35
   // Inputs
36
   dwb_dat_i, dwb_ack_i, imm_of, opd_of, opc_of, opa_of, opb_of,
37 125 sybreon
   msr_ex, mem_ex, sfr_mx, gclk, grst, dena, gpha
38 118 sybreon
   );
39
   parameter AEMB_DWB = 32; ///< data bus address width   
40
 
41
   // DWB control signals
42
   output [AEMB_DWB-1:2] dwb_adr_o;
43
   output [3:0]   dwb_sel_o;
44
   output                dwb_stb_o,
45
                         dwb_cyc_o,
46
                         dwb_tag_o, // cache enable
47
                         dwb_wre_o;
48
   output [31:0]          dwb_dat_o;
49
   input [31:0]   dwb_dat_i;
50
   input                 dwb_ack_i;
51
 
52
   // INTERNAL
53
   output                dwb_fb;
54
   output [3:0]   sel_mx;
55
   output [31:0]          dwb_mx;
56
   input [15:0]   imm_of;
57
   input [31:0]   opd_of;
58
   input [5:0]            opc_of;
59
   input [1:0]            opa_of;
60
   input [1:0]            opb_of;
61
   input [7:0]            msr_ex;
62
   input [AEMB_DWB-1:2]  mem_ex;
63 125 sybreon
   input [5:7]           sfr_mx;
64 118 sybreon
 
65
   // SYS signals
66
   input                 gclk,
67
                         grst,
68
                         dena,
69
                         gpha;
70
 
71
   /*AUTOREG*/
72
   // Beginning of automatic regs (for this module's undeclared outputs)
73
   reg                  dwb_cyc_o;
74
   reg [31:0]            dwb_dat_o;
75
   reg [31:0]            dwb_mx;
76
   reg [3:0]             dwb_sel_o;
77
   reg                  dwb_stb_o;
78
   reg                  dwb_wre_o;
79
   reg [3:0]             sel_mx;
80
   // End of automatics
81
 
82
   wire [1:0]            wOFF = (opa_of[1:0] + opb_of[1:0]);
83
   wire [3:0]            wSEL = {opc_of[1:0], wOFF};
84
 
85
   // ENABLE FEEDBACK
86 120 sybreon
   assign               dwb_fb = (dwb_stb_o ~^ dwb_ack_i);
87 118 sybreon
 
88
   // DATA bus
89
   assign               dwb_adr_o = mem_ex; // passthru
90
 
91 125 sybreon
   // STORE SIZER
92
   // TODO: Move the right words to the right place
93
   // TODO: Make this work with dwb_mx to for partial word loads.
94
 
95
   reg [31:0]            opd_ex;
96 118 sybreon
   always @(posedge gclk)
97
     if (grst) begin
98
        /*AUTORESET*/
99
        // Beginning of autoreset for uninitialized flops
100
        dwb_dat_o <= 32'h0;
101 125 sybreon
        opd_ex <= 32'h0;
102 118 sybreon
        // End of automatics
103 125 sybreon
     end else if (dena) begin
104
        opd_ex <= #1 opd_of;
105
 
106 118 sybreon
        case (opc_of[1:0])
107
          2'o0: dwb_dat_o <= #1 {(4){opd_of[7:0]}};
108
          2'o1: dwb_dat_o <= #1 {(2){opd_of[15:0]}};
109
          2'o2: dwb_dat_o <= #1 opd_of;
110
          default: dwb_dat_o <= #1 32'hX;
111
        endcase // case (opc_of[1:0])
112
     end // if (dena)   
113
 
114
   // WISHBONE PIPELINE
115
   always @(posedge gclk)
116
     if (grst) begin
117
        /*AUTORESET*/
118
        // Beginning of autoreset for uninitialized flops
119
        dwb_sel_o <= 4'h0;
120
        dwb_wre_o <= 1'h0;
121
        sel_mx <= 4'h0;
122
        // End of automatics
123
     end else if (dena) begin
124 125 sybreon
        sel_mx <= #1 dwb_sel_o; // FIXME: do away with this! Combine
125
                                // dwb_dat_o & dwb_mx. dwb_dat_o can
126
                                // hold the existing RD value and have
127
                                // dwb_mx latch the correct bytes
128
                                // depending on dwb_sel_o.
129
 
130 118 sybreon
        dwb_wre_o <= #1 opc_of[2]; // SXX
131 127 sybreon
 
132
        // FIXME: May clash during cache refills
133
        dwb_mx <= #1 (dwb_ack_i) ?  dwb_dat_i : dwb_lat;
134 118 sybreon
 
135
        case (wSEL)
136
          // 32'bit
137
          4'h8: dwb_sel_o <= #1 4'hF;
138
          // 16'bit
139
          4'h4: dwb_sel_o <= #1 4'hC;
140
          4'h6: dwb_sel_o <= #1 4'h3;
141
          // 8'bit
142
          4'h0: dwb_sel_o <= #1 4'h8;
143
          4'h1: dwb_sel_o <= #1 4'h4;
144
          4'h2: dwb_sel_o <= #1 4'h2;
145
          4'h3: dwb_sel_o <= #1 4'h1;
146
          // TODO: ILLEGAL
147
          default: dwb_sel_o <= #1 4'hX;
148
        endcase // case (wSEL)
149
     end // if (dena)
150
 
151 127 sybreon
   // Independent on pipeline
152
 
153
   reg [31:0] dwb_lat;
154 118 sybreon
   always @(posedge gclk)
155
     if (grst) begin
156
        /*AUTORESET*/
157
        // Beginning of autoreset for uninitialized flops
158 127 sybreon
        dwb_lat <= 32'h0;
159
        dwb_mx <= 32'h0;
160
        // End of automatics
161
     end else if (dwb_stb_o & dwb_ack_i) begin
162
        // LATCH READS
163
        dwb_lat <= #1 dwb_dat_i;
164
     end
165
 
166
   always @(posedge gclk)
167
     if (grst) begin
168
        /*AUTORESET*/
169
        // Beginning of autoreset for uninitialized flops
170 118 sybreon
        dwb_cyc_o <= 1'h0;
171
        dwb_stb_o <= 1'h0;
172
        // End of automatics
173 127 sybreon
     end else if (dwb_fb) begin
174 118 sybreon
        dwb_stb_o <= #1
175
                     (dena) ? &opc_of[5:4] : // LXX/SSS
176
                     (dwb_stb_o & !dwb_ack_i); // LXX/SSS
177
        dwb_cyc_o <= #1
178
                     (dena) ? &opc_of[5:4] | msr_ex[0] :
179
                     (dwb_stb_o & !dwb_ack_i) | msr_ex[0];
180
     end
181 125 sybreon
 
182
   assign dwb_tag_o = msr_ex[7]; // MSR_DCE     
183 118 sybreon
 
184
endmodule // aeMB2_memif
185
 
186 120 sybreon
// $Log: not supported by cvs2svn $
187 127 sybreon
// Revision 1.3  2008/04/21 12:11:38  sybreon
188
// Passes arithmetic tests with single thread.
189
//
190 125 sybreon
// Revision 1.2  2008/04/20 16:34:32  sybreon
191
// Basic version with some features left out.
192
//
193 120 sybreon
// Revision 1.1  2008/04/18 00:21:52  sybreon
194
// Initial import.
195
//

powered by: WebSVN 2.1.0

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