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?
Merge request reports
Activity
requested review from @TheZoq2
i think you need to setup a trigger token: https://docs.gitlab.com/ee/ci/triggers/#create-a-trigger-token but since you have push access to spade-lang/spade it makes more sense to push your branches to that repository imo
Nor what the long term plan of this is? (Make a package that can be installed using pip?)
The primary use of the python stuff is to expose enough of the compiler to write spade expressions inside cocotb test benches. The only thing I consider public API for it is the
SpadeExt
stuff used there.I think I also use part of it to do type translation in my experimental VCD viewer, as that needs to figure out types, and to be able to translate bit vectors back to spade values
I'm not sure how much use a more general python library would be. In most cases, you probably wouldn't want to interract much with the compiler at this level, but it has clearly come in handy twice
I've sorted out the issue now, but since some of the projects seems to rely on
from spade import *
will importcocotb
they are not working anymore. I still think that this is the way to go. Python imports are a bit strange since you easily can "proxy import" stuff, leading to later errors if those imports are changed/removed, so always better to import from the correct source.You will have to check https://gitlab.com/spade-lang/trawler/-/jobs/4119690527 as that is the copy pushed to
spade-lang
(identical to the one here).Edited by Oscar Gustafssonmentioned in merge request book!11 (merged)
- spade-python/docs/conf.py 0 → 100644
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' changed this line in version 6 of the diff
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'] This basically says what will be imported if you do
from spade import *
or what you can access fromspade
after doingimport 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).)
added 4 commits
-
e1adf536...38c4fac4 - 3 commits from branch
spade-lang:master
- b8c081cb - Make spade-python a bit more pythonic
-
e1adf536...38c4fac4 - 3 commits from branch