SlideShare a Scribd company logo
Digital Design Using Verilog
- For Absolute Beginners
LECTURE6 : VERILOG OPERATORS
Introduction
• Normally the operators work on any specific data
types or operands to give expected results.
• As Verilog is mainly used to describe the hardware
behavior and functioning, it supports a variety of
pre-defined operators .
• But it should be always remembered that not all the
operands are synthesizable.
•Some of these operators are similar to the operators
used in the C programming language.
•Each operator type is denoted by a symbol
contd
• The different types of Operators supported are
• Assignment operator
• Arithmetic operators
• Logical operators
• relational, equality operators
• Bitwise operators
• Reduction operators
• Shift operators
• Concatenation and Conditional etc.
ASSIGNMENT OPERATOR
• Verilog uses the equal sign (=) to denote an
assignment.
• The left-hand side (LHS) of the assignment is the
target signal. The right-hand side (RHS) contains the
input arguments and can contain both signals,
constants, and operators.
• Ex: Y = a & b;
• F2 = 8’hAA;
• F1 = A ;
23 June 2020 4yayavaram@yahoo.com
• The most fundamental operators are Arithmetic
operators.
• Broadly there are two types of arithmetic operators.
(i).Unary and (ii).Binary
Unary Operators: A unary operator is an operator that
takes a single operand in an expression or a statement.
+ : addition % : modulus
- : subtraction ** : exponentiaion
* : multiplication / : divide
23 June 2020 5yayavaram@yahoo.com
ARITHMETIC OPERATORS
contd
Ex: +A ; - Y ; - (A+B) ; ** D Exponential D etc.
• Binary Operators : A binary operator is an operator
that operates on two operands and manipulates them
to return a result.
• Y = (A+B) * (B+C)
• X = (A+B) / (C-D)
• D =A + D : Addition operator surrounded by two
operands
23 June 2020 6yayavaram@yahoo.com
Illustration
• module Arithmetic (A, B, Y1, Y2, Y3, Y4, Y5);
input [2:0] A, B;
output [3:0] Y1;
output [4:0] Y3;
output [2:0] Y2, Y4, Y5;
reg [3:0] Y1;
reg [4:0] Y3;
reg [2:0] Y2, Y4, Y5;
always @(A or B)
begin
Y1=A+B; //addition operation
Y2=A-B; //subtraction operation
Y3=A*B; //multiplication operation
Y4=A/B; //division operation
Y5=A%B; //modulus of A divided by B
end
endmodule
23 June 2020
7
yayavaram@yahoo.com
% Modulus operator
• The modulus operator is denoted by the symbol %.
• For example A % B, gives the remainder when the first operand is
divided by the second, and thus is zero when B divides A exactly.
• The result of a modulus operation shall take the sign of the first
operand.
23 June 2020 8yayavaram@yahoo.com
Logical Operator
• These operators deals with true or false logic . i.e
the logical operators return either 0 or 1.
• Logical comparison operators are used in conjuction
with relational and equality operators .
• These operators are widely used in if ; While
statements. And, provide a means to perform
multiple comparisons within a single expression.
• ! : Logical negation. Ex : ! (A && B)
&& : Logical AND
|| : Logical OR Ex : A || B
23 June 2020 9yayavaram@yahoo.com
contd
• Logical operators produce 1-bit results.
• The result of && is one if none of the operands is 0.
• The result of || is 1 if at least one of the operands is
non-zero.
• The ! Operator complements its operand and
produces 1 or a 0. If X or Z appears in an operand
of the logical operand ,an X will be the result.The !
Operator has the highest precedence, followed by
&& and || .
23 June 2020 10yayavaram@yahoo.com
Examples
• Let A = 3’b101 ; B = 3’b000; C = 3’B01X
• !A = 1b0 ;
• !B = 1’b1 ;
• !C = 1’Bx
• A && B => 1’b 0 ; // since one operand is zero
• B&&C=> 1’bX;// one operand is unknown
• A || B => 1’b1 // one of the operands is non-zero
• B || C => 1’bX
23 June 2020 11yayavaram@yahoo.com
Example-2
• module ex_logical (A, B, C, D, E, F, Y);
input [2:0] A, B, C, D, E, F;
output Y;
reg Y;
always @ (A or B or C or D or E or F)
begin
if ((A= =B) && ((C>D) || !(E<F)))
Y=1;
else
Y=0;
end
endmodule
23 June 2020 12yayavaram@yahoo.com
Relational & Equality Operators
• These operators are mainly used to compare data
values.
• = = Equality ; != Not equal(Inequality)
• = = = : Case equality ; ! = = Case inequality.
• >= Greater or equal ; <= Less than or equal
• > Greater ; < Less
• Here = = ; ! = ; = = = are the equality operators
• Case equality is used to compare the values with x
or z.
23 June 2020 13yayavaram@yahoo.com
Example for Case Equality
• Let A = 1011; B = 1011
A = =B ; The result is true;
• Let A = 0110 ; B = 1011;
A == B ; The result is false ,as they are not equal.
• Suppose A= 101X ; B = 101X ;
• A ==B ; The result is unknown x
So, One has to use case Equality operator. In a case equality
A = = = B ; The result is 1 (true).
• Suppose A=101X & B= 011X.The the result will be False
i.e 0.
23 June 2020 14yayavaram@yahoo.com
Illustration
• module ex_relational (A, B, Y1, Y2, Y3, Y4);
input [2:0] A, B;
output Y1, Y2, Y3, Y4;
reg Y1, Y2, Y3, Y4;
always @(A or B)
begin
Y1=A<B;//less than
Y2=A<=B;//less than or equal to
Y3=A>B;//greater than
if (A>B)
Y4=1;
else
Y4=0;
end
endmodule
23 June 2020 15yayavaram@yahoo.com
Illustration-Equality operators
• module ex_equality (a, b, y1, y2, y3);
input [2:0] a,b;
output y1,y2;
output [2:0] y3;
reg y1,y2;
reg [2:0] y3;
always @(a or b)
begin
y1= a= =b;// y1=1 if a equivalent to b
y2=a!=b;//y2=1 if a not equivalent to b
if (a= =b) //
y3= a;
else
y3= b;
end
endmodule
23 June 2020 16yayavaram@yahoo.com
Bitwise Operators
• Verilog bitwise operators can be either unary or
binary. Result is always the size of largest operand.
• i.e the meaning is , logical bit-wise operators take
two single or multiple operands on either side of the
operator and return a single bit result.
• The only exception is the NOT operator, which
negates the single operand that follows.
• Verilog does not have the equivalent of NAND or
NOR operator, their function is implemented by
negating the AND and OR operators.
23 June 2020 17yayavaram@yahoo.com
contd
• ~ : bitwise NOT(Invert)
• & : bit wise AND
• | : bitwise OR
• ^ : bitwise Exclusive OR
• ~ ^ : bitwise exclusive NOR
• Bit wise operators operate on each bit and returns a
value that is also a bit.
23 June 2020 18yayavaram@yahoo.com
Bitwise Operators contd
• If two operands are unequal ,the smaller one is left
extended by adding zeros.
• Ex : a = 4’b1001 and b = 3’b 101.
To find a & b , the second operand is taken as
b = 4’b0101 and then logical & operation is
performed.
a & b => 4’b0001
The size of the result is 4 bits .
23 June 2020 19yayavaram@yahoo.com
Examples
• assign a => 4’b1011 ; b=> 4’b1101 ; c => 4’b0111;
• ~ a => 4’b 0100 ; ~b=> 4’b0010 ; ~c => 4’b1000;
• a & b => 4’b1001 ; b & c => 4’b 0101
• a | b => 4’b1111 ; b | c => 4’b1111
• a ^ b => 4’b 0110 ; b ^ c => 4’b 1010
• a ^ ~b => 4’b 1001 ; b ^ ~ c => 4’b 0101
23 June 2020 20yayavaram@yahoo.com
Example-2
• module ex_Bitwise (A, B, Y);
input [6:0] A;
input [5:0] B;
output [6:0] Y;
reg [6:0] Y;
always @(A or B)
begin
Y(0)=A(0)&B(0); // binary AND
Y(1)=A(1)|B(1); // binary OR
Y(2)=!(A(2)&B(2)); // negated AND (NAND)
Y(3)=!(A(3)|B(3)); // negated OR (NOR)
Y(4)=A(4)^B(4); // binary XOR
Y(5)=A(5)~^B(5); // binary XNOR
Y(6)=!A(6); // unary negation
end
endmodule
23 June 2020 21yayavaram@yahoo.com
Reduction Operators
• Reduces a vector to a single bit value. i.e a multibit
value is reduced to a single bit value.
• Majority of the times this is a unary operator.
• To say in terms of hardware , This reduction
operator works like a multiple input bits logic
gate,which accepts a single word operand and
produces a single bit as output.
• The operators are
• & and ; ~ & not and(nand) ; | or ; ~ | not or (nor)
• ^ x-or ; ~ ^ not or (x-nor)
23 June 2020 22yayavaram@yahoo.com
Examples
• For ex, in the ‘and’ gate for
the Inputs 1011 the output is 0.
• Similarly let us consider or gate as shown below.
• So, these reduction operands are reducing a multibit
operands into single bit operands.
• s.23 June 2020 23yayavaram@yahoo.com
Examples contd
• Let us consider the x-or gate .
• y = ^ A where A = 4’b0110
i.e y = 0 ^1^1^0 = 1
23 June 2020 24yayavaram@yahoo.com
Example for Reduction Operator
• module red_ex(a,b,c,y1,y2,y3);
input a, b, c ;
output y1,y2,y3 ;
wire[7:0] a,b,c ;
wire [7:0]y1,y2,y3 ;
assign a=4’b0111;
assign b=4’b0111;
assign c=4’b0100;
assign y1 = ^a // gives y1 = 1
assign y2 = &(a^b); //gives y2=0
assign y3 = ^a&^b; //gives y3 = 1
23 June 2020 25yayavaram@yahoo.com
SHIFT OPERATORS
• Generally ,the shift operators are used to shift the
operand bits either left or right.
• Shift operators require two operands. The operand
before the operator contains data to be shifted and
the operand after the operator contains the
number of single bit shift operations to be
performed.
• Verilog has two types of shift operators .
• i. Logical Shift and ii.Arithmetic shift operators.
23 June 2020 26yayavaram@yahoo.com
• This shifting is done in two ways. Either Left shift
or Right shift.
• Logical Right shift operator is denoted by >>
• Logical Left shift operator is <<.
• In logical shift vacated positions are always filled
with zero(0).
• In terms of the operation right shift means divide by
2 also.
• Similarly Left shift operation will result in multiply
of the operand by 2.
23 June 2020 27yayavaram@yahoo.com
contd
Arithmetic Shift Operators
• Right arithmetic shift is denoted by the symbol >>>
• Left arithmetic shift is denoted by <<<.
• In arithmetic shift: For signed numbers , the vacated
position is filled with sign bit value(MSB bit)
• For unsigned ,the vacated positions are filled with
zero.
23 June 2020 28yayavaram@yahoo.com
Code-Example
• module ex_shift (a, y1, y2);
input [7:0] a;
output [7:0] y1, y2;
parameter b=3; reg [7:0] y1, y2;
always @(a)
begin
y1=a<<b; //logical shift left
y2=a>>b; //logical shift right
end
• endmodule
23 June 2020 29yayavaram@yahoo.com
Concatenation Operator{,}
• The concatenation operator "{ , }" combines or
(concatenates) the bits of two or more data objects.
• The objects may be scalar (single bit) or vectored (muliple
bit).
• Mutiple concatenations may be performed with a constant
prefix and is known as replication.
• For ex: By concatenating two 4-bit operands, an 8-bit
operand is formed.
• Remember it is not direct arithmetic addition.
• Ex: Let A= 4’b1011; B=4’b 1010;
assign y = {a,b} gives y=> 8b’10111010
23 June 2020 30yayavaram@yahoo.com
Replicate Operator
• It replicates the operand for a specified number of
times.( or copied specified number of times).
• For ex: assign y = {3{3’b110}} results in
• y = 9’b110110110
23 June 2020 31yayavaram@yahoo.com
Conditional Operator(?)
• An expression using conditional operator evaluates
the logical expression before the "?".
• If the expression is true then the expression before
the colon (:) is evaluated and assigned to the output.
• If the logical expression is false then the expression
after the colon is evaluated and assigned to the
output.
23 June 2020 32yayavaram@yahoo.com
Example code
• To understand the Conditional operator lets consider
the 2:1 Mux example.
Ex: module mymux2_1(A,B,S,Y);
output Y;
input A,B,S;
assign Y= S ? B:A;
endmodule
Note: In the above ,first the ‘S’ is tested .If it is
true,then Y= B else Y = A
23 June 2020 33yayavaram@yahoo.com
The Conclusion
23 June 2020 34yayavaram@yahoo.com

More Related Content

What's hot

Modules and ports in Verilog HDL
Modules and ports in Verilog HDLModules and ports in Verilog HDL
Modules and ports in Verilog HDL
anand hd
 
Basic concepts in Verilog HDL
Basic concepts in Verilog HDLBasic concepts in Verilog HDL
Basic concepts in Verilog HDL
anand hd
 
Verilog HDL
Verilog HDLVerilog HDL
Verilog HDL
Mantra VLSI
 
Binary multipliers
Binary multipliersBinary multipliers
Binary multipliers
Syed Saeed
 
Introduction to System verilog
Introduction to System verilog Introduction to System verilog
Introduction to System verilog
Pushpa Yakkala
 
Verilog
VerilogVerilog
Verilog
Mohamed Rayan
 
Verilog Tasks & Functions
Verilog Tasks & FunctionsVerilog Tasks & Functions
Verilog Tasks & Functions
anand hd
 
verilog
verilogverilog
Verilog overview
Verilog overviewVerilog overview
Verilog overview
posdege
 
Day2 Verilog HDL Basic
Day2 Verilog HDL BasicDay2 Verilog HDL Basic
Day2 Verilog HDL BasicRon Liu
 
gate level modeling
gate level modelinggate level modeling
gate level modeling
VandanaBR2
 
System verilog important
System verilog importantSystem verilog important
System verilog important
elumalai7
 
Verilog Test Bench
Verilog Test BenchVerilog Test Bench
Verilog Test Bench
Dr.YNM
 
Data types in verilog
Data types in verilogData types in verilog
Data types in verilog
Nallapati Anindra
 
Delays in verilog
Delays in verilogDelays in verilog
Delays in verilog
JITU MISTRY
 
Verilog presentation final
Verilog presentation finalVerilog presentation final
Verilog presentation final
Ankur Gupta
 
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.
 
Verilog tutorial
Verilog tutorialVerilog tutorial
Verilog tutorial
raju reddy
 

What's hot (20)

Crash course in verilog
Crash course in verilogCrash course in verilog
Crash course in verilog
 
Modules and ports in Verilog HDL
Modules and ports in Verilog HDLModules and ports in Verilog HDL
Modules and ports in Verilog HDL
 
Basic concepts in Verilog HDL
Basic concepts in Verilog HDLBasic concepts in Verilog HDL
Basic concepts in Verilog HDL
 
Verilog HDL
Verilog HDLVerilog HDL
Verilog HDL
 
Binary multipliers
Binary multipliersBinary multipliers
Binary multipliers
 
Introduction to System verilog
Introduction to System verilog Introduction to System verilog
Introduction to System verilog
 
Verilog
VerilogVerilog
Verilog
 
Verilog Tasks & Functions
Verilog Tasks & FunctionsVerilog Tasks & Functions
Verilog Tasks & Functions
 
verilog
verilogverilog
verilog
 
Verilog overview
Verilog overviewVerilog overview
Verilog overview
 
Day2 Verilog HDL Basic
Day2 Verilog HDL BasicDay2 Verilog HDL Basic
Day2 Verilog HDL Basic
 
gate level modeling
gate level modelinggate level modeling
gate level modeling
 
System verilog important
System verilog importantSystem verilog important
System verilog important
 
Verilog Test Bench
Verilog Test BenchVerilog Test Bench
Verilog Test Bench
 
Data types in verilog
Data types in verilogData types in verilog
Data types in verilog
 
Delays in verilog
Delays in verilogDelays in verilog
Delays in verilog
 
4 bit add sub
4 bit add sub4 bit add sub
4 bit add sub
 
Verilog presentation final
Verilog presentation finalVerilog presentation final
Verilog presentation final
 
Verilog VHDL code Decoder and Encoder
Verilog VHDL code Decoder and EncoderVerilog VHDL code Decoder and Encoder
Verilog VHDL code Decoder and Encoder
 
Verilog tutorial
Verilog tutorialVerilog tutorial
Verilog tutorial
 

Similar to Verilog operators

Matlab operators
Matlab operatorsMatlab operators
Matlab operators
Aswin Pv
 
C operators
C operators C operators
C operators
AbiramiT9
 
3.OPERATORS_MB.ppt .
3.OPERATORS_MB.ppt                      .3.OPERATORS_MB.ppt                      .
3.OPERATORS_MB.ppt .
happycocoman
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++
Neeru Mittal
 
Csci101 lect09 vectorized_code
Csci101 lect09 vectorized_codeCsci101 lect09 vectorized_code
Csci101 lect09 vectorized_code
Elsayed Hemayed
 
Python PCEP Logic Bit Operations
Python PCEP Logic Bit OperationsPython PCEP Logic Bit Operations
Python PCEP Logic Bit Operations
IHTMINSTITUTE
 
3306617
33066173306617
3306617
shwetakks
 
6 operators-in-c
6 operators-in-c6 operators-in-c
6 operators-in-c
Rohit Shrivastava
 
C++ Programming Basics.pptx
C++ Programming Basics.pptxC++ Programming Basics.pptx
C++ Programming Basics.pptx
ZntalemAbebe
 
8. operators
8. operators8. operators
8. operators
Way2itech
 
Coding verilog
Coding verilogCoding verilog
Coding verilog
umarjamil10000
 
4. operators in c programming by digital wave
4. operators in  c programming by digital wave4. operators in  c programming by digital wave
4. operators in c programming by digital wave
RahulSharma4566
 
03. Operators Expressions and statements
03. Operators Expressions and statements03. Operators Expressions and statements
03. Operators Expressions and statements
Intro C# Book
 
Arithmetic and logic operations in c
Arithmetic and logic operations in cArithmetic and logic operations in c
Arithmetic and logic operations in c
Vikas Dongre
 
Operators expressions-and-statements
Operators expressions-and-statementsOperators expressions-and-statements
Operators expressions-and-statementsCtOlaf
 
Oop using JAVA
Oop using JAVAOop using JAVA
Oop using JAVA
umardanjumamaiwada
 
COM1407: C Operators
COM1407: C OperatorsCOM1407: C Operators
COM1407: C Operators
Hemantha Kulathilake
 

Similar to Verilog operators (20)

Matlab operators
Matlab operatorsMatlab operators
Matlab operators
 
C operators
C operators C operators
C operators
 
3.OPERATORS_MB.ppt .
3.OPERATORS_MB.ppt                      .3.OPERATORS_MB.ppt                      .
3.OPERATORS_MB.ppt .
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++
 
Csci101 lect09 vectorized_code
Csci101 lect09 vectorized_codeCsci101 lect09 vectorized_code
Csci101 lect09 vectorized_code
 
Python PCEP Logic Bit Operations
Python PCEP Logic Bit OperationsPython PCEP Logic Bit Operations
Python PCEP Logic Bit Operations
 
3306617
33066173306617
3306617
 
6 operators-in-c
6 operators-in-c6 operators-in-c
6 operators-in-c
 
6 operators-in-c
6 operators-in-c6 operators-in-c
6 operators-in-c
 
C++ Programming Basics.pptx
C++ Programming Basics.pptxC++ Programming Basics.pptx
C++ Programming Basics.pptx
 
8. operators
8. operators8. operators
8. operators
 
15 bitwise operators
15 bitwise operators15 bitwise operators
15 bitwise operators
 
Coding verilog
Coding verilogCoding verilog
Coding verilog
 
05 operators
05   operators05   operators
05 operators
 
4. operators in c programming by digital wave
4. operators in  c programming by digital wave4. operators in  c programming by digital wave
4. operators in c programming by digital wave
 
03. Operators Expressions and statements
03. Operators Expressions and statements03. Operators Expressions and statements
03. Operators Expressions and statements
 
Arithmetic and logic operations in c
Arithmetic and logic operations in cArithmetic and logic operations in c
Arithmetic and logic operations in c
 
Operators expressions-and-statements
Operators expressions-and-statementsOperators expressions-and-statements
Operators expressions-and-statements
 
Oop using JAVA
Oop using JAVAOop using JAVA
Oop using JAVA
 
COM1407: C Operators
COM1407: C OperatorsCOM1407: C Operators
COM1407: C Operators
 

More from Dr.YNM

Introduction to DSP.ppt
Introduction to DSP.pptIntroduction to DSP.ppt
Introduction to DSP.ppt
Dr.YNM
 
Atmel.ppt
Atmel.pptAtmel.ppt
Atmel.ppt
Dr.YNM
 
PIC Microcontrollers.ppt
PIC Microcontrollers.pptPIC Microcontrollers.ppt
PIC Microcontrollers.ppt
Dr.YNM
 
Crystalstructure-.ppt
Crystalstructure-.pptCrystalstructure-.ppt
Crystalstructure-.ppt
Dr.YNM
 
Basics of OS & RTOS.ppt
Basics of OS & RTOS.pptBasics of OS & RTOS.ppt
Basics of OS & RTOS.ppt
Dr.YNM
 
Introducion to MSP430 Microcontroller.pptx
Introducion to MSP430 Microcontroller.pptxIntroducion to MSP430 Microcontroller.pptx
Introducion to MSP430 Microcontroller.pptx
Dr.YNM
 
Microcontroller-8051.ppt
Microcontroller-8051.pptMicrocontroller-8051.ppt
Microcontroller-8051.ppt
Dr.YNM
 
Introduction to ASICs.pptx
Introduction to ASICs.pptxIntroduction to ASICs.pptx
Introduction to ASICs.pptx
Dr.YNM
 
VHDL-PRESENTATION.ppt
VHDL-PRESENTATION.pptVHDL-PRESENTATION.ppt
VHDL-PRESENTATION.ppt
Dr.YNM
 
Basics of data communications.pptx
Basics of data communications.pptxBasics of data communications.pptx
Basics of data communications.pptx
Dr.YNM
 
CPLD & FPGA Architectures and applictionsplications.pptx
CPLD & FPGA Architectures and applictionsplications.pptxCPLD & FPGA Architectures and applictionsplications.pptx
CPLD & FPGA Architectures and applictionsplications.pptx
Dr.YNM
 
Transient response of RC , RL circuits with step input
Transient response of RC , RL circuits  with step inputTransient response of RC , RL circuits  with step input
Transient response of RC , RL circuits with step input
Dr.YNM
 
CISC & RISC ARCHITECTURES
CISC & RISC ARCHITECTURESCISC & RISC ARCHITECTURES
CISC & RISC ARCHITECTURES
Dr.YNM
 
Lect 4 ARM PROCESSOR ARCHITECTURE
Lect 4 ARM PROCESSOR ARCHITECTURELect 4 ARM PROCESSOR ARCHITECTURE
Lect 4 ARM PROCESSOR ARCHITECTURE
Dr.YNM
 
Lect 3 ARM PROCESSOR ARCHITECTURE
Lect 3  ARM PROCESSOR ARCHITECTURE Lect 3  ARM PROCESSOR ARCHITECTURE
Lect 3 ARM PROCESSOR ARCHITECTURE
Dr.YNM
 
Microprocessor Architecture 4
Microprocessor Architecture  4Microprocessor Architecture  4
Microprocessor Architecture 4
Dr.YNM
 
Lect 2 ARM processor architecture
Lect 2 ARM processor architectureLect 2 ARM processor architecture
Lect 2 ARM processor architecture
Dr.YNM
 
Microprocessor Architecture-III
Microprocessor Architecture-IIIMicroprocessor Architecture-III
Microprocessor Architecture-III
Dr.YNM
 
LECT 1: ARM PROCESSORS
LECT 1: ARM PROCESSORSLECT 1: ARM PROCESSORS
LECT 1: ARM PROCESSORS
Dr.YNM
 
Microprocessor architecture II
Microprocessor architecture   IIMicroprocessor architecture   II
Microprocessor architecture II
Dr.YNM
 

More from Dr.YNM (20)

Introduction to DSP.ppt
Introduction to DSP.pptIntroduction to DSP.ppt
Introduction to DSP.ppt
 
Atmel.ppt
Atmel.pptAtmel.ppt
Atmel.ppt
 
PIC Microcontrollers.ppt
PIC Microcontrollers.pptPIC Microcontrollers.ppt
PIC Microcontrollers.ppt
 
Crystalstructure-.ppt
Crystalstructure-.pptCrystalstructure-.ppt
Crystalstructure-.ppt
 
Basics of OS & RTOS.ppt
Basics of OS & RTOS.pptBasics of OS & RTOS.ppt
Basics of OS & RTOS.ppt
 
Introducion to MSP430 Microcontroller.pptx
Introducion to MSP430 Microcontroller.pptxIntroducion to MSP430 Microcontroller.pptx
Introducion to MSP430 Microcontroller.pptx
 
Microcontroller-8051.ppt
Microcontroller-8051.pptMicrocontroller-8051.ppt
Microcontroller-8051.ppt
 
Introduction to ASICs.pptx
Introduction to ASICs.pptxIntroduction to ASICs.pptx
Introduction to ASICs.pptx
 
VHDL-PRESENTATION.ppt
VHDL-PRESENTATION.pptVHDL-PRESENTATION.ppt
VHDL-PRESENTATION.ppt
 
Basics of data communications.pptx
Basics of data communications.pptxBasics of data communications.pptx
Basics of data communications.pptx
 
CPLD & FPGA Architectures and applictionsplications.pptx
CPLD & FPGA Architectures and applictionsplications.pptxCPLD & FPGA Architectures and applictionsplications.pptx
CPLD & FPGA Architectures and applictionsplications.pptx
 
Transient response of RC , RL circuits with step input
Transient response of RC , RL circuits  with step inputTransient response of RC , RL circuits  with step input
Transient response of RC , RL circuits with step input
 
CISC & RISC ARCHITECTURES
CISC & RISC ARCHITECTURESCISC & RISC ARCHITECTURES
CISC & RISC ARCHITECTURES
 
Lect 4 ARM PROCESSOR ARCHITECTURE
Lect 4 ARM PROCESSOR ARCHITECTURELect 4 ARM PROCESSOR ARCHITECTURE
Lect 4 ARM PROCESSOR ARCHITECTURE
 
Lect 3 ARM PROCESSOR ARCHITECTURE
Lect 3  ARM PROCESSOR ARCHITECTURE Lect 3  ARM PROCESSOR ARCHITECTURE
Lect 3 ARM PROCESSOR ARCHITECTURE
 
Microprocessor Architecture 4
Microprocessor Architecture  4Microprocessor Architecture  4
Microprocessor Architecture 4
 
Lect 2 ARM processor architecture
Lect 2 ARM processor architectureLect 2 ARM processor architecture
Lect 2 ARM processor architecture
 
Microprocessor Architecture-III
Microprocessor Architecture-IIIMicroprocessor Architecture-III
Microprocessor Architecture-III
 
LECT 1: ARM PROCESSORS
LECT 1: ARM PROCESSORSLECT 1: ARM PROCESSORS
LECT 1: ARM PROCESSORS
 
Microprocessor architecture II
Microprocessor architecture   IIMicroprocessor architecture   II
Microprocessor architecture II
 

Recently uploaded

Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
Intella Parts
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
FluxPrime1
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 
addressing modes in computer architecture
addressing modes  in computer architectureaddressing modes  in computer architecture
addressing modes in computer architecture
ShahidSultan24
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
Kamal Acharya
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
Robbie Edward Sayers
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
Pipe Restoration Solutions
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
VENKATESHvenky89705
 
Courier management system project report.pdf
Courier management system project report.pdfCourier management system project report.pdf
Courier management system project report.pdf
Kamal Acharya
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
MdTanvirMahtab2
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
AhmedHussein950959
 
Democratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek AryaDemocratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek Arya
abh.arya
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
Jayaprasanna4
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
Kamal Acharya
 

Recently uploaded (20)

Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 
addressing modes in computer architecture
addressing modes  in computer architectureaddressing modes  in computer architecture
addressing modes in computer architecture
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
 
Courier management system project report.pdf
Courier management system project report.pdfCourier management system project report.pdf
Courier management system project report.pdf
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
Democratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek AryaDemocratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek Arya
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
 

Verilog operators

  • 1. Digital Design Using Verilog - For Absolute Beginners LECTURE6 : VERILOG OPERATORS
  • 2. Introduction • Normally the operators work on any specific data types or operands to give expected results. • As Verilog is mainly used to describe the hardware behavior and functioning, it supports a variety of pre-defined operators . • But it should be always remembered that not all the operands are synthesizable. •Some of these operators are similar to the operators used in the C programming language. •Each operator type is denoted by a symbol
  • 3. contd • The different types of Operators supported are • Assignment operator • Arithmetic operators • Logical operators • relational, equality operators • Bitwise operators • Reduction operators • Shift operators • Concatenation and Conditional etc.
  • 4. ASSIGNMENT OPERATOR • Verilog uses the equal sign (=) to denote an assignment. • The left-hand side (LHS) of the assignment is the target signal. The right-hand side (RHS) contains the input arguments and can contain both signals, constants, and operators. • Ex: Y = a & b; • F2 = 8’hAA; • F1 = A ; 23 June 2020 4yayavaram@yahoo.com
  • 5. • The most fundamental operators are Arithmetic operators. • Broadly there are two types of arithmetic operators. (i).Unary and (ii).Binary Unary Operators: A unary operator is an operator that takes a single operand in an expression or a statement. + : addition % : modulus - : subtraction ** : exponentiaion * : multiplication / : divide 23 June 2020 5yayavaram@yahoo.com ARITHMETIC OPERATORS
  • 6. contd Ex: +A ; - Y ; - (A+B) ; ** D Exponential D etc. • Binary Operators : A binary operator is an operator that operates on two operands and manipulates them to return a result. • Y = (A+B) * (B+C) • X = (A+B) / (C-D) • D =A + D : Addition operator surrounded by two operands 23 June 2020 6yayavaram@yahoo.com
  • 7. Illustration • module Arithmetic (A, B, Y1, Y2, Y3, Y4, Y5); input [2:0] A, B; output [3:0] Y1; output [4:0] Y3; output [2:0] Y2, Y4, Y5; reg [3:0] Y1; reg [4:0] Y3; reg [2:0] Y2, Y4, Y5; always @(A or B) begin Y1=A+B; //addition operation Y2=A-B; //subtraction operation Y3=A*B; //multiplication operation Y4=A/B; //division operation Y5=A%B; //modulus of A divided by B end endmodule 23 June 2020 7 yayavaram@yahoo.com
  • 8. % Modulus operator • The modulus operator is denoted by the symbol %. • For example A % B, gives the remainder when the first operand is divided by the second, and thus is zero when B divides A exactly. • The result of a modulus operation shall take the sign of the first operand. 23 June 2020 8yayavaram@yahoo.com
  • 9. Logical Operator • These operators deals with true or false logic . i.e the logical operators return either 0 or 1. • Logical comparison operators are used in conjuction with relational and equality operators . • These operators are widely used in if ; While statements. And, provide a means to perform multiple comparisons within a single expression. • ! : Logical negation. Ex : ! (A && B) && : Logical AND || : Logical OR Ex : A || B 23 June 2020 9yayavaram@yahoo.com
  • 10. contd • Logical operators produce 1-bit results. • The result of && is one if none of the operands is 0. • The result of || is 1 if at least one of the operands is non-zero. • The ! Operator complements its operand and produces 1 or a 0. If X or Z appears in an operand of the logical operand ,an X will be the result.The ! Operator has the highest precedence, followed by && and || . 23 June 2020 10yayavaram@yahoo.com
  • 11. Examples • Let A = 3’b101 ; B = 3’b000; C = 3’B01X • !A = 1b0 ; • !B = 1’b1 ; • !C = 1’Bx • A && B => 1’b 0 ; // since one operand is zero • B&&C=> 1’bX;// one operand is unknown • A || B => 1’b1 // one of the operands is non-zero • B || C => 1’bX 23 June 2020 11yayavaram@yahoo.com
  • 12. Example-2 • module ex_logical (A, B, C, D, E, F, Y); input [2:0] A, B, C, D, E, F; output Y; reg Y; always @ (A or B or C or D or E or F) begin if ((A= =B) && ((C>D) || !(E<F))) Y=1; else Y=0; end endmodule 23 June 2020 12yayavaram@yahoo.com
  • 13. Relational & Equality Operators • These operators are mainly used to compare data values. • = = Equality ; != Not equal(Inequality) • = = = : Case equality ; ! = = Case inequality. • >= Greater or equal ; <= Less than or equal • > Greater ; < Less • Here = = ; ! = ; = = = are the equality operators • Case equality is used to compare the values with x or z. 23 June 2020 13yayavaram@yahoo.com
  • 14. Example for Case Equality • Let A = 1011; B = 1011 A = =B ; The result is true; • Let A = 0110 ; B = 1011; A == B ; The result is false ,as they are not equal. • Suppose A= 101X ; B = 101X ; • A ==B ; The result is unknown x So, One has to use case Equality operator. In a case equality A = = = B ; The result is 1 (true). • Suppose A=101X & B= 011X.The the result will be False i.e 0. 23 June 2020 14yayavaram@yahoo.com
  • 15. Illustration • module ex_relational (A, B, Y1, Y2, Y3, Y4); input [2:0] A, B; output Y1, Y2, Y3, Y4; reg Y1, Y2, Y3, Y4; always @(A or B) begin Y1=A<B;//less than Y2=A<=B;//less than or equal to Y3=A>B;//greater than if (A>B) Y4=1; else Y4=0; end endmodule 23 June 2020 15yayavaram@yahoo.com
  • 16. Illustration-Equality operators • module ex_equality (a, b, y1, y2, y3); input [2:0] a,b; output y1,y2; output [2:0] y3; reg y1,y2; reg [2:0] y3; always @(a or b) begin y1= a= =b;// y1=1 if a equivalent to b y2=a!=b;//y2=1 if a not equivalent to b if (a= =b) // y3= a; else y3= b; end endmodule 23 June 2020 16yayavaram@yahoo.com
  • 17. Bitwise Operators • Verilog bitwise operators can be either unary or binary. Result is always the size of largest operand. • i.e the meaning is , logical bit-wise operators take two single or multiple operands on either side of the operator and return a single bit result. • The only exception is the NOT operator, which negates the single operand that follows. • Verilog does not have the equivalent of NAND or NOR operator, their function is implemented by negating the AND and OR operators. 23 June 2020 17yayavaram@yahoo.com
  • 18. contd • ~ : bitwise NOT(Invert) • & : bit wise AND • | : bitwise OR • ^ : bitwise Exclusive OR • ~ ^ : bitwise exclusive NOR • Bit wise operators operate on each bit and returns a value that is also a bit. 23 June 2020 18yayavaram@yahoo.com
  • 19. Bitwise Operators contd • If two operands are unequal ,the smaller one is left extended by adding zeros. • Ex : a = 4’b1001 and b = 3’b 101. To find a & b , the second operand is taken as b = 4’b0101 and then logical & operation is performed. a & b => 4’b0001 The size of the result is 4 bits . 23 June 2020 19yayavaram@yahoo.com
  • 20. Examples • assign a => 4’b1011 ; b=> 4’b1101 ; c => 4’b0111; • ~ a => 4’b 0100 ; ~b=> 4’b0010 ; ~c => 4’b1000; • a & b => 4’b1001 ; b & c => 4’b 0101 • a | b => 4’b1111 ; b | c => 4’b1111 • a ^ b => 4’b 0110 ; b ^ c => 4’b 1010 • a ^ ~b => 4’b 1001 ; b ^ ~ c => 4’b 0101 23 June 2020 20yayavaram@yahoo.com
  • 21. Example-2 • module ex_Bitwise (A, B, Y); input [6:0] A; input [5:0] B; output [6:0] Y; reg [6:0] Y; always @(A or B) begin Y(0)=A(0)&B(0); // binary AND Y(1)=A(1)|B(1); // binary OR Y(2)=!(A(2)&B(2)); // negated AND (NAND) Y(3)=!(A(3)|B(3)); // negated OR (NOR) Y(4)=A(4)^B(4); // binary XOR Y(5)=A(5)~^B(5); // binary XNOR Y(6)=!A(6); // unary negation end endmodule 23 June 2020 21yayavaram@yahoo.com
  • 22. Reduction Operators • Reduces a vector to a single bit value. i.e a multibit value is reduced to a single bit value. • Majority of the times this is a unary operator. • To say in terms of hardware , This reduction operator works like a multiple input bits logic gate,which accepts a single word operand and produces a single bit as output. • The operators are • & and ; ~ & not and(nand) ; | or ; ~ | not or (nor) • ^ x-or ; ~ ^ not or (x-nor) 23 June 2020 22yayavaram@yahoo.com
  • 23. Examples • For ex, in the ‘and’ gate for the Inputs 1011 the output is 0. • Similarly let us consider or gate as shown below. • So, these reduction operands are reducing a multibit operands into single bit operands. • s.23 June 2020 23yayavaram@yahoo.com
  • 24. Examples contd • Let us consider the x-or gate . • y = ^ A where A = 4’b0110 i.e y = 0 ^1^1^0 = 1 23 June 2020 24yayavaram@yahoo.com
  • 25. Example for Reduction Operator • module red_ex(a,b,c,y1,y2,y3); input a, b, c ; output y1,y2,y3 ; wire[7:0] a,b,c ; wire [7:0]y1,y2,y3 ; assign a=4’b0111; assign b=4’b0111; assign c=4’b0100; assign y1 = ^a // gives y1 = 1 assign y2 = &(a^b); //gives y2=0 assign y3 = ^a&^b; //gives y3 = 1 23 June 2020 25yayavaram@yahoo.com
  • 26. SHIFT OPERATORS • Generally ,the shift operators are used to shift the operand bits either left or right. • Shift operators require two operands. The operand before the operator contains data to be shifted and the operand after the operator contains the number of single bit shift operations to be performed. • Verilog has two types of shift operators . • i. Logical Shift and ii.Arithmetic shift operators. 23 June 2020 26yayavaram@yahoo.com
  • 27. • This shifting is done in two ways. Either Left shift or Right shift. • Logical Right shift operator is denoted by >> • Logical Left shift operator is <<. • In logical shift vacated positions are always filled with zero(0). • In terms of the operation right shift means divide by 2 also. • Similarly Left shift operation will result in multiply of the operand by 2. 23 June 2020 27yayavaram@yahoo.com contd
  • 28. Arithmetic Shift Operators • Right arithmetic shift is denoted by the symbol >>> • Left arithmetic shift is denoted by <<<. • In arithmetic shift: For signed numbers , the vacated position is filled with sign bit value(MSB bit) • For unsigned ,the vacated positions are filled with zero. 23 June 2020 28yayavaram@yahoo.com
  • 29. Code-Example • module ex_shift (a, y1, y2); input [7:0] a; output [7:0] y1, y2; parameter b=3; reg [7:0] y1, y2; always @(a) begin y1=a<<b; //logical shift left y2=a>>b; //logical shift right end • endmodule 23 June 2020 29yayavaram@yahoo.com
  • 30. Concatenation Operator{,} • The concatenation operator "{ , }" combines or (concatenates) the bits of two or more data objects. • The objects may be scalar (single bit) or vectored (muliple bit). • Mutiple concatenations may be performed with a constant prefix and is known as replication. • For ex: By concatenating two 4-bit operands, an 8-bit operand is formed. • Remember it is not direct arithmetic addition. • Ex: Let A= 4’b1011; B=4’b 1010; assign y = {a,b} gives y=> 8b’10111010 23 June 2020 30yayavaram@yahoo.com
  • 31. Replicate Operator • It replicates the operand for a specified number of times.( or copied specified number of times). • For ex: assign y = {3{3’b110}} results in • y = 9’b110110110 23 June 2020 31yayavaram@yahoo.com
  • 32. Conditional Operator(?) • An expression using conditional operator evaluates the logical expression before the "?". • If the expression is true then the expression before the colon (:) is evaluated and assigned to the output. • If the logical expression is false then the expression after the colon is evaluated and assigned to the output. 23 June 2020 32yayavaram@yahoo.com
  • 33. Example code • To understand the Conditional operator lets consider the 2:1 Mux example. Ex: module mymux2_1(A,B,S,Y); output Y; input A,B,S; assign Y= S ? B:A; endmodule Note: In the above ,first the ‘S’ is tested .If it is true,then Y= B else Y = A 23 June 2020 33yayavaram@yahoo.com
  • 34. The Conclusion 23 June 2020 34yayavaram@yahoo.com

Editor's Notes

  1. If the value of S is 1 ,then Y= B other wise Y= A
  2. If the value of S is 1 ,then Y= B other wise Y= A