Пример #1
0
    def __init__(self, name, fill=None, line_color=(0, 0, 0)):
        self.fill = fill
        self.line_color = line_color
        self.pins = []
        self.spacing = 20
        self.padding = 5
        self.show_name = True

        self.name = name
        self.sect_class = None

        if name is not None:
            m = re.match(r'^(\w+)\s*\|(.*)$', name)
            if m:
                self.name = m.group(2).strip()
                self.sect_class = m.group(1).strip().lower()
                if len(self.name) == 0:
                    self.name = None

        class_colors = {
            'clocks': sinebow.lighten(sinebow.sinebow(0), 0.75),  # Red
            'data': sinebow.lighten(sinebow.sinebow(0.35), 0.75),  # Green
            'control': sinebow.lighten(sinebow.sinebow(0.15), 0.75),  # Yellow
            'power': sinebow.lighten(sinebow.sinebow(0.07), 0.75)  # Orange
        }

        if self.sect_class in class_colors:
            self.fill = class_colors[self.sect_class]
Пример #2
0
def make_symbol(comp, extractor, title=False, libname="", no_type=False):
    '''Create a symbol from a parsed component/module'''
    if libname != "":
        assert comp.name.startswith(libname)
        name = comp.name.split('__')[-1]
        vsym = HdlSymbol(libname, name)
    elif title != False:
        vsym = HdlSymbol(comp.name)
    else:
        vsym = HdlSymbol()

    color_seq = sinebow.distinct_color_sequence(0.6)

    if len(comp.generics) > 0:  #'generic' in entity_data:
        s = make_section(None, comp.generics, (200, 200, 200), extractor,
                         no_type)
        s.line_color = (100, 100, 100)
        gsym = Symbol([s], line_color=(100, 100, 100))
        vsym.add_symbol(gsym)
    if len(comp.ports) > 0:  #'port' in entity_data:
        psym = Symbol()

        # Break ports into sections
        cur_sect = []
        sections = []
        sect_name = comp.sections[0] if 0 in comp.sections else None
        for i, p in enumerate(comp.ports):
            if i in comp.sections and len(
                    cur_sect) > 0:  # Finish previous section
                sections.append((sect_name, cur_sect))
                cur_sect = []
                sect_name = comp.sections[i]
            cur_sect.append(p)

        if len(cur_sect) > 0:
            sections.append((sect_name, cur_sect))

        for sdata in sections:
            s = make_section(sdata[0], sdata[1],
                             sinebow.lighten(next(color_seq), 0.75), extractor,
                             no_type)
            psym.add_section(s)

        vsym.add_symbol(psym)

    return vsym