SlideShare a Scribd company logo
1 of 3
Name:- Sagar Roll No:- B-33 Reg No:- 11103500
module alu_8bit_sagar(x,y,ctrl,out);
input [7:0] x,y;
input [3:0] ctrl;
output [15:0]out;
reg [15:0]out;
always@(ctrl)
begin
if(ctrl==1'd0)
out=x*y;
else if(ctrl==1'd1)
out=x+y;
else if(ctrl==1'd2)
out=y-1;
else if(ctrl==1'd3)
out=x||y;
else if(ctrl==1'd4)
out=x&&y;
else if(ctrl==1'd5)
out=x>>1;
else if(ctrl==1'd6)
out=x<<1;
else if(ctrl==1'd7)
out=x^y;
else if(ctrl==1'd8)
out=x&y;
else if(ctrl==1'd9)
out=x|y;
else if(ctrl=='d10)
out=y>>1;
else if(ctrl==2'd11)
out=y<<1;
else if(ctrl==2'd12)
out=~x;
else if(ctrl==2'd13)
out=!x;
else if(ctrl==2'd14)
out=x-1;
else if(ctrl==2'd15)
out=x+1;
else
out = 'bx;
end
endmodule
Test Bench
module alu_8bit_sagartb_v;
// Inputs
reg [7:0] x;
reg [7:0] y;
reg [3:0] ctrl;
// Outputs
wire [15:0] out;
// Instantiate the Unit Under Test (UUT)
alu_8bit_sagar uut (
.x(x),
.y(y),
.ctrl(ctrl),
.out(out)
);
initial begin
// Initialize Inputs
x = 25;
y = 20;
ctrl = 0;
#2
repeat(16)
begin
#2
ctrl=ctrl+1;
end
#50 $stop;
// Wait 100 ns for global reset to finish
#100;
// Add stimulus here
end
endmodule
11103500 61599 sagar (1)

More Related Content

What's hot (20)

Basic python programs
Basic python programsBasic python programs
Basic python programs
 
Vcs9
Vcs9Vcs9
Vcs9
 
Bti1022 lab sheet 8
Bti1022 lab sheet 8Bti1022 lab sheet 8
Bti1022 lab sheet 8
 
Maple Code for Steepest Descent
Maple Code for Steepest DescentMaple Code for Steepest Descent
Maple Code for Steepest Descent
 
week-21x
week-21xweek-21x
week-21x
 
Project code for Project on Student information management system
Project code for Project on Student information management systemProject code for Project on Student information management system
Project code for Project on Student information management system
 
week-17x
week-17xweek-17x
week-17x
 
C workshop day 6
C workshop day 6C workshop day 6
C workshop day 6
 
COMPUTER GRAPHICS
COMPUTER GRAPHICSCOMPUTER GRAPHICS
COMPUTER GRAPHICS
 
Program to reflecta triangle
Program to reflecta triangleProgram to reflecta triangle
Program to reflecta triangle
 
Eso3 tablasestadisticas blog
Eso3 tablasestadisticas blogEso3 tablasestadisticas blog
Eso3 tablasestadisticas blog
 
Programa expresiones regulares
Programa expresiones regularesPrograma expresiones regulares
Programa expresiones regulares
 
[程式設計]Blackfriday
[程式設計]Blackfriday[程式設計]Blackfriday
[程式設計]Blackfriday
 
Proga 0601
Proga 0601Proga 0601
Proga 0601
 
Bcsl 033 data and file structures lab s1-4
Bcsl 033 data and file structures lab s1-4Bcsl 033 data and file structures lab s1-4
Bcsl 033 data and file structures lab s1-4
 
Line drawing algorithm
Line drawing algorithmLine drawing algorithm
Line drawing algorithm
 
C programs pbq final
C programs pbq finalC programs pbq final
C programs pbq final
 
Euler method in c
Euler method in cEuler method in c
Euler method in c
 
Informatica
InformaticaInformatica
Informatica
 
2D array
2D array2D array
2D array
 

Similar to 11103500 61599 sagar (1)

Graphics programs
Graphics programsGraphics programs
Graphics programsNAVYA RAO
 
Computer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsComputer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsKandarp Tiwari
 
Cg my own programs
Cg my own programsCg my own programs
Cg my own programsAmit Kapoor
 
import java.util.Scanner;public class Main {    public static in.pdf
import java.util.Scanner;public class Main {    public static in.pdfimport java.util.Scanner;public class Main {    public static in.pdf
import java.util.Scanner;public class Main {    public static in.pdfanwarsadath111
 
include ltiostreamgt include ltstringgt include .pdf
include ltiostreamgt include ltstringgt include .pdfinclude ltiostreamgt include ltstringgt include .pdf
include ltiostreamgt include ltstringgt include .pdfcontact32
 
Computer graphics lab assignment
Computer graphics lab assignmentComputer graphics lab assignment
Computer graphics lab assignmentAbdullah Al Shiam
 
ANS#include iostream int Rn_get(int low, int high); int cva.pdf
ANS#include iostream int Rn_get(int low, int high); int cva.pdfANS#include iostream int Rn_get(int low, int high); int cva.pdf
ANS#include iostream int Rn_get(int low, int high); int cva.pdfanikkothari1
 
Numerical Method Assignment
Numerical Method AssignmentNumerical Method Assignment
Numerical Method Assignmentashikul akash
 
implement the following funtions. myg1 and myg2 are seperate. x and .pdf
implement the following funtions. myg1 and myg2 are seperate. x and .pdfimplement the following funtions. myg1 and myg2 are seperate. x and .pdf
implement the following funtions. myg1 and myg2 are seperate. x and .pdfforladies
 
In Java using Eclipse, Im suppose to write a class that encapsulat.pdf
In Java using Eclipse, Im suppose to write a class that encapsulat.pdfIn Java using Eclipse, Im suppose to write a class that encapsulat.pdf
In Java using Eclipse, Im suppose to write a class that encapsulat.pdfanjandavid
 
square.cpp Open
 square.cpp Open square.cpp Open
square.cpp OpenMikeEly930
 
Better performance through Superscalarity
Better performance through SuperscalarityBetter performance through Superscalarity
Better performance through SuperscalarityMårten Rånge
 
VTU Network lab programs
VTU Network lab   programsVTU Network lab   programs
VTU Network lab programsAnanda Kumar HN
 
AI CHALLENGE ADMIN
AI CHALLENGE ADMINAI CHALLENGE ADMIN
AI CHALLENGE ADMINAnkit Gupta
 
Introduction to Computer Graphics using OpenGLCan someone tell me .pdf
Introduction to Computer Graphics using OpenGLCan someone tell me .pdfIntroduction to Computer Graphics using OpenGLCan someone tell me .pdf
Introduction to Computer Graphics using OpenGLCan someone tell me .pdffathimafancyjeweller
 

Similar to 11103500 61599 sagar (1) (20)

Graphics programs
Graphics programsGraphics programs
Graphics programs
 
Computer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsComputer Graphics Lab File C Programs
Computer Graphics Lab File C Programs
 
Cg my own programs
Cg my own programsCg my own programs
Cg my own programs
 
Graphics point clipping c program
Graphics point clipping c programGraphics point clipping c program
Graphics point clipping c program
 
import java.util.Scanner;public class Main {    public static in.pdf
import java.util.Scanner;public class Main {    public static in.pdfimport java.util.Scanner;public class Main {    public static in.pdf
import java.util.Scanner;public class Main {    public static in.pdf
 
include ltiostreamgt include ltstringgt include .pdf
include ltiostreamgt include ltstringgt include .pdfinclude ltiostreamgt include ltstringgt include .pdf
include ltiostreamgt include ltstringgt include .pdf
 
Computer graphics lab assignment
Computer graphics lab assignmentComputer graphics lab assignment
Computer graphics lab assignment
 
ANS#include iostream int Rn_get(int low, int high); int cva.pdf
ANS#include iostream int Rn_get(int low, int high); int cva.pdfANS#include iostream int Rn_get(int low, int high); int cva.pdf
ANS#include iostream int Rn_get(int low, int high); int cva.pdf
 
Numerical Method Assignment
Numerical Method AssignmentNumerical Method Assignment
Numerical Method Assignment
 
implement the following funtions. myg1 and myg2 are seperate. x and .pdf
implement the following funtions. myg1 and myg2 are seperate. x and .pdfimplement the following funtions. myg1 and myg2 are seperate. x and .pdf
implement the following funtions. myg1 and myg2 are seperate. x and .pdf
 
tetris
tetristetris
tetris
 
In Java using Eclipse, Im suppose to write a class that encapsulat.pdf
In Java using Eclipse, Im suppose to write a class that encapsulat.pdfIn Java using Eclipse, Im suppose to write a class that encapsulat.pdf
In Java using Eclipse, Im suppose to write a class that encapsulat.pdf
 
square.cpp Open
 square.cpp Open square.cpp Open
square.cpp Open
 
PRACTICAL COMPUTING
PRACTICAL COMPUTINGPRACTICAL COMPUTING
PRACTICAL COMPUTING
 
Vcs16
Vcs16Vcs16
Vcs16
 
Better performance through Superscalarity
Better performance through SuperscalarityBetter performance through Superscalarity
Better performance through Superscalarity
 
VTU Network lab programs
VTU Network lab   programsVTU Network lab   programs
VTU Network lab programs
 
AI CHALLENGE ADMIN
AI CHALLENGE ADMINAI CHALLENGE ADMIN
AI CHALLENGE ADMIN
 
Dvst
DvstDvst
Dvst
 
Introduction to Computer Graphics using OpenGLCan someone tell me .pdf
Introduction to Computer Graphics using OpenGLCan someone tell me .pdfIntroduction to Computer Graphics using OpenGLCan someone tell me .pdf
Introduction to Computer Graphics using OpenGLCan someone tell me .pdf
 

11103500 61599 sagar (1)

  • 1. Name:- Sagar Roll No:- B-33 Reg No:- 11103500 module alu_8bit_sagar(x,y,ctrl,out); input [7:0] x,y; input [3:0] ctrl; output [15:0]out; reg [15:0]out; always@(ctrl) begin if(ctrl==1'd0) out=x*y; else if(ctrl==1'd1) out=x+y; else if(ctrl==1'd2) out=y-1; else if(ctrl==1'd3) out=x||y; else if(ctrl==1'd4) out=x&&y; else if(ctrl==1'd5) out=x>>1; else if(ctrl==1'd6) out=x<<1; else if(ctrl==1'd7) out=x^y; else if(ctrl==1'd8) out=x&y; else if(ctrl==1'd9) out=x|y; else if(ctrl=='d10) out=y>>1; else if(ctrl==2'd11) out=y<<1; else if(ctrl==2'd12) out=~x; else if(ctrl==2'd13) out=!x; else if(ctrl==2'd14) out=x-1; else if(ctrl==2'd15) out=x+1; else out = 'bx; end endmodule
  • 2. Test Bench module alu_8bit_sagartb_v; // Inputs reg [7:0] x; reg [7:0] y; reg [3:0] ctrl; // Outputs wire [15:0] out; // Instantiate the Unit Under Test (UUT) alu_8bit_sagar uut ( .x(x), .y(y), .ctrl(ctrl), .out(out) ); initial begin // Initialize Inputs x = 25; y = 20; ctrl = 0; #2 repeat(16) begin #2 ctrl=ctrl+1; end #50 $stop; // Wait 100 ns for global reset to finish #100; // Add stimulus here end endmodule