Which is better to use in SystemVerilog interface. Wire or Logic? Or this does not make much difference. When using logic for interface signal, a problem I’ve encountered is simulator throws warning message when there’s mix of Driver Clocking Block and continuous assignment.
The top level signals that connect to your DUT should be wires. The interface should have internal logic that will drive the wires from logic or tri-state them so that the interface can be used as either a master or slave.
Here is a small example which demonstrates an interface that can be used as a master/slave:
interface intf(input clock);
wire a;
wire b;
bit mode = 1; // 1 - Master ; 0 - Slave - You can use an enum
logic a_i;
logic b_1;
assign a = (mode==1) ? a_i : 1'bz;
assign b = (mode==1) ? b_i : 1'bz;
function void set_mode(bit new_mode)
mode = new_mode;
endfunction
...
You can read all of the inputs using the wires. You can use the logic variables in your procedural code, which you can’t do with wires. This solution also eliminates the multiple driver warnings/errors.
In reply to ben@SystemVerilog.us: @ben, your solution in given link looks good. But there also, declaring clocking variable as inout might be unnecessary.
Just replacing “logic” with “wire” in above code seem to have done the job!
I disagree that “declaring clocking variable as inout might be unnecessary”
Decalaring it as inout maintains the integrety/signifance/role of that variable in its context.
Declaring it as output has the implication that the variable is constantly driven to a hard value (i.e., not tri-stated); it now called “fake news” :).
Quote:
1800-2012 14.3 Clocking block declaration
A clockvar whose clocking_direction is inout shall behave as if it were two clockvars, one input and one output, having the same name and the same clocking_signal.
Reading the value of such an inout clockvar shall be equivalent to reading the corresponding input clockvar.
@cgales, This looks like some extra logic in interface.
Quote:The interface should have internal logic that will drive the wires from logic or tri-state them
Actually, it is more than just extra logic in the interface. It is more as to how the interface is viewed: Is it viewed as
An active component/driver/modifier participating in the values of signals connected to e DUT?
As a bundle of wires connecting the DUT to its environment?
My view of an interface is the bundle of wires, and should not play an active role in the connection to the DUT. It can play a passive role in the verification/monitoring processes.
The other problem with this approach is that the driving process is now distributed:
One part is in the class driver
The other part is within the interface
interface intf(input clock);
wire a;
wire b;
bit mode = 1; // Fake interface signal
logic a_i; // Fake interface signal
logic b_1; // Fake interface signal
assign a = (mode==1) ? a_i : 1'bz; // Fake driver
assign b = (mode==1) ? b_i : 1'bz; // Fake driver
...
endfunction
This is true, but if you desire to use emulation, which is a requirement for a growing number of UVM users, then this approach is a necessity. For emulation, all the BFM functionality needs to be in the interface, so starting with this approach is beneficial for long-term portable agents.