mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-04 04:27:34 +00:00
emulation: add ticktimer and serial uarts
This updates renode's emulation to match the current system design. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
9ee43a7acc
commit
ffcccab513
4 changed files with 951 additions and 351 deletions
|
|
@ -4,23 +4,29 @@ cpu: CPU.VexRiscv @ sysbus
|
|||
privilegeArchitecture: PrivilegeArchitecture.Priv1_10
|
||||
|
||||
uart: UART.LiteX_UART @ {
|
||||
sysbus 0x60001000;
|
||||
sysbus 0xF0001000 // shadow
|
||||
sysbus 0x60008000;
|
||||
sysbus 0xF0008000 // shadow
|
||||
}
|
||||
-> cpu@1002
|
||||
|
||||
uartkernel: UART.LiteX_UART @ {
|
||||
sysbus 0x60002000;
|
||||
sysbus 0xF0002000 // shadow
|
||||
uartconsole: UART.LiteX_UART @ {
|
||||
sysbus 0x6000A000;
|
||||
sysbus 0xF000A000 // shadow
|
||||
}
|
||||
-> cpu@1003
|
||||
|
||||
uartlog: UART.LiteX_UART @ {
|
||||
sysbus 0x60004000;
|
||||
sysbus 0xF0004000 // shadow
|
||||
uartserver0: UART.LiteX_UART @ {
|
||||
sysbus 0x6000C000;
|
||||
sysbus 0xF000C000 // shadow
|
||||
}
|
||||
-> cpu@1004
|
||||
|
||||
uartserver1: UART.LiteX_UART @ {
|
||||
sysbus 0x6000E000;
|
||||
sysbus 0xF000E000 // shadow
|
||||
}
|
||||
-> cpu@1005
|
||||
|
||||
timer0: Timers.LiteX_Timer_32 @ {
|
||||
sysbus 0x60003000;
|
||||
sysbus 0xF0003000 // shadow
|
||||
|
|
@ -48,15 +54,18 @@ sram: Memory.MappedMemory @ {
|
|||
fbmem: Memory.MappedMemory @ sysbus 0xB0000000
|
||||
size: 0x6000
|
||||
|
||||
memlcd: Video.BetrustedLCD @ sysbus 0xF0005000
|
||||
memlcd: Video.BetrustedLCD @ sysbus 0xF0011000
|
||||
|
||||
kbd: Input.BetrustedKbd @ sysbus 0xF0006000
|
||||
|
||||
cpu_timer: Timers.LiteX_CPUTimer @ sysbus 0xf0000800
|
||||
frequency: 66000000
|
||||
frequency: 100000000
|
||||
// IRQ #100 is Machine Timer Interrupt
|
||||
-> cpu@100
|
||||
|
||||
ticktimer: Timers.TickTimer @ sysbus 0xf0016000
|
||||
periodInMs: 1
|
||||
|
||||
//flash: SPI.Micron_MT25Q @ spi
|
||||
// underlyingMemory: flash_mem
|
||||
|
||||
|
|
|
|||
|
|
@ -12,14 +12,16 @@ mach create
|
|||
i @peripherals/LiteX_Timer_32.cs
|
||||
i @peripherals/memlcd.cs
|
||||
i @peripherals/keyboard.cs
|
||||
i @peripherals/ticktimer.cs
|
||||
|
||||
# Load the Betrusted Renode Platform file
|
||||
machine LoadPlatformDescription @betrusted.repl
|
||||
|
||||
machine StartGdbServer 3333 true
|
||||
showAnalyzer uart
|
||||
showAnalyzer uartlog
|
||||
showAnalyzer uartkernel
|
||||
showAnalyzer uartconsole
|
||||
showAnalyzer uartserver0
|
||||
showAnalyzer uartserver1
|
||||
showAnalyzer memlcd
|
||||
|
||||
logLevel -1 kbd
|
||||
|
|
|
|||
83
emulation/peripherals/ticktimer.cs
Normal file
83
emulation/peripherals/ticktimer.cs
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
//
|
||||
// Copyright (c) 2010-2019 Antmicro
|
||||
//
|
||||
// This file is licensed under the MIT License.
|
||||
// Full license text is available in 'licenses/MIT.txt'.
|
||||
//
|
||||
using System;
|
||||
using Antmicro.Renode.Core;
|
||||
using Antmicro.Renode.Core.Structure.Registers;
|
||||
using Antmicro.Renode.Utilities;
|
||||
using Antmicro.Renode.Logging;
|
||||
using Antmicro.Renode.Time;
|
||||
using Antmicro.Renode.Peripherals.Bus;
|
||||
using System.Threading;
|
||||
|
||||
namespace Antmicro.Renode.Peripherals.Timers
|
||||
{
|
||||
// this is a model of LiteX timer in the Betrusted configuration:
|
||||
// * width: 32 bits
|
||||
// * csr data width: 32 bit
|
||||
[AllowedTranslations(AllowedTranslation.ByteToDoubleWord)]
|
||||
public class TickTimer : BasicDoubleWordPeripheral, IKnownSize
|
||||
{
|
||||
public TickTimer(Machine machine, ulong periodInMs) : base(machine)
|
||||
{
|
||||
machine.ClockSource.AddClockEntry(new ClockEntry(periodInMs, ClockEntry.FrequencyToRatio(this, 1000), OnTick, this, "TickTimer"));
|
||||
DefineRegisters();
|
||||
}
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
base.Reset();
|
||||
tickValue = 0;
|
||||
paused = true;
|
||||
}
|
||||
|
||||
private void OnTick()
|
||||
{
|
||||
if (!paused) {
|
||||
Interlocked.Increment(ref tickValue);
|
||||
}
|
||||
}
|
||||
|
||||
public long Size { get { return 0x20; }}
|
||||
|
||||
private void DefineRegisters()
|
||||
{
|
||||
Registers.Control.Define32(this)
|
||||
.WithValueField(0, 32, name: "CONTROL", writeCallback: (_, val) =>
|
||||
{
|
||||
if ((val & 1) != 0) {
|
||||
tickValue = 0;
|
||||
}
|
||||
paused = (val & 2) != 0;
|
||||
});
|
||||
;
|
||||
|
||||
Registers.Time1.Define32(this)
|
||||
.WithValueField(0, 32, FieldMode.Read, name: "Time1", valueProviderCallback: _ =>
|
||||
{
|
||||
return (uint) (tickValue >> 32);
|
||||
})
|
||||
;
|
||||
|
||||
Registers.Time0.Define32(this)
|
||||
.WithValueField(0, 32, FieldMode.Read, name: "Time0", valueProviderCallback: _ =>
|
||||
{
|
||||
return (uint) (tickValue >> 0);
|
||||
})
|
||||
;
|
||||
}
|
||||
|
||||
bool paused;
|
||||
long tickValue;
|
||||
|
||||
private enum Registers
|
||||
{
|
||||
Control = 0x00,
|
||||
Time1 = 0x04,
|
||||
Time0 = 0x08,
|
||||
}
|
||||
}
|
||||
}
|
||||
1184
emulation/renode.svd
1184
emulation/renode.svd
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue