Exemple #1
0
    def build_function(self, prototype_only=False):
        template = textwrap.dedent("""\
            procedure {NAME}{ARGUMENTS} is
            {MULTILINE_COMMENT}
            {VARIABLES}
            begin
            {BODY}
            end procedure;""")

        args = f'({self.arguments})' if len(self.arguments) > 2 else ''
        sockets = {
            'NAME': self.name,
            'MULTILINE_COMMENT': self.multiline_comment,
            'ARGUMENTS': args,
            'VARIABLES': tabber(self.variables) if self.variables else '',
            'BODY': tabber(self.build_body())
        }

        if prototype_only:
            return template.format(**sockets).splitlines()[0][:-3] + ';'
        return template.format(**sockets)
Exemple #2
0
    def build_typedefs_package(self):
        template = textwrap.dedent("""\
            {FILE_HEADER}
            library ieee;
                use ieee.std_logic_1164.all;
                use ieee.numeric_std.all;
                use ieee.fixed_float_types.all;
                use ieee.fixed_pkg.all;
                use ieee.math_real.all;
                
            library work;
                use work.complex_pkg.all;
                use work.PyhaUtil.all;
                use work.all;

            package Typedefs is
            {TYPES}
            end package;
            """)
        self.typedefs = list(dict.fromkeys(self.typedefs))  # remove duplicates

        return template.format(FILE_HEADER=file_header(),
                               TYPES=tabber('\n'.join(self.typedefs)))
Exemple #3
0
 def __str__(self):
     body = '\n'.join(tabber(str(x)) for x in self.value)
     return f'else\n{body}'
Exemple #4
0
 def __str__(self):
     body = '\n'.join(tabber(str(x)) for x in self.value)
     return f'elsif {self.test} then\n{body}'
Exemple #5
0
 def tab(x):
     return tabber(tabber(x))