Beginning to add Program Counter and Stack Pointer
Beginning to add initil Instruction Set
This commit is contained in:
@@ -2,6 +2,26 @@ namespace CPUSimulation
|
||||
{
|
||||
public class Utils
|
||||
{
|
||||
|
||||
static Random _random = new Random();
|
||||
public static Word GenerateRandomWord(int byteCount)
|
||||
{
|
||||
byteCount = _random.Next(1, byteCount + 1);
|
||||
//Console.WriteLine($"Generating random word with {byteCount} bytes.");
|
||||
Byte[] bytes = new Byte[byteCount];
|
||||
for (int i = 0; i < byteCount; i++)
|
||||
{
|
||||
bytes[i] = GenerateRandomByte();
|
||||
}
|
||||
return new Word(bytes);
|
||||
}
|
||||
public static Byte GenerateRandomByte()
|
||||
{
|
||||
Bit[] bits = new Bit[8];
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
bits[i] = new Bit(_random.Next(2) == 1);
|
||||
}
|
||||
return new Byte(bits);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user