Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Complete Sensor Guide
      • Engineering Deep Dives
      • AI
      • ARDUINO Compatible Coding
      • Audio Electronics
      • Battery Management
      • Beginners Electronics Series
      • Brainwave
      • Digital electronics (DE)
      • Electric Vehicles
      • EMI/EMC/RFI
      • EVs
      • Hardware Filters
      • IoT tutorials
      • LoRa/LoRaWAN
      • Power Tutorials
      • Protocol
      • Python
      • RPI Python Programming
      • Sensors
      • USB
      • Thermal management
      • Verilog
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Tech Terms
    • Webinars & Digital Events
  • Resources
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • White Papers
  • Guest Post Guidelines
  • Advertise
  • Subscribe

Verilog Tutorial 12: How to design 8-bit parity generator and checker circuits in Verilog

By Ashutosh Bhatt June 2, 2025

Note: it’s recommended to follow this VHDL tutorial series in order, starting with the first tutorial. Follow the full series here.

In the previous Verilog Tutorial – 11, we learned how to design half and full-subtractor circuits in Verilog.

In this tutorial, we’ll:

  1. Write a Verilog program to build an 8-bit parity generator and checker circuits
  2. Verify the program’s output waveform (digital circuit) with truth tables for the parity generator and parity checker circuits

The half-subtractor circuit

Truth table

Here are a few examples of the possible 256 combinations of D0-D7.

Next, let’s write the Verilog program, compile and simulate it, and get the output in a waveform. We’ll also verify the output waveforms with the given truth table.

First, it’s important to review the step-by-step procedure provided in VHDL Tutorial – 3. In that tutorial, we learn how to design a project, edit and compile a program, create a waveform file, simulate the program, and generate the final output waveforms.

Verilog program

Gate-level modeling:

module parity_gen(even_p,odd_p,d);
 output even_p,odd_p;
 input [7:0] d;
 wire t1,t2,t3,t4,t5,t6;
  xor(t1,d[0],d[1]);
  xor(t2,d[2],t1);
  xor(t3,d[3],t2);
  xor(t4,d[4],t3);
  xor(t5,d[5],t4);
  xor(t6,d[6],t5);
  xor(even_p,d[7],t6);
  not(odd_p,even_p);
endmodule

Dataflow modeling:

module parity_gen(even_p,odd_p,d);
 output even_p,odd_p;
 input [7:0] d;
 wire t1,t2,t3,t4,t5,t6;
 assign t1 = d[0] ^ d[1];
 assign t2 = d[2] ^ t1;
 assign t3 = d[3] ^ t2;
 assign t4 = d[4] ^ t3;
 assign t5 = d[5] ^ t4;
 assign t6 = d[6] ^ t5;
 assign even_p = d[7] ^ t6;
 assign odd_p = ~even_p;
endmodule

Now, compile the above program, creating a waveform file with all of the necessary inputs and outputs that are listed, and simulate the project. 

Here are the results…

Waveform simulation

Be sure to verify the ‘even_p’ and ‘odd_p’ output waveforms with the D0-D7 input data. For example, as shown above, for ‘1111 1011’ the even_p output is ‘1’ and the odd _p output is ‘0.’ Whereas, for ‘1011 1110,’ the even_p output is ‘0’ and the odd_p output is ‘1.’

Next, let’s build the 8-bit parity checker circuit.

The 8-bit parity checker circuit

Truth table

Verilog program

Gate-level modeling:

module parity_chk(p,e,d);
 output e;
 input [7:0] d,p;
 wire t1,t2,t3,t4,t5,t6,t7;
  xor(t1,d[0],d[1]);
  xor(t2,d[2],t1);
  xor(t3,d[3],t2);
  xor(t4,d[4],t3);
  xor(t5,d[5],t4);
  xor(t6,d[6],t5);
  xor(t7,d[7],t6);
  xor(e,p,t7);
endmodule

Dataflow modeling:

module parity_gen(p,e,d);
 output e;
 input [7:0] d,p;
 wire t1,t2,t3,t4,t5,t6,t7;
 assign t1 = d[0] ^ d[1];
 assign t2 = d[2] ^ t1;
 assign t3 = d[3] ^ t2;
 assign t4 = d[4] ^ t3;
 assign t5 = d[5] ^ t4;
 assign t6 = d[6] ^ t5;
 assign t7 = d[7] ^ t6;

 assign e = p ^ t7;
endmodule

Simulation waveform

Now, verify the ‘e’ output waveform against the parity input ‘p’ and the D0-D7 data. As shown aboive, for ‘0101 1011’ and parity ‘1,’ the error output is ‘1.’ Whereas, for ‘0100 1010′ and parity ‘0,’ the output is ‘0.’

In next tutorial, we’ll learn how to design 8×3 encoder and 3×8 decoder circuits by using VHDL.

 

You may also like:


  • Verilog Tutorial 11: How to design half and full-subtractor circuits…

  • Verilog Tutorial 10: How to design half and full-adder circuits…

  • How to use NOR as the universal gate in Verilog

  • How to design and verify D’Morgan’s Theorem in Verilog-Part 6

  • How to design, simulate, and verify in Verilog using the…

  • How to design, simulate, and verify all digital gates in…

  • How to compile, simulate, and verify a Verilog program using…

  • What is Verilog, its features, and design flow?- Part 2

  • What are the fundamentals of Verilog programs?-Part 1

  • How to use NAND as a universal gate in Verilog

  • How to design a digital circuit using VHDL


Filed Under: Tutorials
Tagged With: tutorial, vdhl, verilog
 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

Log in to leave a comment:

Lost your password?

Don't have an account? Register here

Submit a Guest Post

submit a guest post

EE TECH TOOLBOX

“ee
Tech Toolbox: Wide Bandgap Semiconductors
Moving from silicon to GaN or SiC feels like a whole new ballgame, doesn’t it? It isn’t just about faster switching; it’s about managing the layout parasitics and thermal realities that come with that speed. This month’s Tech Toolbox features a curated eBook that tackles these design hurdles head-on.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS feed: EDABOARD.com Discussions. EDABOARD.com Discussions.

  • Hi Side Gate drive layout and dv/dt shielding?
  • Reverse recovery issue
  • Current Sense transformer in Phase Shift Full Bridge
  • SA602/NE602 Buffer and Bias Circuit
  • Full Bridge of 1000W: 400V input (48V out)

RSS feed: Electro-Tech-Online.com Discussions Electro-Tech-Online.com Discussions

  • Will this solenoid actuator work as intended?
  • NE602/SA602 Bias and Buffer circuit
  • Rotary encoder with push function
  • How much does generator frequency stability matter for sensitive electrical equipment?
  • differential line loss question

Featured Tutorials

VHDL Series (1-24)

  • VHDL Tutorial 17: Design a JK flip-flop (with preset and clear) using VHDL
    VHDL Tutorial 17: Design a JK flip-flop (with preset and clear) using VHDL
  • VHDL Tutorial 18: Design a T flip-flop (with enable and an active high reset input) using VHDL
    VHDL Tutorial 18: Design a T flip-flop (with enable and an active high reset input) using VHDL
  • VHDL Tutorial – 19: Designing a 4-bit binary counter using VHDL
    VHDL Tutorial – 19: Designing a 4-bit binary counter using VHDL
  • VHDL Tutorial – 20: Designing 4-bit binary-to-gray & gray-to-binary code converters
    VHDL Tutorial – 20: Designing 4-bit binary-to-gray & gray-to-binary code converters
  • VHDL Tutorial – 21: Designing an 8-bit, full-adder circuit using VHDL
    VHDL Tutorial – 21: Designing an 8-bit, full-adder circuit using VHDL
  • VHDL Tutorial – 22: Designing a 1-bit & an 8-bit comparator by using VHDL
    VHDL Tutorial – 22: Designing a 1-bit & an 8-bit comparator by using VHDL
More Tutorials >

Recent Articles

  • Stackpole Electronics introduces 6 W thin-film resistors
  • TDK-Lambda adds 12.5 kW three-phase power supplies
  • Signal Hound adds radar pulse generation to VSG systems
  • ITG Electronics adds 300 VAC common mode chokes
  • Morse Micro introduces USB adapters for Wi-Fi HaLow connectivity

EE ENGINEERING TRAINING DAYS

engineering
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2026 Arrowfly LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of Arrowfly
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Complete Sensor Guide
      • Engineering Deep Dives
      • AI
      • ARDUINO Compatible Coding
      • Audio Electronics
      • Battery Management
      • Beginners Electronics Series
      • Brainwave
      • Digital electronics (DE)
      • Electric Vehicles
      • EMI/EMC/RFI
      • EVs
      • Hardware Filters
      • IoT tutorials
      • LoRa/LoRaWAN
      • Power Tutorials
      • Protocol
      • Python
      • RPI Python Programming
      • Sensors
      • USB
      • Thermal management
      • Verilog
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Tech Terms
    • Webinars & Digital Events
  • Resources
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • White Papers
  • Guest Post Guidelines
  • Advertise
  • Subscribe