whitequark changed the topic of #amaranth-lang to: Amaranth hardware definition language · weekly meetings on Mondays at 1700 UTC · code https://github.com/amaranth-lang · logs https://libera.irclog.whitequark.org/amaranth-lang
Degi_ has joined #amaranth-lang
Degi has quit [Ping timeout: 260 seconds]
Degi_ is now known as Degi
bl0x_ has joined #amaranth-lang
bl0x has quit [Ping timeout: 240 seconds]
cr1901 has quit [Read error: Connection reset by peer]
cr1901 has joined #amaranth-lang
sauce has joined #amaranth-lang
peeps[zen] has quit [Quit: Connection reset by peep]
peepsalot has joined #amaranth-lang
byteit101 has joined #amaranth-lang
<d1b2> <Olivier Galibert> if a = Signal(8) and b = Signal() and I write a & b, do I get a 8-bits expansion of b before the and?
<bl0x_> I think that how the operators work, yes
<d1b2> <Olivier Galibert> thanks
smkz has quit [Quit: smkz]
<josuah> @Oliver Galibert: what I like with Amaranth is that it is easy to look that up:
<josuah> which answers the question \o/ it takes the greater out of the two shapes as a destination signal
<d1b2> <Olivier Galibert> yay!
<d1b2> <Olivier Galibert> but that doesn't tell whether it zero-fills the extra bits or actually copies b
<d1b2> <Olivier Galibert> because the answer is way less obvious if shape(a) = unsigned(4) and shape(b) = unsigned(3)
<d1b2> <Olivier Galibert> you know that shape(a&b) = unsigned(4) but that's it
<d1b2> <Olivier Galibert> (sorry, been looking at a lot of quantum mechanics math lately, I'm in a formal mood)
PatD has joined #amaranth-lang
<PatD> Bonjour!  I haven't done formal verif in Amaranth since ye olde days of nMigen, and as I was coding along I updated yosys hq's oss-cad-suite ('cause I'm lazy and it has everything I need in a bundle, including amaranth).  Short story, newer amaranth in there has a deprecation warning "instead of using `Past`, create a register explicitly" and
<PatD> there's nothing I can find in docs or git logs that gives me a clue what is really meant by this.
<PatD> So my questions are:
<PatD>  * is there an example of this new approach somewhere?
<PatD>  * do you need assist in documenting this further?
<PatD> Ok, guessing I should come back on mondays... I'm assuming this means manually creating a FIFO and checking that, or somesuch (?).  If a maintainer-type person should happen to see this, and you're interested in documenting/tutorial type stuff, I'm not Baruch-level but I do create some content and my last 2 vids were amaranth-related (starts with
<PatD> https://www.youtube.com/watch?v=h9_4jBKhs9k ) so if you're interested in docs or specific tutorial/walk-through type stuff, get in touch through there and lemme know!  Gotta go, cheers!
<josuah> Olivier Galibert: my impression is it that it zero fills, but that is only guessed from the practice of implicitly zero-filling Signals at reset Amaranth has
<josuah> Bonjour PatD, voyons-voir...
<josuah> PatD: what I understand with using a register explicitly instead of using past (like $past() would have been in Verilog/SystemVerilog) would be:
<josuah> for a combinational signal (wire in Verilog) named 'something_d', adding a synchronous signal named 'something_q' (register in Verilog) that gets updated at every clock with the value of 'something_d'
<josuah> then at any given time, 'something_q' contains the value that 'something_d' had the previous clock
<josuah> maybe something like that: m.d.sync += something_q.eq(something_d)
<josuah> for supporting arbitrary amount of $past() values, some shift register could be used
<josuah> that is some catchy video
<PatD> Hah, thanks, and thanks for the answer.  So yeah, am working on a bit of frequency counting so I'll try to implement that using a (relatively) gigantic SyncFIFO or something.
PatD has quit [Quit: Client closed]
PatD has joined #amaranth-lang
<PatD> Actually, maybe a Memory is a more appropriate tool...
smkz has joined #amaranth-lang
smkz has quit [Client Quit]
PatD11 has joined #amaranth-lang
PatD11 has quit [Client Quit]
<PatD> Yeah, no... the sync, the mem, all that stuff is overly convoluted... Best I could come up with is something like
<PatD>     outputs = Signal(100)
<PatD>     inputs = Signal(100)
<PatD>     count = Signal(range(100))
<PatD>     for i in range(100):
<PatD>         with m.If(count == i):
<PatD>             m.d.sync += [
<PatD>                 outputs[i].eq(edgedetect.output),
<PatD>                 inputs[i].eq(edgedetect.input)
<PatD>             ]
<PatD>     m.d.sync += count.eq(count + 1)
<PatD> to keep track of the history rather than use Past, and it seems ridiculous.  So will wait until the meet or some assist on how we're supposed to replace Past now that we're in Future.
<crzwdjk> PatD: you can use inputs.bit_select(count, 1) instead of your loop, for one thing, so that makes things a bit simpler.
<PatD> Hi crzwdjk, thanks for the tip--didn't know this accessor.  My main issue however is the history tracking itself--I'm assuming it cannot be that I have to implement this in every test I perform, but I can't locate any docs on what we're supposed to use instead of Past().
smkz has joined #amaranth-lang
PatD has quit [Quit: Client closed]
<whitequark> a register
<whitequark> or several registers
byteit101 has quit [Remote host closed the connection]
<cr1901> To be explicit, Assert and Assume aren't going away (for now), just Past?
<cr1901> Btw, I've read that for loop in that sample code several times, what is it intended to do?
PatD has joined #amaranth-lang
PatD has quit [Client Quit]
PatD has joined #amaranth-lang
<PatD> Hi, sorry whitequark, I go booted out then it didn't refresh the message I'd missed when it let me back in.  A register...  could you point me to a place in the tests where this is used?
<PatD> To view the past, I mean, say 10 ticks ago for instance.\
<PatD> All right, well for anyone that might find this of use, I've implemented a basic snapshot system to track signal of interest
<PatD> class History(Elaboratable):
<PatD>     '''
<PatD>         Track the history of signals of interest.
<PatD>         @copyright: (C) 2023 Pat Deegan, https://psychogenic.com
<PatD>         Basic attempt to replace Past() functions. Rather than working backwards,
<PatD>         you track() signals of interest and then can access their state at any point
<PatD>         (up to maxHistory), e.g.
<PatD>         hist = History()
<PatD>         hist.track(somesignal)
<PatD>         # ...
<PatD>         # two cycles after somesignal rises, anothersig will be true
<PatD>         with m.If( (hist.ticks == 3) &
<PatD>                     ~hist.snapshot(somesignal, 0) &
<PatD>                     hist.snapshot(somesignal, 1)):
<PatD>             m.d.comb += Assert(anothersig == 1)
<PatD>         @note: barely tested, and only with sigs 1-bit wide
<PatD>     '''
<PatD>         m = Module()
<PatD>         m.d.sync += self.ticks.eq(self.ticks + 1)
<PatD>         for r in range(len(self.registers)):
<PatD>             for t in range(self.maxHistory):
<PatD>                 with m.If(self.ticks == t):
<PatD>                     s = self.registers[r]
<PatD>                     m.d.sync += self.history[r][
<PatD>                             self.sliceStart(s, t):self.sliceEnd(s, t)].eq(self.registers[r])
<PatD>         return m
<PatD>     def sizeFor(self, s:Signal):
<PatD>         return len(s)
<PatD>     def sliceStart(self, s:Signal, tickIdx:int):
<PatD>         ssize = self.sizeFor(s)
<PatD>         return tickIdx*ssize
<PatD>     def sliceEnd(self, s:Signal, tickIdx:int):
<PatD>         return self.sliceStart(s, tickIdx) + self.sizeFor(s)
<PatD> This allows for things like
<PatD>     with m.If( (hist.ticks > 5) &
<PatD>                ~(hist.snapshot(edgedetect.input, 0)) &
PatD has quit [Quit: Client closed]
FFY00_ has quit [Ping timeout: 240 seconds]
PatD has joined #amaranth-lang
<PatD> lol, just saw the log of my recent posts--libera chops it all up in very interesting ways.  So, I'll push this to my fork if there's no better official way. a+
PatD has quit [Client Quit]
nak has quit [Ping timeout: 276 seconds]
<whitequark> Assert and Assume are here to stay, yes
nak has joined #amaranth-lang
FFY00 has joined #amaranth-lang