A fully functional, configurable UART IP core implemented in SystemVerilog with comprehensive verification using a layered testbench architecture.
This project implements a synthesis-ready UART IP core capable of full-duplex serial communication. The design features programmable baud rates, configurable data width, and flexible parity options, making it suitable for various serial communication applications.
- Full-Duplex Communication: Simultaneous transmit and receive operations
- Configurable Parameters:
- System clock frequency
- Baud rate
- Data width (default 8 bits)
- Parity enable/disable
- Even/Odd parity selection
- Robust Error Detection:
- Parity error checking
- Stop bit (frame) error detection
- 16x Oversampling: Enhanced noise immunity on the receiver
- Modular Design: Clean separation of transmitter, receiver, and baud generator
- Comprehensive Verification: Layered SystemVerilog testbench with UVM-style architecture
The UART core consists of three primary components:
- Generates timing pulses for data synchronization
- baud_tick: 1x baud rate for transmitter
- tick_16x: 16x baud rate for receiver oversampling
- FSM-based parallel-to-serial converter
- States: Idle β Start β Data β Parity (optional) β Stop
- LSB-first transmission
- Automatic parity bit calculation (XOR reduction)
- FSM with 16x oversampling for robust data recovery
- Mid-bit sampling for maximum data validity
- Automatic start bit detection
- Comprehensive error checking
| Parameter | Default Value | Description |
|---|---|---|
SYS_FREQ |
50,000,000 Hz | System clock frequency |
BAUD_RATE |
9600 | Target baud rate |
DATABITS |
8 | Width of data packet |
PARITY_EN |
1 | 1 = Enabled, 0 = Disabled |
PARITY_TYPE |
0 | 0 = Even Parity, 1 = Odd Parity |
- SystemVerilog simulator (ModelSim, QuestaSim, VCS, or Xcelium)
- Basic understanding of UART protocol
- Synthesis tool (optional, for FPGA implementation)
The design employs a sophisticated layered testbench architecture inspired by UVM methodology:
-
Transaction Object (
class trans)- Randomized data generation
- Error injection capabilities
- Constraint-based testing (80% normal, 20% error cases)
-
Generator (
class gener)- Creates randomized transactions
- Controls test stimulus generation
-
Driver (
class driv)- Drives physical interface signals
- Implements protocol timing
-
Monitor (
class montr)- Observes interface activity
- Captures output data
-
Scoreboard (
class scrboard)- Compares expected vs. actual results
- Tracks pass/fail statistics
- Provides test summary
-
Coverage (
class coverage)- Functional coverage collection
- Ensures all data patterns (0x00 to 0xFF) are tested
- Verifies control path coverage
- β Standard random data transmission
- β Even/Odd parity verification
- β Parity error injection and detection
- β Stop bit (frame) error injection and detection
- β Back-to-back transmission stress testing
- β Full data pattern coverage (0x00 - 0xFF)
The design has been thoroughly verified with:
- 100% functional coverage across all data patterns
- Zero defects in protocol compliance
- Robust error detection for parity and frame errors
- Successful back-to-back transmission without data loss
Sample test output shows comprehensive pass/fail tracking with detailed transaction logging.
src/
βββuart_top.sv # Top-level module
βββ uart_tx.sv # UART Transmitter
βββ uart_rx.sv # UART Receiver
testbench/
βββ uart_tb.sv # Main testbench file
βββ uart_tb_package.sv # Testbench class definitions
README.md
- FSM Design: Clean state machine implementations
- Protocol Timing: Precise baud rate generation and sampling
- Error Handling: Comprehensive error detection mechanisms
- Verification: Advanced testbench with constrained randomization
- Modular Design: Reusable, parameterized components
- SystemVerilog OOP: Class-based verification environment
- The design is synthesis-ready for FPGA implementation
- All FSMs use registered outputs for timing closure
- Clock domain considerations handled appropriately
- Resource usage scales with
DATABITSparameter
For questions or suggestions, please open an issue on GitHub.
Note: For detailed design specifications, waveform analysis, and verification methodology, please refer to the included Documentation.pdf.