Sunday, 2025-07-20

*** tpb <[email protected]> has joined #yosys00:01
*** _whitelogger <[email protected]> has quit IRC (Remote host closed the connection)03:00
*** _whitelogger <[email protected]> has joined #yosys03:06
*** _whitelogger <[email protected]> has quit IRC (Remote host closed the connection)05:02
*** _whitelogger <[email protected]> has joined #yosys05:08
*** mithro <[email protected]> has quit IRC (Ping timeout: 272 seconds)05:34
*** mithro <[email protected]> has joined #yosys05:38
*** krispaul <[email protected]> has joined #yosys08:03
*** kristianpaul <kristianpaul!~paul@user/kristianpaul> has quit IRC (Ping timeout: 240 seconds)08:04
*** _whitelogger <[email protected]> has quit IRC (Remote host closed the connection)09:54
*** _whitelogger <[email protected]> has joined #yosys10:00
*** xutaxkamay_ <xutaxkamay_!~xutaxkama@2a01:cb1c:206:da00:318e:250:9a90:2816> has joined #yosys12:55
*** xutaxkamay <[email protected]> has quit IRC (Read error: Connection reset by peer)12:55
*** xutaxkamay_ is now known as xutaxkamay12:56
*** krispaul <[email protected]> has quit IRC (Quit: WeeChat 3.5)20:44
*** kristianpaul <kristianpaul!~paul@user/kristianpaul> has joined #yosys20:45
*** nonchip <[email protected]> has quit IRC (Quit: https://quassel-irc.org - Chat comfortably. Anywhere.)22:13
*** nonchip <[email protected]> has joined #yosys22:13
ysionneauhi, I'm trying to understand a timing report from nextpnr here: https://paste.centos.org/view/44380199  the Info: Critical path report for cross-domain path 'posedge $glbnet$ecp5pll_clkout0' -> '<async>':22:39
tpbTitle: Untitled - Pastebin Service (at paste.centos.org)22:39
ysionneauI can see the path starts with:   clk-to-q  4.26  4.26 Source storage_3.0.0.DOB422:39
ysionneaustorage_3.0.0.DOB4 is a DP16KD (dual ported ram) of ECP522:40
ysionneauwell, that's storage_3.0.0 and I guess DOB4 is the DataOut port B bit 422:41
ysionneauclk-to-q is the time for the DP16KD to output data after a clock edge? is it normal it's so slow?!22:42
ysionneauit's eating so much of my timing22:42
ysionneauI'm trying to find this information in Lattice datasheet but all I find is wave diagram and this timing annotation : tCOO_EBR22:43
ysionneaubut they never say how much tCOO_EBR is 22:43
*** lofty[m] <lofty[m]!loftyfield@2a01:4f8:c012:5b7:0:1:0:570> has joined #yosys22:48
lofty[m]ysionneau: what's your nextpnr command line?22:48
lofty[m]I should point out that "<async>" usually implies "the outside world", through I/O or such.22:49
ysionneauyes the end of this route is an IO22:53
ysionneaubut the remaining part of this (critical) path seems quite normal22:54
ysionneauI'm just afraid by this 4.26 ns which is enormous22:54
ysionneauhmm maybe it's because it's in "NOREG" mode (output is not registered), I get "REGMODE_A": "NOREG", and same for B22:55
ysionneauit's sad because I instanciated a LiteX SyncFifo with buffered=True which I think is meant to mean "please put a reg at output"22:57
ysionneaubut it seems yosys did not understand something and put a NOREG DP16KD22:58
ysionneauhmhm it seems indeed the verilog does not seem *that* buffered, at all :o23:04
ysionneauso I guess it's a LiteX or migen issue23:04
ysionneaulofty[m]: cmdline is nextpnr-ecp5 --json hydrasucrela.json --lpf hydrasucrela.lpf --textcfg hydrasucrela.config  --12k --package CABGA381 --speed 8 --timing-allow-fail --seed 123:05
*** whitequark[cis] <whitequark[cis]!whitequark@2a01:4f8:c012:5b7:0:1:0:4> has joined #yosys23:05
whitequark[cis]SyncFIFOBuffered puts one register at the output of an async memory23:05
whitequark[cis]if you want one more pipeline stage you have to add it yourself23:05
whitequark[cis]AsyncFIFOBuffered however adds a pipeline stage on top of an existing sync memory23:06
ysionneauhmhm23:09
ysionneauwhitequark[cis]: I can see this in the generated verilog https://paste.centos.org/view/7209e8b423:10
tpbTitle: Untitled - Pastebin Service (at paste.centos.org)23:10
ysionneauiiuc the fact that it's read in a always @posedge XXX block means the output is buffered?23:11
whitequark[cis]that looks to me like a normal sync memory macro, with one cycle latency23:11
ysionneaushouldn't yosys then generate a OUTREG DP16KD ?23:11
ysionneauor I'm missing something23:11
whitequark[cis]a BRAM on an FPGA always has registered output23:12
whitequark[cis]i'm not deeply familiar with ECP5 but i'm fairly sure that "NOREG" means 1 cycle of latency and "OUTREG" means 2 cycles23:12
ysionneauoh23:12
whitequark[cis]DP16KD will never be fully async, no FPGA BRAM macro is23:13
ysionneauok so maybe my understanding issue is what is an asyncfifo vs a syncfifo23:14
whitequark[cis]SyncFIFO has reader and writer in the same clock domain, AsyncFIFO has them in potentially different domains23:15
ysionneauok23:15
whitequark[cis]non-buffered SyncFIFO in Migen uses async memory primitives (LUTRAM or FFRAM)23:15
whitequark[cis]distrubuted RAM in Xilinx lingo23:16
*** philtor <[email protected]> has quit IRC (Remote host closed the connection)23:16
ysionneauwhich can be quite slow I guess when it's big23:16
whitequark[cis]everything else uses BRAM23:16
whitequark[cis]quite, yes23:16
ysionneauso in my case read and write ports are in the same clk domain23:16
ysionneauso I guess I am OK to use a SyncFIFO23:17
whitequark[cis]you want SyncFIFOBuffered23:17
ysionneauI've put buffered=True 23:17
whitequark[cis]there is almost never any reason to use the non buffered version23:17
whitequark[cis](in fact it has an incompatible interface...)23:17
ysionneaumaybe I'm reading this wrong but isn't SyncFIFOBuffered the same as SyncFifo(buffered=True) ?23:18
whitequark[cis]it is iirc (been many years since i touched migen but i don't think it changed much)23:19
ysionneauso you think I need to add yet another level of buffering after?23:20
ysionneauso that yosys put a OUTREG DPK16KD23:20
ysionneauDP16KD*23:21
whitequark[cis]adding a pipeline stage would be a solution to slow clk-to-q yeah23:21
whitequark[cis]whether it will be folded into DP16KD im not sure23:21
whitequark[cis]but it should improve timing either way23:21
ysionneausure it would cut my critical path23:21
ysionneauis there an easy way to put a "buffer" for all signals in between two pipeline elements in the stream.* api?23:23
ysionneausource/sink api I mean23:23
whitequark[cis]thats a litex thing, i never learned litex23:24
whitequark[cis]but it is like 3 lines of code23:24
ysionneaubecause I can't just do sync += [self.source.data.eq(fifo.source.data)] I should also buffer .valid23:24
ysionneauwell you're right if it's just data and valid ... it's 2 lines23:25
whitequark[cis]if(~valid | ready) dest.data.eq(src.data), dest.valid.eq(src.valid) else dest.valid.eq(0)23:26
whitequark[cis]all sync23:27
ysionneauI've moved self.packet_buffer_pipeline.source.connect(self.source) from a comb to a sync block, I think it's ok23:28
ysionneaulet's try23:28
whitequark[cis]no that will be totally broken23:30
whitequark[cis]migen Record.connect is fucked by design, you should never put it in sync23:30
ysionneauarg ok23:30
whitequark[cis]we redesigned it in amaranth to not be a complete disaster23:32
whitequark[cis]and a part of that is making it impossible to put it in sync23:32
ysionneauI didn't know about the Record.connect issue23:34
ysionneaugood to know!23:34
whitequark[cis]also if you reverse source/sink by accident it will. silently do nothing23:35
whitequark[cis]and you'll spend a hour looking at verilog trying to figure out wtf has happened23:36
ysionneauI had an issue where I put A.connect(B) instead of B.connect(A) just today and it didn't work well ^^23:36
ysionneauso I've put this https://paste.centos.org/view/241a11da23:36
tpbTitle: Untitled - Pastebin Service (at paste.centos.org)23:36
ysionneaunow the critical path is gone23:36
ysionneaubut I don't know if it's because it's really gone or if I fucked up and all my path is optimized out =)23:37
ysionneauhmhm it seems I fucked up, I only see 0s, everything has been optimized out23:38
whitequark[cis]that is not correct23:38
whitequark[cis]please look at the pseudocode i gave you23:38
whitequark[cis]the reason it's all optimized out is because you connected ready backwards23:39
ysionneauoutch23:39
ysionneauyeah now it works :)23:40
ysionneauthanks a lot!23:40
whitequark[cis]you do need a conditional there23:41
whitequark[cis]if you haven't put one there yey23:41
ysionneauwent from 109 MHz to 121 MHz now!23:41
whitequark[cis]s/yey/yet/23:41
ysionneauah23:41
whitequark[cis]you will have data loss23:41
ysionneauok I think I understand now23:42
whitequark[cis]i recommend reading https://amaranth-lang.org/docs/amaranth/latest/stdlib/stream.html which actually explains the stream invariants23:43
tpbTitle: Data streams — Amaranth language & toolchain 0.6.0.dev98 documentation (at amaranth-lang.org)23:43
ysionneauthanks for the link23:43
whitequark[cis]it's a little different from litex in syntax but it is the same concept23:43
ysionneauwhitequark[cis] | if(~valid | ready) < which valid and ready those are?23:44
ysionneauI must say I'm not connecting a source to a sink but a source to a source right now (module encapsulation)23:45
ysionneauI'm connecting the fifo.source from my module to the source of the module itself23:45
ysionneau(to make it clear)23:45
whitequark[cis]src.ready.eq(dest.ready); if(~dest.valid | dest.ready) dest.data.eq(src.data), dest.valid.eq(src.valid) else dest.valid.eq(0)23:45
whitequark[cis]it's more or less the same for source to source if you add a pipeline stage23:46
whitequark[cis]imagine "inverting" the module ports23:46
whitequark[cis]like, inverting the direction. now it becomes a sink23:46
ysionneauI see23:47
whitequark[cis]whitequark[cis]: here, dest.data becomes a sort of one element FIFO, with dest.valid being its level23:48
whitequark[cis]it's a useful pattern to remember for performance issues23:48
ysionneauhmm now something looks broken23:52
ysionneauI've put this https://paste.centos.org/view/5c1c14dc23:53
tpbTitle: Untitled - Pastebin Service (at paste.centos.org)23:53
ysionneaunow it's like nothing goes down the pipeline anymore, not even 0s23:54
whitequark[cis]last line with ready assignment must be in comb23:54
whitequark[cis]rest of it looks good23:54
ysionneauhmm still no luck23:55
ysionneaulet's simulate this23:55
whitequark[cis]oh hold on23:56
whitequark[cis]remove the else branch?23:56
ysionneauworks :)23:57
ysionneauthanks a lot, you're the fpga master o/23:57
ysionneauyosys still instanciates a NOREG DP16KD but anyway since there is a FF behind my critical path is still shorter23:59
ysionneaubut the ram could be even faster with OUTREG ^^23:59

Generated by irclog2html.py 2.17.2 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!