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

Fixed all of the FP <-> Int transfer types; added a test #94

Merged
1 commit merged into from
Oct 6, 2023
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
36 changes: 18 additions & 18 deletions arches/isa_json/olympia_uarch_rv64g.json
Original file line number Diff line number Diff line change
Expand Up @@ -776,126 +776,126 @@
{
"mnemonic" : "fle.s",
"dispatch" : ["fpu"],
"pipe" : "i2f",
"pipe" : "f2i",
"transfer" : true,
"latency" : 2
},
{
"mnemonic" : "flt.s",
"dispatch" : ["fpu"],
"pipe" : "i2f",
"pipe" : "f2i",
"transfer" : true,
"latency" : 2
},
{
"mnemonic" : "feq.s",
"dispatch" : ["fpu"],
"pipe" : "i2f",
"pipe" : "f2i",
"transfer" : true,
"latency" : 2
},
{
"mnemonic" : "fle.d",
"dispatch" : ["fpu"],
"pipe" : "i2f",
"pipe" : "f2i",
"transfer" : true,
"latency" : 2
},
{
"mnemonic" : "flt.d",
"dispatch" : ["fpu"],
"pipe" : "i2f",
"pipe" : "f2i",
"transfer" : true,
"latency" : 2
},
{
"mnemonic" : "feq.d",
"dispatch" : ["fpu"],
"pipe" : "i2f",
"pipe" : "f2i",
"transfer" : true,
"latency" : 2
},
{
"mnemonic" : "fcvt.w.s",
"dispatch" : ["fpu"],
"pipe" : "i2f",
"pipe" : "f2i",
"transfer" : true,
"latency" : 2
},
{
"mnemonic" : "fcvt.wu.s",
"dispatch" : ["fpu"],
"pipe" : "i2f",
"pipe" : "f2i",
"transfer" : true,
"latency" : 2
},
{
"mnemonic" : "fcvt.l.s",
"dispatch" : ["fpu"],
"pipe" : "i2f",
"pipe" : "f2i",
"transfer" : true,
"latency" : 2
},
{
"mnemonic" : "fcvt.lu.s",
"dispatch" : ["fpu"],
"pipe" : "i2f",
"pipe" : "f2i",
"transfer" : true,
"latency" : 2
},
{
"mnemonic" : "fmv.x.w",
"dispatch" : ["fpu"],
"pipe" : "i2f",
"pipe" : "f2i",
"transfer" : true,
"latency" : 2
},
{
"mnemonic" : "fclass.s",
"dispatch" : ["fpu"],
"pipe" : "i2f",
"pipe" : "f2i",
"transfer" : true,
"latency" : 2
},
{
"mnemonic" : "fcvt.w.d",
"dispatch" : ["fpu"],
"pipe" : "i2f",
"pipe" : "f2i",
"transfer" : true,
"latency" : 2
},
{
"mnemonic" : "fcvt.wu.d",
"dispatch" : ["fpu"],
"pipe" : "i2f",
"pipe" : "f2i",
"transfer" : true,
"latency" : 2
},
{
"mnemonic" : "fcvt.l.d",
"dispatch" : ["fpu"],
"pipe" : "i2f",
"pipe" : "f2i",
"transfer" : true,
"latency" : 2
},
{
"mnemonic" : "fcvt.lu.d",
"dispatch" : ["fpu"],
"pipe" : "i2f",
"pipe" : "f2i",
"transfer" : true,
"latency" : 2
},
{
"mnemonic" : "fmv.x.d",
"dispatch" : ["fpu"],
"pipe" : "i2f",
"pipe" : "f2i",
"transfer" : true,
"latency" : 2
},
{
"mnemonic" : "fclass.d",
"dispatch" : ["fpu"],
"pipe" : "i2f",
"pipe" : "f2i",
"transfer" : true,
"latency" : 2
},
Expand Down
5 changes: 3 additions & 2 deletions core/CoreUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ namespace olympia::coreutils
}
inline core_types::RegFile determineRegisterFile(const mavis::OperandInfo::Element & reg)
{
static const std::map<mavis::InstMetaData::OperandTypes, core_types::RegFile> mavis_optype_to_regfile = {
// mapping of supported types ...
static const std::map<mavis::InstMetaData::OperandTypes, core_types::RegFile> mavis_optype_to_regfile = {
// mapping of supported types ...
{mavis::InstMetaData::OperandTypes::SINGLE, core_types::RegFile::RF_FLOAT},
{mavis::InstMetaData::OperandTypes::DOUBLE, core_types::RegFile::RF_FLOAT},
{mavis::InstMetaData::OperandTypes::WORD, core_types::RegFile::RF_INTEGER},
Expand All @@ -37,4 +37,5 @@ namespace olympia::coreutils
sparta_assert(false, "Unknown reg type: " << static_cast<uint32_t>(reg.operand_type));
return core_types::RegFile::RF_INVALID;
}

}
24 changes: 19 additions & 5 deletions core/ExecutePipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,25 @@ namespace olympia
ILOG("Completing inst: " << ex_inst);

// set scoreboard
if(SPARTA_EXPECT_FALSE(ex_inst->getPipe() == InstArchInfo::TargetPipe::I2F)) {
sparta_assert(reg_file_ == core_types::RegFile::RF_INTEGER,
"Got an I2F instruction in an ExecutionPipe that does not source the integer RF");
const auto & dest_bits = ex_inst->getDestRegisterBitMask(core_types::RegFile::RF_FLOAT);
scoreboard_views_[core_types::RegFile::RF_FLOAT]->setReady(dest_bits);
if(SPARTA_EXPECT_FALSE(ex_inst->isTransfer()))
{
if(ex_inst->getPipe() == InstArchInfo::TargetPipe::I2F)
{
// Integer source -> FP dest -- need to mark the appropriate destination SB
sparta_assert(reg_file_ == core_types::RegFile::RF_INTEGER,
"Got an I2F instruction in an ExecutionPipe that does not source the integer RF: " << ex_inst);
const auto & dest_bits = ex_inst->getDestRegisterBitMask(core_types::RegFile::RF_FLOAT);
scoreboard_views_[core_types::RegFile::RF_FLOAT]->setReady(dest_bits);
}
else {
// FP source -> Integer dest -- need to mark the appropriate destination SB
sparta_assert(ex_inst->getPipe() == InstArchInfo::TargetPipe::F2I,
"Instruction is marked transfer type, but I2F nor F2I: " << ex_inst);
sparta_assert(reg_file_ == core_types::RegFile::RF_FLOAT,
"Got an F2I instruction in an ExecutionPipe that does not source the Float RF: " << ex_inst);
const auto & dest_bits = ex_inst->getDestRegisterBitMask(core_types::RegFile::RF_INTEGER);
scoreboard_views_[core_types::RegFile::RF_INTEGER]->setReady(dest_bits);
}
}
else {
const auto & dest_bits = ex_inst->getDestRegisterBitMask(reg_file_);
Expand Down
11 changes: 9 additions & 2 deletions core/Inst.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include "InstArchInfo.hpp"
#include "CoreTypes.hpp"
#include "MiscUtils.hpp"

#include <cstdlib>
#include <ostream>
Expand Down Expand Up @@ -100,6 +101,10 @@ namespace olympia
opcode_info_ (opcode_info),
inst_arch_info_ (inst_arch_info),
is_store_(opcode_info->isInstType(mavis::OpcodeInfo::InstructionTypes::STORE)),
is_transfer_(miscutils::isOneOf(inst_arch_info_->getTargetPipe(),
InstArchInfo::TargetPipe::I2F,
InstArchInfo::TargetPipe::F2I)),

status_state_(Status::FETCHED)
{
sparta_assert(inst_arch_info_ != nullptr,
Expand Down Expand Up @@ -184,6 +189,7 @@ namespace olympia

uint64_t getRAdr() const { return target_vaddr_ | 0x8000000; } // faked
bool isSpeculative() const { return is_speculative_; }
bool isTransfer() const { return is_transfer_; }

// Rename information
core_types::RegisterBitMask & getSrcRegisterBitMask(const core_types::RegFile rf) {
Expand Down Expand Up @@ -220,7 +226,8 @@ namespace olympia
uint64_t unique_id_ = 0; // Supplied by Fetch
uint64_t program_id_ = 0; // Supplied by a trace Reader or execution backend
bool is_speculative_ = false; // Is this instruction soon to be flushed?
bool is_store_ = false;
const bool is_store_;
const bool is_transfer_; // Is this a transfer instruction (F2I/I2F)
sparta::Scheduleable * ev_retire_ = nullptr;
Status status_state_;

Expand Down Expand Up @@ -308,4 +315,4 @@ namespace olympia
extern InstAllocator inst_allocator;
extern InstArchInfoAllocator inst_arch_info_allocator;

}
}
1 change: 1 addition & 0 deletions core/InstArchInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace olympia
{"float", InstArchInfo::TargetPipe::FLOAT},
{"fmac", InstArchInfo::TargetPipe::FMAC},
{"i2f", InstArchInfo::TargetPipe::I2F},
{"f2i", InstArchInfo::TargetPipe::F2I},
{"int", InstArchInfo::TargetPipe::INT},
{"lsu", InstArchInfo::TargetPipe::LSU},
{"mul", InstArchInfo::TargetPipe::MUL},
Expand Down
1 change: 1 addition & 0 deletions core/InstArchInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ namespace olympia
FLOAT,
FMAC,
I2F,
F2I,
INT,
LSU,
MUL,
Expand Down
14 changes: 14 additions & 0 deletions core/MiscUtils.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// <MiscUtils.hpp> -*- C++ -*-

#pragma once

namespace olympia::miscutils
{
// Is var in the set of vals
// https://stackoverflow.com/questions/15181579/c-most-efficient-way-to-compare-a-variable-to-multiple-values
// Usage: bool in = isOneOf(x, 1, 5, 7, 9, 23);
template<typename Var, typename ... Val>
bool isOneOf(Var&& var, Val&& ... val) {
return ((var == val) || ...);
}
}
3 changes: 3 additions & 0 deletions test/sim/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ sparta_named_test(olympia_coremark_test_report_html olympia -i 1M
sparta_named_test(olympia_json_test_missing_opcodes olympia
--workload json_tests/missing_opcodes.json)

sparta_named_test(olympia_json_test_fp_transfers olympia
--workload json_tests/fp_transfers.json)

# Test the arches
file(GLOB TEST_YAML "${SIM_BASE}/arches/*.yaml")
foreach(ARCH_FULL_PATH ${TEST_YAML})
Expand Down
Loading