@@ -98,16 +98,17 @@ def __init__(self,
9898 if self .direction in (io .Direction .Output , io .Direction .Bidir ):
9999 self ._o = Signal (width , name = f"{ self ._name } $o" )
100100
101- # the oe signals that get wired out to iocells. Always one per io.
102101 init_oe = - 1
103102 if 'init_oe' in port_desc .iomodel and port_desc .iomodel ['init_oe' ]:
104103 init_oe = port_desc .iomodel ['init_oe' ]
105- self ._oes = Signal (width , name = f"{ self ._name } $oe" , init = init_oe )
106104
107- # the oe on the user side.
105+ # user side either gets single oe or multiple, depending on 'individual_oe'
106+ # cells side always gets <width> oes. Wired together in the wire method below
108107 if "individual_oe" not in self .iomodel or not self .iomodel ["individual_oe" ]:
109- self ._oe = Signal (1 , name = f"{ self ._name } $oe" , init = - 1 )
108+ self ._oe = Signal (1 , name = f"{ self ._name } $oe" , init = init_oe )
109+ self ._oes = Signal (width , name = f"{ self ._name } $oe" )
110110 else :
111+ self ._oes = Signal (width , name = f"{ self ._name } $oe" , init = init_oe )
111112 self ._oe = self ._oes
112113
113114 logger .debug (f"Created SiliconPlatformPort { self ._name } , with port description:\n { pformat (self ._port_desc )} " )
@@ -119,19 +120,21 @@ def wire(self, m: Module, interface: PureInterface):
119120 for d in ['_o' , '_oe' , '_ie' ]:
120121 if hasattr (interface , d ):
121122 m .d .comb += getattr (self , d ).eq (getattr (interface , d ))
122- if self ._oe is not None \
123- and "individual_oe" in self .iomodel \
124- and self .iomodel ["individual_oe" ]:
123+ # wire user side _oe to _oes if necessary
124+ if self ._oe is not None and self ._oe .shape ().width == 1 and self ._oes .shape ().width > 1 :
125125 m .d .comb += self ._oe .eq (self ._oes )
126126
127127 def instantiate_toplevel (self ):
128128 ports = []
129129 if self .direction in (io .Direction .Input , io .Direction .Bidir ):
130- ports .append ((f"io${ self ._name } $i" , self .i , PortDirection .Input ))
131- ports .append ((f"io${ self ._name } $ie" , self .ie , PortDirection .Output ))
130+ ports .append ((f"io${ self ._name } $i" , self ._i , PortDirection .Input ))
131+ ports .append ((f"io${ self ._name } $ie" , self ._ie , PortDirection .Output ))
132132 if self .direction in (io .Direction .Output , io .Direction .Bidir ):
133- ports .append ((f"io${ self ._name } $o" , self .o , PortDirection .Output ))
134- ports .append ((f"io${ self ._name } $oe" , self .oe , PortDirection .Output ))
133+ ports .append ((f"io${ self ._name } $o" , self ._o , PortDirection .Output ))
134+ if self ._oe is not None and self ._oe .shape ().width == 1 and self ._oes .shape ().width > 1 :
135+ ports .append ((f"io${ self ._name } $oe" , self ._oes , PortDirection .Output ))
136+ else :
137+ ports .append ((f"io${ self ._name } $oe" , self ._oe , PortDirection .Output ))
135138 return ports
136139
137140 def wire_up (self , m , wire ):
@@ -307,10 +310,10 @@ def __init__(self,
307310 dm_init_bits = [ int (b ) for b in f"{ dm_init :b} " ]
308311 dms_shape = data .ArrayLayout (unsigned (3 ), self .width )
309312 self ._dms = Signal (dms_shape , name = f"{ self ._name } $dms" , init = [dm_init ]* self .width )
310-
311- self ._dm0 = Signal (self ._o . shape () , name = f"{ self ._name } $dm0" , init = dm_init_bits [0 ])
312- self ._dm1 = Signal (self ._o . shape () , name = f"{ self ._name } $dm1" , init = dm_init_bits [1 ])
313- self ._dm2 = Signal (self ._o . shape () , name = f"{ self ._name } $dm2" , init = dm_init_bits [2 ])
313+ all_ones = ( 2 << ( self . width - 1 )) - 1
314+ self ._dm0 = Signal (self .width , name = f"{ self ._name } $dm0" , init = dm_init_bits [0 ]* all_ones )
315+ self ._dm1 = Signal (self .width , name = f"{ self ._name } $dm1" , init = dm_init_bits [1 ]* all_ones )
316+ self ._dm2 = Signal (self .width , name = f"{ self ._name } $dm2" , init = dm_init_bits [2 ]* all_ones )
314317 self ._signals .append ((self ._dm0 , PortDirection .Output )) #type: ignore
315318 self ._signals .append ((self ._dm1 , PortDirection .Output )) #type: ignore
316319 self ._signals .append ((self ._dm2 , PortDirection .Output )) #type: ignore
0 commit comments