SlideShare a Scribd company logo
1 of 2
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

What's hot (6)

Arduino code
Arduino codeArduino code
Arduino code
 
VERILOG CODE
VERILOG CODEVERILOG CODE
VERILOG CODE
 
Task i
Task iTask i
Task i
 
CHAPTER 4
CHAPTER 4CHAPTER 4
CHAPTER 4
 
Kts c6-vhdl
Kts c6-vhdlKts c6-vhdl
Kts c6-vhdl
 
week-16x
week-16xweek-16x
week-16x
 

Recently uploaded

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Recently uploaded (20)

Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 

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