Skip to content

Commit 3276eb6

Browse files
committed
more docs
1 parent 06b4b5c commit 3276eb6

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

docs/helpers.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,3 @@ Hardware Design Helper Functions
1919
:special-members:
2020
:undoc-members:
2121
:exclude-members: __dict__,__weakref__,__module__
22-

pyrtl/wire.py

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,13 @@ def __init__(self, bitwidth=None, name='', block=None):
107107
:param String name: The name of the wire referred to in some places.
108108
Must be unique. If none is provided, one will be autogenerated
109109
: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
110117
"""
111118
self._name = None
112119

@@ -170,7 +177,14 @@ def _prepare_for_assignment(self, rhs):
170177
return rhs
171178

172179
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+
"""
174188
other = self._prepare_for_assignment(other)
175189
self._build(other)
176190
return self
@@ -228,6 +242,10 @@ def __bool__(self):
228242
def __and__(self, other):
229243
""" Creates a LogicNet that ands two wires together into a single wire
230244
:return Wirevector: the result wire of the operation
245+
246+
Example::
247+
248+
temp = a & b
231249
"""
232250
return self._two_var_op(other, '&')
233251

@@ -240,6 +258,10 @@ def __iand__(self, other):
240258
def __or__(self, other):
241259
""" Creates a LogicNet that ors two wires together into a single wire
242260
:return Wirevector: the result wire of the operation
261+
262+
Example::
263+
264+
temp = a | b
243265
"""
244266
return self._two_var_op(other, '|')
245267

@@ -267,6 +289,13 @@ def __add__(self, other):
267289
The resulting wire has one more bit than the longer of the two input wires.
268290
269291
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
270299
"""
271300
return self._two_var_op(other, '+')
272301

@@ -517,7 +546,7 @@ def _extend_with_bit(self, bitwidth, extbit):
517546
#
518547

519548
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)."""
521550
_code = 'I'
522551

523552
def __init__(self, bitwidth=None, name='', block=None):

0 commit comments

Comments
 (0)