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

cinterface/accarraygen example (Bounded by Generic Package - VHDL 2008) #5

Open
wants to merge 27 commits into
base: master
Choose a base branch
from

Conversation

radonnachie
Copy link

umarcor/ghdl/pull/1

Examples of sharing dynamically bounded arrays from C to VHDL.

  • AccArrayInt: an integer is shared from C to VHDL, representing the length of the array. VHDL declares a type array(0 to cInt-1) and that is the bounded array.
  • AccArrayGen: a generic mapped from the top level entity to the generic package (VHDL 2008) determines the bound of the array.
    • This is not working. Currently I am only getting ghdl bugs. Firstly I want make sure that I am using VHDL protected shared accesses correctly before filing a bug.

  • Addition of example 'accarray', "Access to array". Actually, I'd further split it into 3 different examples:
    • ...
    • A second one to pass an array, including two possible solutions to using shared variables (-frelaxed or defining a protected type). This should use "easy" types.

@radonnachie
Copy link
Author

@umarcor Please tell me you will be able to help me learn how to use generic packages and shared protected accesses... I think most of what is there is fine. The ghdl bug printout I get:

bash ./run.sh
Analyze cAccess.vhd and tb.vhd
sem_named_entities: cannot handle IIR_KIND_PROTECTED_TYPE_DECLARATION (cAccess.vhd:11:13)

******************** GHDL Bug occurred ***************************
Please report this bug on https://github.com/ghdl/ghdl/issues
GHDL release: 1.0-dev (v0.37.0-274-g93d01c6d) [Dunoon edition]
Compiled with GNAT Version: 7.5.0
Target: x86_64-linux-gnu
/mnt/d/Development/OpenSource/ghdl-cosim/vhpidirect/cinterface/accarraygen/
Command line:
/etc/ghdl-llvm-PIC/bin/ghdl1-llvm --std=08 -P/etc/ghdl-llvm-PIC/lib/ghdl/ieee/v08/ -P/etc/ghdl-llvm-PIC/lib/ghdl/ -c -fpic -o cAccess.o cAccess.vhd
Exception TYPES.INTERNAL_ERROR raised
Exception information:
raised TYPES.INTERNAL_ERROR : vhdl-errors.adb:32
Call stack traceback locations:
0x4b5e8d 0x56194e 0x562504 0x56b097 0x56b389 0x54aa4f 0x54c2e6 0x5675ce 0x56b028 0x56b389 0x57969f 0x57ab4f 0x532ea4 0x64d4d5 0x64f108 0x650a01 0x4086c9 0x7fc0b90a1b95 0x4079b8 0xffffffff
fffffffe
******************************************************************
ghdl:error: compilation error

@umarcor
Copy link
Owner

umarcor commented Apr 13, 2020

@umarcor Please tell me you will be able to help me learn how to use generic packages and shared protected accesses...

I will! Let's solve #4 first. Then, we will discuss naming, .c/.h and style issues. When that is done, it will be easier to dive into this!

@radonnachie radonnachie changed the title Acc array examples. AccArray example Apr 14, 2020
@radonnachie radonnachie changed the title AccArray example cinterface/accarraygen example (Bounded by Generic, VHDL 2008) Apr 14, 2020
@radonnachie radonnachie changed the title cinterface/accarraygen example (Bounded by Generic, VHDL 2008) cinterface/accarrayint+gen examples (Bounded by Int/Generic w/ VHDL 2008) Apr 15, 2020
@radonnachie
Copy link
Author

VHDL2008 Generic Package bugs out with VHPIDRECT (ghdl/ghdl/issues/1229)

@radonnachie
Copy link
Author

ghdl/ghdl/issues/1229 has been resolved, final test will work when git side updates its ghdl. how to?

@umarcor
Copy link
Owner

umarcor commented Apr 16, 2020

ghdl/ghdl/issues/1229 has been resolved, final test will work when git side updates its ghdl. how to?

Just wait up to 24h. Then restart the tests, or force push again. Docker images are updated daily: https://github.com/ghdl/docker#-daily-3-jobs--max-3--6-images-daily. There is no triggering mechanism to force them being updated when changes are pushed to ghdl/ghdl.

radonnachie added a commit to radonnachie/ghdl-cosim that referenced this pull request Apr 17, 2020
@umarcor
Copy link
Owner

umarcor commented Apr 18, 2020

It seems that you found another legit bug... Is this one of the issues that you already opened in ghdl/ghdl?

@radonnachie
Copy link
Author

It seems that you found another legit bug

The bug printout above I no longer get. I don't think that the VHDL code was good. I'll checkout that commit and verify if the bug persists.

The current run.sh succeeds on linux but produces a bug on windows. So that may be a legit bug.

******************** GHDL Bug occurred ***************************
Please report this bug on https://github.com/ghdl/ghdl/issues
GHDL release: 0.37 (v0.37) [Dunoon edition]
Compiled with GNAT Version: 9.1.0
Target: x86_64-w64-mingw32
D:\a\ghdl-cosim\ghdl-cosim\vhpidirect\cinterface\accarraygen\
Command line:
D:\a\ghdl-cosim\ghdl\bin\ghdl1-llvm.exe --std=08 -PD:\a\ghdl-cosim\ghdl\lib/ghdl\ieee\v08\ -PD:\a\ghdl-cosim\ghdl\lib/ghdl\ -c -o tb.o tb.vhd
Exception TYPES.INTERNAL_ERROR raised
Exception information:
raised TYPES.INTERNAL_ERROR : vhdl-sem_inst.adb:271
Call stack traceback locations:
0x4f0a03 0x4f18a5 0x4f0993 0x4f18a5 0x4f088a 0x4f284c 0x568545 0x559c60 0x559db9 0x52cd09 0x562b1b 0x569225 0x5240ef 0x635384 0x636fcf 0x6389e5 0x402685 0x40138a 0x4014b9 0x7ffdea127972 0x7ffdeaf4a25f
******************************************************************

@radonnachie
Copy link
Author

radonnachie commented Apr 19, 2020

The first bug report I mentioned seems to occur when the protected type has the foreign VHPIDIRECT function in it.

Latest commit the foreign subprog is just in the package, not the protected type.

I have not posted this bug. I'll look to do so. A different cause for it, but ghdl/ghdl/issues/1244 causes the same issue.

@umarcor
Copy link
Owner

umarcor commented Apr 19, 2020

The current run.sh succeeds on linux but produces a bug on windows. So that may be a legit bug.

Yes, I meant the one that happens on Windows only.

@radonnachie
Copy link
Author

It boils down to Generic package having a VHPIDIRECT function. ghdl/ghdl/issues/1229
I'm willing to bet that if I compiled GHDL from master for windows the bug wouldn't come up.
Shall I comment out the test until the GHDL windows realease is incremented?

@umarcor
Copy link
Owner

umarcor commented Apr 19, 2020

Shall I comment out the test until the GHDL windows realease is incremented?

Yes, please. Add a comment: #vhpidirect/..., ! fails with v0.37; should work with 'master'.

@radonnachie radonnachie changed the title cinterface/accarrayint+gen examples (Bounded by Int/Generic w/ VHDL 2008) cinterface/accarraygen example (Bounded by Generic Package - VHDL 2008) Apr 20, 2020
vhpidirect/cinterface/accarraygen/caux.c Outdated Show resolved Hide resolved
.github/workflows/test.yml Outdated Show resolved Hide resolved
vhpidirect/cinterface/accarraygen/run.sh Outdated Show resolved Hide resolved
vhpidirect/cinterface/accarraygen/tb.vhd Outdated Show resolved Hide resolved
Copy link
Owner

@umarcor umarcor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, pkg.vhd looks a lot like quickstart/sharedvar/pkg_08.vhd. In fact, it is almost the same, but here the package is a generic package, and the variable is an array instead of an integer.

At the same time caux.c is very similar to quickstart/intvector/vhdlsized/caux.c.

This makes sense, because this new example is a mix between the protected type in quickstart/sharedvar and the vhdlsized vector in intvector.

I think we should make this explicit by using the same files, if possible. At least, by copying the functions/names that are common to the base examples.

BTW, you can use this comment as the base for the (missing) docs of this example.

@@ -75,6 +76,7 @@ jobs:
vhpidirect/shared/shlib,
#vhpidirect/shared/dlopen, ! dlfcn.h is not available on win
#vhpidirect/shared/shghdl, ! dlfcn.h is not available on win
#vhpidirect/arrays/invector/vhdlpkgsized, ! fails with v0.37, should work with master (fixed under #1229)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should go below intvector, since it is a subexample. Ideally, we would not add a subexample to the CI list explicitly. Instead, intvector should have a single run.sh that calls other children run.sh if required. However, since we would need to check the host OS in order to do that, I think it's ok to keep it for now.

@@ -75,6 +76,7 @@ jobs:
vhpidirect/shared/shlib,
#vhpidirect/shared/dlopen, ! dlfcn.h is not available on win
#vhpidirect/shared/shghdl, ! dlfcn.h is not available on win
#vhpidirect/arrays/intvector/vhdlpkgsized, ! fails with v0.37, should work with master (fixed under #1229)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this is fixed in the docker image now?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, doesn't look like the windows ghdl has changed.


int main(int argc, char const *argv[])
{
int vectorLength = 0;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel that +20 lines is too much, since this is not the main feature that we want to show. I think we should accept a single --grow-vec=3 or --grow-vec 3 and multiply it with the size. More complex examples would fit in #14.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually really want to move the main.c to #14...
We would do so after this is merged for sure. And it would just take the main.c file and the appropriate half of the run.sh file....

vhpidirect/arrays/intvector/vhdlpkgsized/pkg.vhd Outdated Show resolved Hide resolved
vhpidirect/arrays/intvector/vhdlpkgsized/pkg.vhd Outdated Show resolved Hide resolved
@radonnachie
Copy link
Author

This makes sense, because this new example is a mix between the protected type in quickstart/sharedvar and the vhdlsized vector in intvector.

sharedvar only references the address of an integer, so the get/set do not take indices, nor is there a free subprog.

If we make a sharedvarIntArr, then we can reuse files.

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

Successfully merging this pull request may close these issues.

None yet

2 participants