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

What's hot (20)

PDF
Zynq architecture
Nguyen Le Hung Nguyen
 
PPTX
gate level modeling
VandanaBR2
 
PPTX
Hdl
Areeba Gill
 
PPTX
Sequential cmos logic circuits
Sakshi Bhargava
 
PPT
4 bit add sub
dennis gookyi
 
PDF
I2C BUS PROTOCOL
Kashyap Mandaliya
 
PDF
Esp32 cam arduino-123
Victor Sue
 
PDF
Jtag presentation
klinetik
 
PPTX
Pll ppt
parassini
 
PPTX
Programming Model of 8051 sybcs lec 06
SAMIRNIMBHORE
 
PPTX
LED and LASER source in optical communication
bhupender rawat
 
DOCX
Report on VLSI
MAYANK KUMAR
 
PPTX
Design of CMOS operational Amplifiers using CADENCE
nandivashishth
 
PPTX
Static Noise margin
VLSI SYSTEM Design
 
PPTX
ASIC design verification
Gireesh Kallihal
 
PDF
Bias compensation
ramalakshmi54
 
PDF
Ssb generation method
jahirpatel
 
PDF
Verilog tutorial
Abhiraj Bohra
 
PPTX
PIC Microcontrollers
Abdullah Saghir Ahmad
 
PPTX
Vhdl programming
Yogesh Mashalkar
 
Zynq architecture
Nguyen Le Hung Nguyen
 
gate level modeling
VandanaBR2
 
Sequential cmos logic circuits
Sakshi Bhargava
 
4 bit add sub
dennis gookyi
 
I2C BUS PROTOCOL
Kashyap Mandaliya
 
Esp32 cam arduino-123
Victor Sue
 
Jtag presentation
klinetik
 
Pll ppt
parassini
 
Programming Model of 8051 sybcs lec 06
SAMIRNIMBHORE
 
LED and LASER source in optical communication
bhupender rawat
 
Report on VLSI
MAYANK KUMAR
 
Design of CMOS operational Amplifiers using CADENCE
nandivashishth
 
Static Noise margin
VLSI SYSTEM Design
 
ASIC design verification
Gireesh Kallihal
 
Bias compensation
ramalakshmi54
 
Ssb generation method
jahirpatel
 
Verilog tutorial
Abhiraj Bohra
 
PIC Microcontrollers
Abdullah Saghir Ahmad
 
Vhdl programming
Yogesh Mashalkar
 

Viewers also liked (13)

PDF
Verilog tutorial
amnis_azeneth
 
PDF
07 sequential verilog
Hendrik Moch Yusro
 
PDF
Verilog VHDL code Decoder and Encoder
Bharti Airtel Ltd.
 
PPTX
Verilog Tutorial - Verilog HDL Tutorial with Examples
E2MATRIX
 
PDF
verilog code for logic gates
Rakesh kumar jha
 
PDF
Verilog codes and testbench codes for basic digital electronic circuits.
shobhan pujari
 
PPTX
Verilog HDL
Mantra VLSI
 
PDF
Experiment write-vhdl-code-for-realize-all-logic-gates
Ricardo Castro
 
DOCX
VERILOG CODE
Dhaval Kaneria
 
PPTX
たぶんできる!Verilog hdl
cahara_mitsu
 
PPT
Encoders and Decoders
Nic JM
 
PPTX
Encoder and decoder
Then Murugeshwari
 
PPT
Multiplexers & Demultiplexers
Jayanshu Gundaniya
 
Verilog tutorial
amnis_azeneth
 
07 sequential verilog
Hendrik Moch Yusro
 
Verilog VHDL code Decoder and Encoder
Bharti Airtel Ltd.
 
Verilog Tutorial - Verilog HDL Tutorial with Examples
E2MATRIX
 
verilog code for logic gates
Rakesh kumar jha
 
Verilog codes and testbench codes for basic digital electronic circuits.
shobhan pujari
 
Verilog HDL
Mantra VLSI
 
Experiment write-vhdl-code-for-realize-all-logic-gates
Ricardo Castro
 
VERILOG CODE
Dhaval Kaneria
 
たぶんできる!Verilog hdl
cahara_mitsu
 
Encoders and Decoders
Nic JM
 
Encoder and decoder
Then Murugeshwari
 
Multiplexers & Demultiplexers
Jayanshu Gundaniya
 
Ad

Similar to Verilog code all (8)

DOC
Combinational circuits II outputs
Gouthaman V
 
DOCX
Vend with ff
Nitish Das
 
DOC
Sequential Circuits I VLSI 9th experiment
Gouthaman V
 
PDF
Task i
Darshil Shah
 
DOC
All VLSI programs
Gouthaman V
 
PPT
ANALYSIS & DESIGN OF COMBINATIONAL LOGIC
Supanna Shirguppe
 
PDF
Digital Systems Design Using Verilog 1st Edition Roth Solutions Manual
sravyalolis
 
PDF
Design of Mux and decoder using VHDL
Omkar Rane
 
Combinational circuits II outputs
Gouthaman V
 
Vend with ff
Nitish Das
 
Sequential Circuits I VLSI 9th experiment
Gouthaman V
 
Task i
Darshil Shah
 
All VLSI programs
Gouthaman V
 
ANALYSIS & DESIGN OF COMBINATIONAL LOGIC
Supanna Shirguppe
 
Digital Systems Design Using Verilog 1st Edition Roth Solutions Manual
sravyalolis
 
Design of Mux and decoder using VHDL
Omkar Rane
 
Ad

Recently uploaded (20)

PPTX
Shinkawa Proposal to meet Vibration API670.pptx
AchmadBashori2
 
DOCX
8th International Conference on Electrical Engineering (ELEN 2025)
elelijjournal653
 
PPTX
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
PDF
International Journal of Information Technology Convergence and services (IJI...
ijitcsjournal4
 
PPTX
Big Data and Data Science hype .pptx
SUNEEL37
 
PDF
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
PPT
Carmon_Remote Sensing GIS by Mahesh kumar
DhananjayM6
 
PDF
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
PDF
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 
PPT
Electrical Safety Presentation for Basics Learning
AliJaved79382
 
PDF
PORTFOLIO Golam Kibria Khan — architect with a passion for thoughtful design...
MasumKhan59
 
DOC
MRRS Strength and Durability of Concrete
CivilMythili
 
PPTX
Element 11. ELECTRICITY safety and hazards
merrandomohandas
 
PPTX
2025 CGI Congres - Surviving agile v05.pptx
Derk-Jan de Grood
 
PDF
Viol_Alessandro_Presentazione_prelaurea.pdf
dsecqyvhbowrzxshhf
 
PPTX
Introduction to Basic Renewable Energy.pptx
examcoordinatormesu
 
PDF
Halide Perovskites’ Multifunctional Properties: Coordination Engineering, Coo...
TaameBerhe2
 
PDF
Electrical Engineer operation Supervisor
ssaruntatapower143
 
PPT
PPT2_Metal formingMECHANICALENGINEEIRNG .ppt
Praveen Kumar
 
PDF
Zilliz Cloud Demo for performance and scale
Zilliz
 
Shinkawa Proposal to meet Vibration API670.pptx
AchmadBashori2
 
8th International Conference on Electrical Engineering (ELEN 2025)
elelijjournal653
 
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
International Journal of Information Technology Convergence and services (IJI...
ijitcsjournal4
 
Big Data and Data Science hype .pptx
SUNEEL37
 
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
Carmon_Remote Sensing GIS by Mahesh kumar
DhananjayM6
 
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 
Electrical Safety Presentation for Basics Learning
AliJaved79382
 
PORTFOLIO Golam Kibria Khan — architect with a passion for thoughtful design...
MasumKhan59
 
MRRS Strength and Durability of Concrete
CivilMythili
 
Element 11. ELECTRICITY safety and hazards
merrandomohandas
 
2025 CGI Congres - Surviving agile v05.pptx
Derk-Jan de Grood
 
Viol_Alessandro_Presentazione_prelaurea.pdf
dsecqyvhbowrzxshhf
 
Introduction to Basic Renewable Energy.pptx
examcoordinatormesu
 
Halide Perovskites’ Multifunctional Properties: Coordination Engineering, Coo...
TaameBerhe2
 
Electrical Engineer operation Supervisor
ssaruntatapower143
 
PPT2_Metal formingMECHANICALENGINEEIRNG .ppt
Praveen Kumar
 
Zilliz Cloud Demo for performance and scale
Zilliz
 

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