Labfile Jatin 1
Labfile Jatin 1
(21ECP612)
SUBMITTED BY:
JATIN KATIYAR
(2024PEV5264)
AY 2024-25
ELECTRONICS & COMMUNICATION ENGINEERING
DEPARTMENT
MALAVIYA NATIONAL INSTITUTE OF TECHNOLOGY
JAIPUR, INDIA
pg. 1
INDEX
pg. 2
Experiment 1 : Basic Logic Gate
Aim :
To design and simulate basic logic gates.
Tools used:
AMD Vivado
Truth table:
pg. 3
RTL block
Simulations:
pg. 4
Experiment 2 : Half Adder and Full Adder
Aim :
To design and simulate Half adder and Full Adder.
Tools used:
AMD Vivado
Truth table:
Half Adder
Full Adder
Verilog codes
`timescale 1ns / 1ps
`timescale 1ns / 1ps module test_bench_ha;
reg a, b;
module half_adder( wire sout, cout;
input a, b, reg clk;
RTL block
Full Adder
Half Adder
pg. 6
Simulations:
pg. 7
Experiment 3 : Half Subtractor and Full Subtractor
Aim :
To design and simulate half subtractor and full subtractor.
Tools used:
AMD Vivado
Truth table:
Half Subtractor
Full Subtractor
Verilog codes
pg. 8
`timescale 1ns / 1ps
module test_bench_fs;
`timescale 1ns / 1ps reg a, b, bin;
module full_subtractor( wire diff, bout;
input a, b, bin, reg clk'
output diff, bout); full_subtractor dut(a, b, bin, diff, bout);
assign diff = a ^ b ^ bin; always #5 clk = ~clk;
assign bout = (~a & (b^bin)) | (b initial begin
& bin) ; clk = 0; a = 0; b = 0; bin = 0;
endmodule #10; a = 0; b = 0; bin = 1;
#10; a = 0; b = 1; bin = 0;
#10; a = 0; b = 1; bin = 1;
#10; a = 1; b = 0; bin = 0;
#10; a = 1; b = 0; bin = 1;
#10; a = 1; b = 1; bin = 0;
#10; a = 1; b = 1; bin = 1;
#10; $finish;
end
always @(posedge clk) begin
$display("a: %b, b: %b, bin: %b, difference:
%b, borrow: %b", a, b, bin, diff, bout);
end
endmodule
RTL block
Aim :
To design and simulate 2:1 multiplexer.
Tools used:
AMD Vivado
Truth table:
Verilog codes
`timescale 1ns / 1ps
module mux_2_1(
input [1:0] i,
input select,
output y_out );
assign y_out= select ? i[1] :
i[0];
endmodule
pg. 10
RTL block
Simulations:
pg. 11
Experiment 5 : 1:2 Demultiplexer (DEMUX)
Aim:
To design and simulate 1:2 demux .
Tools used
AMD Vivado
Truth table
Verilog code
`timescale 1ns / 1ps
`timescale 1ns / 1ps module test_bench;
reg sel, i;
module demux_1_2( wire [1:0]y;
input sel, demux_1_2 dut(sel, i, y);
input i, initial begin
output y0, y1 sel=0; i=0;
); #10;sel=0; i=1;
assign {y0,y1} = #10;sel=1; i=0;
sel?{1'b0,i}: {i,1'b0}; #10;sel=1; i=1;
endmodule end
initial
begin
$monitor("sel: %b i: %b y[0]: %b
y[1]: %b", sel, i, y[0], y[1]);
#40 $finish; end
endmodule
RTL block
pg. 12
Simulation
pg. 13
Experiment 6 : SR Flip Flop
Aim :
To design and simulate SR Flipflop
Tools used:
AMD Vivado
Truth table:
pg. 14
Experiment 7 : JK Flip Flop
Aim :
To design and simulate JK Flipflop
Tools used:
AMD Vivado
Truth table:
Verilog codes
`timescale 1ns / 1ps
module test_bench;
reg clk,rst,j,k;
`timescale 1ns / 1ps wire Q;
JK_flipflop dut(j,k,clk,rst,Q);
module JK_flipflop( initial begin
input j,k,clk,reset, clk=0;
output reg Q forever #5 clk=~clk;
); end
always@(posedge clk) initial
begin begin
if({reset}) rst=1;
Q <= 1'b0; #10;
else j = 1'b0;
begin k = 1'b0;
case({j,k}) #10;
2'b00:Q<=Q; rst=0;
2'b01:Q<=1'b0; #10;
2'b10:Q<=1'b1; j = 1'b0;
2'b11:Q<=~Q; k = 1'b1;
endcase #10;
end j = 1'b1;
end k = 1'b0;
endmodule #10;
j = 1'b1;
k = 1'b1;
#10;
end
initial begin
$monitor("\t clk: %d J: %d K: %d Q:
%d", clk, j, k, Q);
#80 $finish;
end
endmodule
pg. 15
RTL block
Simulations:
pg. 16
Experiment 8 : T Flip Flop
Aim :
To design and simulate T FlipFlop.
Tools used:
AMD Vivado
Truth tabl e:
Verilog codes
pg. 17
RTL block
Simulations:
pg. 18
Experiment 9 : VIO
(virtual input and output)
Aim :
To design and simulate full adder using virtual input and output.
Tools used:
AMD Vivado
Verilog codes
`timescale 1ns / 1ps
module lab1( input [3:0] din,
input [3:0] din1,
output [3:0] dout, output cout
);
assign {cout,dout} = din+din1;
endmodule
RTL block
pg. 20
Experiment 10 : ILA
(input logic analyzer)
Aim :
Implementation of Input logic analyzer
Tools Used
AMD Vivado
RTL block
pg. 21
Integrated VIO and ILA with adder
pg. 22