18 static std::vector<ExampleInst::StaticInfo> dummy_opcodes =
20 { {0x7c01f214, 0xffffffff, {},
"add.", 0 }, ExampleInst::TargetUnit::ALU0, 1,
false},
21 { {0x7c6f0f10, 0xffffffff, {},
"cntlzw", 0 }, ExampleInst::TargetUnit::ALU1, 1,
false},
22 { {0x7c800000, 0xffffffff, {},
"add", 0 }, ExampleInst::TargetUnit::ALU0, 1,
false},
23 { {0x7c700000, 0xffffffff, {},
"subf.", 0 }, ExampleInst::TargetUnit::ALU1, 1,
false},
24 { {0x7c000000, 0xffffffff, {},
"and", 0 }, ExampleInst::TargetUnit::ALU0, 1,
false},
25 { {0x7c000000, 0xffffffff, {},
"and", 0 }, ExampleInst::TargetUnit::ALU0, 1,
false},
26 { {0x7c000710, 0xffffffff, {},
"fadd.", 0 }, ExampleInst::TargetUnit::FPU, 1,
false},
27 { {0x7c700000, 0xffffffff, {},
"cmp", 0 }, ExampleInst::TargetUnit::ALU1, 1,
false},
28 { {0x7c700010, 0xffffffff, {},
"cmn", 0 }, ExampleInst::TargetUnit::ALU1, 1,
false},
29 { {0x7c500000, 0xffffffff, {},
"cmp", 0 }, ExampleInst::TargetUnit::ALU1, 1,
false},
30 { {0x7c500000, 0xffffffff, {},
"cmp", 0 }, ExampleInst::TargetUnit::ALU1, 1,
false},
31 { {0x7c400010, 0xffffffff, {},
"sub", 0 }, ExampleInst::TargetUnit::ALU1, 1,
false},
32 { {0xfc800500, 0xffffffff, {},
"fabs",0 }, ExampleInst::TargetUnit::FPU, 5,
false},
33 { {0xfc000700, 0xffffffff, {},
"fctid.", 0 }, ExampleInst::TargetUnit::FPU, 5,
false},
34 { {0xfc200d00, 0xffffffff, {},
"fadd.", 0 }, ExampleInst::TargetUnit::FPU, 5,
false},
35 { {0xfc800700, 0xffffffff, {},
"fadd.",0 }, ExampleInst::TargetUnit::FPU, 5,
false},
36 { {0xfcb10300, 0xffffffff, {},
"fadd.", 0 }, ExampleInst::TargetUnit::FPU, 5,
false},
37 { {0xfcb00ac0, 0xffffffff, {},
"fadd.", 0 }, ExampleInst::TargetUnit::FPU, 5,
false},
38 { {0xfc000800, 0xffffffff, {},
"fadd.", 0 }, ExampleInst::TargetUnit::FPU, 5,
false},
39 { {0xfc000d00, 0xffffffff, {},
"fadd.", 0 }, ExampleInst::TargetUnit::FPU, 5,
false},
40 { {0xfc300a00, 0xffffffff, {},
"fadd.", 0 }, ExampleInst::TargetUnit::FPU, 5,
false},
41 { {0xfc800400, 0xffffffff, {},
"fadd.", 0 }, ExampleInst::TargetUnit::FPU, 10,
false},
42 { {0xfc800000, 0xffffffff, {},
"fadd.", 0 }, ExampleInst::TargetUnit::FPU, 1,
false},
43 { {0xfc800100, 0xffffffff, {},
"fadd.", 0 }, ExampleInst::TargetUnit::FPU, 1,
false},
44 { {0xfc000110, 0xffffffff, {},
"fdiv", 0 }, ExampleInst::TargetUnit::FPU, 20,
false},
45 { {0xfc800030, 0xffffffff, {},
"fdiv.", 0 }, ExampleInst::TargetUnit::FPU, 30,
false},
46 { {0xfc100000, 0xffffffff, {},
"sync", 0 }, ExampleInst::TargetUnit::ROB, 1,
false},
47 { {0x7ea00010, 0xffffffff, {},
"lwx", 0 }, ExampleInst::TargetUnit::LSU, 10,
false},
48 { {0xfca00030, 0xffffffff, {},
"stw", 0 }, ExampleInst::TargetUnit::LSU, 10,
true}
53 void Fetch::fetchInstruction_()
55 const uint32_t upper = std::min(credits_inst_queue_, num_insts_to_fetch_);
58 if(upper == 0) {
return; }
60 InstGroup insts_to_send;
61 for(uint32_t i = 0; i < upper; ++i) {
62 ExampleInstPtr ex_inst;
65 sparta::allocate_sparta_shared_pointer<ExampleInst>(example_inst_allocator,
74 sparta::allocate_sparta_shared_pointer<ExampleInst>(example_inst_allocator,
75 dummy_opcodes[rand() % dummy_opcodes.size()],
getClock());
77 ex_inst->setUniqueID(++next_inst_id_);
78 ex_inst->setVAdr(vaddr_);
79 ex_inst->setSpeculative(speculative_path_);
80 insts_to_send.emplace_back(ex_inst);
83 info_logger_ <<
"RANDOM: Sending: " << ex_inst <<
" down the pipe";
85 speculative_path_ = (ex_inst->getUnit() == ExampleInst::TargetUnit::ROB);
91 out_fetch_queue_write_.
send(insts_to_send);
93 credits_inst_queue_ -= upper;
94 if(credits_inst_queue_ > 0) {
95 fetch_inst_event_->schedule(1);
99 info_logger_ <<
"Fetch: send num_inst=" << insts_to_send.size()
100 <<
" instructions, remaining credit=" << credits_inst_queue_;
107 num_insts_to_fetch_(p->num_to_fetch),
108 next_pc_(node,
"next_pc", &vaddr_)
110 in_fetch_queue_credits_.
113 if (p->fetch_max_ipc ==
true) {
128 srand(p->inst_rand_seed);
132 void Fetch::receiveFetchQueueCredits_(
const uint32_t & dat) {
133 credits_inst_queue_ += dat;
136 info_logger_ <<
"Fetch: receive num_decode_credits=" << dat
137 <<
", total decode_credits=" << credits_inst_queue_;
141 fetch_inst_event_->schedule(sparta::Clock::Cycle(0));
145 void Fetch::flushFetch_(
const uint64_t & new_addr) {
148 << std::hex << new_addr << std::dec;
155 out_fetch_queue_write_.
cancel();
158 speculative_path_ =
false;
Definition of the CoreModel Fetch unit.
#define SPARTA_EXPECT_FALSE(x)
A macro for hinting to the compiler a particular condition should be considered most likely false.
#define CREATE_SPARTA_HANDLER_WITH_DATA(clname, meth, dataT)
#define CREATE_SPARTA_HANDLER(clname, meth)
File that defines the StartupEvent class.
Parameters for Fetch model.
Fetch(sparta::TreeNode *name, const FetchParameterSet *p)
Constructor for Fetch.
static const char * name
Name of this resource. Required by sparta::UnitFactory.
uint32_t cancel()
Cancel all outstanding port sends regardless of criteria.
void send(const DataT &dat, sparta::Clock::Cycle rel_time=0)
Send data to bound receivers.
void registerConsumerHandler(const SpartaHandler &handler)
Register a handler to this Port (must be Direction::IN) to handle data arrival.
const Clock * getClock() const
An event that can only be schedule one cycle into the future.
Node in a composite tree representing a sparta Tree item.
sparta::EventSet unit_event_set_
The Unit's event set.
log::MessageSource info_logger_
Default info logger.
Macros for handling exponential backoff.