Wednesday, 2019-03-06

*** tpb has joined #tomu00:00
*** Farscrap has joined #tomu01:09
xobstnt: the sw/ dir is a mix, yeah.01:16
xobsI think the reason hosts are so agressive is that you're never supposed to NAK them, you're always supposed to have a dedicated buffer for a SETUP packet on EP0.01:17
xobsStill, I think the transmission issue comes from the fact that state machiens in Migen are asynchronous, and I'm doing the equivalent of `assign` in there.  That's probably a no-no.01:18
xobsI'll make some fixes and verify them this afternoon, when I'm around the oscilloscope again.01:18
xobsOkay, I think the problem may be that the Migen simulator treats FSMs as clocked, but the generator makes them async.03:02
*** futarisIRCcloud has joined #tomu03:27
*** Farscrap has quit IRC04:04
xobsI'm developing such an appreciation for Gray code, though.  I totally get why it's a thing.  Makes combinatorics work out better during state changes.07:37
tntxobs: what do you mean migen fsm are asynchronous ?07:43
tntxobs: and wrt to EP0 SETUP, yeah, you can't NAK, but the state diagram still shows the if you don't have space you can ignore the packet. I'm having trouble having the softcore submit another buffer in time in my stack :/07:46
xobstnt: if you generate a FSM using the FSM() primitive, then everything inside of it goes in a `always @(*) begin` block.  State transitions (using `NextState()`) are synchronous, and `NextValue()` is used to synchronously set registers on the next cycle, but any `value.eq(x)` commands are asynchronous and operate outside of a clock domain.07:46
tntxobs: Ah yeah, I see. But that assignement is only done if the state is the one that was declared in right ?  Kind of wondering what happens for other states where you don't assign that signal to anything then ...07:58
xobstnt: migen assigns them the default value of "0".07:59
tntok makes sense. at least it doesn't create a latch :)08:00
xobsExcept when you're transitioning between states you can get glitches.  For example, I was seeing a very brief (12 ns?) glitch on one line when enabling USB transmission.08:00
xobsIn one state it was "0", and in the next state it was also "0", but in the transition it was a "1".08:00
tntAh yeah of course. Although, I'm surprised you'd not using the IOB registers ?08:01
tnt12 ns is a bit more than 'brief' :/08:02
xobsI am using the IOB registers.08:03
tnton when you said "on one line", you weren't talking about the DP/DN ?08:03
tntjust some signal your exported on the scope ?08:04
xobsI rerouted the DP/DN lines to pads that I can probe more easily.  This was on the "DP" line.08:05 pinstate doesn't have IOB regs enabled AFAICT, unless I'm not looking at the right code.08:05
xobsAh, you're right.  No latch.08:09
tntWhy did you go for the Vexriscv vs the picorv32 btw ?08:29
xobsThere are a few reasons.  A big one is that vex has a debug plugin, which means we'll get openocd support (once I get USB working, of course).08:31
xobsIt's also easier to scale Vex, and the latest version has a single-cycle multiplier using the UP5k DSP blocks.08:32
tntI'm trying to understand the core structure, but all I see is a direct fifo conneciton to the cpu ? basically cpu -> 8:1 serdes -> pad ?09:08
xobstnt: the current setup in Git is using the "unififo" connection, which is indeed just a shift register.  It's definitely not fast enough, but it's simple enough that I can hook up a scope and a logic analyzer to figure out what it's doing.09:09
tntAlso, I don't understand how the RX 48M -> 12M works ? I mean, the local 12M isn't synchronized and can be 'slower' than the usb 12M, so they'll drift over time and at some point you might need to receive 2 bits or 0 bits from the 48M -> 12M ?09:09
xobsNow I'm working on the epfifo implementation.  I see some waveform issues that may be contributing to the problem.09:09
xobsThe local 12M is derived from 48M by dividing it by 4.  It didn't used to be that way, and in fact 12M used to come from the HFOSC.  But that was causing some clock-domain crossing issues, so I made 12M slaved off of 48M and removed the CDC registers.09:10
tpbTitle: foboot/ at master · xobs/foboot · GitHub (at
tntI don't meant he 12M/48M clock inside the FPGA. I mean the bits coming from USB. The clock recovery RX bit strobe can be 3/4/5 clock cycles appart depending on the incoming timing of the usb data.09:12
xobsThat's a good point.  That shoudl be taken care of by `line_state_phase`, which tries to center it up on the pulse, +/- one cycle:
tpbTitle: valentyusb/ at master · xobs/valentyusb · GitHub (at
tntYes, the sampling in the 48 MHz domain is going to be good. But then the result of that sampling seems to be "just passeD" in the 12M domain with no fifo, no sync, ... and that 'line_state_phase' can/will drift over time vs the local 12M clock and so when crossing the bit you captured at 48M in the local 12M domain, it may be missed or it may be sampled twice.09:17
*** futarisIRCcloud has quit IRC09:17
*** awe00 has joined #tomu10:16
xobstnt: I'll have to see how often that's a problem in practice. Right now I'm seeing lots of corruption, and I don't think that's the issue. Mostly because I was seeing the same behavior when the cdc registers were in place.10:20
xobsSomething isn't working right. Simulation isn't matching up to reality. The raw FIFO receives fine, but the automated endpoint system isn't responding correctly.10:22
*** futarisIRCcloud has joined #tomu10:54
*** futarisIRCcloud has quit IRC13:54
*** awe00 has quit IRC16:14
*** awe00 has joined #tomu16:21
*** awe00 has quit IRC20:26
*** awe00 has joined #tomu22:42
*** AmosSam has left #tomu23:12
*** AmosSam has joined #tomu23:12
*** Farscrap has joined #tomu23:33
*** awe00 has quit IRC23:36
*** xkapastel has joined #tomu23:44

Generated by 2.13.1 by Marius Gedminas - find it at!