Beispiel #1
0
    def emit_verilog(instance, ns, add_data_file):
        r = instance.of + " "
        parameters = list(
            filter(lambda i: isinstance(i, Instance.Parameter),
                   instance.items))
        if parameters:
            r += "#(\n"
            firstp = True
            for p in parameters:
                if not firstp:
                    r += ",\n"
                firstp = False
                r += "\t." + p.name + "("
                if isinstance(p.value, Constant):
                    r += verilog_printexpr(ns, p.value)[0]
                elif isinstance(p.value, float):
                    r += str(p.value)
                elif isinstance(p.value, Instance.PreformattedParam):
                    r += p.value
                elif isinstance(p.value, str):
                    r += "\"" + p.value + "\""
                else:
                    raise TypeError
                r += ")"
            r += "\n) "
        r += ns.get_name(instance)
        if parameters: r += " "
        r += "(\n"
        firstp = True
        for p in instance.items:
            if isinstance(p, Instance._IO):
                name_inst = p.name
                name_design = verilog_printexpr(ns, p.expr)[0]
                if not firstp:
                    r += ",\n"
                firstp = False
                r += "\t." + name_inst + "(" + name_design + ")"
        if not firstp:
            r += "\n"

        directives = instance.synthesis_directive
        if directives is None:
            directives = []
        elif type(directives) == str:
            directives = [
                directives,
            ]

        r += ")"
        for directive in directives:
            r += "\n\t/* synthesis {} */".format(directive)
        r += ";\n\n"

        return r
Beispiel #2
0
 def emit_verilog(instance, ns, add_data_file):
     r = instance.of + " "
     parameters = list(filter(lambda i: isinstance(i, Instance.Parameter), instance.items))
     if parameters:
         r += "#(\n"
         firstp = True
         for p in parameters:
             if not firstp:
                 r += ",\n"
             firstp = False
             r += "\t." + p.name + "("
             if isinstance(p.value, Constant):
                 r += verilog_printexpr(ns, p.value)[0]
             elif isinstance(p.value, float):
                 r += str(p.value)
             elif isinstance(p.value, Instance.PreformattedParam):
                 r += p.value
             elif isinstance(p.value, str):
                 r += "\"" + p.value + "\""
             else:
                 raise TypeError
             r += ")"
         r += "\n) "
     r += ns.get_name(instance)
     if parameters: r += " "
     r += "(\n"
     firstp = True
     for p in instance.items:
         if isinstance(p, Instance._IO):
             name_inst = p.name
             name_design = verilog_printexpr(ns, p.expr)[0]
             if not firstp:
                 r += ",\n"
             firstp = False
             r += "\t." + name_inst + "(" + name_design + ")"
     if not firstp:
         r += "\n"
     if instance.synthesis_directive is not None:
         synthesis_directive = "/* synthesis {} */".format(instance.synthesis_directive)
         r += ")" + synthesis_directive + ";\n\n"
     else:
         r += ");\n\n"
     return r
Beispiel #3
0
 def pe(e):
     return verilog_printexpr(ns, e)[0]
Beispiel #4
0
 def gn(e):
     if isinstance(e, Memory):
         return ns.get_name(e)
     else:
         return verilog_printexpr(ns, e)[0]