C Bindings¶
GenC produces a C header declaring the DPI-C interface for a given root
interface hierarchy. It is designed to pair with the GenSV DPI glue
package so that C code can call into SystemVerilog interface methods across
the DPI boundary.
Generated Artifacts¶
The generator requires a --root-if argument identifying the root
interface:
$ python -m ml_hpi generate --spec spec.yaml --outdir gen/ --lang c \
--root-if pkg.RegIf
This produces pkg_RegIf_dpi.h containing:
externdeclarations for DPI export functions (SV provides, C calls).Prototype declarations for completion import functions (C provides, SV calls on blocking method finish).
Package init / scope helper declarations.
Example output (abbreviated):
#ifndef PKG_REGIF_DPI_H
#define PKG_REGIF_DPI_H
#include <stdint.h>
#include <stdbool.h>
#include "svdpi.h"
#ifdef __cplusplus
extern "C" {
#endif
/* DPI exports -- implemented in SystemVerilog, called from C */
extern void pkg_RegIf_write32(int root_id, int path,
uint64_t addr, uint32_t data, void *cb);
extern void pkg_RegIf_read32(int root_id, int path,
uint64_t addr, void *cb);
/* Completion imports -- implemented in C, called from SystemVerilog */
void pkg_RegIf_write32_complete(void *cb);
void pkg_RegIf_read32_complete(void *cb, uint32_t rval);
int pkg_RegIf_dpi_init(void);
void pkg_RegIf_dpi_set_scope(void);
#ifdef __cplusplus
}
#endif
#endif
Type Mapping¶
ml-hpi |
C |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Limitations¶
There is no C parser. C headers generated by
GenCare DPI glue and do not contain enough semantic information to reconstruct anMlHpiDoc.Blocking methods use an opaque
void *cbcallback handle; the C side must call the corresponding_completefunction when the operation finishes.