source: XOpenSparcT1/trunk/os2wb/l1dir.v @ 6

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

versione iniziale opensparc

Line 
1module l1dir(
2   input clk,
3   input reset,
4   
5   input        cpu,     // Issuing CPU number
6   input        strobe,  // Start transaction
7   input [ 1:0] way,     // Way to allocate for allocating loads
8   input [39:0] address,
9   input        load,
10   input        ifill,
11   input        store,
12   input        cas,
13   input        swap,
14   input        strload,
15   input        strstore,
16   input        cacheable,
17   input        prefetch,
18   input        invalidate,
19   input        blockstore,
20   
21   output [111:0] inval_vect0,    // Invalidation vector
22   output [111:0] inval_vect1,   
23   output [  1:0] othercachehit, // Other cache hit in the same CPU, wayval0/wayval1
24   output [  1:0] othercpuhit,   // Any cache hit in the other CPU, wayval0/wayval1
25   output [  1:0] wayval0,       // Way valid
26   output [  1:0] wayval1,       // Second way valid for ifill
27   output         ready         // Directory init done   
28);
29
30wire [3:0] rdy;
31wire dquery0=(!cpu) && store && (!blockstore);
32wire dquery1=  cpu  && store && (!blockstore);
33wire dalloc0=(!cpu) && cacheable && (!invalidate) && load && (!prefetch);
34wire dalloc1=  cpu  && cacheable && (!invalidate) && load && (!prefetch);
35wire ddealloc0=((!cpu) && ((ifill && (!prefetch) && (!invalidate)) || cas || swap || strstore || (store && blockstore))) ||
36               (  cpu  && ((load && cacheable && (!prefetch) && (!invalidate)) || (ifill && (!prefetch) && (!invalidate)) || store || cas || swap || strload || strstore));
37wire ddealloc1=(  cpu  && ((ifill && (!prefetch) && (!invalidate)) || cas || swap || strstore || (store && blockstore))) ||
38               ((!cpu) && ((load && cacheable && (!prefetch) && (!invalidate)) || (ifill && (!prefetch) && (!invalidate)) || store || cas || swap || strload || strstore));
39
40wire iquery0=0;
41wire iquery1=0;
42wire ialloc0=(!cpu) && cacheable && (!invalidate) && ifill;
43wire ialloc1=  cpu  && cacheable && (!invalidate) && ifill;
44wire idealloc0=((!cpu) && ((load && cacheable && (!prefetch) && (!invalidate))          || store || cas || swap || strstore)) ||
45               (  cpu  && ((load && cacheable && (!prefetch) && (!invalidate)) || (ifill && (!prefetch) && (!invalidate)) || store || cas || swap || strload || strstore));
46wire idealloc1=(  cpu  && ((load && cacheable && (!prefetch) && (!invalidate))          || store || cas || swap || strstore )) ||
47               ((!cpu) && ((load && cacheable && (!prefetch) && (!invalidate)) || (ifill && (!prefetch) && (!invalidate)) || store || cas || swap || strload || strstore));
48
49
50wire [2:0] cpu0_dhit0;
51wire [2:0] cpu0_dhit1;
52wire [2:0] cpu1_dhit0;
53wire [2:0] cpu1_dhit1;
54wire [2:0] cpu0_ihit;
55wire [2:0] cpu1_ihit;
56wire invalidate_d=invalidate && load;
57wire invalidate_i=invalidate && ifill;
58
59reg        ifill_d;
60reg        load_d;
61reg        cacheable_d;
62reg        cpu_d;
63reg [39:0] address_d;
64reg        strobe_d;
65reg        strobe_d1;
66reg        strobe_d2;
67
68always @(posedge clk)
69   begin
70      strobe_d<=strobe;
71      strobe_d1<=strobe_d;
72      strobe_d2<=strobe_d1;
73   end
74   
75always @(posedge clk)
76   if(strobe)
77      begin
78         ifill_d<=ifill;
79         load_d<=load;
80         cacheable_d<=cacheable;
81         cpu_d<=cpu;
82         address_d<=address;
83      end
84
85l1ddir cpu0_ddir(
86   .clk(clk),
87   .reset(reset),
88   
89   .index(address[10:4]),
90   .way(way),
91   .tag(address[39:11]),
92        .strobe(strobe),
93   .query(dquery0),
94   .allocate(dalloc0),
95   .deallocate(ddealloc0),
96   .dualdealloc(ifill),
97   .invalidate(invalidate_d && !cpu),
98   
99   .hit0(cpu0_dhit0),
100   .hit1(cpu0_dhit1),
101   
102   .ready(rdy[0])
103);
104
105l1ddir cpu1_ddir(
106   .clk(clk),
107   .reset(reset),
108   
109   .index(address[10:4]),
110   .way(way),
111   .tag(address[39:11]),
112        .strobe(strobe),
113   .query(dquery1),
114   .allocate(dalloc1),
115   .deallocate(ddealloc1),
116   .dualdealloc(ifill),
117   .invalidate(invalidate_d && cpu),
118   
119   .hit0(cpu1_dhit0),
120   .hit1(cpu1_dhit1),
121   
122   .ready(rdy[1])
123);
124
125l1idir cpu0_idir(
126   .clk(clk),
127   .reset(reset),
128   
129   .index(address[11:5]),
130   .way(way),
131   .tag(address[39:12]),
132        .strobe(strobe),
133   .query(iquery0),
134   .allocate(ialloc0),
135   .deallocate(idealloc0),
136   .invalidate(invalidate_i && !cpu),
137   
138   .hit(cpu0_ihit),
139   
140   .ready(rdy[2])
141);
142
143l1idir cpu1_idir(
144   .clk(clk),
145   .reset(reset),
146   
147   .index(address[11:5]),
148   .way(way),
149   .tag(address[39:12]),
150        .strobe(strobe),
151   .query(iquery1),
152   .allocate(ialloc1),
153   .deallocate(idealloc1),
154   .invalidate(invalidate_i && cpu),
155   
156   .hit(cpu1_ihit),
157   
158   .ready(rdy[3])
159);
160
161assign ready=(!rdy[0] | !rdy[1] | !rdy[2] | !rdy[3]) ? 0:1;
162assign inval_vect0[3:0]={wayval0,cpu0_ihit[2] && (!address_d[5]),cpu0_dhit0[2] && (address_d[5:4]==2'b00)};
163assign inval_vect0[7:4]={wayval0,cpu1_ihit[2] && (!address_d[5]),cpu1_dhit0[2] && (address_d[5:4]==2'b00)};
164assign inval_vect0[31:8]=0;
165assign inval_vect0[34:32]={wayval0,cpu0_dhit0[2] && (address_d[5:4]==2'b01)};
166assign inval_vect0[37:35]={wayval0,cpu1_dhit0[2] && (address_d[5:4]==2'b01)};
167assign inval_vect0[55:38]=0;
168assign inval_vect0[59:56]={wayval0,cpu0_ihit[2] && address_d[5],cpu0_dhit0[2] && (address_d[5:4]==2'b10)};
169assign inval_vect0[63:60]={wayval0,cpu1_ihit[2] && address_d[5],cpu1_dhit0[2] && (address_d[5:4]==2'b10)};
170assign inval_vect0[87:64]=0;
171assign inval_vect0[90:88]={wayval0,cpu0_dhit0[2] && (address_d[5:4]==2'b11)};
172assign inval_vect0[93:91]={wayval0,cpu1_dhit0[2] && (address_d[5:4]==2'b11)};
173assign inval_vect0[111:94]=0;
174
175/*assign inval_vect1[3:0]={wayval1,cpu0_dhit1[2] && (address_d[5:4]==2'b00)};
176assign inval_vect1[7:4]={wayval1,cpu1_dhit1[2] && (address_d[5:4]==2'b00)};
177assign inval_vect1[31:8]=0;
178assign inval_vect1[34:32]={wayval1,cpu0_dhit1[2] && (address_d[5:4]==2'b01)};
179assign inval_vect1[37:35]={wayval1,cpu1_dhit1[2] && (address_d[5:4]==2'b01)};
180assign inval_vect1[55:38]=0;
181assign inval_vect1[59:56]={wayval1,cpu0_dhit1[2] && (address_d[5:4]==2'b10)};
182assign inval_vect1[63:60]={wayval1,cpu1_dhit1[2] && (address_d[5:4]==2'b10)};
183assign inval_vect1[87:64]=0;
184assign inval_vect1[90:88]={wayval1,cpu0_dhit1[2] && (address_d[5:4]==2'b11)};
185assign inval_vect1[93:91]={wayval1,cpu1_dhit1[2] && (address_d[5:4]==2'b11)};
186assign inval_vect1[111:94]=0;*/
187
188assign inval_vect1[3:0]=0;
189assign inval_vect1[7:4]=0;
190assign inval_vect1[31:8]=0;
191assign inval_vect1[34:32]={wayval1,cpu0_dhit1[2] && (address_d[5]==0)};
192assign inval_vect1[37:35]={wayval1,cpu1_dhit1[2] && (address_d[5]==0)};
193assign inval_vect1[55:38]=0;
194assign inval_vect1[59:56]=0;
195assign inval_vect1[63:60]=0;
196assign inval_vect1[87:64]=0;
197assign inval_vect1[90:88]={wayval1,cpu0_dhit1[2] && (address_d[5]==1)};
198assign inval_vect1[93:91]={wayval1,cpu1_dhit1[2] && (address_d[5]==1)};
199assign inval_vect1[111:94]=0;
200
201assign wayval0=cpu0_dhit0[1:0] | cpu1_dhit0[1:0] | cpu0_ihit[1:0] | cpu1_ihit[1:0];
202assign wayval1=cpu0_dhit1[1:0] | cpu1_dhit1[1:0];
203assign othercachehit[0]=((!cpu_d) && ifill_d && cpu0_dhit0[2]) ||
204                        (  cpu_d  && ifill_d && cpu1_dhit0[2]) ||
205                        ((!cpu_d) && load_d && cacheable_d && cpu0_ihit[2]) ||
206                        (  cpu_d  && load_d && cacheable_d && cpu1_ihit[2]);
207assign othercachehit[1]=((!cpu_d) && ifill_d && cpu0_dhit1[2]) ||
208                        (  cpu_d  && ifill_d && cpu1_dhit1[2]);
209assign othercpuhit[0]=((!cpu_d) && (cpu1_dhit0[2] || cpu1_ihit[2])) ||
210                      (  cpu_d  && (cpu0_dhit0[2] || cpu0_ihit[2]));
211assign othercpuhit[1]=((!cpu_d) && ifill_d && cpu1_dhit1[2]) ||
212                      (  cpu_d  && ifill_d && cpu0_dhit1[2]);
213
214//wire [149:0] ILA_DATA;
215
216/*st2 st2_inst(
217        .acq_clk(clk),
218        .acq_data_in(ILA_DATA),
219        .acq_trigger_in(ILA_DATA),
220        .storage_enable(strobe || strobe_d || strobe_d1 || strobe_d2)
221);
222
223assign ILA_DATA[39:0]=address;
224assign ILA_DATA[41:40]=way;
225assign ILA_DATA[42]=strobe;
226assign ILA_DATA[43]=load;
227assign ILA_DATA[44]=ifill;
228assign ILA_DATA[45]=store;
229assign ILA_DATA[46]=cas;
230assign ILA_DATA[47]=swap;
231assign ILA_DATA[48]=strload;
232assign ILA_DATA[49]=strstore;
233assign ILA_DATA[50]=cacheable;
234assign ILA_DATA[51]=prefetch;
235assign ILA_DATA[52]=invalidate;
236assign ILA_DATA[53]=blockstore;
237assign ILA_DATA[55:54]=othercachehit;
238assign ILA_DATA[57:56]=othercpuhit;
239assign ILA_DATA[59:58]=wayval0;
240assign ILA_DATA[61:60]=wayval1;
241assign ILA_DATA[69:62]=inval_vect0[7:0];
242assign ILA_DATA[75:70]=inval_vect0[37:32];
243assign ILA_DATA[83:76]=inval_vect0[63:56];
244assign ILA_DATA[89:84]=inval_vect0[93:88];
245assign ILA_DATA[97:90]=inval_vect1[7:0];
246assign ILA_DATA[103:98]=inval_vect1[37:32];
247assign ILA_DATA[111:104]=inval_vect1[63:56];
248assign ILA_DATA[117:112]=inval_vect1[93:88];
249assign ILA_DATA[118]=dquery0;
250assign ILA_DATA[119]=dquery1;
251assign ILA_DATA[120]=dalloc0;
252assign ILA_DATA[121]=dalloc1;
253assign ILA_DATA[122]=ddealloc0;
254assign ILA_DATA[123]=ddealloc1;
255assign ILA_DATA[124]=iquery0;
256assign ILA_DATA[125]=iquery1;
257assign ILA_DATA[126]=ialloc0;
258assign ILA_DATA[127]=ialloc1;
259assign ILA_DATA[128]=idealloc0;
260assign ILA_DATA[129]=idealloc1;
261*/
262endmodule
Note: See TracBrowser for help on using the repository browser.