(Vlsi) Short PDF
(Vlsi) Short PDF
Experiment : Flipflops
D-Flipflop:
Aim: For D- Flipflop.
Write Verilog description
Test-bench
Verilog Code
module d_ff (
input clk,
input d,
output reg q
);
q <= d;
end
endmodule
Testbench
module tb_d_ff;
reg clk, d;
wire q;
ini al begin
clk = 0; d = 0;
#10 d = 1;
VLSI
#10 d = 0;
#10 d = 1;
#50 $finish;
End
endmodule
SR- Flipflop:
Aim : For SR- Flipflop.
Write Verilog description
Test-bench
module sr_ff (
input clk,
input s,
input r,
output reg q
);
2'b00: q <= q;
2'b01: q <= 0;
2'b10: q <= 1;
endcase
end endmodule
VLSI
Testbench
module tb_sr_ff;
reg clk, s, r;
wire q;
ini al begin
clk = 0; s = 0; r = 0;
#10 s = 1; r = 0;
#10 s = 0; r = 1;
#10 s = 0; r = 0;
#10 s = 1; r = 1;
#10 s = 0; r = 0;
#10 $stop;
end
endmodule
JK Flipflop
Aim: For JK- Flipflop
Write Verilog description
Test-bench
VLSI
module jk_ff (
input clk,
input j,
input k,
output reg q
);
2'b00: q <= q;
2'b01: q <= 0;
2'b10: q <= 1;
endcase
end
endmodule
Testbench
module tb_jk_ff;
reg clk, j, k;
wire q;
ini al begin
clk = 0; j = 0; k = 0;
#10 j = 1; k = 0;
#10 j = 0; k = 1;
#10 j = 1; k = 1;
#10 j = 0; k = 0; //
#10 $finish;
end
endmodule
VLSI
input clk,
input rst,
);
if (rst)
count <= 0;
count <= 0;
else
end
endmodule
Testbench
module tb_mod_n_counter;
parameter N = 10;
ini al begin
rst = 1; #10;
rst = 0;
#100;
$finish;
end
endmodule
module alu_32bit (
input [31:0] a,
input [31:0] b,
output zero
);
case (sel)
3'b000: result = a + b;
3'b001: result = a - b;
3'b011: result = a | b;
3'b100: result = a ^ b;
endcase
end
endmodule
Testbench
module tb_alu_32bit;
reg [31:0] a, b;
wire zero;
ini al begin
a = 32'd15; b = 32'd10;
#10 $finish;
end
endmodule
Aim: To write a verilog code for 4bit shift and add multiplier and verify the
functionality using Test bench.
VLSI
input [3:0] a,
input [3:0] b,
);
case (sel)
2'b00: out = a;
endcase
end
endmodule
Testbench
reg [3:0] a, b;
ini al begin
a = 4'b1010; b = 4'b1100;
#10 $finish;
end
endmodule
Aim: To write a verilog code for 4bit adder and verify the functionality using Test bench
module adder_4bit (
input [3:0] a,
input [3:0] b,
input cin,
VLSI
output cout
);
endmodule
module full_adder (
input a, b, cin,
);
endmodule
Testbench
module tb_adder_4bit;
reg [3:0] a, b;
reg cin;
wire cout;
ini al begin
#10 $finish;
end
endmodule
OR
module adder_4bit (
input [3:0] a,
input [3:0] b,
input cin,
output cout
);
endmodule
Testbench
module tb_adder_4bit;
reg [3:0] a, b;
reg cin;
wire cout;
ini al begin
VLSI
#10 $finish;
end
endmodule