source: XOpenSparcT1/trunk/T1-CPU/lsu/lsu_rrobin_picker2.v @ 6

Revision 6, 7.3 KB checked in by pntsvt00, 13 years ago (diff)

versione iniziale opensparc

Line 
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T1 Processor File: lsu_rrobin_picker2.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//      Description:    Round-Robin Picker for 4 eventss.
24//                      (see description of picker at the end of this file)
25*/
26////////////////////////////////////////////////////////////////////////
27// Global header file includes
28////////////////////////////////////////////////////////////////////////
29`include        "sys.h" // system level definition file which contains the
30                                        // time scale definition
31
32////////////////////////////////////////////////////////////////////////
33// Local header file includes / local defines
34////////////////////////////////////////////////////////////////////////   
35
36module lsu_rrobin_picker2 (/*AUTOARG*/
37   // Outputs
38   so, pick_one_hot, 
39   // Inputs
40   rclk, grst_l, arst_l, si, se, events, events_picked, thread_force
41   );
42
43input           rclk ;
44input           grst_l;
45input           arst_l;
46input           si;
47input           se;
48output          so;
49
50
51input   [3:0]   events ;                // multi-hot; events that could be chosen
52input   [3:0]   events_picked ;         // one-hot; events that were picked - same cycle as pick
53input   [3:0]   thread_force ;          // multi-hot; thread events that have high priority
54
55output  [3:0]   pick_one_hot ;          // one-hot
56
57wire         clk;
58wire         reset,dbb_reset_l ;
59   
60wire  [3:0]  thread_force_pe_mask ;
61wire  [3:0]  pick_thread_force_1hot ;
62wire         thread_force_events_sel ;
63
64wire  [3:0]  pick_rrobin_1hot, pick_rev_rrobin_1hot, pick_rrobin_1hot_mx ;
65wire         events_pick_dir_d1 ;
66wire         events_pick_dir ;
67wire  [3:0]  pick_rrobin_status_or_one_hot ;
68wire  [3:0]  pick_rrobin_din ;
69wire  [3:0]  pick_rrobin ;
70wire         pick_rrobin_reset ;
71wire         pick_rrobin_dir_upd ;
72wire  [3:0]  pick_rrobin_events ;
73
74   
75
76    dffrl_async rstff(.din (grst_l),
77                        .q   (dbb_reset_l),
78                        .clk (clk), .se(se), .si(), .so(),
79                        .rst_l (arst_l));
80
81assign  reset =  ~dbb_reset_l;
82assign  clk = rclk;
83
84
85//*******************************************************************************************************
86//PICK 
87//*******************************************************************************************************
88
89   //pick for thread force events
90assign  thread_force_events_sel = |(events[3:0] & thread_force[3:0]) ;
91
92assign  thread_force_pe_mask[3:0]  =  events[3:0] & thread_force[3:0] ;
93assign  pick_thread_force_1hot[0] = thread_force_pe_mask[0] ;
94assign  pick_thread_force_1hot[1] = thread_force_pe_mask[1] & ~thread_force_pe_mask[0] ;
95assign  pick_thread_force_1hot[2] = thread_force_pe_mask[2] & ~|thread_force_pe_mask[1:0] ;
96assign  pick_thread_force_1hot[3] = thread_force_pe_mask[3] & ~|thread_force_pe_mask[2:0] ;
97
98   //pick for round robin events
99assign  pick_rrobin_events[3:0]  =  events[3:0] & ~pick_rrobin[3:0] ;
100
101assign  pick_rrobin_1hot[0] = ~events_pick_dir_d1 & pick_rrobin_events[0] ;
102assign  pick_rrobin_1hot[1] = ~events_pick_dir_d1 & pick_rrobin_events[1] & ~pick_rrobin_events[0] ;
103assign  pick_rrobin_1hot[2] = ~events_pick_dir_d1 & pick_rrobin_events[2] & ~|pick_rrobin_events[1:0] ;
104assign  pick_rrobin_1hot[3] = ~events_pick_dir_d1 & pick_rrobin_events[3] & ~|pick_rrobin_events[2:0] ;
105
106   //pick for reverse round robin events
107assign  pick_rev_rrobin_1hot[0] = events_pick_dir_d1 & pick_rrobin_events[0] & ~|pick_rrobin_events[3:1] ;
108assign  pick_rev_rrobin_1hot[1] = events_pick_dir_d1 & pick_rrobin_events[1] & ~|pick_rrobin_events[3:2] ;
109assign  pick_rev_rrobin_1hot[2] = events_pick_dir_d1 & pick_rrobin_events[2] & ~|pick_rrobin_events[3] ;
110assign  pick_rev_rrobin_1hot[3] = events_pick_dir_d1 & pick_rrobin_events[3] ;
111
112assign  pick_rrobin_1hot_mx[3:0]  =  pick_rev_rrobin_1hot[3:0] | pick_rrobin_1hot[3:0] ;
113assign  pick_one_hot[3:0]    =  thread_force_events_sel ? pick_thread_force_1hot[3:0] : 
114                                                          pick_rrobin_1hot_mx[3:0] ;
115
116//*******************************************************************************************************
117
118
119
120//*******************************************************************************************************
121//PICK ROUND ROBIN (bug4814)
122//*******************************************************************************************************
123// this is used if there are no requests to be picked based on pick_status[3:0]
124
125assign pick_rrobin_status_or_one_hot[3:0] = pick_rrobin[3:0] | events_picked[3:0] ;
126assign pick_rrobin_reset = reset | ~|(events[3:0] & ~pick_rrobin_status_or_one_hot[3:0]) ;
127   //change direction bit only when events are non-zero
128assign pick_rrobin_dir_upd = |events[3:0] & (~|(events[3:0] & ~pick_rrobin_status_or_one_hot[3:0])) ;
129
130   // make reset dominant
131assign pick_rrobin_din[3:0] = pick_rrobin_status_or_one_hot[3:0] & ~{4{pick_rrobin_reset}};
132
133dff_s   #(4) ff_pick_rrobin (
134           .din    (pick_rrobin_din[3:0]),
135           .q      (pick_rrobin[3:0]    ),
136           .clk    (clk),
137           .se     (1'b0),       .si (),          .so ()
138            );
139//*******************************************************************************************************
140
141
142//*******************************************************************************************************
143// PICK DIRECTION
144//*******************************************************************************************************
145
146   //bug4609 - change direction of pick all events are picked in round robin pick
147   //          this is needed when the condition below occurs. assuming misc is less frequent
148   //          this should pick load/store in round robin fashion
149   //-------------------------------------------------------
150   // cycle                 0   1   2
151   //-------------------------------------------------------
152   // history{misc,st,ld}  010 011 011
153   // vld{misc,st,ld}      011 011 011
154   //-------------------------------------------------------
155
156assign events_pick_dir  =  ~reset &
157                           (( ~pick_rrobin_dir_upd & events_pick_dir_d1) |              //hold
158                            (  pick_rrobin_dir_upd & ~events_pick_dir_d1)) ;            //set - invert direction
159   
160   dff_s   #(1) ff_events_pick_dir (
161        .din    (events_pick_dir),
162        .q      (events_pick_dir_d1),
163        .clk    (clk),
164        .se     (1'b0),       .si (),          .so ()
165        );
166   
167//*******************************************************************************************************
168endmodule
Note: See TracBrowser for help on using the repository browser.