llvm / circt

Circuit IR Compilers and Tools
https://circt.org
Other
1.57k stars 277 forks source link

[FIRRTL] Add optional arg name to DPI-C functions #7226

Open sequencer opened 6 days ago

sequencer commented 6 days ago

The current version of DPI-C cannot encode arg name of function call, if there are too much args, it will cause naming hell. see example:

import "DPI-C" function void axi_write(
  input longint                                                           in_0,
                                                                          in_1,
                                                                          in_2,
                                                                          in_3,
                                                                          in_4,
                                                                          in_5,
                                                                          in_6,
                                                                          in_7,
                                                                          in_8,
                                                                          in_9,
  input struct packed {bit [255:0][255:0] data; bit [255:0][31:0] strb; } in_10
);

I'm proposing the arg field providing name to the intrinsic field to make the function import becoming:

node result = intrinsic(circt_dpi_call<isClocked = 1, functionName="axi_write", argName="awid,awaddr,awlen,awsize,awburst,awlock,awcache,awprot,awqos,awregion,payload"> : UInt<64>, clock, enable, ...)
import "DPI-C" function void axi_write(
  input longint                                                           awid,
                                                                          awaddr,
                                                                          awlen,
                                                                          awsize,
                                                                          awburst,
                                                                          awlock,
                                                                          awcache,
                                                                          awprot,
                                                                          awqos,
                                                                          awregion,
  input struct packed {bit [255:0][255:0] data; bit [255:0][31:0] strb; } payload
);