/// <summary> /// Constructs a new hardware register. /// </summary> /// <param name="description">The current register description.</param> /// <param name="registerValue">The associated register value.</param> internal HardwareRegister( RegisterDescription description, int registerValue) : base(description) { RegisterValue = registerValue; }
/// <summary> /// Constructs a new primitive register. /// </summary> /// <param name="description">The current register description.</param> /// <param name="registerValue">The associated register value.</param> internal PrimitiveRegister( RegisterDescription description, int registerValue) { Description = description; RegisterValue = registerValue; }
/// <summary> /// Constructs a new constant register. /// </summary> /// <param name="description">The current register description.</param> /// <param name="value">The primitive value.</param> public ConstantRegister( RegisterDescription description, PrimitiveValue value) : base(description) { Value = value; }
public void AddRegister(RegisterDescription reg) { if (Registers.ContainsKey(reg.Name)) { throw new ArgumentException($"Dublicate register: {reg.Name}"); } Registers.Add(reg); }
private uint RegisterWeight(RegisterDescription r) { if (r.FloatAddress != null) { return((uint)r.FloatAddress); } return(r.IntegerAddress); }
public EditRegisterViewModel(IDevicesConfigurationProvider devicesConfiguration) { this.devicesConfiguration = devicesConfiguration; this.PropertyChanged += (s, e) => { var canSaveName = nameof(this.CanSave); if (e.PropertyName != canSaveName) { this.RaisePropertyChanged(nameof(this.CanSave)); } }; this.registerDescription = new RegisterDescription(); }
/// <summary> /// Allocates a specific register kind for the given node. /// </summary> /// <param name="node">The node to allocate the register for.</param> /// <param name="description">The register description to allocate.</param> /// <returns>The allocated register.</returns> public PrimitiveRegister Allocate(Value node, RegisterDescription description) { Debug.Assert(node != null, "Invalid node"); if (aliases.TryGetValue(node, out Value alias)) node = alias; if (!registerLookup.TryGetValue(node, out RegisterEntry entry)) { var targetRegister = AllocateRegister(description); entry = new RegisterEntry(targetRegister, node); registerLookup.Add(node, entry); } var result = entry.Register as PrimitiveRegister; Debug.Assert(result != null, "Invalid primitive register"); return result; }
/// <summary> /// Allocates a specific register kind for the given node. /// </summary> /// <param name="node">The node to allocate the register for.</param> /// <param name="description">The register description to allocate.</param> /// <returns>The allocated register.</returns> public HardwareRegister Allocate(Value node, RegisterDescription description) { node.AssertNotNull(node); if (aliases.TryGetValue(node, out Value alias)) { node = alias; } if (!registerLookup.TryGetValue(node, out RegisterEntry entry)) { var targetRegister = AllocateRegister(description); entry = new RegisterEntry(targetRegister, node); registerLookup.Add(node, entry); } var result = entry.Register as HardwareRegister; node.AssertNotNull(result); return(result); }
private static void AddRegister(ArchitectureDescription architecture, ParseTreeNode parseTreeNode) { RegisterDescription reg = new RegisterDescription() { Name = parseTreeNode.ChildNodes[1].Token.ValueString }; List <ParseTreeNode> parts = parseTreeNode.ChildNodes[3].SeperatedList("view-parts", "view-part"); foreach (var part in parts) { string name = part.ChildNodes[0].Token.ValueString; IndexRange range = ReadIndexRange(part.ChildNodes[1]); if (architecture.ContainsStorage(name)) { StorageDescription storage = architecture.Storages[name]; StoragePartDescription stPart = new StoragePartDescription() { Storage = storage, StartBit = range.Start, EndBit = range.End }; if (range.Start < 0) { throw new IndexOutOfRangeException("View range must have positive indexes."); } else if (range.End > storage.Length) { throw new IndexOutOfRangeException("View is out of storage bounds."); } reg.Parts.Add(stPart); } else { throw new KeyNotFoundException($"Storage {name} not found in {architecture.Name}."); } } architecture.AddRegister(reg); }
public static PeripheralRegisterInfo ParseXmlNode(XmlNode root) { RegisterDescription? register_descritpion = null; List <BitDescription> bit_descriptions = new List <BitDescription>(); if (root.Name != nameof(PeripheralRegisterInfo)) { throw new ArgumentException(); } foreach (XmlNode child in root.ChildNodes) { if (child.Name == nameof(RegisterDescription)) { if (register_descritpion != null) { throw new ArgumentException(); } register_descritpion = new RegisterDescription( child.SelectSingleNode("/" + nameof(RegisterDescription.short_name)).Value, child.SelectSingleNode("/" + nameof(RegisterDescription.long_name)).Value, child.SelectSingleNode("/" + nameof(RegisterDescription.description)).Value); } else if (child.Name == nameof(BitDescription)) { bit_descriptions.Add(new BitDescription( uint.Parse(child.SelectSingleNode("/" + nameof(BitDescription.num_bits)).Value), child.SelectSingleNode("/" + nameof(BitDescription.short_name)).Value, child.SelectSingleNode("/" + nameof(BitDescription.long_name)).Value, child.SelectSingleNode("/" + nameof(BitDescription.description)).Value, child.SelectSingleNode("/" + nameof(BitDescription.values)).Value)); } else { throw new ArgumentException(); } } return(new PeripheralRegisterInfo(register_descritpion.Value, bit_descriptions)); }
/// <summary> /// Allocates a new hardware register of the given kind. /// </summary> /// <param name="description"> /// The register description used for allocation. /// </param> /// <returns>The allocated register.</returns> public abstract HardwareRegister AllocateRegister( RegisterDescription description);
/// <summary> /// Allocates a new primitive register of the given kind. /// </summary> /// <param name="description">The register description used for allocation.</param> /// <returns>The allocated register.</returns> public abstract PrimitiveRegister AllocateRegister(RegisterDescription description);
public RegisterReference(DeviceDescription device, RegisterDescription register) { this.Register = register; this.Device = device; }
private int RegisterLength(RegisterDescription register) { return(register.FloatAddress == null ? 1 : 2); }
/// <summary> /// Constructs a new constant register. /// </summary> /// <param name="description">The current register description.</param> protected PrimitiveRegister(RegisterDescription description) { Description = description; }
public Register(RegisterDescription description) { this.Description = description; this.CanWrite = description.WriteAddress != null; }
public RegisterId(uint device, RegisterDescription register) { this.Device = device; this.Register = register.IntegerAddress; }
public PeripheralRegisterInfo(RegisterDescription reg, List <BitDescription> bit) { register_info = reg; bit_info = bit; }