1*** Variables ***
2${SYSTEMC_BINARY}                    @https://dl.antmicro.com/projects/renode/x64-systemc--dma.elf-s_943520-d936f6165ff706163a1d722c301a11a55672c365
3${PLATFORM}=    SEPARATOR=
4...  """                                                                        ${\n}
5...  memory: Memory.MappedMemory @ sysbus 0x20000000                            ${\n}
6...  ${SPACE*4}size: 0x1000000                                                  ${\n}
7...                                                                             ${\n}
8...  dma_systemc: SystemC.SystemCPeripheral @ sysbus <0x9000000, +0xffffff>     ${\n}
9...  ${SPACE*4}address: "127.0.0.1"                                             ${\n}
10...  ${SPACE*4}timeSyncPeriodUS: 5000                                           ${\n}
11...  """
12
13*** Keywords ***
14Create Machine
15    Execute Command                 mach create
16    Execute Command                 machine LoadPlatformDescriptionFromString ${PLATFORM}
17    Execute Command                 sysbus.dma_systemc SystemCExecutablePath ${SYSTEMC_BINARY}
18
19Memory Should Be Equal To
20    [Arguments]                     ${address}  ${value}
21    ${res}=                         Execute Command  sysbus ReadByte ${address}
22    Should Be Equal As Numbers      ${res}  ${value}
23
24*** Test Cases ***
25Should Perform Memory-To-Memory Transfer
26    [Tags]                          skip_windows    skip_osx
27    Create Machine
28    Start Emulation
29
30    # Initialize memory
31    Execute Command                 sysbus.memory WriteString 0 "Hello"
32
33    # Make sure memory destination is initialized to 0
34    Memory Should Be Equal To       0x20000010  0
35    Memory Should Be Equal To       0x20000011  0
36    Memory Should Be Equal To       0x20000012  0
37    Memory Should Be Equal To       0x20000013  0
38    Memory Should Be Equal To       0x20000014  0
39
40    # Set source address register in dma_systemc.
41    Execute Command                 sysbus WriteDoubleWord 0x9000004 0x20000000
42
43    # Set destination address register in dma_systemc.
44    Execute Command                 sysbus WriteDoubleWord 0x9000008 0x20000010
45
46    # Set data length register (in bytes) in dma_systemc.
47    Execute Command                 sysbus WriteDoubleWord 0x900000C 5
48
49    # Start memory-to-memory transfer in dma_systemc
50    Execute Command                 sysbus WriteDoubleWord 0x9000010 0x1
51
52    # Signal "bus free" to notify DMAC it can use the bus now.
53    Execute Command                 sysbus.dma_systemc OnGPIO 2 True
54
55    # Verify the memory was copied correctly.
56    # "H"
57    Memory Should Be Equal To       0x20000010  0x48
58    # "e"
59    Memory Should Be Equal To       0x20000011  0x65
60    # "l"
61    Memory Should Be Equal To       0x20000012  0x6C
62    # "l"
63    Memory Should Be Equal To       0x20000013  0x6C
64    # "o"
65    Memory Should Be Equal To       0x20000014  0x6F
66