Skip to content

Commit

Permalink
use 0xff for exit message instead of 0x1
Browse files Browse the repository at this point in the history
  • Loading branch information
wsipak committed Nov 6, 2024
1 parent 2c319b8 commit 156b6b8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions euvm/riscv/gen/riscv_asm_program_gen.d
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,8 @@ class riscv_asm_program_gen : uvm_object

void gen_program_end(int hart) {
if (hart == 0) {
// Use write_tohost to terminate spike simulation
gen_section("write_tohost", ["sw gp, tohost, t5"]);
// Use write_tohost to terminate verilator/spike simulation
gen_section("write_tohost", ["li gp, 0xff", "sw gp, tohost, t5"]);
gen_section("_exit", ["j write_tohost"]);
}
}
Expand Down
4 changes: 3 additions & 1 deletion pygen/experimental/riscv_asm_program_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@ def gen_test_done(self):
def gen_program_end(self):
# TODO: this instruction puts Spike in an infinite loop. For now, I just
# replace it with "writing 1 into tohost" to tell Spike to exit.
self.gen_section("write_tohost", ["sw gp, tohost, t5"])

# end verilator with 0xff
self.gen_section("write_tohost", ["li gp, 0xff", "sw gp, tohost, t5"])
# self.gen_section("write_tohost", ["li t0, 1", "la t1, tohost", "sw t0, 0(t1)"])
self.gen_section("_exit", ["j write_tohost"])

Expand Down
4 changes: 2 additions & 2 deletions pygen/pygen_src/riscv_asm_program_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,8 @@ def gen_program_header(self):

def gen_program_end(self, hart):
if hart == 0:
# Use write_tohost to terminate spike simulation
self.gen_section("write_tohost", ["sw gp, tohost, t5"])
# Use write_tohost to terminate verilator/spike simulation
self.gen_section("write_tohost", ["li gp, 0xff", "sw gp, tohost, t5"])
self.gen_section("_exit", ["j write_tohost"])

def gen_data_page_begin(self, hart):
Expand Down
4 changes: 2 additions & 2 deletions src/riscv_asm_program_gen.sv
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ class riscv_asm_program_gen extends uvm_object;

virtual function void gen_program_end(int hart);
if (hart == 0) begin
// Use write_tohost to terminate spike simulation
gen_section("write_tohost", {"sw gp, tohost, t5"});
// Use write_tohost to terminate verilator/spike simulation
gen_section("write_tohost", {"li gp, 0xff", "sw gp, tohost, t5"});
gen_section("_exit", {"j write_tohost"});
end
endfunction
Expand Down

0 comments on commit 156b6b8

Please sign in to comment.