private void SetBit(BitValue bit, bool value) { if (value) this.CONFIG1 = (byte)(this.CONFIG1 | (byte)bit); else this.CONFIG1 = (byte)(this.CONFIG1 & ~(byte)bit); }
private void SetBit(BitValue bit, bool value) { if (value) this.MSR = (byte)(this.MSR | (byte)bit); else this.MSR = (byte)(this.MSR & ~(byte)bit); }
public static BitNumber FromString(string val) { BitValue[] bits = new BitValue[val.Length]; for (int i = 0; i < val.Length; i++) { if (val[i] == '1') bits[i] = BitValue.One; else if (val[i] == '0') bits[i] = BitValue.Zero; else if (val[i] == '-') bits[i] = BitValue.DontCare; else throw new ArgumentException(); } return new BitNumber(bits); }
public DPLSYModel(DoubleWordValue _FreqValue, DoubleWordValue _PulseValue, BitValue _OutputValue) { FreqValue = _FreqValue; PulseValue = _PulseValue; OutputValue = _OutputValue; }
public PLSFModel(WordValue _FreqValue, BitValue _OutputValue) { FreqValue = _FreqValue; OutputValue = _OutputValue; }
private static BitValue ConvertZeroOne(BitValue input) { return(input); }
public DPLSFModel(DoubleWordValue _FreqValue, BitValue _OutputValue) { FreqValue = _FreqValue; OutputValue = _OutputValue; }
public DPLSRModel(DoubleWordValue _ArgumentValue, DoubleWordValue _VelocityValue, BitValue _OutputValue) { ArgumentValue = _ArgumentValue; VelocityValue = _VelocityValue; OutputValue = _OutputValue; }
public ALTPModel() { Value = BitValue.Null; }
public PLSRModel(WordValue _ArgumentValue, WordValue _VelocityValue, BitValue _OutputValue) { ArgumentValue = _ArgumentValue; VelocityValue = _VelocityValue; OutputValue = _OutputValue; }
public LDIMModel(BitValue value) { Value = value; }
public PLSSTOPModel() { OutputValue = BitValue.Null; }
public PLSSTOPModel(BitValue _OutputValue) { OutputValue = _OutputValue; }
public PWMModel(WordValue _FreqValue, WordValue _DutyCycleValue, BitValue _OutputValue) { FreqValue = _FreqValue; DutyCycleValue = _DutyCycleValue; OutputValue = _OutputValue; }
public PWMModel() { FreqValue = WordValue.Null; DutyCycleValue = WordValue.Null; OutputValue = BitValue.Null; }
public MEPModel(BitValue value) { }
/// <summary> /// Gets the minterms. LSB are in columns, MSB are in rows. /// </summary> /// <returns>The minterms.</returns> /// <param name="numVar">Number variable.</param> public int[] GetMintermsOf(int numVar, BitValue value) { if (numVar >= (1 << this.NumBits)) throw new ArgumentException(); int numRows = this.table.GetLength(0); int numColumns = this.table.GetLength(1); List<int> minterms = new List<int>(); for (int c = 0; c < numColumns; c++) { for (int r = 0; r < numRows; r++) { if (this.table[r, c][numVar] != value) continue; int mt = 0; for (int x = 0; x < this.NumVarsColumns; x++) { int b = c + (1 << x); b /= (1 << (x + 1)); b %= 2; mt |= (b << x); } for (int y = 0; y < this.NumVarsRows; y++) { int b = r + (1 << y); b /= (1 << (y + 1)); b %= 2; mt |= (b << (y + this.NumVarsColumns)); } minterms.Add(mt); } } return minterms.ToArray(); }
public DPLSRDModel(DoubleWordValue _ArgumentValue, DoubleWordValue _VelocityValue, BitValue _OutputValue1, BitValue _OutputValue2) { ArgumentValue = _ArgumentValue; VelocityValue = _VelocityValue; OutputValue1 = _OutputValue1; OutputValue2 = _OutputValue2; }
public BitNumber(BitValue[] bits) { this.bits = bits; }
public ZRNModel(WordValue _BackValue, WordValue _CrawValue, BitValue _SignalValue, BitValue _OutputValue) { BackValue = _BackValue; CrawValue = _CrawValue; SignalValue = _SignalValue; OutputValue = _OutputValue; }
public DPLSRModel() { ArgumentValue = DoubleWordValue.Null; VelocityValue = DoubleWordValue.Null; OutputValue = BitValue.Null; }
public CMPFModel() { InputValue1 = FloatValue.Null; InputValue2 = FloatValue.Null; OutputValue = BitValue.Null; }
private BitValue[] TransferNumber(int init_number) { System.Text.StringBuilder str = new System.Text.StringBuilder(); while (init_number != 0) { str.Append(init_number % 2); init_number /= 2; } BitValue[] mass = new BitValue[str.Length]; for (int i = 0; i < str.Length; ++i) { if (str[str.Length - 1 - i] == '1') mass[i] = BitValue.One; else if (str[str.Length - 1 - i] == '0') mass[i] = BitValue.Zero; } return mass; }
public CMPFModel(FloatValue _InputValue1, FloatValue _InputValue2, BitValue _OutputValue) { InputValue1 = _InputValue1; InputValue2 = _InputValue2; OutputValue = _OutputValue; }
public ALTPModel(BitValue value) { Value = value; }
public SETIMModel(BitValue value, WordValue count) { Value = value; Count = count; }
public string Ask(string input, out bool success) { success = false; //Remove comment var x = Regex.Match(input, @"\/\/(?=[^""]*(?: ""[^""]*""[^""]*)*$)"); if (x.Success) { input = input.Substring(0, x.Index).Trim(); } if (input == "") { return(""); } try { if (string.IsNullOrWhiteSpace(input)) { return(""); } input = Regex.Replace(input, @"\s+", " ").Trim(); //GetByte var match = Regex.Match(input, @"^getbyte$", RegexOptions.IgnoreCase); if (match.Success) { var adr = Memory.BytePointer; var theByte = Memory.GetByte(); success = true; return($"{adr} {adr.ToHexString()}: {theByte:000} ${theByte:X2}"); } //GetByte 4096 match = Regex.Match(input, @"^getbyte\s?(\$?[0-9A-F]+)$", RegexOptions.IgnoreCase); if (match.Success) { var adrValue = match.Groups[1].Value; var adr = adrValue.StartsWith("$") ? GetAddressHex(adrValue, out var addressSuccess) : GetAddressDec(adrValue, out addressSuccess); if (!addressSuccess) { return("Invalid address."); } var theByte = Memory.GetByte(adr); success = true; return($"{adr} {adr.ToHexString()}: {theByte:000} ${theByte:X2}"); } //GetWord match = Regex.Match(input, @"^getword$", RegexOptions.IgnoreCase); if (match.Success) { var adr = Memory.BytePointer; var theWord = Memory.GetWord(); success = true; return($"{adr} {adr.ToHexString()}: {theWord:00000} ${theWord:X4}"); } //GetWord 4096 match = Regex.Match(input, @"^getword\s?(\$?[0-9A-F]+)$", RegexOptions.IgnoreCase); if (match.Success) { var adrValue = match.Groups[1].Value; var adr = adrValue.StartsWith("$") ? GetWordHex(adrValue, out var addressSuccess) : GetWordDec(adrValue, out addressSuccess); if (!addressSuccess) { return("Invalid address."); } var theWord = Memory.GetWord((Address)adr); success = true; return($"{adr} {adr.ToHexString()}: {theWord:00000} ${theWord:X4}"); } //SetByte 1 match = Regex.Match(input, @"^setbyte\s?(\$?[0-9A-F]+)$", RegexOptions.IgnoreCase); if (match.Success) { var value = match.Groups[1].Value; var adr = Memory.BytePointer; var oldByte = Memory.GetByte(adr); var theByte = value.StartsWith("$") ? GetByteHex(value, out var byteSuccess) : GetByteDec(value, out byteSuccess); if (!byteSuccess) { return("Invalid byte."); } Memory.SetByte(adr, theByte); success = true; return($"{adr} {adr.ToHexString()}: {oldByte:000} ${oldByte:X2} --> {theByte:000} ${theByte:X2}"); } //SetByte 4096, 1 match = Regex.Match(input, @"^setbyte\s?(\$?[0-9A-F]+)\s?,\s?(\$?[0-9A-F]+)$", RegexOptions.IgnoreCase); if (match.Success) { var adrValue = match.Groups[1].Value; var adr = adrValue.StartsWith("$") ? GetAddressHex(adrValue, out var addressSuccess) : GetAddressDec(adrValue, out addressSuccess); if (!addressSuccess) { return("Invalid address."); } var value = match.Groups[2].Value; var oldByte = Memory.GetByte(adr); var theByte = value.StartsWith("$") ? GetByteHex(value, out var byteSuccess) : GetByteDec(value, out byteSuccess); if (!byteSuccess) { return("Invalid byte."); } Memory.SetByte(adr, theByte); success = true; return($"{adr} {adr.ToHexString()}: {oldByte:000} ${oldByte:X2} --> {theByte:000} ${theByte:X2}"); } //SetWord 400 match = Regex.Match(input, @"^setword\s?(\$?[0-9A-F]+)$", RegexOptions.IgnoreCase); if (match.Success) { var value = match.Groups[1].Value; var adr = Memory.BytePointer; var oldByte1 = Memory.GetByte(adr); var oldByte2 = Memory.GetByte(); var theWord = value.StartsWith("$") ? GetAddressHex(value, out var wordSuccess) : GetAddressDec(value, out wordSuccess); if (!wordSuccess) { return("Invalid word."); } Memory.SetWord(adr, theWord); success = true; var s = new StringBuilder(); var newByte1 = Memory.GetByte(adr); var adr2 = Memory.BytePointer; s.AppendLine($"{adr} {adr.ToHexString()}: {oldByte1:000} ${oldByte1:X2} --> {newByte1:000} ${newByte1:X2}"); var newByte2 = Memory.GetByte(); s.Append($"{adr2} {adr2.ToHexString()}: {oldByte2:000} ${oldByte2:X2} --> {newByte2:000} ${newByte2:X2}"); return(s.ToString()); } //SetWord 4096, 400 match = Regex.Match(input, @"^setword\s?(\$?[0-9A-F]+)\s?,\s?(\$?[0-9A-F]+)$", RegexOptions.IgnoreCase); if (match.Success) { var adrValue = match.Groups[1].Value; var adr = adrValue.StartsWith("$") ? GetAddressHex(adrValue, out var addressSuccess) : GetAddressDec(adrValue, out addressSuccess); if (!addressSuccess) { return("Invalid address."); } var value = match.Groups[2].Value; var oldByte1 = Memory.GetByte(adr); var oldByte2 = Memory.GetByte(); var theWord = value.StartsWith("$") ? GetWordHex(value, out var wordSuccess) : GetWordDec(value, out wordSuccess); if (!wordSuccess) { return("Invalid word."); } Memory.SetWord(adr, theWord); success = true; var s = new StringBuilder(); var newByte1 = Memory.GetByte(adr); var adr2 = Memory.BytePointer; s.AppendLine($"{adr} {adr.ToHexString()}: {oldByte1:000} ${oldByte1:X2} --> {newByte1:000} ${newByte1:X2}"); var newByte2 = Memory.GetByte(); s.Append($"{adr2} {adr2.ToHexString()}: {oldByte2:000} ${oldByte2:X2} --> {newByte2:000} ${newByte2:X2}"); return(s.ToString()); } //SetString $1000, "Hello!" match = Regex.Match(input, @"^setstring\s?(\$?[0-9A-F]+)\s?,\s?\""(.*)\""$", RegexOptions.IgnoreCase); if (match.Success) { try { var adrValue = match.Groups[1].Value; var adr = adrValue.StartsWith("$") ? GetAddressHex(adrValue, out var addressSuccess) : GetAddressDec(adrValue, out addressSuccess); if (!addressSuccess) { return("Invalid address."); } var value = match.Groups[2].Value; if (string.IsNullOrEmpty(value)) { return("Empty string."); } Memory.SetString(adr, Memory.CharacterSets[0], value); success = true; return("Ok."); } catch (SystemException ex) { success = false; return(ex.Message); } } //SetString "Hello!" match = Regex.Match(input, @"^setstring\s?\""(.*)\""$", RegexOptions.IgnoreCase); if (match.Success) { try { var value = match.Groups[1].Value; if (string.IsNullOrEmpty(value)) { return("Empty string."); } Memory.SetString(Memory.CharacterSets[0], value); success = true; return("Ok."); } catch (SystemException ex) { success = false; return(ex.Message); } } //GetString $1000, 5 match = Regex.Match(input, @"^getstring\s?(\$?[0-9A-F]+)\s?,\s?(\$?[0-9A-F]+)$", RegexOptions.IgnoreCase); if (match.Success) { try { var adrValue = match.Groups[1].Value; var adr = adrValue.StartsWith("$") ? GetAddressHex(adrValue, out var addressSuccess) : GetAddressDec(adrValue, out addressSuccess); if (!addressSuccess) { return("Invalid address."); } var lenValue = match.Groups[2].Value; var len = lenValue.StartsWith("$") ? GetWordHex(lenValue, out var lengthSuccess) : GetWordDec(lenValue, out lengthSuccess); if (!lengthSuccess) { return("Invalid length."); } var ret = Memory.GetString(adr, Memory.CharacterSets[0], len); success = true; return(ret); } catch (SystemException ex) { success = false; return(ex.Message); } } //GetString 5 match = Regex.Match(input, @"^getstring\s?(\$?[0-9A-F]+)$", RegexOptions.IgnoreCase); if (match.Success) { try { var lenValue = match.Groups[1].Value; var len = lenValue.StartsWith("$") ? GetWordHex(lenValue, out var lengthSuccess) : GetWordDec(lenValue, out lengthSuccess); if (!lengthSuccess) { return("Invalid length."); } var ret = Memory.GetString(Memory.CharacterSets[0], len); success = true; return(ret); } catch (SystemException ex) { success = false; return(ex.Message); } } //SetBits 110*01*1 match = Regex.Match(input, @"^setbits ([01\*][01\*][01\*][01\*][01\*][01\*][01\*][01\*])$"); if (match.Success) { var adr = Memory.GetBytePointer(); var oldByte = Memory.GetByte(adr); var change = match.Groups[1].Value; var args = new BitValue[8]; for (var i = 0; i < 8; i++) { args[i] = change.Substring(i, 1) == "0" ? BitValue.NotSet : change.Substring(i, 1) == "1" ? BitValue.Set : BitValue.Unchanged; } Memory.SetBits(adr, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]); var theByte = Memory.GetByte(adr); success = true; return($@"{adr:00000} ${adr:X4}: {new Types.Byte(oldByte)} --> {new Types.Byte(theByte)} {adr:00000} ${adr:X4}: {oldByte:000} ${oldByte:X2} --> {theByte:000} ${theByte:X2}"); } //GetBits match = Regex.Match(input, @"^getbits$"); if (match.Success) { var adr = Memory.GetBytePointer(); var b = new Types.Byte(Memory.GetByte()); success = true; return($"{adr:00000} ${adr:X4}: {b}"); } //M match = Regex.Match(input, @"^m$", RegexOptions.IgnoreCase); if (match.Success) { var s = new StringBuilder(); for (var i = 0; i < 16; i++) { s.AppendLine(Memory.Visualize()); } success = true; return(s.ToString()); } //M 4096 match = Regex.Match(input, @"^m\s?(\$?[0-9A-F]+)$", RegexOptions.IgnoreCase); if (match.Success) { var value = match.Groups[1].Value; var address = value.StartsWith("$") ? GetAddressHex(match.Groups[1].Value, out var addressSuccess) : GetAddressDec(match.Groups[1].Value, out addressSuccess); if (!addressSuccess) { return("Invalid address."); } var s = new StringBuilder(); s.AppendLine(Memory.Visualize(address)); for (var i = 0; i < 15; i++) { s.AppendLine(Memory.Visualize()); } success = true; return(s.ToString()); } //D match = Regex.Match(input, @"^d$", RegexOptions.IgnoreCase); if (match.Success) { var ret = Memory.GetDisassembly(16, true); success = true; return(ret); } //D 4096 match = Regex.Match(input, @"^d\s?(\$?[0-9A-F]+)$", RegexOptions.IgnoreCase); if (match.Success) { var value = match.Groups[1].Value; var address = value.StartsWith("$") ? GetAddressHex(value, out var addressSuccess) : GetAddressDec(value, out addressSuccess); if (!addressSuccess) { return("Invalid address."); } Memory.SetBytePointer(address); var ret = Memory.GetDisassembly(16, true); success = true; return(ret); } //GoTo 4096 match = Regex.Match(input, @"^goto\s?(\$?[0-9A-F]+)$", RegexOptions.IgnoreCase); if (match.Success) { var value = match.Groups[1].Value; var address = value.StartsWith("$") ? GetAddressHex(value, out var addressSuccess) : GetAddressDec(value, out addressSuccess); if (!addressSuccess) { return("Invalid address."); } Memory.SetBytePointer(address); return(""); } //Load "Filename" match = Regex.Match(input, @"^Load ""(.+)""$", RegexOptions.IgnoreCase); if (match.Success) { var filename = match.Groups[1].Value; try { Memory.Load(filename, out var startAddress, out var length); success = true; return($"{length} bytes loaded to {startAddress} (${startAddress:X})."); } catch (Exception) { return("Load failed."); } } //Save "Filename" match = Regex.Match(input, @"^Save ""(.+)""$", RegexOptions.IgnoreCase); if (match.Success) { var filename = match.Groups[1].Value; try { Memory.Save(filename, out var startAddress, out var length); success = true; return($"{length} bytes saved from {startAddress} (${startAddress:X})."); } catch (Exception) { return("Save failed."); } } match = Regex.Match(input, @"^Clear$", RegexOptions.IgnoreCase); if (match.Success) { Memory.Clear(); success = true; return("Memory cleared."); } return("Unknown command."); } catch (Exception) { success = false; return("Invalid argument."); } }
public OUTIMModel(BitValue value) { Value = value; }
public DPLSYModel() { FreqValue = DoubleWordValue.Null; PulseValue = DoubleWordValue.Null; OutputValue = BitValue.Null; }
public PLSNEXTModel() { OutputValue = BitValue.Null; }
public PLSFModel() { FreqValue = WordValue.Null; OutputValue = BitValue.Null; }
public PLSNEXTModel(BitValue _OutputValue) { OutputValue = _OutputValue; }
public DRVIModel() { FreqValue = WordValue.Null; PulseValue = WordValue.Null; OutputValue = BitValue.Null; }
private void SetBit(BitValue bit, bool value) { if (value) this.TSD = (byte)(this.TSD | (byte)bit); else this.TSD = (byte)(this.TSD & ~(byte)bit); }
private void SetBit(BitValue bit, bool value) { if (value) this.CONTROL = (byte)(this.CONTROL | (byte)bit); else this.CONTROL = (byte)(this.CONTROL & ~(byte)bit); }
internal void WriteBit(int offset, BitValue bit) { // Todo: this is completely broken. //unsafe { Keys[offset / 32] = Keys[offset / 32] ^ (~(int)bit << (offset % 32)); } }
public ZCPFModel(FloatValue _InputValue1, FloatValue _InputValue2, FloatValue _InputValue3, BitValue _OutputValue) { InputValue1 = _InputValue1; InputValue2 = _InputValue2; InputValue3 = _InputValue3; OutputValue = _OutputValue; }
public LDIMModel() { Value = BitValue.Null; }