-
Notifications
You must be signed in to change notification settings - Fork 0
/
core.cc
4409 lines (4061 loc) · 251 KB
/
core.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*****************************************************************************
* McPAT
* SOFTWARE LICENSE AGREEMENT
* Copyright 2012 Hewlett-Packard Development Company, L.P.
* All Rights Reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met: redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer;
* redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution;
* neither the name of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.”
*
***************************************************************************/
#include "io.h"
#include "parameter.h"
#include "const.h"
#include "basic_circuit.h"
#include <iostream>
#include <algorithm>
#include "XML_Parse.h"
#include <string>
#include <cmath>
#include <assert.h>
#include "core.h"
//#include "globalvar.h"
InstFetchU::InstFetchU(ParseXML* XML_interface, int ithCore_, InputParameter* interface_ip_, const CoreDynParam & dyn_p_, bool exist_)
: XML(XML_interface),
ithCore(ithCore_),
interface_ip(*interface_ip_),
coredynp(dyn_p_),
IB(0),
BTB(0),
ID_inst(0),
ID_operand(0),
ID_misc(0),
exist(exist_) {
if (!exist) return;
int idx, tag, data, size, line, assoc, banks;
bool debug = false, is_default = true;
clockRate = coredynp.clockRate;
executionTime = coredynp.executionTime;
cache_p = (Cache_policy) XML->sys.core[ithCore].icache.icache_config[7];
//Assuming all L1 caches are virtually idxed physically tagged.
//cache
size = (int) XML->sys.core[ithCore].icache.icache_config[0];
line = (int) XML->sys.core[ithCore].icache.icache_config[1];
assoc = (int) XML->sys.core[ithCore].icache.icache_config[2];
banks = (int) XML->sys.core[ithCore].icache.icache_config[3];
idx = debug ? 9 : int(ceil(log2(size / line / assoc)));
tag = debug ? 51 : (int) XML->sys.physical_address_width - idx - int(ceil(log2(line))) + EXTRA_TAG_BITS;
interface_ip.specific_tag = 1;
interface_ip.tag_w = tag;
interface_ip.cache_sz = debug ? 32768 : (int) XML->sys.core[ithCore].icache.icache_config[0];
interface_ip.line_sz = debug ? 64 : (int) XML->sys.core[ithCore].icache.icache_config[1];
interface_ip.assoc = debug ? 8 : (int) XML->sys.core[ithCore].icache.icache_config[2];
interface_ip.nbanks = debug ? 1 : (int) XML->sys.core[ithCore].icache.icache_config[3];
interface_ip.out_w = interface_ip.line_sz * 8;
interface_ip.access_mode = 0; //debug?0:XML->sys.core[ithCore].icache.icache_config[5];
interface_ip.throughput = debug ? 1.0 / clockRate : XML->sys.core[ithCore].icache.icache_config[4] / clockRate;
interface_ip.latency = debug ? 3.0 / clockRate : XML->sys.core[ithCore].icache.icache_config[5] / clockRate;
interface_ip.is_cache = true;
interface_ip.pure_cam = false;
interface_ip.pure_ram = false;
// interface_ip.obj_func_dyn_energy = 0;
// interface_ip.obj_func_dyn_power = 0;
// interface_ip.obj_func_leak_power = 0;
// interface_ip.obj_func_cycle_t = 1;
interface_ip.num_rw_ports = debug ? 1 : XML->sys.core[ithCore].number_instruction_fetch_ports;
interface_ip.num_rd_ports = 0;
interface_ip.num_wr_ports = 0;
interface_ip.num_se_rd_ports = 0;
icache.caches = new ArrayST(&interface_ip, "icache", Core_device, coredynp.opt_local, coredynp.core_ty);
scktRatio = g_tp.sckt_co_eff;
chip_PR_overhead = g_tp.chip_layout_overhead;
macro_PR_overhead = g_tp.macro_layout_overhead;
icache.area.set_area(icache.area.get_area() + icache.caches->local_result.area);
area.set_area(area.get_area() + icache.caches->local_result.area);
//output_data_csv(icache.caches.local_result);
/*
*iCache controllers
*miss buffer Each MSHR contains enough state
*to handle one or more accesses of any type to a single memory line.
*Due to the generality of the MSHR mechanism,
*the amount of state involved is non-trivial:
*including the address, pointers to the cache entry and destination register,
*written data, and various other pieces of state.
*/
interface_ip.num_search_ports = debug ? 1 : XML->sys.core[ithCore].number_instruction_fetch_ports;
tag = XML->sys.physical_address_width + EXTRA_TAG_BITS;
data = (XML->sys.physical_address_width) + int(ceil(log2(size / line))) + icache.caches->l_ip.line_sz * 8;
interface_ip.specific_tag = 1;
interface_ip.tag_w = tag;
interface_ip.line_sz = int(ceil(data / 8.0)); //int(ceil(pow(2.0,ceil(log2(data)))/8.0));
interface_ip.cache_sz = XML->sys.core[ithCore].icache.buffer_sizes[0] * interface_ip.line_sz;
interface_ip.assoc = 0;
interface_ip.nbanks = 1;
interface_ip.out_w = interface_ip.line_sz * 8;
interface_ip.access_mode = 0;
interface_ip.throughput = debug ? 1.0 / clockRate : XML->sys.core[ithCore].icache.icache_config[4] / clockRate; //means cycle time
interface_ip.latency = debug ? 1.0 / clockRate : XML->sys.core[ithCore].icache.icache_config[5] / clockRate; //means access time
interface_ip.obj_func_dyn_energy = 0;
interface_ip.obj_func_dyn_power = 0;
interface_ip.obj_func_leak_power = 0;
interface_ip.obj_func_cycle_t = 1;
interface_ip.num_rw_ports = debug ? 1 : XML->sys.core[ithCore].number_instruction_fetch_ports;
interface_ip.num_rd_ports = 0;
interface_ip.num_wr_ports = 0;
interface_ip.num_se_rd_ports = 0;
interface_ip.num_search_ports = XML->sys.core[ithCore].number_instruction_fetch_ports;
icache.missb = new ArrayST(&interface_ip, "icacheMissBuffer", Core_device, coredynp.opt_local, coredynp.core_ty);
icache.area.set_area(icache.area.get_area() + icache.missb->local_result.area);
area.set_area(area.get_area() + icache.missb->local_result.area);
//output_data_csv(icache.missb.local_result);
//fill buffer
tag = XML->sys.physical_address_width + EXTRA_TAG_BITS;
data = icache.caches->l_ip.line_sz;
interface_ip.specific_tag = 1;
interface_ip.tag_w = tag;
interface_ip.line_sz = data; //int(pow(2.0,ceil(log2(data))));
interface_ip.cache_sz = data * XML->sys.core[ithCore].icache.buffer_sizes[1];
interface_ip.assoc = 0;
interface_ip.nbanks = 1;
interface_ip.out_w = interface_ip.line_sz * 8;
interface_ip.access_mode = 0;
interface_ip.throughput = debug ? 1.0 / clockRate : XML->sys.core[ithCore].icache.icache_config[4] / clockRate;
interface_ip.latency = debug ? 1.0 / clockRate : XML->sys.core[ithCore].icache.icache_config[5] / clockRate;
interface_ip.obj_func_dyn_energy = 0;
interface_ip.obj_func_dyn_power = 0;
interface_ip.obj_func_leak_power = 0;
interface_ip.obj_func_cycle_t = 1;
interface_ip.num_rw_ports = debug ? 1 : XML->sys.core[ithCore].number_instruction_fetch_ports;
interface_ip.num_rd_ports = 0;
interface_ip.num_wr_ports = 0;
interface_ip.num_se_rd_ports = 0;
interface_ip.num_search_ports = XML->sys.core[ithCore].number_instruction_fetch_ports;
icache.ifb = new ArrayST(&interface_ip, "icacheFillBuffer", Core_device, coredynp.opt_local, coredynp.core_ty);
icache.area.set_area(icache.area.get_area() + icache.ifb->local_result.area);
area.set_area(area.get_area() + icache.ifb->local_result.area);
//output_data_csv(icache.ifb.local_result);
//prefetch buffer
tag = XML->sys.physical_address_width + EXTRA_TAG_BITS; //check with previous entries to decide wthether to merge.
data = icache.caches->l_ip.line_sz; //separate queue to prevent from cache polution.
interface_ip.specific_tag = 1;
interface_ip.tag_w = tag;
interface_ip.line_sz = data; //int(pow(2.0,ceil(log2(data))));
interface_ip.cache_sz = XML->sys.core[ithCore].icache.buffer_sizes[2] * interface_ip.line_sz;
interface_ip.assoc = 0;
interface_ip.nbanks = 1;
interface_ip.out_w = interface_ip.line_sz * 8;
interface_ip.access_mode = 0;
interface_ip.throughput = debug ? 1.0 / clockRate : XML->sys.core[ithCore].icache.icache_config[4] / clockRate;
interface_ip.latency = debug ? 1.0 / clockRate : XML->sys.core[ithCore].icache.icache_config[5] / clockRate;
interface_ip.obj_func_dyn_energy = 0;
interface_ip.obj_func_dyn_power = 0;
interface_ip.obj_func_leak_power = 0;
interface_ip.obj_func_cycle_t = 1;
interface_ip.num_rw_ports = debug ? 1 : XML->sys.core[ithCore].number_instruction_fetch_ports;
interface_ip.num_rd_ports = 0;
interface_ip.num_wr_ports = 0;
interface_ip.num_se_rd_ports = 0;
interface_ip.num_search_ports = XML->sys.core[ithCore].number_instruction_fetch_ports;
icache.prefetchb = new ArrayST(&interface_ip, "icacheprefetchBuffer", Core_device, coredynp.opt_local, coredynp.core_ty);
icache.area.set_area(icache.area.get_area() + icache.prefetchb->local_result.area);
area.set_area(area.get_area() + icache.prefetchb->local_result.area);
//output_data_csv(icache.prefetchb.local_result);
//Instruction buffer
data = XML->sys.core[ithCore].instruction_length * XML->sys.core[ithCore].peak_issue_width; //icache.caches.l_ip.line_sz; //multiple threads timing sharing the instruction buffer.
interface_ip.is_cache = false;
interface_ip.pure_ram = true;
interface_ip.pure_cam = false;
interface_ip.line_sz = int(ceil(data / 8.0));
interface_ip.cache_sz = XML->sys.core[ithCore].number_hardware_threads * XML->sys.core[ithCore].instruction_buffer_size * interface_ip.line_sz > 64 ?
XML->sys.core[ithCore].number_hardware_threads * XML->sys.core[ithCore].instruction_buffer_size * interface_ip.line_sz : 64;
interface_ip.assoc = 1;
interface_ip.nbanks = 1;
interface_ip.out_w = interface_ip.line_sz * 8;
interface_ip.access_mode = 0;
interface_ip.throughput = 1.0 / clockRate;
interface_ip.latency = 1.0 / clockRate;
interface_ip.obj_func_dyn_energy = 0;
interface_ip.obj_func_dyn_power = 0;
interface_ip.obj_func_leak_power = 0;
interface_ip.obj_func_cycle_t = 1;
//NOTE: Assuming IB is time slice shared among threads, every fetch op will at least fetch "fetch width" instructions.
interface_ip.num_rw_ports = debug ? 1 : XML->sys.core[ithCore].number_instruction_fetch_ports; //XML->sys.core[ithCore].fetch_width;
interface_ip.num_rd_ports = 0;
interface_ip.num_wr_ports = 0;
interface_ip.num_se_rd_ports = 0;
IB = new ArrayST(&interface_ip, "InstBuffer", Core_device, coredynp.opt_local, coredynp.core_ty);
IB->area.set_area(IB->area.get_area() + IB->local_result.area);
area.set_area(area.get_area() + IB->local_result.area);
//output_data_csv(IB.IB.local_result);
// inst_decoder.opcode_length = XML->sys.core[ithCore].opcode_width;
// inst_decoder.init_decoder(is_default, &interface_ip);
// inst_decoder.full_decoder_power();
if (coredynp.predictionW > 0) {
/*
* BTB branch target buffer, accessed during IF stage. Virtually indexed and virtually tagged
* It is only a cache without all the buffers in the cache controller since it is more like a
* look up table than a cache with cache controller. When access miss, no load from other places
* such as main memory (not actively fill the misses), it is passively updated under two circumstances:
* 1) when BPT@ID stage finds out current is a taken branch while BTB missed
* 2) When BPT@ID stage predicts differently than BTB
* 3) When ID stage finds out current instruction is not a branch while BTB had a hit.(mark as invalid)
* 4) when EXEU find out wrong target has been provided from BTB.
*
*/
size = XML->sys.core[ithCore].BTB.BTB_config[0];
line = XML->sys.core[ithCore].BTB.BTB_config[1];
assoc = XML->sys.core[ithCore].BTB.BTB_config[2];
banks = XML->sys.core[ithCore].BTB.BTB_config[3];
idx = debug ? 9 : int(ceil(log2(size / line / assoc)));
// tag = debug?51:XML->sys.virtual_address_width-idx-int(ceil(log2(line))) + int(ceil(log2(XML->sys.core[ithCore].number_hardware_threads))) +EXTRA_TAG_BITS;
tag = debug ? 51 : XML->sys.virtual_address_width + int(ceil(log2(XML->sys.core[ithCore].number_hardware_threads))) + EXTRA_TAG_BITS;
interface_ip.is_cache = true;
interface_ip.pure_ram = false;
interface_ip.pure_cam = false;
interface_ip.specific_tag = 1;
interface_ip.tag_w = tag;
interface_ip.cache_sz = debug ? 32768 : size;
interface_ip.line_sz = debug ? 64 : line;
interface_ip.assoc = debug ? 8 : assoc;
interface_ip.nbanks = debug ? 1 : banks;
interface_ip.out_w = interface_ip.line_sz * 8;
interface_ip.access_mode = 0; //debug?0:XML->sys.core[ithCore].dcache.dcache_config[5];
interface_ip.throughput = debug ? 1.0 / clockRate : XML->sys.core[ithCore].BTB.BTB_config[4] / clockRate;
interface_ip.latency = debug ? 3.0 / clockRate : XML->sys.core[ithCore].BTB.BTB_config[5] / clockRate;
interface_ip.obj_func_dyn_energy = 0;
interface_ip.obj_func_dyn_power = 0;
interface_ip.obj_func_leak_power = 0;
interface_ip.obj_func_cycle_t = 1;
interface_ip.num_rw_ports = 1;
interface_ip.num_rd_ports = coredynp.predictionW;
interface_ip.num_wr_ports = coredynp.predictionW;
interface_ip.num_se_rd_ports = 0;
BTB = new ArrayST(&interface_ip, "Branch Target Buffer", Core_device, coredynp.opt_local, coredynp.core_ty);
BTB->area.set_area(BTB->area.get_area() + BTB->local_result.area);
area.set_area(area.get_area() + BTB->local_result.area);
///cout<<"area="<<area<<endl;
BPT = new BranchPredictor(XML, ithCore, &interface_ip, coredynp);
area.set_area(area.get_area() + BPT->area.get_area());
}
ID_inst = new inst_decoder(is_default, &interface_ip,
coredynp.opcode_length, 1/*Decoder should not know how many by itself*/,
coredynp.x86,
Core_device, coredynp.core_ty);
ID_operand = new inst_decoder(is_default, &interface_ip,
coredynp.arch_ireg_width, 1,
coredynp.x86,
Core_device, coredynp.core_ty);
ID_misc = new inst_decoder(is_default, &interface_ip,
8/* Prefix field etc upto 14B*/, 1,
coredynp.x86,
Core_device, coredynp.core_ty);
//TODO: X86 decoder should decode the inst in cyclic mode under the control of squencer.
//So the dynamic power should be multiplied by a few times.
area.set_area(area.get_area()+ (ID_inst->area.get_area()
+ ID_operand->area.get_area()
+ ID_misc->area.get_area()) * coredynp.decodeW);
}
BranchPredictor::BranchPredictor(ParseXML* XML_interface, int ithCore_, InputParameter* interface_ip_, const CoreDynParam & dyn_p_, bool exist_)
: XML(XML_interface),
ithCore(ithCore_),
interface_ip(*interface_ip_),
coredynp(dyn_p_),
globalBPT(0),
localBPT(0),
L1_localBPT(0),
L2_localBPT(0),
chooser(0),
RAS(0),
exist(exist_) {
/*
* Branch Predictor, accessed during ID stage.
* McPAT's branch predictor model is the tournament branch predictor used in Alpha 21264,
* including global predictor, local two level predictor, and Chooser.
* The Branch predictor also includes a RAS (return address stack) for function calls
* Branch predictors are tagged by thread ID and modeled as 1-way associative cache.
* However RAS return address stacks are duplicated for each thread.
* TODO:Data Width need to be computed more precisely *
*/
if (!exist) return;
int tag, data;
clockRate = coredynp.clockRate;
executionTime = coredynp.executionTime;
interface_ip.assoc = 1;
interface_ip.pure_cam = false;
if (coredynp.multithreaded) {
tag = int(log2(coredynp.num_hthreads) + EXTRA_TAG_BITS);
interface_ip.specific_tag = 1;
interface_ip.tag_w = tag;
interface_ip.is_cache = true;
interface_ip.pure_ram = false;
} else {
interface_ip.is_cache = false;
interface_ip.pure_ram = true;
}
//Global predictor
data = int(ceil(XML->sys.core[ithCore].predictor.global_predictor_bits / 8.0));
interface_ip.line_sz = data;
interface_ip.cache_sz = data * XML->sys.core[ithCore].predictor.global_predictor_entries;
interface_ip.nbanks = 1;
interface_ip.out_w = interface_ip.line_sz * 8;
interface_ip.access_mode = 2;
interface_ip.throughput = 1.0 / clockRate;
interface_ip.latency = 1.0 / clockRate;
interface_ip.obj_func_dyn_energy = 0;
interface_ip.obj_func_dyn_power = 0;
interface_ip.obj_func_leak_power = 0;
interface_ip.obj_func_cycle_t = 1;
interface_ip.num_rw_ports = 0;
interface_ip.num_rd_ports = coredynp.predictionW;
interface_ip.num_wr_ports = coredynp.predictionW;
interface_ip.num_se_rd_ports = 0;
globalBPT = new ArrayST(&interface_ip, "Global Predictor", Core_device, coredynp.opt_local, coredynp.core_ty);
globalBPT->area.set_area(globalBPT->area.get_area() + globalBPT->local_result.area);
area.set_area(area.get_area() + globalBPT->local_result.area);
//Local BPT (Level 1)
data = int(ceil(XML->sys.core[ithCore].predictor.local_predictor_size[0] / 8.0));
interface_ip.line_sz = data;
interface_ip.cache_sz = data * XML->sys.core[ithCore].predictor.local_predictor_entries;
interface_ip.nbanks = 1;
interface_ip.out_w = interface_ip.line_sz * 8;
interface_ip.access_mode = 2;
interface_ip.throughput = 1.0 / clockRate;
interface_ip.latency = 1.0 / clockRate;
interface_ip.obj_func_dyn_energy = 0;
interface_ip.obj_func_dyn_power = 0;
interface_ip.obj_func_leak_power = 0;
interface_ip.obj_func_cycle_t = 1;
interface_ip.num_rw_ports = 0;
interface_ip.num_rd_ports = coredynp.predictionW;
interface_ip.num_wr_ports = coredynp.predictionW;
interface_ip.num_se_rd_ports = 0;
L1_localBPT = new ArrayST(&interface_ip, "L1 local Predictor", Core_device, coredynp.opt_local, coredynp.core_ty);
L1_localBPT->area.set_area(L1_localBPT->area.get_area() + L1_localBPT->local_result.area);
area.set_area(area.get_area() + L1_localBPT->local_result.area);
//Local BPT (Level 2)
data = int(ceil(XML->sys.core[ithCore].predictor.local_predictor_size[1] / 8.0));
interface_ip.line_sz = data;
interface_ip.cache_sz = data * XML->sys.core[ithCore].predictor.local_predictor_entries;
interface_ip.nbanks = 1;
interface_ip.out_w = interface_ip.line_sz * 8;
interface_ip.access_mode = 2;
interface_ip.throughput = 1.0 / clockRate;
interface_ip.latency = 1.0 / clockRate;
interface_ip.obj_func_dyn_energy = 0;
interface_ip.obj_func_dyn_power = 0;
interface_ip.obj_func_leak_power = 0;
interface_ip.obj_func_cycle_t = 1;
interface_ip.num_rw_ports = 0;
interface_ip.num_rd_ports = coredynp.predictionW;
interface_ip.num_wr_ports = coredynp.predictionW;
interface_ip.num_se_rd_ports = 0;
L2_localBPT = new ArrayST(&interface_ip, "L2 local Predictor", Core_device, coredynp.opt_local, coredynp.core_ty);
L2_localBPT->area.set_area(L2_localBPT->area.get_area() + L2_localBPT->local_result.area);
area.set_area(area.get_area() + L2_localBPT->local_result.area);
//Chooser
data = int(ceil(XML->sys.core[ithCore].predictor.chooser_predictor_bits / 8.0));
interface_ip.line_sz = data;
interface_ip.cache_sz = data * XML->sys.core[ithCore].predictor.chooser_predictor_entries;
interface_ip.nbanks = 1;
interface_ip.out_w = interface_ip.line_sz * 8;
interface_ip.access_mode = 2;
interface_ip.throughput = 1.0 / clockRate;
interface_ip.latency = 1.0 / clockRate;
interface_ip.obj_func_dyn_energy = 0;
interface_ip.obj_func_dyn_power = 0;
interface_ip.obj_func_leak_power = 0;
interface_ip.obj_func_cycle_t = 1;
interface_ip.num_rw_ports = 0;
interface_ip.num_rd_ports = coredynp.predictionW;
interface_ip.num_wr_ports = coredynp.predictionW;
interface_ip.num_se_rd_ports = 0;
chooser = new ArrayST(&interface_ip, "Predictor Chooser", Core_device, coredynp.opt_local, coredynp.core_ty);
chooser->area.set_area(chooser->area.get_area() + chooser->local_result.area);
area.set_area(area.get_area() + chooser->local_result.area);
//RAS return address stacks are Duplicated for each thread.
interface_ip.is_cache = false;
interface_ip.pure_ram = true;
data = int(ceil(coredynp.pc_width / 8.0));
interface_ip.line_sz = data;
interface_ip.cache_sz = data * XML->sys.core[ithCore].RAS_size;
interface_ip.assoc = 1;
interface_ip.nbanks = 1;
interface_ip.out_w = interface_ip.line_sz * 8;
interface_ip.access_mode = 2;
interface_ip.throughput = 1.0 / clockRate;
interface_ip.latency = 1.0 / clockRate;
interface_ip.obj_func_dyn_energy = 0;
interface_ip.obj_func_dyn_power = 0;
interface_ip.obj_func_leak_power = 0;
interface_ip.obj_func_cycle_t = 1;
interface_ip.num_rw_ports = 0;
interface_ip.num_rd_ports = coredynp.predictionW;
interface_ip.num_wr_ports = coredynp.predictionW;
interface_ip.num_se_rd_ports = 0;
RAS = new ArrayST(&interface_ip, "RAS", Core_device, coredynp.opt_local, coredynp.core_ty);
RAS->area.set_area(RAS->area.get_area() + RAS->local_result.area * coredynp.num_hthreads);
area.set_area(area.get_area() + RAS->local_result.area * coredynp.num_hthreads);
}
SchedulerU::SchedulerU(ParseXML* XML_interface, int ithCore_, InputParameter* interface_ip_, const CoreDynParam & dyn_p_, bool exist_)
: XML(XML_interface),
ithCore(ithCore_),
interface_ip(*interface_ip_),
coredynp(dyn_p_),
int_inst_window(0),
fp_inst_window(0),
ROB(0),
instruction_selection(0),
exist(exist_) {
if (!exist) return;
int tag, data;
bool is_default = true;
string tmp_name;
clockRate = coredynp.clockRate;
executionTime = coredynp.executionTime;
if ((coredynp.core_ty == Inorder && coredynp.multithreaded)) {
//Instruction issue queue, in-order multi-issue or multithreaded processor also has this structure. Unified window for Inorder processors
tag = int(log2(XML->sys.core[ithCore].number_hardware_threads) * coredynp.perThreadState); //This is the normal thread state bits based on Niagara Design
data = XML->sys.core[ithCore].instruction_length;
//NOTE: x86 inst can be very lengthy, up to 15B. Source: Intel® 64 and IA-32 Architectures
//Software Developer’s Manual
interface_ip.is_cache = true;
interface_ip.pure_cam = false;
interface_ip.pure_ram = false;
interface_ip.line_sz = int(ceil(data / 8.0));
interface_ip.specific_tag = 1;
interface_ip.tag_w = tag;
interface_ip.cache_sz = XML->sys.core[ithCore].instruction_window_size * interface_ip.line_sz > 64 ? XML->sys.core[ithCore].instruction_window_size * interface_ip.line_sz : 64;
interface_ip.assoc = 0;
interface_ip.nbanks = 1;
interface_ip.out_w = interface_ip.line_sz * 8;
interface_ip.access_mode = 1;
interface_ip.throughput = 1.0 / clockRate;
interface_ip.latency = 1.0 / clockRate;
interface_ip.obj_func_dyn_energy = 0;
interface_ip.obj_func_dyn_power = 0;
interface_ip.obj_func_leak_power = 0;
interface_ip.obj_func_cycle_t = 1;
interface_ip.num_rw_ports = 0;
interface_ip.num_rd_ports = coredynp.peak_issueW;
interface_ip.num_wr_ports = coredynp.peak_issueW;
interface_ip.num_se_rd_ports = 0;
interface_ip.num_search_ports = coredynp.peak_issueW;
int_inst_window = new ArrayST(&interface_ip, "InstFetchQueue", Core_device, coredynp.opt_local, coredynp.core_ty);
int_inst_window->area.set_area(int_inst_window->area.get_area() + int_inst_window->local_result.area * coredynp.num_pipelines);
area.set_area(area.get_area() + int_inst_window->local_result.area * coredynp.num_pipelines);
//output_data_csv(iRS.RS.local_result);
Iw_height = int_inst_window->local_result.cache_ht;
/*
* selection logic
* In a single-issue Inorder multithreaded processor like Niagara, issue width=1*number_of_threads since the processor does need to pick up
* instructions from multiple ready ones(although these ready ones are from different threads).While SMT processors do not distinguish which thread belongs to who
* at the issue stage.
*/
interface_ip.assoc = 1; //reset to prevent unnecessary warning messages when init_interface
instruction_selection = new selection_logic(is_default, XML->sys.core[ithCore].instruction_window_size,
coredynp.peak_issueW * XML->sys.core[ithCore].number_hardware_threads,
&interface_ip, Core_device, coredynp.core_ty);
}
if (coredynp.core_ty == OOO) {
/*
* CAM based instruction window
* For physicalRegFilebased OOO it is the instruction issue queue, where only tags of phy regs are stored
* For RS based OOO it is the Reservation station, where both tags and values of phy regs are stored
* It is written once and read twice(two operands) before an instruction can be issued.
* X86 instruction can be very long up to 15B. add instruction length in XML
*/
if (coredynp.scheu_ty == PhysicalRegFile) {
tag = coredynp.phy_ireg_width;
// Each time only half of the tag is compared, but two tag should be stored.
// This underestimate the search power
data = int((ceil((coredynp.instruction_length + 2 * (coredynp.phy_ireg_width - coredynp.arch_ireg_width)) / 2.0) / 8.0));
//Data width being divided by 2 means only after both operands available the whole data will be read out.
//This is modeled using two equivalent readouts with half of the data width
tmp_name = "InstIssueQueue";
} else {
tag = coredynp.phy_ireg_width;
// Each time only half of the tag is compared, but two tag should be stored.
// This underestimate the search power
data = int(ceil(((coredynp.instruction_length + 2 * (coredynp.phy_ireg_width - coredynp.arch_ireg_width) +
2 * coredynp.int_data_width) / 2.0) / 8.0));
//Data width being divided by 2 means only after both operands available the whole data will be read out.
//This is modeled using two equivalent readouts with half of the data width
tmp_name = "IntReservationStation";
}
interface_ip.is_cache = true;
interface_ip.pure_cam = false;
interface_ip.pure_ram = false;
interface_ip.line_sz = data;
interface_ip.cache_sz = data * XML->sys.core[ithCore].instruction_window_size;
interface_ip.assoc = 0;
interface_ip.nbanks = 1;
interface_ip.out_w = interface_ip.line_sz * 8;
interface_ip.specific_tag = 1;
interface_ip.tag_w = tag;
interface_ip.access_mode = 0;
interface_ip.throughput = 2 * 1.0 / clockRate;
interface_ip.latency = 2 * 1.0 / clockRate;
interface_ip.obj_func_dyn_energy = 0;
interface_ip.obj_func_dyn_power = 0;
interface_ip.obj_func_leak_power = 0;
interface_ip.obj_func_cycle_t = 1;
interface_ip.num_rw_ports = 0;
interface_ip.num_rd_ports = coredynp.peak_issueW;
interface_ip.num_wr_ports = coredynp.peak_issueW;
interface_ip.num_se_rd_ports = 0;
interface_ip.num_search_ports = coredynp.peak_issueW;
int_inst_window = new ArrayST(&interface_ip, tmp_name, Core_device, coredynp.opt_local, coredynp.core_ty);
int_inst_window->area.set_area(int_inst_window->area.get_area() + int_inst_window->local_result.area * coredynp.num_pipelines);
area.set_area(area.get_area() + int_inst_window->local_result.area * coredynp.num_pipelines);
Iw_height = int_inst_window->local_result.cache_ht;
//FU inst window
if (coredynp.scheu_ty == PhysicalRegFile) {
tag = 2 * coredynp.phy_freg_width; // TODO: each time only half of the tag is compared
data = int(ceil((coredynp.instruction_length + 2 * (coredynp.phy_freg_width - coredynp.arch_freg_width)) / 8.0));
tmp_name = "FPIssueQueue";
} else {
tag = 2 * coredynp.phy_ireg_width;
data = int(ceil((coredynp.instruction_length + 2 * (coredynp.phy_freg_width - coredynp.arch_freg_width) +
2 * coredynp.fp_data_width) / 8.0));
tmp_name = "FPReservationStation";
}
interface_ip.is_cache = true;
interface_ip.pure_cam = false;
interface_ip.pure_ram = false;
interface_ip.line_sz = data;
interface_ip.cache_sz = data * XML->sys.core[ithCore].fp_instruction_window_size;
interface_ip.assoc = 0;
interface_ip.nbanks = 1;
interface_ip.out_w = interface_ip.line_sz * 8;
interface_ip.specific_tag = 1;
interface_ip.tag_w = tag;
interface_ip.access_mode = 0;
interface_ip.throughput = 1.0 / clockRate;
interface_ip.latency = 1.0 / clockRate;
interface_ip.obj_func_dyn_energy = 0;
interface_ip.obj_func_dyn_power = 0;
interface_ip.obj_func_leak_power = 0;
interface_ip.obj_func_cycle_t = 1;
interface_ip.num_rw_ports = 0;
interface_ip.num_rd_ports = coredynp.fp_issueW;
interface_ip.num_wr_ports = coredynp.fp_issueW;
interface_ip.num_se_rd_ports = 0;
interface_ip.num_search_ports = coredynp.fp_issueW;
fp_inst_window = new ArrayST(&interface_ip, tmp_name, Core_device, coredynp.opt_local, coredynp.core_ty);
fp_inst_window->area.set_area(fp_inst_window->area.get_area() + fp_inst_window->local_result.area * coredynp.num_fp_pipelines);
area.set_area(area.get_area() + fp_inst_window->local_result.area * coredynp.num_fp_pipelines);
fp_Iw_height = fp_inst_window->local_result.cache_ht;
if (XML->sys.core[ithCore].ROB_size > 0) {
/*
* if ROB_size = 0, then the target processor does not support hardware-based
* speculation, i.e. , the processor allow OOO issue as well as OOO completion, which
* means branch must be resolved before instruction issued into instruction window, since
* there is no change to flush miss-predict branch path after instructions are issued in this situation.
*
* ROB.ROB size = inflight inst. ROB is unified for int and fp inst.
* One old approach is to combine the RAT and ROB as a huge CAM structure as in AMD K7.
* However, this approach is abandoned due to its high power and poor scalability.
* McPAT uses current implementation of ROB as circular buffer.
* ROB is written once when instruction is issued and read once when the instruction is committed. *
*/
int robExtra = int(ceil(5 + log2(coredynp.num_hthreads)));
data = int(ceil((robExtra + coredynp.pc_width + ((coredynp.rm_ty == RAMbased) ? (coredynp.phy_ireg_width + coredynp.phy_freg_width) : fmax(coredynp.phy_ireg_width, coredynp.phy_freg_width)) + ((coredynp.scheu_ty == PhysicalRegFile) ? 0 : coredynp.fp_data_width)) / 8.0));
/*
* 5 bits are: busy, Issued, Finished, speculative, valid;
* PC is to id the instruction for recover exception/mis-prediction.
* When using RAM-based RAT, ROB needs to contain the ARF-PRF mapping to index the correct entry in the RAT,
* so that the correct architecture register (and freelist) can be found and the RAT can be appropriately updated;
* otherwise, the RAM-based RAT needs to support search ops to identify the target architecture register that needs to be updated, or the physical resigner that needs to be recycled;
* When using CAM-based RAT, ROB only needs to contain destination physical register since the CAM-base RAT can search for the corresponding ARF-PRF mapping
* to find the correct entry in the RAT, so that the correct architecture register (and freelist/bits) can be found and the RAT can be appropriately updated.
* ROB phy_reg entry should use the larger one from phy_ireg and phy_freg; fdata_width is always larger.
* Latest Intel Processors may have different ROB/RS designs.
*/
/*
if(coredynp.scheu_ty==PhysicalRegFile)
{
//PC is to id the instruction for recover exception.
//inst is used to map the renamed dest. registers.so that commit stage can know which reg/RRAT to update
// data = int(ceil((robExtra+coredynp.pc_width +
// coredynp.instruction_length + 2*coredynp.phy_ireg_width)/8.0));
if (coredynp.rm_ty ==RAMbased)
{
data = int(ceil((robExtra + coredynp.pc_width + (coredynp.phy_ireg_width, coredynp.phy_freg_width))/8.0));
//When using RAM-based RAT, ROB needs to contain the ARF-PRF mapping to index the correct entry in the RAT,
//so that the correct architecture register (and freelist) can be found and the RAT can be appropriately updated.
}
else if ((coredynp.rm_ty ==CAMbased))
{
data = int(ceil((robExtra+coredynp.pc_width + fmax(coredynp.phy_ireg_width, coredynp.phy_freg_width))/8.0));
//When using CAM-based RAT, ROB needs to contain the ARF-PRF mapping to index the correct entry in the RAT,
//so that the correct architecture register (and freelist) can be found and the RAT can be appropriately updated.
}
}
else
{
//in RS based OOO, ROB also contains value of destination reg
// data = int(ceil((robExtra+coredynp.pc_width +
// coredynp.instruction_length + 2*coredynp.phy_ireg_width + coredynp.fp_data_width)/8.0));
//using phy_reg number to search in the RAT, the correct architecture register can be found and the RAT can be appropriately updated.
//ROB phy_reg entry should use the larger one from ireg and freg; fdata_width is always larger; Latest Intel Processors may have different ROB/RS designs.
data = int(ceil((robExtra + coredynp.pc_width + fmax(coredynp.phy_ireg_width, coredynp.phy_freg_width) + coredynp.fp_data_width)/8.0));
}
*/
interface_ip.is_cache = false;
interface_ip.pure_cam = false;
interface_ip.pure_ram = true;
interface_ip.line_sz = data;
interface_ip.cache_sz = data * XML->sys.core[ithCore].ROB_size; //The XML ROB size is for all threads
interface_ip.assoc = 1;
interface_ip.nbanks = 1;
interface_ip.out_w = interface_ip.line_sz * 8;
interface_ip.access_mode = 1;
interface_ip.throughput = 1.0 / clockRate;
interface_ip.latency = 1.0 / clockRate;
interface_ip.obj_func_dyn_energy = 0;
interface_ip.obj_func_dyn_power = 0;
interface_ip.obj_func_leak_power = 0;
interface_ip.obj_func_cycle_t = 1;
interface_ip.num_rw_ports = 0;
interface_ip.num_rd_ports = coredynp.peak_commitW;
interface_ip.num_wr_ports = coredynp.peak_issueW;
interface_ip.num_se_rd_ports = 0;
interface_ip.num_search_ports = 0;
ROB = new ArrayST(&interface_ip, "ReorderBuffer", Core_device, coredynp.opt_local, coredynp.core_ty);
ROB->area.set_area(ROB->area.get_area() + ROB->local_result.area * coredynp.num_pipelines);
area.set_area(area.get_area() + ROB->local_result.area * coredynp.num_pipelines);
ROB_height = ROB->local_result.cache_ht;
}
instruction_selection = new selection_logic(is_default, XML->sys.core[ithCore].instruction_window_size,
coredynp.peak_issueW, &interface_ip, Core_device, coredynp.core_ty);
}
}
LoadStoreU::LoadStoreU(ParseXML* XML_interface, int ithCore_, InputParameter* interface_ip_, const CoreDynParam & dyn_p_, bool exist_)
: XML(XML_interface),
ithCore(ithCore_),
interface_ip(*interface_ip_),
coredynp(dyn_p_),
LSQ(0),
LoadQ(0),
exist(exist_) {
if (!exist) return;
int idx, tag, data, size, line, assoc, banks;
bool debug = false;
int ldst_opcode = XML->sys.core[ithCore].opcode_width; //16;
clockRate = coredynp.clockRate;
executionTime = coredynp.executionTime;
cache_p = (Cache_policy) XML->sys.core[ithCore].dcache.dcache_config[7];
interface_ip.num_search_ports = XML->sys.core[ithCore].memory_ports;
interface_ip.is_cache = true;
interface_ip.pure_cam = false;
interface_ip.pure_ram = false;
//Dcache
size = (int) XML->sys.core[ithCore].dcache.dcache_config[0];
line = (int) XML->sys.core[ithCore].dcache.dcache_config[1];
assoc = (int) XML->sys.core[ithCore].dcache.dcache_config[2];
banks = (int) XML->sys.core[ithCore].dcache.dcache_config[3];
idx = debug ? 9 : int(ceil(log2(size / line / assoc)));
tag = debug ? 51 : XML->sys.physical_address_width - idx - int(ceil(log2(line))) + EXTRA_TAG_BITS;
interface_ip.specific_tag = 1;
interface_ip.tag_w = tag;
interface_ip.cache_sz = debug ? 32768 : (int) XML->sys.core[ithCore].dcache.dcache_config[0];
interface_ip.line_sz = debug ? 64 : (int) XML->sys.core[ithCore].dcache.dcache_config[1];
interface_ip.assoc = debug ? 8 : (int) XML->sys.core[ithCore].dcache.dcache_config[2];
interface_ip.nbanks = debug ? 1 : (int) XML->sys.core[ithCore].dcache.dcache_config[3];
interface_ip.out_w = interface_ip.line_sz * 8;
interface_ip.access_mode = 0; //debug?0:XML->sys.core[ithCore].dcache.dcache_config[5];
interface_ip.throughput = debug ? 1.0 / clockRate : XML->sys.core[ithCore].dcache.dcache_config[4] / clockRate;
interface_ip.latency = debug ? 3.0 / clockRate : XML->sys.core[ithCore].dcache.dcache_config[5] / clockRate;
interface_ip.is_cache = true;
interface_ip.obj_func_dyn_energy = 0;
interface_ip.obj_func_dyn_power = 0;
interface_ip.obj_func_leak_power = 0;
interface_ip.obj_func_cycle_t = 1;
interface_ip.num_rw_ports = debug ? 1 : XML->sys.core[ithCore].memory_ports; //usually In-order has 1 and OOO has 2 at least.
interface_ip.num_rd_ports = 0;
interface_ip.num_wr_ports = 0;
interface_ip.num_se_rd_ports = 0;
dcache.caches = new ArrayST(&interface_ip, "dcache", Core_device, coredynp.opt_local, coredynp.core_ty);
dcache.area.set_area(dcache.area.get_area() + dcache.caches->local_result.area);
area.set_area(area.get_area() + dcache.caches->local_result.area);
//output_data_csv(dcache.caches.local_result);
//dCache controllers
//miss buffer
tag = XML->sys.physical_address_width + EXTRA_TAG_BITS;
data = (XML->sys.physical_address_width) + int(ceil(log2(size / line))) + dcache.caches->l_ip.line_sz * 8;
interface_ip.specific_tag = 1;
interface_ip.tag_w = tag;
interface_ip.line_sz = int(ceil(data / 8.0)); //int(ceil(pow(2.0,ceil(log2(data)))/8.0));
interface_ip.cache_sz = XML->sys.core[ithCore].dcache.buffer_sizes[0] * interface_ip.line_sz;
interface_ip.assoc = 0;
interface_ip.nbanks = 1;
interface_ip.out_w = interface_ip.line_sz * 8;
interface_ip.access_mode = 2;
interface_ip.throughput = debug ? 1.0 / clockRate : XML->sys.core[ithCore].dcache.dcache_config[4] / clockRate;
interface_ip.latency = debug ? 1.0 / clockRate : XML->sys.core[ithCore].dcache.dcache_config[5] / clockRate;
interface_ip.obj_func_dyn_energy = 0;
interface_ip.obj_func_dyn_power = 0;
interface_ip.obj_func_leak_power = 0;
interface_ip.obj_func_cycle_t = 1;
interface_ip.num_rw_ports = debug ? 1 : XML->sys.core[ithCore].memory_ports;
;
interface_ip.num_rd_ports = 0;
interface_ip.num_wr_ports = 0;
interface_ip.num_se_rd_ports = 0;
dcache.missb = new ArrayST(&interface_ip, "dcacheMissBuffer", Core_device, coredynp.opt_local, coredynp.core_ty);
dcache.area.set_area(dcache.area.get_area() + dcache.missb->local_result.area);
area.set_area(area.get_area() + dcache.missb->local_result.area);
//output_data_csv(dcache.missb.local_result);
//fill buffer
tag = XML->sys.physical_address_width + EXTRA_TAG_BITS;
data = dcache.caches->l_ip.line_sz;
interface_ip.specific_tag = 1;
interface_ip.tag_w = tag;
interface_ip.line_sz = data; //int(pow(2.0,ceil(log2(data))));
interface_ip.cache_sz = data * XML->sys.core[ithCore].dcache.buffer_sizes[1];
interface_ip.assoc = 0;
interface_ip.nbanks = 1;
interface_ip.out_w = interface_ip.line_sz * 8;
interface_ip.access_mode = 2;
interface_ip.throughput = debug ? 1.0 / clockRate : XML->sys.core[ithCore].dcache.dcache_config[4] / clockRate;
interface_ip.latency = debug ? 1.0 / clockRate : XML->sys.core[ithCore].dcache.dcache_config[5] / clockRate;
interface_ip.obj_func_dyn_energy = 0;
interface_ip.obj_func_dyn_power = 0;
interface_ip.obj_func_leak_power = 0;
interface_ip.obj_func_cycle_t = 1;
interface_ip.num_rw_ports = debug ? 1 : XML->sys.core[ithCore].memory_ports;
;
interface_ip.num_rd_ports = 0;
interface_ip.num_wr_ports = 0;
interface_ip.num_se_rd_ports = 0;
dcache.ifb = new ArrayST(&interface_ip, "dcacheFillBuffer", Core_device, coredynp.opt_local, coredynp.core_ty);
dcache.area.set_area(dcache.area.get_area() + dcache.ifb->local_result.area);
area.set_area(area.get_area() + dcache.ifb->local_result.area);
//output_data_csv(dcache.ifb.local_result);
//prefetch buffer
tag = XML->sys.physical_address_width + EXTRA_TAG_BITS; //check with previous entries to decide wthether to merge.
data = dcache.caches->l_ip.line_sz; //separate queue to prevent from cache polution.
interface_ip.specific_tag = 1;
interface_ip.tag_w = tag;
interface_ip.line_sz = data; //int(pow(2.0,ceil(log2(data))));
interface_ip.cache_sz = XML->sys.core[ithCore].dcache.buffer_sizes[2] * interface_ip.line_sz;
interface_ip.assoc = 0;
interface_ip.nbanks = 1;
interface_ip.out_w = interface_ip.line_sz * 8;
interface_ip.access_mode = 2;
interface_ip.throughput = debug ? 1.0 / clockRate : XML->sys.core[ithCore].dcache.dcache_config[4] / clockRate;
interface_ip.latency = debug ? 1.0 / clockRate : XML->sys.core[ithCore].dcache.dcache_config[5] / clockRate;
interface_ip.obj_func_dyn_energy = 0;
interface_ip.obj_func_dyn_power = 0;
interface_ip.obj_func_leak_power = 0;
interface_ip.obj_func_cycle_t = 1;
interface_ip.num_rw_ports = debug ? 1 : XML->sys.core[ithCore].memory_ports;
;
interface_ip.num_rd_ports = 0;
interface_ip.num_wr_ports = 0;
interface_ip.num_se_rd_ports = 0;
dcache.prefetchb = new ArrayST(&interface_ip, "dcacheprefetchBuffer", Core_device, coredynp.opt_local, coredynp.core_ty);
dcache.area.set_area(dcache.area.get_area() + dcache.prefetchb->local_result.area);
area.set_area(area.get_area() + dcache.prefetchb->local_result.area);
//output_data_csv(dcache.prefetchb.local_result);
//WBB
if (cache_p == Write_back) {
tag = XML->sys.physical_address_width + EXTRA_TAG_BITS;
data = dcache.caches->l_ip.line_sz;
interface_ip.specific_tag = 1;
interface_ip.tag_w = tag;
interface_ip.line_sz = data;
interface_ip.cache_sz = XML->sys.core[ithCore].dcache.buffer_sizes[3] * interface_ip.line_sz;
interface_ip.assoc = 0;
interface_ip.nbanks = 1;
interface_ip.out_w = interface_ip.line_sz * 8;
interface_ip.access_mode = 2;
interface_ip.throughput = debug ? 1.0 / clockRate : XML->sys.core[ithCore].dcache.dcache_config[4] / clockRate;
interface_ip.latency = debug ? 1.0 / clockRate : XML->sys.core[ithCore].dcache.dcache_config[5] / clockRate;
interface_ip.obj_func_dyn_energy = 0;
interface_ip.obj_func_dyn_power = 0;
interface_ip.obj_func_leak_power = 0;
interface_ip.obj_func_cycle_t = 1;
interface_ip.num_rw_ports = XML->sys.core[ithCore].memory_ports;
interface_ip.num_rd_ports = 0;
interface_ip.num_wr_ports = 0;
interface_ip.num_se_rd_ports = 0;
dcache.wbb = new ArrayST(&interface_ip, "dcacheWBB", Core_device, coredynp.opt_local, coredynp.core_ty);
dcache.area.set_area(dcache.area.get_area() + dcache.wbb->local_result.area);
area.set_area(area.get_area() + dcache.wbb->local_result.area);
//output_data_csv(dcache.wbb.local_result);
}
/*
* LSU--in-order processors do not have separate load queue: unified lsq
* partitioned among threads
* it is actually the store queue but for inorder processors it serves as both loadQ and StoreQ
*/
tag = ldst_opcode + XML->sys.virtual_address_width + int(ceil(log2(XML->sys.core[ithCore].number_hardware_threads))) + EXTRA_TAG_BITS;
data = XML->sys.machine_bits;
interface_ip.is_cache = true;
interface_ip.line_sz = int(ceil(data / 32.0))*4;
interface_ip.specific_tag = 1;
interface_ip.tag_w = tag;
interface_ip.cache_sz = XML->sys.core[ithCore].store_buffer_size * interface_ip.line_sz;
interface_ip.assoc = 0;
interface_ip.nbanks = 1;
interface_ip.out_w = interface_ip.line_sz * 8;
interface_ip.access_mode = 1;
interface_ip.throughput = 1.0 / clockRate;
interface_ip.latency = 1.0 / clockRate;
interface_ip.obj_func_dyn_energy = 0;
interface_ip.obj_func_dyn_power = 0;
interface_ip.obj_func_leak_power = 0;
interface_ip.obj_func_cycle_t = 1;
interface_ip.num_rw_ports = 0;
interface_ip.num_rd_ports = XML->sys.core[ithCore].memory_ports;
interface_ip.num_wr_ports = XML->sys.core[ithCore].memory_ports;
interface_ip.num_se_rd_ports = 0;
interface_ip.num_search_ports = XML->sys.core[ithCore].memory_ports;
LSQ = new ArrayST(&interface_ip, "Load(Store)Queue", Core_device, coredynp.opt_local, coredynp.core_ty);
LSQ->area.set_area(LSQ->area.get_area() + LSQ->local_result.area);
area.set_area(area.get_area() + LSQ->local_result.area);
//output_data_csv(LSQ.LSQ.local_result);
lsq_height = LSQ->local_result.cache_ht * sqrt(cdb_overhead); /*XML->sys.core[ithCore].number_hardware_threads*/
if ((coredynp.core_ty == OOO) && (XML->sys.core[ithCore].load_buffer_size > 0)) {
interface_ip.line_sz = int(ceil(data / 32.0))*4;
interface_ip.specific_tag = 1;
interface_ip.tag_w = tag;
interface_ip.cache_sz = XML->sys.core[ithCore].load_buffer_size * interface_ip.line_sz;
interface_ip.assoc = 0;
interface_ip.nbanks = 1;
interface_ip.out_w = interface_ip.line_sz * 8;
interface_ip.access_mode = 1;
interface_ip.throughput = 1.0 / clockRate;
interface_ip.latency = 1.0 / clockRate;
interface_ip.obj_func_dyn_energy = 0;
interface_ip.obj_func_dyn_power = 0;
interface_ip.obj_func_leak_power = 0;
interface_ip.obj_func_cycle_t = 1;
interface_ip.num_rw_ports = 0;
interface_ip.num_rd_ports = XML->sys.core[ithCore].memory_ports;
interface_ip.num_wr_ports = XML->sys.core[ithCore].memory_ports;
interface_ip.num_se_rd_ports = 0;
interface_ip.num_search_ports = XML->sys.core[ithCore].memory_ports;
LoadQ = new ArrayST(&interface_ip, "LoadQueue", Core_device, coredynp.opt_local, coredynp.core_ty);
LoadQ->area.set_area(LoadQ->area.get_area() + LoadQ->local_result.area);
area.set_area(area.get_area() + LoadQ->local_result.area);
//output_data_csv(LoadQ.LoadQ.local_result);
lsq_height = (LSQ->local_result.cache_ht + LoadQ->local_result.cache_ht) * sqrt(cdb_overhead); /*XML->sys.core[ithCore].number_hardware_threads*/
}
area.set_area(area.get_area() * cdb_overhead);
}
MemManU::MemManU(ParseXML* XML_interface, int ithCore_, InputParameter* interface_ip_, const CoreDynParam & dyn_p_, bool exist_)
: XML(XML_interface),
ithCore(ithCore_),
interface_ip(*interface_ip_),
coredynp(dyn_p_),
itlb(0),
dtlb(0),
exist(exist_) {
if (!exist) return;
int tag, data;
bool debug = false;
clockRate = coredynp.clockRate;
executionTime = coredynp.executionTime;
interface_ip.is_cache = true;
interface_ip.pure_cam = false;
interface_ip.pure_ram = false;
interface_ip.specific_tag = 1;
//Itlb TLBs are partioned among threads according to Nigara and Nehalem
tag = XML->sys.virtual_address_width - int(floor(log2(XML->sys.virtual_memory_page_size))) + int(ceil(log2(XML->sys.core[ithCore].number_hardware_threads))) + EXTRA_TAG_BITS;
data = XML->sys.physical_address_width - int(floor(log2(XML->sys.virtual_memory_page_size)));
interface_ip.tag_w = tag;
interface_ip.line_sz = int(ceil(data / 8.0)); //int(ceil(pow(2.0,ceil(log2(data)))/8.0));
interface_ip.cache_sz = XML->sys.core[ithCore].itlb.number_entries * interface_ip.line_sz; //*XML->sys.core[ithCore].number_hardware_threads;
interface_ip.assoc = 0;
interface_ip.nbanks = 1;
interface_ip.out_w = interface_ip.line_sz * 8;
interface_ip.access_mode = 0;
interface_ip.throughput = debug ? 1.0 / clockRate : XML->sys.core[ithCore].icache.icache_config[4] / clockRate;
interface_ip.latency = debug ? 1.0 / clockRate : XML->sys.core[ithCore].icache.icache_config[5] / clockRate;
interface_ip.obj_func_dyn_energy = 0;
interface_ip.obj_func_dyn_power = 0;
interface_ip.obj_func_leak_power = 0;
interface_ip.obj_func_cycle_t = 1;
interface_ip.num_rw_ports = 0;
interface_ip.num_rd_ports = 0;
interface_ip.num_wr_ports = debug ? 1 : XML->sys.core[ithCore].number_instruction_fetch_ports;
interface_ip.num_se_rd_ports = 0;
interface_ip.num_search_ports = debug ? 1 : XML->sys.core[ithCore].number_instruction_fetch_ports;
itlb = new ArrayST(&interface_ip, "ITLB", Core_device, coredynp.opt_local, coredynp.core_ty);
itlb->area.set_area(itlb->area.get_area() + itlb->local_result.area);
area.set_area(area.get_area() + itlb->local_result.area);
//output_data_csv(itlb.tlb.local_result);
//dtlb
tag = XML->sys.virtual_address_width - int(floor(log2(XML->sys.virtual_memory_page_size))) + int(ceil(log2(XML->sys.core[ithCore].number_hardware_threads))) + EXTRA_TAG_BITS;
data = XML->sys.physical_address_width - int(floor(log2(XML->sys.virtual_memory_page_size)));
interface_ip.specific_tag = 1;
interface_ip.tag_w = tag;
interface_ip.line_sz = int(ceil(data / 8.0)); //int(ceil(pow(2.0,ceil(log2(data)))/8.0));
interface_ip.cache_sz = XML->sys.core[ithCore].dtlb.number_entries * interface_ip.line_sz; //*XML->sys.core[ithCore].number_hardware_threads;
interface_ip.assoc = 0;
interface_ip.nbanks = 1;
interface_ip.out_w = interface_ip.line_sz * 8;
interface_ip.access_mode = 0;
interface_ip.throughput = debug ? 1.0 / clockRate : XML->sys.core[ithCore].dcache.dcache_config[4] / clockRate;
interface_ip.latency = debug ? 1.0 / clockRate : XML->sys.core[ithCore].dcache.dcache_config[5] / clockRate;
interface_ip.obj_func_dyn_energy = 0;
interface_ip.obj_func_dyn_power = 0;
interface_ip.obj_func_leak_power = 0;
interface_ip.obj_func_cycle_t = 1;
interface_ip.num_rw_ports = 0;
interface_ip.num_rd_ports = 0;
interface_ip.num_wr_ports = XML->sys.core[ithCore].memory_ports;
interface_ip.num_se_rd_ports = 0;
interface_ip.num_search_ports = XML->sys.core[ithCore].memory_ports;
dtlb = new ArrayST(&interface_ip, "DTLB", Core_device, coredynp.opt_local, coredynp.core_ty);
dtlb->area.set_area(dtlb->area.get_area() + dtlb->local_result.area);
area.set_area(area.get_area() + dtlb->local_result.area);
//output_data_csv(dtlb.tlb.local_result);
}
IBuffer::IBuffer(ParseXML* XML_interface, int ithCore_, InputParameter* interface_ip_, const CoreDynParam & dyn_p_, bool exist_)
: XML(XML_interface),
ithCore(ithCore_),
interface_ip(*interface_ip_),
coredynp(dyn_p_),
Buffer(0),
exist(exist_) {
clockRate = coredynp.clockRate;
executionTime = coredynp.executionTime;