mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
renode: remove custom LiteX_Timer_32
When we started this project, all Renode Litex modules were 8-bits, and we had to custom-make a 32-bit timer module. However, in the interim, upstream has grown a 32-bit variant of this timer. As of this writing, this change was made two years ago. Remove our custom variant and use the upstream version instead. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
5ce00cbe25
commit
46fab8cbc8
5 changed files with 3 additions and 160 deletions
|
|
@ -28,7 +28,6 @@ i @peripherals/engine.cs
|
|||
i @peripherals/Jtag.cs
|
||||
i @peripherals/keyboard.cs
|
||||
i @peripherals/keyrom.cs
|
||||
i @peripherals/LiteX_Timer_32.cs
|
||||
i @peripherals/LM3509.cs
|
||||
i @peripherals/LSM6DS3.cs
|
||||
i @peripherals/memlcd.cs
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ uart: UART.LiteX_UART @ {
|
|||
}
|
||||
-> cpu@1001
|
||||
|
||||
timer0: Timers.Betrusted.LiteX_Timer_32 @ {
|
||||
timer0: Timers.LiteX_Timer_CSR32 @ {
|
||||
sysbus 0xe0001000
|
||||
}
|
||||
frequency: 100000000
|
||||
|
|
|
|||
|
|
@ -1,156 +0,0 @@
|
|||
//
|
||||
// Copyright (c) 2010-2019 Antmicro
|
||||
//
|
||||
// This file is licensed under the MIT License.
|
||||
// Full license text is available in 'licenses/MIT.txt'.
|
||||
//
|
||||
using Antmicro.Renode.Core;
|
||||
using Antmicro.Renode.Core.Structure.Registers;
|
||||
using Antmicro.Renode.Logging;
|
||||
using Antmicro.Renode.Peripherals.Bus;
|
||||
|
||||
namespace Antmicro.Renode.Peripherals.Timers.Betrusted
|
||||
{
|
||||
// this is a model of LiteX timer in the Betrusted configuration:
|
||||
// * width: 32 bits
|
||||
// * csr data width: 32 bit
|
||||
[AllowedTranslations(AllowedTranslation.ByteToDoubleWord)]
|
||||
public class LiteX_Timer_32 : BasicDoubleWordPeripheral, IKnownSize
|
||||
{
|
||||
public LiteX_Timer_32(Machine machine, long frequency) : base(machine)
|
||||
{
|
||||
IRQ = new GPIO();
|
||||
innerTimer = new LimitTimer(machine.ClockSource, frequency, this, "LiteXTimer32", eventEnabled: true, autoUpdate: true);
|
||||
innerTimer.LimitReached += delegate
|
||||
{
|
||||
this.Log(LogLevel.Noisy, "Limit reached");
|
||||
irqPending.Value = true;
|
||||
UpdateInterrupts();
|
||||
|
||||
if(reloadValue == 0)
|
||||
{
|
||||
this.Log(LogLevel.Noisy, "No realod value - disabling the timer");
|
||||
innerTimer.Enabled = false;
|
||||
}
|
||||
innerTimer.Limit = reloadValue;
|
||||
};
|
||||
DefineRegisters();
|
||||
}
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
base.Reset();
|
||||
innerTimer.Reset();
|
||||
latchedValue = 0;
|
||||
loadValue = 0;
|
||||
reloadValue = 0;
|
||||
RegistersCollection.Reset();
|
||||
|
||||
UpdateInterrupts();
|
||||
}
|
||||
|
||||
public GPIO IRQ {
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public long Size { get { return 0x20; }}
|
||||
|
||||
private void DefineRegisters()
|
||||
{
|
||||
Registers.Load.Define32(this)
|
||||
.WithValueField(0, 32, name: "LOAD", writeCallback: (_, val) =>
|
||||
{
|
||||
loadValue = val;
|
||||
});
|
||||
;
|
||||
|
||||
Registers.Reload.Define32(this)
|
||||
.WithValueField(0, 32, name: "RELOAD", writeCallback: (_, val) =>
|
||||
{
|
||||
reloadValue = val;
|
||||
});
|
||||
;
|
||||
|
||||
Registers.TimerEnable.Define32(this)
|
||||
.WithFlag(0, name: "ENABLE", writeCallback: (_, val) =>
|
||||
{
|
||||
if(innerTimer.Enabled == val)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(val)
|
||||
{
|
||||
innerTimer.Limit = loadValue;
|
||||
this.Log(LogLevel.Noisy, "Enabling timer. Load value: 0x{0:X}, reload value: 0x{1:X}", loadValue, reloadValue);
|
||||
}
|
||||
|
||||
innerTimer.Enabled = val;
|
||||
})
|
||||
;
|
||||
|
||||
Registers.TimerUpdateValue.Define32(this)
|
||||
.WithFlag(0, FieldMode.WriteOneToClear, name: "UPDATE_VALUE", writeCallback: (_, val) =>
|
||||
{
|
||||
if(val)
|
||||
{
|
||||
latchedValue = (uint)innerTimer.Value;
|
||||
}
|
||||
});
|
||||
;
|
||||
|
||||
// VALUE0 contains most significant 8 bits
|
||||
// VALUE3 contains least significant 8 bits
|
||||
Registers.Value.Define32(this)
|
||||
.WithValueField(0, 32, FieldMode.Read, name: "VALUE", valueProviderCallback: _ =>
|
||||
{
|
||||
return latchedValue;
|
||||
});
|
||||
;
|
||||
|
||||
Registers.EventStatus.Define32(this)
|
||||
.WithFlag(0, FieldMode.Read, name: "EV_STATUS", valueProviderCallback: _ => innerTimer.Value == 0)
|
||||
;
|
||||
|
||||
Registers.EventPending.Define32(this)
|
||||
.WithFlag(0, out irqPending, FieldMode.Read | FieldMode.WriteOneToClear, name: "EV_PENDING", changeCallback: (_, __) => UpdateInterrupts())
|
||||
;
|
||||
|
||||
Registers.EventEnable.Define32(this)
|
||||
.WithFlag(0, out irqEnabled, name: "EV_ENABLE", changeCallback: (_, __) => UpdateInterrupts())
|
||||
;
|
||||
}
|
||||
|
||||
private void UpdateInterrupts()
|
||||
{
|
||||
this.Log(LogLevel.Noisy, "Setting IRQ: {0}", irqPending.Value && irqEnabled.Value);
|
||||
IRQ.Set(irqPending.Value && irqEnabled.Value);
|
||||
}
|
||||
|
||||
private IFlagRegisterField irqEnabled;
|
||||
private IFlagRegisterField irqPending;
|
||||
|
||||
private uint latchedValue;
|
||||
private uint loadValue;
|
||||
private uint reloadValue;
|
||||
|
||||
private readonly LimitTimer innerTimer;
|
||||
|
||||
private enum Registers
|
||||
{
|
||||
Load = 0x00,
|
||||
|
||||
Reload = 0x04,
|
||||
|
||||
TimerEnable = 0x08,
|
||||
TimerUpdateValue = 0x0C,
|
||||
|
||||
Value = 0x10,
|
||||
|
||||
EventStatus = 0x14,
|
||||
EventPending = 0x18,
|
||||
EventEnable = 0x1C
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@ cpu: CPU.Betrusted.AesVexRiscv @ sysbus
|
|||
// Platform Peripherals
|
||||
// Unrecognized peripheral: reboot @ 0xf0000000
|
||||
|
||||
timer0: Timers.Betrusted.LiteX_Timer_32 @ sysbus 0xf0001000
|
||||
timer0: Timers.LiteX_Timer_CSR32 @ sysbus 0xf0001000
|
||||
frequency: 100000000
|
||||
IRQ -> cpu @ 1000
|
||||
|
||||
|
|
|
|||
|
|
@ -665,7 +665,7 @@ pub fn generate<T: Read, U: Write>(src: T, dest: &mut U) -> Result<(), ParseErro
|
|||
cs_peripherals.insert("spinor_soft_int", "Miscellaneous.Betrusted.SpinorSoftInt");
|
||||
cs_peripherals.insert("spinor", "SPI.Betrusted.BetrustedSpinor");
|
||||
cs_peripherals.insert("susres", "Timers.Betrusted.SusRes");
|
||||
cs_peripherals.insert("timer0", "Timers.Betrusted.LiteX_Timer_32");
|
||||
cs_peripherals.insert("timer0", "Timers.LiteX_Timer_CSR32");
|
||||
cs_peripherals.insert("trng_kernel", "Miscellaneous.Betrusted.BetrustedRNGKernel");
|
||||
cs_peripherals.insert("trng_server", "Miscellaneous.Betrusted.BetrustedRNGServer");
|
||||
cs_peripherals.insert("ticktimer", "Timers.Betrusted.TickTimer");
|
||||
|
|
|
|||
Loading…
Reference in a new issue