1 |
2 |
smjoshua |
//////////////////////////////////////////////////////////////////
|
2 |
|
|
// //
|
3 |
|
|
// OoOPs Core Instruction Dispatch module //
|
4 |
|
|
// //
|
5 |
|
|
// This file is part of the OoOPs project //
|
6 |
|
|
// http://www.opencores.org/project,oops //
|
7 |
|
|
// //
|
8 |
|
|
// Description: //
|
9 |
|
|
// Instruction dispatch block handles instruction register //
|
10 |
|
|
// renaming, and dependency checking, and dispatching //
|
11 |
|
|
// instructions to the ROB and appropriate Reservation Station.//
|
12 |
|
|
// Due to the structure of the map table, Dispatch is pipelined//
|
13 |
|
|
// into 2 stages: DS1 and DS2. //
|
14 |
|
|
// //
|
15 |
|
|
// DS1 stage will be for determining which checkpoint has the //
|
16 |
|
|
// latest valid mapping for a register, and for allocating the //
|
17 |
|
|
// destination physical register. //
|
18 |
|
|
// //
|
19 |
|
|
// DS2 stage will be for reading the map tables and dispatching//
|
20 |
|
|
// to the Reservation Stations. //
|
21 |
|
|
// //
|
22 |
|
|
// Author(s): //
|
23 |
|
|
// - Joshua Smith, smjoshua@umich.edu //
|
24 |
|
|
// //
|
25 |
|
|
//////////////////////////////////////////////////////////////////
|
26 |
|
|
// //
|
27 |
|
|
// Copyright (C) 2012 Authors and OPENCORES.ORG //
|
28 |
|
|
// //
|
29 |
|
|
// This source file may be used and distributed without //
|
30 |
|
|
// restriction provided that this copyright statement is not //
|
31 |
|
|
// removed from the file and that any derivative work contains //
|
32 |
|
|
// the original copyright notice and the associated disclaimer. //
|
33 |
|
|
// //
|
34 |
|
|
// This source file is free software; you can redistribute it //
|
35 |
|
|
// and/or modify it under the terms of the GNU Lesser General //
|
36 |
|
|
// Public License as published by the Free Software Foundation; //
|
37 |
|
|
// either version 2.1 of the License, or (at your option) any //
|
38 |
|
|
// later version. //
|
39 |
|
|
// //
|
40 |
|
|
// This source is distributed in the hope that it will be //
|
41 |
|
|
// useful, but WITHOUT ANY WARRANTY; without even the implied //
|
42 |
|
|
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //
|
43 |
|
|
// PURPOSE. See the GNU Lesser General Public License for more //
|
44 |
|
|
// details. //
|
45 |
|
|
// //
|
46 |
|
|
// You should have received a copy of the GNU Lesser General //
|
47 |
|
|
// Public License along with this source; if not, download it //
|
48 |
|
|
// from http://www.opencores.org/lgpl.shtml //
|
49 |
|
|
// //
|
50 |
|
|
//////////////////////////////////////////////////////////////////
|
51 |
|
|
`include "ooops_defs.v"
|
52 |
|
|
|
53 |
|
|
module ds_stage (
|
54 |
|
|
input wire clk,
|
55 |
|
|
input wire rst,
|
56 |
|
|
|
57 |
|
|
// Flush/stall interface
|
58 |
|
|
input wire rob_pipe_flush,
|
59 |
|
|
output wire ds_stall,
|
60 |
|
|
|
61 |
|
|
// Interface to ID stage
|
62 |
|
|
input wire id_ds1_valid,
|
63 |
|
|
input wire [`ADDR_SZ-1:0] id_ds1_fpc,
|
64 |
|
|
input wire id_ds1_in_dly_slot,
|
65 |
|
|
input wire [`DEC_BUS_SZ-1:0] id_ds1_dec_bus,
|
66 |
|
|
input wire [`BP_SZ-1:0] id_ds1_bprd_info,
|
67 |
|
|
|
68 |
|
|
// Interface to CDB (for tag monitoring)
|
69 |
|
|
input wire ex_cdb_valid,
|
70 |
|
|
input wire [`TAG_SZ-1:0] ex_cdb_tag,
|
71 |
|
|
input wire [`REG_IDX_SZ-1:0] ex_cdb_dest_idx,
|
72 |
|
|
|
73 |
|
|
// Interface to ROB
|
74 |
|
|
input wire rob_ds_full,
|
75 |
|
|
input wire [`ROB_PTR_SZ-1:0] rob_ds_tail_ptr,
|
76 |
|
|
input wire [`CHKPT_PTR_SZ-1:0] rob_ds_chkpt_ptr,
|
77 |
|
|
input wire [`FL_PTR_SZ-1:0] rob_ds_fl_head_ptr,
|
78 |
|
|
input wire rob_ds_ret_valid,
|
79 |
|
|
input wire rob_ds_ret_dest_write,
|
80 |
|
|
input wire rob_ds_ret_chkpt_free,
|
81 |
|
|
input wire [`REG_IDX_SZ-1:0] rob_ds_ret_idx,
|
82 |
|
|
input wire [`TAG_SZ-1:0] rob_ds_ret_tag,
|
83 |
|
|
input wire [`TAG_SZ-1:0] rob_ds_ret_tag_old,
|
84 |
|
|
output wire ds2_rob_valid,
|
85 |
|
|
output wire [`ADDR_SZ-1:0] ds2_rob_fpc,
|
86 |
|
|
output wire ds2_rob_in_dly_slot,
|
87 |
|
|
output wire [`DEC_BUS_SZ-1:0] ds2_rob_dec_bus,
|
88 |
|
|
output wire [`REN_BUS_SZ-1:0] ds2_rob_ren_info,
|
89 |
|
|
output wire [`BP_SZ-1:0] ds2_rob_bprd_info,
|
90 |
|
|
output wire [`CHKPT_PTR_SZ-1:0] ds2_rob_chkpt_ptr,
|
91 |
|
|
output wire [`FL_PTR_SZ-1:0] ds2_rob_fl_head_ptr,
|
92 |
|
|
|
93 |
|
|
// Interface to ALU RS
|
94 |
|
|
input wire rs_ds_alu_full,
|
95 |
|
|
output wire ds2_rs_alu_valid,
|
96 |
|
|
output wire [`ADDR_SZ-1:0] ds2_rs_alu_fpc,
|
97 |
|
|
output wire [`REN_BUS_SZ-1:0] ds2_rs_alu_ren_info,
|
98 |
|
|
output wire [`ALU_CTL_SZ-1:0] ds2_rs_alu_ctl,
|
99 |
|
|
output wire [`ROB_PTR_SZ-1:0] ds2_rs_alu_rob_ptr
|
100 |
|
|
|
101 |
|
|
// Interface to MULT/DIV RS
|
102 |
|
|
//input wire rs_ds_mult_div_full,
|
103 |
|
|
//output wire ds2_rs_mult_div_valid,
|
104 |
|
|
//output wire [`REN_BUS_SZ-1:0] ds2_rs_mult_div_ren_info,
|
105 |
|
|
//output wire [`MULTDIV_CTL_SZ-1:0] ds2_rs_mult_div_ctl,
|
106 |
|
|
//output wire [`ROB_PTR_SZ-1:0] ds2_rs_mult_div_rob_ptr,
|
107 |
|
|
|
108 |
|
|
//// Interface to LDST RS
|
109 |
|
|
//input wire rs_ds_ldst_full,
|
110 |
|
|
//output wire ds2_rs_ldst_valid,
|
111 |
|
|
//output wire [`REN_BUS_SZ-1:0] ds2_rs_ldst_ren_info,
|
112 |
|
|
//output wire [`LDST_CTL_SZ-1:0] ds2_rs_ldst_ctl,
|
113 |
|
|
//output wire [`ROB_PTR_SZ-1:0] ds2_rs_ldst_rob_ptr
|
114 |
|
|
);
|
115 |
|
|
|
116 |
|
|
// Internal wires/regs
|
117 |
|
|
// DS1 stage signals
|
118 |
|
|
wire [`REG_IDX_SZ-1:0] ds1_src1_idx, ds1_src2_idx, ds1_dest_idx;
|
119 |
|
|
wire ds1_dest_wr;
|
120 |
|
|
wire ds1_type_br;
|
121 |
|
|
|
122 |
|
|
// DS2 stage signals
|
123 |
|
|
wire ds2_valid;
|
124 |
|
|
wire [`ADDR_SZ-1:0] ds2_fpc;
|
125 |
|
|
wire ds2_in_dly_slot;
|
126 |
|
|
wire [`DEC_BUS_SZ-1:0] ds2_dec_bus;
|
127 |
|
|
wire [`BP_SZ-1:0] ds2_bprd_info;
|
128 |
|
|
wire [`TAG_SZ-1:0] ds2_src1_tag, ds2_src2_tag;
|
129 |
|
|
wire ds2_src1_valid, ds2_src2_valid;
|
130 |
|
|
wire [`TAG_SZ-1:0] ds2_dest_tag;
|
131 |
|
|
wire [`TAG_SZ-1:0] ds2_dest_tag_old;
|
132 |
|
|
wire [`REN_BUS_SZ-1:0] ds2_ren_info;
|
133 |
|
|
wire [`FL_PTR_SZ-1:0] ds2_fl_head_ptr;
|
134 |
|
|
|
135 |
|
|
// Handle stalling pipe for full ROB/RS
|
136 |
|
|
// Since the stall has to propagate back to IF/ID stages, we may need this
|
137 |
|
|
// to be an early signal (from a flop ideally). In this case we may need ID stage
|
138 |
|
|
// signals to determine the stall.
|
139 |
|
|
assign ds_stall = map_table_init | ds2_valid & (
|
140 |
|
|
rob_ds_full |
|
141 |
|
|
(rs_ds_alu_full & ds2_dec_bus[`DEC_TYPE_ALU]) |
|
142 |
|
|
(rs_ds_mult_div_full & ds2_dec_bus[`DEC_TYPE_MULTDIV]) |
|
143 |
|
|
(rs_ds_ldst_full & ds2_dec_bus[`DEC_TYPE_LDST]));
|
144 |
|
|
|
145 |
|
|
|
146 |
|
|
// Instantiate Map table for register renaming
|
147 |
|
|
// Note: for MULT/DIV we will use both rename ports for the single instruction
|
148 |
|
|
// because they write to both HI and LO.
|
149 |
|
|
assign ds1_src1_idx = id_ds1_dec_bus[`DEC_REG_S_IDX];
|
150 |
|
|
assign ds1_src2_idx = id_ds1_dec_bus[`DEC_REG_T_IDX];
|
151 |
|
|
assign ds1_dest_idx = id_ds1_dec_bus[`DEC_REG_D_IDX];
|
152 |
|
|
assign ds1_dest_wr = id_ds1_valid & id_ds1_dec_bus[`DEC_REG_D_WR] & !ds_stall;
|
153 |
|
|
assign ds1_type_br = id_ds1_valid & id_ds1_dec_bus[`DEC_TYPE_BR] & !ds_stall;
|
154 |
|
|
|
155 |
|
|
map_table mt0 (
|
156 |
|
|
.clk(clk),
|
157 |
|
|
.rst(rst),
|
158 |
|
|
.map_table_init(map_table_init),
|
159 |
|
|
|
160 |
|
|
.ds1_valid(id_ds1_valid),
|
161 |
|
|
.ds1_src1_idx(ds1_src1_idx),
|
162 |
|
|
.ds1_src2_idx(ds1_src2_idx),
|
163 |
|
|
.ds1_dest_idx(ds1_dest_idx),
|
164 |
|
|
.ds1_dest_wr(ds1_dest_wr),
|
165 |
|
|
.ds1_type_br(ds1_type_br),
|
166 |
|
|
.ds2_src1_tag(ds2_src1_tag),
|
167 |
|
|
.ds2_src2_tag(ds2_src2_tag),
|
168 |
|
|
.ds2_src1_valid(ds_src1_valid),
|
169 |
|
|
.ds2_src2_valid(ds_src2_valid),
|
170 |
|
|
.ds2_dest_tag(ds2_dest_tag),
|
171 |
|
|
.ds2_dest_tag_old(ds2_dest_tag_old),
|
172 |
|
|
.ds2_fl_head_ptr(ds2_fl_head_ptr),
|
173 |
|
|
.ds2_chkpt_ptr(ds2_rob_chkpt_ptr),
|
174 |
|
|
|
175 |
|
|
//.ex_cdb_bus(ex_cdb_bus),
|
176 |
|
|
.rob_pipe_flush(rob_pipe_flush),
|
177 |
|
|
.rob_ds_ret_valid(rob_ds_ret_valid),
|
178 |
|
|
.rob_ds_ret_dest_write(rob_ds_ret_dest_write),
|
179 |
|
|
.rob_ds_chkpt_ptr(rob_ds_chkpt_ptr),
|
180 |
|
|
.rob_ds_fl_head_ptr(rob_ds_fl_head_ptr),
|
181 |
|
|
.rob_ds_ret_chkpt_free(rob_ds_ret_chkpt_free),
|
182 |
|
|
.rob_ds_ret_idx(rob_ds_ret_idx),
|
183 |
|
|
.rob_ds_ret_tag(rob_ds_ret_tag),
|
184 |
|
|
.rob_ds_ret_tag_old(rob_ds_ret_tag_old)
|
185 |
|
|
);
|
186 |
|
|
|
187 |
|
|
// Flop info into DS2 stage
|
188 |
|
|
MDFFLR #(1) ds2_valid_ff (clk, rst, !ds_stall, 1'b0, id_ds1_valid, ds2_valid);
|
189 |
|
|
MDFFL #(`ADDR_SZ) ds2_fpc_ff (clk, id_ds1_valid, id_ds1_fpc, ds2_fpc);
|
190 |
|
|
MDFFLR #(1) ds2_in_dly_slot_ff (clk, rst, id_ds1_valid, 1'b0, id_ds1_in_dly_slot, ds2_in_dly_slot);
|
191 |
|
|
MDFFL #(`DEC_BUS_SZ) ds2_dec_bus_ff (clk, id_ds1_valid, id_ds1_dec_bus, ds2_dec_bus);
|
192 |
|
|
MDFFL #(`BP_SZ) ds2_bprd_info_ff (clk, id_ds1_valid, id_ds1_bprd_info, ds2_bprd_info);
|
193 |
|
|
|
194 |
|
|
|
195 |
|
|
// Construct dispatch packets to the different Reservation Stations
|
196 |
|
|
assign ds2_ren_info = { ds2_dec_bus[`DEC_REG_D_IDX], // DEST_IDX
|
197 |
|
|
ds2_dec_bus[`DEC_REG_D_WR], // DEST_VLD
|
198 |
|
|
ds2_dest_tag_old, // DEST_TAG_OLD
|
199 |
|
|
ds2_dest_tag, // DEST_TAG
|
200 |
|
|
ds2_src2_valid, // SRC2_VLD
|
201 |
|
|
ds2_dec_bus[`DEC_REG_T_NEED], // SRC2_NEED
|
202 |
|
|
ds2_src2_tag, // SRC2_TAG
|
203 |
|
|
ds2_src1_valid, // SRC1_VLD
|
204 |
|
|
ds2_dec_bus[`DEC_REG_S_NEED], // SRC1_NEED
|
205 |
|
|
ds2_src1_tag // SRC1_TAG
|
206 |
|
|
};
|
207 |
|
|
|
208 |
|
|
// Handle outputs to ROB
|
209 |
|
|
assign ds_rob_valid = ds2_valid;
|
210 |
|
|
assign ds_rob_fpc = ds2_fpc;
|
211 |
|
|
assign ds_rob_in_dly_slot = ds2_in_dly_slot;
|
212 |
|
|
assign ds_rob_dec_bus = ds2_dec_bus;
|
213 |
|
|
assign ds_rob_ren_info = ds2_ren_info;
|
214 |
|
|
assign ds_rob_bprd_info = ds2_bprd_info;
|
215 |
|
|
assign ds_rob_fl_head_ptr = ds2_fl_head_ptr;
|
216 |
|
|
|
217 |
|
|
// Handle outputs to ALU RS
|
218 |
|
|
assign ds2_rs_alu_valid = ds2_valid & ds2_dec_bus[`DEC_TYPE_ALU] & !ds_stall;
|
219 |
|
|
assign ds2_rs_alu_fpc = ds2_fpc;
|
220 |
|
|
assign ds2_rs_alu_ren_info = ds2_ren_info;
|
221 |
|
|
assign ds2_rs_alu_rob_ptr = rob_ds_tail_ptr;
|
222 |
|
|
|
223 |
|
|
endmodule
|