Skip to content
DenseChip
Learn
PracticeCode labInterview

DenseChip

Navigate

Menu

LearnPracticeCode labInterview

Tools

All toolsSV editorCode repoResume
DenseChip

Practice, courses, and chip-design tools in one focused workspace.

LearnPracticeCode labInterviewToolsLearning paths

© 2026 DenseChip

AboutContactPrivacyTerms
Skip to lesson

Course contents

  • RTL Foundations36
  • Combinational Design25
  • Sequential Design27
  • FSM & Control27
  • Timing & Clocking39
  • Reset & CDC34
  • Memory & Buses57
  • Advanced RTL28
    • Parameterization and Generate Hub
    • Top-Level Integration Hub
    • Synthesis Intent Hub
    • Style and Static Checks Hub
    • Assertions in RTL Hub
    • Formal Verification Basics Hub
    • Reusable SystemVerilog for RTL
      • Packages and Compile Order
      • Packed Structs and Unions
      • Parameter Types and Guards
      • Functions and Tasks
      • Interfaces, Modports, and Portability
      • Compile-Order and Package Errors, Decoded
      • Mini Project: a Reusable FIFO IP
  • Senior & Interview76
  • Glossary and Notation
Loading lesson

‹Reusable SystemVerilog for RTL
  1. Topics
  2. RTL Design
  3. Advanced RTL
  4. Reusable SystemVerilog for RTL
  5. Interfaces, Modports, and Portability

Part 8 · Advanced · Advanced

Interfaces, Modports, and Portability

Bundle stable bus contracts, constrain signal direction, and keep timing and tool behavior visible.

Why this matters

An interface makes connectivity tidy but proves nothing about the protocol. A tool or IP boundary that cannot take an interface also forces a rewrite to plain ports late in the project.

After this lesson you can: use modports to document driver direction, decide where to flatten an interface, and check a pattern in every supported tool.

stream_if.sv
1
2
3
4
5
6
7
8
9
10
interface stream_if #(parameter type T = logic [31:0]) (input logic clk);
  logic valid, ready;
  T data;
  modport source (input clk, ready, output valid, data);
  modport sink   (input clk, valid, data, output ready);
endinterface

module stage(stream_if.sink in_if, stream_if.source out_if);
  // valid/ready stage implementation
endmodule
The source modport drives valid and data, the sink modport drives ready, and both take clk as an input

Read the arrows as who drives each wire. Each modport line in the interface lists the same wires; only the direction differs.

  • source has output valid, data and input ready: the producer drives the forward wires.

  • sink has input valid, data and output ready: the stage drives only the backward wire.

  • If the stage assigns valid, a tool that checks modports stops the build: Verilator reports Attempt to drive input-only modport: 'valid'.

This interface declaration can carry a caller-selected packed type. The empty stage body is an interface-port sketch, not an implemented valid/ready stage. Modports establish source and sink ownership, while protocol assertions remain necessary because type safety alone cannot enforce valid/ready stability. For a complete elastic stage and scoreboard, use the valid/ready lesson.

  • Use modports to document driver direction.

  • Keep the clock/reset relationship explicit in the interface contract.

  • Avoid hiding complex combinational logic in interface methods.

  • Flatten interfaces at external IP boundaries when tool or language interoperability requires plain ports.

  • Compile a small representative design in every supported simulator and synthesis tool before standardizing a pattern.

Warning

An interface improves connectivity but does not prove protocol correctness. Stability, transfer, liveness, and reset assertions still belong at the boundary.

Check yourself When should an interface be flattened into ordinary ports?

At boundaries crossing tool/language/IP compatibility limits, or where the published integration contract must be language-neutral and explicit.

Remember

  • Modports state source and sink ownership; assertions still have to check stability, transfer and reset.

  • Flatten interfaces at external IP boundaries when a tool or language needs plain ports.

  • Compile a small representative design in every supported simulator and synthesis tool before standardising.

Rule of thumb: type safety does not enforce valid/ready stability; the assertions do.

How this was checked

Verilator 5.048 (2026-10-17) rejected a sink-side assignment to valid with Attempt to drive input-only modport. Icarus Verilog 13.0 does not accept interface ports, which is itself a reason to compile a pattern in every supported tool.

Keep going

  • Code lab: Simple interface and modports

  • Interview: run a mock interview on this topic

Related topics

  • Complete interfaces and modports course

  • Compilation and elaboration

Previous

271 / 350

Next: Compile-Order and Package Errors, Decoded

Up next

Up nextCompile-Order and Package Errors, Decoded

Sign in to save progress

Practice this lessonReport an error

See also

  • Packages and Compile Order
  • Packed Structs and Unions
  • Parameter Types and Guards