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 11 namespace Antmicro.Renode.Peripherals.Mocks 12 { 13 public class MockDoubleWordPeripheralWithoutTranslations : IDoubleWordPeripheral 14 { MockDoubleWordPeripheralWithoutTranslations()15 public MockDoubleWordPeripheralWithoutTranslations() 16 { 17 registers = new DoubleWordRegisterCollection(this, new Dictionary<long, DoubleWordRegister>{ 18 { 0x0, new DoubleWordRegister(this, 0x0).WithValueField(0, 32) }, 19 { 0x4, new DoubleWordRegister(this, 0x0).WithValueField(0, 32) }, 20 }); 21 regionRegisters = new DoubleWordRegisterCollection(this, new Dictionary<long, DoubleWordRegister>{ 22 { 0x0, new DoubleWordRegister(this, 0x0).WithValueField(0, 32) }, 23 { 0x4, new DoubleWordRegister(this, 0x0).WithValueField(0, 32) }, 24 }); 25 Reset(); 26 } 27 Reset()28 public void Reset() 29 { 30 registers.Reset(); 31 regionRegisters.Reset(); 32 } 33 ReadDoubleWord(long offset)34 public virtual uint ReadDoubleWord(long offset) 35 { 36 return registers.Read(offset); 37 } 38 WriteDoubleWord(long offset, uint value)39 public virtual void WriteDoubleWord(long offset, uint value) 40 { 41 registers.Write(offset, value); 42 } 43 44 [ConnectionRegion("region")] ReadDoubleWordFromRegion(long offset)45 public uint ReadDoubleWordFromRegion(long offset) 46 { 47 return regionRegisters.Read(offset); 48 } 49 50 [ConnectionRegion("region")] WriteDoubleWordToRegion(long offset, uint value)51 public void WriteDoubleWordToRegion(long offset, uint value) 52 { 53 regionRegisters.Write(offset, value); 54 } 55 56 private readonly DoubleWordRegisterCollection registers; 57 private readonly DoubleWordRegisterCollection regionRegisters; 58 } 59 } 60