Add clock input to ALU/ConditionalUnit
This commit is contained in:
3
ALU.sv
3
ALU.sv
@ -9,6 +9,7 @@
|
|||||||
// 100 - ADD
|
// 100 - ADD
|
||||||
// 101 - SUB
|
// 101 - SUB
|
||||||
module ALU(
|
module ALU(
|
||||||
|
input var logic clock,
|
||||||
input var logic[2:0] opcode,
|
input var logic[2:0] opcode,
|
||||||
input var logic signed[7:0] operandA,
|
input var logic signed[7:0] operandA,
|
||||||
input var logic signed[7:0] operandB,
|
input var logic signed[7:0] operandB,
|
||||||
@ -37,7 +38,7 @@ module ALU(
|
|||||||
// "always @(opcode or operandA or operandB)"
|
// "always @(opcode or operandA or operandB)"
|
||||||
// This didn't work though, the result didn't update correctly.
|
// This didn't work though, the result didn't update correctly.
|
||||||
// TODO: Figure out why
|
// TODO: Figure out why
|
||||||
always @(lu_result or au_result) case (opcode)
|
always @(posedge clock) case (opcode)
|
||||||
3'b000,
|
3'b000,
|
||||||
3'b001,
|
3'b001,
|
||||||
3'b010,
|
3'b010,
|
||||||
|
@ -11,13 +11,14 @@
|
|||||||
// 110 - > 0
|
// 110 - > 0
|
||||||
// 111 - >= 0
|
// 111 - >= 0
|
||||||
module ConditionalUnit(
|
module ConditionalUnit(
|
||||||
|
input var logic clock,
|
||||||
input var logic[2:0] opcode,
|
input var logic[2:0] opcode,
|
||||||
input var logic signed[7:0] operand,
|
input var logic signed[7:0] operand,
|
||||||
output var logic result
|
output var logic result
|
||||||
);
|
);
|
||||||
|
|
||||||
// This could be simplified significantly (basically removed), if I had ALU flags.
|
// This could be simplified significantly (basically removed), if I had ALU flags.
|
||||||
always_comb case (opcode)
|
always @(posedge clock) case (opcode)
|
||||||
3'b000: result = 0;
|
3'b000: result = 0;
|
||||||
3'b001: result = (operand == 0);
|
3'b001: result = (operand == 0);
|
||||||
3'b010: result = (operand < 0);
|
3'b010: result = (operand < 0);
|
||||||
|
Reference in New Issue
Block a user