From cf84dfe2fd6098f7c38085ab91ccee450d3603c2 Mon Sep 17 00:00:00 2001 From: Keith Rothman <537074+litghost@users.noreply.github.com> Date: Thu, 9 May 2019 14:18:09 -0700 Subject: [PATCH] Fix some comments. Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com> --- prjxray/math_models.py | 65 +++++++++++++++++++++++ prjxray/tile.py | 16 +++--- prjxray/timing.py | 117 +++++++++-------------------------------- 3 files changed, 99 insertions(+), 99 deletions(-) create mode 100644 prjxray/math_models.py diff --git a/prjxray/math_models.py b/prjxray/math_models.py new file mode 100644 index 00000000..a649302c --- /dev/null +++ b/prjxray/math_models.py @@ -0,0 +1,65 @@ +""" Math models are used to represent abstract operations for the timing models. +This is useful for creating excel workbooks that can update dynamically, or +generating a model with symbolic constants to be backsolved. +""" + + +class ExcelMathModel(object): + """ Math model used for outputting to an dyanmic Excel sheet. """ + + def __init__(self): + pass + + def sum(self, elems): + sum_val = '(' + ' + '.join(elems) + ')' + if sum_val == '()': + return '0' + else: + return sum_val + + def product(self, elems): + sum_val = '(' + ' * '.join(elems) + ')' + if sum_val == '()': + return '1' + else: + return sum_val + + def plus(self, a, b): + return self.sum((a, b)) + + def divide(self, a, b): + return '({}/{})'.format(a, b) + + def multiply(self, a, b): + return '({}*{})'.format(a, b) + + def eval(self, elem): + return '=' + elem + + +def PythonMathModel(object): + """ Math model used for outputting values equalated immediately. """ + + def __init__(self): + pass + + def sum(self, elems): + return sum(elems) + + def product(self, elems): + v = 1.0 + for elem in elems: + v *= elem + return v + + def divide(self, a, b): + return a / b + + def plus(self, a, b): + return a + b + + def multiply(self, a, b): + return a * b + + def eval(self, elem): + return elem diff --git a/prjxray/tile.py b/prjxray/tile.py index e6e01660..4ca5a702 100644 --- a/prjxray/tile.py +++ b/prjxray/tile.py @@ -8,7 +8,7 @@ TileDbs = namedtuple( 'TileDbs', 'segbits block_ram_segbits ppips mask tile_type') -class OutpinTiming(namedtuple('OutpinTiming', 'delays drive_resistance')): +class OutPinTiming(namedtuple('OutPinTiming', 'delays drive_resistance')): """ Timing for site output pins. Attributes @@ -22,7 +22,7 @@ class OutpinTiming(namedtuple('OutpinTiming', 'delays drive_resistance')): pass -class InpinTiming(namedtuple('InpinTiming', 'delays capacitance')): +class InPinTiming(namedtuple('InPinTiming', 'delays capacitance')): """ Timing for site input pins. Attributes @@ -125,7 +125,7 @@ class SitePin(namedtuple('SitePin', 'name wire timing')): all sites of the same type. wire : str Wire name within the tile. This name is site instance specific. - timing : Either InpinTiming or OutpinTiming + timing : Either InPinTiming or OutPinTiming Timing of site pin. May be None if database lacks timing information. """ @@ -177,13 +177,13 @@ def get_pip_timing(pip_timing_json): def get_site_pin_timing(site_pin_info): - """ Convert site_pin_info JSON into InpinTiming or OutpinTiming object. + """ Convert site_pin_info JSON into InPinTiming or OutPinTiming object. Returns ------- If timing information is not present for this site pin, returns None. - If this is an output pin, returns OutpinTiming. - If this is an input pin, returns InpinTiming. + If this is an output pin, returns OutPinTiming. + If this is an input pin, returns InPinTiming. """ if isinstance(site_pin_info, str): @@ -198,13 +198,13 @@ def get_site_pin_timing(site_pin_info): if 'cap' in site_pin_info: assert 'res' not in site_pin_info - return wire, InpinTiming( + return wire, InPinTiming( delays=delays, capacitance=float(site_pin_info['cap']) / CAPACITANCE_FACTOR, ) else: assert 'res' in site_pin_info - return wire, OutpinTiming( + return wire, OutPinTiming( delays=delays, drive_resistance=float(site_pin_info['res']) / RESISTANCE_FACTOR, ) diff --git a/prjxray/timing.py b/prjxray/timing.py index 2098d4d1..29a3dd78 100644 --- a/prjxray/timing.py +++ b/prjxray/timing.py @@ -30,31 +30,31 @@ a pi-model. Example timing tree: -+------+ -|Outpin| -+--+---+ - | - | - v -+--+--+ -|Wire | -+--+--+ - | - +-----------------+ - | | -+--+---+ +-------+------+ -|Buffer| |PassTransistor| -+--+---+ +------+-------+ - | | - v v -+--+-+ +--+-+ -|Wire| |Wire| -+--+-+ +--+-+ - | | - v v -+--+--+ +--+--+ -|Inpin| |Inpin| -+-----+ +-----+ + +------+ + |Outpin| + +--+---+ + | + | + v + +--+--+ + |Wire | + +--+--+ + | + +-----------------+ + | | + +--+---+ +-------+------+ + |Buffer| |PassTransistor| + +--+---+ +------+-------+ + | | + v v + +--+-+ +--+-+ + |Wire| |Wire| + +--+-+ +--+-+ + | | + v v + +--+--+ +--+--+ + |Inpin| |Inpin| + +-----+ +-----+ Note on units: @@ -160,72 +160,6 @@ def fast_slow_tuple_to_corners(arr): } -# Math models are used to represent abstract operations for the timing models. -# This is useful for creating excel workbooks that can update dynamically, or -# generating a model with symbolic constants to be backsolved. - - -class ExcelMathModel(object): - """ Math model used for outputting to an dyanmic Excel sheet. """ - - def __init__(self): - pass - - def sum(self, elems): - sum_val = '(' + ' + '.join(elems) + ')' - if sum_val == '()': - return '0' - else: - return sum_val - - def product(self, elems): - sum_val = '(' + ' * '.join(elems) + ')' - if sum_val == '()': - return '1' - else: - return sum_val - - def plus(self, a, b): - return self.sum((a, b)) - - def divide(self, a, b): - return '({}/{})'.format(a, b) - - def multiply(self, a, b): - return '({}*{})'.format(a, b) - - def eval(self, elem): - return '=' + elem - - -def PythonMathModel(object): - """ Math model used for outputting values equalated immediately. """ - - def __init__(self): - pass - - def sum(self, elems): - return sum(elems) - - def product(self, elems): - v = 1.0 - for elem in elems: - v *= elem - return v - - def divide(self, a, b): - return a / b - - def plus(self, a, b): - return a + b - - def multiply(self, a, b): - return a * b - - def eval(self, elem): - return elem - - class TimingNode(object): """ Base class for timing node models. """ @@ -288,6 +222,7 @@ class DownstreamNode(TimingNode): math : MathModel Math model to use to compute delays """ + pass class Outpin(TimingNode):