1*** Variables ***
2${URI}                              @https://dl.antmicro.com/projects/renode
3${UART}                             sysbus.uart
4${CPU_IBEX_NATIVE_LINUX}            ${URI}/libVcpu_ibex-Linux-x86_64-13112907851.so-s_2251128-ab2dcb1801188d7f934bdeafa93f9c1edc60ad39
5${CPU_IBEX_NATIVE_WINDOWS}          ${URI}/libVcpu_ibex-Windows-x86_64-13112907851.dll-s_3426669-58d11ffc81ea755c1d1151e6b33fc13164bb13d5
6${CPU_IBEX_NATIVE_MACOS}            ${URI}/libVcpu_ibex-macOS-x86_64-13112907851.dylib-s_336528-7677f09f18bfb2937ad2bffdd63ed7d76bb15d56
7
8*** Keywords ***
9Create Machine
10    Execute Command                 using sysbus
11    Execute Command                 mach create
12    Execute Command                 machine LoadPlatformDescription @platforms/cpus/verilated/verilated_ibex.repl
13    Execute Command                 sysbus.cpu SimulationFilePathLinux ${CPU_IBEX_NATIVE_LINUX}
14    Execute Command                 sysbus.cpu SimulationFilePathWindows ${CPU_IBEX_NATIVE_WINDOWS}
15    Execute Command                 sysbus.cpu SimulationFilePathMacOS ${CPU_IBEX_NATIVE_MACOS}
16    Execute Command                 logLevel 3
17    Execute Command                 $c_example=@https://dl.antmicro.com/projects/renode/verilated-ibex--c_example.elf-s_5956-ea5ae45679b4070cd21933b9602bbcfd80302c93
18    Execute Command                 showAnalyzer ${UART}
19    Execute Command                 sysbus LoadELF $c_example
20    Create Terminal Tester          ${UART}
21
22Check Register By Name
23    [Arguments]                     ${register}     ${x}
24    ${value}=  Execute Command      cpu ${register}
25    ${valuen}=  Convert To Integer  ${value}
26    ${xn}=  Convert To Integer      ${x}            16
27    Should Be True                  ${valuen} == ${xn}
28
29Check Register
30    [Arguments]                     ${register}     ${x}
31    ${value}=  Execute Command      cpu GetRegister ${register}
32    ${valuen}=  Convert To Integer  ${value}
33    ${xn}=  Convert To Integer      ${x}            16
34    Should Be True                  ${valuen} == ${xn}
35
36Set Register By Name
37    [Arguments]                     ${register}     ${x}
38    Execute Command                 cpu ${register} ${x}
39
40Step
41    Execute Command                 cpu Step
42
43*** Test Cases ***
44Should Read Write Registers
45    [Tags]                          skip_host_arm
46    Create Machine
47
48    # start
49    Check Register By Name          PC  0x80
50    Step
51
52    # first instruction
53    Check Register By Name          PC  0x82
54    Check register                  2   0xfffffff0
55    Check register                  8   0x0
56    Step
57
58    # second instruction
59    Check Register By Name          PC  0x84
60    Check register                  2   0xfffffff0
61    Check register                  8   0x0
62
63    # jump to begin
64    Set Register By Name            PC  0x80
65    Check Register By Name          PC  0x80
66    Step
67    Check Register By Name          PC  0x82
68    Step
69    Check Register By Name          PC  0x84
70    Step
71    Check Register By Name          PC  0x86
72    Step
73
74    Provides                        ecall  Reexecution
75
76Should Be In Machine Mode
77    [Tags]                          skip_host_arm
78    Requires                        ecall
79    Check Register By Name          MCAUSE  0xb
80    Check Register By Name          MEPC    0x86
81    Execute Command                 cpu ExecutionMode Continuous
82    Provides                        continuous-mode  Reexecution
83
84Should Print Hello On Uart
85    [Tags]                          skip_host_arm
86    Requires                        continuous-mode
87    Wait For Line On Uart           hello
88    Provides                        hello  Reexecution
89
90Should Print Hello On Uart Again
91    [Tags]                          skip_host_arm
92    Requires                        hello
93    Wait For Line On Uart           hello
94