Vlsi HDL Programmes
Vlsi HDL Programmes
Vlsi HDL Programmes
input Clock;
input Reset;
output [3:0] Count;
Counter_tb:
`timescale 1ns / 1ps
module counter_tb;
// Inputs
reg Clock;
reg Reset;
// Outputs
wire [3:0] Count;
initial begin
// Initialize Inputs
Clock = 0;
Reset = 0;
#30 Reset = 1;
#40 Reset = 0;
#450 Reset = 1;
#480 Reset = 0;
end
endmodule
D-FF:
`timescale 1ns / 1ps
module dff(d,clk,reset,q);
input d;
input clk;
input reset;
output q;
// output qbar;
reg q;
// reg qbar;
always @(posedge reset or negedge clk)
begin
if (reset)
q <= 0'b0;
else
q <= d;
// qbar <= !q;
end
endmodule
D-FF_TB:
`timescale 1ns / 1ps
module dff_tb;
// Inputs
reg d;
reg clk;
reg reset;
// Outputs
wire q;
initial begin
// Initialize Inputs
d = 0;
clk = 0;
reset = 0;
#20 reset = 1;
#70 reset = 0;
#100 d = 1;
#170 d = 0;
#270 d = 1;
#300 reset = 1;
#320 reset = 0;
end
always
#10 clk = !clk;
endmodule
JKMS:
`timescale 1ns / 1ps
module jk_ff(j,k,clk,q,qbar);
input j,k,clk;
output q,qbar;
wire clkbar,a,b,c,d,e,f;
not_gate n1 (clk,clkbar);
nand_gate g1 (qbar,a,q);
nand_gate g2 (q,b,qbar);
nand_gate g3 (c,clkbar,a);
nand_gate g4 (d,clkbar,b);
nand_gate g5 (e,d,c);
nand_gate g6 (f,c,d);
endmodule
JKMDFF_tb:
`timescale 1ns / 1ps
module jkms_tb;
// Inputs
reg j;
reg k;
reg clk;
// Outputs
wire q;
wire qbar;
initial begin
// Initialize Inputs
j = 0;
k = 0;
clk = 0;
#100 j = 1;
#200 j = 0;
#250 k = 1;
#400 j = 1;
end
always
#20 clk = ~clk;
endmodule
NAND:
`timescale 1ns / 1ps
module nand_gate(a,b,c);
input a;
input b;
output c;
endmodule
NAND_TB:
`timescale 1ns / 1ps
module nand_tb;
// Inputs
reg a;
reg b;
// Outputs
wire c;
initial begin
// Initialize Inputs
a = 0;
b = 0;
end
always
begin
#20 a = !a;
#40 b = !b;
end
endmodule
TRANSCRIPT:
# Reading C:/Modeltech_6.1f/tcl/vsim/pref.tcl
# // ModelSim SE 6.1f May 12 2006
# //
# // Copyright 2006 Mentor Graphics Corporation
# // All Rights Reserved.
# //
# // THIS WORK CONTAINS TRADE SECRET AND
# // PROPRIETARY INFORMATION WHICH IS THE PROPERTY
# // OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS
# // AND IS SUBJECT TO LICENSE TERMS.
# //
# OpenFile "C:/IMS/verilog/Nand Gate/Source Code/nand_tb.v"
NOT GATE:
`timescale 1ns / 1ps
module not_gate(
input a,
output b
);
assign b = !a;
endmodule
NOT_tb:
`timescale 1ns / 1ps
module not_tb;
// Inputs
reg a;
// Outputs
wire b;
initial begin
// Initialize Inputs
a = 0;
#50 a = 1;
#150 a = 0;
#250 a = 1;
end
endmodule
NOR:
`timescale 1ns / 1ps
module nor_gate(
input a,
input b,
output c
);
endmodule
NOR_tb:
`timescale 1ns / 1ps
module nor_tb;
// Inputs
reg a;
reg b;
// Outputs
wire c;
initial begin
// Initialize Inputs
a = 0;
b = 0;
end
always
begin
#20 a = !a;
#40 b = !b;
end
endmodule
PARALLEL_ADDER:
`timescale 1ns / 1ps
module parallel_adder(a,b,cin,sum,cout);
input [3:0] a;
input [3:0] b;
input cin;
output cout;
output [3:0] sum;
endmodule
PARALLEL_ADDER_TB:
`timescale 1ns / 1ps
module parallel_adder_tb;
// Inputs
reg [3:0] a;
reg [3:0] b;
reg cin;
// Outputs
wire [3:0] sum;
wire cout;
initial begin
// Initialize Inputs
a = 0;
b = 0;
cin = 0;
end
always
begin
#10 a = a + 1'b1;
#20 b = b+1'b1;
#320 cin = !cin;
end
endmodule
SERIAL_ADDER:
`timescale 1ns / 1ps
// serial adder module with no latency
module serial_adder(clk,rst,a,b,out);
input wire clk,rst,a,b;
//output reg out;
output wire out;
reg carry_reg, a_reg, b_reg;
wire carry, out_wire;
endmodule
SERIAL_ADDER_TB:
`timescale 1ns / 1ps
module serialadder_tb;
// Inputs
reg clk;
reg rst;
reg a;
reg b;
// Outputs
wire out;
initial begin
// Initialize Inputs
clk = 0;
rst = 0;
a = 0;
b = 0;
#50 rst = 1;
#70 rst = 0;
#100 a = 1;
#200 b = 1;
end
always
#10 clk = ~clk;
endmodule
SRFF:
`timescale 1ns / 1ps
module sr_ff(
input s,
input r,
output q,
output qbar
);
wire sbar,rbar;
not_gate g3 (s,sbar);
not_gate g4 (r,rbar);
nand_gate g1 (sbar,qbar,q);
nand_gate g2 (rbar,q,qbar);
endmodule
SRFF_TB:
`timescale 1ns / 1ps
module srff_tb;
// Inputs
reg s;
reg r;
// Outputs
wire q;
wire qbar;
initial begin
// Initialize Inputs
s = 0;
r = 0;
#50 s = 1;
#100 s = 0;
#200 r = 1;
#400 s = 1;
end
endmodule
T_FF:
`timescale 1ns / 1ps
module T_FF(
input clk,
input reset,
input tin,
output q
);
wire t;
dff c1(t,clk,reset,q);
not_gate c2(q,t);
endmodule
T_FF_TB:
`timescale 1ns / 1ps
module tff_tb;
// Inputs
reg clk;
reg reset;
reg tin;
// Outputs
wire q;
initial begin
// Initialize Inputs
clk = 0;
reset = 0;
tin = 0;
#20 reset = 1;
#70 reset = 0;
#100 tin = 1;
#170 tin = 0;
#270 tin = 1;
#300 reset = 1;
#320 reset = 0;
end
always
#10 clk = !clk;
endmodule