Skip to content

Commit 10525c1

Browse files
committed
sw: change success exit code to 0
1 parent 337dcaa commit 10525c1

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

rtl/tb_croc_soc.sv

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,8 @@ module tb_croc_soc #(
285285
endtask
286286

287287
// Wait for termination signal and get return code
288+
// Poll bit zero of core status register which signals end of computation
289+
// Bits 1 to 31 contain the application's return value
288290
task automatic jtag_wait_for_eoc(output bit [31:0] exit_code);
289291
automatic dm::sbcs_t sbcs = dm::sbcs_t'{sbreadonaddr: 1'b1, sbaccess: 2, default: '0};
290292
jtag_write(dm::SBCS, sbcs, 0, 1);
@@ -294,7 +296,11 @@ module tb_croc_soc #(
294296
jtag_dbg.wait_idle(20);
295297
jtag_dbg.read_dmi_exp_backoff(dm::SBData0, exit_code);
296298
end while (exit_code == 0);
297-
$display("@%t | [JTAG] Simulation finished: return code 0x%0h", $time, exit_code);
299+
exit_code >>= 1;
300+
if (exit_code)
301+
$display("@%t | [JTAG] Simulation finished: FAIL (return code 0x%0h)", $time, exit_code);
302+
else
303+
$display("@%t | [JTAG] Simulation finished: SUCCESS", $time);
298304
$finish();
299305
endtask
300306

sw/crt0.S

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ _start:
3232
li x15, 0
3333
call main
3434
_eoc:
35-
la t0, status
36-
sw a0, 0(t0)
35+
# Write status register in SoC control regs
36+
# Bit 0 signals end of computation
37+
# Bits 31:1 contain return code
38+
slli t0, a0, 1
39+
ori t0, t0, 1
40+
la t1, status
41+
sw t0, 0(t1)
3742
wfi

sw/helloworld.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,5 @@ int main() {
8282
sleep_ms(10);
8383
printf("Tock\n");
8484
uart_write_flush();
85-
return 1;
85+
return 0;
8686
}

0 commit comments

Comments
 (0)