aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl/python/libghdl/__init__.py
blob: 6589aec3f401ac2c49823b5388ae3c1ba086cc76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import ctypes
import os.path
from libghdl.config import libghdl_filename

# Load the DLL.
_basedir = os.path.dirname(__file__)
libghdl = ctypes.CDLL(os.path.join(_basedir, libghdl_filename))

# Low-level initialization (elaboration).
libghdl.libghdl_init()

# Set the default prefix.
_prefix = os.path.join(_basedir, "ghdl")
_prefix_opt = ("--PREFIX=" + _prefix).encode('utf-8')
libghdl.libghdl__set_option(
    ctypes.c_char_p(_prefix_opt), len(_prefix_opt))

# libghdl

_set_option = libghdl.libghdl__set_option
_analyze_file = libghdl.libghdl__analyze_file


def set_option(opt):
    return _set_option(ctypes.c_char_p(opt), len(opt))


def analyze_init():
    return libghdl.libghdl__analyze_init()


def analyze_file(filename):
    return _analyze_file(ctypes.c_char_p(filename), len(filename))