I need to have an inout port with real dataytype in my module. Also I need to have multiple driver resolution capability in that port. (Saw about nettype, but didn't see usage of that in module ports in LRM)
Here is a sample code.
module abc (
input real vref1,
output real vout);
assign vout = vref1 * 3.17;
endmodule
module def (
input logic out_en,
input logic data,
output logic vref1);
bufif1 b1 (vref1, data, out_en);
endmodule
module top (
inout real vref1,
input logic out_en,
input logic data,
output real vout);
logic vref1_dig_l;
assign vref1 = (vref1_dig_l === 1'bz) ? 100.0 : ((vref1_dig_l == 1'b0) ? 0.0 : 20.0);
abc a1 (vref1, vout);
def d1 (out_en, data, vref1_dig_l);
endmodule
module temp ();
real vref1;
logic out_en;
logic data;
real vout;
top t1 (vref1, out_en, data, vout);
initial
$monitor("vref1 - %0f, out_en - %0b, data - %0b, vout - %0f", vref1, out_en, data, vout);
initial begin
#1 vref1 = 5.0; out_en = $random()%2; data = $random();
#1 vref1 = 5.0; out_en = $random()%2; data = $random();
#1 vref1 = 5.0; out_en = $random()%2; data = $random();
#1 vref1 = 5.0; out_en = $random()%2; data = $random();
#1 vref1 = 5.0; out_en = $random()%2; data = $random();
#1 vref1 = 5.0; out_en = $random()%2; data = $random();
#1 vref1 = 5.0; out_en = $random()%2; data = $random();
#1 vref1 = 5.0; out_en = $random()%2; data = $random();
end
endmodule
This is giving me the following error -
inout real vref1,
|
xmvlog: *E,SVNTRL (../b.sv,25|17): A module port that is a net cannot be of type 'real' or 'shortreal' by SystemVerilog language rules.
you can use the following:
however,
realis not a synthesizable concept and cannot be used in the gate-level logic, so the following is illegal:bufif1 b1 (vref1, data, out_en)with verif1 as real.Another way to work around your issues is using of system verilog functions for conversion real to bits and vice versa (lrm 20.5)
for assignment issues in the init block of the temp module:
by verilog rules lhs of any assignment from a procedural block must be a variable. 'initial' block is a procedural block. 'net' is not a variable.
In temp you have to declare vref1 as 'nreal', which is a net type and you cannot assign it from a procedural block. You would need a varialbe as an intermediate stage:
The above would fix your assignment issues.
It also looks like in your case a resolution function is needed. Something like the following can help: