Documente Academic
Documente Profesional
Documente Cultură
HALF ADDER
Simulation
Inputs: a,b
Outputs: s,c
1
//HALF ADDER
Code:
// Verilog Module abc_lib.fa
// Created:
// by - student.UNKNOWN (ECE 12)
// at - 09:42:26 01/21/2009
// using Mentor Graphics HDL Designer(TM) 2005.1b (Build 76)
`resetall
`timescale 1ns/10ps
and(c,a,b);
endmodule//End Module
2
Program No: 2
2_4 DECODER
Simulation
Inputs: a,b,enable
Outputs: w,x,y,z
3
Program No:2
2_4 DECODER
Code:
// Verilog Module abc_lib.fa
// Created:
// by - student.UNKNOWN (ECE12)
// at - 09:42:26 01/21/2009
// using Mentor Graphics HDL Designer(TM) 2005.1b (Build 76)
`resetall
`timescale 1ns/10ps
and(w,w1,w2,enable);
and(x,w1,b,enable);
and(y,a,w2,enable);
and(z,a,b,enable);
endmodule//End Module
4
Program No: 3
MUX2_1(SWITCH LEVEL)
Simulation
Inputs: d,select
Outputs: q
5
Program No: 3
MUX2_1(SWITCH LEVEL)
Code:
// Verilog Module abc_lib.fa
// Created:
// by - student.UNKNOWN (ECE12)
// at - 09:42:26 01/21/2009
// using Mentor Graphics HDL Designer(TM) 2005.1b (Build 76)
`resetall
`timescale 1ns/10ps
input select;
wire w; //Internal nets
cmos c1(q,d[0],w,select);
cmos c2(q,d[1],select,w);
endmodule//End Module
6
Program No:4
FINITE STATE MACHINE
Simulation
Inputs: clk, reset,x
Outputs: outp
7
Program No:4
Code:
// Verilog Module abc_lib.fa
// Created:
// by - student.UNKNOWN (ECE12)
// at - 09:42:26 01/21/2009
// using Mentor Graphics HDL Designer(TM) 2005.1b (Build 76)
`resetall
`timescale 1ns/10ps
begin
if (reset)
begin
end
else
8
ps = ns;
end
always @(x)
begin
s1: begin
if (x==1'b1) ns = s2;
else ns = s3;
outp = 1'b1;
end
s2: begin
ns = s4; outp = 1'b1;
end
s3: begin
ns = s4; outp = 1'b0;
end
s4: begin
ns = s1; outp = 1'b0;
end
endcase
end
9
Program no 5
4:1 MUX
Simulation
Inputs: s, i
Outputs: y
10
Program No: 5
Code:
// Verilog Module abc_lib.fa
// Created:
// by - student.UNKNOWN (ECE12)
// at - 09:42:26 01/21/2009
// using Mentor Graphics HDL Designer(TM) 2005.1b (Build 76)
`resetall
`timescale 1ns/10ps
`resetall
`timescale 1ns/10ps
11
input s0,s1; //Inputs are declared
12
Program no 6
Full Adder
Simulation
Inputs: a,b,c
Outputs: ca,s
13
Program No: 6
Code:
// Verilog Module abc_lib.fa
// Created:
// by - student.UNKNOWN (ECE12)
// at - 10:22:40 01/21/2009
// using Mentor Graphics HDL Designer(TM) 2005.1b (Build 76)
`resetall
`timescale 1ns/10ps
module fulladder1(s,ca,a,b,c); //Declared parameter list for the full adder module
output s,ca; //Outputs are declared
input a,b,c; //Inputs are declared
wire y0,y1,y2;
xor(y0,a,b); //Pre-defined gates are used
and(y1,a,b);
and(y2,y0,c);
xor(s,y0,c);
xor(ca,y2,y1);
endmodule
Program no 7
4-bit Ripple Carry full adder
14
Simulation
Inputs: a,b,s cin
Outputs: cout
15
Program No: 7
Code:
//
// Verilog Module kk_tabish_lib.bit4_adder
//
// Created:
// by - student.UNKNOWN (ECE 12)
// at - 10:32:07 02/11/2009
// using Mentor Graphics HDL Designer(TM) 2005.3 (Build 75)
`resetall
`timescale 1ns/10ps
module adder4bit(a,b,cin,s,cout); //Declared parameter list for the 4-bit ripple Carry adder module
input [3:0]a; //Inputs are declared
input [3:0]b;
input cin;
output [3:0]s; //Outputs are declared
output cout;
wire w1,w2,w3; //Internal nets
fulladder1 f1(a[0],b[0],cin,s[0],w1); //Instantiate four 1-bit full adders
fulladder1 f2(a[1],b[1],w1,s[1],w2);
fulladder1 f3(a[2],b[2],w2,s[2],w3);
fulladder1 f4(a[3],b[3],w3,s[3],cout);
endmodule //End Module
16
Program no 8
JK flip flop
Simulation
Inputs: j,k,clk
Outputs: q
17
Program No: 8
J K Q*
0 0 Q
0 1 0
1 0 1
1 1 ~Q
Truth Table
Code:
// Verilog Module abc_lib.fa
// Created:
// by - student.UNKNOWN (ECE12)
// at - 09:54:16 02/18/2009
// using Mentor Graphics HDL Designer(TM) 2005.1b (Build 76)
`resetall
`timescale 1ns/10ps
module jk_ff (q,j,k,clk); //Declared parameter list for the JK flip flop module
input j,k,clk; //Inputs are declared
output q; //Outputs are declared
reg q; //Internal nets
always@(posedge clk) //Sensitivity list for changes to occur when clock changes.
begin
if (j==1'b0 && k==1'b1) //Conditional statement starts
q=1'b0;
else if(j==1'b1&&k==1'b0)
q=1'b1;
else if(j==1'b1&&k==1'b1)
q=~q;
else q=q;
end //If Ends
endmodule //End Module
18
Program no 9
SR flipflop
Simulation
Inputs: s,r,reset,clk
Outputs:q
19
Program No:9
20
S R Q*
0 0 Q
0 1 0
1 0 1
21
1 1 Undefined
22
Truth Table
Code:
// Verilog Module abc_lib.fa
// Created:
// by - student.UNKNOWN (ECE12)
// at - 10:15:25 02/18/2009
// using Mentor Graphics HDL Designer(TM) 2005.1b (Build 76)
`resetall
`timescale 1ns/10ps
module srff(s,r,clk,res,q); //Declared parameter list for the SR flip flop module
always@(negedge clk) //Sensitivity list for changes to occur when clock changes.
begin
q<=1'b0;
q=q;
q=0;
q=1;
else
q=1'bz;
23
endmodule //End Module
24
Program no 10
D flipflop
Simulation
Inputs: d,clk,reset
Outputs: q
25
Program No: 10
Reset Q*
0 D
1 0
Truth Table
Code:
// Verilog Module abc_lib.fa
// by - student.UNKNOWN (ECE12)
// at - 10:40:45 02/18/2009
// using Mentor Graphics HDL Designer(TM) 2005.1b (Build 76)
`resetall
`timescale 1ns/10ps
module Dflipflop (q,d,clk,reset); //Declared parameter list for the D flip flop module
output q; //Outputs are declared
input d,clk,reset; //Inputs are declared
reg q; //Internal nets
always@(posedge reset or negedge clk) //Sensitivity list for changes to occur when input changes.
if (reset) //Conditional statement starts
q<=1'b0;
else
q<=d;
endmodule //End Module
26
Program no 11
T flip-flop
Simulation
Inputs: clk,t
Outputs:q,qbar
27
Program No: 11
T Q*
0 Q
1 ~Q
Truth Table
Code:
//
// Verilog Module kk_tabish_lib.t_ff_dataflow
// Created:
// by - student.UNKNOWN (ECE12)
// at - 11:00:45 02/18/2009
// using Mentor Graphics HDL Designer(TM) 2005.3 (Build 75)
// ### Please start your Verilog code here ###
`resetall
`timescale 1ns/10ps
module t_flipflop_dataflow(t,clk,q,qbar,reset); //Declared parameter list for the T ff module
input t,clk,reset; //Inputs are declared
output q,qbar; //Outputs are declared
reg q;
always@(posedge reset or negedge clk)
if(reset)
q= 0;
else
q <= q^t;
assign qbar = ~q;
28