-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestALU.cpp
More file actions
30 lines (22 loc) · 838 Bytes
/
testALU.cpp
File metadata and controls
30 lines (22 loc) · 838 Bytes
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
#include "ALU.h"
#include <iostream>
int main() {
ALU alu;
uint32_t result = 0;
// Test ADD
alu.execute(ALU::AluOp::Add, 5, 7, result);
std::cout << "5 + 7 = " << result << " (expected 12)" << std::endl;
// Test SUB
alu.execute(ALU::AluOp::Sub, 10, 4, result);
std::cout << "10 - 4 = " << result << " (expected 6)" << std::endl;
// Test AND
alu.execute(ALU::AluOp::And, 0b1100, 0b1010, result);
std::cout << "1100 AND 1010 = " << result << " (expected 8)" << std::endl;
// Test OR
alu.execute(ALU::AluOp::Or, 0b1100, 0b1010, result);
std::cout << "1100 OR 1010 = " << result << " (expected 14)" << std::endl;
// Test Left Shift
alu.execute(ALU::AluOp::LeftShift, 1, 3, result);
std::cout << "1 << 3 = " << result << " (expected 8)" << std::endl;
return 0;
}