示例#1
0
        public RiscV(string cpuType, long frequency, Machine machine, PrivilegeMode privilegeMode = PrivilegeMode.Priv1_10, Endianess endianness = Endianess.LittleEndian) : base(cpuType, machine, endianness)
        {
            InnerTimer = new ComparingTimer(machine.ClockSource, frequency, enabled: true, eventEnabled: true);

            intTypeToVal = new TwoWayDictionary <int, IrqType>();
            intTypeToVal.Add(0, IrqType.MachineTimerIrq);
            intTypeToVal.Add(1, IrqType.MachineExternalIrq);
            intTypeToVal.Add(2, IrqType.MachineSoftwareInterrupt);

            var architectureSets = DecodeArchitecture(cpuType);

            foreach (var @set in architectureSets)
            {
                if (Enum.IsDefined(typeof(InstructionSet), set))
                {
                    TlibAllowFeature((uint)set);
                }
                else if ((int)set == 'G' - 'A')
                {
                    //G is a wildcard denoting multiple instruction sets
                    foreach (var gSet in new [] { InstructionSet.I, InstructionSet.M, InstructionSet.F, InstructionSet.D, InstructionSet.A })
                    {
                        TlibAllowFeature((uint)gSet);
                    }
                }
                else
                {
                    this.Log(LogLevel.Warning, $"Undefined instruction set: {char.ToUpper((char)(set + 'A'))}.");
                }
            }
            TlibSetPrivilegeMode109(privilegeMode == PrivilegeMode.Priv1_09 ? 1 : 0u);
        }
 static PropertySerializationTypeConverter()
 {
     _serializationTypesStringMap = new TwoWayDictionary <PropertySerializationType, string> ();
     _serializationTypesStringMap.Add(PropertySerializationType.CamelCase, "camelCase");
     _serializationTypesStringMap.Add(PropertySerializationType.LowerSnakeCase, "lower_snake_case");
     _serializationTypesStringMap.Add(PropertySerializationType.PascalCase, "PascalCase");
     _serializationTypesStringMap.Add(PropertySerializationType.UnderscoreCamelCase, "_underscoreCamelCase");
 }
        public void TwoWayDictionary_Add_ShouldAddItemToBothDictionaries()
        {
            int    i = 1;
            string s = "one";

            _sut.Add(i, s);

            _sut._forwardDict[i].Should().Be(s);
            _sut._reverseDict[s].Should().Be(i);
            _sut[i].Should().Be(s);
            _sut.GetByKey(i).Should().Be(s);
            _sut.GetByValue(s).Should().Be(i);
        }
示例#4
0
        public void AddShapeLink(Link link)
        {
            if (!linksAndArrows.Contains(link))
            {
                var arrow  = templates.GetLinkTemplate();
                var shape1 = nodesAndShapes[link.Node1];
                var shape2 = nodesAndShapes[link.Node2];
                arrow.Connect(ControlPointId.FirstVertex, shape1, ControlPointId.Reference);
                arrow.Connect(ControlPointId.LastVertex, shape2, ControlPointId.Reference);

                linksAndArrows.Add(link, arrow);
                presentersManager.GetPresenterFor(link).Apply(arrow);
                AddShape(arrow);
            }
        }
示例#5
0
        private void AddMarker(Marker marker)
        {
            if (marker is Polyline)
            {
                AddPolyline(marker as Polyline);
                return;
            }

            MarkerOptions options = new MarkerOptions();

            if (marker.ZIndex.HasValue)
            {
                options.InvokeZIndex(marker.ZIndex.Value);
            }
            options.SetPosition(new LatLng(marker.Center.Latitude, marker.Center.Longitude));

            if (!string.IsNullOrEmpty(marker.Icon))
            {
                if (imageResolver != null)
                {
                    System.IO.Stream stream = imageResolver.Resolve(marker.Layer, marker.Icon);
                    if (stream == null)
                    {
                        stream = imageResolver.Resolve(marker);
                    }
                    if (stream != null)
                    {
                        options.SetIcon(BitmapDescriptorFactory.FromBitmap(BitmapFactory.DecodeStream(stream)));
                    }
                }
                else
                {
                    options.SetIcon(BitmapDescriptorFactory.FromResource(ResourceManager.GetDrawableByName(marker.Icon)));
                }
                if (marker.Label != null)
                {
                    CreateLabel(marker);
                }
            }

            options.SetTitle(marker.Title);
            options.SetSnippet(marker.Content);
            options.Draggable(marker.Draggable);

            markers.Add(marker, googleMap.AddMarker(options));

            marker.PropertyChanged += Marker_PropertyChanged;
        }
        public int Add(T value)
        {
            var refid = map.Count;

            map.Add(value, refid);
            return(refid);
        }
        private void DoMapping()
        {
            var graph         = mapDescription.GetGraph();
            var stageOneGraph = mapDescription.GetStageOneGraph();

            foreach (var vertex in graph.Vertices)
            {
                // Create vertices mapping
                nodeToIntMapping.Add(vertex, nodeToIntMapping.Count);
                mappedGraph.AddVertex(nodeToIntMapping[vertex]);

                // Store room description
                roomDescriptions[nodeToIntMapping[vertex]] = mapDescription.GetRoomDescription(vertex);
            }

            // Handle main graph edges
            foreach (var edge in graph.Edges)
            {
                mappedGraph.AddEdge(nodeToIntMapping[edge.From], nodeToIntMapping[edge.To]);
            }

            // Handle stage one graph vertices
            foreach (var vertex in stageOneGraph.Vertices)
            {
                mappedStageOneGraph.AddVertex(nodeToIntMapping[vertex]);
            }

            // Handle stage one graph edges
            foreach (var edge in stageOneGraph.Edges)
            {
                mappedStageOneGraph.AddEdge(nodeToIntMapping[edge.From], nodeToIntMapping[edge.To]);
            }
        }
        private RoomNode <TNode> CreateRoomNode(TNode node)
        {
            var roomNode = new RoomNode <TNode>(nodeToIntMapping.Count, node);

            nodeToIntMapping.Add(node, roomNode);

            return(roomNode);
        }
        public static TwoWayDictionary <TElement, int> CreateIntMapping <TElement>(this IEnumerable <TElement> elements)
        {
            var mapping = new TwoWayDictionary <TElement, int>();

            foreach (var element in elements)
            {
                mapping.Add(element, mapping.Count);
            }

            return(mapping);
        }
示例#10
0
        private void AddTileOverlay(TileOverlay tileOverlay)
        {
            TileOverlayOptions options = new TileOverlayOptions();

            if (tileOverlay is UrlTileOverlay)
            {
                options.InvokeTileProvider(new UrlTileOverlayProvider(tileOverlay as UrlTileOverlay));
            }

            tileOverlays.Add(tileOverlay, googleMap.AddTileOverlay(options));
        }
        public static TwoWayDictionary <TKey, TValue> ToTwoWayDictionary <TKey, TValue>(this IDictionary <TKey, TValue> dictionary)
        {
            var twoWayDictionary = new TwoWayDictionary <TKey, TValue>();

            foreach (var pair in dictionary)
            {
                twoWayDictionary.Add(pair.Key, pair.Value);
            }

            return(twoWayDictionary);
        }
        public int Count_ReturnsExpectedValue(int entriesToAdd)
        {
            var dictionary = new TwoWayDictionary <string, int>();

            for (var i = 0; i < entriesToAdd; i++)
            {
                dictionary.Add(i.ToString(), i);
            }

            return(dictionary.Count);
        }
示例#13
0
        private void PrepareMapping(ICorridorMapDescription <int> mapDescription)
        {
            var graph     = mapDescription.GetGraph();
            var corridors = graph.Vertices.Where(mapDescription.IsCorridorRoom).ToList();

            foreach (var corridor in corridors)
            {
                var room = ScriptableObject.CreateInstance <Room>();
                precomputedMapping.Add(room, corridor);
            }
        }
示例#14
0
        /// <summary>
        /// Returns the mapping from original vertices to ints.
        /// </summary>
        /// <returns></returns>
        public virtual TwoWayDictionary <TNode, int> GetRoomsMapping()
        {
            IsLocked = true;
            var mapping = new TwoWayDictionary <TNode, int>();

            foreach (var pair in Rooms)
            {
                mapping.Add(pair.Key, pair.Value);
            }

            return(mapping);
        }
        public void EnsureBothDirections()
        {
            var dictionary = new TwoWayDictionary <int, int>();

            dictionary.Add(1, 2);

            Assert.True(dictionary.ContainsKey(1));
            Assert.True(dictionary.ContainsValue(2));
            Assert.False(dictionary.ContainsKey(2));
            Assert.False(dictionary.ContainsValue(1));
            Assert.Equal(2, dictionary[1]);
            Assert.Equal(1, dictionary.Reverse[2]);
        }
        private IntAlias <PolygonGrid2D> GetRoomTemplateInstanceAlias(RoomTemplateInstance roomTemplateInstance)
        {
            if (IntAliasMapping.TryGetValue(roomTemplateInstance, out var alias))
            {
                return(alias);
            }

            var newAlias = new IntAlias <PolygonGrid2D>(IntAliasMapping.Count, roomTemplateInstance.RoomShape);

            IntAliasMapping.Add(roomTemplateInstance, newAlias);

            return(newAlias);
        }
示例#17
0
        /// <summary>
        /// Gets room description from a given room template.
        /// </summary>
        /// <remarks>
        /// Returns cached result if a given room template was already processed.
        /// </remarks>
        /// <param name="roomTemplate"></param>
        /// <returns></returns>
        protected RoomDescription GetRoomDescription(GameObject roomTemplate)
        {
            if (RoomDescriptionsToRoomTemplates.ContainsValue(roomTemplate))
            {
                return((RoomDescription)RoomDescriptionsToRoomTemplates.GetByValue(roomTemplate));
            }

            var roomDescription = RoomShapesLoader.GetRoomDescription(roomTemplate);

            RoomDescriptionsToRoomTemplates.Add(roomDescription, roomTemplate);

            return(roomDescription);
        }
示例#18
0
        private RoomTemplate GetRoomTemplate(GameObject roomTemplatePrefab)
        {
            if (prefabToRoomTemplateMapping.ContainsKey(roomTemplatePrefab))
            {
                return(prefabToRoomTemplateMapping[roomTemplatePrefab]);
            }

            var roomTemplate = RoomTemplatesLoader.GetRoomTemplate(roomTemplatePrefab);

            prefabToRoomTemplateMapping.Add(roomTemplatePrefab, roomTemplate);

            return(roomTemplate);
        }
示例#19
0
        private bool RegisterType(TwoWayDictionary <Type, MessageDescriptor> registeredTypes, Type type)
        {
            lock (_lock)
            {
                if (!registeredTypes.ContainsKey(type) && TryGetDescriptorFromAttribute(type, out var descriptor))
                {
                    registeredTypes.Add(type, descriptor);

                    return(true);
                }

                return(false);
            }
        }
示例#20
0
        public void AddCorridorsToMapping(ICorridorMapDescription <int> mapDescription, TwoWayDictionary <Room, int> mapping)
        {
            if (alreadyUsed)
            {
                throw new InvalidOperationException("Each instance of this class can be used at most once because it is tied to a specific map description.");
            }

            foreach (var pair in precomputedMapping)
            {
                mapping.Add(pair.Key, pair.Value);
            }

            alreadyUsed = true;
        }
    private void AssignUnitToTile(Tile tile, Unit unit)
    {
        UnregisterTile(tile);

        Assert.IsFalse(_unitsToTiles.Contains(tile));
        Assert.IsFalse(_unitsToTiles.Contains(unit));

        _unitsToTiles.Add(tile, unit);

        tile.Enter(unit);

        unit.transform.SetGridPosition(tile.transform.GetGridPosition());

        DebugEx.Log <WorldUnitHandler>("Unit moved to tile " + tile.name);
    }
        /// <inheritdoc />
        /// <summary>
        /// Finds the smallest feasible multiple of a specified number and then make from it a sequence of corridors.
        /// </summary>
        public void AddCorridorsToMapping(ICorridorMapDescription <int> mapDescription, TwoWayDictionary <int, int> mapping)
        {
            var graph                = mapDescription.GetGraph();
            var corridors            = graph.Vertices.Where(mapDescription.IsCorridorRoom).ToList();
            var maxNonCorridorNumber = graph.Vertices.Where(x => !mapDescription.IsCorridorRoom(x)).Max();

            var parts      = maxNonCorridorNumber / roundTo;
            var nextNumber = roundTo * (parts + 1);
            var counter    = nextNumber;

            foreach (var corridor in corridors)
            {
                mapping.Add(counter++, corridor);
            }
        }
示例#23
0
        protected override MapDescription <int> SetupMapDescription()
        {
            if (Config.LevelGraph == null)
            {
                throw new ArgumentException("LevelGraph must not be null.");
            }

            RoomToIntMapping = new TwoWayDictionary <Room, int>();
            var mapDescription = new MapDescription <int>();

            mapDescription.SetDefaultTransformations(new List <Transformation>()
            {
                Transformation.Identity
            });

            // Setup individual rooms
            foreach (var room in Config.LevelGraph.Rooms)
            {
                RoomToIntMapping.Add(room, RoomToIntMapping.Count);
                mapDescription.AddRoom(RoomToIntMapping[room]);
                SetupRoomShapesForRoom(mapDescription, room);
            }

            // Add default room shapes
            SetupDefaultRoomShapes(mapDescription, Config.LevelGraph);

            // Add corridors
            if (Config.UseCorridors)
            {
                SetupCorridorRoomShapes(mapDescription, Config.LevelGraph);
            }

            // Add passages
            foreach (var connection in Config.LevelGraph.Connections)
            {
                var from = RoomToIntMapping[connection.From];
                var to   = RoomToIntMapping[connection.To];

                mapDescription.AddPassage(from, to);
            }

            if (Payload is IRoomToIntMappingPayload <Room> payloadWithMapping)
            {
                payloadWithMapping.RoomToIntMapping = RoomToIntMapping;
            }

            return(mapDescription);
        }
        /// <summary>
        /// Adds rooms and connections from the level graph to the map description.
        /// </summary>
        /// <returns></returns>
        protected TwoWayDictionary <Room, int> SetupMapDescriptionFromLevelGraph()
        {
            foreach (var room in LevelGraph.Vertices)
            {
                RoomToIntMapping.Add(room, RoomToIntMapping.Count);
                MapDescription.AddRoom(RoomToIntMapping[room]);
            }

            foreach (var edge in LevelGraph.Edges)
            {
                var from = RoomToIntMapping[edge.From];
                var to   = RoomToIntMapping[edge.To];

                MapDescription.AddPassage(from, to);
            }

            return(RoomToIntMapping);
        }
示例#25
0
        /// <summary>
        ///     Initialized VstParameterManagerDict by createing a VstParameterManager for each MSS
        ///     parameter.
        /// </summary>
        protected void InitializeVstParams()
        {
            // all parameter definitions are added to a central list.
            VstParameterInfoCollection parameterInfos = this.pluginPrograms.ParameterInfos;

            //itterate over each MssParameterID
            foreach (MssParameterID paramId in MssParameterID.GetValues(typeof(MssParameterID)))
            {
                VstParameterInfo paramInfo = MssToVstParameterInfo(paramId);

                parameterInfos.Add(paramInfo);

                VstParameterManager paramMgr = new VstParameterManager(paramInfo);

                //Adds listener to changes made to a parameter from the host
                paramMgr.PropertyChanged +=
                    new PropertyChangedEventHandler(VstParameterManager_PropertyChanged);
                VstParameterManagerDict.Add(paramId, paramMgr);
            }
        }
示例#26
0
        private RoomTemplateGrid2D GetRoomTemplate(GameObject roomTemplatePrefab)
        {
            if (prefabToRoomTemplateMapping.ContainsKey(roomTemplatePrefab))
            {
                return(prefabToRoomTemplateMapping[roomTemplatePrefab]);
            }

            if (RoomTemplateLoaderGrid2D.TryGetRoomTemplate(roomTemplatePrefab, out var roomTemplate, out var result))
            {
                prefabToRoomTemplateMapping.Add(roomTemplatePrefab, roomTemplate);
                return(roomTemplate);
            }

            Debug.LogError($"There was a problem when loading the room template \"{roomTemplatePrefab.name}\":");
            foreach (var error in result.Errors)
            {
                Debug.LogError($"- {error}");
            }

            throw new ConfigurationException("Please fix all the errors above and try again");
        }
示例#27
0
        /// <inheritdoc />
        /// <remarks>
        /// Adds number to a given prefix until all corridors have a name.
        /// </remarks>
        public void AddCorridorsToMapping(ICorridorMapDescription <int> mapDescription, TwoWayDictionary <string, int> mapping)
        {
            var graph     = mapDescription.GetGraph();
            var corridors = graph.Vertices.Where(mapDescription.IsCorridorRoom).ToList();

            var counter = 0;

            foreach (var corridor in corridors)
            {
                while (true)
                {
                    var name = prefix + counter;

                    if (!mapping.ContainsKey(name))
                    {
                        mapping.Add(name, corridor);
                        break;
                    }

                    counter++;
                }
            }
        }
示例#28
0
        public void AddCorridorConnection(TConnection connection, List <GameObject> corridorRoomTemplates, TRoom corridorRoom)
        {
            if (connection == null)
            {
                throw new ArgumentNullException(nameof(connection));
            }
            if (corridorRoom == null)
            {
                throw new ArgumentNullException(nameof(corridorRoom));
            }
            if (corridorRoomTemplates.Count == 0)
            {
                throw new ArgumentException($"There must be at least one room template for each corridor room. Room: {corridorRoom}", nameof(corridorRoom));
            }

            connections.Add(connection);
            corridorToConnectionMapping.Add(corridorRoom, connection);

            var corridorRoomDescription = GetCorridorRoomDescription(corridorRoomTemplates);

            mapDescription.AddRoom(corridorRoom, corridorRoomDescription);
            mapDescription.AddConnection(connection.From, corridorRoom);
            mapDescription.AddConnection(connection.To, corridorRoom);
        }
示例#29
0
        public PSE_GPIO(Machine machine) : base(machine, 32)
        {
            locker     = new object();
            IRQ        = new GPIO();
            irqManager = new GPIOInterruptManager(IRQ, State);

            var registersMap = new Dictionary <long, DoubleWordRegister>
            {
                { (long)Registers.InterruptRegister, new DoubleWordRegister(this)
                  .WithValueField(0, 32,
                                  writeCallback: (_, val) =>
                    {
                        foreach (var i in BitHelper.GetSetBits(val))
                        {
                            irqManager.ClearInterrupt(i);
                            if ((irqManager.PinDirection[i] & GPIOInterruptManager.Direction.Input) != 0)
                            {
                                Connections[i].Set(false);
                            }
                        }
                    },
                                  valueProviderCallback: _ => BitHelper.GetValueFromBitsArray(irqManager.ActiveInterrupts), name: "INTR") },

                { (long)Registers.InputRegister, new DoubleWordRegister(this)
                  .WithValueField(0, 32, out inputReg, FieldMode.Read,
                                  valueProviderCallback: val =>
                    {
                        var pins   = irqManager.PinDirection.Select(x => (x & GPIOInterruptManager.Direction.Input) != 0);
                        var result = pins.Zip(State, (pin, state) => pin && state);
                        return(BitHelper.GetValueFromBitsArray(result));
                    }, name: "GPIN") },

                { (long)Registers.OutputRegister, new DoubleWordRegister(this)
                  .WithValueField(0, 32,
                                  valueProviderCallback: val =>
                    {
                        var pins   = irqManager.PinDirection.Select(x => (x & GPIOInterruptManager.Direction.Output) != 0);
                        var result = pins.Zip(Connections.Values, (pin, state) => pin && state.IsSet);
                        return(BitHelper.GetValueFromBitsArray(result));
                    },
                                  writeCallback: (_, val) =>
                    {
                        // Potentially we should raise an exception, as GPIO is bidirectional,
                        // but we do not have such infrastructure.
                        var bits = BitHelper.GetBits(val);
                        for (var i = 0; i < bits.Length; i++)
                        {
                            if ((irqManager.PinDirection[i] & GPIOInterruptManager.Direction.Output) != 0)
                            {
                                Connections[i].Set(bits[i]);
                            }
                        }
                    }, name: "GPOUT") },

                { (long)Registers.ClearRegister, new DoubleWordRegister(this)
                  .WithValueField(0, 32, writeCallback: (_, val) => SetRegisterBits(val, false), name: "CLEAR_BITS") },

                { (long)Registers.SetRegister, new DoubleWordRegister(this)
                  .WithValueField(0, 32, writeCallback: (_, val) => SetRegisterBits(val, true), name: "SET_BITS") },
            };

            var intTypeToVal = new TwoWayDictionary <GPIOInterruptManager.InterruptTrigger, uint>();

            intTypeToVal.Add(GPIOInterruptManager.InterruptTrigger.ActiveHigh, 0);
            intTypeToVal.Add(GPIOInterruptManager.InterruptTrigger.ActiveLow, 1);
            intTypeToVal.Add(GPIOInterruptManager.InterruptTrigger.RisingEdge, 2);
            intTypeToVal.Add(GPIOInterruptManager.InterruptTrigger.FallingEdge, 3);
            intTypeToVal.Add(GPIOInterruptManager.InterruptTrigger.BothEdges, 4);

            for (var i = 0; i < RegisterLength; i++)
            {
                var j = i;
                registersMap.Add(i * RegisterOffset, new DoubleWordRegister(this)
                                 .WithFlag(0,
                                           writeCallback: (_, val) =>
                {
                    if (val)
                    {
                        irqManager.PinDirection[j] |= GPIOInterruptManager.Direction.Output;
                    }
                    else
                    {
                        irqManager.PinDirection[j] &= ~GPIOInterruptManager.Direction.Output;
                    }
                },
                                           valueProviderCallback: _ => (irqManager.PinDirection[j] & GPIOInterruptManager.Direction.Output) != 0, name: "OutputRegEnable")
                                 .WithFlag(1,
                                           writeCallback: (_, value) =>
                {
                    if (value)
                    {
                        irqManager.PinDirection[j] |= GPIOInterruptManager.Direction.Input;
                    }
                    else
                    {
                        irqManager.PinDirection[j] &= ~GPIOInterruptManager.Direction.Input;
                    }
                },
                                           valueProviderCallback: _ => (irqManager.PinDirection[j] & GPIOInterruptManager.Direction.Input) != 0, name: "InputRegEnable")
                                 .WithTag("OutputBufferEnable", 2, 1)
                                 .WithFlag(3, writeCallback: (_, v) => { irqManager.InterruptEnable[j] = v; }, valueProviderCallback: _ => irqManager.InterruptEnable[j], name: "InterruptEnable")
                                 .WithReservedBits(4, 1)
                                 .WithValueField(5, 3,
                                                 writeCallback: (_, value) =>
                {
                    if (!intTypeToVal.TryGetValue(value, out var type))
                    {
                        this.Log(LogLevel.Warning, "Invalid interrupt type for pin #{0}: {1}", j, value);
                        return;
                    }
                    irqManager.InterruptType[j] = type;
                },
                                                 valueProviderCallback: _ => intTypeToVal[irqManager.InterruptType[j]], name: "InterruptType"));
            }
            registers = new DoubleWordRegisterCollection(this, registersMap);
        }
示例#30
0
        public MiV_CoreGPIO(Machine machine) : base(machine, NumberOfInterrupts)
        {
            innerLock = new object();
            IRQ       = new GPIO();

            irqManager = new GPIOInterruptManager(IRQ, State);

            var registersMap = new Dictionary <long, DoubleWordRegister>
            {
                { (long)Registers.OutputRegister, new DoubleWordRegister(this).WithValueField(0, 32, FieldMode.Write, writeCallback: (_, value) =>
                    {
                        lock (innerLock)
                        {
                            var bits = BitHelper.GetBits(value);
                            for (var i = 0; i < bits.Length; i++)
                            {
                                Connections[i].Set(bits[i]);
                            }
                        }
                    }) },

                { (long)Registers.InputRegister, new DoubleWordRegister(this).WithValueField(0, 32, FieldMode.Read, valueProviderCallback: _ =>
                    {
                        lock (innerLock)
                        {
                            return(BitHelper.GetValueFromBitsArray(State));
                        }
                    }) },

                { (long)Registers.InterruptClearRegister, new DoubleWordRegister(this).WithValueField(0, 32, writeCallback: (_, value) =>
                    {
                        lock (innerLock)
                        {
                            foreach (var i in BitHelper.GetSetBits(value))
                            {
                                irqManager.ClearInterrupt((uint)i);
                            }
                        }
                    }, valueProviderCallback: _ => {
                        lock (innerLock)
                        {
                            return(BitHelper.GetValueFromBitsArray(irqManager.ActiveInterrupts));
                        }
                    }) }
            };

            var intTypeToVal = new TwoWayDictionary <GPIOInterruptManager.InterruptTrigger, uint>();

            intTypeToVal.Add(GPIOInterruptManager.InterruptTrigger.ActiveHigh, 0);
            intTypeToVal.Add(GPIOInterruptManager.InterruptTrigger.ActiveLow, 1);
            intTypeToVal.Add(GPIOInterruptManager.InterruptTrigger.RisingEdge, 2);
            intTypeToVal.Add(GPIOInterruptManager.InterruptTrigger.FallingEdge, 3);
            intTypeToVal.Add(GPIOInterruptManager.InterruptTrigger.BothEdges, 4);

            for (var i = 0; i < NumberOfInterrupts; i++)
            {
                var j = i;
                registersMap.Add((long)Registers.ConfigurationRegisterBase + i * 0x4, new DoubleWordRegister(this)
                                 .WithFlag(0, writeCallback: (_, v) =>
                {
                    if (v)
                    {
                        irqManager.PinDirection[j] |= GPIOInterruptManager.Direction.Output;
                    }
                    else
                    {
                        irqManager.PinDirection[j] &= ~GPIOInterruptManager.Direction.Output;
                    }
                },
                                           valueProviderCallback: _ => (irqManager.PinDirection[j] & GPIOInterruptManager.Direction.Output) != 0, name: "OUTREG")
                                 .WithFlag(1, writeCallback: (_, value) =>
                {
                    if (value)
                    {
                        irqManager.PinDirection[j] |= GPIOInterruptManager.Direction.Input;
                    }
                    else
                    {
                        irqManager.PinDirection[j] &= ~GPIOInterruptManager.Direction.Input;
                    }
                },
                                           valueProviderCallback: _ => (irqManager.PinDirection[j] & GPIOInterruptManager.Direction.Input) != 0, name: "INREG")
                                 .WithTag("OUTBUFF", 2, 1)
                                 .WithFlag(3, writeCallback: (_, v) => { irqManager.InterruptEnable[j] = v; }, valueProviderCallback: _ => irqManager.InterruptEnable[j], name: "INTENABLE")
                                 //bit 4 unused
                                 .WithValueField(5, 3, writeCallback: (_, value) =>
                {
                    if (!intTypeToVal.TryGetValue(value, out var type))
                    {
                        this.Log(LogLevel.Warning, "Invalid interrupt type for pin #{0}: {1}", j, value);
                        return;
                    }
                    irqManager.InterruptType[j] = type;
                }, valueProviderCallback: _ =>
                {
                    if (!intTypeToVal.TryGetValue(irqManager.InterruptType[j], out var value))
                    {
                        throw new ArgumentOutOfRangeException($"Unknown interrupt trigger type: {irqManager.InterruptType[j]}");
                    }
                    return(value);
                }, name: "INTTYPE"));
            }

            registers = new DoubleWordRegisterCollection(this, registersMap);
        }