1 // 2 // Copyright (c) 2010-2021 Antmicro 3 // 4 // This file is licensed under the MIT License. 5 // Full license text is available in 'licenses/MIT.txt'. 6 // 7 using Antmicro.Renode.Core; 8 using Antmicro.Renode.Core.Structure.Registers; 9 using Antmicro.Renode.Logging; 10 11 namespace Antmicro.Renode.Peripherals.Miscellaneous 12 { 13 public class OpenTitan_VerilatorSwTestStatus : BasicDoubleWordPeripheral, IKnownSize 14 { OpenTitan_VerilatorSwTestStatus(IMachine machine)15 public OpenTitan_VerilatorSwTestStatus(IMachine machine) : base(machine) 16 { 17 DefineRegisters(); 18 } 19 20 public long Size => 0x8; 21 DefineRegisters()22 private void DefineRegisters() 23 { 24 Registers.SoftwareTestStatus.Define(this, 0x0) 25 .WithValueField(0, 16, name: "software test status", writeCallback: (_, value) => 26 { 27 this.Log(LogLevel.Info, "Opentitan Software test status set to 0x{0:x}", value); 28 switch((SoftwareTestStatusCode)value) 29 { 30 case SoftwareTestStatusCode.InBootRom: 31 this.Log(LogLevel.Info, "Opentitan in boot ROM"); 32 break; 33 case SoftwareTestStatusCode.InTest: 34 this.Log(LogLevel.Info, "Opentitan in test"); 35 break; 36 case SoftwareTestStatusCode.InWfi: 37 this.Log(LogLevel.Info, "Opentitan in WFI"); 38 break; 39 case SoftwareTestStatusCode.Passed: 40 this.Log(LogLevel.Info, "Opentitan PASSED Test"); 41 break; 42 case SoftwareTestStatusCode.Failed: 43 this.Log(LogLevel.Info, "Opentitan FAILED Test"); 44 break; 45 } 46 }) 47 .WithIgnoredBits(16,16) 48 ; 49 } 50 51 private enum SoftwareTestStatusCode : uint 52 { 53 Default = 0x0000, 54 InBootRom = 0xb090, // 'bogo', BOotrom GO 55 InTest = 0x4354, // 'test' 56 InWfi = 0x1d1e, // 'idle' 57 Passed = 0x900d, // 'good' 58 Failed = 0xbaad // 'baad' 59 } 60 61 private enum Registers 62 { 63 SoftwareTestStatus = 0x0 64 } 65 } 66 } 67