From 134e729d5ba13f4b2e8b8af30d84db907f38cc7e Mon Sep 17 00:00:00 2001 From: rishijain01 <41798222+rishijain01@users.noreply.github.com> Date: Wed, 2 Oct 2019 12:50:04 +0530 Subject: [PATCH] Create 4 bit ALU --- .../4 bit ALU" | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 "Project 2 \342\200\223 Combinational Logic/4 bit ALU" diff --git "a/Project 2 \342\200\223 Combinational Logic/4 bit ALU" "b/Project 2 \342\200\223 Combinational Logic/4 bit ALU" new file mode 100644 index 0000000..bfcd453 --- /dev/null +++ "b/Project 2 \342\200\223 Combinational Logic/4 bit ALU" @@ -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 +