Lab 1 Introduction To Verilog: Pinaki Ranjan Sarkar (SC13B110)
Lab 1 Introduction To Verilog: Pinaki Ranjan Sarkar (SC13B110)
Introduction to Verilog
Pinaki Ranjan Sarkar
(SC13B110)
Sub: VLSI Design
Date of Submission: February 4, 2015
Question 1:
Write a Verilog code for the basic gates and the universal gates and check the output.
Verilog Code:
module allgate(c,d,e,f,g,h,i,j,k,a,b);
input a,b;
output c,d,e,f,g,h;
assign c =a & b;
assign d =a | b;
assign e = ~a;
assign f= ~b;
assign g = a b;
assign h = a b;
assign i = ~(a & b);
assign k = ~(a | b);
endmodule
Output
Question 2:
Write a Verilog code for Full adder and check the output.
Verilog Code:
module adder(s,c,a,b,d);
input a,b,d;
output s,c;
assign s = a b d;
assign c = a b&dSa&b;
endmodule
Output
Question 3:
Write a Verilog code for Full Subtractor and check the output.
Verilog Code:
module subtractor (s,c,a,b,d);
input a,b,d;
output s,c;
assign s = a b d;
assign c = a&a dSb&d;
endmodule
Output
Question 4:
Write a Verilog code for converting Gray code to Binary and check the output.
Verilog Code:
module gtob(y,a);
input [0:3]a;
output [0:3]y;
assign y[0] = a[0];
assign y[1] = a 1 y 0;
assign y[2] = a 2 y 1;
assign y[3] = a 3 y 2;
endmodule;
Output
Observations:
For the Gates, The truth table of the gates:
Table 1: Truth table of OR-Gate
a b Y
0 0
0
0 1
1
1 0
1
1 0
1
Table 2: Truth
a
0
0
1
1
table of AND-Gate
b Y
0
0
1
0
0
0
0
1
Table 4: Truth
a
0
0
1
1
table of XOR-Gate
b Y
0
0
1
1
0
1
0
0
Table 5: Truth
a
0
0
1
1
table
b
0
1
0
0
of XNOR-Gate
Y
1
0
0
1
Observations:
The truth table of the Half Adder and Full Subtractor. And the Gray code to Binary conversion table.
Table 6: Truth
x y
0 0
0 0
0 1
0 1
1 0
1 0
1 1
1 1
table of
z
C
0
0
1
0
0
0
1
1
0
0
1
1
0
1
1
1
Full Adder
S
0
1
1
0
1
0
0
1