OpenCores
URL https://opencores.org/ocsvn/an-fpga-implementation-of-low-latency-noc-based-mpsoc/an-fpga-implementation-of-low-latency-noc-based-mpsoc/trunk

Subversion Repositories an-fpga-implementation-of-low-latency-noc-based-mpsoc

[/] [an-fpga-implementation-of-low-latency-noc-based-mpsoc/] [trunk/] [mpsoc/] [src_processor/] [aeMB/] [verilog/] [src/] [aeMB_ibuf.v] - Blame information for rev 16

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 16 alirezamon
/* $Id: aeMB_ibuf.v,v 1.10 2008-01-21 01:02:26 sybreon Exp $
2
**
3
** AEMB INSTRUCTION BUFFER
4
** Copyright (C) 2004-2007 Shawn Tan Ser Ngiap <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
`timescale  1ns/1ps
22
module aeMB_ibuf (/*AUTOARG*/
23
   // Outputs
24
   rIMM, rRA, rRD, rRB, rALT, rOPC, rSIMM, xIREG, rSTALL, iwb_stb_o,
25
   // Inputs
26
   rBRA, rMSR_IE, rMSR_BIP, iwb_dat_i, iwb_ack_i, sys_int_i, gclk,
27
   grst, gena, oena
28
   );
29
   // INTERNAL
30
   output [15:0] rIMM;
31
   output [4:0]  rRA, rRD, rRB;
32
   output [10:0] rALT;
33
   output [5:0]  rOPC;
34
   output [31:0] rSIMM;
35
   output [31:0] xIREG;
36
   output        rSTALL;
37
 
38
   input         rBRA;
39
   //input [1:0]         rXCE;
40
   input         rMSR_IE;
41
   input         rMSR_BIP;
42
 
43
   // INST WISHBONE
44
   output        iwb_stb_o;
45
   input [31:0]  iwb_dat_i;
46
   input         iwb_ack_i;
47
 
48
   // SYSTEM
49
   input         sys_int_i;
50
 
51
   // SYSTEM
52
   input         gclk, grst, gena, oena;
53
 
54
   reg [15:0]     rIMM;
55
   reg [4:0]      rRA, rRD;
56
   reg [5:0]      rOPC;
57
 
58
   // FIXME: Endian
59
   wire [31:0]    wIDAT = iwb_dat_i;
60
   assign        {rRB, rALT} = rIMM;
61
 
62
   // TODO: Assign to FIFO not full.
63
   assign       iwb_stb_o = 1'b1;
64
 
65
   reg [31:0]    rSIMM, xSIMM;
66
   reg          rSTALL;
67
 
68
   wire [31:0]   wXCEOP = 32'hBA2D0008; // Vector 0x08
69
   wire [31:0]   wINTOP = 32'hB9CE0010; // Vector 0x10
70
   wire [31:0]   wBRKOP = 32'hBA0C0018; // Vector 0x18
71
   wire [31:0]   wBRAOP = 32'h88000000; // NOP for branches
72
 
73
   wire [31:0]   wIREG = {rOPC, rRD, rRA, rRB, rALT};
74
   reg [31:0]    xIREG;
75
 
76
 
77
   // --- INTERRUPT LATCH --------------------------------------
78
   // Debounce and latch onto the positive level. This is independent
79
   // of the pipeline so that stalls do not affect it.
80
 
81
   reg          rFINT;
82
   reg [1:0]     rDINT;
83
   wire         wSHOT = rDINT[0];
84
 
85
   always @(posedge gclk)
86
     if (grst) begin
87
        /*AUTORESET*/
88
        // Beginning of autoreset for uninitialized flops
89
        rDINT <= 2'h0;
90
        rFINT <= 1'h0;
91
        // End of automatics
92
     end else begin
93
        if (rMSR_IE)
94
          rDINT <= #1
95
                   {rDINT[0], sys_int_i};
96
 
97
        rFINT <= #1
98
                 //(wIREG == wINTOP) ? 1'b0 : 
99
                 (rFINT | wSHOT) & rMSR_IE;
100
     end
101
 
102
   wire         fIMM = (rOPC == 6'o54);
103
   wire         fRTD = (rOPC == 6'o55);
104
   wire         fBRU = ((rOPC == 6'o46) | (rOPC == 6'o56));
105
   wire         fBCC = ((rOPC == 6'o47) | (rOPC == 6'o57));
106
 
107
   // --- DELAY SLOT -------------------------------------------
108
 
109
   always @(/*AUTOSENSE*/fBCC or fBRU or fIMM or fRTD or rBRA or rFINT
110
            or wBRAOP or wIDAT or wINTOP) begin
111
      xIREG <= (rBRA) ? wBRAOP :
112
               (!fIMM & rFINT & !fRTD & !fBRU & !fBCC) ? wINTOP :
113
               wIDAT;
114
   end
115
 
116
   always @(/*AUTOSENSE*/fIMM or rBRA or rIMM or wIDAT or xIREG) begin
117
      xSIMM <= (!fIMM | rBRA) ? { {(16){xIREG[15]}}, xIREG[15:0]} :
118
               {rIMM, wIDAT[15:0]};
119
   end
120
 
121
   // --- PIPELINE --------------------------------------------
122
 
123
   always @(posedge gclk)
124
     if (grst) begin
125
        /*AUTORESET*/
126
        // Beginning of autoreset for uninitialized flops
127
        rIMM <= 16'h0;
128
        rOPC <= 6'h0;
129
        rRA <= 5'h0;
130
        rRD <= 5'h0;
131
        rSIMM <= 32'h0;
132
        // End of automatics
133
     end else if (gena) begin
134
        {rOPC, rRD, rRA, rIMM} <= #1 xIREG;
135
        rSIMM <= #1 xSIMM;
136
     end
137
 
138
   // --- STALL FOR MUL/BSF -----------------------------------
139
 
140
   wire [5:0] wOPC = xIREG[31:26];
141
 
142
   wire       fMUL = (wOPC == 6'o20) | (wOPC == 6'o30);
143
   wire       fBSF = (wOPC == 6'o21) | (wOPC == 6'o31);
144
 
145
   always @(posedge gclk)
146
     if (grst) begin
147
        /*AUTORESET*/
148
        // Beginning of autoreset for uninitialized flops
149
        rSTALL <= 1'h0;
150
        // End of automatics
151
     end else begin
152
        rSTALL <= #1 (!rSTALL & (fMUL | fBSF)) | (oena & rSTALL);
153
     end
154
 
155
endmodule // aeMB_ibuf
156
 
157
/*
158
 $Log: not supported by cvs2svn $
159
 Revision 1.9  2008/01/19 16:01:22  sybreon
160
 Patched problem where memory access followed by dual cycle instructions were not stalling correctly (submitted by M. Ettus)
161
 
162
 Revision 1.8  2007/12/25 22:15:09  sybreon
163
 Stalls pipeline on MUL/BSF instructions results in minor speed improvements.
164
 
165
 Revision 1.7  2007/11/22 15:11:15  sybreon
166
 Change interrupt to positive level triggered interrupts.
167
 
168
 Revision 1.6  2007/11/14 23:39:51  sybreon
169
 Fixed interrupt signal synchronisation.
170
 
171
 Revision 1.5  2007/11/14 22:14:34  sybreon
172
 Changed interrupt handling system (reported by M. Ettus).
173
 
174
 Revision 1.4  2007/11/10 16:39:38  sybreon
175
 Upgraded license to LGPLv3.
176
 Significant performance optimisations.
177
 
178
 Revision 1.3  2007/11/03 08:34:55  sybreon
179
 Minor code cleanup.
180
 
181
 Revision 1.2  2007/11/02 19:20:58  sybreon
182
 Added better (beta) interrupt support.
183
 Changed MSR_IE to disabled at reset as per MB docs.
184
 
185
 Revision 1.1  2007/11/02 03:25:40  sybreon
186
 New EDK 3.2 compatible design with optional barrel-shifter and multiplier.
187
 Fixed various minor data hazard bugs.
188
 Code compatible with -O0/1/2/3/s generated code.
189
*/

powered by: WebSVN 2.1.0

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