Skip to content
Snippets Groups Projects

Make spade-python a bit more pythonic

It is now possible to build a simple documentation (requires sphinx), but I do not really know how it relates to the rust docs. Nor what the long term plan of this is? (Make a package that can be installed using pip?)

Are there any tests for this?

Edited by Oscar Gustafsson

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
1 # Configuration file for the Sphinx documentation builder.
2 #
3 # For the full list of built-in configuration values, see the documentation:
4 # https://www.sphinx-doc.org/en/master/usage/configuration.html
5
6 # -- Project information -----------------------------------------------------
7 # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
8
9 project = 'spade'
10 copyright = '2023, Frans Skarman'
11 author = 'Frans Skarman'
  • 77 return expected_bits.lower() == got_bits.lower()
    78
    79 def _eq_helper(self, other: str):
    80 r = self._spade.compare_field(
    81 self._field_ref,
    93 82 other,
    94 BitString(self.dut__.output__.value.binstr)
    83 BitString(self._dut.output__.value.binstr)
    95 84 )
    96 expected_bits = r.expected_bits.inner();
    97 got_bits = r.got_bits.inner();
    98 return expected_bits.lower() == got_bits.lower()
    85 expected_bits = r.expected_bits.inner().lower()
    86 got_bits = r.got_bits.inner().lower()
    99 87
    88 return expected_bits, got_bits, r
  • 91 if attr.endswith("__") or attr == "assert_eq" or attr == "is_eq" or attr == "value":
    92 return super(OutputField, self).__getattribute__(attr)
    104 93 else:
    105 new_path = self.path__ + [__name]
    94 new_path = self._path + [attr]
    106 95 return OutputField(
    107 self.spade__,
    96 self._spade,
    108 97 new_path,
    109 self.spade__.output_field(new_path),
    110 self.dut__
    98 self._spade.output_field(new_path),
    99 self._dut
    111 100 )
    112 101
    102 __all__ = ['Spade', 'SpadeExt', 'OutputField', 'InputPorts', 'BitString', 'ComparisonResult', 'SpadeType']
    • I've never seen this before, what is it used for?

    • This basically says what will be imported if you do from spade import * or what you can access from spade after doing import spade.

      Good thing is that you cannot do like:

      spade.cocotb.package_that_cocotb_happens_to_import.class

      (This will for sure bite users sooner or later. We have loads of unused imports in Matplotlib that we cannot really remove in case someone has happened to include them (sometimes we still do, but having a well-defined import location for something is good, although you can import it from the wrong location).)

    • Please register or sign in to reply
    • Nice!

      I'm a bit sad that the from cocotb import * won't work, because while I very much like explicit imports normally, in a testbench, they are fairly tedious

    • No need to merge it yet. Probably better to discuss it once you are back. It is possible to include those in __all__ as well, if we think that it should be the case. (And then import the ones we think should be there explicitly from cocotb.)

    • Please register or sign in to reply
  • Frans Skarman approved this merge request

    approved this merge request

  • added 4 commits

    Compare with previous version

  • added 1 commit

    • d7d5fe7d - Make spade-python a bit more pythonic

    Compare with previous version

  • Please register or sign in to reply
    Loading