SV-Interfaces
SV-Interfaces
-Geethanjali G
Agenda
Introduction
Features
How Interface Works
Ports in Interface
Modports
Clocking Blocks
Tasks and Functions in Interfaces
Parameterized Interfaces
Introduction
SystemVerilog interface encapsulates communication between blocks.
An interface allows a number of signals to be grouped together and
- Parameters
- Variables and constants
- Tasks and functions
- initial or always Blocks
- Continuous assignments
Syntax
Device
Device11 interface Device
Device22
(TB)
(TB) (DUT)
(DUT)
How Interfaces Work…
How Interfaces Work Cont…
How Interfaces Work Cont…
Example for Ports in Interface
simple_bus
mem clk cpu
top
interface
interface module
modulemem( mem( module
modulecpu(
cpu(
simple_bus;
simple_bus; simple_bus
simple_bus simple_bus
simple_bus
logic
logicreq,
req,gnt;
gnt; sb,
sb, sb,
sb,
logic
logic[7:0]
[7:0]addr;
addr; input
inputbit
bitclk);
clk); input
inputbit
bitclk);
clk); interface.sv
wire
wire [7:0]
[7:0]data;
data; …… ……
logic
logic[1:0]
[1:0]mode;
mode; endmodule
endmodule endmodule
endmodule
logic module
moduletop;
logicstart,
start,rdy;
rdy; top;
endinterface logic
logicclk
clk==0;0;
endinterface
always
always#10 #10clk
clk==! !
clk;
clk;
simple_bus
simple_bussb();sb();
mem
memm1(sb,
m1(sb,clk);
clk);
cpu
cpuc1(sb,
c1(sb,clk);
clk);
endmodule
endmodule
Connecting the Testbench and the Design
Interface Modports
modport
interface_mod_port.sv
interface mod_if;
logic a, b, c, d;
modport master (input a,b, output c,d);
modport slave (output a,b, input c,d);
endinterface
Tasks and Functions in Interfaces
If the interface is connected via a modport, the method must be specified using the import
keyword.
Ex:
task slaveWrite;
...
endtask
endinterface: simple_bus
Clocking blocks
Clocking blocks
interface
interfacearb_if
arb_if(input
(inputbit
bitclk);
clk);
logic
logic[1:0]
[1:0]grant,
grant,request;
request; reset
logic
logicreset;
reset; request[1:0]
grant[1:0]
clocking
clockingcb
cb@(posedge
@(posedgeclk);
clk); clock
input
inputgrant;
grant; ////TB
TBinput
output
input arb.sv
outputrequest;
request; ////TB
TBoutput
output
endclocking
endclocking
modport
modportDUTDUT(input
(inputclk,
clk,
input
inputrequest,
request,reset,
reset, ////Design
Designunder
under
test
test
output
outputgrant);
grant);
modport
modportTB TB (clocking
(clockingcb,
cb, ////Synch
Synchsignals
signals
output
outputreset);
reset); ////Async
Asyncsignals
signals
endinterface:
endinterface:arb_if
arb_if
Clocking Declaration
Input Skew: Denotes when an input is sampled before the
clocking event occurs. Input skew is for sampling.
A program block can contain zero or more initial blocks, continuous assignments,
(In other words virtual interface are used to connect between class objects and
modules)