Hi,
I was not able to find any conclusive answer if it can work this way, so I thought of asking this question here:
I have an interface declared in the top module of DUT (pins). One of the pins declared in that respective interface is inout. Since I do not want to handle the tristate deeper in the hierarchy I thought of this solution:
// interface declaration, 2 modports: one for pins (with inout), one for internal logic (exploded tristate)
interface my_ifc ();
wire [15:0] d;
logic d_oe;
logic d_in;
logic d_out;
modport pins (inout d);
modport user (input d_in, output d_out, output d_oe);
assign d_out = (d_oe)? d_out : 16'hzzzz;
assign d_in = d;
endinterface
// interface driver with modport "user" -> _in, _out, _oe
module ifc_drv (
my_ifc.user ifc
);
assign ifc.d = 16'hcafe;
assign ifc.d_oe = 1'b1;
endmodule
// pad (synthesizable) with interface in module declaration
module dut_pad (
my_ifc.pins ifc
);
ifc_drv drv (
.ifc(ifc)
);
endmodule
Since the code above returns modport mismatch error this is not the solution for my problem.
What is the right way to handle tristates in interfaces?