2023-02-11 14:43:53 +00:00
|
|
|
`include "alu_header.v"
|
2023-02-09 20:16:50 +00:00
|
|
|
|
2023-02-11 14:43:53 +00:00
|
|
|
module ALU(input [15:0]A,input [15:0]B, input oe,output reg [15:0]OUT,input [`ALU_OP_BITS-1:0]op);
|
|
|
|
reg C_FLAG;
|
|
|
|
|
|
|
|
always @ ( * ) begin
|
|
|
|
case (op)
|
|
|
|
`ALU_OP_ADD: {C_FLAG,OUT}=A+B;
|
|
|
|
`ALU_OP_SUB: {C_FLAG,OUT}=A-B;
|
|
|
|
`ALU_OP_AND: OUT=A&B;
|
|
|
|
`ALU_OP_OR: OUT=A|B;
|
|
|
|
`ALU_OP_XOR: OUT=A^B;
|
|
|
|
endcase
|
|
|
|
end
|
2023-02-09 20:16:50 +00:00
|
|
|
|
|
|
|
endmodule
|