SlideShare a Scribd company logo
1 of 2
Download to read offline
Program 1 Legal uses of the wire element
1 wire A, B, C, D, E; // simple 1-bit wide wires
2 wire [8:0] Wide; // a 9-bit wide wire
3 reg I;
4
5 assign A = B & C; // using a wire with an assign statement
6
7 always @(B or C) begin
8 I = B | C; // using wires on the right -hand side of an always@
9 // assignment
10 end
11
12 mymodule mymodule_instance (.In (D),
13 .Out(E)); // using a wire as the output of a module
1
Verilog: wire vs. reg
Ahmed Abdelazeem
KAUST, PGDip
Version 0.2023.11.20
November, 20, 2023
1 Introduction
Sections 1.1 to 1.3 discuss the difference between wire and reg in Verilog, and when to use each of them.
1.1 wire Elements (Combinational logic)
wire elements are simple wires (or busses of arbitrary width) in Verilog designs. The following are syntax
rules when using wires:
1. wire elements are used to connect input and output ports of a module instantiation together with
some other element in your design.
2. wire elements are used as inputs and outputs within an actual module declaration.
3. wire elements must be driven by something, and cannot store a value without being driven.
4. wire elements cannot be used as the left-hand side of an = or <= sign in an always@ block.
5. wire elements are the only legal type on the left-hand side of an assign statement.
6. wire elements are a stateless way of connecting two peices in a Verilog-based design.
7. wire elements can only be used to model combinational logic.
Program 1 shows various legal uses of the wire element.
1.2 reg Elements (Combinational and Sequential logic)
reg are similar to wires, but can be used to store information (‘state’) like registers. The following are
syntax rules when using reg elements.
1. reg elements can be connected to the input port of a module instantiation.
2. reg elements cannot be connected to the output port of a module instantiation.
3. reg elements can be used as outputs within an actual module declaration.
4. reg elements cannot be used as inputs within an actual module declaration.
5. reg is the only legal type on the left-hand side of an always@ block = or <= sign.
6. reg is the only legal type on the left-hand side of an initial block = sign (used in Test Benches).
7. reg cannot be used on the left-hand side of an assign statement.
8. reg can be used to create registers when used in conjunction with always@(posedge Clock) blocks.
9. reg can, therefore, be used to create both combinational and sequential logic.
Program 2 shows various legal uses of the reg element.
Program 2 Legal uses of the reg element
1 wire A, B;
2 reg I, J, K; // simple 1-bit wide reg elements
3 reg [8:0] Wide; // a 9-bit wide reg element
4
5 always @(A or B) begin
6 I = A | B; // using a reg as the left -hand side of an always@
7 // assignment
8 end
9
10 initial begin // using a reg in an initial block
11 J = 1’b1;
12 #1
13 J = 1’b0;
14 end
15
16 always @(posedge Clock) begin
17 K <= I; // using a reg to create a positive -edge -triggered register
18 end
1.3 When wire and reg Elements are Interchangable
wire and reg elements can be used interchangably in certain situations:
1. Both can appear on the right-hand side of assign statements and always@ block = or <= signs.
2. Both can be connected to the input ports of module instantiations.
2

More Related Content

Similar to wire vs. reg.pdf

IRJET- Intelligent Car Parking System
IRJET-  	  Intelligent Car Parking SystemIRJET-  	  Intelligent Car Parking System
IRJET- Intelligent Car Parking SystemIRJET Journal
 
IRJET- Braille Oriented Classroom
IRJET-  	  Braille Oriented ClassroomIRJET-  	  Braille Oriented Classroom
IRJET- Braille Oriented ClassroomIRJET Journal
 
IRJET- To Design 16 bit Synchronous Microprocessor using VHDL on FPGA
IRJET-  	  To Design 16 bit Synchronous Microprocessor using VHDL on FPGAIRJET-  	  To Design 16 bit Synchronous Microprocessor using VHDL on FPGA
IRJET- To Design 16 bit Synchronous Microprocessor using VHDL on FPGAIRJET Journal
 
Microprocessorlabmanual ee0310
Microprocessorlabmanual ee0310Microprocessorlabmanual ee0310
Microprocessorlabmanual ee0310Hari Prakash
 
Micro Processor Lab Manual!
Micro Processor Lab Manual!Micro Processor Lab Manual!
Micro Processor Lab Manual!PRABHAHARAN429
 
8051 data type and directives
8051 data type and directives8051 data type and directives
8051 data type and directivesSARITHA REDDY
 
8051 data types and directives
8051 data types and directives8051 data types and directives
8051 data types and directivesSARITHA REDDY
 
IRJET- FPGA Implementation of Orthogonal Codes for Efficient Digital Communic...
IRJET- FPGA Implementation of Orthogonal Codes for Efficient Digital Communic...IRJET- FPGA Implementation of Orthogonal Codes for Efficient Digital Communic...
IRJET- FPGA Implementation of Orthogonal Codes for Efficient Digital Communic...IRJET Journal
 
IRJET- Bluetooth Controlled Metal Detecting Robot with Message Alert
IRJET- Bluetooth Controlled Metal Detecting Robot with Message AlertIRJET- Bluetooth Controlled Metal Detecting Robot with Message Alert
IRJET- Bluetooth Controlled Metal Detecting Robot with Message AlertIRJET Journal
 
IRJET- Design & Implementation of Black Box in Automobiles System
IRJET-  	  Design & Implementation of Black Box in Automobiles SystemIRJET-  	  Design & Implementation of Black Box in Automobiles System
IRJET- Design & Implementation of Black Box in Automobiles SystemIRJET Journal
 
Boimetric using 8051
Boimetric  using 8051 Boimetric  using 8051
Boimetric using 8051 Shilpa Nayak
 
IRJET-Hardware Co-Simulation of Classical Edge Detection Algorithms using Xil...
IRJET-Hardware Co-Simulation of Classical Edge Detection Algorithms using Xil...IRJET-Hardware Co-Simulation of Classical Edge Detection Algorithms using Xil...
IRJET-Hardware Co-Simulation of Classical Edge Detection Algorithms using Xil...IRJET Journal
 
Tutorial on avr atmega8 microcontroller, architecture and its applications
Tutorial on avr atmega8 microcontroller, architecture and its applicationsTutorial on avr atmega8 microcontroller, architecture and its applications
Tutorial on avr atmega8 microcontroller, architecture and its applicationsEdgefxkits & Solutions
 
IRJET- Single Precision Floating Point Arithmetic using VHDL Coding
IRJET-  	  Single Precision Floating Point Arithmetic using VHDL CodingIRJET-  	  Single Precision Floating Point Arithmetic using VHDL Coding
IRJET- Single Precision Floating Point Arithmetic using VHDL CodingIRJET Journal
 
IRJET- Line following and Obstacle avoiding Bluetooth Controlled Surveillance...
IRJET- Line following and Obstacle avoiding Bluetooth Controlled Surveillance...IRJET- Line following and Obstacle avoiding Bluetooth Controlled Surveillance...
IRJET- Line following and Obstacle avoiding Bluetooth Controlled Surveillance...IRJET Journal
 
Design and Construction of Parcel Wrapping System using Arduino
Design and Construction of Parcel Wrapping System using ArduinoDesign and Construction of Parcel Wrapping System using Arduino
Design and Construction of Parcel Wrapping System using Arduinoijtsrd
 
Robotics Report final.compressed (1)
Robotics Report final.compressed (1)Robotics Report final.compressed (1)
Robotics Report final.compressed (1)Kael Kristjanson
 
Analysis Of Transmission Line Using MATLAB Software
Analysis Of Transmission Line Using MATLAB SoftwareAnalysis Of Transmission Line Using MATLAB Software
Analysis Of Transmission Line Using MATLAB SoftwareAllison Thompson
 

Similar to wire vs. reg.pdf (20)

IRJET- Intelligent Car Parking System
IRJET-  	  Intelligent Car Parking SystemIRJET-  	  Intelligent Car Parking System
IRJET- Intelligent Car Parking System
 
IRJET- Braille Oriented Classroom
IRJET-  	  Braille Oriented ClassroomIRJET-  	  Braille Oriented Classroom
IRJET- Braille Oriented Classroom
 
IRJET- To Design 16 bit Synchronous Microprocessor using VHDL on FPGA
IRJET-  	  To Design 16 bit Synchronous Microprocessor using VHDL on FPGAIRJET-  	  To Design 16 bit Synchronous Microprocessor using VHDL on FPGA
IRJET- To Design 16 bit Synchronous Microprocessor using VHDL on FPGA
 
Microprocessorlabmanual ee0310
Microprocessorlabmanual ee0310Microprocessorlabmanual ee0310
Microprocessorlabmanual ee0310
 
Micro Processor Lab Manual!
Micro Processor Lab Manual!Micro Processor Lab Manual!
Micro Processor Lab Manual!
 
8051 data type and directives
8051 data type and directives8051 data type and directives
8051 data type and directives
 
8051 data types and directives
8051 data types and directives8051 data types and directives
8051 data types and directives
 
IRJET- FPGA Implementation of Orthogonal Codes for Efficient Digital Communic...
IRJET- FPGA Implementation of Orthogonal Codes for Efficient Digital Communic...IRJET- FPGA Implementation of Orthogonal Codes for Efficient Digital Communic...
IRJET- FPGA Implementation of Orthogonal Codes for Efficient Digital Communic...
 
IRJET- Bluetooth Controlled Metal Detecting Robot with Message Alert
IRJET- Bluetooth Controlled Metal Detecting Robot with Message AlertIRJET- Bluetooth Controlled Metal Detecting Robot with Message Alert
IRJET- Bluetooth Controlled Metal Detecting Robot with Message Alert
 
IRJET- Design & Implementation of Black Box in Automobiles System
IRJET-  	  Design & Implementation of Black Box in Automobiles SystemIRJET-  	  Design & Implementation of Black Box in Automobiles System
IRJET- Design & Implementation of Black Box in Automobiles System
 
Boimetric using 8051
Boimetric  using 8051 Boimetric  using 8051
Boimetric using 8051
 
IRJET-Hardware Co-Simulation of Classical Edge Detection Algorithms using Xil...
IRJET-Hardware Co-Simulation of Classical Edge Detection Algorithms using Xil...IRJET-Hardware Co-Simulation of Classical Edge Detection Algorithms using Xil...
IRJET-Hardware Co-Simulation of Classical Edge Detection Algorithms using Xil...
 
Tutorial on avr atmega8 microcontroller, architecture and its applications
Tutorial on avr atmega8 microcontroller, architecture and its applicationsTutorial on avr atmega8 microcontroller, architecture and its applications
Tutorial on avr atmega8 microcontroller, architecture and its applications
 
IRJET- Single Precision Floating Point Arithmetic using VHDL Coding
IRJET-  	  Single Precision Floating Point Arithmetic using VHDL CodingIRJET-  	  Single Precision Floating Point Arithmetic using VHDL Coding
IRJET- Single Precision Floating Point Arithmetic using VHDL Coding
 
IRJET- Line following and Obstacle avoiding Bluetooth Controlled Surveillance...
IRJET- Line following and Obstacle avoiding Bluetooth Controlled Surveillance...IRJET- Line following and Obstacle avoiding Bluetooth Controlled Surveillance...
IRJET- Line following and Obstacle avoiding Bluetooth Controlled Surveillance...
 
Design and Construction of Parcel Wrapping System using Arduino
Design and Construction of Parcel Wrapping System using ArduinoDesign and Construction of Parcel Wrapping System using Arduino
Design and Construction of Parcel Wrapping System using Arduino
 
Robotics Report final.compressed (1)
Robotics Report final.compressed (1)Robotics Report final.compressed (1)
Robotics Report final.compressed (1)
 
Project-Synopsis
Project-SynopsisProject-Synopsis
Project-Synopsis
 
Hd6
Hd6Hd6
Hd6
 
Analysis Of Transmission Line Using MATLAB Software
Analysis Of Transmission Line Using MATLAB SoftwareAnalysis Of Transmission Line Using MATLAB Software
Analysis Of Transmission Line Using MATLAB Software
 

More from Ahmed Abdelazeem

8. Clock Tree Synthesis.pdf
8. Clock Tree Synthesis.pdf8. Clock Tree Synthesis.pdf
8. Clock Tree Synthesis.pdfAhmed Abdelazeem
 
5. Data and Timing Setup Introduction.pdf
5. Data and Timing Setup Introduction.pdf5. Data and Timing Setup Introduction.pdf
5. Data and Timing Setup Introduction.pdfAhmed Abdelazeem
 
What is the Difference Between the target_library and link_library Variables?
What is the Difference Between the target_library and link_library Variables?What is the Difference Between the target_library and link_library Variables?
What is the Difference Between the target_library and link_library Variables?Ahmed Abdelazeem
 
Physical Implementation: I/O Pad Insertion for Innovus.pdf
Physical Implementation: I/O Pad Insertion for Innovus.pdfPhysical Implementation: I/O Pad Insertion for Innovus.pdf
Physical Implementation: I/O Pad Insertion for Innovus.pdfAhmed Abdelazeem
 
Learn Makefiles With the tastiest examples
Learn Makefiles With the tastiest examplesLearn Makefiles With the tastiest examples
Learn Makefiles With the tastiest examplesAhmed Abdelazeem
 
1. Introduction to PnR.pptx
1. Introduction to PnR.pptx1. Introduction to PnR.pptx
1. Introduction to PnR.pptxAhmed Abdelazeem
 
4. Formal Equivalence Checking (Formality).pptx
4. Formal Equivalence Checking (Formality).pptx4. Formal Equivalence Checking (Formality).pptx
4. Formal Equivalence Checking (Formality).pptxAhmed Abdelazeem
 

More from Ahmed Abdelazeem (20)

10. Signoff.pdf
10. Signoff.pdf10. Signoff.pdf
10. Signoff.pdf
 
9. Routing.pdf
9. Routing.pdf9. Routing.pdf
9. Routing.pdf
 
8. Clock Tree Synthesis.pdf
8. Clock Tree Synthesis.pdf8. Clock Tree Synthesis.pdf
8. Clock Tree Synthesis.pdf
 
7. Placement.pdf
7. Placement.pdf7. Placement.pdf
7. Placement.pdf
 
6. Design Planning.pdf
6. Design Planning.pdf6. Design Planning.pdf
6. Design Planning.pdf
 
5. Data and Timing Setup Introduction.pdf
5. Data and Timing Setup Introduction.pdf5. Data and Timing Setup Introduction.pdf
5. Data and Timing Setup Introduction.pdf
 
What is the Difference Between the target_library and link_library Variables?
What is the Difference Between the target_library and link_library Variables?What is the Difference Between the target_library and link_library Variables?
What is the Difference Between the target_library and link_library Variables?
 
Physical Implementation: I/O Pad Insertion for Innovus.pdf
Physical Implementation: I/O Pad Insertion for Innovus.pdfPhysical Implementation: I/O Pad Insertion for Innovus.pdf
Physical Implementation: I/O Pad Insertion for Innovus.pdf
 
Learn Makefiles With the tastiest examples
Learn Makefiles With the tastiest examplesLearn Makefiles With the tastiest examples
Learn Makefiles With the tastiest examples
 
ready_valid_interface.pdf
ready_valid_interface.pdfready_valid_interface.pdf
ready_valid_interface.pdf
 
always_at_blocks.pdf
always_at_blocks.pdfalways_at_blocks.pdf
always_at_blocks.pdf
 
1. Introduction to PnR.pptx
1. Introduction to PnR.pptx1. Introduction to PnR.pptx
1. Introduction to PnR.pptx
 
5. DFT.pptx
5. DFT.pptx5. DFT.pptx
5. DFT.pptx
 
4. Formal Equivalence Checking (Formality).pptx
4. Formal Equivalence Checking (Formality).pptx4. Formal Equivalence Checking (Formality).pptx
4. Formal Equivalence Checking (Formality).pptx
 
3. Synthesis.pptx
3. Synthesis.pptx3. Synthesis.pptx
3. Synthesis.pptx
 
Routing.pdf
Routing.pdfRouting.pdf
Routing.pdf
 
Clock Tree Synthesis.pdf
Clock Tree Synthesis.pdfClock Tree Synthesis.pdf
Clock Tree Synthesis.pdf
 
ASIC_Design.pdf
ASIC_Design.pdfASIC_Design.pdf
ASIC_Design.pdf
 
Placement.pdf
Placement.pdfPlacement.pdf
Placement.pdf
 
STA.pdf
STA.pdfSTA.pdf
STA.pdf
 

Recently uploaded

9004554577, Get Adorable Call Girls service. Book call girls & escort service...
9004554577, Get Adorable Call Girls service. Book call girls & escort service...9004554577, Get Adorable Call Girls service. Book call girls & escort service...
9004554577, Get Adorable Call Girls service. Book call girls & escort service...Pooja Nehwal
 
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Kalyan callg Girls, { 07738631006 } || Call Girl In Kalyan Women Seeking Men ...
Kalyan callg Girls, { 07738631006 } || Call Girl In Kalyan Women Seeking Men ...Kalyan callg Girls, { 07738631006 } || Call Girl In Kalyan Women Seeking Men ...
Kalyan callg Girls, { 07738631006 } || Call Girl In Kalyan Women Seeking Men ...Pooja Nehwal
 
VIP Call Girls Dharwad 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Dharwad 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Dharwad 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Dharwad 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Lucknow 💋 Call Girls Adil Nagar | ₹,9500 Pay Cash 8923113531 Free Home Delive...
Lucknow 💋 Call Girls Adil Nagar | ₹,9500 Pay Cash 8923113531 Free Home Delive...Lucknow 💋 Call Girls Adil Nagar | ₹,9500 Pay Cash 8923113531 Free Home Delive...
Lucknow 💋 Call Girls Adil Nagar | ₹,9500 Pay Cash 8923113531 Free Home Delive...anilsa9823
 
Top Rated Pune Call Girls Shirwal ⟟ 6297143586 ⟟ Call Me For Genuine Sex Ser...
Top Rated  Pune Call Girls Shirwal ⟟ 6297143586 ⟟ Call Me For Genuine Sex Ser...Top Rated  Pune Call Girls Shirwal ⟟ 6297143586 ⟟ Call Me For Genuine Sex Ser...
Top Rated Pune Call Girls Shirwal ⟟ 6297143586 ⟟ Call Me For Genuine Sex Ser...Call Girls in Nagpur High Profile
 
Kothanur Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...
Kothanur Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...Kothanur Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...
Kothanur Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...amitlee9823
 
Shikrapur Call Girls Most Awaited Fun 6297143586 High Profiles young Beautie...
Shikrapur Call Girls Most Awaited Fun  6297143586 High Profiles young Beautie...Shikrapur Call Girls Most Awaited Fun  6297143586 High Profiles young Beautie...
Shikrapur Call Girls Most Awaited Fun 6297143586 High Profiles young Beautie...tanu pandey
 
Deira Dubai Escorts +0561951007 Escort Service in Dubai by Dubai Escort Girls
Deira Dubai Escorts +0561951007 Escort Service in Dubai by Dubai Escort GirlsDeira Dubai Escorts +0561951007 Escort Service in Dubai by Dubai Escort Girls
Deira Dubai Escorts +0561951007 Escort Service in Dubai by Dubai Escort GirlsEscorts Call Girls
 
Lubrication and it's types and properties of the libricabt
Lubrication and it's types and properties of the libricabtLubrication and it's types and properties of the libricabt
Lubrication and it's types and properties of the libricabtdineshkumar430venkat
 
VVIP Pune Call Girls Karve Nagar (7001035870) Pune Escorts Nearby with Comple...
VVIP Pune Call Girls Karve Nagar (7001035870) Pune Escorts Nearby with Comple...VVIP Pune Call Girls Karve Nagar (7001035870) Pune Escorts Nearby with Comple...
VVIP Pune Call Girls Karve Nagar (7001035870) Pune Escorts Nearby with Comple...Call Girls in Nagpur High Profile
 
(=Towel) Dubai Call Girls O525547819 Call Girls In Dubai (Fav0r)
(=Towel) Dubai Call Girls O525547819 Call Girls In Dubai (Fav0r)(=Towel) Dubai Call Girls O525547819 Call Girls In Dubai (Fav0r)
(=Towel) Dubai Call Girls O525547819 Call Girls In Dubai (Fav0r)kojalkojal131
 
VVIP Pune Call Girls Kalyani Nagar (7001035870) Pune Escorts Nearby with Comp...
VVIP Pune Call Girls Kalyani Nagar (7001035870) Pune Escorts Nearby with Comp...VVIP Pune Call Girls Kalyani Nagar (7001035870) Pune Escorts Nearby with Comp...
VVIP Pune Call Girls Kalyani Nagar (7001035870) Pune Escorts Nearby with Comp...Call Girls in Nagpur High Profile
 
CALL GIRLS IN Saket 83778-77756 | Escort Service In DELHI NcR
CALL GIRLS IN Saket 83778-77756 | Escort Service In DELHI NcRCALL GIRLS IN Saket 83778-77756 | Escort Service In DELHI NcR
CALL GIRLS IN Saket 83778-77756 | Escort Service In DELHI NcRdollysharma2066
 
Vip Mumbai Call Girls Andheri East Call On 9920725232 With Body to body massa...
Vip Mumbai Call Girls Andheri East Call On 9920725232 With Body to body massa...Vip Mumbai Call Girls Andheri East Call On 9920725232 With Body to body massa...
Vip Mumbai Call Girls Andheri East Call On 9920725232 With Body to body massa...amitlee9823
 
NO1 Verified Amil Baba In Karachi Kala Jadu In Karachi Amil baba In Karachi A...
NO1 Verified Amil Baba In Karachi Kala Jadu In Karachi Amil baba In Karachi A...NO1 Verified Amil Baba In Karachi Kala Jadu In Karachi Amil baba In Karachi A...
NO1 Verified Amil Baba In Karachi Kala Jadu In Karachi Amil baba In Karachi A...Amil baba
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In Yusuf Sarai ≼🔝 Delhi door step delevry≼🔝
Call Now ≽ 9953056974 ≼🔝 Call Girls In Yusuf Sarai ≼🔝 Delhi door step delevry≼🔝Call Now ≽ 9953056974 ≼🔝 Call Girls In Yusuf Sarai ≼🔝 Delhi door step delevry≼🔝
Call Now ≽ 9953056974 ≼🔝 Call Girls In Yusuf Sarai ≼🔝 Delhi door step delevry≼🔝9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Call Girls Pimple Saudagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Pimple Saudagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Pimple Saudagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Pimple Saudagar Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
 

Recently uploaded (20)

9004554577, Get Adorable Call Girls service. Book call girls & escort service...
9004554577, Get Adorable Call Girls service. Book call girls & escort service...9004554577, Get Adorable Call Girls service. Book call girls & escort service...
9004554577, Get Adorable Call Girls service. Book call girls & escort service...
 
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Kalyan callg Girls, { 07738631006 } || Call Girl In Kalyan Women Seeking Men ...
Kalyan callg Girls, { 07738631006 } || Call Girl In Kalyan Women Seeking Men ...Kalyan callg Girls, { 07738631006 } || Call Girl In Kalyan Women Seeking Men ...
Kalyan callg Girls, { 07738631006 } || Call Girl In Kalyan Women Seeking Men ...
 
VIP Call Girls Dharwad 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Dharwad 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Dharwad 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Dharwad 7001035870 Whatsapp Number, 24/07 Booking
 
Lucknow 💋 Call Girls Adil Nagar | ₹,9500 Pay Cash 8923113531 Free Home Delive...
Lucknow 💋 Call Girls Adil Nagar | ₹,9500 Pay Cash 8923113531 Free Home Delive...Lucknow 💋 Call Girls Adil Nagar | ₹,9500 Pay Cash 8923113531 Free Home Delive...
Lucknow 💋 Call Girls Adil Nagar | ₹,9500 Pay Cash 8923113531 Free Home Delive...
 
Top Rated Pune Call Girls Shirwal ⟟ 6297143586 ⟟ Call Me For Genuine Sex Ser...
Top Rated  Pune Call Girls Shirwal ⟟ 6297143586 ⟟ Call Me For Genuine Sex Ser...Top Rated  Pune Call Girls Shirwal ⟟ 6297143586 ⟟ Call Me For Genuine Sex Ser...
Top Rated Pune Call Girls Shirwal ⟟ 6297143586 ⟟ Call Me For Genuine Sex Ser...
 
Kothanur Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...
Kothanur Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...Kothanur Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...
Kothanur Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Shikrapur Call Girls Most Awaited Fun 6297143586 High Profiles young Beautie...
Shikrapur Call Girls Most Awaited Fun  6297143586 High Profiles young Beautie...Shikrapur Call Girls Most Awaited Fun  6297143586 High Profiles young Beautie...
Shikrapur Call Girls Most Awaited Fun 6297143586 High Profiles young Beautie...
 
Deira Dubai Escorts +0561951007 Escort Service in Dubai by Dubai Escort Girls
Deira Dubai Escorts +0561951007 Escort Service in Dubai by Dubai Escort GirlsDeira Dubai Escorts +0561951007 Escort Service in Dubai by Dubai Escort Girls
Deira Dubai Escorts +0561951007 Escort Service in Dubai by Dubai Escort Girls
 
Lubrication and it's types and properties of the libricabt
Lubrication and it's types and properties of the libricabtLubrication and it's types and properties of the libricabt
Lubrication and it's types and properties of the libricabt
 
VVIP Pune Call Girls Karve Nagar (7001035870) Pune Escorts Nearby with Comple...
VVIP Pune Call Girls Karve Nagar (7001035870) Pune Escorts Nearby with Comple...VVIP Pune Call Girls Karve Nagar (7001035870) Pune Escorts Nearby with Comple...
VVIP Pune Call Girls Karve Nagar (7001035870) Pune Escorts Nearby with Comple...
 
(=Towel) Dubai Call Girls O525547819 Call Girls In Dubai (Fav0r)
(=Towel) Dubai Call Girls O525547819 Call Girls In Dubai (Fav0r)(=Towel) Dubai Call Girls O525547819 Call Girls In Dubai (Fav0r)
(=Towel) Dubai Call Girls O525547819 Call Girls In Dubai (Fav0r)
 
VVIP Pune Call Girls Kalyani Nagar (7001035870) Pune Escorts Nearby with Comp...
VVIP Pune Call Girls Kalyani Nagar (7001035870) Pune Escorts Nearby with Comp...VVIP Pune Call Girls Kalyani Nagar (7001035870) Pune Escorts Nearby with Comp...
VVIP Pune Call Girls Kalyani Nagar (7001035870) Pune Escorts Nearby with Comp...
 
(ISHITA) Call Girls Service Aurangabad Call Now 8617697112 Aurangabad Escorts...
(ISHITA) Call Girls Service Aurangabad Call Now 8617697112 Aurangabad Escorts...(ISHITA) Call Girls Service Aurangabad Call Now 8617697112 Aurangabad Escorts...
(ISHITA) Call Girls Service Aurangabad Call Now 8617697112 Aurangabad Escorts...
 
CALL GIRLS IN Saket 83778-77756 | Escort Service In DELHI NcR
CALL GIRLS IN Saket 83778-77756 | Escort Service In DELHI NcRCALL GIRLS IN Saket 83778-77756 | Escort Service In DELHI NcR
CALL GIRLS IN Saket 83778-77756 | Escort Service In DELHI NcR
 
Vip Mumbai Call Girls Andheri East Call On 9920725232 With Body to body massa...
Vip Mumbai Call Girls Andheri East Call On 9920725232 With Body to body massa...Vip Mumbai Call Girls Andheri East Call On 9920725232 With Body to body massa...
Vip Mumbai Call Girls Andheri East Call On 9920725232 With Body to body massa...
 
NO1 Verified Amil Baba In Karachi Kala Jadu In Karachi Amil baba In Karachi A...
NO1 Verified Amil Baba In Karachi Kala Jadu In Karachi Amil baba In Karachi A...NO1 Verified Amil Baba In Karachi Kala Jadu In Karachi Amil baba In Karachi A...
NO1 Verified Amil Baba In Karachi Kala Jadu In Karachi Amil baba In Karachi A...
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In Yusuf Sarai ≼🔝 Delhi door step delevry≼🔝
Call Now ≽ 9953056974 ≼🔝 Call Girls In Yusuf Sarai ≼🔝 Delhi door step delevry≼🔝Call Now ≽ 9953056974 ≼🔝 Call Girls In Yusuf Sarai ≼🔝 Delhi door step delevry≼🔝
Call Now ≽ 9953056974 ≼🔝 Call Girls In Yusuf Sarai ≼🔝 Delhi door step delevry≼🔝
 
Call Girls Pimple Saudagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Pimple Saudagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Pimple Saudagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Pimple Saudagar Call Me 7737669865 Budget Friendly No Advance Booking
 

wire vs. reg.pdf

  • 1. Program 1 Legal uses of the wire element 1 wire A, B, C, D, E; // simple 1-bit wide wires 2 wire [8:0] Wide; // a 9-bit wide wire 3 reg I; 4 5 assign A = B & C; // using a wire with an assign statement 6 7 always @(B or C) begin 8 I = B | C; // using wires on the right -hand side of an always@ 9 // assignment 10 end 11 12 mymodule mymodule_instance (.In (D), 13 .Out(E)); // using a wire as the output of a module 1 Verilog: wire vs. reg Ahmed Abdelazeem KAUST, PGDip Version 0.2023.11.20 November, 20, 2023 1 Introduction Sections 1.1 to 1.3 discuss the difference between wire and reg in Verilog, and when to use each of them. 1.1 wire Elements (Combinational logic) wire elements are simple wires (or busses of arbitrary width) in Verilog designs. The following are syntax rules when using wires: 1. wire elements are used to connect input and output ports of a module instantiation together with some other element in your design. 2. wire elements are used as inputs and outputs within an actual module declaration. 3. wire elements must be driven by something, and cannot store a value without being driven. 4. wire elements cannot be used as the left-hand side of an = or <= sign in an always@ block. 5. wire elements are the only legal type on the left-hand side of an assign statement. 6. wire elements are a stateless way of connecting two peices in a Verilog-based design. 7. wire elements can only be used to model combinational logic. Program 1 shows various legal uses of the wire element.
  • 2. 1.2 reg Elements (Combinational and Sequential logic) reg are similar to wires, but can be used to store information (‘state’) like registers. The following are syntax rules when using reg elements. 1. reg elements can be connected to the input port of a module instantiation. 2. reg elements cannot be connected to the output port of a module instantiation. 3. reg elements can be used as outputs within an actual module declaration. 4. reg elements cannot be used as inputs within an actual module declaration. 5. reg is the only legal type on the left-hand side of an always@ block = or <= sign. 6. reg is the only legal type on the left-hand side of an initial block = sign (used in Test Benches). 7. reg cannot be used on the left-hand side of an assign statement. 8. reg can be used to create registers when used in conjunction with always@(posedge Clock) blocks. 9. reg can, therefore, be used to create both combinational and sequential logic. Program 2 shows various legal uses of the reg element. Program 2 Legal uses of the reg element 1 wire A, B; 2 reg I, J, K; // simple 1-bit wide reg elements 3 reg [8:0] Wide; // a 9-bit wide reg element 4 5 always @(A or B) begin 6 I = A | B; // using a reg as the left -hand side of an always@ 7 // assignment 8 end 9 10 initial begin // using a reg in an initial block 11 J = 1’b1; 12 #1 13 J = 1’b0; 14 end 15 16 always @(posedge Clock) begin 17 K <= I; // using a reg to create a positive -edge -triggered register 18 end 1.3 When wire and reg Elements are Interchangable wire and reg elements can be used interchangably in certain situations: 1. Both can appear on the right-hand side of assign statements and always@ block = or <= signs. 2. Both can be connected to the input ports of module instantiations. 2