whitequark[cis] changed the topic of #amaranth-lang to: Amaranth hardware definition language · weekly meetings: Amaranth each Mon 1700 UTC, Amaranth SoC each Fri 1700 UTC · code https://github.com/amaranth-lang · logs https://libera.irclog.whitequark.org/amaranth-lang · Matrix #amaranth-lang:matrix.org
<cr1901> I'll keep that in mind. In the meantime I'm a bit stuck...
<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
<charlottia> layout.
<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.
<charlottia> data_foo._View__layout['foo'] == Enum.Foo
<charlottia> s//`/, s/Enum.//, s//`/
<charlottia> I think it would be nicer for .shape() to return Foo in this case, though, and it would not break its definition by doing so.
<charlottia> (since Foo is equally valid as an argument to Signal())
<cr1901> I'm willing to accept putting a shape call higher up the "." hierarchy for now
<cr1901> Bleh...
<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
jjsuperpower has quit [Ping timeout: 264 seconds]
<_whitenotifier-f> [amaranth] codecov[bot] commented on pull request #912: ast: fix const-castable expression handling in `Signal(reset=)`. - https://github.com/amaranth-lang/amaranth/pull/912#issuecomment-1732461652
<_whitenotifier-f> [amaranth-lang/amaranth] github-merge-queue[bot] pushed 1 commit to gh-readonly-queue/main/pr-912-11d5bb19eb34463918c07dc5e2e0eac7dbf822b0 [+0/-0/±2] https://github.com/amaranth-lang/amaranth/commit/05cb82b8fc3a
<_whitenotifier-f> [amaranth-lang/amaranth] wanda-phi 05cb82b - ast: fix const-castable expression handling in `Signal(reset=)`.
<_whitenotifier-f> [amaranth] github-merge-queue[bot] created branch gh-readonly-queue/main/pr-912-11d5bb19eb34463918c07dc5e2e0eac7dbf822b0 - https://github.com/amaranth-lang/amaranth
<_whitenotifier-f> [amaranth-lang/amaranth] github-merge-queue[bot] pushed 1 commit to main [+0/-0/±2] https://github.com/amaranth-lang/amaranth/compare/11d5bb19eb34...05cb82b8fc3a
<_whitenotifier-f> [amaranth-lang/amaranth] wanda-phi 05cb82b - ast: fix const-castable expression handling in `Signal(reset=)`.
<_whitenotifier-f> [amaranth-lang/amaranth] github-merge-queue[bot] deleted branch gh-readonly-queue/main/pr-912-11d5bb19eb34463918c07dc5e2e0eac7dbf822b0
<_whitenotifier-f> [amaranth] whitequark closed pull request #912: ast: fix const-castable expression handling in `Signal(reset=)`. - https://github.com/amaranth-lang/amaranth/pull/912
<_whitenotifier-f> [amaranth] github-merge-queue[bot] deleted branch gh-readonly-queue/main/pr-912-11d5bb19eb34463918c07dc5e2e0eac7dbf822b0 - https://github.com/amaranth-lang/amaranth
<_whitenotifier-f> [amaranth] whitequark closed issue #911: Signal reset cannot be set to a const value - https://github.com/amaranth-lang/amaranth/issues/911
<_whitenotifier-f> [amaranth-lang/amaranth-lang.github.io] whitequark pushed 1 commit to main [+0/-0/±32] https://github.com/amaranth-lang/amaranth-lang.github.io/compare/15c19c4088ff...2922d6ccff93
<_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"