-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathALU.v
61 lines (56 loc) · 1.13 KB
/
ALU.v
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 13.07.2023 00:49:47
// Design Name:
// Module Name: ALU
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module ALU(
output reg[7:0]ALU_out,
output reg carry_out,
input [7:0]A,B,
input [2:0]opcode,
input clk,rst
);
wire [7:0]AND_out;
wire [7:0]OR_out;
wire [7:0]XOR_out;
wire [7:0]XNOR_out;
wire [7:0]NOR_out;
wire [7:0]NAND_out;
wire [7:0]FA_out;
wire carry;
wire [7:0]SUB_out;
always @(posedge clk or negedge rst)
begin
if(!rst)
begin
ALU_out <= 6'b000000;
carry_out <= 1'b0;
end
else
begin
case(opcode)
2'b00:ALU_out <= AND_out;
2'b01:begin
ALU_out <= FA_out;
carry_out <= carry;
end
2'b10:ALU_out <= MUL_out;
endcase
end
end
endmodule