1

Implement ALU/Register components

This commit is contained in:
2023-03-23 21:51:50 +01:00
commit 49d1871dfa
6 changed files with 183 additions and 0 deletions

20
ArithmeticUnit.sv Normal file
View File

@ -0,0 +1,20 @@
`default_nettype none
// Inst: MD OP
// 01 000 XXX
// OPs: 100 - ADD
// 101 - SUB
module ArithmeticUnit(
input var logic[2:0] opcode,
input var logic[7:0] operandA,
input var logic[7:0] operandB,
output var logic[7:0] result
);
// If the least significant opcode bit is 0, it is an addition
always_comb case (opcode)
3'b100: result = operandA + operandB;
3'b101: result = operandA - operandB;
default: result = 0;
endcase
endmodule