import "DPI-C" [context|pure] function/task prototypes, export "DPI-C" function/task, and export pkg::*; / pkg::item. Coverage loop round 1, cluster 2: 661 -> 671 / 820 (80.6% -> 81.8%). Feature README: docs/features/dpi-export/README.md Co-Authored-By: Claude Fable 5 <[email protected]>
283 lines
7.6 KiB
Plaintext
283 lines
7.6 KiB
Plaintext
# a DPI import split across lines collapses onto one when it fits
|
|
# corpus/ibex/dv/cs_registers/env/env_dpi.sv:7
|
|
package p;
|
|
import "DPI-C"
|
|
function void env_final();
|
|
endpackage
|
|
----
|
|
package p;
|
|
import "DPI-C" function void env_final();
|
|
endpackage
|
|
====
|
|
# a DPI import's argument list breaks like any other, one per line
|
|
# corpus/ibex/dv/cs_registers/reg_driver/reg_dpi.sv:8
|
|
package p;
|
|
import "DPI-C"
|
|
function void monitor_tick (
|
|
input string name,
|
|
input bit rst_n,
|
|
input bit [1:0] csr_op,
|
|
input bit [11:0] csr_addr,
|
|
input bit [31:0] csr_wdata,
|
|
input bit [31:0] csr_rdata);
|
|
endpackage
|
|
----
|
|
package p;
|
|
import "DPI-C" function void monitor_tick(
|
|
input string name,
|
|
input bit rst_n,
|
|
input bit [1:0] csr_op,
|
|
input bit [11:0] csr_addr,
|
|
input bit [31:0] csr_wdata,
|
|
input bit [31:0] csr_rdata
|
|
);
|
|
endpackage
|
|
====
|
|
# a DPI import with no port list at all, returning `chandle`
|
|
# corpus/ibex/dv/verilator/simple_system_cosim/ibex_simple_system_cosim_checker.sv:29
|
|
module m;
|
|
import "DPI-C" function chandle get_spike_cosim;
|
|
endmodule
|
|
----
|
|
module m;
|
|
import "DPI-C" function chandle get_spike_cosim;
|
|
endmodule
|
|
====
|
|
# `context` keeps its place, and packed multi-dimensional argument types survive
|
|
# corpus/ibex/vendor/lowrisc_ip/ip/prim/dv/prim_ascon/ascon_model_dpi/ascon_model_dpi_pkg.sv:8
|
|
package p;
|
|
import "DPI-C" context function void c_dpi_ascon_round(
|
|
input bit[4:0][7:0][7:0] data_i,
|
|
input bit[7:0] round_i,
|
|
output bit[4:0][7:0][7:0] data_o
|
|
);
|
|
endpackage
|
|
----
|
|
package p;
|
|
import "DPI-C" context function void c_dpi_ascon_round(
|
|
input bit [4:0][7:0][7:0] data_i,
|
|
input bit [7:0] round_i,
|
|
output bit [4:0][7:0][7:0] data_o
|
|
);
|
|
endpackage
|
|
====
|
|
# arguments without a direction keyword, and an unsized unpacked dimension
|
|
# corpus/ibex/vendor/lowrisc_ip/ip/prim/dv/prim_present/crypto_dpi_present/crypto_dpi_present_pkg.sv:12
|
|
package p;
|
|
import "DPI-C" function chandle c_dpi_present_mk(int unsigned key_size,
|
|
bit [127:0] key);
|
|
import "DPI-C" context function void c_dpi_aead_encrypt(output byte unsigned ct[],
|
|
input byte unsigned msg[]);
|
|
endpackage
|
|
----
|
|
package p;
|
|
import "DPI-C" function chandle c_dpi_present_mk(int unsigned key_size, bit [127:0] key);
|
|
import "DPI-C" context function void c_dpi_aead_encrypt(
|
|
output byte unsigned ct [],
|
|
input byte unsigned msg []
|
|
);
|
|
endpackage
|
|
====
|
|
# `longint unsigned` returns and arguments
|
|
# corpus/ibex/vendor/lowrisc_ip/ip/prim/dv/prim_prince/crypto_dpi_prince/crypto_dpi_prince_pkg.sv:14
|
|
package p;
|
|
import "DPI-C" context function longint c_dpi_prince_encrypt(
|
|
input longint unsigned data,
|
|
input int unsigned num_half_rounds
|
|
);
|
|
endpackage
|
|
----
|
|
package p;
|
|
import "DPI-C" context function longint c_dpi_prince_encrypt(
|
|
input longint unsigned data,
|
|
input int unsigned num_half_rounds
|
|
);
|
|
endpackage
|
|
====
|
|
# a `pure` DPI import, and a DPI-imported task
|
|
package p;
|
|
import "DPI-C" pure function int clog2( input int x );
|
|
import "DPI-C" context task tick(input int cycles);
|
|
endpackage
|
|
----
|
|
package p;
|
|
import "DPI-C" pure function int clog2(input int x);
|
|
import "DPI-C" context task tick(input int cycles);
|
|
endpackage
|
|
====
|
|
# the `c_identifier =` linkage-name spelling, on an import and on an export
|
|
package p;
|
|
import "DPI-C" my_c_name=function void f(input int x);
|
|
import "DPI-C" context other_name = task t();
|
|
export "DPI-C" exported_c_name = function f;
|
|
endpackage
|
|
----
|
|
package p;
|
|
import "DPI-C" my_c_name = function void f(input int x);
|
|
import "DPI-C" context other_name = task t();
|
|
export "DPI-C" exported_c_name = function f;
|
|
endpackage
|
|
====
|
|
# a DPI export next to the function it names
|
|
# corpus/ibex/examples/simple_system/rtl/ibex_simple_system.sv:369
|
|
module m;
|
|
export "DPI-C" function mhpmcounter_num;
|
|
|
|
function automatic int unsigned mhpmcounter_num();
|
|
return 0;
|
|
endfunction
|
|
endmodule
|
|
----
|
|
module m;
|
|
export "DPI-C" function mhpmcounter_num;
|
|
|
|
function automatic int unsigned mhpmcounter_num();
|
|
return 0;
|
|
endfunction
|
|
endmodule
|
|
====
|
|
# a DPI export inside a generate block, under a directive
|
|
# corpus/ibex/rtl/ibex_if_stage.sv:378
|
|
module m;
|
|
if (1) begin : g
|
|
`ifndef SYNTHESIS
|
|
export "DPI-C" function simutil_get_scramble_key;
|
|
export "DPI-C" task simutil_tick;
|
|
`endif
|
|
end
|
|
endmodule
|
|
----
|
|
module m;
|
|
if (1) begin : g
|
|
`ifndef SYNTHESIS
|
|
export "DPI-C" function simutil_get_scramble_key;
|
|
export "DPI-C" task simutil_tick;
|
|
`endif
|
|
end
|
|
endmodule
|
|
====
|
|
# a wildcard package re-export
|
|
# corpus/ibex/dv/uvm/core_ibex/common/ibex_mem_intf_agent/ibex_mem_intf_agent_pkg.sv:28
|
|
package p;
|
|
export ibex_mem_intf_pkg::* ;
|
|
endpackage
|
|
----
|
|
package p;
|
|
export ibex_mem_intf_pkg::*;
|
|
endpackage
|
|
====
|
|
# a package re-export naming individual items
|
|
# corpus/ibex/vendor/lowrisc_ip/dv/sv/csr_utils/csr_utils_pkg.sv:10
|
|
package p;
|
|
import dv_base_reg_pkg::*;
|
|
export dv_base_reg_pkg::csr_field_t,dv_base_reg_pkg::decode_csr_or_field;
|
|
endpackage
|
|
----
|
|
package p;
|
|
import dv_base_reg_pkg::*;
|
|
export dv_base_reg_pkg::csr_field_t, dv_base_reg_pkg::decode_csr_or_field;
|
|
endpackage
|
|
====
|
|
# `export *::*;` — the LRM's re-export-everything form (no corpus hits)
|
|
package p;
|
|
export * :: *;
|
|
endpackage
|
|
----
|
|
package p;
|
|
export *::*;
|
|
endpackage
|
|
====
|
|
# comments cling to a DPI import: leading, trailing, and inside the arg list
|
|
package p;
|
|
// what it does
|
|
|
|
import "DPI-C" function void f( // opens
|
|
input int a, // first
|
|
// about b
|
|
input int b /* before comma */,
|
|
input int c
|
|
); // done
|
|
endpackage
|
|
----
|
|
package p;
|
|
// what it does
|
|
import "DPI-C" function void f(
|
|
// opens
|
|
input int a, // first
|
|
// about b
|
|
input int b /* before comma */,
|
|
input int c
|
|
); // done
|
|
endpackage
|
|
====
|
|
# a DPI import and a DPI export inside a `verilog_format: off` fence stay byte-exact
|
|
package p;
|
|
// verilog_format: off
|
|
import "DPI-C" function void f( input int a );
|
|
export "DPI-C" function f;
|
|
export p2::*;
|
|
// verilog_format: on
|
|
import "DPI-C" function void g();
|
|
endpackage
|
|
----
|
|
package p;
|
|
// verilog_format: off
|
|
import "DPI-C" function void f( input int a );
|
|
export "DPI-C" function f;
|
|
export p2::*;
|
|
// verilog_format: on
|
|
import "DPI-C" function void g();
|
|
endpackage
|
|
====
|
|
# the header fits at exactly 100 columns and breaks at 101
|
|
package p;
|
|
import "DPI-C" context function void aaaaaaaaaaaaaaaaaaaaaaaaaa(input int bbbbbbbbb, int ccccccc);
|
|
import "DPI-C" context function void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(input int bbbbbbbbb, int ccccccc);
|
|
endpackage
|
|
----
|
|
package p;
|
|
import "DPI-C" context function void aaaaaaaaaaaaaaaaaaaaaaaaaa(input int bbbbbbbbb, int ccccccc);
|
|
import "DPI-C" context function void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
|
|
input int bbbbbbbbb,
|
|
int ccccccc
|
|
);
|
|
endpackage
|
|
====
|
|
# an ordinary package import is untouched by the DPI spelling next to it
|
|
package p;
|
|
import q::*;
|
|
import "DPI-C" function void f();
|
|
import r::t , s::u;
|
|
endpackage
|
|
----
|
|
package p;
|
|
import q::*;
|
|
import "DPI-C" function void f();
|
|
import r::t, s::u;
|
|
endpackage
|
|
====
|
|
# DPI imports and exports inside a class body
|
|
class c;
|
|
import "DPI-C" function int c_get(input int i);
|
|
export "DPI-C" function sv_put;
|
|
function void sv_put(int v);
|
|
endfunction
|
|
endclass
|
|
----
|
|
class c;
|
|
import "DPI-C" function int c_get(input int i);
|
|
export "DPI-C" function sv_put;
|
|
function void sv_put(int v);
|
|
endfunction
|
|
endclass
|
|
====
|
|
# at compilation-unit scope, outside any package or module
|
|
import "DPI-C" function void f(input int a);
|
|
export "DPI-C" function g;
|
|
export p::*;
|
|
----
|
|
import "DPI-C" function void f(input int a);
|
|
export "DPI-C" function g;
|
|
export p::*;
|
|
====
|