SlideShare a Scribd company logo
A 4 X 1 M U LT I P L E X E R
S Y S T E M V E R I L O G
S Y S T E M V E R I L O G
A 4 X 1 M U LT I P L E X E R
This tutorial builds a 4X1 multiplexer
using 2X1 multiplexer modules in System Verilog.
Two levels of functionality are included:
• Lower Level Module
• 2X1 multiplexer (explained in detail in a previous tutorial)
• Higher Level Module
• 4X1 multiplexer (constructed using 2X1 multiplexer modules)
This tutorial also includes a testbench module which allows the 4X1
multiplexer to be simulated and its functionality verified in ModelSim.
S Y S T E M V E R I L O G
A 2 X 1 M U LT I P L E X E R
module mux2_1(out, i0, i1, sel);
output logic out;
input logic i0, i1, sel;
assign out = (i1 & sel) | (i0 & ~sel);
endmodule
The mux2_1 module has the functionality of a 2X1 multiplexer and is described in
more detail in a previous tutorial. The 2X1 multiplexer has three inputs. If sel=0,
the value of i0 is transferred to the output (out); If sel = 1, the value of i1 is
transferred to the output (out).
out
i0
i1
sel
S Y S T E M V E R I L O G
A 4 X 1 M U LT I P L E X E R
module mux4_1(out, i00, i01, i11, i10, sel0, sel1);
output logic out;
input logic i00, i01, i11, i10, sel0, sel1;
wire out_0, out_1;
mux2_1 a1(.out(out_0), .i0(i00), .i1(i01), .sel(sel0));
mux2_1 a2(.out(out_1), .i0(i10), .i1(i11), .sel(sel0));
mux2_1 a3(.out(out), .i0(out_0), .i1(out_1), .sel(sel1));
endmodule
out is an output of the
module mux4_1. out is of
the variable type logic
and can have four possible
values: z, x, 0, or 1
i00, i01, i11, i10, sel0,
and sel1 are all inputs to
mux4X1 and also are of
the variable type logic
out_0 and out_1 are internal signals to the mux4_1
The functionality of the 4X1 multiplexer (mux4_1) is generated by
instantiating three 2X1 multiplexers (mux2_1)
S Y S T E M V E R I L O G
A 4 X 1 M U LT I P L E X E R
module mux4_1(out, i00, i01, i11, i10, sel0, sel1);
output logic out;
input logic i00, i01, i11, i10, sel0, sel1;
wire out_0, out_1;
mux2_1 a1(.out(out_0), .i0(i00), .i1(i01), .sel(sel0));
mux2_1 a2(.out(out_1), .i0(i10), .i1(i11), .sel(sel0));
mux2_1 a3(.out(out), .i0(out_0), .i1(out_1), .sel(sel1));
endmodule
out_0
i00
i01
sel0
mux2_1
out_1
i10
i11
sel0
mux2_1
out
sel1
mux2_1
S Y S T E M V E R I L O G
A 4 X 1 M U LT I P L E X E R
module mux4_1_testbench;
logic out;
logic i00, i01, i11, i10, sel0, sel1;
mux4_1 dut (.out, .i00, .i01, .i11, .i10, .sel0, .sel1);
initial begin
sel0 = 0; sel1 = 0; i00 = 1; i01 = 1; i10 = 0; i11 = 1; #10;
sel0 = 1; sel1 = 1; i00 = 1; i01 = 1; i10 = 0; i11 = 1; #10;
sel0 = 1; sel1 = 0; i00 = 1; i01 = 1; i10 = 0; i11 = 1; #10;
sel0 = 1; sel1 = 1; i00 = 1; i01 = 1; i10 = 0; i11 = 1; #10;
sel0 = 1; sel1 = 1; i00 = 0; i01 = 1; i10 = 0; i11 = 1; #10;
sel0 = 1; sel1 = 0; i00 = 0; i01 = 1; i10 = 0; i11 = 1; #10;
sel0 = 0; sel1 = 1; i00 = 0; i01 = 1; i10 = 0; i11 = 1; #10;
sel0 = 0; sel1 = 0; i00 = 0; i01 = 1; i10 = 0; i11 = 1; #10;
end
endmodule
The testbench establishes the conditions by
which the mux4_1 that was created
(functionalized) in the previous slide (via the
module mux4_1) can be tested in ModelSim;
the testbench module is typically included in
the same file as the functionalized module
(which would be mux4_1 in this case).
S Y S T E M V E R I L O G
A 4 X 1 M U LT I P L E X E R
module mux4_1_testbench;
logic out;
logic i00, i01, i11, i10, sel0, sel1;
mux4_1 dut (.out, .i00, .i01, .i11, .i10, .sel0, .sel1);
initial begin
sel0 = 0; sel1 = 0; i00 = 1; i01 = 1; i10 = 0; i11 = 1; #10;
sel0 = 1; sel1 = 1; i00 = 1; i01 = 1; i10 = 0; i11 = 1; #10;
sel0 = 1; sel1 = 0; i00 = 1; i01 = 1; i10 = 0; i11 = 1; #10;
sel0 = 1; sel1 = 1; i00 = 1; i01 = 1; i10 = 0; i11 = 1; #10;
sel0 = 1; sel1 = 1; i00 = 0; i01 = 1; i10 = 0; i11 = 1; #10;
sel0 = 1; sel1 = 0; i00 = 0; i01 = 1; i10 = 0; i11 = 1; #10;
sel0 = 0; sel1 = 1; i00 = 0; i01 = 1; i10 = 0; i11 = 1; #10;
sel0 = 0; sel1 = 0; i00 = 0; i01 = 1; i10 = 0; i11 = 1; #10;
end
endmodule
Sets up the mux4_1 for testing/simulating
and names it dut (device under test). Unlike
the previous slide, each input and output
signal does not need a separate wire name
(e.g. .out (out_0)) because this module only
tests mux4_1 rather than instantiating it.
S Y S T E M V E R I L O G
A 4 X 1 M U LT I P L E X E R
module mux4_1_testbench;
logic out;
logic i00, i01, i11, i10, sel0, sel1;
mux4_1 dut (.out, .i00, .i01, .i11, .i10, .sel0, .sel1);
initial begin
sel0 = 0; sel1 = 0; i00 = 1; i01 = 1; i10 = 0; i11 = 1; #10;
sel0 = 1; sel1 = 1; i00 = 1; i01 = 1; i10 = 0; i11 = 1; #10;
sel0 = 1; sel1 = 0; i00 = 1; i01 = 1; i10 = 0; i11 = 1; #10;
sel0 = 1; sel1 = 1; i00 = 1; i01 = 1; i10 = 0; i11 = 1; #10;
sel0 = 1; sel1 = 1; i00 = 0; i01 = 1; i10 = 0; i11 = 1; #10;
sel0 = 1; sel1 = 0; i00 = 0; i01 = 1; i10 = 0; i11 = 1; #10;
sel0 = 0; sel1 = 1; i00 = 0; i01 = 1; i10 = 0; i11 = 1; #10;
sel0 = 0; sel1 = 0; i00 = 0; i01 = 1; i10 = 0; i11 = 1; #10;
end
endmodule
This initial block sets up the testing of
8 of the 64 possible input (sel0, sel1,
i00, i01, i10, i11) combinations to
mux4_1. The outputs of this testing
sequence can be viewed in ModelSim.
A delay of 10 time units occurs
between each input combination (as
indicated by #10 after each input
combination).
S Y S T E M V E R I L O G
A 4 X 1 M U LT I P L E X E R
In this tutorial, we have
created a 4X1 multiplexer in
System Verilog using 2X1
multiplexers and created a
testbench to simulate a subset
of input combinations in
ModelSim.
out
i00
sel1 sel0
i01
i10
i11
Click here for
More Tutorials on
Digital Logic & Circuits

More Related Content

What's hot

Delays in verilog
Delays in verilogDelays in verilog
Delays in verilog
JITU MISTRY
 
Switch level modeling
Switch level modelingSwitch level modeling
Switch level modeling
Devi Pradeep Podugu
 
Verilog VHDL code Decoder and Encoder
Verilog VHDL code Decoder and EncoderVerilog VHDL code Decoder and Encoder
Verilog VHDL code Decoder and Encoder
Bharti Airtel Ltd.
 
design of FPGA based traffic light controller system
design of FPGA based traffic light controller systemdesign of FPGA based traffic light controller system
design of FPGA based traffic light controller system
Vinny Chweety
 
design of FPGA based traffic light controller system
design of FPGA based traffic light controller systemdesign of FPGA based traffic light controller system
design of FPGA based traffic light controller system
Vinny Chweety
 
Verilog HDL CODES
Verilog HDL CODES Verilog HDL CODES
Verilog HDL CODES
OmkarDarekar6
 
Design and implementation of 32 bit alu using verilog
Design and implementation of 32 bit alu using verilogDesign and implementation of 32 bit alu using verilog
Design and implementation of 32 bit alu using verilog
STEPHEN MOIRANGTHEM
 
Four way traffic light conrol using Verilog
Four way traffic light conrol using VerilogFour way traffic light conrol using Verilog
Four way traffic light conrol using Verilog
Utkarsh De
 
Verilog operators.pptx
Verilog  operators.pptxVerilog  operators.pptx
Verilog operators.pptx
VandanaPagar1
 
digital electronics Design of 101 sequence detector without overlapping for...
digital  electronics Design of 101 sequence detector without  overlapping for...digital  electronics Design of 101 sequence detector without  overlapping for...
digital electronics Design of 101 sequence detector without overlapping for...
sanjay kumar pediredla
 
Booth Multiplier
Booth MultiplierBooth Multiplier
Booth Multiplier
Sudhir Kumar
 
Multipliers in VLSI
Multipliers in VLSIMultipliers in VLSI
Multipliers in VLSI
Kiranmai Sony
 
Pass Transistor Logic
Pass Transistor LogicPass Transistor Logic
Pass Transistor Logic
Sudhanshu Janwadkar
 
Verilog HDL
Verilog HDLVerilog HDL
Verilog HDL
Mantra VLSI
 
Verilog tutorial
Verilog tutorialVerilog tutorial
Verilog tutorial
Maryala Srinivas
 
Digital Electronics Question Bank
Digital Electronics Question BankDigital Electronics Question Bank
Digital Electronics Question Bank
Mathankumar S
 
8 Bit ALU
8 Bit ALU8 Bit ALU
Basics of digital verilog design(alok singh kanpur)
Basics of digital verilog design(alok singh kanpur)Basics of digital verilog design(alok singh kanpur)
Basics of digital verilog design(alok singh kanpur)
Alok Singh
 
Vhdl lab manual
Vhdl lab manualVhdl lab manual
Vhdl lab manual
Mukul Mohal
 
VHDL Behavioral Description
VHDL Behavioral DescriptionVHDL Behavioral Description
VHDL Behavioral Description
Sudhanshu Janwadkar
 

What's hot (20)

Delays in verilog
Delays in verilogDelays in verilog
Delays in verilog
 
Switch level modeling
Switch level modelingSwitch level modeling
Switch level modeling
 
Verilog VHDL code Decoder and Encoder
Verilog VHDL code Decoder and EncoderVerilog VHDL code Decoder and Encoder
Verilog VHDL code Decoder and Encoder
 
design of FPGA based traffic light controller system
design of FPGA based traffic light controller systemdesign of FPGA based traffic light controller system
design of FPGA based traffic light controller system
 
design of FPGA based traffic light controller system
design of FPGA based traffic light controller systemdesign of FPGA based traffic light controller system
design of FPGA based traffic light controller system
 
Verilog HDL CODES
Verilog HDL CODES Verilog HDL CODES
Verilog HDL CODES
 
Design and implementation of 32 bit alu using verilog
Design and implementation of 32 bit alu using verilogDesign and implementation of 32 bit alu using verilog
Design and implementation of 32 bit alu using verilog
 
Four way traffic light conrol using Verilog
Four way traffic light conrol using VerilogFour way traffic light conrol using Verilog
Four way traffic light conrol using Verilog
 
Verilog operators.pptx
Verilog  operators.pptxVerilog  operators.pptx
Verilog operators.pptx
 
digital electronics Design of 101 sequence detector without overlapping for...
digital  electronics Design of 101 sequence detector without  overlapping for...digital  electronics Design of 101 sequence detector without  overlapping for...
digital electronics Design of 101 sequence detector without overlapping for...
 
Booth Multiplier
Booth MultiplierBooth Multiplier
Booth Multiplier
 
Multipliers in VLSI
Multipliers in VLSIMultipliers in VLSI
Multipliers in VLSI
 
Pass Transistor Logic
Pass Transistor LogicPass Transistor Logic
Pass Transistor Logic
 
Verilog HDL
Verilog HDLVerilog HDL
Verilog HDL
 
Verilog tutorial
Verilog tutorialVerilog tutorial
Verilog tutorial
 
Digital Electronics Question Bank
Digital Electronics Question BankDigital Electronics Question Bank
Digital Electronics Question Bank
 
8 Bit ALU
8 Bit ALU8 Bit ALU
8 Bit ALU
 
Basics of digital verilog design(alok singh kanpur)
Basics of digital verilog design(alok singh kanpur)Basics of digital verilog design(alok singh kanpur)
Basics of digital verilog design(alok singh kanpur)
 
Vhdl lab manual
Vhdl lab manualVhdl lab manual
Vhdl lab manual
 
VHDL Behavioral Description
VHDL Behavioral DescriptionVHDL Behavioral Description
VHDL Behavioral Description
 

Similar to System Verilog (Tutorial -- 4X1 Multiplexer)

System Verilog (Tutorial -- 2X1 Multiplexer)
System Verilog (Tutorial -- 2X1 Multiplexer)System Verilog (Tutorial -- 2X1 Multiplexer)
System Verilog (Tutorial -- 2X1 Multiplexer)
Denise Wilson
 
Vhdlbputspdas
VhdlbputspdasVhdlbputspdas
Vhdlbputspdas
GIET,Bhubaneswar
 
Basic-VHDL-Constructs1.ppt
Basic-VHDL-Constructs1.pptBasic-VHDL-Constructs1.ppt
Basic-VHDL-Constructs1.ppt
BUCHUPALLIVIMALAREDD2
 
Decodificador
DecodificadorDecodificador
Decodificador
Eduardo Garcia
 
correctionTD-1-vhdl2947.pptx
correctionTD-1-vhdl2947.pptxcorrectionTD-1-vhdl2947.pptx
correctionTD-1-vhdl2947.pptx
MbarkiIsraa
 
Java Bytecode Crash Course [Code One 2019]
Java Bytecode Crash Course [Code One 2019]Java Bytecode Crash Course [Code One 2019]
Java Bytecode Crash Course [Code One 2019]
David Buck
 
Aprenda Elixir em um final de semana
Aprenda Elixir em um final de semanaAprenda Elixir em um final de semana
Aprenda Elixir em um final de semana
Marcos Brizeno
 
500523224.pptx
500523224.pptx500523224.pptx
500523224.pptx
Iftikhar70
 

Similar to System Verilog (Tutorial -- 4X1 Multiplexer) (8)

System Verilog (Tutorial -- 2X1 Multiplexer)
System Verilog (Tutorial -- 2X1 Multiplexer)System Verilog (Tutorial -- 2X1 Multiplexer)
System Verilog (Tutorial -- 2X1 Multiplexer)
 
Vhdlbputspdas
VhdlbputspdasVhdlbputspdas
Vhdlbputspdas
 
Basic-VHDL-Constructs1.ppt
Basic-VHDL-Constructs1.pptBasic-VHDL-Constructs1.ppt
Basic-VHDL-Constructs1.ppt
 
Decodificador
DecodificadorDecodificador
Decodificador
 
correctionTD-1-vhdl2947.pptx
correctionTD-1-vhdl2947.pptxcorrectionTD-1-vhdl2947.pptx
correctionTD-1-vhdl2947.pptx
 
Java Bytecode Crash Course [Code One 2019]
Java Bytecode Crash Course [Code One 2019]Java Bytecode Crash Course [Code One 2019]
Java Bytecode Crash Course [Code One 2019]
 
Aprenda Elixir em um final de semana
Aprenda Elixir em um final de semanaAprenda Elixir em um final de semana
Aprenda Elixir em um final de semana
 
500523224.pptx
500523224.pptx500523224.pptx
500523224.pptx
 

More from Denise Wilson

Sexual Harassment in Academia
Sexual Harassment in AcademiaSexual Harassment in Academia
Sexual Harassment in Academia
Denise Wilson
 
Is Sexual Harassment different for Gender and Sexual Minorities (LGBTQ)?
Is Sexual Harassment different for Gender and Sexual Minorities (LGBTQ)?Is Sexual Harassment different for Gender and Sexual Minorities (LGBTQ)?
Is Sexual Harassment different for Gender and Sexual Minorities (LGBTQ)?
Denise Wilson
 
Is Sexual Harassment Different among Different Age Groups?
Is Sexual Harassment Different among Different Age Groups?Is Sexual Harassment Different among Different Age Groups?
Is Sexual Harassment Different among Different Age Groups?
Denise Wilson
 
Is Sexual Harassment Different by Race and Ethnicity?
Is Sexual Harassment Different by Race and Ethnicity?Is Sexual Harassment Different by Race and Ethnicity?
Is Sexual Harassment Different by Race and Ethnicity?
Denise Wilson
 
Is Sexual Harassment Different for Men vs. Women?
Is Sexual Harassment Different for Men vs. Women?Is Sexual Harassment Different for Men vs. Women?
Is Sexual Harassment Different for Men vs. Women?
Denise Wilson
 
What do Student Evaluations of Teaching Really Measure?
What do Student Evaluations of Teaching Really Measure?What do Student Evaluations of Teaching Really Measure?
What do Student Evaluations of Teaching Really Measure?
Denise Wilson
 
Student Teaching Evaluations: Friend or Foe?
Student Teaching Evaluations: Friend or Foe?Student Teaching Evaluations: Friend or Foe?
Student Teaching Evaluations: Friend or Foe?
Denise Wilson
 
Women in the Engineering Workplace
Women in the Engineering WorkplaceWomen in the Engineering Workplace
Women in the Engineering Workplace
Denise Wilson
 
Boeing 737 Max Accidents
Boeing 737 Max AccidentsBoeing 737 Max Accidents
Boeing 737 Max Accidents
Denise Wilson
 
Electricity production windpower
Electricity production windpowerElectricity production windpower
Electricity production windpower
Denise Wilson
 
Environmental Impacts of Electricity Production
Environmental Impacts of Electricity ProductionEnvironmental Impacts of Electricity Production
Environmental Impacts of Electricity Production
Denise Wilson
 
Economic Considerations in Engineering Design
Economic Considerations in Engineering DesignEconomic Considerations in Engineering Design
Economic Considerations in Engineering Design
Denise Wilson
 
Social Considerations in Engineering Design
Social Considerations in Engineering DesignSocial Considerations in Engineering Design
Social Considerations in Engineering Design
Denise Wilson
 
Environmental Considerations in Electronic Product Design
Environmental Considerations in Electronic Product DesignEnvironmental Considerations in Electronic Product Design
Environmental Considerations in Electronic Product Design
Denise Wilson
 
Basic Engineering Design (Part 8)): Redesigning & Iterating
Basic Engineering Design (Part 8)):  Redesigning & IteratingBasic Engineering Design (Part 8)):  Redesigning & Iterating
Basic Engineering Design (Part 8)): Redesigning & Iterating
Denise Wilson
 
Basic Engineering Design (Part 7): Presenting the Solution
Basic Engineering Design (Part 7): Presenting the SolutionBasic Engineering Design (Part 7): Presenting the Solution
Basic Engineering Design (Part 7): Presenting the Solution
Denise Wilson
 
Basic Engineering Design (Part 6): Test and Evaluate
Basic Engineering Design (Part 6): Test and EvaluateBasic Engineering Design (Part 6): Test and Evaluate
Basic Engineering Design (Part 6): Test and Evaluate
Denise Wilson
 
Basic Engineering Design (Part 5): Constructing a Prototype
Basic Engineering Design (Part 5): Constructing a PrototypeBasic Engineering Design (Part 5): Constructing a Prototype
Basic Engineering Design (Part 5): Constructing a Prototype
Denise Wilson
 
Basic Engineering Design (Part 4): Selecting the Best Solution
Basic Engineering Design (Part 4): Selecting the Best SolutionBasic Engineering Design (Part 4): Selecting the Best Solution
Basic Engineering Design (Part 4): Selecting the Best Solution
Denise Wilson
 
Basic Engineering Design (Part 3): Designing Solutions
Basic Engineering Design (Part 3): Designing SolutionsBasic Engineering Design (Part 3): Designing Solutions
Basic Engineering Design (Part 3): Designing Solutions
Denise Wilson
 

More from Denise Wilson (20)

Sexual Harassment in Academia
Sexual Harassment in AcademiaSexual Harassment in Academia
Sexual Harassment in Academia
 
Is Sexual Harassment different for Gender and Sexual Minorities (LGBTQ)?
Is Sexual Harassment different for Gender and Sexual Minorities (LGBTQ)?Is Sexual Harassment different for Gender and Sexual Minorities (LGBTQ)?
Is Sexual Harassment different for Gender and Sexual Minorities (LGBTQ)?
 
Is Sexual Harassment Different among Different Age Groups?
Is Sexual Harassment Different among Different Age Groups?Is Sexual Harassment Different among Different Age Groups?
Is Sexual Harassment Different among Different Age Groups?
 
Is Sexual Harassment Different by Race and Ethnicity?
Is Sexual Harassment Different by Race and Ethnicity?Is Sexual Harassment Different by Race and Ethnicity?
Is Sexual Harassment Different by Race and Ethnicity?
 
Is Sexual Harassment Different for Men vs. Women?
Is Sexual Harassment Different for Men vs. Women?Is Sexual Harassment Different for Men vs. Women?
Is Sexual Harassment Different for Men vs. Women?
 
What do Student Evaluations of Teaching Really Measure?
What do Student Evaluations of Teaching Really Measure?What do Student Evaluations of Teaching Really Measure?
What do Student Evaluations of Teaching Really Measure?
 
Student Teaching Evaluations: Friend or Foe?
Student Teaching Evaluations: Friend or Foe?Student Teaching Evaluations: Friend or Foe?
Student Teaching Evaluations: Friend or Foe?
 
Women in the Engineering Workplace
Women in the Engineering WorkplaceWomen in the Engineering Workplace
Women in the Engineering Workplace
 
Boeing 737 Max Accidents
Boeing 737 Max AccidentsBoeing 737 Max Accidents
Boeing 737 Max Accidents
 
Electricity production windpower
Electricity production windpowerElectricity production windpower
Electricity production windpower
 
Environmental Impacts of Electricity Production
Environmental Impacts of Electricity ProductionEnvironmental Impacts of Electricity Production
Environmental Impacts of Electricity Production
 
Economic Considerations in Engineering Design
Economic Considerations in Engineering DesignEconomic Considerations in Engineering Design
Economic Considerations in Engineering Design
 
Social Considerations in Engineering Design
Social Considerations in Engineering DesignSocial Considerations in Engineering Design
Social Considerations in Engineering Design
 
Environmental Considerations in Electronic Product Design
Environmental Considerations in Electronic Product DesignEnvironmental Considerations in Electronic Product Design
Environmental Considerations in Electronic Product Design
 
Basic Engineering Design (Part 8)): Redesigning & Iterating
Basic Engineering Design (Part 8)):  Redesigning & IteratingBasic Engineering Design (Part 8)):  Redesigning & Iterating
Basic Engineering Design (Part 8)): Redesigning & Iterating
 
Basic Engineering Design (Part 7): Presenting the Solution
Basic Engineering Design (Part 7): Presenting the SolutionBasic Engineering Design (Part 7): Presenting the Solution
Basic Engineering Design (Part 7): Presenting the Solution
 
Basic Engineering Design (Part 6): Test and Evaluate
Basic Engineering Design (Part 6): Test and EvaluateBasic Engineering Design (Part 6): Test and Evaluate
Basic Engineering Design (Part 6): Test and Evaluate
 
Basic Engineering Design (Part 5): Constructing a Prototype
Basic Engineering Design (Part 5): Constructing a PrototypeBasic Engineering Design (Part 5): Constructing a Prototype
Basic Engineering Design (Part 5): Constructing a Prototype
 
Basic Engineering Design (Part 4): Selecting the Best Solution
Basic Engineering Design (Part 4): Selecting the Best SolutionBasic Engineering Design (Part 4): Selecting the Best Solution
Basic Engineering Design (Part 4): Selecting the Best Solution
 
Basic Engineering Design (Part 3): Designing Solutions
Basic Engineering Design (Part 3): Designing SolutionsBasic Engineering Design (Part 3): Designing Solutions
Basic Engineering Design (Part 3): Designing Solutions
 

Recently uploaded

Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
insn4465
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
SUTEJAS
 
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.pptPROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
bhadouriyakaku
 
一比一原版(UC Berkeley毕业证)加利福尼亚大学|伯克利分校毕业证成绩单专业办理
一比一原版(UC Berkeley毕业证)加利福尼亚大学|伯克利分校毕业证成绩单专业办理一比一原版(UC Berkeley毕业证)加利福尼亚大学|伯克利分校毕业证成绩单专业办理
一比一原版(UC Berkeley毕业证)加利福尼亚大学|伯克利分校毕业证成绩单专业办理
skuxot
 
bank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdfbank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdf
Divyam548318
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
SyedAbiiAzazi1
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
KrishnaveniKrishnara1
 
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
awadeshbabu
 
sieving analysis and results interpretation
sieving analysis and results interpretationsieving analysis and results interpretation
sieving analysis and results interpretation
ssuser36d3051
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdfTutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
aqil azizi
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
zwunae
 
Unbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptxUnbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptx
ChristineTorrepenida1
 
6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
ClaraZara1
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
nooriasukmaningtyas
 
introduction to solar energy for engineering.pdf
introduction to solar energy for engineering.pdfintroduction to solar energy for engineering.pdf
introduction to solar energy for engineering.pdf
ravindarpurohit26
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
IJECEIAES
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
gerogepatton
 

Recently uploaded (20)

Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
 
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.pptPROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
 
一比一原版(UC Berkeley毕业证)加利福尼亚大学|伯克利分校毕业证成绩单专业办理
一比一原版(UC Berkeley毕业证)加利福尼亚大学|伯克利分校毕业证成绩单专业办理一比一原版(UC Berkeley毕业证)加利福尼亚大学|伯克利分校毕业证成绩单专业办理
一比一原版(UC Berkeley毕业证)加利福尼亚大学|伯克利分校毕业证成绩单专业办理
 
bank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdfbank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdf
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
 
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
 
sieving analysis and results interpretation
sieving analysis and results interpretationsieving analysis and results interpretation
sieving analysis and results interpretation
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdfTutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
 
Unbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptxUnbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptx
 
6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
 
introduction to solar energy for engineering.pdf
introduction to solar energy for engineering.pdfintroduction to solar energy for engineering.pdf
introduction to solar energy for engineering.pdf
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
 

System Verilog (Tutorial -- 4X1 Multiplexer)

  • 1. A 4 X 1 M U LT I P L E X E R S Y S T E M V E R I L O G
  • 2. S Y S T E M V E R I L O G A 4 X 1 M U LT I P L E X E R This tutorial builds a 4X1 multiplexer using 2X1 multiplexer modules in System Verilog. Two levels of functionality are included: • Lower Level Module • 2X1 multiplexer (explained in detail in a previous tutorial) • Higher Level Module • 4X1 multiplexer (constructed using 2X1 multiplexer modules) This tutorial also includes a testbench module which allows the 4X1 multiplexer to be simulated and its functionality verified in ModelSim.
  • 3. S Y S T E M V E R I L O G A 2 X 1 M U LT I P L E X E R module mux2_1(out, i0, i1, sel); output logic out; input logic i0, i1, sel; assign out = (i1 & sel) | (i0 & ~sel); endmodule The mux2_1 module has the functionality of a 2X1 multiplexer and is described in more detail in a previous tutorial. The 2X1 multiplexer has three inputs. If sel=0, the value of i0 is transferred to the output (out); If sel = 1, the value of i1 is transferred to the output (out). out i0 i1 sel
  • 4. S Y S T E M V E R I L O G A 4 X 1 M U LT I P L E X E R module mux4_1(out, i00, i01, i11, i10, sel0, sel1); output logic out; input logic i00, i01, i11, i10, sel0, sel1; wire out_0, out_1; mux2_1 a1(.out(out_0), .i0(i00), .i1(i01), .sel(sel0)); mux2_1 a2(.out(out_1), .i0(i10), .i1(i11), .sel(sel0)); mux2_1 a3(.out(out), .i0(out_0), .i1(out_1), .sel(sel1)); endmodule out is an output of the module mux4_1. out is of the variable type logic and can have four possible values: z, x, 0, or 1 i00, i01, i11, i10, sel0, and sel1 are all inputs to mux4X1 and also are of the variable type logic out_0 and out_1 are internal signals to the mux4_1 The functionality of the 4X1 multiplexer (mux4_1) is generated by instantiating three 2X1 multiplexers (mux2_1)
  • 5. S Y S T E M V E R I L O G A 4 X 1 M U LT I P L E X E R module mux4_1(out, i00, i01, i11, i10, sel0, sel1); output logic out; input logic i00, i01, i11, i10, sel0, sel1; wire out_0, out_1; mux2_1 a1(.out(out_0), .i0(i00), .i1(i01), .sel(sel0)); mux2_1 a2(.out(out_1), .i0(i10), .i1(i11), .sel(sel0)); mux2_1 a3(.out(out), .i0(out_0), .i1(out_1), .sel(sel1)); endmodule out_0 i00 i01 sel0 mux2_1 out_1 i10 i11 sel0 mux2_1 out sel1 mux2_1
  • 6. S Y S T E M V E R I L O G A 4 X 1 M U LT I P L E X E R module mux4_1_testbench; logic out; logic i00, i01, i11, i10, sel0, sel1; mux4_1 dut (.out, .i00, .i01, .i11, .i10, .sel0, .sel1); initial begin sel0 = 0; sel1 = 0; i00 = 1; i01 = 1; i10 = 0; i11 = 1; #10; sel0 = 1; sel1 = 1; i00 = 1; i01 = 1; i10 = 0; i11 = 1; #10; sel0 = 1; sel1 = 0; i00 = 1; i01 = 1; i10 = 0; i11 = 1; #10; sel0 = 1; sel1 = 1; i00 = 1; i01 = 1; i10 = 0; i11 = 1; #10; sel0 = 1; sel1 = 1; i00 = 0; i01 = 1; i10 = 0; i11 = 1; #10; sel0 = 1; sel1 = 0; i00 = 0; i01 = 1; i10 = 0; i11 = 1; #10; sel0 = 0; sel1 = 1; i00 = 0; i01 = 1; i10 = 0; i11 = 1; #10; sel0 = 0; sel1 = 0; i00 = 0; i01 = 1; i10 = 0; i11 = 1; #10; end endmodule The testbench establishes the conditions by which the mux4_1 that was created (functionalized) in the previous slide (via the module mux4_1) can be tested in ModelSim; the testbench module is typically included in the same file as the functionalized module (which would be mux4_1 in this case).
  • 7. S Y S T E M V E R I L O G A 4 X 1 M U LT I P L E X E R module mux4_1_testbench; logic out; logic i00, i01, i11, i10, sel0, sel1; mux4_1 dut (.out, .i00, .i01, .i11, .i10, .sel0, .sel1); initial begin sel0 = 0; sel1 = 0; i00 = 1; i01 = 1; i10 = 0; i11 = 1; #10; sel0 = 1; sel1 = 1; i00 = 1; i01 = 1; i10 = 0; i11 = 1; #10; sel0 = 1; sel1 = 0; i00 = 1; i01 = 1; i10 = 0; i11 = 1; #10; sel0 = 1; sel1 = 1; i00 = 1; i01 = 1; i10 = 0; i11 = 1; #10; sel0 = 1; sel1 = 1; i00 = 0; i01 = 1; i10 = 0; i11 = 1; #10; sel0 = 1; sel1 = 0; i00 = 0; i01 = 1; i10 = 0; i11 = 1; #10; sel0 = 0; sel1 = 1; i00 = 0; i01 = 1; i10 = 0; i11 = 1; #10; sel0 = 0; sel1 = 0; i00 = 0; i01 = 1; i10 = 0; i11 = 1; #10; end endmodule Sets up the mux4_1 for testing/simulating and names it dut (device under test). Unlike the previous slide, each input and output signal does not need a separate wire name (e.g. .out (out_0)) because this module only tests mux4_1 rather than instantiating it.
  • 8. S Y S T E M V E R I L O G A 4 X 1 M U LT I P L E X E R module mux4_1_testbench; logic out; logic i00, i01, i11, i10, sel0, sel1; mux4_1 dut (.out, .i00, .i01, .i11, .i10, .sel0, .sel1); initial begin sel0 = 0; sel1 = 0; i00 = 1; i01 = 1; i10 = 0; i11 = 1; #10; sel0 = 1; sel1 = 1; i00 = 1; i01 = 1; i10 = 0; i11 = 1; #10; sel0 = 1; sel1 = 0; i00 = 1; i01 = 1; i10 = 0; i11 = 1; #10; sel0 = 1; sel1 = 1; i00 = 1; i01 = 1; i10 = 0; i11 = 1; #10; sel0 = 1; sel1 = 1; i00 = 0; i01 = 1; i10 = 0; i11 = 1; #10; sel0 = 1; sel1 = 0; i00 = 0; i01 = 1; i10 = 0; i11 = 1; #10; sel0 = 0; sel1 = 1; i00 = 0; i01 = 1; i10 = 0; i11 = 1; #10; sel0 = 0; sel1 = 0; i00 = 0; i01 = 1; i10 = 0; i11 = 1; #10; end endmodule This initial block sets up the testing of 8 of the 64 possible input (sel0, sel1, i00, i01, i10, i11) combinations to mux4_1. The outputs of this testing sequence can be viewed in ModelSim. A delay of 10 time units occurs between each input combination (as indicated by #10 after each input combination).
  • 9. S Y S T E M V E R I L O G A 4 X 1 M U LT I P L E X E R In this tutorial, we have created a 4X1 multiplexer in System Verilog using 2X1 multiplexers and created a testbench to simulate a subset of input combinations in ModelSim. out i00 sel1 sel0 i01 i10 i11 Click here for More Tutorials on Digital Logic & Circuits