My set less than was behavioral which is a no no

# Conflicts:
#	lab2CA.srcs/sources_1/new/ALU.v
This commit is contained in:
Johannes
2019-03-12 21:30:00 -04:00
2 changed files with 38 additions and 7 deletions

View File

@@ -48,16 +48,19 @@ module ALU(
shift_right_arithmetic sra( shift_right_arithmetic sra(
.A(operand0), .A(operand0),
.B(result_H)); .B(result_H));
// I (1000) // I (1000) - NOT
not_9bit not0( not_9bit not0(
.A(operand0), .A(operand0),
.B(result_I)); .B(result_I));
// J (1001) // J (1001) - Less Than
slt slt0( less_than less0(
.inA(operand0), .A(operand0),
.inB(operand1), .B(operand1),
.outA(result)); .C(result_J));
// K (1010) // K (1010) - Zero
zero zero0(
.A(operand0),
.B(result_K));
// L (1011) // L (1011)
// M (1100) // M (1100)
// N (1101) // N (1101)

View File

@@ -314,6 +314,22 @@ module gen_clock();
end end
endmodule endmodule
module less_than(
input wire [8:0] A,B,
output wire [8:0] C);
wire [8:0] D;
sub_9bit sub0(
.A(A),
.B(B),
.C(D));
assign C = {8'b00000000,D[8]};
// 1 if A is less than B
// 0 if B is greater than or equal to A
endmodule
module mux_2_1( module mux_2_1(
input wire switch, input wire switch,
input wire [8:0] A,B, input wire [8:0] A,B,
@@ -1076,3 +1092,15 @@ module twos_compliment_tb();
end end
endmodule endmodule
module zero(
input wire [8:0] A,
output reg [8:0] B);
always @(A) begin
if(A == 9'b000000000)
B = 9'b000000001; // 1 if A is zero
else
B = 9'b000000000; // 0 if A is non-zero
end
endmodule