Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Add packageless intvector examples (#5 a + c) #11
base: master
Are you sure you want to change the base?
Add packageless intvector examples (#5 a + c) #11
Changes from 1 commit
64b71a2
07efdff
95a760d
2bfef3e
7762ae1
34f25ab
cfb7846
3df7d0d
96553c5
43efa07
56079f9
c6410b2
7181f2f
201eb51
89d0c62
006b0e9
ad92bd4
2ad5c38
59f039c
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would limit
getIntArr_ptr
to retrieving the pointer.Optionally, you can add a
main.c
where thiscaux.c
is imported and the content ofintArray
is redefined before callingghdl_main
. This would not replace thecaux.c
only example. It'd be two subexamples of the same. This would be interesting, because it would be the example where to show why havingcaux.c
,caux.h
andmain.c
makes sense, and how to use them separated or together.Don't take me wrong: I like the concept of a get function that acts as a generator, because that's the essence of VUnit/vunit#603, and we are kind of blocked. However, I believe that it fits later, not in this example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I didn't stick to such a simple main.c+caux subexample, but I think you may like what I posted. I have not run through the many ways to compile and run the executable, as it is an early example, and we have a dedicated section for that, and the executable asks for user input.
The subexample prompts the user for the array's length, fills the array, and calls ghdl_main. Only thing I don't like is trusting the user to enter a reasonable number, but I cannot seem to break the executable with outrageous values so I think it is safe. Only thing is getting the test to provide runtime stdin input...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My point was not about different ways to compile and run the executable, but about different requirements dependending on the number of C files.
-Wl,main.c
or-Wl,caux.c
only. Already covered.-Wl,caux.c -Wl,main.c
. Not used yet. Questions that users might have:-I./
required?caux.h
need to exist?Of course, this can be explained in a different example instead of here.
I think it would be better to use/parse
argv[1]
. Three options:argc == 1
, useargv[1]
as an integer (atoi
).argv
and look for--size=
or-s
. Then useatoi
as in the previous point.--
in argv and consider all previous args to be "custom args for C". Then search for--size
or-s
as in the previous point. Pass args after--
to GHDL. Open question would be: what to do when--
is not found? Are all args for C or for ghdl_main?Either of these would be interesting because they'd show how to add custom args (that need to be removed from the argv passed to GHDL). I would not use any lib such as optargs, tho. We want to support a single custom argument.
Even if they try to, it's ok. See ghdl/ghdl#822.
I think it is better to pass argv, which allows
./tb 26
or./tb -s 26
or./tb --size=26
or./tb --size 26 -- --wave=mywave.ghw
.