Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4 bit ALU #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions Project 2 – Combinational Logic/4 bit ALU
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
`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