Esempio n. 1
0
        public static Queue<ulong> GenerateLocality(ulong address, ulong addressSpaceSize, ulong distance, ulong numberOfAddresses)
        {
            Queue<ulong> queue = new Queue<ulong>();
            Random64 random = new Random64();
            ulong addressToAdd;
            ulong upperBound = (address + distance) < addressSpaceSize ? address + distance : addressSpaceSize;
            ulong lowerBound = (address - distance) > 0 ? address - distance : 0;

            queue.Enqueue(address);

            for (ulong i = 0; i < numberOfAddresses-1; i++)
            {
                if (i % 2 == 0)
                {

                    while((addressToAdd = random.Next(address, upperBound)) % 64 != 0){

                    }
                    queue.Enqueue(addressToAdd);
                }
                else
                {
                    while ((addressToAdd = random.Next(lowerBound, address)) % 64 != 0)
                    {

                    }
                    queue.Enqueue(addressToAdd);

                }
            }

            return queue;
        }
Esempio n. 2
0
 public static ulong GeneratorSixtyBitVirtualPhysicalPair()
 {
     Random64 random = new Random64();
     return random.Next(0xFFFFFFFFFFFFFFF - 1);
 }
        public static void GenerateInstructions(ulong AddressSpaceSize, ulong numberOfInstructions,
            uint loadFrequency,
            uint storeFrequency,
            uint testBranchFrequency,
            uint otherFrequency,
            uint numberOfOperands,
            String filename)
        {
            uint loadStart = 0;
            uint loadEnd = loadFrequency;
            uint storeStart = loadEnd + 1;
            uint storeEnd = storeStart + storeFrequency;
            uint testBranchStart = storeEnd + 1;
            uint testBranchEnd = testBranchStart + testBranchFrequency;
            uint otherStart = testBranchEnd + 1;
            uint otherEnd = otherStart + otherFrequency;

            ulong address;

            ulong value;
            ulong operandNumberForInstruction;

            ulong counter = 0;
            Random64 random = new Random64();

            //make sure that test and branch instructions have a destination address with 13th
            //bit set = 0
            //conversely when you generate operand address

            while (counter < numberOfInstructions)
            {
               /* while ((address = random.Next(0, AddressSpaceSize - 1)) % 64 != 0)
                    continue;*/

                address = random.Next(0, (AddressSpaceSize - 1)/64);
                address *= 64;

                if (address % 64 != 0)
                {
                    throw new Exception("Address is not 64 bit aligned");
                }

                operandNumberForInstruction = random.Next(1, numberOfOperands);

                value = random.Next(0, (ulong)(loadFrequency + storeFrequency + testBranchFrequency + otherFrequency));

                if (value >= loadStart && value <= loadEnd)
                {
                    FileWriter.WriteStringToFile(filename, "(0," + operandNumberForInstruction + "," + address + ")");
                }
                else if (value >= storeStart && value <= storeEnd)
                {
                    FileWriter.WriteStringToFile(filename, "(1," + operandNumberForInstruction + "," + address + ")");
                }
                else if (value >= testBranchStart && value <= testBranchEnd)
                {
                    address = address & 0xFFFFFFFFFFFFEFFF;
                    FileWriter.WriteStringToFile(filename, "(2," + operandNumberForInstruction + "," + address + ")");
                }
                else if (value >= otherStart && value <= otherEnd)
                {
                    FileWriter.WriteStringToFile(filename, "(3," + operandNumberForInstruction + "," + address + ")");
                }
                counter++;
            }
        }
Esempio n. 4
0
 public static ulong GenerateVirtualAddress(ulong virtualAddressSize)
 {
     Random64 random = new Random64();
     return random.Next(virtualAddressSize - 1);
 }