Skip to content

Commit 4f1d8ab

Browse files
authored
Merge pull request #2005 from riscv-software-src/ziccid
Implement Ziccid extension
2 parents 9919430 + 833ab91 commit 4f1d8ab

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

disasm/isa_parser.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ isa_parser_t::isa_parser_t(const char* str, const char *priv)
140140
// HINTs encoded in base-ISA instructions are always present.
141141
} else if (ext_str == "zihintntl") {
142142
// HINTs encoded in base-ISA instructions are always present.
143+
} else if (ext_str == "ziccid") {
144+
extension_table[EXT_ZICCID] = true;
145+
} else if (ext_str == "ziccif") {
146+
// aligned instruction fetch is always atomic in Spike
143147
} else if (ext_str == "zaamo") {
144148
extension_table[EXT_ZAAMO] = true;
145149
} else if (ext_str == "zalrsc") {

riscv/execute.cc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@ bool processor_t::slow_path() const
210210
// fetch/decode/execute loop
211211
void processor_t::step(size_t n)
212212
{
213+
mmu_t* _mmu = mmu;
214+
213215
if (!state.debug_mode) {
214216
if (halt_request == HR_REGULAR) {
215217
enter_debug_mode(DCSR_CAUSE_DEBUGINT, 0);
@@ -221,10 +223,18 @@ void processor_t::step(size_t n)
221223
}
222224
}
223225

226+
if (extension_enabled(EXT_ZICCID)) {
227+
// Ziccid requires stores eventually become visible to instruction fetch,
228+
// so periodically flush the I$
229+
if (ziccid_flush_count-- == 0) {
230+
ziccid_flush_count += ZICCID_FLUSH_PERIOD;
231+
_mmu->flush_icache();
232+
}
233+
}
234+
224235
while (n > 0) {
225236
size_t instret = 0;
226237
reg_t pc = state.pc;
227-
mmu_t* _mmu = mmu;
228238
state.prv_changed = false;
229239
state.v_changed = false;
230240

riscv/isa_parser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ typedef enum {
5050
EXT_ZFINX,
5151
EXT_ZHINX,
5252
EXT_ZHINXMIN,
53+
EXT_ZICCID,
5354
EXT_ZICBOM,
5455
EXT_ZICBOZ,
5556
EXT_ZICNTR,

riscv/processor.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,9 @@ class processor_t : public abstract_device_t
412412
static const size_t OPCODE_CACHE_SIZE = 4095;
413413
opcode_cache_entry_t opcode_cache[OPCODE_CACHE_SIZE];
414414

415+
unsigned ziccid_flush_count = 0;
416+
static const unsigned ZICCID_FLUSH_PERIOD = 10;
417+
415418
bool is_handled_in_vs();
416419
void take_pending_interrupt() { take_interrupt(state.mip->read() & state.mie->read()); }
417420
void take_interrupt(reg_t mask); // take first enabled interrupt in mask

0 commit comments

Comments
 (0)