@@ -107,6 +107,13 @@ def __init__(self, bitwidth=None, name='', block=None):
107
107
:param String name: The name of the wire referred to in some places.
108
108
Must be unique. If none is provided, one will be autogenerated
109
109
:return: a wirevector object representing a const wire
110
+
111
+ Examples::
112
+
113
+ data = pyrtl.WireVector(8, 'data') # visible in trace as "data"
114
+ ctrl = pyrtl.WireVector(1) # assigned tmp name, not visible in traces by default
115
+ temp = pyrtl.WireVector() # temporary with width to be defined later
116
+ temp <<= data # this this case temp will get the bitwdith of 8 from data
110
117
"""
111
118
self ._name = None
112
119
@@ -170,7 +177,14 @@ def _prepare_for_assignment(self, rhs):
170
177
return rhs
171
178
172
179
def __ilshift__ (self , other ):
173
- """ Wire assignment operator (assign other to self). """
180
+ """ Wire assignment operator (assign other to self).
181
+
182
+ Example::
183
+
184
+ i = pyrtl.Input(8, 'i')
185
+ t = pyrtl.WireVector(8, 't')
186
+ t <<= i
187
+ """
174
188
other = self ._prepare_for_assignment (other )
175
189
self ._build (other )
176
190
return self
@@ -228,6 +242,10 @@ def __bool__(self):
228
242
def __and__ (self , other ):
229
243
""" Creates a LogicNet that ands two wires together into a single wire
230
244
:return Wirevector: the result wire of the operation
245
+
246
+ Example::
247
+
248
+ temp = a & b
231
249
"""
232
250
return self ._two_var_op (other , '&' )
233
251
@@ -240,6 +258,10 @@ def __iand__(self, other):
240
258
def __or__ (self , other ):
241
259
""" Creates a LogicNet that ors two wires together into a single wire
242
260
:return Wirevector: the result wire of the operation
261
+
262
+ Example::
263
+
264
+ temp = a | b
243
265
"""
244
266
return self ._two_var_op (other , '|' )
245
267
@@ -267,6 +289,13 @@ def __add__(self, other):
267
289
The resulting wire has one more bit than the longer of the two input wires.
268
290
269
291
Addition is compatible with two's complement signed numbers.
292
+
293
+ Examples::
294
+
295
+ temp = a + b # simple addition of two wirevectors
296
+ temp = a + 5 # you can use integers
297
+ temp = a + 0b110 # you can use other integers
298
+ temp = a + "3'h7" # compatable verilog constants work too
270
299
"""
271
300
return self ._two_var_op (other , '+' )
272
301
@@ -517,7 +546,7 @@ def _extend_with_bit(self, bitwidth, extbit):
517
546
#
518
547
519
548
class Input (WireVector ):
520
- """ A WireVector type denoting inputs to a block (no writers) """
549
+ """ A WireVector type denoting inputs to a block (no writers). """
521
550
_code = 'I'
522
551
523
552
def __init__ (self , bitwidth = None , name = '' , block = None ):
0 commit comments