Replies: 7 comments 1 reply
-
I see what you mean. The issue is at lines 465-6 in
Where it has
I don't know what your linking process has for requirements, because you haven't said what you're doing for linking. Are you using BSC to perform the linking step or are you directly executing a downstream tool? In either case, it would help to see the command-line flags you are using for compile and link. If you are using BSC to link, make sure to provide the
This flag will cause BSC to generate
There is no mention of the
This confuses me, because you shouldn't need to move anything. And nothing needs to be in the same directory as the source files for the imported functions -- if you're linking with BSC, you just provide the files on the command line. But maybe it's because I don't understand what "linking into a non-cwd dir" means. Can you show the command lines? I have written a test that uses BSC to compile and link in multiple configurations (with and without vdir, etc) and it works for me. The source file is in a subdirectory (as shown in the commands above), but I am calling BSC from the same directory in both the compile and link steps. The C file is also in another directory, separate from everything else. (In my case, I am providing the |
Beta Was this translation helpful? Give feedback.
-
Thanks! Replies inline.
Excellent. Thanks. Is there an issue open for this now?
I am using https://github.com/rossc719g/bsc_examples But also have some example command lines below.
I have not used the But, creating a .ba for every module in my design might be tricky for me, because bazel needs to know about every consumed and produced file at every step, before executing the tools, and without inspecting the source. So, I'd need to enumerate every module in the
This is what I am currently doing. It is creating the
Then I am probably doing something wrong. The example repo I mentioned above will probably help. Sorry I did not take the time to make it initially.
The example scripts in my repo all print the command lines when they run, and the README.md does a better job of explaining it all, but briefly, given this example source tree:
Beef.bsv and Cafe.bsv both have BDPI imports, and the *Test.bs files use them. Here are the command lines that show what I mean.
That last linking step fails with:
Since the Again, the repo does a better job of explaining my issues. And, regarding my confusion of I am considering completely segregating all my I hope I am explaining myself better this time! And thanks again! |
Beta Was this translation helpful? Give feedback.
-
I've submited PR #576, which I'll merge soon. (Unless the following issue requires rethinking where VPI files get written.)
It's looking in We do anticipate that someone might compile files as a library, that they then provide to others. (In a way, you're compiling libraries, that you then use yourself.) If someone makes a library containing imported C functions, it will have VPI wrapper functions that need to be handed off, too. It seems like there's not a good way for that to happen. So probably BSC's linking step needs a better way to find the wrapper files than by using a single
I don't think the third option is reasonable. And I think the first option would require placing the wrappers in the same directory with the Since the BSC compile places the wrapper with the Verilog, it would make sense to use the Verilog search path. If compilation has been done into several different If adding
Let me first say that I avoid using Also, the The The If module You can even reuse So if you want to avoid synthesizing a module twice, you can compile with Each Verilog module has its own scheduler, and they work in parallel with each other by using the EN and RDY ports, to schedule a whole design. As a result, BSC can generate Verilog modules separately. Bluesim works by gathering up the entire design and making one global scheduler, that tells the rules in each module when to execute. Bluesim, therefore, needs to see the entire design hierarchy. The BSC can even take a |
Beta Was this translation helpful? Give feedback.
-
Great, sounds good.
Absolutely. I agree with your comments 100%. It feels like
Until recently, I did this as well, and I agree it is a bit cleaner. The reason I stopped was just because
This is interesting... but from your other comments I understood that this will generate a
Makes sense. That matches well with my setup. I am already using the And thanks for the Did you see the third issue |
Beta Was this translation helpful? Give feedback.
-
No. You only get The
Oh, I did not. Thanks for pointing that out. In one case, you are running this command:
(I've added the The only thing that makes the executable be placed in a directory is that the filename given to Separately, are you concerned about work files that are generated by the Verilog simulator linking? For different simulators, there may be additional files that are placed in the current directory (where BSC is invoked), which are not needed after the executable is created. For VPI, different simulators have different requirements for files that need to be provided during linker. Older versions of Icarus Verilog need a |
Beta Was this translation helpful? Give feedback.
-
Ah, I misunderstood. Then, it sounds like, except for the
Yep. That does make the most sense to me.
As long as they are not needed at runtime and I can ignore them, then they do not cause any issues for my workflow since Personally, I think the least surprising thing would be for these files to be created in a temp dir somewhere (e.g., That said... if they are needed at runtime, then I feel like they should be next to the executable, and that the executable should then look for them there. Otherwise, your cwd must always be the same as the dir that contains the executable, or you need to copy files or make symlinks before running it. Doable... but awkward.
Yeah, your comments sum it up perfectly. It is a bit of an awkward thing to deal with. Assuming these .so files could not be statically linked into the executable, the trick I have used in the past is to wrap an executable in something like a |
Beta Was this translation helpful? Give feedback.
-
Just to circle back (and to thank you again!)... Initially, I was concerned about subtle consequences of forgetting to add those exceptions for cases where I use
But, as you said, for all cases where I don't use So, it seems to know the difference between a Again, truly.... Thanks for the tip! |
Beta Was this translation helpful? Give feedback.
-
I'm a little confused about the correct location for
vpi_wrapper_*.{ch}
files when compiling usingDBPI
.It seems like
bsc
will place them in thecwd
, unless I specify-vdir
, which is odd, because the docs say that-vdir
defaults to the location of the source file being compiled. This seems to be true for all other files governed by-vdir
, but not these?And then when linking, it seems like they all need to be in the same directory where the output file is being created, even if that is not the directory that contained the code that generated them.
E.g,
If I have this structure below my cwd:
And both files contain
BDPI
imports, then without-vdir
, both sets ofvpi_wrapper_
files will end up in thecwd
.If I do specify the
-vdir
to be the location of each source file when I compile them, then they end up in their respective directories.If I then try to link them into an executable in the
baz
directory (with the-p
path including bothfoo
andbar
), then I first need to move or copy them into thebaz
dir before linking.It seems like if you're linking into a non-
cwd
dir that does not contain yourBDPI
-containing source file, then there is no way to avoid needing themv
/cp
.Similarly, when linking using
VPI
,bsc
creates adirectc_*.so
file that always seems to end up in thecwd
, even if the executable is being built elsewhere. If I do not move it to the same place as the executable after linking, then it wont be able to find it at runtime.The reason I am asking is that I'm running
bsc
frombazel
, andbazel
is very persnickety about knowing exactly where each file is, so I need to know all of these behaviors, and explain them tobazel
. What I would normally do on the command line is just find the files and put them where they need to go manually, but I can't do that here.Anyway, I'm wondering if there is something I am missing about how these files behave that makes it all make sense?
Beta Was this translation helpful? Give feedback.
All reactions