@@ -19,7 +19,7 @@ def mux(index, *mux_ins, **kwargs):
19
19
:param WireVector index: used as the select input to the multiplexer
20
20
:param WireVector mux_ins: additional WireVector arguments selected when select>1
21
21
: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
23
23
use the "default" keyword argument to auto-expand those terms. For example,
24
24
if you have a 3-bit index but are selecting between 6 options, you need to specify
25
25
a value for those other 2 possible values of index (0b110 and 0b111).
@@ -91,7 +91,7 @@ def select(sel, truecase, falsecase):
91
91
92
92
The hardware this generates is exactly the same as "mux" but by putting the
93
93
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 .
95
95
96
96
Example of mux as "ternary operator" to take the min of 'a' and 5: ::
97
97
@@ -145,9 +145,9 @@ def concat_list(wire_list):
145
145
:param wire_list: list of WireVectors to concat
146
146
:return: WireVector with length equal to the sum of the args' lengths
147
147
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,
151
151
otherwise "concat" is prefered.
152
152
153
153
Example using concat to combine two bytes into a 16-bit quantity: ::
@@ -160,12 +160,12 @@ def concat_list(wire_list):
160
160
161
161
162
162
def signed_add (a , b ):
163
- """ Return wirevector for result of signed addition.
163
+ """ Return a WireVector for result of signed addition.
164
164
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
167
167
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
169
169
signed addition is length max(n,m)+1. The inputs are twos
170
170
complement sign extended to the same length before adding.
171
171
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):
259
259
of the input `bits_to_shift` but where the bits have been shifted
260
260
to the left. An arithemetic shift is one that treats the value as
261
261
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.
263
263
"""
264
264
# shift left arithmetic and logical are the same thing
265
265
return shift_left_logical (bits_to_shift , shift_amount )
@@ -324,7 +324,8 @@ def shift_right_logical(bits_to_shift, shift_amount):
324
324
325
325
326
326
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
328
329
329
330
:param args: WireVectors of which to match bitwidths
330
331
:param opt: Optional keyword argument 'signed=True' (defaults to False)
@@ -333,12 +334,12 @@ def match_bitwidth(*args, **opt):
333
334
Example of matching the bitwidths of two WireVectors `a` and `b` with
334
335
with zero extention: ::
335
336
336
- a,b = match_bitwidth(a, b)
337
+ a, b = match_bitwidth(a, b)
337
338
338
339
Example of matching the bitwidths of three WireVectors `a`,`b`, and `c` with
339
340
with sign extention: ::
340
341
341
- a,b = match_bitwidth(a, b, c, signed=True)
342
+ a, b = match_bitwidth(a, b, c, signed=True)
342
343
"""
343
344
# TODO: when we drop 2.7 support, this code should be cleaned up with explicit
344
345
# kwarg support for "signed" rather than the less than helpful "**opt"
@@ -376,7 +377,7 @@ def myhardware(input_a, input_b):
376
377
b = as_wires(input_b)
377
378
myhardware(3, x)
378
379
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
380
381
assuming it is a WireVector.
381
382
382
383
"""
@@ -407,19 +408,19 @@ def myhardware(input_a, input_b):
407
408
408
409
409
410
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.
411
412
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
413
414
:param range_start: the start of the range of bits to be updated
414
415
:param range_end: the end of the range of bits to be updated
415
416
:param newvalue: the value to be written in to the start:end range
416
417
:param truncating: if true, silently clip newvalue to the proper bitwidth rather than
417
418
throw an error if the value provided is too large
418
419
419
- Given a wirevector w, this function returns a new wirevector that
420
+ Given a WireVector w, this function returns a new WireVector that
420
421
is identical to w except in the range of bits specified. In that
421
422
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
423
424
of the same length as w, and with the same values as w, but with
424
425
bits 20, 21, and 22 all set to 1.
425
426
@@ -463,16 +464,16 @@ def bitfield_update(w, range_start, range_end, newvalue, truncating=False):
463
464
def enum_mux (cntrl , table , default = None , strict = True ):
464
465
""" Build a mux for the control signals specified by an enum.
465
466
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
469
470
it is possible to use the key 'otherwise' to specify a default value, but
470
471
it is an error if both are supplied.
471
472
:param strict: is flag, that when set, will cause enum_mux to check
472
473
that the dictionary has an entry for every possible value in the enum.
473
474
Note that if a default is set, then this check is not performed as
474
475
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.
476
477
::
477
478
478
479
from enum import IntEnum
@@ -567,7 +568,7 @@ def _apply_op_over_all_bits(op, vector):
567
568
568
569
569
570
def rtl_any (* vectorlist ):
570
- """ Hardware equivalent of python native "any".
571
+ """ Hardware equivalent of Python native "any".
571
572
572
573
:param WireVector vectorlist: all arguments are WireVectors of length 1
573
574
:return: WireVector of length 1
@@ -584,7 +585,7 @@ def rtl_any(*vectorlist):
584
585
585
586
586
587
def rtl_all (* vectorlist ):
587
- """ Hardware equivalent of python native "all".
588
+ """ Hardware equivalent of Python native "all".
588
589
589
590
:param WireVector vectorlist: all arguments are WireVectors of length 1
590
591
:return: WireVector of length 1
0 commit comments