1 // 2 // Copyright (c) 2010-2024 Antmicro 3 // 4 // This file is licensed under the MIT License. 5 // Full license text is available in 'licenses/MIT.txt'. 6 // 7 using System.Collections.Generic; 8 using Antmicro.Renode.Peripherals.Bus; 9 using Antmicro.Renode.Core.Structure.Registers; 10 using Antmicro.Renode.Logging; 11 12 namespace Antmicro.Renode.Peripherals.Mocks 13 { 14 public class MockWordPeripheralWithoutTranslations : IWordPeripheral 15 { MockWordPeripheralWithoutTranslations()16 public MockWordPeripheralWithoutTranslations() 17 { 18 registers = new WordRegisterCollection(this, new Dictionary<long, WordRegister>{ 19 { 0x0, new WordRegister(this, 0x0).WithValueField(0, 16) }, 20 { 0x2, new WordRegister(this, 0x0).WithValueField(0, 16) }, 21 { 0x4, new WordRegister(this, 0x0).WithValueField(0, 16) }, 22 { 0x6, new WordRegister(this, 0x0).WithValueField(0, 16) }, 23 }); 24 regionRegisters = new WordRegisterCollection(this, new Dictionary<long, WordRegister>{ 25 { 0x0, new WordRegister(this, 0x0).WithValueField(0, 16) }, 26 { 0x2, new WordRegister(this, 0x0).WithValueField(0, 16) }, 27 { 0x4, new WordRegister(this, 0x0).WithValueField(0, 16) }, 28 { 0x6, new WordRegister(this, 0x0).WithValueField(0, 16) }, 29 }); 30 Reset(); 31 } 32 Reset()33 public void Reset() 34 { 35 registers.Reset(); 36 regionRegisters.Reset(); 37 } 38 ReadWord(long offset)39 public virtual ushort ReadWord(long offset) 40 { 41 return registers.Read(offset); 42 } 43 WriteWord(long offset, ushort value)44 public virtual void WriteWord(long offset, ushort value) 45 { 46 registers.Write(offset, value); 47 } 48 49 [ConnectionRegion("region")] ReadWordFromRegion(long offset)50 public ushort ReadWordFromRegion(long offset) 51 { 52 return regionRegisters.Read(offset); 53 } 54 55 [ConnectionRegion("region")] WriteWordToRegion(long offset, ushort value)56 public void WriteWordToRegion(long offset, ushort value) 57 { 58 regionRegisters.Write(offset, value); 59 } 60 61 private readonly WordRegisterCollection registers; 62 private readonly WordRegisterCollection regionRegisters; 63 } 64 } 65