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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [or1200/] [rtl/] [verilog/] [or1200_freeze.v] - Blame information for rev 294

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

Line No. Rev Author Line
1 10 unneback
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OR1200's Freeze logic                                       ////
4
////                                                              ////
5
////  This file is part of the OpenRISC 1200 project              ////
6 258 julius
////  http://www.opencores.org/project,or1k                       ////
7 10 unneback
////                                                              ////
8
////  Description                                                 ////
9
////  Generates all freezes and stalls inside RISC                ////
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 141 marcus.erl
// $Log: or1200_freeze.v,v $
45
// Revision 2.0  2010/06/30 11:00:00  ORSoC
46
// Minor update: 
47
// Bugs fixed. 
48
//
49 10 unneback
 
50
// synopsys translate_off
51
`include "timescale.v"
52
// synopsys translate_on
53
`include "or1200_defines.v"
54
 
55
`define OR1200_NO_FREEZE        3'd0
56
`define OR1200_FREEZE_BYDC      3'd1
57
`define OR1200_FREEZE_BYMULTICYCLE      3'd2
58
`define OR1200_WAIT_LSU_TO_FINISH       3'd3
59
`define OR1200_WAIT_IC                  3'd4
60
 
61
//
62
// Freeze logic (stalls CPU pipeline, ifetcher etc.)
63
//
64 258 julius
module or1200_freeze
65
  (
66
   // Clock and reset
67
   clk, rst,
68
 
69
   // Internal i/f
70
   multicycle, wait_on, flushpipe, extend_flush, lsu_stall, if_stall,
71
   lsu_unstall, du_stall, mac_stall,
72
   force_dslot_fetch, abort_ex,
73
   genpc_freeze, if_freeze, id_freeze, ex_freeze, wb_freeze, saving_if_insn,
74
   fpu_done, mtspr_done,
75
   icpu_ack_i, icpu_err_i
76
   );
77 10 unneback
 
78
//
79
// I/O
80
//
81
input                           clk;
82
input                           rst;
83
input   [`OR1200_MULTICYCLE_WIDTH-1:0]   multicycle;
84 258 julius
input   [`OR1200_WAIT_ON_WIDTH-1:0]      wait_on;
85 10 unneback
input                           flushpipe;
86
input                           extend_flush;
87
input                           lsu_stall;
88
input                           if_stall;
89
input                           lsu_unstall;
90
input                           force_dslot_fetch;
91
input                           abort_ex;
92
input                           du_stall;
93
input                           mac_stall;
94
output                          genpc_freeze;
95
output                          if_freeze;
96
output                          id_freeze;
97
output                          ex_freeze;
98
output                          wb_freeze;
99 258 julius
input                           saving_if_insn;
100
input                           fpu_done;
101
input                           mtspr_done;
102 10 unneback
input                           icpu_ack_i;
103
input                           icpu_err_i;
104
 
105
//
106
// Internal wires and regs
107
//
108
wire                            multicycle_freeze;
109
reg     [`OR1200_MULTICYCLE_WIDTH-1:0]   multicycle_cnt;
110
reg                             flushpipe_r;
111 258 julius
reg [`OR1200_WAIT_ON_WIDTH-1:0]  waiting_on;
112
 
113 10 unneback
//
114
// Pipeline freeze
115
//
116
// Rules how to create freeze signals:
117
// 1. Not overwriting pipeline stages:
118 258 julius
// Freeze signals at the beginning of pipeline (such as if_freeze) can be 
119
// asserted more often than freeze signals at the of pipeline (such as 
120
// wb_freeze). In other words, wb_freeze must never be asserted when ex_freeze 
121
// is not. ex_freeze must never be asserted when id_freeze is not etc.
122 10 unneback
//
123
// 2. Inserting NOPs in the middle of pipeline only if supported:
124 258 julius
// At this time, only ex_freeze (and wb_freeze) can be deassrted when id_freeze
125
// (and if_freeze) are asserted.
126 10 unneback
// This way NOP is asserted from stage ID into EX stage.
127
//
128 258 julius
 
129 141 marcus.erl
assign genpc_freeze = (du_stall & !saving_if_insn) | flushpipe_r;
130 10 unneback
assign if_freeze = id_freeze | extend_flush;
131 258 julius
 
132
assign id_freeze = (lsu_stall | (~lsu_unstall & if_stall) | multicycle_freeze
133
                    | (|waiting_on) | force_dslot_fetch) | du_stall | mac_stall;
134 10 unneback
assign ex_freeze = wb_freeze;
135
 
136 258 julius
assign wb_freeze = (lsu_stall | (~lsu_unstall & if_stall) | multicycle_freeze
137
                    | (|waiting_on)) | du_stall | mac_stall | abort_ex;
138
 
139 10 unneback
//
140
// registered flushpipe
141
//
142
always @(posedge clk or posedge rst)
143
        if (rst)
144 258 julius
                flushpipe_r <=  1'b0;
145 10 unneback
        else if (icpu_ack_i | icpu_err_i)
146
//      else if (!if_stall)
147 258 julius
                flushpipe_r <=  flushpipe;
148 10 unneback
        else if (!flushpipe)
149 258 julius
                flushpipe_r <=  1'b0;
150 10 unneback
 
151
//
152
// Multicycle freeze
153
//
154
assign multicycle_freeze = |multicycle_cnt;
155
 
156
//
157
// Multicycle counter
158
//
159
always @(posedge clk or posedge rst)
160
        if (rst)
161 258 julius
                multicycle_cnt <=  2'b00;
162 10 unneback
        else if (|multicycle_cnt)
163 258 julius
                multicycle_cnt <=  multicycle_cnt - 2'd1;
164 10 unneback
        else if (|multicycle & !ex_freeze)
165 258 julius
                multicycle_cnt <=  multicycle;
166 10 unneback
 
167 258 julius
 
168
//
169
// Waiting on generation
170
//
171
always @(posedge clk or posedge rst)
172
  if (rst)
173
    waiting_on <= 0;
174
  else if ((waiting_on == `OR1200_WAIT_ON_FPU) & fpu_done)
175
    waiting_on <= 0;
176
  else if ((waiting_on == `OR1200_WAIT_ON_MTSPR) & mtspr_done)
177
    waiting_on <= 0;
178
  else if (!ex_freeze)
179
    waiting_on <= wait_on;
180
 
181
 
182 10 unneback
endmodule

powered by: WebSVN 2.1.0

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