-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmultiplier_test.java
46 lines (42 loc) · 1.81 KB
/
multiplier_test.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package ComputerArchitecture;
/*
Jan Karl Galia
Comp. Architecture
HW 4: The Multiplier
*/
public class multiplier_test {
public static void main(String[] args) {
runTests();
}
public static void runTests() {
testMultiplier();
}
public static void testMultiplier() {
Longword otherInput = new Longword();
//Random BitArray Generator for Automatic testing---------------------------------------
Longword randomInput = new Longword();
Bit randomBit = new Bit();
Bit bitTrue = new Bit();
bitTrue.set(true);
boolean randomBool = false;
for (int i = 0; i < 32; i++) {//Creates Random binary string and sets it to randomInput bitArray
randomBool = randomBit.randomBool();
if (randomBool) {
randomInput.setBit(i, bitTrue);
}
}
for (int i = 0; i < 32; i++) {//Creates Random binary string and sets it to randomInput bitArray
randomBool = randomBit.randomBool();
if (randomBool) {
otherInput.setBit(i, bitTrue);
}
}
//--------------------------------------------------------------------------------------------
System.out.println("-------------------------------------------");
System.out.println("Generating Random Inputs Each Run");
System.out.println("TestFirstInput:" + randomInput.toStringConvert());
System.out.println("TestOtherInput:" + otherInput.toStringConvert());
System.out.println("TestLower32Half-BitsMultiplier:(1,0):" + multiplier.multiply(randomInput, otherInput).toStringConvert());
System.out.println("TestLower32Half-BitsMultiplier:(t,f):" + multiplier.multiply(randomInput, otherInput).toString());
}
}