|
1 | 1 | Helper Functions
|
2 | 2 | ================
|
3 | 3 |
|
4 |
| -Built-in Hardware Generators |
| 4 | +Cutting and Extending WireVectors |
| 5 | +--------------------------------- |
| 6 | + |
| 7 | +The functions below provide ways of combining, slicing, and extending WireVectors in |
| 8 | +ways that are often useful in hardware design. The functions below extend those member |
| 9 | +functions of the WireVector class iself (which provides support for the python builtin |
| 10 | +``len``, slicing as just as in a python list e.g. ``wire[3:6]``, ``zero_extend``, ``sign_extend``, |
| 11 | +and many operators such as addition and multiplication). |
| 12 | + |
| 13 | +.. autofunction:: pyrtl.corecircuits.concat |
| 14 | +.. autofunction:: pyrtl.corecircuits.concat_list |
| 15 | +.. autofunction:: pyrtl.corecircuits.match_bitwidth |
| 16 | +.. autofunction:: pyrtl.helperfuncs.truncate |
| 17 | +.. autofunction:: pyrtl.helperfuncs.chop |
| 18 | + |
| 19 | +Coercion to WireVector |
| 20 | +---------------------- |
| 21 | + |
| 22 | +In PyRTL there is only one function in charge of coercing values into WireVectors, and that is |
| 23 | +``as_wires``. This function is called in almost all helper functions and classes to manage |
| 24 | +the mixture of constants and WireVectors that naturally occur in hardware development. |
| 25 | + |
| 26 | +.. autofunction:: pyrtl.corecircuits.as_wires |
| 27 | + |
| 28 | +Control Flow Hardware |
| 29 | +--------------------- |
| 30 | + |
| 31 | +.. autofunction:: pyrtl.corecircuits.mux |
| 32 | +.. autofunction:: pyrtl.corecircuits.select |
| 33 | +.. autofunction:: pyrtl.corecircuits.enum_mux |
| 34 | +.. autofunction:: pyrtl.corecircuits.bitfield_update |
| 35 | +.. autofunction:: pyrtl.corecircuits.bitfield_update_set |
| 36 | +.. autofunction:: pyrtl.helperfuncs.match_bitpattern |
| 37 | + |
| 38 | +Creating Lists of WireVectors |
| 39 | +----------------------------- |
| 40 | + |
| 41 | +.. autofunction:: pyrtl.helperfuncs.input_list |
| 42 | +.. autofunction:: pyrtl.helperfuncs.output_list |
| 43 | +.. autofunction:: pyrtl.helperfuncs.register_list |
| 44 | +.. autofunction:: pyrtl.helperfuncs.wirevector_list |
| 45 | + |
| 46 | +Interpreting Vectors of Bits |
5 | 47 | ----------------------------
|
6 | 48 |
|
7 |
| -.. automodule:: pyrtl.corecircuits |
8 |
| - :members: |
9 |
| - :show-inheritance: |
10 |
| - :special-members: __init__ __iter__ __str__ |
11 |
| - :undoc-members: |
12 |
| - |
13 |
| -Hardware Design Helper Functions |
14 |
| --------------------------------- |
15 |
| - |
16 |
| -.. automodule:: pyrtl.helperfuncs |
17 |
| - :members: |
18 |
| - :show-inheritance: |
19 |
| - :special-members: |
20 |
| - :undoc-members: |
21 |
| - :exclude-members: __dict__,__weakref__,__module__ |
| 49 | +Under the hood, every single `value` a PyRTL design operates on is a bit vector (which is, in turn, simply |
| 50 | +an integer of bounded power-of-two size. Interpreting these bit vectors as humans, and turning human |
| 51 | +understandable values into their corresponding bit vectors, can both be a bit of a pain. The functions |
| 52 | +below do not create any hardware but rather help in the process of reasoning about bit vector representations |
| 53 | +of human understandable values. |
| 54 | + |
| 55 | +.. autofunction:: pyrtl.helperfuncs.val_to_signed_integer |
| 56 | +.. autofunction:: pyrtl.helperfuncs.val_to_formatted_str |
| 57 | +.. autofunction:: pyrtl.helperfuncs.formatted_str_to_val |
| 58 | +.. autofunction:: pyrtl.helperfuncs.infer_val_and_bitwidth |
| 59 | +.. autofunction:: pyrtl.helperfuncs.log2 |
| 60 | + |
| 61 | +Debugging |
| 62 | +--------- |
| 63 | + |
| 64 | +.. autofunction:: pyrtl.core.set_debug_mode |
| 65 | +.. autofunction:: pyrtl.helperfuncs.probe |
| 66 | +.. autofunction:: pyrtl.helperfuncs.rtl_assert |
| 67 | +.. autofunction:: pyrtl.helperfuncs.check_rtl_assertions |
| 68 | +.. autofunction:: pyrtl.helperfuncs.find_loop |
| 69 | +.. autofunction:: pyrtl.helperfuncs.find_and_print_loop |
| 70 | + |
| 71 | +Reductions |
| 72 | +---------- |
| 73 | + |
| 74 | +.. autofunction:: pyrtl.corecircuits.and_all_bits |
| 75 | +.. autofunction:: pyrtl.corecircuits.or_all_bits |
| 76 | +.. autofunction:: pyrtl.corecircuits.xor_all_bits |
| 77 | +.. autofunction:: pyrtl.corecircuits.parity |
| 78 | +.. autofunction:: pyrtl.corecircuits.rtl_any |
| 79 | +.. autofunction:: pyrtl.corecircuits.rtl_all |
| 80 | +.. autofunction:: pyrtl.corecircuits.tree_reduce |
| 81 | + |
| 82 | +Extended Logic and Arithmetic |
| 83 | +----------------------------- |
| 84 | + |
| 85 | +The functions below provide ways of comparing and arithmetically combining WireVectors |
| 86 | +in ways that are often useful in hardware design. The functions below extend those member |
| 87 | +functions of the WireVector class iself (which provides support for addition, unsigned |
| 88 | +multiplication, unsigned comparison, and many others). |
| 89 | + |
| 90 | +.. autofunction:: pyrtl.corecircuits.signed_add |
| 91 | +.. autofunction:: pyrtl.corecircuits.signed_mult |
| 92 | +.. autofunction:: pyrtl.corecircuits.signed_lt |
| 93 | +.. autofunction:: pyrtl.corecircuits.signed_le |
| 94 | +.. autofunction:: pyrtl.corecircuits.signed_gt |
| 95 | +.. autofunction:: pyrtl.corecircuits.signed_ge |
| 96 | +.. autofunction:: pyrtl.corecircuits.shift_left_arithmetic |
| 97 | +.. autofunction:: pyrtl.corecircuits.shift_right_arithmetic |
| 98 | +.. autofunction:: pyrtl.corecircuits.shift_left_logical |
| 99 | +.. autofunction:: pyrtl.corecircuits.shift_right_logical |
0 commit comments