SlideShare a Scribd company logo
2
Most read
3
Most read
5
Most read
4:1mux
module 4:1mux(s0,s1,i0,i1,i2,i3,y);
outputy;
inputs0,s1,i0,i1,i2,i3;
assigny=((!s1)&&(!s0)&&(i0))||((!s1)&&(s0)&&(i1))||((s1)&&(!s0)&&(i2))||((s1)&&(s0)&&(i3));
endmodule
jk flipflop
module jk(q,q1,j,k,c);
outputq,q1;
inputj,k,c;
reg q,q1;
initial beginq=1'b0;q1=1'b1; end
always@ (posedge c)
begin
case({j,k})
{1'b0,1'b0}:beginq=q; q1=q1; end
{1'b0,1'b1}: beginq=1'b0; q1=1'b1; end
{1'b1,1'b0}:beginq=1'b1; q1=1'b0; end
{1'b1,1'b1}: beginq=~q; q1=~q1; end
endcase
end
endmodule
4*2 encoder
module jugad3(d0,d1,d2,d3,b1,b0);
input d0,d1,d2,d3;
output b1,b0;
assign b0=d1||d3;
assign b1=d2||d3;
endmodule
2*4 decoder
module jugad4(d0,d1,d2,d3,b1,b0);
output d0,d1,d2,d3;
input b1,b0;
assign d0=(!b1)&&(!b0);
assign d1=(!b1)&&(b0);
assign d2=(b1)&&(!b0);
assign d3=(b1)&&(b0);
endmodule
1:4 demux
module jugad5(y0,y1,y2,y3,s1,s0,i);
output y0,y1,y2,y3;
input s1,s0,i;
assign y0=!s1&&!s0&&i;
assign y1=!s1&&s0&&i;
assign y2=s1&&!s0&&i;
assign y3=s1&&s0&&i;
endmodule
Asynchronous countor
module jugad6( q_out, qbar_out, j,k, clk, reset);
input [1:0] j; input [1:0] k; input clk; input reset;
output [1:0] q_out;
output [1:0] qbar_out;
wire [1:0] q_out;
wire [1:0] qbar_out;
wire clk;
assign qbar_out[0] = ~q_out[0];
assign j[0] = 1;
assign k[0] = 1;
assign j[1] = 1;
assign k[1] = 1;
jkff M1(q_out[0], qbar_out[0], j[0], k[0], clk, reset);
jkff M2(q_out[1], qbar_out[1], j[1], k[1], qbar_out[0]);
endmodule
module jkff(output q_out, output qbar_out,
input j, input k, input clk, input reset);
reg q;
assign q_out = q;
assign qbar_out = ~q;
initial begin
q = 1'b0;
end
always @(posedge clk)
begin
case({j,k})
{1'b0, 1'b0}: begin
q = q;
end
{1'b0, 1'b1}: begin
q = 1'b0;
end
{1'b1, 1'b0}: begin
q = 1'b1;
end
{1'b1, 1'b1}: begin
q = ~q;
end
endcase
end
always @(posedge reset)
begin
q = 1'b0;
end
endmodule
skipping counter(0->1->3->0)
module jugad7( q_out, qbar_out, j,k, clk, reset);
input [1:0] j; input [1:0] k; input clk; input reset;
output [1:0] q_out;
output [1:0] qbar_out;
wire [1:0] q_out;
wire [1:0] qbar_out;
wire clk;
assign qbar_out[0] = ~q_out[0];
assign j[0]=!q_out[1];
assign j[1]=q_out[0];
assign k[0] =q_out[1];
assign k[1] =1;
jkff M1(q_out[0], qbar_out[0], j[0], k[0], clk, reset);
jkff M2(q_out[1], qbar_out[1], j[1], k[1], clk,reset);
endmodule
module jkff(output q_out, output qbar_out,
input j, input k, input clk, input reset);
reg q;
assign q_out = q;
assign qbar_out = ~q;
initial begin
q = 1'b0;
end
always @(posedge clk)
begin
case({j,k})
{1'b0, 1'b0}: begin
q = q;
end
{1'b0, 1'b1}: begin
q = 1'b0;
end
{1'b1, 1'b0}: begin
q = 1'b1;
end
{1'b1, 1'b1}: begin
q = ~q;
end
endcase
end
always @(posedge reset)
begin
q = 1'b0;
end
endmodule

More Related Content

PPTX
Pass Transistor Logic
PPTX
Clock divider by 3
PDF
Chapter 4 flip flop for students
PDF
Verilog full adder in dataflow & gate level modelling style.
PDF
Synchronous Loadable Up and Down Counter
PPTX
Divide by N clock
PPTX
Flipflop
PPTX
Cmos fabrication process
Pass Transistor Logic
Clock divider by 3
Chapter 4 flip flop for students
Verilog full adder in dataflow & gate level modelling style.
Synchronous Loadable Up and Down Counter
Divide by N clock
Flipflop
Cmos fabrication process

What's hot (20)

PPTX
Twin well process
PDF
Vlsi design
PDF
Verilog lab manual (ECAD and VLSI Lab)
PPT
Switch level modeling
PPT
PPTX
Stick Diagram
PPT
Vlsi design and fabrication ppt
PPTX
Race around and master slave flip flop
PPT
KARNAUGH MAP(K-MAP)
PPTX
Reversible logic gate
PPTX
Lect 7: Verilog Behavioral model for Absolute Beginners
PPTX
Presentation on Karnaugh Map
PPTX
CMOS Fabrication using P-well -VLSI
PDF
Overview of digital design with Verilog HDL
DOCX
Lambda design rule
PPTX
Performance Analysis (BER vs Eb/N0) of BPSK,QPSK, DPSK and M-PSK
PDF
Verilog coding of mux 8 x1
PDF
Ee560 mos theory_p101
PDF
Verilog coding of demux 8 x1
PPTX
Dynamic logic circuits
Twin well process
Vlsi design
Verilog lab manual (ECAD and VLSI Lab)
Switch level modeling
Stick Diagram
Vlsi design and fabrication ppt
Race around and master slave flip flop
KARNAUGH MAP(K-MAP)
Reversible logic gate
Lect 7: Verilog Behavioral model for Absolute Beginners
Presentation on Karnaugh Map
CMOS Fabrication using P-well -VLSI
Overview of digital design with Verilog HDL
Lambda design rule
Performance Analysis (BER vs Eb/N0) of BPSK,QPSK, DPSK and M-PSK
Verilog coding of mux 8 x1
Ee560 mos theory_p101
Verilog coding of demux 8 x1
Dynamic logic circuits
Ad

Viewers also liked (13)

PDF
Verilog tutorial
PDF
07 sequential verilog
PDF
Verilog VHDL code Decoder and Encoder
PPTX
Verilog Tutorial - Verilog HDL Tutorial with Examples
PDF
verilog code for logic gates
PDF
Verilog codes and testbench codes for basic digital electronic circuits.
PPTX
Verilog HDL
PDF
Experiment write-vhdl-code-for-realize-all-logic-gates
DOCX
VERILOG CODE
PPTX
たぶんできる!Verilog hdl
PPT
Encoders and Decoders
PPTX
Encoder and decoder
PPT
Multiplexers & Demultiplexers
Verilog tutorial
07 sequential verilog
Verilog VHDL code Decoder and Encoder
Verilog Tutorial - Verilog HDL Tutorial with Examples
verilog code for logic gates
Verilog codes and testbench codes for basic digital electronic circuits.
Verilog HDL
Experiment write-vhdl-code-for-realize-all-logic-gates
VERILOG CODE
たぶんできる!Verilog hdl
Encoders and Decoders
Encoder and decoder
Multiplexers & Demultiplexers
Ad

Similar to Verilog code all (6)

DOC
All VLSI programs
PPT
Digital System Design-Synchronous Sequential Circuits
PDF
TOC(CS-501) (19-49).pdf
DOCX
PRACTICAL COMPUTING
PDF
Task i
PPTX
ECE448_lecture7_ASM_VHDL.pptx
All VLSI programs
Digital System Design-Synchronous Sequential Circuits
TOC(CS-501) (19-49).pdf
PRACTICAL COMPUTING
Task i
ECE448_lecture7_ASM_VHDL.pptx

Recently uploaded (20)

PDF
PPT on Performance Review to get promotions
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
OOP with Java - Java Introduction (Basics)
PDF
Well-logging-methods_new................
PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
PDF
Digital Logic Computer Design lecture notes
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPTX
bas. eng. economics group 4 presentation 1.pptx
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PPTX
Geodesy 1.pptx...............................................
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PPT
Mechanical Engineering MATERIALS Selection
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
additive manufacturing of ss316l using mig welding
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPT
Introduction, IoT Design Methodology, Case Study on IoT System for Weather Mo...
PPT
Project quality management in manufacturing
PPT on Performance Review to get promotions
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
OOP with Java - Java Introduction (Basics)
Well-logging-methods_new................
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
Digital Logic Computer Design lecture notes
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
bas. eng. economics group 4 presentation 1.pptx
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
Geodesy 1.pptx...............................................
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
Mechanical Engineering MATERIALS Selection
Model Code of Practice - Construction Work - 21102022 .pdf
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
additive manufacturing of ss316l using mig welding
Operating System & Kernel Study Guide-1 - converted.pdf
CYBER-CRIMES AND SECURITY A guide to understanding
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Introduction, IoT Design Methodology, Case Study on IoT System for Weather Mo...
Project quality management in manufacturing

Verilog code all

  • 1. 4:1mux module 4:1mux(s0,s1,i0,i1,i2,i3,y); outputy; inputs0,s1,i0,i1,i2,i3; assigny=((!s1)&&(!s0)&&(i0))||((!s1)&&(s0)&&(i1))||((s1)&&(!s0)&&(i2))||((s1)&&(s0)&&(i3)); endmodule jk flipflop module jk(q,q1,j,k,c); outputq,q1; inputj,k,c; reg q,q1; initial beginq=1'b0;q1=1'b1; end always@ (posedge c) begin case({j,k}) {1'b0,1'b0}:beginq=q; q1=q1; end {1'b0,1'b1}: beginq=1'b0; q1=1'b1; end {1'b1,1'b0}:beginq=1'b1; q1=1'b0; end {1'b1,1'b1}: beginq=~q; q1=~q1; end endcase end endmodule
  • 2. 4*2 encoder module jugad3(d0,d1,d2,d3,b1,b0); input d0,d1,d2,d3; output b1,b0; assign b0=d1||d3; assign b1=d2||d3; endmodule 2*4 decoder module jugad4(d0,d1,d2,d3,b1,b0); output d0,d1,d2,d3; input b1,b0; assign d0=(!b1)&&(!b0); assign d1=(!b1)&&(b0); assign d2=(b1)&&(!b0); assign d3=(b1)&&(b0); endmodule
  • 3. 1:4 demux module jugad5(y0,y1,y2,y3,s1,s0,i); output y0,y1,y2,y3; input s1,s0,i; assign y0=!s1&&!s0&&i; assign y1=!s1&&s0&&i; assign y2=s1&&!s0&&i; assign y3=s1&&s0&&i; endmodule Asynchronous countor module jugad6( q_out, qbar_out, j,k, clk, reset); input [1:0] j; input [1:0] k; input clk; input reset; output [1:0] q_out; output [1:0] qbar_out; wire [1:0] q_out; wire [1:0] qbar_out; wire clk; assign qbar_out[0] = ~q_out[0]; assign j[0] = 1; assign k[0] = 1; assign j[1] = 1;
  • 4. assign k[1] = 1; jkff M1(q_out[0], qbar_out[0], j[0], k[0], clk, reset); jkff M2(q_out[1], qbar_out[1], j[1], k[1], qbar_out[0]); endmodule module jkff(output q_out, output qbar_out, input j, input k, input clk, input reset); reg q; assign q_out = q; assign qbar_out = ~q; initial begin q = 1'b0; end always @(posedge clk) begin case({j,k}) {1'b0, 1'b0}: begin q = q; end {1'b0, 1'b1}: begin q = 1'b0; end {1'b1, 1'b0}: begin
  • 5. q = 1'b1; end {1'b1, 1'b1}: begin q = ~q; end endcase end always @(posedge reset) begin q = 1'b0; end endmodule skipping counter(0->1->3->0) module jugad7( q_out, qbar_out, j,k, clk, reset); input [1:0] j; input [1:0] k; input clk; input reset; output [1:0] q_out; output [1:0] qbar_out; wire [1:0] q_out; wire [1:0] qbar_out; wire clk; assign qbar_out[0] = ~q_out[0]; assign j[0]=!q_out[1]; assign j[1]=q_out[0]; assign k[0] =q_out[1];
  • 6. assign k[1] =1; jkff M1(q_out[0], qbar_out[0], j[0], k[0], clk, reset); jkff M2(q_out[1], qbar_out[1], j[1], k[1], clk,reset); endmodule module jkff(output q_out, output qbar_out, input j, input k, input clk, input reset); reg q; assign q_out = q; assign qbar_out = ~q; initial begin q = 1'b0; end always @(posedge clk) begin case({j,k}) {1'b0, 1'b0}: begin q = q; end {1'b0, 1'b1}: begin q = 1'b0; end
  • 7. {1'b1, 1'b0}: begin q = 1'b1; end {1'b1, 1'b1}: begin q = ~q; end endcase end always @(posedge reset) begin q = 1'b0; end endmodule