File mock_instr_buffer.h
File List > projects > simtix > src > simtix > uvm > mock_instr_buffer.h
Go to the documentation of this file
#pragma once
#include <cstdint>
#include <vector>
#include "sm/pipelined/instr_buffer.h"
#include "sm/pipelined/pipelined.h"
namespace simtix {
namespace uvm {
using pipelined::PipelinedSM;
using pipelined::PipelinedSMImpl;
class MockInstrBuffer : public pipelined::InstrBuffer {
public:
explicit MockInstrBuffer(
PipelinedSMImpl *sm, const ArchParam &p = kDefaultArchParam,
const PipelinedSM::Param &pp = PipelinedSM::kDefaultParam)
: InstrBuffer(sm, p, pp),
capacious_warps_(p.kWarpsPerCore()),
fetch_pc_(p.kWarpsPerCore(), 0) {}
~MockInstrBuffer() = default;
bool capacious(uint32_t wid, std::optional<uint32_t> ssw) const override {
return capacious_warps_[wid];
}
uint64_t fetch_pc(uint32_t wid, std::optional<uint32_t> ssw) const override {
return fetch_pc_[wid];
}
void PutTestInput(std::vector<bool> capacious_warps,
std::vector<uint64_t> fetch_pc) {
assert(capacious_warps.size() == capacious_warps_.size() ||
fetch_pc.size() == fetch_pc_.size());
capacious_warps_ = capacious_warps;
fetch_pc_ = fetch_pc;
}
void ResetTestInput() {
std::fill(capacious_warps_.begin(), capacious_warps_.end(), false);
std::fill(fetch_pc_.begin(), fetch_pc_.end(), 0);
}
bool empty(uint32_t wid, std::optional<uint32_t> ssw) const { return false; }
protected:
std::vector<bool> capacious_warps_;
std::vector<uint64_t> fetch_pc_;
};
} // namespace uvm
} // namespace simtix