-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy path4 bit ALU
More file actions
66 lines (53 loc) · 1.12 KB
/
Copy path4 bit ALU
File metadata and controls
66 lines (53 loc) · 1.12 KB
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
62
63
64
65
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 06/14/2019 04:04:29 PM
// Design Name:
// Module Name: alu_checker
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
// Author : Rishi Jain
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module alu_checker(a,b,oper,opcode,s,z,p,out);
input [3:0] a;
input [3:0] b;
input oper;
input [1:0] opcode;
output s,z,p;
output reg [7:0] out;
always@(opcode or oper)
begin
if(oper==0)
begin
case(opcode)
2'b00 : out = a+b;
2'b01 : out = a-b;
2'b10 : out= a/b;
2'b11 : out= a*b ;
endcase
end
else if(oper==1)
begin
case(opcode)
2'b00 : out= a | b;
2'b01 : out = a&b;
2'b10 : out = a^b;
2'b11 : out = (~(a^b)) ;
endcase
end
end
assign s = out[7];
assign z = ~|(out);
assign p = ^(out);
endmodule