Assignment 6
Assignment 6
LAB Assignment 6
Q1 Design NOT, NOR, NAND, XOR and XNOR gates using switch level
modeling.
Answer :
3.Nand gate
module Q1nand(out,a1,a2); //module for nand gate
input a1,a2;
output out;
supply1 vdd; //vdd supply for source of pmos
supply0 gnd; //gnd supply for source of nmos
wire w1;
pmos g1(out,vdd,a1); //pullup logic
pmos g2(out,vdd,a2); //pullup logic
2. Design NOT, NOR, NAND, XOR and XNOR gates using switch level
modeling with less number of transistor count than in conventional CMOS.
Answer : In this question we replaced all pmos transistor by Pull-up data-type and tried to
simulate all the logic gate
1.Not gate
module Q2not(out,in); //not gate using pull-up logic to reduce no of transistor
input in;
output out;
pullup (out); //pull-up logic
supply0 gnd; //ground supply for source of pmos
endmodule
endmodule
5.Xnor gate
module Q2xnor(out,a,b); //module of Xnor gate using pull-up
input a,b;
output out;
pullup (out); //pullup logic
supply0 gnd; //gnd supply for source of nmos
wire w1,w2;
nmos g1(out,w1,a); //pulldown logic
nmos g2(w1,gnd,~b); //pulldown logic
nmos g3(out,w2,~a); //pulldown logic
nmos g4(w2,gnd,b); //pulldown logic
endmodule
Instance 2 : In this experiment we implemented all the basic logic gates using switch level
modelling. Previously we use pmos as pull-up and nmos as pull-down but in this experiment
we replaced the pmos by pull-up type output, by doing this number of transistor is also
reduced.
nmos g1(out1,w1,~sel);
nmos g2(w1,gnd,a[0]);
nmos g3(out1,w2,sel);
nmos g4(w2,gnd,a[0]);
nmos g5(out,gnd,out1);
endmodule
nmos g1(out1,w2,~sel[1]);
nmos g2(w2,w1,~sel[0]);
nmos g3(w1,gnd,a[0]);
nmos g4(out1,w4,~sel[1]);
nmos g5(w4,w3,sel[0]);
nmos g6(w3,gnd,a[1]);
nmos g7(out1,w6,sel[1]);
nmos g8(w6,w5,~sel[0]);
nmos g9(w5,gnd,a[2]);
nmos g10(out1,w8,sel[1]);
nmos g11(w8,w7,sel[0]);
nmos g12(w7,gnd,a[3]);
nmos g13(out,gnd,out1);
endmodule
Instance 3: In this experiment we implemented two basic multiplexer using switch level
modelling. In above experiment we made output as pullup circuit. In this experiment we
learned that how we can realize the the basic multiplexer using transistors,also saw that
complexity and length of module is increased.
4. Design SRAM
(i) Without using strength in Verilog
(ii) Using strength in Verilog
Answer:
(i) Without using strength in Verilog
Figure 4.1 : block diagram of basic SRAM without using signal strength
bufif1 g1(w1,data_in,w_st);
bufif0 g2(w1,w2,w_st);
not g3(w3,w1);
not g4(w2,w3);
bufif1 g5(dataout,w2,read);
endmodule
endmodule
Instance 4: In this experiment we analysed the SRAM (static random access memory) with
or without using signal strength. We can simply observed that complexity of circuit is
reduced in SRAM using signal strength, less wire is used for bigger circuit. The reduction of
complexity can directly be observed in block diagram of figure 4.1 and 4.3 .
Exercise:
// Inputs
reg in;
// Outputs
wire out;
// Instantiate the Unit Under Test (UUT)
Ex_cap uut (.out(out), .in(in));
initial begin
// Initialize Inputs
#0 in = 0;
#1 in= 1'b1;
#1 in= 1'b1;
#1 in= 1'b1;
#1 in= 1'b0;
#1 in= 1'b0;
#1 in= 1'b0;
#1 in= 1'b0;
#1 in= 1'b0;
#1 in= 1'b1;
// Wait 100 ns for global reset to finish
#100;
end
endmodule
module adder(sum,carry,a,b,c); // 3bit adder made of switch level modelling for instantiation
input a,b,c;
output sum,carry;
wire w1,w2,w3,w4;
Q1xor b1(w1,a,b); //instantiating the switch level xor gate
Q1xor b2(sum,w1,c); //instantiating the switch level xor gate
andgate b3(w2,a,b); //instantiating the switch level and gate
andgate b4(w3,b,c); //instantiating the switch level and gate
andgate b5(w4,c,a); //instantiating the switch level and gate
orgate b6(carry,w2,w3,w4); //instantiating the switch level or gate
endmodule
module andgate(out,a,b); //module of and gate using switch level modelling for instantiation
input a,b;
output out;
wire w1;
wire out1;
supply0 gnd;
pullup (out1);
nmos g1(out1,w1,a);
nmos g2(w1,gnd,b);
nmos g3(out,gnd,out1);
endmodule
module orgate(out,a,b,c); //module of or gate using switch level modelling for instantiation
input a,b,c;
output out;
supply0 gnd;
pullup (out);
wire out1;
pullup (out1);
wire w1,w2;
nmos n1(out1,w1,a);
nmos n2(w1,w2,b);
nmos n3(w2,gnd,c);
nmos n4(out,gnd,out1);
endmodule
module Q1xor(out,a,b); //module of xor gate using switch level modelling for instantiation
input a,b;
output out;
supply1 vdd;
supply0 gnd;
wire w1,w4,w5;
pmos g1(w1,vdd,a);
pmos g2(w1,vdd,b);
pmos g3(out,w1,~a);
pmos g4(out,w1,~b);
nmos g5(out,w4,a);
nmos g6(w4,gnd,b);
nmos g7(out,w5,~a);
nmos g8(w5,gnd,~b);
endmodule
Instace of Exercise: In this Exercise we analysed a 4 bit full adder and a capacitor using
switch level modelling. All the module instantiated in full adder module is made of switch
level modelling. We simple can say that switch level modelling provide better realization of
logic cicuit at smaller level but as size of logic circuit increase it become tedious task to find
error of logic circuit. So that is the reason we basic logic gate to make design more flexible.