From baaa8406d60374e7f30614fb48463b829a5d3c58 Mon Sep 17 00:00:00 2001 From: Jakub Jatczak Date: Mon, 9 Mar 2020 17:02:52 +0100 Subject: [PATCH 1/7] Add 'power' to fixed-style sections --- symbolator.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/symbolator.py b/symbolator.py index 013fdd7..3d5dbd8 100755 --- a/symbolator.py +++ b/symbolator.py @@ -131,9 +131,10 @@ def __init__(self, name, fill=None, line_color=(0,0,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 + '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: From 1d036552ca765e4b8be4230eda85e96f5bfecbed Mon Sep 17 00:00:00 2001 From: Jakub Jatczak Date: Wed, 25 Mar 2020 15:09:25 +0100 Subject: [PATCH 2/7] Add `caption` argument `caption` can be used to ovverride filename when used with --title --- symbolator.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/symbolator.py b/symbolator.py index 3d5dbd8..0f8f50e 100755 --- a/symbolator.py +++ b/symbolator.py @@ -336,9 +336,14 @@ def make_section(sname, sect_pins, fill, extractor, no_type=False): return sect -def make_symbol(comp, extractor, title=False, no_type=False): +def make_symbol(comp, extractor, title=False, caption="", no_type=False): '''Create a symbol from a parsed component/module''' - vsym = HdlSymbol() if title == False else HdlSymbol(comp.name) + if caption != "": + vsym = HdlSymbol(caption) + elif title != False: + vsym = HdlSymbol(comp.name) + else: + vsym = HdlSymbol() color_seq = sinebow.distinct_color_sequence(0.6) @@ -387,6 +392,7 @@ def parse_args(): parser.add_argument('--title', dest='title', action='store_true', default=False, help='Add component name above symbol') parser.add_argument('--no-type', dest='no_type', action='store_true', default=False, help='Omit pin type information') parser.add_argument('-v', '--version', dest='version', action='store_true', default=False, help='Symbolator version') + parser.add_argument('--caption', dest='caption', action='store', default='', help='Caption above module. Works only with --tile and replaces filename') args, unparsed = parser.parse_known_args() @@ -405,6 +411,10 @@ def parse_args(): print('Error: output file is required') sys.exit(1) + if args.caption != '' and not args.title: + print("Error: '--tile' is required when using caption") + sys.exit(1) + args.scale = float(args.scale) # Remove duplicates @@ -551,7 +561,7 @@ def main(): fname = args.output else: base = os.path.splitext(os.path.basename(source))[0] - fname = '{}-{}.{}'.format(base, comp.name, args.format) + fname = '{}.{}'.format(comp.name, args.format) if args.output: fname = os.path.join(args.output, fname) print('Creating symbol for {} "{}"\n\t-> {}'.format(source, comp.name, fname)) @@ -563,7 +573,7 @@ def main(): nc.set_surface(surf) nc.clear_shapes() - sym = make_symbol(comp, extractor, args.title, args.no_type) + sym = make_symbol(comp, extractor, args.title, args.caption, args.no_type) sym.draw(0,0, nc) nc.render() From b1539af7fcaa3b2dc763404dae5813829b4bd101 Mon Sep 17 00:00:00 2001 From: Jakub Jatczak Date: Tue, 31 Mar 2020 13:06:30 +0200 Subject: [PATCH 3/7] Rename caption to libname, move component name to bottom if libname specified --- symbolator.py | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/symbolator.py b/symbolator.py index 0f8f50e..b3f61d5 100755 --- a/symbolator.py +++ b/symbolator.py @@ -257,11 +257,12 @@ def draw(self, x, y, c, sym_width=None): class HdlSymbol(object): '''Top level symbol object''' - def __init__(self, component=None, symbols=None, symbol_spacing=10, width_steps=20): + def __init__(self, component=None, libname=None, symbols=None, symbol_spacing=10, width_steps=20): self.symbols = symbols if symbols is not None else [] self.symbol_spacing = symbol_spacing self.width_steps = width_steps self.component = component + self.libname = libname @@ -277,13 +278,19 @@ def draw(self, x, y, c): yoff = y for i, s in enumerate(self.symbols): bb = s.draw(x, y + yoff, c, sym_width) - - if i == 0 and self.component: + if i==0 and self.libname: + # Add libname + c.create_text((bb[0]+bb[2])/2.0,bb[1] - self.symbol_spacing, anchor='cs', + text=self.libname, font=('Helvetica', 12, 'bold')) + elif i == 0 and self.component: # Add component name c.create_text((bb[0]+bb[2])/2.0,bb[1] - self.symbol_spacing, anchor='cs', - text=self.component, font=('Helvetica', 14, 'bold')) + text=self.component, font=('Helvetica', 12, 'bold')) yoff += bb[3] - bb[1] + self.symbol_spacing + if self.libname is not None: + c.create_text((bb[0]+bb[2])/2.0,bb[3] + 2 * self.symbol_spacing, anchor='cs', + text=self.component, font=('Helvetica', 12, 'bold')) @@ -336,10 +343,10 @@ def make_section(sname, sect_pins, fill, extractor, no_type=False): return sect -def make_symbol(comp, extractor, title=False, caption="", no_type=False): +def make_symbol(comp, extractor, title=False, libname="", no_type=False): '''Create a symbol from a parsed component/module''' - if caption != "": - vsym = HdlSymbol(caption) + if libname != "": + vsym = HdlSymbol(comp.name, libname) elif title != False: vsym = HdlSymbol(comp.name) else: @@ -392,7 +399,7 @@ def parse_args(): parser.add_argument('--title', dest='title', action='store_true', default=False, help='Add component name above symbol') parser.add_argument('--no-type', dest='no_type', action='store_true', default=False, help='Omit pin type information') parser.add_argument('-v', '--version', dest='version', action='store_true', default=False, help='Symbolator version') - parser.add_argument('--caption', dest='caption', action='store', default='', help='Caption above module. Works only with --tile and replaces filename') + parser.add_argument('--libname', dest='libname', action='store', default='', help='Add libname above cellname, and move component name to bottom. Works only with --title') args, unparsed = parser.parse_known_args() @@ -411,8 +418,8 @@ def parse_args(): print('Error: output file is required') sys.exit(1) - if args.caption != '' and not args.title: - print("Error: '--tile' is required when using caption") + if args.libname != '' and not args.title: + print("Error: '--tile' is required when using libname") sys.exit(1) args.scale = float(args.scale) @@ -561,7 +568,10 @@ def main(): fname = args.output else: base = os.path.splitext(os.path.basename(source))[0] - fname = '{}.{}'.format(comp.name, args.format) + fname = '{}{}.{}'.format( + args.libname + "_" if args.libname is not None else "", + comp.name, + args.format) if args.output: fname = os.path.join(args.output, fname) print('Creating symbol for {} "{}"\n\t-> {}'.format(source, comp.name, fname)) @@ -573,7 +583,7 @@ def main(): nc.set_surface(surf) nc.clear_shapes() - sym = make_symbol(comp, extractor, args.title, args.caption, args.no_type) + sym = make_symbol(comp, extractor, args.title, args.libname, args.no_type) sym.draw(0,0, nc) nc.render() From 4770f37d2ed88c52045d2f3e3fb02b50176758ad Mon Sep 17 00:00:00 2001 From: Jakub Jatczak Date: Mon, 4 May 2020 21:49:31 +0200 Subject: [PATCH 4/7] Use dash to separate libname from module name --- symbolator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/symbolator.py b/symbolator.py index b3f61d5..42fc689 100755 --- a/symbolator.py +++ b/symbolator.py @@ -569,7 +569,7 @@ def main(): else: base = os.path.splitext(os.path.basename(source))[0] fname = '{}{}.{}'.format( - args.libname + "_" if args.libname is not None else "", + args.libname + "-" if args.libname is not None else "", comp.name, args.format) if args.output: From bce75fd6487e2199d8910d76f50ec209568399db Mon Sep 17 00:00:00 2001 From: Jakub Jatczak Date: Wed, 6 May 2020 16:05:29 +0200 Subject: [PATCH 5/7] Use double underscore to separate libname from modname --- symbolator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/symbolator.py b/symbolator.py index 42fc689..4f885e0 100755 --- a/symbolator.py +++ b/symbolator.py @@ -569,7 +569,7 @@ def main(): else: base = os.path.splitext(os.path.basename(source))[0] fname = '{}{}.{}'.format( - args.libname + "-" if args.libname is not None else "", + args.libname + "__" if args.libname is not None else "", comp.name, args.format) if args.output: From 381fe540ed2a0421fdce6f9af01df6d0d8e893e5 Mon Sep 17 00:00:00 2001 From: Piotr Zierhoffer Date: Thu, 7 May 2020 10:57:46 +0200 Subject: [PATCH 6/7] Remove leading underscore from component name --- symbolator.py | 1 + 1 file changed, 1 insertion(+) diff --git a/symbolator.py b/symbolator.py index 4f885e0..295246c 100755 --- a/symbolator.py +++ b/symbolator.py @@ -563,6 +563,7 @@ def main(): # Render every component from every file into an image for source, components in all_components.iteritems(): for comp, extractor in components: + comp.name = comp.name.strip('_') reformat_array_params(comp) if source == '': fname = args.output From 77231804cca92a994dc9843b55b5136ff40430c6 Mon Sep 17 00:00:00 2001 From: Daniel Lim Wee Soong Date: Sat, 15 Aug 2020 10:21:28 +0800 Subject: [PATCH 7/7] Check libname is not empty string Signed-off-by: Daniel Lim Wee Soong --- symbolator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/symbolator.py b/symbolator.py index 295246c..a699818 100755 --- a/symbolator.py +++ b/symbolator.py @@ -570,7 +570,7 @@ def main(): else: base = os.path.splitext(os.path.basename(source))[0] fname = '{}{}.{}'.format( - args.libname + "__" if args.libname is not None else "", + args.libname + "__" if args.libname is not None or args.libname != "" else "", comp.name, args.format) if args.output: