1. Home
  2. /
  3. Systemverilog
  4. /
  5. 2-bit Counter with Reset

2-bit Counter with Reset - Systemverilog Typing CST Test

Loading…

2-bit Counter with Reset — Systemverilog Code

A synchronous 2-bit counter with asynchronous reset.

module Counter2Bit(
	input logic clk,
	input logic reset,
	output logic [1:0] count
);

always_ff @(posedge clk or posedge reset) begin
	if (reset)
		count <= 2'b00;
	else
		count <= count + 1;
end

endmodule

Systemverilog Language Guide

SystemVerilog is a hardware description and verification language (HDVL) that extends Verilog with advanced features for hardware modeling, simulation, and verification in digital design.

Primary Use Cases

  • ▸RTL modeling of digital circuits
  • ▸Functional verification using testbenches
  • ▸Formal verification with assertions
  • ▸Constrained-random stimulus generation
  • ▸Coverage-driven verification of complex designs

Notable Features

  • ▸Class-based object-oriented programming for verification
  • ▸Constrained random stimulus generation
  • ▸Functional coverage and assertions
  • ▸Interfaces and modports for modular designs
  • ▸Enhanced data types (logic, bit, enum, struct, union)

Origin & Creator

Developed by Accellera and later standardized as IEEE 1800, SystemVerilog builds upon Verilog (originally created by Phil Moorby in 1984) to unify design and verification features.

Industrial Note

SystemVerilog is essential in high-performance semiconductor industries for complex SoC verification, coverage-driven testbenches, and constrained-random simulation.

Quick Explain

  • ▸SystemVerilog combines design and verification constructs into a single language.
  • ▸Supports hardware modeling at RTL (Register Transfer Level) and behavioral levels.
  • ▸Includes object-oriented programming features for verification environments.
  • ▸Provides assertions, coverage, and constrained randomization for functional verification.
  • ▸Widely used in ASIC, FPGA, and SoC design and verification workflows.

Core Features

  • ▸RTL design constructs inherited from Verilog
  • ▸Advanced verification constructs (classes, randomization, assertions)
  • ▸Interfaces for modular connectivity
  • ▸Packages for reusable code
  • ▸Clocking blocks for synchronized stimulus

Learning Path

  • ▸Learn Verilog RTL basics
  • ▸Understand digital logic design and FSMs
  • ▸Study SystemVerilog verification constructs
  • ▸Practice testbench creation and constrained randomization
  • ▸Advance to coverage-driven and UVM-based verification

Practical Examples

  • ▸Design and simulate a 4-bit adder
  • ▸Verify a FIFO module with constrained random inputs
  • ▸Implement functional coverage for a bus protocol
  • ▸Use assertions to check handshaking signals
  • ▸Create reusable verification environment for an IP block

Comparisons

  • ▸SystemVerilog vs Verilog: adds verification, OOP, assertions, and coverage
  • ▸SystemVerilog vs VHDL: more verification-friendly, syntax differences
  • ▸UVM vs plain SystemVerilog: methodology framework vs language features
  • ▸RTL simulation vs emulation: software vs hardware-accelerated
  • ▸Formal vs simulation: exhaustive vs randomized checking

Strengths

  • ▸Combines design and verification in one language
  • ▸Reduces dependency on multiple verification tools
  • ▸Powerful assertion and coverage features
  • ▸Supports scalable and reusable verification environments
  • ▸Industry-standard with wide EDA tool support

Limitations

  • ▸Steep learning curve for beginners
  • ▸Requires strong understanding of digital design concepts
  • ▸Simulation speed can be slow for very large designs
  • ▸EDA tool dependency for full verification features
  • ▸Not all FPGA tools fully support advanced verification constructs

When NOT to Use

  • ▸For simple combinational logic with no verification need
  • ▸Where legacy Verilog is sufficient
  • ▸For analog or mixed-signal designs not supported by simulators
  • ▸If team lacks expertise in verification methodology
  • ▸For extremely resource-constrained FPGA-only rapid prototyping

Cheat Sheet

  • ▸module - hardware building block
  • ▸interface - bundle signals for DUT/testbench
  • ▸class - object for verification environment
  • ▸assert property - check design properties
  • ▸covergroup - collect functional coverage

FAQ

  • ▸Can SystemVerilog be used for FPGA design? -> Yes, RTL constructs are synthesizable.
  • ▸Is SystemVerilog backward-compatible with Verilog? -> Mostly, Verilog code is valid.
  • ▸What tools support SystemVerilog? -> Synopsys, Cadence, Mentor, etc.
  • ▸Can SystemVerilog be used for verification only? -> Yes, object-oriented features are verification-specific.
  • ▸Is UVM mandatory in SystemVerilog? -> No, but industry-standard for complex verification.

30-Day Skill Plan

  • ▸Week 1: Verilog RTL and modules
  • ▸Week 2: SystemVerilog data types and interfaces
  • ▸Week 3: Assertions and covergroups
  • ▸Week 4: Testbench classes and constrained random stimulus
  • ▸Week 5: Full verification environment with UVM

Final Summary

  • ▸SystemVerilog unifies hardware design and verification in one language.
  • ▸Supports RTL modeling, verification classes, assertions, and coverage.
  • ▸Essential for ASIC, FPGA, and SoC verification.
  • ▸Works with UVM for scalable, reusable verification environments.
  • ▸Widely supported in industry-standard EDA tools.

Project Structure

  • ▸Design RTL source files (.sv)
  • ▸Verification files (classes, sequences, testcases)
  • ▸Interface definitions (.sv)
  • ▸Coverage and assertion definitions
  • ▸Simulation scripts and makefiles

Monetization

  • ▸IP block design and verification services
  • ▸ASIC/FPGA design consulting
  • ▸EDA tool training and support
  • ▸Verification IP creation and licensing
  • ▸Advanced hardware verification contracts

Productivity Tips

  • ▸Reuse testbench components across projects
  • ▸Automate simulation runs and regression tests
  • ▸Leverage constrained randomization for effective coverage
  • ▸Use assertion-driven debugging for faster bug identification
  • ▸Segment large designs for incremental verification

Basic Concepts

  • ▸Module: basic hardware building block
  • ▸Interface: encapsulates signals and connectivity
  • ▸Class: object-oriented construct for verification
  • ▸Assertion: checks properties during simulation
  • ▸Constraint: defines rules for random stimulus generation

Official Docs

  • ▸https://ieeexplore.ieee.org/document/6144021
  • ▸https://www.accellera.org/downloads/standards/systemverilog
  • ▸https://verificationacademy.com/verification-methodology

More Systemverilog Typing Exercises

Blink LED2-input AND Gate

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher