1 |
2 |
smjoshua |
//////////////////////////////////////////////////////////////////
|
2 |
|
|
// //
|
3 |
|
|
// OoOPs Core Register Free List module //
|
4 |
|
|
// //
|
5 |
|
|
// This file is part of the OoOPs project //
|
6 |
|
|
// http://www.opencores.org/project,oops //
|
7 |
|
|
// //
|
8 |
|
|
// Description: //
|
9 |
|
|
// The free list is a circular FIFO used to keep track of free //
|
10 |
|
|
// physical registers that can be allocated to new instructions//
|
11 |
|
|
// New tags are allocated from the head and freed tags are //
|
12 |
|
|
// written to the tail of the FIFO. //
|
13 |
|
|
// The head pointer+1 is passed along with branches so that //
|
14 |
|
|
// The FIFO state can be recovered after a misprediction. //
|
15 |
|
|
// //
|
16 |
|
|
// Note: MULT/DIV instructions will require two tags since //
|
17 |
|
|
// they update both HI and LO registers. //
|
18 |
|
|
// //
|
19 |
|
|
// Author(s): //
|
20 |
|
|
// - Joshua Smith, smjoshua@umich.edu //
|
21 |
|
|
// //
|
22 |
|
|
//////////////////////////////////////////////////////////////////
|
23 |
|
|
// //
|
24 |
|
|
// Copyright (C) 2012 Authors and OPENCORES.ORG //
|
25 |
|
|
// //
|
26 |
|
|
// This source file may be used and distributed without //
|
27 |
|
|
// restriction provided that this copyright statement is not //
|
28 |
|
|
// removed from the file and that any derivative work contains //
|
29 |
|
|
// the original copyright notice and the associated disclaimer. //
|
30 |
|
|
// //
|
31 |
|
|
// This source file is free software; you can redistribute it //
|
32 |
|
|
// and/or modify it under the terms of the GNU Lesser General //
|
33 |
|
|
// Public License as published by the Free Software Foundation; //
|
34 |
|
|
// either version 2.1 of the License, or (at your option) any //
|
35 |
|
|
// later version. //
|
36 |
|
|
// //
|
37 |
|
|
// This source is distributed in the hope that it will be //
|
38 |
|
|
// useful, but WITHOUT ANY WARRANTY; without even the implied //
|
39 |
|
|
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //
|
40 |
|
|
// PURPOSE. See the GNU Lesser General Public License for more //
|
41 |
|
|
// details. //
|
42 |
|
|
// //
|
43 |
|
|
// You should have received a copy of the GNU Lesser General //
|
44 |
|
|
// Public License along with this source; if not, download it //
|
45 |
|
|
// from http://www.opencores.org/lgpl.shtml //
|
46 |
|
|
// //
|
47 |
|
|
//////////////////////////////////////////////////////////////////
|
48 |
|
|
`include "ooops_defs.v"
|
49 |
|
|
|
50 |
|
|
// TODO: consider making this a bit-vector-based free list to save on
|
51 |
|
|
// flop usage. With tag FIFO, we have (`ARCH_REGS+`ROB_SZ)*`TAG_SZ flops
|
52 |
|
|
// just for the storage.
|
53 |
|
|
module free_list (
|
54 |
|
|
input wire clk,
|
55 |
|
|
input wire rst,
|
56 |
|
|
input wire ds1_dest_wr,
|
57 |
|
|
|
58 |
|
|
input wire rob_pipe_flush,
|
59 |
|
|
input wire [`FL_PTR_SZ-1:0] rob_ds_fl_head_ptr,
|
60 |
|
|
input wire rob_ds_ret_valid,
|
61 |
|
|
input wire rob_ds_ret_dest_write,
|
62 |
|
|
input wire [`TAG_SZ-1:0] rob_ds_ret_tag_old,
|
63 |
|
|
|
64 |
|
|
output wire [`TAG_SZ-1:0] ds1_dest_tag,
|
65 |
|
|
output wire [`FL_PTR_SZ-1:0] ds1_fl_head_ptr
|
66 |
|
|
);
|
67 |
|
|
|
68 |
|
|
// Internal wires/regs
|
69 |
|
|
wire [`TAG_SZ-1:0] tag_list [`FL_SZ-1:0];
|
70 |
|
|
wire [`TAG_SZ-1:0] tag_list_in [`FL_SZ-1:0];
|
71 |
|
|
wire [`FL_SZ-1:0] tag_list_ld;
|
72 |
|
|
wire [`FL_PTR_SZ-1:0] head_ptr;
|
73 |
|
|
wire [`FL_PTR_SZ-1:0] head_ptr_p1;
|
74 |
|
|
wire [`FL_PTR_SZ-1:0] head_ptr_p2;
|
75 |
|
|
wire [`FL_PTR_SZ-1:0] head_ptr_in;
|
76 |
|
|
wire [`FL_PTR_SZ-1:0] tail_ptr;
|
77 |
|
|
wire [`FL_PTR_SZ-1:0] tail_ptr_p1;
|
78 |
|
|
wire [`FL_PTR_SZ-1:0] tail_ptr_in;
|
79 |
|
|
wire pop;
|
80 |
|
|
wire push;
|
81 |
|
|
wire [`FL_PTR_SZ-1:0] rob_ds_fl_head_ptr_p1;
|
82 |
|
|
wire [`TAG_SZ-1:0] ds1_dest_tag_in;
|
83 |
|
|
wire [`FL_PTR_SZ-1:0] ds1_fl_head_ptr_in;
|
84 |
|
|
integer i;
|
85 |
|
|
|
86 |
|
|
// Handle output generation
|
87 |
|
|
// For timing, make dest_tag and fl_head_ptr available from a flop.
|
88 |
|
|
// TODO: verify corner cases such as free list becomes empty (so next head_ptr is tail_ptr) and instruction retiring.
|
89 |
|
|
assign ds1_dest_tag_in = rob_pipe_flush ? tag_list[rob_ds_fl_head_ptr] :
|
90 |
|
|
//(head_ptr_p1 == tail_ptr) & push ? rob_ds_ret_tag_old :
|
91 |
|
|
tag_list[head_ptr_p1]; // ds1_dest_wr case
|
92 |
|
|
|
93 |
|
|
assign rob_ds_fl_head_ptr_p1 = (rob_ds_fl_head_ptr == `FL_SZ-1) ? {`FL_PTR_SZ{1'b0}} : rob_ds_fl_head_ptr + `FL_PTR_SZ'h1;
|
94 |
|
|
assign ds1_fl_head_ptr_in = rob_pipe_flush ? rob_ds_fl_head_ptr_p1 : head_ptr_p2;
|
95 |
|
|
|
96 |
|
|
MDFFLR #(`TAG_SZ) ds1_dest_tag_ff (clk, rst, pop | rob_pipe_flush, `ARCH_REGS, ds1_dest_tag_in, ds1_dest_tag);
|
97 |
|
|
MDFFLR #(`FL_PTR_SZ) ds1_fl_head_ptr_ff (clk, rst, pop | rob_pipe_flush, `ARCH_REGS+1, ds1_fl_head_ptr_in, ds1_fl_head_ptr);
|
98 |
|
|
|
99 |
|
|
|
100 |
|
|
// Handle updating head/tail pointers
|
101 |
|
|
assign pop = ds1_dest_wr;
|
102 |
|
|
assign push = rob_ds_ret_valid & rob_ds_ret_dest_write;
|
103 |
|
|
assign head_ptr_p1 = (head_ptr == `FL_SZ-1) ? {`FL_PTR_SZ{1'b0}} : head_ptr + `FL_PTR_SZ'h1;
|
104 |
|
|
assign head_ptr_p2 = (head_ptr == `FL_SZ-2) ? {`FL_PTR_SZ{1'b0}} : head_ptr + `FL_PTR_SZ'h2;
|
105 |
|
|
assign tail_ptr_p1 = (tail_ptr == `FL_SZ-1) ? {`FL_PTR_SZ{1'b0}} : tail_ptr + `FL_PTR_SZ'h1;
|
106 |
|
|
assign head_ptr_in = (rob_pipe_flush) ? rob_ds_fl_head_ptr : head_ptr_p1;
|
107 |
|
|
assign tail_ptr_in = tail_ptr_p1;
|
108 |
|
|
|
109 |
|
|
// Initialize head pointer to NUM_ARCH_REGS because architected registers will
|
110 |
|
|
// be allocated out of reset.
|
111 |
|
|
MDFFLR #(`FL_PTR_SZ) head_ptr_ff (clk, rst, pop | rob_pipe_flush, `ARCH_REGS, head_ptr_in, head_ptr);
|
112 |
|
|
MDFFLR #(`FL_PTR_SZ) tail_ptr_ff (clk, rst, push, {`FL_PTR_SZ{1'b0}}, tail_ptr_in, tail_ptr);
|
113 |
|
|
|
114 |
|
|
// Handle updating list
|
115 |
|
|
// Reset list so that physical registers beyond 33 are initialized into free list
|
116 |
|
|
assign tag_list_ld = (push << tail_ptr);
|
117 |
|
|
genvar g;
|
118 |
|
|
generate
|
119 |
|
|
for (g=0; g<`FL_SZ; g=g+1) begin: fl_gen
|
120 |
|
|
assign tag_list_in[g] = rob_ds_ret_tag_old;
|
121 |
|
|
if (g < `ARCH_REGS)
|
122 |
|
|
MDFFLR #(`TAG_SZ) tag_list_ff (clk, rst, tag_list_ld[g], `TAG_SZ'h0, tag_list_in[g], tag_list[g]);
|
123 |
|
|
else
|
124 |
|
|
MDFFLR #(`TAG_SZ) tag_list_ff (clk, rst, tag_list_ld[g], g[`TAG_SZ-1:0], tag_list_in[g], tag_list[g]);
|
125 |
|
|
end
|
126 |
|
|
endgenerate
|
127 |
|
|
|
128 |
|
|
endmodule
|