44 using UnitID = uint32_t;
45 using InstID = uint64_t;
47 static constexpr UnitID INVALID_UNIT_ID = std::numeric_limits<UnitID>::max();
48 static constexpr uint32_t INVALID_LATENCY =
static_cast<uint32_t
>(-1);
49 static constexpr uint32_t MAX_REGISTERS = 512;
51 using RegisterBitMask = std::bitset<MAX_REGISTERS>;
59 using LatencyMatrixParameterType = std::vector<std::vector<std::string>>;
76 PARAMETER(LatencyMatrixParameterType, latency_matrix, {},
77 "The forwarding latency matrix. See the Scoreboard test for format example")
97 void set(
const RegisterBitMask & bits);
109 void set(
const RegisterBitMask & bits, UnitID producer);
132 bool isSet(
const RegisterBitMask & bits)
const;
140 RegisterBitMask global_reg_ready_mask_{0xffffffff};
143 using ForwardingLatency = uint32_t;
144 using ForwardingLatencyConsumers = std::vector<ForwardingLatency>;
145 using ForwardingLatencyProducers = std::vector<ForwardingLatencyConsumers>;
148 ForwardingLatencyProducers forwarding_latencies_;
151 using UnitToIDMap = std::map<std::string, uint32_t>;
152 UnitToIDMap unit_name_to_id_;
156 using UnitIDToSBVs = std::vector<std::vector<ScoreboardView *>>;
157 UnitIDToSBVs unit_id_to_scoreboard_views_;
160 using ConsumerSBV = std::tuple<ScoreboardView *, ForwardingLatency>;
161 using ConsumerSBVs = std::vector<ConsumerSBV>;
162 using ProducerToConsumerSBVs = std::vector<ConsumerSBVs>;
163 ProducerToConsumerSBVs producer_to_consumer_scoreboard_views_;
166 uint32_t unit_id_ = 0;
169 struct ScoreboardUpdate {
170 RegisterBitMask bits;
175 struct ScoreboardViewUpdate
177 ScoreboardUpdate first;
178 ScoreboardView *second;
182 void deliverScoreboardUpdate_(
const ScoreboardViewUpdate &);
207 const std::string & scoreboard_type,
225 const Scoreboard::InstID inst_id,
242 bool isSet(
const Scoreboard::RegisterBitMask & bits)
const
244 return bits == (local_ready_mask_ & bits);
251 void setReady(
const Scoreboard::RegisterBitMask & bits);
258 return scoreboard_type_;
280 void receiveScoreboardUpdate_(
const Scoreboard::RegisterBitMask & bits,
281 const Scoreboard::UnitID producer);
284 Scoreboard::UnitID findMasterScoreboard_(
const std::string & unit_name,
285 const std::string & scoreboard_type,
292 void clearBits_(
const Scoreboard::RegisterBitMask & bits);
294 Scoreboard::RegisterBitMask local_ready_mask_{0xffffffff};
297 Scoreboard * master_scoreboard_ =
nullptr;
301 CallbackData(
const Scoreboard::RegisterBitMask & bv,
302 const Scoreboard::InstID iid,
304 sparta::Clock::Cycle cyc) :
305 needed_bits(bv), inst_id(iid), callback(cb), registered_time(cyc)
309 CallbackData(CallbackData&&) =
default;
311 const Scoreboard::RegisterBitMask needed_bits;
312 const Scoreboard::InstID inst_id;
314 sparta::Clock::Cycle registered_time;
317 using ReadinessCallbacks = std::list<CallbackData>;
318 ReadinessCallbacks ready_callbacks_;
321 const std::string unit_name_;
322 const Scoreboard::UnitID unit_id_;
323 const std::string scoreboard_type_;
328 extern std::string printBitSet(
const Scoreboard::RegisterBitMask & bits);
A set of sparta::Parameters per sparta::ResourceTreeNode.
#define PARAMETER(type, name, def, doc)
Parameter declaration.
File that defines the PayloadEvent class.
Basic Node framework in sparta device tree composite pattern.
File that defines the Unit class, a common grouping of sets and loggers.
A representation of simulated time.
Generic container of Parameters.
Class to schedule a Scheduleable in the future with a payload, typed on both the data type and the sc...
A ScoreboardView is a view into the master Scoreboard for operand readiness.
std::string getType() const
Get the scoreboard type identifier.
std::string getName() const
Get the name of this view.
void registerReadyCallback(const Scoreboard::RegisterBitMask &bits, const Scoreboard::InstID inst_id, const ReadinessCallback &callback)
Register a ready callback to be called when the bits are ready.
bool isSet(const Scoreboard::RegisterBitMask &bits) const
See if the given bits are set.
std::function< void(const Scoreboard::RegisterBitMask &)> ReadinessCallback
Typedef for the callbacks.
ScoreboardView(const std::string &unit_name, const std::string &scoreboard_type, sparta::TreeNode *node)
Create a ScoreboardView.
void setReady(const Scoreboard::RegisterBitMask &bits)
Set the given bits as ready in the Scoreboard.
void clearCallbacks(const Scoreboard::InstID inst_id)
On a flush any registered callback needs to be "forgotten".
Class used to track operand dependencies (timed) between units.
static const char name[]
Name of this resource. Required by sparta::ResourceFactory.
Scoreboard(sparta::TreeNode *container, const ScoreboardParameters *params)
Construct a Scoreboard.
UnitID registerView(const std::string &producer_name, ScoreboardView *view)
Register a view with this Scoreboard based on producer's name. The producer name MUST be listed in co...
bool isSet(const RegisterBitMask &bits) const
Look at the master scoreboard's view of ready.
void set(const RegisterBitMask &bits, UnitID producer)
Set Ready bits on the master scoreboard.
void clearBits(const RegisterBitMask &bits)
Clear the given bits from the Scoreboard.
void set(const RegisterBitMask &bits)
Set Ready bits on the master scoreboard.
Node in a composite tree representing a sparta Tree item.
The is the base class for user defined blocks in simulation.
Macros for handling exponential backoff.