Beispiel #1
0
    def build_constants(self):
        template = textwrap.dedent("""\
            type self_t_const is record
            {DATA}
            end record;""")

        data = [
            x._pyha_definition() for x in self.data.elems if const_filter(x)
        ]

        if not data:
            data = ['DUMMY: integer;']
        return template.format(DATA=formatter(data))
Beispiel #2
0
    def build_data_structs(self):
        template = textwrap.dedent("""\
            type self_t is record
            {DATA}
            end record;""")

        data = [
            x._pyha_definition() for x in self.data.elems
            if not is_constant(x._name)
        ]
        if not data:
            data = ['dummy: integer;']
        return template.format(DATA=formatter(data))
Beispiel #3
0
    def build_constructor(self, prototype_only=False):
        template = textwrap.dedent("""\
            function {NAME}{ARGS} return self_t is
                -- constructor
                variable self: self_t;
            begin
            {DATA}
                return self;
            end function;""")

        data = [x._pyha_constructor() for x in self.data.elems]
        args = '; '.join([
            x._pyha_constructor_arg() for x in self.data.elems
            if x._pyha_constructor_arg() != ''
        ])
        if args != '':
            args = f'({args[:-2]})' if args[-2:] == '; ' else f'({args})'
        ret = template.format(NAME=escape_reserved_vhdl(self.name),
                              ARGS=args,
                              DATA=formatter(data))

        if prototype_only:
            return ret.splitlines()[0][:-3] + ';'
        return ret
Beispiel #4
0
    def build_imports(self):
        template = textwrap.dedent("""\
            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.Typedefs.all;
                use work.all;
            {IMPORTS}""")

        # add all converted classes to imports
        # look: https://github.com/tgingold/ghdl/issues/209
        from pyha.conversion.conversion import RecursiveConverter
        imports = [
            f'use work.{x}.all;'
            for x in RecursiveConverter.converted_modules.keys()
        ]
        return template.format(IMPORTS=formatter(imports))
Beispiel #5
0
    def make_ram_edge(self, rams):
        data = [f'\tself.{name}.data(self_next.{name}.write_address) <= self_next.{name}.write_value;\n' \
                f'\tself.{name}.read_reg <= self.{name}.data(self_next.{name}.read_address);\n\n' for name in rams]

        return formatter(data)
Beispiel #6
0
 def make_ram_resets(self, rams):
     data = [f'self.{x} <= self.{x};' for x in rams]
     return formatter(data)
Beispiel #7
0
 def make_constants(self):
     data = [
         x._pyha_reset(filter_func=const_filter)
         for x in self.simulated_object_vhdl.elems
     ]
     return formatter(data)
Beispiel #8
0
 def make_reset(self):
     data = [
         x._pyha_reset(filter_func=lambda x: not is_constant(x._name))
         for x in self.simulated_object_vhdl.elems
     ]
     return formatter(data)