From: Yunsup Lee Date: Sun, 10 Apr 2011 02:35:14 +0000 (-0700) Subject: [sim] add vt stuff X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e9567ce7bbcdd59cc6e6bc2133a1680c1598cb04;p=riscv-isa-sim.git [sim] add vt stuff --- diff --git a/riscv/decode.h b/riscv/decode.h index bb1f605..c2702a6 100644 --- a/riscv/decode.h +++ b/riscv/decode.h @@ -207,4 +207,49 @@ private: #define CRD do_writeback(XPR,(insn.bits >> 5) & 0x1f) #define CIMM6 ((int32_t)((insn.bits >> 10) & 0x3f) << 26 >> 26) +// vector stuff +#define VL vl + +#define UT_RS1(idx) uts[idx]->XPR[insn.rtype.rs1] +#define UT_RS2(idx) uts[idx]->XPR[insn.rtype.rs2] +#define UT_RD(idx) do_writeback(uts[idx]->XPR,insn.rtype.rd) +#define UT_RA(idx) do_writeback(uts[idx]->XPR,1) +#define UT_FRS1(idx) uts[idx]->FPR[insn.ftype.rs1] +#define UT_FRS2(idx) uts[idx]->FPR[insn.ftype.rs2] +#define UT_FRS3(idx) uts[idx]->FPR[insn.ftype.rs3] +#define UT_FRD(idx) uts[idx]->FPR[insn.ftype.rd] +#define UT_RM(idx) ((insn.ftype.rm != 7) ? insn.ftype.rm : \ + ((uts[idx]->fsr & FSR_RD) >> FSR_RD_SHIFT)) + +#define UT_LOOP_START for (int i=0;i> 6) & 0x3f; +vcfg(); +setvl(RS1); +RD = VL; diff --git a/riscv/insns/vf.h b/riscv/insns/vf.h index e69de29..eff542c 100644 --- a/riscv/insns/vf.h +++ b/riscv/insns/vf.h @@ -0,0 +1,7 @@ +for (int i=0; ipc = RS1+SIMM; + uts[i]->utmode = true; + while (uts[i]->utmode) + uts[i]->step(n, noisy); +} diff --git a/riscv/processor.cc b/riscv/processor.cc index 8aa2966..99da902 100644 --- a/riscv/processor.cc +++ b/riscv/processor.cc @@ -32,6 +32,17 @@ processor_t::processor_t(sim_t* _sim, char* _mem, size_t _memsz) memset(counters,0,sizeof(counters)); + // vector stuff + utidx = -1; + vlmax = 8; + vl = 0; + nxpr_all = 256; + nfpr_all = 256; + nxpr_use = 0; + nfpr_use = 0; + for (int i=0; iset_sr(uts[i]->sr | SR_EF); + uts[i]->utidx = i; + } } void processor_t::set_sr(uint32_t val) @@ -67,6 +85,25 @@ void processor_t::set_fsr(uint32_t val) fsr = val & ~FSR_ZERO; } +void processor_t::vcfg() +{ + if (nxpr_use == 0 && nfpr_use == 0) + vlmax = 8; + else if (nfpr_use == 0) + vlmax = (nxpr_all-1) / (nxpr_use-1); + else if (nxpr_use == 0) + vlmax = (nfpr_all-1) / (nfpr_use-1); + else + vlmax = std::min((nxpr_all-1) / (nxpr_use-1), (nfpr_all-1) / (nfpr_use-1)); + + vlmax = std::min(vlmax, MAX_UTS); +} + +void processor_t::setvl(int vlapp) +{ + vl = std::min(vlmax, vlapp); +} + void processor_t::step(size_t n, bool noisy) { size_t i = 0; @@ -101,6 +138,11 @@ void processor_t::step(size_t n, bool noisy) i++; take_trap(t,noisy); } + catch(vt_command_t cmd) + { + if (cmd == vt_command_stop) + return; + } } void processor_t::take_trap(trap_t t, bool noisy) diff --git a/riscv/processor.h b/riscv/processor.h index c1c65ce..34c31ac 100644 --- a/riscv/processor.h +++ b/riscv/processor.h @@ -6,13 +6,15 @@ #include "trap.h" #include "mmu.h" +#define MAX_UTS 32 + class sim_t; class processor_t { public: processor_t(sim_t* _sim, char* _mem, size_t _memsz); - void init(uint32_t _id); + void init(uint32_t _id, char* _mem, size_t _memsz); void step(size_t n, bool noisy); private: @@ -55,6 +57,20 @@ private: void take_trap(trap_t t, bool noisy); void disasm(insn_t insn, reg_t pc); + // vector stuff + void vcfg(); + void setvl(int vlapp); + + bool utmode; + int utidx; + int vlmax; + int vl; + int nxpr_all; + int nfpr_all; + int nxpr_use; + int nfpr_use; + processor_t* uts[MAX_UTS]; + friend class sim_t; }; diff --git a/riscv/sim.cc b/riscv/sim.cc index 56326b5..fbea374 100644 --- a/riscv/sim.cc +++ b/riscv/sim.cc @@ -15,7 +15,7 @@ sim_t::sim_t(int _nprocs, size_t _memsz, appserver_link_t* _applink) demand(mem != MAP_FAILED, "couldn't allocate target machine's memory"); for(int i = 0; i < (int)procs.size(); i++) - procs[i].init(i); + procs[i].init(i, mem, memsz); applink->init(this); }