1010"""
1111from __future__ import annotations
1212
13- from typing import TYPE_CHECKING
14-
15- if TYPE_CHECKING :
16- from .wire import WireVector , Register
17- from .memory import MemBlock
18-
1913import collections
2014import re
2115import keyword
22- from typing import NamedTuple
16+ from typing import NamedTuple , TYPE_CHECKING
2317
24- from .pyrtlexceptions import PyrtlError , PyrtlInternalError
18+ from pyrtl .pyrtlexceptions import PyrtlError , PyrtlInternalError
19+
20+ if TYPE_CHECKING :
21+ from pyrtl .wire import WireVector , Register
22+ from pyrtl .memory import MemBlock
2523
2624
2725# -----------------------------------------------------------------
2826# __ __ __
2927# |__) | / \ / ` |__/
3028# |__) |___ \__/ \__, | \
3129#
32-
3330class LogicNet (NamedTuple ):
3431 """The basic immutable datatype for storing a "net" in a netlist.
3532
@@ -147,7 +144,7 @@ def __str__(self):
147144 lhs = ', ' .join (str (x ) for x in self .dests )
148145 options = '' if self .op_param is None else '(' + str (self .op_param ) + ')'
149146
150- from .helperfuncs import _currently_in_jupyter_notebook
147+ from pyrtl .helperfuncs import _currently_in_jupyter_notebook
151148
152149 if _currently_in_jupyter_notebook ():
153150 # Output the working block as a Latex table
@@ -349,7 +346,7 @@ def __init__(self):
349346
350347 def __str__ (self ):
351348 """String form has one LogicNet per line."""
352- from .helperfuncs import _currently_in_jupyter_notebook , _print_netlist_latex
349+ from pyrtl .helperfuncs import _currently_in_jupyter_notebook , _print_netlist_latex
353350
354351 if _currently_in_jupyter_notebook ():
355352 _print_netlist_latex (list (self ))
@@ -517,7 +514,7 @@ class _NetConnectionsDict(dict):
517514 nice error message when _MemIndexed is used as a lookup key.
518515 """
519516 def __missing__ (self , key ):
520- from .memory import _MemIndexed
517+ from pyrtl .memory import _MemIndexed
521518
522519 if isinstance (key , _MemIndexed ):
523520 raise PyrtlError (
@@ -572,7 +569,7 @@ def add_wire_dst(edge, node):
572569 dst_list [edge ] = [node ]
573570
574571 if include_virtual_nodes :
575- from .wire import Input , Output , Const
572+ from pyrtl .wire import Input , Output , Const
576573 for wire in self .wirevector_subset ((Input , Const )):
577574 add_wire_src (wire , wire )
578575
@@ -589,7 +586,7 @@ def add_wire_dst(edge, node):
589586
590587 def _repr_svg_ (self ):
591588 """ IPython display support for Block. """
592- from .visualization import block_to_svg
589+ from pyrtl .visualization import block_to_svg
593590 return block_to_svg (self )
594591
595592 def __iter__ (self ):
@@ -602,7 +599,7 @@ def __iter__(self):
602599 Also, the order of the nets is not guaranteed to be the same
603600 over multiple iterations.
604601 """
605- from .wire import Input , Const , Register
602+ from pyrtl .wire import Input , Const , Register
606603 src_dict , dest_dict = self .net_connections ()
607604 to_clear = self .wirevector_subset ((Input , Const , Register ))
608605 cleared = set ()
@@ -634,9 +631,8 @@ def sanity_check(self):
634631
635632 :raise PyrtlError: If the ``Block`` is malformed.
636633 """
637-
638- from .wire import Input , Const , Output
639- from .helperfuncs import get_stack , get_stacks
634+ from pyrtl .wire import Input , Const , Output
635+ from pyrtl .helperfuncs import get_stack , get_stacks
640636
641637 # check for valid LogicNets (and wires)
642638 for net in self .logic :
@@ -734,7 +730,7 @@ def sanity_check_memory_sync(self, wire_src_dict=None):
734730 if wire_src_dict is None :
735731 wire_src_dict , wdd = self .net_connections ()
736732
737- from .wire import Input , Const
733+ from pyrtl .wire import Input , Const
738734 sync_src = 'r'
739735 sync_prop = 'wcs'
740736 for net in sync_mems :
@@ -756,24 +752,24 @@ def sanity_check_memory_sync(self, wire_src_dict=None):
756752
757753 def sanity_check_wirevector (self , w ):
758754 """ Check that w is a valid WireVector type. """
759- from .wire import WireVector
755+ from pyrtl .wire import WireVector
760756 if not isinstance (w , WireVector ):
761757 raise PyrtlError (
762758 'error attempting to pass an input of type "%s" '
763759 'instead of WireVector' % type (w ))
764760
765761 def sanity_check_memblock (self , m ):
766762 """ Check that m is a valid memblock type. """
767- from .memory import MemBlock
763+ from pyrtl .memory import MemBlock
768764 if not isinstance (m , MemBlock ):
769765 raise PyrtlError (
770766 'error attempting to pass an input of type "%s" '
771767 'instead of MemBlock' % type (m ))
772768
773769 def sanity_check_net (self , net ):
774770 """ Check that net is a valid LogicNet. """
775- from .wire import Input , Output , Const , Register
776- from .memory import MemBlock
771+ from pyrtl .wire import Input , Output , Const , Register
772+ from pyrtl .memory import MemBlock
777773
778774 # general sanity checks that apply to all operations
779775 if not isinstance (net , LogicNet ):
0 commit comments