VUnit / vunit

VUnit is a unit testing framework for VHDL/SystemVerilog
http://vunit.github.io/
Other
739 stars 263 forks source link

Python method to export dependencies for a given source for a specific IDE #352

Open FranzForstmayr opened 6 years ago

FranzForstmayr commented 6 years ago

I would like to have a Python method, which exports all dependencies for a given source file into a format, which common IDE's accept.

I'm using vivado, which can read a .tcl file. So the method should export a tcl file, which i can read in vivado. The method should list the files directly and libraries. I can serve a pull request for this issue (only vivado), are there any additional functions, which we can provide easily? Are there any doubts?

kraigher commented 6 years ago

Have you looked at: http://vunit.github.io/python_interface.html#vunit.ui.VUnit.get_source_files http://vunit.github.io/python_interface.html#vunit.ui.VUnit.get_compile_order http://vunit.github.io/python_interface.html#vunit.ui.VUnit.get_implementation_subset

FranzForstmayr commented 6 years ago

I've looked at the first two, but not the latter one. This would be what i need, but i would like to have an IDE specific wrapper around, which is able to format the files properly. Do you want something like this in Vunit?

kraigher commented 6 years ago

The IDE specific wrapper would be written by the user. I do not think it belongs in VUnit as the goal of VUnit is not to be a build tool that is used for synthesis. Ideally there is a higher level HDL package/module system that uses VUnit to run tests and something else to run synthesis.

FranzForstmayr commented 6 years ago

Yes of course. For example in vivado i have to manually find my dependencies. Then i run synthesis for about 5 min. and vivado tells me, there's another missing file. This would be easier, if the run.py is able to export a tcl script, which you are importing into vivado and everything is fine. I have to write a function like this for my personal purposes. If you don't need it, I won't make a pull request.

FranzForstmayr commented 6 years ago

I just tried the 'get_implementation_subset()'. I'm using the PoC library, but the lib is not visible in the listed implementation subset. I didn't set the 'no_parse' flag. Should the vhdl parser be able to parse the library dependencies or do i have to set the dependency manually?

eine commented 6 years ago

Coming form #347.

@FranzForstmayr I need a similar feature, also in TCL, but targeting Mentor Graphics' Precision RTL (Plus). I am considering to just export the implementation subset to a JSON file and then write a generic snippet composed of two nested for loops in TCL. Would you be interested in sharing this approach?

FranzForstmayr commented 6 years ago

Hi, i wanted to try a python method, which exports a .tcl to get read in vivado. So no external tcl script should be necessary. I'll try this on my local fork the next days

FranzForstmayr commented 6 years ago

@1138-4EB Ok, lets make a implementation subset in JSON. I though about:

{
    "name"  : "myproject",
    "vhdl_standard" : "2008",
    "compile_options" : {
       "ghdl.flags" : ["flag1", "flag2"],
       "ghdl.elab_flags" : ["flag3", "flag4"]},
    "sim_options" : {
       "ghdl.flags" : ["flag1", "flag2"],
       "ghdl.elab_flags" : ["flag3", "flag4"]},
    "libraries" : {
        "vhdl_standard" : "specify, or use global defined above",
        "files" : [
            "src/Test1.vhd", "src/Test2.vhd", "tb/Test3_tb.vhd"
        ]
    }
}

Or should we split up the files, as you can define a different vhdl standard for each file. I don't know, if there's a simulator which supports different standards within one lib.

eine commented 6 years ago

Sorry @FranzForstmayr, I missed your last message. Please, have a look at https://github.com/VUnit/vunit/issues/347#issuecomment-416055643 and https://github.com/VUnit/vunit/issues/347#issuecomment-416059855. As commented there, I think it is interesting to group files per library.

I am neither aware of how mixed standard versions are supported. So, specifying it at the top level is ok for me.