<cr1901>
For starters, how do I get rid of the "Slice object has no attribute FOO" error?
<cr1901>
(Comment out "amaranth.lib.enum import Enum" line if you try this code yourself)
charlottia has joined #amaranth-lang
<charlottia>
:eyse:
<charlottia>
* 👀
<charlottia>
* :eyes:
<cr1901>
Are those good eyes, or bad eyes :P? The code is meant to be syntatically valid, not a meaningful circuit :P
<jfng[m]>
here ? `with m.If(self.data_foo == self.data_all.foo.FOO):`
<jfng[m]>
`data_all.foo` is just a value, right ?
<charlottia>
That's "me looking"!
<charlottia>
Why would you expect FOO to be a property of a signal with a Foo value?
<charlottia>
Just to get back to the enum?
<jfng[m]>
^
<charlottia>
I am aware you can say Foo.BAR.FOO, for instance, but signals are a bit too special for that (since they represent values, rather than being values).
<cr1901>
Because I did a bad find and replace and apparently I'm not observant
<charlottia>
(it wouldn't be impossible to make this work, too, but I think the value is limited.)
<charlottia>
Oooooh, that's fair!
<charlottia>
<cr1901> "(Comment out "amaranth.lib...." <- At some point soon-ish I'll probably go through a bunch of Enum-related stuff with Cat and get rid of more of the weird differences between builtin enum and Amaranth enum.
<cr1901>
Is is not clear to me that the TypeError is desired or not (at least, I think it should be consistent- data_all doesn't error out, and it contains a Foo
<charlottia>
I agree that it should be consistent.
<charlottia>
Are you able to open an issue about that one and tag me? I'd like to keep it in mind.
<cr1901>
I'll do it a bit later, but yes
<charlottia>
My thanks.
<cr1901>
Okay, I actually do need the Foo.BAR.FOO functionality, because these enums (and the layout these enums are part of) are generated on-the-fly from a file.
<cr1901>
The example I pasted doesn't reflect this, but I don't actually know the _name_ of the enum class when trying to access the variants (functional-style enum)
<charlottia>
Hmm, okay.
<charlottia>
<charlottia> "(it wouldn't be impossible to..." <- (Then maybe the value is less limited.)
Degi has quit [Ping timeout: 252 seconds]
Degi_ has joined #amaranth-lang
Degi_ is now known as Degi
<charlottia>
hmm, okay.
<cr1901>
AttributeError: type object 'Layout' has no attribute 'of' <-- uhhh, what happened to Layout.of again?
<charlottia>
So, data_all.foo is returning a slice into its underlying signal, and so of course it isn't a regular Enum value because it's a signal. I don't think we should have signals do this lookup arbitrarily (e.g. in __getattr__ or whatever), even if they point to an Enum-shaped thing; that would be unexpected from an arbitrary signal. But maybe it should be easier to get the (statically-known) shape of a field of a given view's
<cr1901>
That's fine. I just want to be able to access the enum values at all. This is in fact by design; if the txt file that generates the enums/variants mis-matches with the Amaranth code actually using the enum variant names, I _want_ the build to error out.
<charlottia>
(Unfortunately for you in this example, .shape() returns unsigned(2), not Foo.)
<charlottia>
_nodnod-
<charlottia>
* _nodnod_
<cr1901>
So I'm stuck then.
<charlottia>
Well, you can do it with private accesses.
<cr1901>
shape() returns the Layout, which is a dict, accessing the dict returns a Field, and the shape attr contains the actual enum class
<charlottia>
Glad there's a workaround! I will think about getting the field's .shape() to return the enum and not just unsigned(2).
<cr1901>
Butterfly meme "Is this introspection?"
<charlottia>
:3
<cr1901>
Thankfully, this is probably the "worst" that I intended to stress Amaranth's capabilities. The old method I had of using dicts to hold all the autogenerated crap worked, but I thought was very ugly
<_whitenotifier-f>
[amaranth-lang/amaranth-lang.github.io] github-merge-queue[bot] 2922d6c - Deploying to main from @ amaranth-lang/amaranth@05cb82b8fc3ac53518d5bd07c5d474ae21522099 🚀
<cr1901>
charlottia: I had a hyperfocus refactoring code and my energy has run out. I'll do the enum issue thing tomorrow
<cr1901>
(But at least most of the refactoring is done)
leptonix has quit [Ping timeout: 258 seconds]
leptonix has joined #amaranth-lang
notgull has quit [Ping timeout: 255 seconds]
notgull has joined #amaranth-lang
peeps[zen] has quit [Ping timeout: 258 seconds]
peepsalot has joined #amaranth-lang
Guest75 has joined #amaranth-lang
Guest75 has quit [Client Quit]
Guest51 has joined #amaranth-lang
Guest51 has quit [Quit: Client closed]
josuah has quit [Quit: josuah]
josuah has joined #amaranth-lang
jjsuperpower has joined #amaranth-lang
jjsuperpower has quit [Ping timeout: 252 seconds]
<mcc111[m]>
So if anyone's interested in the progress on the Pocket front, I've got a version up of Catherine's Pocket sample code which supports audio and has synchronized audio/video animation, and can emit wav files in simulation (as well as PNGs, which it inherited from Catherine's code) https://mastodon.social/@mcc/111116272752744809
<mcc111[m]>
It's really slow— when I moved from Mac to Windows I didn't wind up installing Pypy, and probably I should have.
<galibert[m]>
Cool
moupinger has joined #amaranth-lang
moupinger has left #amaranth-lang [Smell ya l8r]
peeps[zen] has joined #amaranth-lang
peepsalot has quit [Ping timeout: 245 seconds]
peeps[zen] has quit [Ping timeout: 240 seconds]
<cr1901>
(On IRC side) Did m**pinger come and privmsg anyone else a slur?
<whitequark[cis]>
not me
<cr1901>
Interesting. I got a privmsg from them. It said "I hate [slur]". Guess it's "just" a drive-by troll, thankfully
Darius has quit [Ping timeout: 240 seconds]
Darius has joined #amaranth-lang
<cr1901>
Something that didn't click for me until now is that "interface objects don't necessarily need to also be Elaboratables/Components in order to be useful": https://github.com/amaranth-lang/amaranth-soc/blob/main/tests/test_wishbone_bus.py#L263. AFAIK you can do connect(m, sub_1, my_wb_device_on_the_bus), and you'll still get "my_wb_device_on_the_bus" attached downstream of Decoder
<cr1901>
Maybe this was supposed to be an obvious takeaway, but took me seeing an example to "get it"