Make exiting from simple_system tests work with Spike

This commit is contained in:
Rupert Swarbrick 2020-03-02 15:34:28 +00:00 committed by Rupert Swarbrick
parent e9872889bf
commit 91d7721fa9
4 changed files with 20 additions and 4 deletions

View file

@ -131,7 +131,7 @@ binary.
| Address | Description |
|---------------------|--------------------------------------------------------------------------------------------------------|
| 0x20000 | ASCII Out, write ASCII characters here that will get output to the log file |
| 0x20004 | Simulator Halt, write 1 here to halt the simulation |
| 0x20008 | Simulator Halt, write 1 here to halt the simulation |
| 0x30000 | RISC-V timer `mtime` register |
| 0x30004 | RISC-V timer `mtimeh` register |
| 0x30008 | RISC-V timer `mtimecmp` register |

View file

@ -19,6 +19,16 @@ _stack_start = ORIGIN(stack) + LENGTH(stack);
_entry_point = _vectors_start + 0x80;
ENTRY(_entry_point)
/* The tohost address is used by Spike for a magic "stop me now" message. This
is set to equal SIM_CTRL_CTRL (see simple_system_regs.h), which has that
effect in simple_system simulations. Note that it must be 8-byte aligned.
We don't read data back from Spike, so fromhost is set to some dummy value:
we place it just above the top of the stack.
*/
tohost = 0x20008;
fromhost = _stack_start + 0x10;
SECTIONS
{
.vectors :

View file

@ -7,7 +7,7 @@
#define SIM_CTRL_BASE 0x20000
#define SIM_CTRL_OUT 0x0
#define SIM_CTRL_CTRL 0x4
#define SIM_CTRL_CTRL 0x8
#define TIMER_BASE 0x30000
#define TIMER_MTIME 0x0

View file

@ -10,7 +10,13 @@
*
* * 0x0 - CHAR_OUT_ADDR - [7:0] of write data output via output_char DPI call
* and SimOutputManager (see dv/common/cpp/sim_output_manager.cc)
* * 0x4 - SIM_CTRL_ADDR - Write 1 to bit 0 to halt sim
*
* * 0x8 - SIM_CTRL_ADDR - Write 1 to bit 0 to halt sim
*
* The slightly odd spacing is because we also use SIM_CTRL_ADDR when
* simulating simple_system code with Spike, which requires the address to be
* 64-bit aligned.
*
*/
module simulator_ctrl #(
@ -33,7 +39,7 @@ module simulator_ctrl #(
);
localparam CHAR_OUT_ADDR = 0;
localparam SIM_CTRL_ADDR = 1;
localparam SIM_CTRL_ADDR = 2;
logic [7:0] ctrl_addr;
logic [2:0] sim_finish = 3'b000;