Exp - No.1 Design and Implementation of Combinational Circuits
Exp - No.1 Design and Implementation of Combinational Circuits
Exp - No.1 Design and Implementation of Combinational Circuits
Experiment No: 1
Software Details:
For design Functional Simulation: ModelSim
For design Synthesis: Quartus II
For design Implementation: Quartus II
Hardware Details:
Family: Cyclone II
Device: EP2C
Package: FBGA
Pin count: 484
Date: 7-8-2012
Reg No: 12mvd0031
output y;
wire y;
and(y,a,b);
endmodule
Experiment No: 1
Date: 7-8-2012
Reg No: 12mvd0031
OR GATE:
Data Flow Modeling:
module orgate(a,b,y);
input a,b;
output y;
wire y;
assign y=a|b;
endmodule
Structural Modeling:
module orgate(a,b,y);
input a,b;
output y;
wire y;
or(y,a,b);
endmodule
Test Bench for OR gate:
module or_gate_tst();
reg a,b;
wire y;
Experiment No: 1
Date: 7-8-2012
Reg No: 12mvd0031
orgate a1(a,b,y);
initial
begin
a=1'b0;
b=1'b0;
#100;
a=1'b0;
b=1'b1;
#100;
a=1'b1;
b=1'b0;
#100;
a=1'b1;
b=1'b1;
end
endmodule
Experiment No: 1
Date: 7-8-2012
Reg No: 12mvd0031
NOT GATE:
Data Flow Modeling
module notgate(a,y);
input a;
output y;
wire y;
assign y=(~a);
endmodule
Structural Modeling:
module notgate(a,y);
input a;
output y;
wire y;
not(y,a);
endmodule
Test Bench for NOT gate:
module notgate_tst();
reg a;
wire y;
notgate a1(a,y);
initial
begin
a=1'b0;
#100;
a=1'b1;
end
endmodule
Experiment No: 1
Date: 7-8-2012
Reg No: 12mvd0031
XOR GATE:
Data Flow Modeling
module xorgate(a,b,y);
input a,b;
output y;
wire y;
assign y=(a^b);
endmodule
Structural Modeling:
module xorgate(a,b,y);
input a,b;
output y;
wire y;
xor(y,a,b);
endmodule
Experiment No: 1
Date: 7-8-2012
Reg No: 12mvd0031
Experiment No: 1
Date: 7-8-2012
Reg No: 12mvd0031
Experiment No: 1
Date: 7-8-2012
Reg No: 12mvd0031
NOR GATE:
Data Flow Modeling:
module norgate(a,b,y);
input a,b;
output y;
wire y;
assign y=~(a|b);
endmodule
Structural Modeling:
module norgate(a,b,y);
input a,b;
output y;
wire y;
nor(y,a,b);
endmodule
Experiment No: 1
Date: 7-8-2012
Reg No: 12mvd0031
reg a,b;
wire y;
norgate a1(a,b,y);
initial
begin
a=1'b0;
b=1'b0;
#100;
a=1'b0;
b=1'b1;
#100;
a=1'b1;
b=1'b0;
#100;
a=1'b1;
b=1'b1;
end
endmodule
Experiment No: 1
Date: 7-8-2012
Reg No: 12mvd0031
XNOR GATE:
Data Flow Modeling:
module xnorgate(a,b,y);
input a,b;
output y;
wire y;
assign y=~(a^b);
endmodule
Structural Modeling:
module xnorgate(a,b,y);
input a,b;
output y;
wire y;
xnor(y,a,b);
endmodule
Test Bench for XNOR gate:
module xnorgate_tst();
reg a,b;
Experiment No: 1
Date: 7-8-2012
Reg No: 12mvd0031
wire y;
xnorgate a1(a,b,y);
initial
begin
a=1'b0;
b=1'b0;
#100;
a=1'b0;
b=1'b1;
#100;
a=1'b1;
b=1'b0;
#100;
a=1'b1;
b=1'b1;
end
endmodule
Experiment No: 1
Date: 7-8-2012
Reg No: 12mvd0031
Experiment No: 1
Date: 7-8-2012
Reg No: 12mvd0031
endmodule
Full-Adder:
Structural Modeling:
module fulladdr(a,b,ci,s,c);
input a,b,ci;
output s,c;
wire w,s,c;
xor (w,a,b);
xor (s,w,ci);
and (c,w,ci);
endmodule
Data flow modeling:
module fulladder(a,b,ci,s,c);
input a,b,ci;
output s,c;
Experiment No: 1
Date: 7-8-2012
Reg No: 12mvd0031
wire s,c;
assign s=a^b^ci;
assign c=((a&b)|(b&ci)|(ci&a));
endmodule
Test Bench for Full Adder :
module fo_tst();
reg a,b,ci;
wire s,c;
fulladder fa (a,b,ci,s,c);
initial
begin
a=1'b0;
b=1'b0;
ci=1'b0;
#100;
a=1'b0;
b=1'b0;
ci=1'b1;
#100;
a=1'b0;
b=1'b1;
ci=1'b0;
#100;
a=1'b0;
b=1'b1;
ci=1'b1;
#100;
a=1'b1;
b=1'b0;
ci=1'b0;
#100;
a=1'b1;
b=1'b0;
ci=1'b1;
#100;
a=1'b1;
b=1'b1;
ci=1'b0;
#100;
a=1'b1;
b=1'b1;
ci=1'b1;
end
endmodule
Experiment No: 1
Date: 7-8-2012
Reg No: 12mvd0031
Experiment No: 1
Dataflow Modeling:
module halfsubtractor(a,b,d,c);
input a,b;
output d,c;
Date: 7-8-2012
Reg No: 12mvd0031
Experiment No: 1
wire d,c;
assign d=a^b;
assign c=(~a)&b;
endmodule
Test Bench for Half Subtractor:
module hs_tst();
reg a,b;
wire d,c;
halfsubtractor hs (a,b,d,c);
initial
begin
a=1'b0;
b=1'b0;
#100;
a=1'b0;
b=1'b1;
#100;
a=1'b1;
b=1'b0;
#100;
a=1'b1;
b=1'b1;
end
endmodule
Date: 7-8-2012
Reg No: 12mvd0031
Full-Subtractor:
Structural modeling:
module fullsubtrac(a,b,c,d,b0);
input a,b,c;
output d,b0;
wire d,b0,w1,w2,w3,w4,w5;
xor(w1,a,b);
xor(d,w1,c);
not(w2,a);
not(w3,w1);
and(w4,w2,c);
and(w5,w3,c);
or(b0,w5,w4);
endmodule
Dataflow modeling:
module fullsubtrac(a,b,c,d,b0);
input a,b,c;
output d,b0;
assign d=a^b^c;
assign b0=(~a&b)|(~a&c)|(b&c);
endmodule
Experiment No: 1
Date: 7-8-2012
Reg No: 12mvd0031
Experiment No: 1
Date: 7-8-2012
Reg No: 12mvd0031
Experiment No: 1
Date: 7-8-2012
Reg No: 12mvd0031
#100;
a=1'b0;b=1'b1;
#100;
a=1'b1;b=1'b1;
end
endmodule
Experiment No: 1
Date: 7-8-2012
Reg No: 12mvd0031
ENCODER:
Structural modeling of encoder:
module encoder (x,y,z,d);
input [7:0] d;
output x,y,z;
wire x,y,z;
or(x,d[4]|d[5]|d[6]|d[7]);
or(y,d[2]|d[3]|d[6]|d[7]);
or(z,d[1]|d[3]|d[5]|d[7]);
endmodule
Dataflow modelling of encoder:
module encoder(x,y,z,d);
input [7:0]d;
output x,y,z;
wire x,y,z;
assign x=d[4]|d[5]|d[6]|d[7];
assign y=d[2]|d[3]|d[6]|d[7];
assign z=d[1]|d[3]|d[5]|d[7];
endmodule
Test Bench for encoder:
Experiment No: 1
Date: 7-8-2012
Reg No: 12mvd0031
Experiment No: 1
module enc_tst();
reg [7:0]d;
wire x,y,z;
encoder p(x,y,z,d);
initial
begin
d[0]=1'b1;d[1]=1'b0;d[2]=1'b0;d[3]=1'b0;d[4]=1'b0;d[5]=1'b0;d[6]=1'b0;d[7]=1'b0;
#20;
d[0]=0'b1;d[1]=1'b1;d[2]=1'b0;d[3]=1'b0;d[4]=1'b0;d[5]=1'b0;d[6]=1'b0;d[7]=1'b0;
#20;
d[0]=1'b0;d[1]=1'b0;d[2]=1'b1;d[3]=1'b0;d[4]=1'b0;d[5]=1'b0;d[6]=1'b0;d[7]=1'b0;
#20;
d[0]=1'b0;d[1]=1'b0;d[2]=1'b0;d[3]=1'b1;d[4]=1'b0;d[5]=1'b0;d[6]=1'b0;d[7]=1'b0;
#20;
d[0]=1'b0;d[1]=1'b0;d[2]=1'b0;d[3]=1'b0;d[4]=1'b1;d[5]=1'b0;d[6]=1'b0;d[7]=1'b0;
#20;
d[0]=1'b0;d[1]=1'b0;d[2]=1'b0;d[3]=1'b0;d[4]=1'b0;d[5]=1'b1;d[6]=1'b0;d[7]=1'b0;
#20;
d[0]=1'b0;d[1]=1'b0;d[2]=1'b0;d[3]=1'b0;d[4]=1'b0;d[5]=1'b0;d[6]=1'b1;d[7]=1'b0;
#20;
d[0]=1'b0;d[1]=1'b0;d[2]=1'b0;d[3]=1'b0;d[4]=1'b0;d[5]=1'b0;d[6]=1'b0;d[7]=1'b1;
end
endmodule
Date: 7-8-2012
Reg No: 12mvd0031
Experiment No: 1
Functional Verification:
Date: 7-8-2012
Reg No: 12mvd0031
Experiment No: 1
input a,b,c,d;
output w,x,y,z;
wire w,x,y,z;
assign w=a;
assign x=a^b;
assign y=c^b;
assign z=c^d;
endmodule
Date: 7-8-2012
Reg No: 12mvd0031
Experiment No: 1
Date: 7-8-2012
Reg No: 12mvd0031
endmodule
Structural modeling of grey to binary:
module gb(a,b,c,d,w,x,y,z);
input a,b,c,d;
output w,x,y,z;
wire w,x,y,z;
or (w,a);
xor (x,w,b);
xor (y,x,c);
xor (z,y,d);
endmodule
Test Bench of grey to binary:
module gb_tst();
reg a,b,c,d;
wire w,x,y,z;
gb b1(a,b,c,d,w,x,y,z);
initial
begin
a=1'b0;b=1'b0;c=1'b1;d=1'b0;
#50;
a=1'b0;b=1'b0;c=1'b0;d=1'b0;
#50;
a=1'b0;b=1'b1;c=1'b1;d=1'b0;
end
endmodule
Functional simulation of grey to binary:
Experiment No: 1
Date: 7-8-2012
Reg No: 12mvd0031
Parity Generator:
Structural modeling of parity generator:
module pgen(x,y,z,p);
input x,y,z;
output p;
wire p,w1,w2;
xor(w1,x,y);
xor(w2,w1,z);
not (p,w2);
endmodule
Experiment No: 1
Date: 7-8-2012
Reg No: 12mvd0031
output y;
wire y;
assign y=a^(b^c);
endmodule
Experiment No: 1
Date: 7-8-2012
Reg No: 12mvd0031
#50;
a=1'b1;b=1'b0;c=1'b1;
end
endmodule
Experiment No: 1
Date: 7-8-2012
Reg No: 12mvd0031
Experiment No: 1
Date: 7-8-2012
Reg No: 12mvd0031
Experiment No: 1
Date: 7-8-2012
Reg No: 12mvd0031
Multiplexer:
Experiment No: 1
Date: 7-8-2012
Reg No: 12mvd0031
Experiment No: 1
Date: 7-8-2012
Reg No: 12mvd0031
Experiment No: 1
wire y,w1,w2,w3,w4;
mux4_1 mo(s1,s0,a,b,c,d,y);
initial
begin
a=1'b1;b=1'b1;c=1'b0;d=1'b1;s1=1'b0;s0=1'b0;
#100;
a=1'b1;b=1'b1;c=1'b1;d=1'b0;
s1=1'b0;s0=1'b1;
#100;
a=1'b1;b=1'b1;c=1'b1;d=1'b0;
s1=1'b1;s0=1'b0;
#100;
a=1'b1;b=1'b1;c=1'b1;d=1'b0;
s1=1'b1;s0=1'b1;
end
endmodule
Date: 7-8-2012
Reg No: 12mvd0031
Experiment No: 1