mirror of
https://github.com/vortexgpgpu/vortex.git
synced 2025-04-20 11:57:41 -04:00
186 lines
3.8 KiB
C++
186 lines
3.8 KiB
C++
// Copyright © 2019-2023
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
#pragma once
|
|
|
|
#include <vector>
|
|
#include <simobject.h>
|
|
#include "types.h"
|
|
#include "emulator.h"
|
|
#include "pipeline.h"
|
|
#include "cache_sim.h"
|
|
#include "local_mem.h"
|
|
#include "ibuffer.h"
|
|
#include "scoreboard.h"
|
|
#include "operand.h"
|
|
#include "dispatcher.h"
|
|
#include "func_unit.h"
|
|
#include "mem_coalescer.h"
|
|
#include "VX_config.h"
|
|
|
|
namespace vortex {
|
|
|
|
class Socket;
|
|
class Arch;
|
|
class DCRS;
|
|
|
|
using TraceArbiter = Arbiter<instr_trace_t*>;
|
|
|
|
class Core : public SimObject<Core> {
|
|
public:
|
|
struct PerfStats {
|
|
uint64_t cycles;
|
|
uint64_t instrs;
|
|
uint64_t sched_idle;
|
|
uint64_t sched_stalls;
|
|
uint64_t ibuf_stalls;
|
|
uint64_t scrb_stalls;
|
|
uint64_t opds_stalls;
|
|
uint64_t scrb_alu;
|
|
uint64_t scrb_fpu;
|
|
uint64_t scrb_lsu;
|
|
uint64_t scrb_sfu;
|
|
uint64_t scrb_csrs;
|
|
uint64_t scrb_wctl;
|
|
uint64_t ifetches;
|
|
uint64_t loads;
|
|
uint64_t stores;
|
|
uint64_t ifetch_latency;
|
|
uint64_t load_latency;
|
|
|
|
PerfStats()
|
|
: cycles(0)
|
|
, instrs(0)
|
|
, sched_idle(0)
|
|
, sched_stalls(0)
|
|
, ibuf_stalls(0)
|
|
, scrb_stalls(0)
|
|
, opds_stalls(0)
|
|
, scrb_alu(0)
|
|
, scrb_fpu(0)
|
|
, scrb_lsu(0)
|
|
, scrb_sfu(0)
|
|
, scrb_csrs(0)
|
|
, scrb_wctl(0)
|
|
, ifetches(0)
|
|
, loads(0)
|
|
, stores(0)
|
|
, ifetch_latency(0)
|
|
, load_latency(0)
|
|
{}
|
|
};
|
|
|
|
std::vector<SimPort<MemReq>> icache_req_ports;
|
|
std::vector<SimPort<MemRsp>> icache_rsp_ports;
|
|
|
|
std::vector<SimPort<MemReq>> dcache_req_ports;
|
|
std::vector<SimPort<MemRsp>> dcache_rsp_ports;
|
|
|
|
Core(const SimContext& ctx,
|
|
uint32_t core_id,
|
|
Socket* socket,
|
|
const Arch &arch,
|
|
const DCRS &dcrs);
|
|
|
|
~Core();
|
|
|
|
void reset();
|
|
|
|
void tick();
|
|
|
|
void attach_ram(RAM* ram);
|
|
#ifdef VM_ENABLE
|
|
void set_satp(uint64_t satp);
|
|
#endif
|
|
|
|
bool running() const;
|
|
|
|
void resume(uint32_t wid);
|
|
|
|
bool barrier(uint32_t bar_id, uint32_t count, uint32_t wid);
|
|
|
|
bool wspawn(uint32_t num_warps, Word nextPC);
|
|
|
|
uint32_t id() const {
|
|
return core_id_;
|
|
}
|
|
|
|
const Arch& arch() const {
|
|
return arch_;
|
|
}
|
|
|
|
Socket* socket() const {
|
|
return socket_;
|
|
}
|
|
|
|
const LocalMem::Ptr& local_mem() const {
|
|
return local_mem_;
|
|
}
|
|
|
|
const MemCoalescer::Ptr& mem_coalescer(uint32_t idx) const {
|
|
return mem_coalescers_.at(idx);
|
|
}
|
|
|
|
const PerfStats& perf_stats() const {
|
|
return perf_stats_;
|
|
}
|
|
|
|
int get_exitcode() const;
|
|
|
|
private:
|
|
|
|
void schedule();
|
|
void fetch();
|
|
void decode();
|
|
void issue();
|
|
void execute();
|
|
void commit();
|
|
|
|
uint32_t core_id_;
|
|
Socket* socket_;
|
|
const Arch& arch_;
|
|
|
|
Emulator emulator_;
|
|
|
|
std::vector<IBuffer> ibuffers_;
|
|
Scoreboard scoreboard_;
|
|
std::vector<Operand::Ptr> operands_;
|
|
std::vector<Dispatcher::Ptr> dispatchers_;
|
|
std::vector<FuncUnit::Ptr> func_units_;
|
|
LocalMem::Ptr local_mem_;
|
|
std::vector<LocalMemSwitch::Ptr> lmem_switch_;
|
|
std::vector<MemCoalescer::Ptr> mem_coalescers_;
|
|
|
|
PipelineLatch fetch_latch_;
|
|
PipelineLatch decode_latch_;
|
|
|
|
HashTable<instr_trace_t*> pending_icache_;
|
|
uint64_t pending_instrs_;
|
|
|
|
uint64_t pending_ifetches_;
|
|
|
|
PerfStats perf_stats_;
|
|
|
|
std::vector<TraceArbiter::Ptr> commit_arbs_;
|
|
|
|
uint32_t commit_exe_;
|
|
uint32_t ibuffer_idx_;
|
|
|
|
friend class LsuUnit;
|
|
friend class AluUnit;
|
|
friend class FpuUnit;
|
|
friend class SfuUnit;
|
|
friend class TcuUnit;
|
|
};
|
|
|
|
} // namespace vortex
|