Skip to content

Commit c53449d

Browse files
committed
adding/augmenting documentation and fixing typos
1 parent 107864d commit c53449d

File tree

12 files changed

+84
-77
lines changed

12 files changed

+84
-77
lines changed

pyrtl/analysis/estimate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ def max_length(self):
260260
The result assumes that the circuit is implemented in a 130nm process, and that there is no
261261
setup or hold time associated with the circuit. The resulting value is in picoseconds. If
262262
an proper estimation of timing is required it is recommended to us "max_freq" to determine
263-
the clock period as it more accurately consideres scaling and setup/hold.
263+
the clock period as it more accurately considers scaling and setup/hold.
264264
"""
265265
return max(self.timing_map.values())
266266

@@ -315,7 +315,7 @@ def critical_path_pass(old_critical_path, first_wire):
315315
@staticmethod
316316
def print_critical_paths(critical_paths):
317317
""" Prints the results of the critical path length analysis.
318-
Done by default by the `timing_critical_path()` function.
318+
Done by default by the `TimingAnalysis().critical_path()` function.
319319
"""
320320
line_indent = " " * 2
321321
# print the critical path

pyrtl/compilesim.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,8 @@ def _sort_tuple(t):
234234
def run(self, inputs):
235235
"""Run many steps of the simulation.
236236
237-
The argument is a list of input mappings for each step,
238-
and its length is the number of steps to be executed.
237+
:param inputs: A list of input mappings for each step;
238+
its length is the number of steps to be executed.
239239
"""
240240
steps = len(inputs)
241241
# create i/o arrays of the appropriate length

pyrtl/conditional.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def __exit__(self, *exc_info):
7676
_finalize()
7777
finally:
7878
# even if the above finalization throws an error we need to
79-
# return reset the state to prevent errors from bleeding over
79+
# reset the state to prevent errors from bleeding over
8080
_reset_conditional_state() # sets _depth back to 0
8181

8282

pyrtl/core.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def __eq__(self, other):
144144
# We can't be going and calling __eq__ recursively on the logic nets for all of
145145
# the args and dests because that will actually *create* new logic nets which is
146146
# very much not what people would expect to happen. Instead we define equality
147-
# as the immutable fields as being equal and the list of args and dests as being
147+
# as the immutable fields being equal and the list of args and dests being
148148
# references to the same objects.
149149
return (self.op == other.op
150150
and self.op_param == other.op_param
@@ -186,20 +186,20 @@ class Block(object):
186186
187187
1) the op (a single character describing the operation such as '+' or 'r'),
188188
2) a set of hard parameters to that primitives (such as the constants to
189-
select from the "selection" op.
189+
select from the "selection" op).
190190
3) the tuple "args" which list the wirevectors hooked up as inputs to
191191
this particular net.
192192
4) the tuple "dests" which list the wirevectors hooked up as output for
193193
this particular net.
194194
195195
Below is a list of the basic operations. These properties (more formally
196-
specified) should all be checked by the class method sanity_check.
196+
specified) should all be checked by the class method 'sanity_check'.
197197
198-
* Most logical and arithmetic ops are pretty self explanatory, each takes
199-
exactly two arguments and they should perform the arithmetic or logical
198+
* Most logical and arithmetic ops are pretty self explanatory. Each takes
199+
exactly two arguments, and they should perform the arithmetic or logical
200200
operation specified. OPS: ('&','|','^','n','~','+','-','*'). All inputs must
201201
be the same bitwidth. Logical operations produce as many bits as are in
202-
the input, while '+' and '-' produce n+1 bits, and '*' produced 2n bits.
202+
the input, while '+' and '-' produce n+1 bits, and '*' produces 2n bits.
203203
204204
* In addition there are some operations for performing comparisons
205205
that should perform the operation specified. The '=' op is checking
@@ -210,29 +210,29 @@ class Block(object):
210210
* The 'w' operator is simply a directional wire and has no logic function.
211211
212212
* The 'x' operator is a mux which takes a select bit and two signals.
213-
If the value of the select bit is 0 it selects the second argument, if
213+
If the value of the select bit is 0 it selects the second argument; if
214214
it is 1 it selects the third argument. Select must be a single bit, while
215215
the other two arguments must be the same length.
216216
217-
* The 'c' operator is the concatiation operator and combines any number of
217+
* The 'c' operator is the concatenation operator and combines any number of
218218
wirevectors (a,b,...,z) into a single new wirevector with "a" in the MSB
219219
and "z" (or whatever is last) in the LSB position.
220220
221221
* The 's' operator is the selection operator and chooses, based on the
222-
op_param specificied, a subset of the logic bits from a WireVector to
222+
op_param specified, a subset of the logic bits from a WireVector to
223223
select. Repeats are accepted.
224224
225225
* The 'r' operator is a register and on posedge, simply copies the value
226-
from the input to the output of the register
226+
from the input to the output of the register.
227227
228228
* The 'm' operator is a memory block read port, which supports async reads (acting
229-
like combonational logic). Multiple read (and write) ports are possible to
229+
like combinational logic). Multiple read (and write) ports are possible to
230230
the same memory but each 'm' defines only one of those. The op_param
231231
is a tuple containing two references: the mem id, and a reference to the
232232
MemBlock containing this port. The MemBlock should only be used for debug and
233233
sanity checks. Each read port has one addr (an arg) and one data (a dest).
234234
235-
* The '@' (update) operator is a memory block write port, which supports syncronous writes
235+
* The '@' (update) operator is a memory block write port, which supports synchronous writes
236236
(writes are "latched" at posedge). Multiple write (and read) ports are possible
237237
to the same memory but each '@' defines only one of those. The op_param
238238
is a tuple containing two references: the mem id, and a reference to the MemoryBlock.
@@ -243,13 +243,13 @@ class Block(object):
243243
244244
The connecting elements (args and dests) should be WireVectors or derived
245245
from WireVector, and should be registered with the block using
246-
the method add_wirevector. Nets should be registered using add_net.
246+
the method 'add_wirevector'. Nets should be registered using 'add_net'.
247247
248-
In addition, there is a member legal_ops which defines the set of operations
248+
In addition, there is a member 'legal_ops' which defines the set of operations
249249
that can be legally added to the block. By default it is set to all of the above
250250
defined operations, but it can be useful in certain cases to only allow a
251251
subset of operations (such as when transforms are being done that are "lowering"
252-
the blocks to more primitive ops.
252+
the blocks to more primitive ops).
253253
"""
254254

255255
def __init__(self):
@@ -314,7 +314,7 @@ def get_memblock_by_name(self, name, strict=False):
314314
This useful for when a block defines its own internal memory block, and
315315
during simulation you want to instantiate that memory with certain values
316316
for testing. Since the Simulation constructor requires a reference to the
317-
memory object itself, but the block your testing defines the memory internally,
317+
memory object itself, but the block you're testing defines the memory internally,
318318
this allows you to get the object reference.
319319
320320
Note that this requires you know the name of the memory block, meaning that
@@ -410,16 +410,16 @@ def net_connections(self, include_virtual_nodes=False):
410410
signal an external source or sink (such as the source for an Input net).
411411
If disabled, these nodes will be excluded from the adjacency dictionaries
412412
:return wire_src_dict, wire_sink_dict
413-
Returns two dictionaries: one that map WireVectors to the logic
414-
nets that creates their signal and one that maps WireVectors to
413+
Returns two dictionaries: one that maps WireVectors to the logic
414+
net that creates their signal and one that maps WireVectors to
415415
a list of logic nets that use the signal
416416
417417
These dictionaries make the creation of a graph much easier, as
418418
well as facilitate other places in which one would need wire source
419-
and wire sink information
419+
and wire sink information.
420420
421421
Look at inputoutput.net_graph for one such graph that uses the information
422-
from this function
422+
from this function.
423423
"""
424424
src_list = {}
425425
dst_list = {}
@@ -466,8 +466,8 @@ def __iter__(self):
466466
that all of its "parents" have already been returned earlier in the iteration.
467467
468468
Note: this method will throw an error if there are loops in the
469-
logic that do not involve registers
470-
Also, the order of the nets is not guaranteed to be the the same
469+
logic that do not involve registers.
470+
Also, the order of the nets is not guaranteed to be the same
471471
over multiple iterations"""
472472
from .wire import Input, Const, Register
473473
src_dict, dest_dict = self.net_connections()

pyrtl/corecircuits.py

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def mux(index, *mux_ins, **kwargs):
1919
:param WireVector index: used as the select input to the multiplexer
2020
:param WireVector mux_ins: additional WireVector arguments selected when select>1
2121
:param WireVector kwargs: additional WireVectors, keyword arg "default"
22-
If you are selecting between less items than your index can address, you can
22+
If you are selecting between fewer items than your index can address, you can
2323
use the "default" keyword argument to auto-expand those terms. For example,
2424
if you have a 3-bit index but are selecting between 6 options, you need to specify
2525
a value for those other 2 possible values of index (0b110 and 0b111).
@@ -91,7 +91,7 @@ def select(sel, truecase, falsecase):
9191
9292
The hardware this generates is exactly the same as "mux" but by putting the
9393
true case as the first argument it matches more of the C-style ternary operator
94-
semantics which can be helpful for readablity.
94+
semantics which can be helpful for readability.
9595
9696
Example of mux as "ternary operator" to take the min of 'a' and 5: ::
9797
@@ -145,9 +145,9 @@ def concat_list(wire_list):
145145
:param wire_list: list of WireVectors to concat
146146
:return: WireVector with length equal to the sum of the args' lengths
147147
148-
This take a list of wirevectors and concats them all into a single wire
149-
vector with the element at index 0 serving as the least significant bits.
150-
This is useful when you have a variable number of wirevectors to concatenate,
148+
This take a list of WireVectors and concats them all into a single
149+
WireVector with the element at index 0 serving as the least significant bits.
150+
This is useful when you have a variable number of WireVectors to concatenate,
151151
otherwise "concat" is prefered.
152152
153153
Example using concat to combine two bytes into a 16-bit quantity: ::
@@ -160,12 +160,12 @@ def concat_list(wire_list):
160160

161161

162162
def signed_add(a, b):
163-
""" Return wirevector for result of signed addition.
163+
""" Return a WireVector for result of signed addition.
164164
165-
:param a: a wirevector to serve as first input to addition
166-
:param b: a wirevector to serve as second input to addition
165+
:param a: a WireVector to serve as first input to addition
166+
:param b: a WireVector to serve as second input to addition
167167
168-
Given a length n and length m wirevector the result of the
168+
Given a length n and length m WireVector the result of the
169169
signed addition is length max(n,m)+1. The inputs are twos
170170
complement sign extended to the same length before adding.
171171
If an integer is passed to either a or b, it will be converted
@@ -259,7 +259,7 @@ def shift_left_arithmetic(bits_to_shift, shift_amount):
259259
of the input `bits_to_shift` but where the bits have been shifted
260260
to the left. An arithemetic shift is one that treats the value as
261261
as signed number, although for left shift arithmetic and logic shift
262-
are identical. Note that `shift_amount` is treated as unsigned.
262+
they are identical. Note that `shift_amount` is treated as unsigned.
263263
"""
264264
# shift left arithmetic and logical are the same thing
265265
return shift_left_logical(bits_to_shift, shift_amount)
@@ -324,7 +324,8 @@ def shift_right_logical(bits_to_shift, shift_amount):
324324

325325

326326
def match_bitwidth(*args, **opt):
327-
""" Matches the bitwidth of all of the input arguments with zero or sign extend
327+
""" Matches the bitwidth of all of the input arguments with zero or sign extension,
328+
returning new WireVectors
328329
329330
:param args: WireVectors of which to match bitwidths
330331
:param opt: Optional keyword argument 'signed=True' (defaults to False)
@@ -333,12 +334,12 @@ def match_bitwidth(*args, **opt):
333334
Example of matching the bitwidths of two WireVectors `a` and `b` with
334335
with zero extention: ::
335336
336-
a,b = match_bitwidth(a, b)
337+
a, b = match_bitwidth(a, b)
337338
338339
Example of matching the bitwidths of three WireVectors `a`,`b`, and `c` with
339340
with sign extention: ::
340341
341-
a,b = match_bitwidth(a, b, c, signed=True)
342+
a, b = match_bitwidth(a, b, c, signed=True)
342343
"""
343344
# TODO: when we drop 2.7 support, this code should be cleaned up with explicit
344345
# kwarg support for "signed" rather than the less than helpful "**opt"
@@ -376,7 +377,7 @@ def myhardware(input_a, input_b):
376377
b = as_wires(input_b)
377378
myhardware(3, x)
378379
379-
The function as_wires will covert the 3 to Const but keep `x` unchanged
380+
The function as_wires will convert the 3 to Const but keep `x` unchanged
380381
assuming it is a WireVector.
381382
382383
"""
@@ -407,19 +408,19 @@ def myhardware(input_a, input_b):
407408

408409

409410
def bitfield_update(w, range_start, range_end, newvalue, truncating=False):
410-
""" Return wirevector w but with some of the bits overwritten by newvalue.
411+
""" Return WireVector w but with some of the bits overwritten by newvalue.
411412
412-
:param w: a wirevector to use as the starting point for the update
413+
:param w: a WireVector to use as the starting point for the update
413414
:param range_start: the start of the range of bits to be updated
414415
:param range_end: the end of the range of bits to be updated
415416
:param newvalue: the value to be written in to the start:end range
416417
:param truncating: if true, silently clip newvalue to the proper bitwidth rather than
417418
throw an error if the value provided is too large
418419
419-
Given a wirevector w, this function returns a new wirevector that
420+
Given a WireVector w, this function returns a new WireVector that
420421
is identical to w except in the range of bits specified. In that
421422
specified range, the value newvalue is swapped in. For example:
422-
`bitfield_update(w, 20, 23, 0x7)` will return return a wirevector
423+
`bitfield_update(w, 20, 23, 0x7)` will return return a WireVector
423424
of the same length as w, and with the same values as w, but with
424425
bits 20, 21, and 22 all set to 1.
425426
@@ -463,16 +464,16 @@ def bitfield_update(w, range_start, range_end, newvalue, truncating=False):
463464
def enum_mux(cntrl, table, default=None, strict=True):
464465
""" Build a mux for the control signals specified by an enum.
465466
466-
:param cntrl: is a wirevector and control for the mux.
467-
:param table: is a dictionary of the form mapping enum->wirevector.
468-
:param default: is a wirevector to use when the key is not present. In addtion
467+
:param cntrl: is a WireVector and control for the mux.
468+
:param table: is a dictionary of the form mapping enum->WireVector.
469+
:param default: is a WireVector to use when the key is not present. In addition
469470
it is possible to use the key 'otherwise' to specify a default value, but
470471
it is an error if both are supplied.
471472
:param strict: is flag, that when set, will cause enum_mux to check
472473
that the dictionary has an entry for every possible value in the enum.
473474
Note that if a default is set, then this check is not performed as
474475
the default will provide valid values for any underspecified keys.
475-
:return: a wirevector which is the result of the mux.
476+
:return: a WireVector which is the result of the mux.
476477
::
477478
478479
from enum import IntEnum
@@ -567,7 +568,7 @@ def _apply_op_over_all_bits(op, vector):
567568

568569

569570
def rtl_any(*vectorlist):
570-
""" Hardware equivalent of python native "any".
571+
""" Hardware equivalent of Python native "any".
571572
572573
:param WireVector vectorlist: all arguments are WireVectors of length 1
573574
:return: WireVector of length 1
@@ -584,7 +585,7 @@ def rtl_any(*vectorlist):
584585

585586

586587
def rtl_all(*vectorlist):
587-
""" Hardware equivalent of python native "all".
588+
""" Hardware equivalent of Python native "all".
588589
589590
:param WireVector vectorlist: all arguments are WireVectors of length 1
590591
:return: WireVector of length 1

pyrtl/helperfuncs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ def formatted_str_to_val(data, format, enum_set=None):
329329
330330
:param data: a string holding the value to convert
331331
:param format: a string holding a format which will be used to convert the data string
332-
:param enum_set: an iterable of enums which are used as part of the converstion process
332+
:param enum_set: an iterable of enums which are used as part of the conversion process
333333
334334
Given a string (not a wirevector!) covert that to an unsigned integer ready for input
335335
to the simulation enviornment. This helps deal with signed/unsigned numbers (simulation
@@ -717,7 +717,7 @@ def __init__(self, block=None):
717717

718718
def shrank(self, block=None, percent_diff=0, abs_diff=1):
719719
"""
720-
Returns whether a block has less nets than before
720+
Returns whether a block has fewer nets than before
721721
722722
:param Block block: block to check (if changed)
723723
:param Number percent_diff: percentage difference threshold

pyrtl/inputoutput.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ def net_graph(block=None, split_state=False):
456456
457457
aka: edge = graph[source][dest]
458458
459-
Each node can be either a logic net or a WireVector (e.g. an Input, and Output, a
459+
Each node can be either a logic net or a WireVector (e.g. an Input, an Output, a
460460
Const or even an undriven WireVector (which acts as a source or sink in the network)
461461
Each edge is a WireVector or derived type (Input, Output, Register, etc.)
462462
Note that inputs, consts, and outputs will be both "node" and "edge".
@@ -488,14 +488,14 @@ def net_graph(block=None, split_state=False):
488488
try:
489489
_from = wire_src_dict[w]
490490
except Exception:
491-
_from = w
491+
_from = w # e.g. an Input/Const
492492
if split_state and isinstance(w, Register):
493493
_from = w
494494

495495
try:
496496
_to_list = wire_dst_dict[w]
497497
except Exception:
498-
_to_list = [w]
498+
_to_list = [w] # e.g. an Output
499499

500500
for _to in _to_list:
501501
graph[_from][_to] = w

pyrtl/memory.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
MemBlocks supports any number of the following operations:
66
77
* read: `d = mem[address]`
8-
* write: `mem[address] = d`
9-
* write with an enable: `mem[address] = MemBlock.EnabledWrite(d,enable=we)`
8+
* write: `mem[address] <<= d`
9+
* write with an enable: `mem[address] <<= MemBlock.EnabledWrite(d,enable=we)`
1010
1111
Based on the number of reads and writes a memory will be inferred
1212
with the correct number of ports to support that
@@ -154,7 +154,7 @@ class MemBlock(_MemReadBase):
154154
155155
Usage::
156156
157-
data <<= memory[addr] (infer read port)
157+
data = memory[addr] (infer read port)
158158
memory[addr] <<= data (infer write port)
159159
mem[address] <<= MemBlock.EnabledWrite(data,enable=we)
160160

0 commit comments

Comments
 (0)