The Sparta Modeling Framework
Loading...
Searching...
No Matches
Fetch.hpp
Go to the documentation of this file.
1// <Fetch.hpp> -*- C++ -*-
2
7
8
9#pragma once
10
11#include <string>
18
19#include "CoreTypes.hpp"
20
21namespace core_example
22{
33 class Fetch : public sparta::Unit
34 {
35 public:
38 {
39 public:
42 {
43 auto non_zero_validator = [](uint32_t & val, const sparta::TreeNode*)->bool {
44 if(val > 0) {
45 return true;
46 }
47 return false;
48 };
49 num_to_fetch.addDependentValidationCallback(non_zero_validator,
50 "Num to fetch must be greater than 0");
51 }
52
53 PARAMETER(uint32_t, num_to_fetch, 4, "Number of instructions to fetch")
54 PARAMETER(uint32_t, inst_rand_seed, 0xdeadbeef, "Seed for random instruction fetch")
55 PARAMETER(bool, fetch_max_ipc, false, "Fetch tries to maximize IPC by distributing insts")
56 };
57
65 const FetchParameterSet * p);
66
67 ~Fetch() {
69 << ": "
70 << example_inst_allocator.getNumAllocated()
71 << " ExampleInst objects allocated/created"
72 << std::endl;
73 }
74
76 static const char * name;
77
78 private:
79
80 // Internal DataOutPort to the decode unit's fetch queue
81 sparta::DataOutPort<InstGroup> out_fetch_queue_write_ {&unit_port_set_, "out_fetch_queue_write"};
82
83 // Internal DataInPort from decode's fetch queue for credits
84 sparta::DataInPort<uint32_t> in_fetch_queue_credits_
85 {&unit_port_set_, "in_fetch_queue_credits", sparta::SchedulingPhase::Tick, 0};
86
87 // Incoming flush from Retire w/ redirect
88 sparta::DataInPort<uint64_t> in_fetch_flush_redirect_
89 {&unit_port_set_, "in_fetch_flush_redirect", sparta::SchedulingPhase::Flush, 1};
90
91 // Number of instructions to fetch
92 const uint32_t num_insts_to_fetch_;
93
94 // Number of credits from decode that fetch has
95 uint32_t credits_inst_queue_ = 0;
96
97 // Current "PC"
98 uint64_t vaddr_ = 0x1000;
99
100 // Fetch instruction event, triggered when there are credits
101 // from decode. The callback set is either to fetch random
102 // instructions or a perfect IPC set
103 std::unique_ptr<sparta::SingleCycleUniqueEvent<>> fetch_inst_event_;
104
105 // A pipeline collector
107
109 // Callbacks
110
111 // Receive the number of free credits from decode
112 void receiveFetchQueueCredits_(const uint32_t &);
113
114 // Read data from a trace at random or at MaxIPC and send it
115 // through
116 template<bool MaxIPC>
117 void fetchInstruction_();
118
119 // Receive flush from retire
120 void flushFetch_(const uint64_t & new_addr);
121
122 // A unique instruction ID
123 uint64_t next_inst_id_ = 0;
124
125 // Are we fetching a speculative path?
126 bool speculative_path_ = false;
127 };
128
129}
Implementation of the Collectable class that allows a user to collect an object into an pipeViewer pi...
File that defines Data[In,Out]Port<DataT>
A set of sparta::Parameters per sparta::ResourceTreeNode.
#define PARAMETER(type, name, def, doc)
Parameter declaration.
File that defines the SingleCycleUniqueEvent class.
Basic Node framework in sparta device tree composite pattern.
File that defines the Unit class, a common grouping of sets and loggers.
Parameters for Fetch model.
Definition Fetch.hpp:38
static const char * name
Name of this resource. Required by sparta::UnitFactory.
Definition Fetch.hpp:76
DataInPort receives data from sender using a DataOutPort.
Definition DataPort.hpp:289
DataOutPort is used for transferring any data to another module.
Definition DataPort.hpp:77
Generic container of Parameters.
TreeNode * getContainer()
Gets the TreeNode (container) for this resource (if any)
Node in a composite tree representing a sparta Tree item.
Definition TreeNode.hpp:205
std::string getLocation() const override final
The is the base class for user defined blocks in simulation.
Definition Unit.hpp:38
log::MessageSource debug_logger_
Default debug logger.
Definition Unit.hpp:167
sparta::PortSet unit_port_set_
The Unit's Ports.
Definition Unit.hpp:111
Class used to either manually or auto-collect an Annotation String object in a pipeline database.
@ Tick
Most operations (combinational logic) occurs in this phase.
@ Flush
Phase where flushing of pipelines, etc can occur.