@@ -370,7 +370,8 @@ def wirevector_subset(self, cls=None, exclude=tuple()):
370
370
If no cls is specified, the full set of wirevectors associated with the Block are
371
371
returned. If cls is a single type, or a tuple of types, only those wirevectors of
372
372
the matching types will be returned. This is helpful for getting all inputs, outputs,
373
- or registers of a block for example."""
373
+ or registers of a block for example.
374
+ """
374
375
if cls is None :
375
376
initial_set = self .wirevector_set
376
377
else :
@@ -384,7 +385,8 @@ def logic_subset(self, op=None):
384
385
"""Return set of logicnets, filtered by the type(s) of logic op provided as op.
385
386
386
387
If no op is specified, the full set of logicnets associated with the Block are
387
- returned. This is helpful for getting all memories of a block for example."""
388
+ returned. This is helpful for getting all memories of a block for example.
389
+ """
388
390
if op is None :
389
391
return self .logic
390
392
else :
@@ -395,7 +397,8 @@ def get_wirevector_by_name(self, name, strict=False):
395
397
396
398
By fallthrough, if a matching wirevector cannot be found the value None is
397
399
returned. However, if the argument strict is set to True, then this will
398
- instead throw a PyrtlError when no match is found."""
400
+ instead throw a PyrtlError when no match is found.
401
+ """
399
402
if name in self .wirevector_by_name :
400
403
return self .wirevector_by_name [name ]
401
404
elif strict :
@@ -468,7 +471,8 @@ def __iter__(self):
468
471
Note: this method will throw an error if there are loops in the
469
472
logic that do not involve registers.
470
473
Also, the order of the nets is not guaranteed to be the same
471
- over multiple iterations"""
474
+ over multiple iterations.
475
+ """
472
476
from .wire import Input , Const , Register
473
477
src_dict , dest_dict = self .net_connections ()
474
478
to_clear = self .wirevector_subset ((Input , Const , Register ))
@@ -498,7 +502,8 @@ def sanity_check(self):
498
502
""" Check block and throw PyrtlError or PyrtlInternalError if there is an issue.
499
503
500
504
Should not modify anything, only check data structures to make sure they have been
501
- built according to the assumptions stated in the Block comments."""
505
+ built according to the assumptions stated in the Block comments.
506
+ """
502
507
503
508
# TODO: check that the wirevector_by_name is sane
504
509
from .wire import Input , Const , Output
@@ -724,7 +729,7 @@ def sanity_check_net(self, net):
724
729
725
730
class PostSynthBlock (Block ):
726
731
""" This is a block with extra metadata required to maintain the
727
- pre synthesis interface post synthesis
732
+ pre- synthesis interface during post- synthesis.
728
733
"""
729
734
730
735
def __init__ (self ):
@@ -758,7 +763,8 @@ def _get_debug_mode():
758
763
759
764
760
765
def _get_useful_callpoint_name ():
761
- """ Attempts to find the lowest user-level call into the pyrtl module
766
+ """ Attempts to find the lowest user-level call into the PyRTL module.
767
+
762
768
:return (string, int) or None: the file name and line number respectively
763
769
764
770
This function walks back the current frame stack attempting to find the
@@ -815,10 +821,10 @@ def reset_working_block():
815
821
816
822
class set_working_block (object ):
817
823
""" Set the working block to be the block passed as argument.
818
- Compatible with the 'with' statement
824
+ Compatible with the 'with' statement.
819
825
820
- Sanity checks will only be run if the new block is different
821
- from the original block
826
+ Sanity checks will only be run if the new block is different
827
+ from the original block.
822
828
"""
823
829
824
830
@staticmethod
@@ -844,8 +850,9 @@ def __exit__(self, exc_type, exc_val, exc_tb):
844
850
845
851
def temp_working_block ():
846
852
""" Set the working block to be new temporary block.
847
- If used with the 'with' statement the block will be reset to the
848
- original value (at the time of call) at exit of the context.
853
+
854
+ If used with the 'with' statement the block will be reset to the
855
+ original value (at the time of call) at exit of the context.
849
856
"""
850
857
return set_working_block (Block ())
851
858
@@ -864,13 +871,13 @@ def set_debug_mode(debug=True):
864
871
865
872
866
873
class _NameIndexer (object ):
867
- """ Provides internal names that are based on a prefix and an index"""
874
+ """ Provides internal names that are based on a prefix and an index. """
868
875
def __init__ (self , internal_prefix = '_sani_temp' ):
869
876
self .internal_prefix = internal_prefix
870
877
self .internal_index = 0
871
878
872
879
def make_valid_string (self ):
873
- """Build a valid string based on the prefix and internal index"""
880
+ """ Build a valid string based on the prefix and internal index. """
874
881
return self .internal_prefix + str (self .next_index ())
875
882
876
883
def next_index (self ):
@@ -880,9 +887,8 @@ def next_index(self):
880
887
881
888
882
889
class _NameSanitizer (_NameIndexer ):
883
- """
884
- Sanitizes the names so that names can be used in places that don't allow
885
- for arbitrary names while not mangling valid names
890
+ """ Sanitizes the names so that names can be used in places that don't allow
891
+ for arbitrary names while not mangling valid names.
886
892
887
893
Put the values you want to validate into make_valid_string the first time
888
894
you want to sanitize a particular string (or before the first time), and
@@ -902,7 +908,7 @@ def __init__(self, identifier_regex_str, internal_prefix='_sani_temp',
902
908
super (_NameSanitizer , self ).__init__ (internal_prefix )
903
909
904
910
def __getitem__ (self , item ):
905
- """ Get a value from the sanitizer"""
911
+ """ Get a value from the sanitizer """
906
912
if not self .map_valid and self .is_valid_str (item ):
907
913
return item
908
914
return self .val_map [item ]
@@ -911,7 +917,7 @@ def is_valid_str(self, string):
911
917
return self .identifier .match (string ) and self .extra_checks (string )
912
918
913
919
def make_valid_string (self , string = '' ):
914
- """ Inputting a value for the first time """
920
+ """ Inputting a value for the first time. """
915
921
if not self .is_valid_str (string ):
916
922
if string in self .val_map and not self .allow_dups :
917
923
raise IndexError ("Value {} has already been given to the sanitizer" .format (string ))
@@ -925,7 +931,7 @@ def make_valid_string(self, string=''):
925
931
926
932
927
933
class _PythonSanitizer (_NameSanitizer ):
928
- """ Name Sanitizer specifically built for Python identifers"""
934
+ """ Name Sanitizer specifically built for Python identifers. """
929
935
def __init__ (self , internal_prefix = '_sani_temp' , map_valid_vals = True ):
930
936
super (_PythonSanitizer , self ).__init__ (_py_regex , internal_prefix , map_valid_vals )
931
937
self .extra_checks = lambda s : not keyword .iskeyword (s )
0 commit comments