Closed TheAnimatrix closed 2 weeks ago
// high when dpl has atleast one pair of 1's - 110,011,111 (101-X) - low when 000,001,100 //but why is it high for 110 and low for 001, we are transitioning to the opposite state wire dpv = &dpl[3:2] | &dpl[2:1] | dpl[3] & dpl[1];
it's really unclear to me how exactly this works,
After having a better look of the code, dpv looks like an "average" over the shifted in values. however, this only really makes sense when you look at in tandem with the condition its used in. Separating the signal from the condition is needless to say bad code, atleast if not indicated through comments or some other means.
// high when dpl has atleast one pair of 1's - 110,011,111 (101-X) - low when 000,001,100 //but why is it high for 110 and low for 001, we are transitioning to the opposite state wire dpv = &dpl[3:2] | &dpl[2:1] | dpl[3] & dpl[1];
it's really unclear to me how exactly this works,
This is actually a simple voting algorithm. If out of 2 votes for 1, the result is 1. 5 samples are taken for a single usb bit time, and the code uses the middle 3 bits to deduce the value. As for the diffrential issue, this is a simple digital implementation, there is no point to do dp - dn here.
After reading the source of usb_fs_bitlevel
It is unclear to me why you don't try to merge the P & N lines together for data identification. Instead you only seem to use dpv and last_dp.
sig = p-n, would actually take advantage of differential characteristics whereas you completely ignore the negative part of the differential for data packets.
Also the naming scheme is really unclear. What is dpv ? dpl ? what is L and V ?