internal Tsl2591Registers(IRegisterManagerAdapter adapter) : base(adapter, true) { enable = new EnableRegister(this); _registers.Add(enable); config = new ConfigRegister(this); _registers.Add(config); interruptLowThreshold = new InterruptLowThresholdRegister(this); _registers.Add(interruptLowThreshold); interruptHighThreshold = new InterruptHighThresholdRegister(this); _registers.Add(interruptHighThreshold); noPersistLowThreshold = new NoPersistLowThresholdRegister(this); _registers.Add(noPersistLowThreshold); noPersistHighThreshold = new NoPersistHighThresholdRegister(this); _registers.Add(noPersistHighThreshold); persist = new PersistRegister(this); _registers.Add(persist); packageId = new PackageIdRegister(this); _registers.Add(packageId); deviceId = new DeviceIdRegister(this); _registers.Add(deviceId); status = new StatusRegister(this); _registers.Add(status); ch0 = new Ch0Register(this); _registers.Add(ch0); ch1 = new Ch1Register(this); _registers.Add(ch1); }
public void OnInterruptRequested() { if (StatusRegister.HasFlag(NESCpuFlags.DisableInterrupts)) { return; } WriteToDataBus( (ushort)(Constants.InterruptStackPointerBase + StackPointer--), (byte)((ProgramCounter >> 8) & Constants.Masks.LowByte)); WriteToDataBus( (ushort)(Constants.InterruptStackPointerBase + StackPointer--), (byte)(ProgramCounter & Constants.Masks.LowByte)); SetStatusFlag(NESCpuFlags.Break, false); SetStatusFlag(NESCpuFlags.Unused, true); SetStatusFlag(NESCpuFlags.DisableInterrupts, true); WriteToDataBus( (ushort)(Constants.InterruptStackPointerBase + StackPointer--), (byte)StatusRegister); AbsoluteAddress = Constants.InterruptRequestPCAddress; var pcLowBits = ReadFromDataBus(AbsoluteAddress); var pcHighBits = ReadFromDataBus((ushort)(AbsoluteAddress + 1)); ProgramCounter = (ushort)((pcHighBits << 8) | pcLowBits); ClockCyclesRemaining = 7; }
public void StartListening() { ConfigurationRegister configRegister = Configuration.Registers.ConfigurationRegister; configRegister.PWR_UP = true; configRegister.PRIM_RX = true; configRegister.Save(); StatusRegister statusRegister = Configuration.Registers.StatusRegister; statusRegister.RX_DR = false; statusRegister.TX_DS = false; statusRegister.MAX_RT = false; statusRegister.Save(); // Restore the pipe0 address, if exists if (_receiveAddressPipe0 > 0) { AddressPipeRegister receiveAddressPipe0Register = Configuration.Registers.ReceiveAddressPipeRegisters[0]; receiveAddressPipe0Register.Load(BitConverter.GetBytes(_receiveAddressPipe0)); receiveAddressPipe0Register.Save(); } TransmitPipe.FlushBuffer(); ReceivePipes.FlushBuffer(); ChipEnable(true); }
public bool Write(byte[] data, bool disableAck = false, int timeout = 1000) { Stopwatch stopwatch = Stopwatch.StartNew(); StatusRegister statusRegister = _registerContainer.StatusRegister; while (statusRegister.TransmitFifoFull) { if (statusRegister.MaximunTransmitRetries) { //ReuseTransmitPayload(); bool checkOperatingMode = _commandProcessor.CheckOperatingMode; _commandProcessor.CheckOperatingMode = false; statusRegister.ResetToDefault(); _commandProcessor.CheckOperatingMode = checkOperatingMode; return(false); } //if (stopwatch.ElapsedMilliseconds() > timeout) // return false; statusRegister.Load(); } if (data.Length > Constants.MaxPayloadWidth) { throw new ArgumentOutOfRangeException(nameof(data), string.Format("Data should be 0-{0} bytes", Constants.MaxPayloadWidth)); } _commandProcessor.ExecuteCommand(disableAck ? DeviceCommands.W_TX_PAYLOAD_NO_ACK : DeviceCommands.W_TX_PAYLOAD, RegisterAddresses.EMPTY_ADDRESS, data); return(true); }
public RegistersPPU() { PpuCtrl = new ControlRegister(0); PpuMask = new MaskRegister(0); PpuStat = new StatusRegister(0); PpuScrl = new ScrollRegister(0); }
public bool Available(byte[] pipes) { StatusRegister statusRegister = Configuration.Registers.StatusRegister; bool result = statusRegister.RX_DR; if (result) { // If the caller wants the pipe number, include that if (pipes != null) { pipes[0] = (byte)((statusRegister >> Properties.RX_P_NO) & 0x7); } statusRegister.RX_DR = true; // Handle ack payload receipt if (!statusRegister.TX_DS) { statusRegister.TX_DS = true; } statusRegister.Save(); } return(result); }
/// <summary> /// Sets the instruction. /// </summary> /// <param name="instruction">The instruction.</param> /// <param name="updateStatus">if set to <c>true</c> [update status].</param> /// <param name="result">The result.</param> /// <param name="operand1">The operand1.</param> public void SetInstruction(BaseInstruction instruction, StatusRegister statusRegister, Operand result, Operand operand1) { SetInstruction(instruction, 1, (byte)((result == null) ? 0 : 1)); Result = result; Operand1 = operand1; StatusRegister = statusRegister; }
internal Bmp280Registers(IRegisterManagerAdapter adapter) : base(adapter, true) { t1 = new T1Register(this); _registers.Add(t1); t2 = new T2Register(this); _registers.Add(t2); t3 = new T3Register(this); _registers.Add(t3); p1 = new P1Register(this); _registers.Add(p1); p2 = new P2Register(this); _registers.Add(p2); p3 = new P3Register(this); _registers.Add(p3); p4 = new P4Register(this); _registers.Add(p4); p5 = new P5Register(this); _registers.Add(p5); p6 = new P6Register(this); _registers.Add(p6); p7 = new P7Register(this); _registers.Add(p7); p8 = new P8Register(this); _registers.Add(p8); p9 = new P9Register(this); _registers.Add(p9); h1 = new H1Register(this); _registers.Add(h1); id = new IdRegister(this); _registers.Add(id); reset = new ResetRegister(this); _registers.Add(reset); h2 = new H2Register(this); _registers.Add(h2); h3 = new H3Register(this); _registers.Add(h3); h4 = new H4Register(this); _registers.Add(h4); h4h5 = new H4h5Register(this); _registers.Add(h4h5); h5 = new H5Register(this); _registers.Add(h5); h6 = new H6Register(this); _registers.Add(h6); ctrlHumidity = new CtrlHumidityRegister(this); _registers.Add(ctrlHumidity); status = new StatusRegister(this); _registers.Add(status); ctrlMeasure = new CtrlMeasureRegister(this); _registers.Add(ctrlMeasure); config = new ConfigRegister(this); _registers.Add(config); pressure = new PressureRegister(this); _registers.Add(pressure); temperature = new TemperatureRegister(this); _registers.Add(temperature); humidity = new HumidityRegister(this); _registers.Add(humidity); }
/// <summary> /// Sets the instruction. /// </summary> /// <param name="instruction">The instruction.</param> /// <param name="condition">The condition.</param> /// <param name="updateStatus">if set to <c>true</c> [update status].</param> /// <param name="result">The result.</param> /// <param name="operand1">The operand1.</param> /// <param name="operand2">The operand2.</param> public void SetInstruction(BaseInstruction instruction, StatusRegister statusRegister, ConditionCode condition, Operand result, Operand operand1, Operand operand2) { SetInstruction(instruction, 2, (byte)((result == null) ? 0 : 1)); Result = result; Operand1 = operand1; Operand2 = operand2; ConditionCode = condition; StatusRegister = statusRegister; }
public Cpu(Nes nes) { this.nes = nes; Status = new StatusRegister(); InitInstructions(); cycles = 0; }
public void WhatHappened(out bool txOk, out bool txFail, out bool rxReady) { StatusRegister statusRegister = Configuration.Registers.StatusRegister; statusRegister.RX_DR = true; statusRegister.TX_DS = true; statusRegister.MAX_RT = true; statusRegister.Save(); txOk = statusRegister.TX_DS; txFail = statusRegister.MAX_RT; rxReady = statusRegister.RX_DR; }
public void Begin() { RegisterManager registers = Configuration.Registers; ChipEnable(false); // Set 1500uS (minimum for 32B payload in ESB@250KBPS) timeouts, to make testing a little easier // WARNING: If this is ever lowered, either 250KBS mode with AA is broken or maximum packet // sizes must never be used. See documentation for a more complete explanation. Configuration.AutoRetransmitDelay = AutoRetransmitDelays.Delay4000uS; Configuration.AutoRetransmitCount = 15; // Disable auto acknowledgement EnableAutoAcknowledgementRegister autoAckRegister = registers.EnableAutoAcknowledgementRegister; autoAckRegister.EN_AA = false; autoAckRegister.Save(); // Attempt to set DataRate to 250Kbps to determine if this is a plus model Configuration.DataRate = DataRates.DataRate250Kbps; Configuration.IsPlusModel = Configuration.DataRate == DataRates.DataRate250Kbps; // Restore our default PA level Configuration.PowerLevel = PowerLevels.Max; // Initialize CRC and request 2-byte (16bit) CRC Configuration.CrcEncodingScheme = CrcEncodingSchemes.DualBytes; Configuration.CrcEnabled = true; // Disable dynamic payload lengths Configuration.DynamicPayloadLengthEnabled = false; // Set up default configuration. Callers can always change it later. // This channel should be universally safe and not bleed over into adjacent spectrum. Configuration.Channel = 76; // Then set the data rate to the slowest (and most reliable) speed supported by all hardware. Configuration.DataRate = DataRates.DataRate1Mbps; // Reset current status // Notice reset and flush is the last thing we do StatusRegister statusRegister = registers.StatusRegister; statusRegister.RX_DR = false; statusRegister.TX_DS = false; statusRegister.MAX_RT = false; statusRegister.Save(); TransmitPipe.FlushBuffer(); ReceivePipes.FlushBuffer(); }
public static bool IsBitSet(this StatusRegisterBit bit, StatusRegister reg, RegisterFeedback feedback) { if (reg.SignednessType == Signedness.Signed) { var val = feedback.getSignedValue(); return isBitSet(val, bit.Bit); } else if (reg.SignednessType == Signedness.Unsigned) { var val = feedback.getUnsignedValue(); return isBitSet(val, bit.Bit); } throw new Exception("unknown signedness"); }
public SystemControlUnit(VR4300 cpu) { this.cpu = cpu; Config = new ConfigRegister(this); Status = new StatusRegister(this); Cause = new CauseRegister(this); operations = new Dictionary <Instruction, Action <Instruction> > { [From(OpCode.MT)] = i => { var destination = i.RD; var data = cpu.GPR[i.RT]; switch ((RegisterIndex)destination) { case RegisterIndex.Cause: Registers[destination] &= ~CauseRegister.WriteMask; Registers[destination] |= data & CauseRegister.WriteMask; return; case RegisterIndex.Compare: var ip = Cause.IP; ip.TimerInterrupt = false; Cause.IP = ip; break; } Registers[destination] = data; }, [From(OpCode.MF)] = i => cpu.GPR[i.RT] = (ulong)(int)Registers[i.RD], [From(FunctOpCode.TLBWI)] = i => { /* TODO. */ }, [From(FunctOpCode.ERET)] = i => { if (Status.ERL) { cpu.PC = Registers[(int)RegisterIndex.ErrorEPC]; Status.ERL = false; } else { cpu.PC = Registers[(int)RegisterIndex.EPC]; Status.EXL = false; } cpu.LLBit = false; cpu.DelaySlot = null; } }; }
public byte ReadRegister(RegisterEnum register, out StatusRegister statusRegister) { var registerOrCommand = (byte)((byte)register | (byte)CommandEnum.ReadRegister); if (register == RegisterEnum.Status) { statusRegister = Exchange(NOP, null); return(statusRegister); } _tinyBuffer[0] = NOP; statusRegister = Exchange(registerOrCommand, _tinyBuffer); return(_tinyBuffer[0]); }
internal L3gd20Registers(IRegisterManagerAdapter adapter) : base(adapter, true) { whoAmI = new WhoAmIRegister(this); _registers.Add(whoAmI); ctrlReg1 = new CtrlReg1Register(this); _registers.Add(ctrlReg1); ctrlReg2 = new CtrlReg2Register(this); _registers.Add(ctrlReg2); ctrlReg3 = new CtrlReg3Register(this); _registers.Add(ctrlReg3); ctrlReg4 = new CtrlReg4Register(this); _registers.Add(ctrlReg4); ctrlReg5 = new CtrlReg5Register(this); _registers.Add(ctrlReg5); referenceDataCapture = new ReferenceDataCaptureRegister(this); _registers.Add(referenceDataCapture); outTemp = new OutTempRegister(this); _registers.Add(outTemp); status = new StatusRegister(this); _registers.Add(status); fifoCtrl = new FifoCtrlRegister(this); _registers.Add(fifoCtrl); fifoSrc = new FifoSrcRegister(this); _registers.Add(fifoSrc); intConfig = new IntConfigRegister(this); _registers.Add(intConfig); int1Src = new Int1SrcRegister(this); _registers.Add(int1Src); int1ThresholdX = new Int1ThresholdXRegister(this); _registers.Add(int1ThresholdX); int1ThresholdY = new Int1ThresholdYRegister(this); _registers.Add(int1ThresholdY); int1ThresholdZ = new Int1ThresholdZRegister(this); _registers.Add(int1ThresholdZ); int1Duration = new Int1DurationRegister(this); _registers.Add(int1Duration); outX = new OutXRegister(this); _registers.Add(outX); outY = new OutYRegister(this); _registers.Add(outY); outZ = new OutZRegister(this); _registers.Add(outZ); }
public override string ToString() { StringBuilder sb = new StringBuilder(); StatusRegister statusRegister = _registerContainer.StatusRegister; statusRegister.Load(); byte status = statusRegister; sb.AppendFormat("STATUS\t\t\t = 0x{0} RX_DR={1} TX_DS={2} MAX_RT={3} RX_P_NO={4} TX_FULL={5}\r\n", status.ToString("X").PadLeft(2, '0'), statusRegister.ReceiveDataReady, statusRegister.TransmitDataSent, statusRegister.MaximunTransmitRetries, statusRegister.ReceiveDataPipeNumber, statusRegister.TransmitFifoFull); sb.AppendLine(GetAddressRegister("RX_ADDR_P0-1", RegisterAddresses.RX_ADDR_P0, 2)); sb.AppendLine(GetByteRegister("RX_ADDR_P2-5", RegisterAddresses.RX_ADDR_P2, 4)); sb.AppendLine(GetAddressRegister("TX_ADDR", RegisterAddresses.TX_ADDR, 1)); sb.AppendLine(GetByteRegister("RX_PW_P0-6", RegisterAddresses.RX_PW_P0, 6)); sb.AppendLine(GetByteRegister("EN_AA", RegisterAddresses.EN_AA, 1)); sb.AppendLine(GetByteRegister("EN_RXADDR", RegisterAddresses.EN_RXADDR, 1)); sb.AppendLine(GetByteRegister("RF_CH", RegisterAddresses.RF_CH, 1)); sb.AppendLine(GetByteRegister("RF_SETUP", RegisterAddresses.RF_SETUP, 1)); sb.AppendLine(GetByteRegister("CONFIG", RegisterAddresses.CONFIG, 1)); sb.AppendLine(GetByteRegister("DYNPD/FEATURE", RegisterAddresses.DYNPD, 2)); sb.AppendLine("Data Rate\t\t = " + _configuration.DataRate.GetName()); sb.AppendLine("Model\t\t\t = " + _configuration.RadioModel.GetName()); sb.AppendLine("CRC Length\t\t = " + _configuration.CrcEncodingScheme.GetName()); sb.AppendLine("PA Power\t\t = " + _configuration.PowerLevel.GetName()); string output = sb.ToString(); _logger.InfoFormat("Arduino Details\r\n{0}", output); return(output); }
/// <summary> /// Appends the instruction. /// </summary> /// <param name="instruction">The instruction.</param> /// <param name="statusRegister">if set to <c>true</c> [update status].</param> /// <param name="result">The result.</param> /// <param name="operand1">The operand1.</param> /// <param name="operand2">The operand2.</param> public void AppendInstruction(BaseInstruction instruction, StatusRegister statusRegister, Operand result, Operand operand1, Operand operand2) { AppendInstruction(); Node.SetInstruction(instruction, statusRegister, result, operand1, operand2); }
/// <summary> /// Sets the instruction. /// </summary> /// <param name="instruction">The instruction.</param> /// <param name="statusRegister">if set to <c>true</c> [update status].</param> /// <param name="condition">The condition.</param> /// <param name="result">The result.</param> /// <param name="operand1">The operand1.</param> /// <param name="operand2">The operand2.</param> /// <param name="operand3">The operand3.</param> public void SetInstruction(BaseInstruction instruction, StatusRegister statusRegister, Operand result, Operand operand1, Operand operand2, Operand operand3) { Node.SetInstruction(instruction, statusRegister, result, operand1, operand2, operand3); }
/// <summary> /// Sets the instruction. /// </summary> /// <param name="instruction">The instruction.</param> /// <param name="statusRegister">if set to <c>true</c> [update status].</param> /// <param name="condition">The condition.</param> /// <param name="result">The result.</param> /// <param name="operand1">The operand1.</param> /// <param name="operand2">The operand2.</param> public void SetInstruction(BaseInstruction instruction, StatusRegister statusRegister, ConditionCode condition, Operand result, Operand operand1, Operand operand2) { Node.SetInstruction(instruction, statusRegister, condition, result, operand1, operand2); }
/// <summary> /// Sets the instruction. /// </summary> /// <param name="instruction">The instruction.</param> /// <param name="statusRegister">if set to <c>true</c> [update status].</param> /// <param name="result">The result.</param> public void SetInstruction(BaseInstruction instruction, StatusRegister statusRegister, Operand result) { Node.SetInstruction(instruction, statusRegister, result); }
/// <summary> /// Appends the instruction. /// </summary> /// <param name="instruction">The instruction.</param> /// <param name="statusRegister">if set to <c>true</c> [update status].</param> /// <param name="condition">The condition.</param> /// <param name="result">The result.</param> /// <param name="operand1">The operand1.</param> public void AppendInstruction(BaseInstruction instruction, StatusRegister statusRegister, ConditionCode condition, Operand result, Operand operand1) { AppendInstruction(); Node.SetInstruction(instruction, statusRegister, condition, result, operand1); }
public StatusRegisterTester() { flags = new StatusRegister(); }
public CP0Registers() { m_Regs = new UInt64[32]; m_SR = new StatusRegister(); m_CauseReg = new CauseRegister(); }
public TRegister ModifyRegister <TRegister>(RegisterEnum register, [NotNull] Action <TRegister> action, out StatusRegister statusRegister) where TRegister : IRegister { if (action == null) { throw new ArgumentNullException(nameof(action)); } var readByteValue = ReadRegister(register, out statusRegister); var registerValue = (TRegister)(dynamic)readByteValue; action(registerValue); var setByteValue = (byte)(dynamic)registerValue; if (setByteValue != readByteValue) { statusRegister = WriteRegister(register, setByteValue); } return(registerValue); }
public byte ModifyRegister(RegisterEnum register, [NotNull] Func <byte, byte> action, out StatusRegister statusRegister) { if (action == null) { throw new ArgumentNullException(nameof(action)); } var readValue = ReadRegister(register, out statusRegister); var setValue = action(readValue); if (setValue != readValue) { statusRegister = WriteRegister(register, setValue); } return(setValue); }
protected void TransformInstructionXXX(Context context, BaseInstruction virtualInstruction, BaseInstruction immediateInstruction, Operand result, StatusRegister statusRegister, Operand operand1, Operand operand2) { // TODO!!!!! // AddFloatR4 result, operand1, operand2 // TODO: (across all float instructions) // if operand1 is constant // if resolved & specific constant, then AdfImm // else if resolved & non-specific constant, then LoadConstant, adf // else if unresolved, throw not implemented if (operand1.IsConstant) { if (virtualInstruction.IsCommutative && !operand2.IsConstant) { var temp = operand1; operand1 = operand2; operand2 = temp; } else { operand1 = MoveConstantToRegister(context, operand1); } } if (operand2.IsConstant) { operand2 = CreateRotatedImmediateOperand(context, operand2); } Debug.Assert(operand1.IsVirtualRegister || operand1.IsCPURegister); if (operand2.IsVirtualRegister || operand2.IsCPURegister) { context.SetInstruction(virtualInstruction, statusRegister, result, operand1, operand2); } else if (operand2.IsResolvedConstant) { context.SetInstruction(immediateInstruction, statusRegister, result, operand1, operand2); } else { throw new CompilerException("Error at {context} in {Method}"); } }
public RegisterManager(Radio radio) { ConfigurationRegister = new ConfigurationRegister(radio); EnableAutoAcknowledgementRegister = new EnableAutoAcknowledgementRegister(radio); EnableReceiveAddressRegister = new EnableReceiveAddressRegister(radio); AddressWidthRegister = new SetupAddressWidthRegister(radio); SetupRetransmissionRegister = new SetupRetransmissionRegister(radio); RfChannelRegister = new RfChannelRegister(radio); RfSetupRegister = new RfSetupRegister(radio); StatusRegister = new StatusRegister(radio); ObserveTransmitRegister = new ObserveTransmitRegister(radio); ReceivedPowerDetectorRegister = new ReceivedPowerDetectorRegister(radio); TransmitAddressRegister = new AddressPipeRegister(radio, Addresses.TX_ADDR, 0); FifoStatusRegister = new FifoStatusRegister(radio); DynamicPayloadLengthRegister = new DynamicPayloadLengthRegister(radio); FeatureRegister = new FeatureRegister(radio); ReceiveAddressPipeRegisters = new RegisterCollection<AddressPipeRegister> { {0, new AddressPipeRegister(radio, Addresses.RX_ADDR_P0, 0)}, {1, new AddressPipeRegister(radio, Addresses.RX_ADDR_P1, 1)}, {2, new AddressPipeRegister(radio, Addresses.RX_ADDR_P1, 2)}, {3, new AddressPipeRegister(radio, Addresses.RX_ADDR_P1, 3)}, {4, new AddressPipeRegister(radio, Addresses.RX_ADDR_P1, 4)}, {5, new AddressPipeRegister(radio, Addresses.RX_ADDR_P1, 5)}, }; ReceivePayloadWidthPipeRegisters = new RegisterCollection<ReceivePayloadWidthPipeRegister> { {0, new ReceivePayloadWidthPipeRegister(radio, Addresses.RX_PW_P0, 0)}, {1, new ReceivePayloadWidthPipeRegister(radio, Addresses.RX_PW_P1, 1)}, {2, new ReceivePayloadWidthPipeRegister(radio, Addresses.RX_PW_P2, 2)}, {3, new ReceivePayloadWidthPipeRegister(radio, Addresses.RX_PW_P3, 3)}, {4, new ReceivePayloadWidthPipeRegister(radio, Addresses.RX_PW_P4, 4)}, {5, new ReceivePayloadWidthPipeRegister(radio, Addresses.RX_PW_P5, 5)} }; AllRegisters = new RegisterCollection<RegisterBase> { {Addresses.CONFIG, ConfigurationRegister}, {Addresses.EN_AA, EnableAutoAcknowledgementRegister}, {Addresses.EN_RXADDR, EnableReceiveAddressRegister}, {Addresses.SETUP_AW, AddressWidthRegister}, {Addresses.SETUP_RETR, SetupRetransmissionRegister}, {Addresses.RF_CH, RfChannelRegister}, {Addresses.RF_SETUP, RfSetupRegister}, {Addresses.STATUS, StatusRegister}, {Addresses.OBSERVE_TX, ObserveTransmitRegister}, {Addresses.RPD, ReceivedPowerDetectorRegister}, {Addresses.RX_ADDR_P0, ReceiveAddressPipeRegisters[0]}, {Addresses.RX_ADDR_P1, ReceiveAddressPipeRegisters[1]}, {Addresses.RX_ADDR_P2, ReceiveAddressPipeRegisters[2]}, {Addresses.RX_ADDR_P3, ReceiveAddressPipeRegisters[3]}, {Addresses.RX_ADDR_P4, ReceiveAddressPipeRegisters[4]}, {Addresses.RX_ADDR_P5, ReceiveAddressPipeRegisters[5]}, {Addresses.TX_ADDR, TransmitAddressRegister}, {Addresses.RX_PW_P0, ReceivePayloadWidthPipeRegisters[0]}, {Addresses.RX_PW_P1, ReceivePayloadWidthPipeRegisters[1]}, {Addresses.RX_PW_P2, ReceivePayloadWidthPipeRegisters[2]}, {Addresses.RX_PW_P3, ReceivePayloadWidthPipeRegisters[3]}, {Addresses.RX_PW_P4, ReceivePayloadWidthPipeRegisters[4]}, {Addresses.RX_PW_P5, ReceivePayloadWidthPipeRegisters[5]}, {Addresses.FIFO_STATUS, FifoStatusRegister}, {Addresses.DYNPD, DynamicPayloadLengthRegister}, {Addresses.FEATURE, FeatureRegister} }; }
public RegisterManager(Radio radio) { ConfigurationRegister = new ConfigurationRegister(radio); EnableAutoAcknowledgementRegister = new EnableAutoAcknowledgementRegister(radio); EnableReceiveAddressRegister = new EnableReceiveAddressRegister(radio); AddressWidthRegister = new SetupAddressWidthRegister(radio); SetupRetransmissionRegister = new SetupRetransmissionRegister(radio); RfChannelRegister = new RfChannelRegister(radio); RfSetupRegister = new RfSetupRegister(radio); StatusRegister = new StatusRegister(radio); ObserveTransmitRegister = new ObserveTransmitRegister(radio); ReceivedPowerDetectorRegister = new ReceivedPowerDetectorRegister(radio); TransmitAddressRegister = new AddressPipeRegister(radio, Addresses.TX_ADDR, 0); FifoStatusRegister = new FifoStatusRegister(radio); DynamicPayloadLengthRegister = new DynamicPayloadLengthRegister(radio); FeatureRegister = new FeatureRegister(radio); ReceiveAddressPipeRegisters = new RegisterCollection <AddressPipeRegister> { { 0, new AddressPipeRegister(radio, Addresses.RX_ADDR_P0, 0) }, { 1, new AddressPipeRegister(radio, Addresses.RX_ADDR_P1, 1) }, { 2, new AddressPipeRegister(radio, Addresses.RX_ADDR_P1, 2) }, { 3, new AddressPipeRegister(radio, Addresses.RX_ADDR_P1, 3) }, { 4, new AddressPipeRegister(radio, Addresses.RX_ADDR_P1, 4) }, { 5, new AddressPipeRegister(radio, Addresses.RX_ADDR_P1, 5) }, }; ReceivePayloadWidthPipeRegisters = new RegisterCollection <ReceivePayloadWidthPipeRegister> { { 0, new ReceivePayloadWidthPipeRegister(radio, Addresses.RX_PW_P0, 0) }, { 1, new ReceivePayloadWidthPipeRegister(radio, Addresses.RX_PW_P1, 1) }, { 2, new ReceivePayloadWidthPipeRegister(radio, Addresses.RX_PW_P2, 2) }, { 3, new ReceivePayloadWidthPipeRegister(radio, Addresses.RX_PW_P3, 3) }, { 4, new ReceivePayloadWidthPipeRegister(radio, Addresses.RX_PW_P4, 4) }, { 5, new ReceivePayloadWidthPipeRegister(radio, Addresses.RX_PW_P5, 5) } }; AllRegisters = new RegisterCollection <RegisterBase> { { Addresses.CONFIG, ConfigurationRegister }, { Addresses.EN_AA, EnableAutoAcknowledgementRegister }, { Addresses.EN_RXADDR, EnableReceiveAddressRegister }, { Addresses.SETUP_AW, AddressWidthRegister }, { Addresses.SETUP_RETR, SetupRetransmissionRegister }, { Addresses.RF_CH, RfChannelRegister }, { Addresses.RF_SETUP, RfSetupRegister }, { Addresses.STATUS, StatusRegister }, { Addresses.OBSERVE_TX, ObserveTransmitRegister }, { Addresses.RPD, ReceivedPowerDetectorRegister }, { Addresses.RX_ADDR_P0, ReceiveAddressPipeRegisters[0] }, { Addresses.RX_ADDR_P1, ReceiveAddressPipeRegisters[1] }, { Addresses.RX_ADDR_P2, ReceiveAddressPipeRegisters[2] }, { Addresses.RX_ADDR_P3, ReceiveAddressPipeRegisters[3] }, { Addresses.RX_ADDR_P4, ReceiveAddressPipeRegisters[4] }, { Addresses.RX_ADDR_P5, ReceiveAddressPipeRegisters[5] }, { Addresses.TX_ADDR, TransmitAddressRegister }, { Addresses.RX_PW_P0, ReceivePayloadWidthPipeRegisters[0] }, { Addresses.RX_PW_P1, ReceivePayloadWidthPipeRegisters[1] }, { Addresses.RX_PW_P2, ReceivePayloadWidthPipeRegisters[2] }, { Addresses.RX_PW_P3, ReceivePayloadWidthPipeRegisters[3] }, { Addresses.RX_PW_P4, ReceivePayloadWidthPipeRegisters[4] }, { Addresses.RX_PW_P5, ReceivePayloadWidthPipeRegisters[5] }, { Addresses.FIFO_STATUS, FifoStatusRegister }, { Addresses.DYNPD, DynamicPayloadLengthRegister }, { Addresses.FEATURE, FeatureRegister } }; }
protected void TransformInstruction(Context context, BaseInstruction virtualInstruction, BaseInstruction immediateInstruction, Operand result, StatusRegister statusRegister, Operand operand1, Operand operand2) { if (operand1.IsConstant) { if (virtualInstruction.IsCommutative && !operand2.IsConstant) { var temp = operand1; operand1 = operand2; operand2 = temp; } else { operand1 = MoveConstantToRegister(context, operand1); } } if (operand2.IsConstant) { operand2 = CreateRotatedImmediateOperand(context, operand2); } Debug.Assert(operand1.IsVirtualRegister || operand1.IsCPURegister); if (operand2.IsVirtualRegister || operand2.IsCPURegister) { context.SetInstruction(virtualInstruction, statusRegister, result, operand1, operand2); } else if (operand2.IsResolvedConstant) { context.SetInstruction(immediateInstruction, statusRegister, result, operand1, operand2); } else { throw new CompilerException("Error at {context} in {Method}"); } }
/// <summary> /// Write a status register in the controller /// </summary> /// <param name="aStatus">The register to be written to. It is the <i>generic axis</i> register</param> /// <param name="aValue">The value to write in the register</param> protected void SetControllerStatus(Status aStatus, Int32 aValue) { Debug.Assert(StatusRegister.ContainsKey(aStatus)); Controller.Registers theRegister = StatusRegister[aStatus]; WriteInt(theRegister, aValue); }
public bool GetFlag(CpuFlag cpuFlag) => StatusRegister.HasFlag(cpuFlag);
protected void TransformInstruction(Context context, BaseInstruction virtualInstruction, BaseInstruction immediateInstruction, Operand result, StatusRegister statusRegister, Operand operand1) { if (operand1.IsConstant) { operand1 = CreateRotatedImmediateOperand(context, operand1); } if (operand1.IsVirtualRegister || operand1.IsCPURegister) { context.SetInstruction(virtualInstruction, result, operand1); } else if (operand1.IsResolvedConstant) { context.SetInstruction(immediateInstruction, result, operand1); } else { throw new CompilerException("Error at {context} in {Method}"); } }