diff --git a/emulation/ec/betrusted-ec.repl b/emulation/ec/betrusted-ec.repl new file mode 100644 index 000000000..e9edc1672 --- /dev/null +++ b/emulation/ec/betrusted-ec.repl @@ -0,0 +1,34 @@ +cpu: CPU.VexRiscv @ sysbus + cpuType: "rv32i" + PerformanceInMips: 6 + +uart: UART.LiteX_UART @ { + sysbus 0xE0001800 + } + -> cpu@1000 + +timer0: Timers.LiteX_Timer_32 @ { + sysbus 0xe0002000 + } + frequency: 100000000 + -> cpu@1001 + +sram: Memory.MappedMemory @ { + sysbus 0x10000000; + sysbus 0x90000000 // shadow + } + size: 0x00020000 + +ticktimer: Timers.TickTimer @ sysbus 0xe0005000 + periodInMs: 1 + -> cpu @ 1003 + +flash_mem: Memory.MappedMemory @ { + sysbus 0x20000000; + sysbus 0xA0000000 // shadow + } + size: 0x8000000 + +sysbus: + init: + ApplySVD @ec/soc.svd diff --git a/emulation/ec/kernel.bin b/emulation/ec/kernel.bin new file mode 100644 index 000000000..6a3586adc Binary files /dev/null and b/emulation/ec/kernel.bin differ diff --git a/emulation/ec/soc.svd b/emulation/ec/soc.svd new file mode 100644 index 000000000..b2bc9e23f --- /dev/null +++ b/emulation/ec/soc.svd @@ -0,0 +1,1447 @@ + + + + litex + SOC + Betrusted EC + 8 + 32 + 32 + read-write + 0x00000000 + 0xFFFFFFFF + + + + CTRL + 0xE0000000 + CTRL + + + RESET + + 0x0000 + 0x00 + 32 + + + reset + 0 + [0:0] + 0 + + + + + SCRATCH + + 0x0004 + 0x12345678 + 32 + + + scratch + 31 + [31:0] + 0 + + + + + BUS_ERRORS + + 0x0008 + 0x00 + 32 + + + bus_errors + 31 + [31:0] + 0 + + + + + + 0 + 0xc + registers + + + + UART + 0xE0001800 + UART + + + RXTX + 0x0000 + 0x00 + 32 + + + rxtx + 7 + [7:0] + 0 + + + + + TXFULL + 0x0004 + 0x00 + 32 + + + txfull + 0 + [0:0] + 0 + + + + + RXEMPTY + 0x0008 + 0x00 + 32 + + + rxempty + 0 + [0:0] + 0 + + + + + EV_STATUS + + 0x000c + 0x00 + 32 + + + tx + 0 + [0:0] + 0 + + + + rx + 1 + [1:1] + 1 + + + + + + EV_PENDING + + 0x0010 + 0x00 + 32 + + + tx + 0 + [0:0] + 0 + + + + rx + 1 + [1:1] + 1 + + + + + + EV_ENABLE + + 0x0014 + 0x00 + 32 + + + tx + 0 + [0:0] + 0 + + + + rx + 1 + [1:1] + 1 + + + + + + TXEMPTY + 0x0018 + 0x00 + 32 + + + txempty + 0 + [0:0] + 0 + + + + + RXFULL + 0x001c + 0x00 + 32 + + + rxfull + 0 + [0:0] + 0 + + + + + XOVER_RXTX + 0x0020 + 0x00 + 32 + + + xover_rxtx + 7 + [7:0] + 0 + + + + + XOVER_TXFULL + 0x0024 + 0x00 + 32 + + + xover_txfull + 0 + [0:0] + 0 + + + + + XOVER_RXEMPTY + 0x0028 + 0x00 + 32 + + + xover_rxempty + 0 + [0:0] + 0 + + + + + XOVER_EV_STATUS + + 0x002c + 0x00 + 32 + + + tx + 0 + [0:0] + 0 + + + + rx + 1 + [1:1] + 1 + + + + + + XOVER_EV_PENDING + + 0x0030 + 0x00 + 32 + + + tx + 0 + [0:0] + 0 + + + + rx + 1 + [1:1] + 1 + + + + + + XOVER_EV_ENABLE + + 0x0034 + 0x00 + 32 + + + tx + 0 + [0:0] + 0 + + + + rx + 1 + [1:1] + 1 + + + + + + XOVER_TXEMPTY + 0x0038 + 0x00 + 32 + + + xover_txempty + 0 + [0:0] + 0 + + + + + XOVER_RXFULL + 0x003c + 0x00 + 32 + + + xover_rxfull + 0 + [0:0] + 0 + + + + + + 0 + 0x40 + registers + + + uart + 0 + + + + TIMER0 + 0xE0002000 + TIMER0 + + + LOAD + + 0x0000 + 0x00 + 32 + + + load + 31 + [31:0] + 0 + + + + + RELOAD + + 0x0004 + 0x00 + 32 + + + reload + 31 + [31:0] + 0 + + + + + EN + + 0x0008 + 0x00 + 32 + + + en + 0 + [0:0] + 0 + + + + + UPDATE_VALUE + + 0x000c + 0x00 + 32 + + + update_value + 0 + [0:0] + 0 + + + + + VALUE + + 0x0010 + 0x00 + 32 + + + value + 31 + [31:0] + 0 + + + + + EV_STATUS + + 0x0014 + 0x00 + 32 + + + zero + 0 + [0:0] + 0 + + + + + + EV_PENDING + + 0x0018 + 0x00 + 32 + + + zero + 0 + [0:0] + 0 + + + + + + EV_ENABLE + + 0x001c + 0x00 + 32 + + + zero + 0 + [0:0] + 0 + + + + + + + 0 + 0x20 + registers + + + timer0 + 1 + + + + CRG + 0xE0002800 + CRG + + + WATCHDOG + 0x0000 + 0x00 + 32 + + + reset_code + 15 + [15:0] + 0 + + + + enable + 16 + [16:16] + 16 + + + + + + + 0 + 0x4 + registers + + + + GIT + 0xE0003000 + GIT + + + GITREV + + 0x0000 + 0xd167b75b + 32 + + + gitrev + 31 + [31:0] + 0 + + + + + DIRTY + 0x0004 + 0x01 + 32 + + + dirty + 0 + [0:0] + 0 + + + + + + + 0 + 0x8 + registers + + + + POWER + 0xE0003800 + POWER + + + POWER + 0x0000 + 0x03 + 32 + + + self + 0 + [0:0] + 0 + + + + soc_on + 1 + [1:1] + 1 + + + + discharge + 2 + [2:2] + 2 + + + + kbddrive + 3 + [3:3] + 3 + + + + + + STATS + 0x0004 + 0x00 + 32 + + + state + 0 + [0:0] + 0 + + + + monkey + 2 + [2:1] + 1 + + + + + + + 0 + 0x8 + registers + + + + PICORVSPI + 0xE0004000 + PICORVSPI + + + RDATA + 0x0000 + 0x00 + 32 + + + data + 3 + [3:0] + 0 + + + + + + MODE + 0x0004 + 0x00 + 32 + + + bitbang + 0 + [0:0] + 0 + + + + csn + 1 + [1:1] + 1 + + + + + + WDATA + + 0x0008 + 0x00 + 32 + + + data + 3 + [3:0] + 0 + + + + oe + 7 + [7:4] + 4 + + + + + + + 0 + 0xc + registers + + + + I2C + 0xE0004800 + I2C + + + EV_STATUS + + 0x0000 + 0x00 + 32 + + + i2c_int + 0 + [0:0] + 0 + + + + gg_int + 1 + [1:1] + 1 + + + + gyro_int + 2 + [2:2] + 2 + + + + usbcc_int + 3 + [3:3] + 3 + + + + + + EV_PENDING + + 0x0004 + 0x00 + 32 + + + i2c_int + 0 + [0:0] + 0 + + + + gg_int + 1 + [1:1] + 1 + + + + gyro_int + 2 + [2:2] + 2 + + + + usbcc_int + 3 + [3:3] + 3 + + + + + + EV_ENABLE + + 0x0008 + 0x00 + 32 + + + i2c_int + 0 + [0:0] + 0 + + + + gg_int + 1 + [1:1] + 1 + + + + gyro_int + 2 + [2:2] + 2 + + + + usbcc_int + 3 + [3:3] + 3 + + + + + + + 0 + 0xc + registers + + + i2c + 2 + + + + TICKTIMER + 0xE0005000 + TICKTIMER + + + CONTROL + 0x0000 + 0x00 + 32 + + + reset + 0 + [0:0] + 0 + + + + pause + 1 + [1:1] + 1 + + + + + + TIME1 + + 0x0004 + 0x00 + 32 + + + time + 31 + [31:0] + 0 + + + + + TIME0 + + 0x0008 + 0x00 + 32 + + + time + 31 + [31:0] + 0 + + + + + MSLEEP_TARGET1 + + 0x000c + 0x00 + 32 + + + msleep_target + 31 + [31:0] + 0 + + + + + MSLEEP_TARGET0 + + 0x0010 + 0x00 + 32 + + + msleep_target + 31 + [31:0] + 0 + + + + + EV_STATUS + + 0x0014 + 0x00 + 32 + + + alarm + 0 + [0:0] + 0 + + + + + + EV_PENDING + + 0x0018 + 0x00 + 32 + + + alarm + 0 + [0:0] + 0 + + + + + + EV_ENABLE + + 0x001c + 0x00 + 32 + + + alarm + 0 + [0:0] + 0 + + + + + + + 0 + 0x20 + registers + + + ticktimer + 3 + + + + COM + 0xE0005800 + COM + + + CONTROL + 0x0000 + 0x00 + 32 + + + clrerr + 0 + [0:0] + 0 + + + + host_int + 1 + [1:1] + 1 + 1 raises an interrupt to the COM host]]> + + + reset + 2 + [2:2] + 2 + + + + + + STATUS + 0x0004 + 0x00 + 32 + + + tip + 0 + [0:0] + 0 + + + + rx_avail + 1 + [1:1] + 1 + + + + rx_over + 2 + [2:2] + 2 + + + + rx_under + 3 + [3:3] + 3 + + + + rx_level + 15 + [15:4] + 4 + + + + tx_avail + 16 + [16:16] + 16 + + + + tx_empty + 17 + [17:17] + 17 + + + + tx_level + 29 + [29:18] + 18 + + + + tx_over + 30 + [30:30] + 30 + + + + tx_under + 31 + [31:31] + 31 + + + + + + EV_STATUS + + 0x0008 + 0x00 + 32 + + + spi_avail + 0 + [0:0] + 0 + + + + spi_event + 1 + [1:1] + 1 + + + + spi_err + 2 + [2:2] + 2 + + + + + + EV_PENDING + + 0x000c + 0x00 + 32 + + + spi_avail + 0 + [0:0] + 0 + + + + spi_event + 1 + [1:1] + 1 + + + + spi_err + 2 + [2:2] + 2 + + + + + + EV_ENABLE + + 0x0010 + 0x00 + 32 + + + spi_avail + 0 + [0:0] + 0 + + + + spi_event + 1 + [1:1] + 1 + + + + spi_err + 2 + [2:2] + 2 + + + + + + + 0 + 0x14 + registers + + + com + 4 + + + + WIFI + 0xE0006000 + WIFI + + + TX + + 0x0000 + 0x00 + 32 + + + tx + 15 + [15:0] + 0 + + + + + RX + + 0x0004 + 0x00 + 32 + + + rx + 15 + [15:0] + 0 + + + + + CS + 0x0008 + 0x00 + 32 + + + cs + 0 + [0:0] + 0 + + + + + + CONTROL + 0x000c + 0x00 + 32 + + + go + 0 + [0:0] + 0 + + + + + + STATUS + 0x0010 + 0x00 + 32 + + + tip + 0 + [0:0] + 0 + + + + txfull + 1 + [1:1] + 1 + + + + + + WIFI + 0x0014 + 0x01 + 32 + + + reset + 0 + [0:0] + 0 + + + + pa_ena + 1 + [1:1] + 1 + + + + wakeup + 2 + [2:2] + 2 + + + + + + EV_STATUS + + 0x0018 + 0x00 + 32 + + + wirq + 0 + [0:0] + 0 + + + + + + EV_PENDING + + 0x001c + 0x00 + 32 + + + wirq + 0 + [0:0] + 0 + + + + + + EV_ENABLE + + 0x0020 + 0x00 + 32 + + + wirq + 0 + [0:0] + 0 + + + + + + + 0 + 0x24 + registers + + + wifi + 5 + + + + + + + VEXRISCV_DEBUG + 0xF00F0000 + 0x00000100 + + + SRAM + 0x10000000 + 0x00020000 + + + SPIFLASH + 0x20000000 + 0x00100000 + + + I2C + 0xB0000000 + 0x00000040 + + + COM + 0xD0000000 + 0x00000004 + + + CSR + 0xE0000000 + 0x00010000 + + + + diff --git a/emulation/betrusted.repl b/emulation/soc/betrusted-soc.repl similarity index 81% rename from emulation/betrusted.repl rename to emulation/soc/betrusted-soc.repl index db09043ff..7e9e51534 100644 --- a/emulation/betrusted.repl +++ b/emulation/soc/betrusted-soc.repl @@ -1,7 +1,7 @@ cpu: CPU.VexRiscv @ sysbus - timeProvider: cpu_timer cpuType: "rv32imac" privilegeArchitecture: PrivilegeArchitecture.Priv1_10 + PerformanceInMips: 120 uart: UART.LiteX_UART @ { sysbus 0xF0004000 // shadow @@ -48,13 +48,6 @@ trng_kernel: Miscellaneous.BetrustedRNGKernel @ sysbus 0xF0019000 trng_server: Miscellaneous.BetrustedRNGServer @ sysbus 0xF001A000 -// This peripheral doesn't actually exist, but is required -// in order to keep the CPU running. -cpu_timer: Timers.LiteX_CPUTimer @ sysbus 0xf0000800 - frequency: 100000000 - // IRQ #100 is Machine Timer Interrupt - -> cpu@100 - ticktimer: Timers.TickTimer @ sysbus 0xF0011000 periodInMs: 1 -> cpu @ 1008 @@ -67,4 +60,4 @@ flash_mem: Memory.MappedMemory @ { sysbus: init: - ApplySVD @renode.svd + ApplySVD @soc/renode.svd diff --git a/emulation/csr.csv b/emulation/soc/csr.csv similarity index 100% rename from emulation/csr.csv rename to emulation/soc/csr.csv diff --git a/emulation/renode.svd b/emulation/soc/renode.svd similarity index 100% rename from emulation/renode.svd rename to emulation/soc/renode.svd diff --git a/emulation/xous-release.resc b/emulation/xous-release.resc index 5bd5ec4c9..2e646d9fa 100644 --- a/emulation/xous-release.resc +++ b/emulation/xous-release.resc @@ -5,19 +5,20 @@ path add $ORIGIN using sysbus -mach create # Add peripherals that are defined in C#. You must restart Renode # if you modify these files. +i @peripherals/i2c_lattice_hip.cs +i @peripherals/keyboard.cs i @peripherals/LiteX_Timer_32.cs i @peripherals/memlcd.cs -i @peripherals/keyboard.cs i @peripherals/ticktimer.cs i @peripherals/trng_kernel.cs i @peripherals/trng_server.cs -# Load the Betrusted Renode Platform file -machine LoadPlatformDescription @betrusted.repl +############### Define the Betrusted SoC ############### +mach create "SoC" +machine LoadPlatformDescription @soc/betrusted-soc.repl machine StartGdbServer 3333 true showAnalyzer uart @@ -50,4 +51,22 @@ macro reset """ runMacro $reset +mach clear + +############### Define the Betrusted EC ############### +mach create "EC" +machine LoadPlatformDescription @ec/betrusted-ec.repl +showAnalyzer uart +macro reset +""" + sysbus LoadBinary @ec/kernel.bin 0x10000000 + cpu PC 0x10000000 +""" +runMacro $reset + +# Silence I2C for now while we work on the driver +sysbus SilenceRange <0xB0000000, 0xB000FFFF> + +mach clear + start