diff options
author | Jerry Zhao <jerryz123@berkeley.edu> | 2024-06-28 13:00:19 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-28 13:00:19 -0700 |
commit | f2a20b185e3c339a9dec60d75853847734e44e85 (patch) | |
tree | 420a14a4bf37919998d41d360163a32f7784b32d | |
parent | ed5f817613a066600f5e417a1e4d6af74db56ec5 (diff) | |
parent | 3947fa0e1cd4f244ee191c67790e033d9b3e7fa3 (diff) | |
download | spike-f2a20b185e3c339a9dec60d75853847734e44e85.zip spike-f2a20b185e3c339a9dec60d75853847734e44e85.tar.gz spike-f2a20b185e3c339a9dec60d75853847734e44e85.tar.bz2 |
Merge pull request #1715 from abejgonzalez/fix-interactive-vregs
Don't print vregs in interactive mode if no V extension exists
-rw-r--r-- | riscv/interactive.cc | 63 |
1 files changed, 34 insertions, 29 deletions
diff --git a/riscv/interactive.cc b/riscv/interactive.cc index 3f76513..b0855fa 100644 --- a/riscv/interactive.cc +++ b/riscv/interactive.cc @@ -580,39 +580,44 @@ void sim_t::interactive_vreg(const std::string& cmd, const std::vector<std::stri } } + std::ostream out(sout_.rdbuf()); + // Show all the regs! processor_t *p = get_core(args[0]); - const int vlen = (int)(p->VU.get_vlen()) >> 3; - const int elen = (int)(p->VU.get_elen()) >> 3; - const int num_elem = vlen/elen; - - std::ostream out(sout_.rdbuf()); - out << std::dec << "VLEN=" << (vlen << 3) << " bits; ELEN=" << (elen << 3) << " bits" << std::endl; - - for (int r = rstart; r < rend; ++r) { - out << std::setfill (' ') << std::left << std::setw(4) << vr_name[r] << std::right << ": "; - for (int e = num_elem-1; e >= 0; --e) { - uint64_t val; - switch (elen) { - case 8: - val = p->VU.elt<uint64_t>(r, e); - out << std::dec << "[" << e << "]: 0x" << std::hex << std::setfill ('0') << std::setw(16) << val << " "; - break; - case 4: - val = p->VU.elt<uint32_t>(r, e); - out << std::dec << "[" << e << "]: 0x" << std::hex << std::setfill ('0') << std::setw(8) << (uint32_t)val << " "; - break; - case 2: - val = p->VU.elt<uint16_t>(r, e); - out << std::dec << "[" << e << "]: 0x" << std::hex << std::setfill ('0') << std::setw(8) << (uint16_t)val << " "; - break; - case 1: - val = p->VU.elt<uint8_t>(r, e); - out << std::dec << "[" << e << "]: 0x" << std::hex << std::setfill ('0') << std::setw(8) << (int)(uint8_t)val << " "; - break; + if (p->any_vector_extensions()) { + const int vlen = (int)(p->VU.get_vlen()) >> 3; + const int elen = (int)(p->VU.get_elen()) >> 3; + const int num_elem = vlen/elen; + + out << std::dec << "VLEN=" << (vlen << 3) << " bits; ELEN=" << (elen << 3) << " bits" << std::endl; + + for (int r = rstart; r < rend; ++r) { + out << std::setfill (' ') << std::left << std::setw(4) << vr_name[r] << std::right << ": "; + for (int e = num_elem-1; e >= 0; --e) { + uint64_t val; + switch (elen) { + case 8: + val = p->VU.elt<uint64_t>(r, e); + out << std::dec << "[" << e << "]: 0x" << std::hex << std::setfill ('0') << std::setw(16) << val << " "; + break; + case 4: + val = p->VU.elt<uint32_t>(r, e); + out << std::dec << "[" << e << "]: 0x" << std::hex << std::setfill ('0') << std::setw(8) << (uint32_t)val << " "; + break; + case 2: + val = p->VU.elt<uint16_t>(r, e); + out << std::dec << "[" << e << "]: 0x" << std::hex << std::setfill ('0') << std::setw(8) << (uint16_t)val << " "; + break; + case 1: + val = p->VU.elt<uint8_t>(r, e); + out << std::dec << "[" << e << "]: 0x" << std::hex << std::setfill ('0') << std::setw(8) << (int)(uint8_t)val << " "; + break; + } } + out << std::endl; } - out << std::endl; + } else { + out << "Processor selected does not support any vector extensions" << std::endl; } } |