Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

instruction fetch unit finally DONE #37

Merged
merged 1 commit into from
Jun 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/core/core.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ Core::Core(const ParseXML *XML_interface,

clockRate = coredynp.clockRate;
executionTime = coredynp.executionTime;
ifu = new InstFetchU(XML, ithCore, &interface_ip, coredynp, exit_flag);
ifu = new InstFetchU();
ifu->set_params(XML, ithCore, &interface_ip, coredynp, exit_flag);
ifu->computeArea();
ifu->set_stats(XML);

lsu = new LoadStoreU(XML, ithCore, &interface_ip, coredynp, exit_flag);
mmu = new MemManU();
mmu->set_params(XML, ithCore, &interface_ip, coredynp);
Expand Down Expand Up @@ -155,7 +159,7 @@ void Core::computeEnergy(bool is_tdp) {
double rtp_pipeline_coe;
double num_units = 4.0;
if (is_tdp) {
ifu->computeEnergy(is_tdp);
ifu->computeDynamicPower(is_tdp);
lsu->computeEnergy(is_tdp);
mmu->computeDynamicPower(is_tdp);
exu.computeDynamicPower(is_tdp);
Expand Down Expand Up @@ -245,7 +249,7 @@ void Core::computeEnergy(bool is_tdp) {
}

} else {
ifu->computeEnergy(is_tdp);
ifu->computeDynamicPower(is_tdp);
lsu->computeEnergy(is_tdp);
mmu->computeDynamicPower(is_tdp);
exu.computeDynamicPower(is_tdp);
Expand Down
103 changes: 68 additions & 35 deletions src/core/instfetch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,16 @@
#include <iostream>
#include <string>

InstFetchU::InstFetchU(const ParseXML *XML_interface,
void InstFetchU::set_params(const 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_),
exist(exist_) {
bool exist_){
XML=XML_interface; ithCore=ithCore_; interface_ip=*interface_ip_;
coredynp=dyn_p_;
exist=exist_;


if (!exist)
return;
int idx, tag, data, size, line, assoc, banks;
Expand Down Expand Up @@ -105,13 +107,10 @@ InstFetchU::InstFetchU(const ParseXML *XML_interface,
Core_device,
coredynp.opt_local,
coredynp.core_ty);
icache.caches.computeArea();

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);

/*
Expand Down Expand Up @@ -162,9 +161,6 @@ InstFetchU::InstFetchU(const ParseXML *XML_interface,
Core_device,
coredynp.opt_local,
coredynp.core_ty);
icache.missb.computeArea();
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
Expand Down Expand Up @@ -200,9 +196,6 @@ InstFetchU::InstFetchU(const ParseXML *XML_interface,
Core_device,
coredynp.opt_local,
coredynp.core_ty);
icache.ifb.computeArea();
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
Expand Down Expand Up @@ -242,10 +235,6 @@ InstFetchU::InstFetchU(const ParseXML *XML_interface,
Core_device,
coredynp.opt_local,
coredynp.core_ty);
icache.prefetchb.computeArea();
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
Expand Down Expand Up @@ -292,9 +281,6 @@ InstFetchU::InstFetchU(const ParseXML *XML_interface,
Core_device,
coredynp.opt_local,
coredynp.core_ty);
IB.computeArea();
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;
Expand Down Expand Up @@ -360,15 +346,9 @@ InstFetchU::InstFetchU(const ParseXML *XML_interface,
Core_device,
coredynp.opt_local,
coredynp.core_ty);
BTB.computeArea();
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.set_params(XML, ithCore, &interface_ip, coredynp);
BPT.computeArea();
BPT.set_stats(XML);
area.set_area(area.get_area() + BPT.area.get_area());

}

ID_inst.set_params(is_default,
Expand All @@ -394,13 +374,56 @@ InstFetchU::InstFetchU(const ParseXML *XML_interface,
coredynp.x86,
Core_device,
coredynp.core_ty);

ID_misc.computeArea();
ID_misc.computeDynamicPower();
init_params = true;
}

void InstFetchU::set_stats(const ParseXML *XML_interface){
if (coredynp.predictionW > 0) {
BPT.set_stats(XML);
}
init_stats = true;
}

void InstFetchU::computeArea(){
if (!init_params) {
std::cerr << "[ InstFetchU ] Error: must set params before calling "
"computeArea()\n";

exit(1);
}
icache.caches.computeArea();
icache.area.set_area(icache.area.get_area() +
icache.caches.local_result.area);
area.set_area(area.get_area() + icache.caches.local_result.area);

icache.missb.computeArea();
icache.area.set_area(icache.area.get_area() + icache.missb.local_result.area);
area.set_area(area.get_area() + icache.missb.local_result.area);

icache.ifb.computeArea();
icache.area.set_area(icache.area.get_area() + icache.ifb.local_result.area);
area.set_area(area.get_area() + icache.ifb.local_result.area);

icache.prefetchb.computeArea();
icache.area.set_area(icache.area.get_area() +
icache.prefetchb.local_result.area);
area.set_area(area.get_area() + icache.prefetchb.local_result.area);

IB.computeArea();
IB.area.set_area(IB.area.get_area() + IB.local_result.area);
area.set_area(area.get_area() + IB.local_result.area);

if (coredynp.predictionW > 0) {
BPT.computeArea();
area.set_area(area.get_area() + BPT.area.get_area());
BTB.computeArea();
BTB.area.set_area(BTB.area.get_area() + BTB.local_result.area);
area.set_area(area.get_area() + BTB.local_result.area);
}

ID_misc.computeArea();
ID_operand.computeArea();
ID_operand.computeDynamicPower();
ID_inst.computeArea();
ID_inst.computeDynamicPower();

// 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.
Expand All @@ -410,9 +433,15 @@ InstFetchU::InstFetchU(const ParseXML *XML_interface,
coredynp.decodeW);
}

void InstFetchU::computeEnergy(bool is_tdp) {
void InstFetchU::computeDynamicPower(bool is_tdp) {

if (!exist)
return;
if (!init_stats) {
std::cerr << "[ InstFetchU ] Error: must set params before calling "
"computeDynamicPower()\n";
exit(1);
}
if (is_tdp) {
// init stats for Peak
icache.caches.stats_t.readAc.access =
Expand Down Expand Up @@ -559,6 +588,10 @@ void InstFetchU::computeEnergy(bool is_tdp) {
// (icache.missb.local_result.power +
// icache.ifb.local_result.power +
// icache.prefetchb.local_result.power)*pppm_Isub;

ID_misc.computeDynamicPower();
ID_operand.computeDynamicPower();
ID_inst.computeDynamicPower();
icache.power =
icache.power_t +
(icache.caches.local_result.power + icache.missb.local_result.power +
Expand Down
11 changes: 9 additions & 2 deletions src/core/instfetch.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,21 @@ class InstFetchU : public Component {
inst_decoder ID_misc;
bool exist;

InstFetchU(const ParseXML *XML_interface,
InstFetchU(){init_params = false; init_stats = false;};
void set_stats(const ParseXML *XML_interface);
void set_params(const ParseXML *XML_interface,
int ithCore_,
InputParameter *interface_ip_,
const CoreDynParam &dyn_p_,
bool exsit = true);
void computeEnergy(bool is_tdp = true);
void computeArea();
void computeDynamicPower(bool is_tdp = true);
void displayEnergy(uint32_t indent = 0, int plevel = 100, bool is_tdp = true);
~InstFetchU();

private:
bool init_params;
bool init_stats;
};

#endif // __INST_FETCH_U_H__