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

Convert VHDL package to Verilog or SV #168

Open
jabate-anova opened this issue Apr 5, 2022 · 2 comments
Open

Convert VHDL package to Verilog or SV #168

jabate-anova opened this issue Apr 5, 2022 · 2 comments

Comments

@jabate-anova
Copy link

I have VHDL package files in my current directory which I'd like to convert to Verilog or SV using hdlConvertor. Is this possible?

As in the notebook example, I'm able to use visit_HdlContext(d) to display a VHDL package:

from hdlConvertor import HdlConvertor
from hdlConvertorAst.to.vhdl.vhdl2008 import ToVhdl2008

TEST_DIR = os.path.join("./")
filenames = [os.path.join(TEST_DIR, "axis_pkg.vhd"), ]
include_dirs = []
c = HdlConvertor()
d = c.parse(filenames, Language.VHDL, include_dirs, hierarchyOnly=False, debug=True)
to_vhdl = ToVhdl2008(sys.stdout) 
to_vhdl.visit_HdlContext(d) 

I see that the hdlConvertorAst.translate module may be able to help me, but I'm not sure how to proceed. If I import VHDL to verilog (from hdlConvertorAst.translate import vhdl_to_verilog), how could I use vhdl_to_verilog.link_module_dec_def(context) with my parsed VHDL?

Any help is appreciated, thanks!

@Nic30
Copy link
Owner

Nic30 commented Jun 16, 2022

@jabate-anova

Sorry, I am seeing this issue just now, there are may people asking the same and the response is:

In some cases it is possible but it generic case it is not. It also depends on what you are expecting.
There are construct in VHDL which does not have equivalent in SV.
And there many builtin functions/data types. Translation of many elements does need full implementation of VHDL typesystem, builtins and std library. All this is ridiculous amount of work.

I did several translations of commercial projects. I recommend this:
Use hdlConvertor to parse VHDL AST, and hdlConvertor/hdlConvertorAst to print verilog. There are several translation helpers in
hdlConvertorAst.translate but they are not complete and you will need to implement things which are used in your code.

@poleguy
Copy link

poleguy commented Aug 23, 2023

This is the same question I was about to ask. I can't find any examples that produce valid verilog starting from even trivial VHDL. Can we produce a working python example from any of the 'cases' that are possible? Just as a starting point? And maybe a trivial working example that uses hdlConvertorAst.translat.vhdl_to_verilog?

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

No branches or pull requests

3 participants