From b4634413da05307fbfdab29d46d28c75f8499901 Mon Sep 17 00:00:00 2001 From: Karol Gugala Date: Fri, 21 Jun 2019 17:25:37 +0200 Subject: [PATCH] fuzzers: 007: bel: use functions for searching in speed_model Signed-off-by: Karol Gugala --- fuzzers/007-timing/bel/tim2json.py | 34 +++++++++++++++--------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/fuzzers/007-timing/bel/tim2json.py b/fuzzers/007-timing/bel/tim2json.py index 7a75e0bc..ae88c5f3 100644 --- a/fuzzers/007-timing/bel/tim2json.py +++ b/fuzzers/007-timing/bel/tim2json.py @@ -110,6 +110,16 @@ def find_aliased_pin(pin, model, pin_aliases): return False, None +def instance_in_model(instance, model): + + if len(instance.split('_')) == 1: + # instance name is one word, search it in the model + return instance in model.split('_') + else: + # instance name is multi word, search for a string + return instance in model + + def pin_in_model(pin, pin_aliases, model, direction=None): """ Checks if a given pin belongs to the model. @@ -166,24 +176,14 @@ def pin_in_model(pin, pin_aliases, model, direction=None): if direction is not None: extended_pin_name = pin + direction - if len(pin.split('_')) == 1: - # pin name is one word, search it in the model - if pin in model.split('_'): - return True, pin - elif extended_pin_name in model.split('_'): - return True, extended_pin_name - elif aliased_pin: - return True, aliased_pin_name - else: - return False, None + if instance_in_model(pin, model): + return True, pin + elif instance_in_model(extended_pin_name, model): + return True, extended_pin_name + elif aliased_pin: + return True, aliased_pin_name else: - # pin name is multi word, search for a string - if pin in model: - return True, pin - elif aliased_pin: - return True, aliased_pin_name - else: - return False, None + return False, None def remove_pin_from_model(pin, model):