Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Header file for VHPIDIRECT/C and demo #3

Open
4 of 11 tasks
umarcor opened this issue Apr 12, 2020 · 4 comments
Open
4 of 11 tasks

Header file for VHPIDIRECT/C and demo #3

umarcor opened this issue Apr 12, 2020 · 4 comments

Comments

@umarcor
Copy link
Member

umarcor commented Apr 12, 2020

This issue is to discuss the implementation of a header file ghdl.h that provides an API to (de)code/convert GHDL's non-trivial data types. Precisely, to update https://ghdl.github.io/ghdl-cosim/vhpidirect/declarations.html by providing an easy-to-use solution for the types that are currently considered too difficult.

WIP: https://github.com/umarcor/ghdl-cosim/blob/header/vhpidirect/ghdl.h

Refs:

This issue is directly related to #2, because the functions provided in ghdl.h need to be accesible to foreign languages that load simulation models dynamically (as in VUnit/vunit#568). Hence, a *.ver script needs to be provided along with ghdl.h.

/cc @RocketRoss @bradleyharden


  • Most non-composite types (character/char, integer/int32_t, natural/uint32_t, positive/uint32_t, real/double, boolean/bool, bit/bool, time/int64_t, short enum/uint8_t)
  • Record/struct
  • Arrays with static bounds (note: we have found no issues with these so far)
  • Unconstrained arrays
    • Strings
    • With dimensions of type natural.
  • Accesses to unconstrained arrays
    • Strings (i.e. line)
    • With dimensions of type natural.
  • Other accesses.
  • Files

As expected, handling unconstrained arrays is neither straightforward nor intuitive. Hence, the main purpose of the demo is to make it easier for new users to use these. The following helper functions are provided:

  • char* ghdlToString(ghdl_NaturalDimArr_t* ptr): convert a fat pointer of an unconstrained string, to a (null terminated) C string
  • void ghdlToArray(ghdl_NaturalDimArr_t* ptr, void** vec, int* len, int num): convert a fat pointer of an uncontrained array with (up to 3) dimensions of type 'natural', to C types
  • ghdl_NaturalDimArr_t ghdlFromString(char *string): convert a (null terminated) C string, to a fat pointer of an unconstrained string
  • ghdl_NaturalDimArr_t ghdlFromArray(void* vec, int* len, int num): convert C types representing an unconstrained array with a dimension of type 'natural', to a fat pointer (not complete yet
  • char* ghdlAccToString(ghdl_AccNaturalDimArr_t *line): convert an access to an unconstrained string, to a (null terminated) C string
  • void ghdlAccToArray(ghdl_AccNaturalDimArr_t* ptr, void** vec, int* len, int num): convert an access to an unconstrained array with a dimension of type 'natural', to C types (not implemented yet)
  • ghdl_AccNaturalDimArr_t* ghdlAccFromArray(uint32_t length, size_t bytes): convert C types representing an unconstrained array with a dimension of type 'natural', to an access
  • ghdl_AccNaturalDimArr_t* ghdlAccFromString(char *string): convert a (null terminated) C string, to an access to an unconstrained string
@umarcor
Copy link
Member Author

umarcor commented Apr 12, 2020

@RocketRoss, can you rebase/rework umarcor/ghdl#1 on top of https://github.com/umarcor/ghdl-cosim/tree/header?

@radonnachie
Copy link
Contributor

Im on it

@radonnachie
Copy link
Contributor

umarcor/pull/3

Is that clean enough?

@umarcor
Copy link
Member Author

umarcor commented Jul 15, 2020

Ref umarcor#17 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants