1 |
2 |
dmitryr |
// ========== Copyright Header Begin ==========================================
|
2 |
|
|
//
|
3 |
|
|
// OpenSPARC T1 Processor File: sparc_exu_rndrob.v
|
4 |
|
|
// Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
|
5 |
|
|
// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
|
6 |
|
|
//
|
7 |
|
|
// The above named program is free software; you can redistribute it and/or
|
8 |
|
|
// modify it under the terms of the GNU General Public
|
9 |
|
|
// License version 2 as published by the Free Software Foundation.
|
10 |
|
|
//
|
11 |
|
|
// The above named program is distributed in the hope that it will be
|
12 |
|
|
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
|
|
// General Public License for more details.
|
15 |
|
|
//
|
16 |
|
|
// You should have received a copy of the GNU General Public
|
17 |
|
|
// License along with this work; if not, write to the Free Software
|
18 |
|
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
19 |
|
|
//
|
20 |
|
|
// ========== Copyright Header End ============================================
|
21 |
|
|
////////////////////////////////////////////////////////////////////////
|
22 |
|
|
/*
|
23 |
|
|
// Module Name: sparc_exu_rndrob
|
24 |
|
|
// Description:
|
25 |
|
|
// Round robin scheduler. Least priority to the last granted
|
26 |
|
|
// customer. If no requests, the priority remains the same.
|
27 |
|
|
*/
|
28 |
|
|
////////////////////////////////////////////////////////////////////////
|
29 |
|
|
|
30 |
|
|
module sparc_exu_rndrob(/*AUTOARG*/
|
31 |
|
|
// Outputs
|
32 |
|
|
grant_vec,
|
33 |
|
|
// Inputs
|
34 |
|
|
clk, reset, se, req_vec, advance
|
35 |
|
|
);
|
36 |
|
|
|
37 |
|
|
input clk, reset, se;
|
38 |
|
|
|
39 |
|
|
input [3:0] req_vec;
|
40 |
|
|
input advance;
|
41 |
|
|
|
42 |
|
|
output [3:0] grant_vec;
|
43 |
|
|
|
44 |
|
|
wire [3:0] pv,
|
45 |
|
|
next_pv,
|
46 |
|
|
park_vec;
|
47 |
|
|
|
48 |
|
|
|
49 |
|
|
assign next_pv = advance ? grant_vec : park_vec;
|
50 |
|
|
|
51 |
|
|
dffr_s #4 park_reg(.din (next_pv[3:0]),
|
52 |
|
|
.clk (clk),
|
53 |
|
|
.q (pv[3:0]),
|
54 |
|
|
.rst (reset),
|
55 |
|
|
.se (se), .si(), .so());
|
56 |
|
|
|
57 |
|
|
assign park_vec = pv;
|
58 |
|
|
|
59 |
|
|
// if noone requests, don't advance, otherwise we'll go back to 0
|
60 |
|
|
// and will not be fair to other requestors
|
61 |
|
|
assign grant_vec[0] = park_vec[3] & req_vec[0] |
|
62 |
|
|
park_vec[2] & ~req_vec[3] & req_vec[0] |
|
63 |
|
|
park_vec[1] & ~req_vec[2] & ~req_vec[3] & req_vec[0] |
|
64 |
|
|
~req_vec[1] & ~req_vec[2] & ~req_vec[3];
|
65 |
|
|
|
66 |
|
|
assign grant_vec[1] = park_vec[0] & req_vec[1] |
|
67 |
|
|
park_vec[3] & ~req_vec[0] & req_vec[1] |
|
68 |
|
|
park_vec[2] & ~req_vec[3] & ~req_vec[0] & req_vec[1] |
|
69 |
|
|
req_vec[1] & ~req_vec[2] & ~req_vec[3] & ~req_vec[0];
|
70 |
|
|
|
71 |
|
|
assign grant_vec[2] = park_vec[1] & req_vec[2] |
|
72 |
|
|
park_vec[0] & ~req_vec[1] & req_vec[2] |
|
73 |
|
|
park_vec[3] & ~req_vec[0] & ~req_vec[1] & req_vec[2] |
|
74 |
|
|
req_vec[2] & ~req_vec[3] & ~req_vec[0] & ~req_vec[1];
|
75 |
|
|
|
76 |
|
|
assign grant_vec[3] = park_vec[2] & req_vec[3] |
|
77 |
|
|
park_vec[1] & ~req_vec[2] & req_vec[3] |
|
78 |
|
|
park_vec[0] & ~req_vec[1] & ~req_vec[2] & req_vec[3] |
|
79 |
|
|
req_vec[3] & ~req_vec[0] & ~req_vec[1] & ~req_vec[2];
|
80 |
|
|
|
81 |
|
|
endmodule // sparc_exu_rndrob
|
82 |
|
|
|
83 |
|
|
|
84 |
|
|
|