Thursday 24 March 2022

Verilog Code for 4 bit - Memory Unit


4 Bit - Memory Unit

module memory(RW, Datain, Dataout, CE, Address)

input CE, RW;

input [7:0] Address;

input [3:0] Datain;

Output [3:0] Dataout;

reg [3:0] Dataout;

reg [3:0] mem[127:0];

always @(CE or RW or Datain or Dataout or Address)

if(CE)

begin

if(RW)

Dataout = Mem[Address];

else

Mem[Address] = Datain;

else

Dataout = 4'bz;

end

endmodule



Verilog Code for 8-Bit Ripple Carry Adder

 

Full adder

module fulladder(a,b,cin,s,cout);

input a, b, cin;

output s, cout;

wire x,y,z;

xor g1(x,a,b);

and g2(y,a,b);

and g3(z, x,cin);

xor g4(s, x,cin);

or g5(cout, y, z);

endmodule


8-bit Ripple carry adder using Full adder

module ripplecarryadder(a,b,c,sum,cout);

input [7:0]a,b;

input cin;

output reg [7:0]sum;

output cout;

wire [6:0]c;

fulladder f1(a[0],b[0],cin,sum[0],c[0]);

fulladder f2(a[1],b[1],c[0],sum[1],c[1]);

fulladder f3(a[2],b[2],c[1],sum[2],c[2]);

fulladder f4(a[3],b[3],c[2],sum[3],c[3]);

fulladder f1(a[4],b[4],c[3],sum[4],c[4]);

fulladder f2(a[5],b[5],c[4],sum[5],c[5]);

fulladder f3(a[6],b[6],c[5],sum[6],c[6]);

fulladder f4(a[7],b[7],c[6],sum[7],cout);

endmodule

Verilog code for Arithmetic and Logic Unit

 

Behavioral Level Modelling

module alu(s,a,b,f);

input[2:0]s;

input[3:0]a,b;

output[3:0]f;

reg[3:0]f;

always@(s or a or b)

begin

case(s)

3'b000:f<=4'b0000;

3'b001:f<=a-b;

3'b010:f<=a+b;

3'b011:f<=b-a;

3'b100:f<=a&b;

3'b101:f<=a|b;

3'b110:f<=~a;

default:f<=4'b1111;

endcase

end

endmodule

Quantitative Aptitude Book - 3

Quantitative Aptitude Book - 3 

Quantitative Aptitude Book - 2

Quantitative Aptitude Book - 2 

Aptitude - Ages

Aptitude - Ages 

Quantitative Aptitude Book - 1

Quantitative Aptitude Book

Aptitude - Simple Interest

Aptitude - Simple Interest 

Aptitude - Number System

 Aptitude - Number System

Aptitude - Number Series

Aptitude - Number Series 

Aptitude - Averages

 Aptitude - Averages

Verilog Code for Universal Shift Register

  Universal Shift Register module universalshift (clr,clk,sel,in,out); input clr,clk; input [1:0]sel; input [3:0]parin; output reg[3:0]out; ...