SlideShare a Scribd company logo
Arithmetic Logic Unit
Main Module Test Bench
module ALU(op1,op2,out,opt,enb);
input enb;
input [3:0] op1;
input [3:0] op2;
input[3:0]opt;
output [3:0] out;
reg [3:0] out;
always@(op1 or op2 or opt or enb) begin
if(enb == 1) begin
case(opt)
4'b0000: out = (op1+op2);
4'b0001: out = (op1*op2);
4'b0011: out = (op1-op2);
4'b0010: out = (op1/op2);
endcase
end
end
endmodule
module test_Alu;
reg enb;
reg [3:0] op1;
reg [3:0] op2;
reg [3:0]opt;
wire [3:0] out;
ALU g1(op1,op2,out,opt,enb);
initial begin
enb = 1'b1;
op1 = 4'b0100;
op2 = 4'b0010;
opt = 4'b0000;
#100
enb = 1'b1;
op1 = 4'b0100;
op2 = 4'b0010;
opt = 4'b0001;
#100
enb = 1'b1;
op1 = 4'b0100;
op2 = 4'b0010;
opt = 4'b0010;
#100
enb = 1'b1;
op1 = 4'b0100;
op2 = 4'b0010;
opt = 4'b0011;
#100
enb = 1'b0;
op1 = 4'b0100;
op2 = 4'b0010;
opt = 4'b0000;
#100
enb = 1'b0;
op1 = 4'b0100;
op2 = 4'b0010;
opt = 4'b0001;
#100
enb = 1'b0;
op1 = 4'b0100;
op2 = 4'b0010;
opt = 4'b0010;
#100
enb = 1'b0;
op1 = 4'b0100;
op2 = 4'b0010;
opt = 4'b0011;
end
endmodule
Output

More Related Content

PPT
PPT
Function in cpu 2
PDF
0.my book draft chap 1
PPT
Interesting facts on c
DOCX
PPTX
CSE240 Pointers
PDF
Appsec obfuscator reloaded
PDF
Space Time Varying Color Palettes
Function in cpu 2
0.my book draft chap 1
Interesting facts on c
CSE240 Pointers
Appsec obfuscator reloaded
Space Time Varying Color Palettes

What's hot (6)

TXT
Arduino code
DOCX
VERILOG CODE
PDF
Task i
PPTX
CHAPTER 4
PPT
Kts c6-vhdl
Arduino code
VERILOG CODE
Task i
CHAPTER 4
Kts c6-vhdl
Ad

Similar to Arithmetic logic unit Assembly Language Code (20)

PDF
VLSI Final Design Project
PPTX
DOC
Alu design-project
DOCX
32 bit ALU Chip Design using IBM 130nm process technology
PDF
Project single cyclemips processor_verilog
PDF
8 bit single cycle processor
DOCX
Alu all shift register
PDF
A0220105
PDF
3. Single Cycle Data Path in computer architecture
PPTX
Design of Alu in computer architecture.pptx
PDF
2. ALU and MIPS Arcitecture introduction.pdf
PPTX
Moduleeyshgsnshneyehnhneyjhnynhneh3dgcfhhgg
PPTX
Very high speed HDL Presentation FOR KIET.pptx
PDF
- Problem Design a simple ALU using VHDL capable of performing the o.pdf
DOCX
Vend with ff
PPTX
PROCESSOR AND CONTROL UNIT - unit 3 Architecture
PDF
Vlsi lab manual exp:1
PPSX
Dsp Datapath
PDF
Ecad &vlsi lab 18
PPT
W9: Laboratory 2
VLSI Final Design Project
Alu design-project
32 bit ALU Chip Design using IBM 130nm process technology
Project single cyclemips processor_verilog
8 bit single cycle processor
Alu all shift register
A0220105
3. Single Cycle Data Path in computer architecture
Design of Alu in computer architecture.pptx
2. ALU and MIPS Arcitecture introduction.pdf
Moduleeyshgsnshneyehnhneyjhnynhneh3dgcfhhgg
Very high speed HDL Presentation FOR KIET.pptx
- Problem Design a simple ALU using VHDL capable of performing the o.pdf
Vend with ff
PROCESSOR AND CONTROL UNIT - unit 3 Architecture
Vlsi lab manual exp:1
Dsp Datapath
Ecad &vlsi lab 18
W9: Laboratory 2
Ad

Recently uploaded (20)

PDF
Classroom Observation Tools for Teachers
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
GDM (1) (1).pptx small presentation for students
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
master seminar digital applications in india
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
RMMM.pdf make it easy to upload and study
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PPTX
Pharma ospi slides which help in ospi learning
PPTX
Institutional Correction lecture only . . .
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
Cell Types and Its function , kingdom of life
PDF
01-Introduction-to-Information-Management.pdf
PDF
Insiders guide to clinical Medicine.pdf
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Classroom Observation Tools for Teachers
Final Presentation General Medicine 03-08-2024.pptx
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
GDM (1) (1).pptx small presentation for students
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
master seminar digital applications in india
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
human mycosis Human fungal infections are called human mycosis..pptx
Pharmacology of Heart Failure /Pharmacotherapy of CHF
102 student loan defaulters named and shamed – Is someone you know on the list?
RMMM.pdf make it easy to upload and study
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
Pharma ospi slides which help in ospi learning
Institutional Correction lecture only . . .
Module 4: Burden of Disease Tutorial Slides S2 2025
Cell Types and Its function , kingdom of life
01-Introduction-to-Information-Management.pdf
Insiders guide to clinical Medicine.pdf
school management -TNTEU- B.Ed., Semester II Unit 1.pptx

Arithmetic logic unit Assembly Language Code

  • 1. Arithmetic Logic Unit Main Module Test Bench module ALU(op1,op2,out,opt,enb); input enb; input [3:0] op1; input [3:0] op2; input[3:0]opt; output [3:0] out; reg [3:0] out; always@(op1 or op2 or opt or enb) begin if(enb == 1) begin case(opt) 4'b0000: out = (op1+op2); 4'b0001: out = (op1*op2); 4'b0011: out = (op1-op2); 4'b0010: out = (op1/op2); endcase end end endmodule module test_Alu; reg enb; reg [3:0] op1; reg [3:0] op2; reg [3:0]opt; wire [3:0] out; ALU g1(op1,op2,out,opt,enb); initial begin enb = 1'b1; op1 = 4'b0100; op2 = 4'b0010; opt = 4'b0000; #100 enb = 1'b1; op1 = 4'b0100; op2 = 4'b0010; opt = 4'b0001; #100 enb = 1'b1; op1 = 4'b0100; op2 = 4'b0010; opt = 4'b0010; #100 enb = 1'b1; op1 = 4'b0100; op2 = 4'b0010; opt = 4'b0011; #100 enb = 1'b0; op1 = 4'b0100; op2 = 4'b0010; opt = 4'b0000; #100 enb = 1'b0; op1 = 4'b0100; op2 = 4'b0010; opt = 4'b0001; #100 enb = 1'b0; op1 = 4'b0100;
  • 2. op2 = 4'b0010; opt = 4'b0010; #100 enb = 1'b0; op1 = 4'b0100; op2 = 4'b0010; opt = 4'b0011; end endmodule Output