11103500 61599 sagar (1)

4
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)

Transcript of 11103500 61599 sagar (1)

Page 1: 11103500 61599 sagar (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)beginif(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;elseout = 'bx;endendmodule

Page 2: 11103500 61599 sagar (1)

Test Benchmodule alu_8bit_sagartb_v;

// Inputsreg [7:0] x;reg [7:0] y;reg [3:0] ctrl;

// Outputswire [15:0] out;

// Instantiate the Unit Under Test (UUT)alu_8bit_sagar uut (

.x(x),

.y(y),

.ctrl(ctrl),

.out(out));

initial begin// Initialize Inputsx = 25;y = 20;ctrl = 0;#2repeat(16)begin#2ctrl=ctrl+1;end

#50 $stop;

// Wait 100 ns for global reset to finish#100;

// Add stimulus here

end endmodule

Page 3: 11103500 61599 sagar (1)