Exemplo n.º 1
0
        private Bitfield ConcatenateAllInstructionsBitfields(ref List <List <Instruction> > instrSets)
        {
            var aggBitfield = new Bitfield(width: 0);

            for (var i = 0; i < instrSets.Count; i++)
            {
                instrSets[i].ForEach(instr => aggBitfield = aggBitfield.Concat(instr.BitfieldWrapper.ToAggregatedBitfield()));
            }

            return(aggBitfield);
        }
Exemplo n.º 2
0
        private Bitfield PadBitfieldToPacketSizeMultiple(Bitfield bitfield)
        {
            var packetBitLen = DeviceTable.Dev.UsbPacketByteLen * BitsPerByte;

            if (bitfield.BitWidth % packetBitLen == 0)
            {
                return(bitfield);
            }

            var packetSizeMultiple = bitfield.BitWidth;

            while (packetSizeMultiple % packetBitLen != 0)
            {
                packetSizeMultiple++;
            }
            var paddingBitfield = new Bitfield(width: packetSizeMultiple - bitfield.BitWidth);

            paddingBitfield.BitArray.SetAll(true);  // fill with 1's.
            bitfield = bitfield.Concat(paddingBitfield);

            return(bitfield);
        }
Exemplo n.º 3
0
        // Populate bitfield values (bitfield widths unchanged).
        private void AddDynamicData(ref List <List <Instruction> > instrSets)
        {
            var tempAggBitfield1 = new Bitfield(width: 0);

            // Populate each instructions's bit address relative to start of first path:
            for (var i = 0; i < instrSets.Count; i++)
            {
                var tempAggBitfield2 = new Bitfield(width: 0);

                foreach (var instr in instrSets[i])
                {
                    // Save instruction bit address:
                    instr.BitAddress            = tempAggBitfield1.BitWidth;
                    instr.CurrentPathBitAddress = tempAggBitfield2.BitWidth;

                    // Append instruction bitfield to aggregated bitfield:
                    tempAggBitfield1 = tempAggBitfield1.Concat(instr.BitfieldWrapper.ToAggregatedBitfield());    // aggBitfield value is incomplete/unused.
                    tempAggBitfield2 = tempAggBitfield2.Concat(instr.BitfieldWrapper.ToAggregatedBitfield());    // aggBitfield value is incomplete/unused.
                }
            }

            // Populate each goto instruction's target bit address relative to start of current path:
            for (var i = 0; i < instrSets.Count; i++)
            {
                foreach (var instr in instrSets[i])
                {
                    if (instr.Type == Instruction.InstrType.Goto)
                    {
                        var gotoTargetName = ((GotoInstruction)instr).TargetName;
                        var matchingHere   = instrSets[i].First(x => x.Type == Instruction.InstrType.Here && ((HereInstruction)x).Name == gotoTargetName);
                        // Set 'here' bit address relative to start of current path:
                        ((GotoBitfieldWrapper)((GotoInstruction)instr).BitfieldWrapper).TargetBitAddress.SetValue(matchingHere.CurrentPathBitAddress);
                    }
                }
            }
        }