You are on page 1of 6

usb_serial: USB 1.1 / 2.

0 serial data transfer core


Version: Author: Language: License: &e%site: 2011-10-04 Joris van Rantwijk VHDL G L ! G"# Genera$ u%$ic License http://jorisvr.nl/usb/

usb_serial is a s'nthesi(a%$e VHDL core) i*+$e*enting seria$ ,ata trans-er over #./0 1o*%ine, with a #234-co*+ati%$e #./ transceiver chi+) this core acts as a #./ ,evice that trans-ers a %'te strea* in %oth ,irections over the %us0 2his +ackage is -ree so-tware5 'ou can re,istri%ute it an,6or *o,i-' it un,er the ter*s o- the G"# Genera$ u%$ic License as +u%$ishe, %' the 7ree .o-tware 7oun,ation5 either version 2 othe License) or 8at 'our o+tion9 an' $ater version0

Features
Ver' si*+$e a++$ication inter-ace in ter*s o- %'te-at-a-ti*e 747:s0 1o*+$ications invo$ving

the #./ +rotoco$ 8+ackets) en,+oints) ,escri+tors9 are han,$e, within the core0 2his is in -act the who$e +oint o- this +ackage0

#2341-co*+ati%$e transceiver inter-ace0 .u++orts #./ 101 an, #./ 2005 -u$$-s+ee, 812 3%it6s9 or high-s+ee, 84;0 3%it6s90 1o*+ati%$e with the stan,ar, 1o**unication Device 1$ass as a 1D1-A13 ,evice0 2his

i*+$ies that no special drivers are nee,e, on the co*+uter0 Linu<) &in,ows an, 3ac :. = a$$ have %ui$t-in su++ort -or 1D1-A13 ,evices0 87or &in,ows) a s+ecia$ .INF -i$e is nee,e,09

2este, on a =i$in< .+artan->0 &orks out-o--the-%o< on a 2ren( 2?014@ *icro*o,u$e0

Applications
Drop-in replacement for RS-232 communication with a PC.

3an' *o,ern 1s $ack a seria$ +ort0 #se usb_serial +$us an #234 chi+ on 'our 7 GA %oar, instea, o- an R.-2>2 #AR20 :n the 1) the ,evice wi$$ a++ear as a 22A or virtua$ 1:3 +ort0 "o nee, to *o,i-' 1 so-tware0 ?na%$e high s+ee, su++ort in usb_serial an, +u*+ >0 3/'te6s %etween 'our 7 GA an, 10 "ote that #./ trans-er rates are ver' ,e+en,ent on the 1 *ain%oar, s+ecs an, 1 # $oa,0 1usto* so-tware wi$$ %e nee,e, on the 15 virtua$ 1:3 +ort ,rivers are not *a,e -or such high ,ata rates0

Fast data exchange with a PC.

Operation
At +ower on an, a-ter a reset +u$se) the core attaches to the #./ %us0 4- high s+ee, su++ort is ena%$e,) the core tries to negotiate high s+ee, *o,e with the host0 :therwise) or in case high s+ee, negotiation -ai$s) the core wi$$ o+erate in -u$$ s+ee, *o,e0 4t res+on,s to stan,ar, ,evice reBuests -ro* the host to o%tain an a,,ress an, to +u%$ish its ,evice ,escri+tor0 2he ,evice ,escri+tor in,icates 1D1-A13 co*+ati%i$it'0 ro,uct 4D) Ven,or 4D an, ro,uct Version can %e con-igure, at co*+i$e ti*e0 4n a,,ition) o+tiona$ te<t strings *a' %e s+eci-ie, -or *anu-acturer na*e) +ro,uct na*e) an, seria$ nu*%er0
1 !"# $ S% 2.& !ransceiver "acrocell #nterface' a standard interface for age 16@ S% transceivers.

usb_serial: #./ 101 6 200 seria$ ,ata trans-er core

usb_s"rial
r#val r#$at r#r$% t#val t#$at t#r$%

usb_transact usb_pac&"t usb_control


UTMI

RX FIFO

PHY (UTMI)

U !

TX FIFO

desc ROM

usb_init

Figure () usb_serial core with external interface and su*-entities

2wo %u$k en,+oints are use, to trans-er ,ata5 one -or sen,ing an, the other -or receiving0 An a,,itiona$ interru+t en,+oint is i*+$e*ente, as reBuire, %' the 1D1-A13 s+eci-ication) %ut tra--ic on that en,+oint is ignore,0 Receive, ,ata are he$, in a 747: unti$ the' are acce+te, %' the a++$ication0 Likewise) the a++$ication +uts ,ata in a trans*it 747: unti$ the' can %e sent on the #./ %us0 2he a++$ication interacts with these 747:s one %'te at a ti*e0 2he core reBuires a @0 3H( s'ste* c$ock signa$) s'nchroni(e, to the #234 inter-ace signa$s0 2his c$ock signa$ is nor*a$$' generate, %' the #234 transceiver0 Note: An e<terna$ #./ 200 transceiver chi+ is reBuire, %etween the core an, the actua$ #./ $ines0 2his transceiver *ust %e co*+ati%$e with the #234 stan,ar, 8#./ 200 2ransceiver 3acroce$$ 4nter-ace90 4t *ust use an ;-%it ,ata inter-ace at @0 3H(0

Application interface
2he a++$ication receives ,ata %' rea,ing -ro* the R= 747:0 &hen the a++$ication is rea,' to rea, ,ata) it asserts the R=RDA signa$0 4n res+onse to R=RDA) i- the 747: is not e*+t') the core asserts R=VAL an, +uts a ,ata %'te on R=DA20 &henever %oth R=RDA an, R=VAL are high on a rising c$ock e,ge) the core assu*es that a %'te has %een consu*e, an, *oves on to the -o$$owing %'te0 4- the a++$ication ,oes not want to rea, *ore ,ata) it shou$, ,eassert R=RDA %e-ore the -o$$owing rising c$ock e,ge0 2he a++$ication sen,s ,ata %' +utting it in the 2= 747:0 As $ong as the 747: is not -u$$) the core asserts 2=RDA0 &hen the a++$ication is rea,' to sen, ,ata) it asserts 2=VAL an, +uts a ,ata %'te on 2=DA20 &henever %oth 2=RDA an, 2=VAL are high on a rising c$ock e,ge) the core acce+ts a %'te -ro* 2=DA2 an, +uts it in the 747:0 2he a++$ication *ust either +rovi,e the ne<t ,ata %'te on 2=DA2 or ,eassert 2=VAL %e-ore the -o$$owing rising c$ock e,ge0
1LC R= RDA R= VAL R= DA2 00 01 02

Figure 2) timing of R+ F#F, interface -application accepts 3 *.tes/

Confi uration options


!eneric V?"D:R4D R:D#124D V?R.4:"/1D V?"D:R.2R Function Ven,or 4D re+orte, in ,evice ,escri+tor0 ro,uct 4D re+orte, in ,evice ,escri+tor0 ro,uct version re+orte, in ,evice ,escri+tor0 :+tiona$ *anu-acurer na*e0 "#pe 1@ %its 1@ %its 1@ %its string $efault

none

usb_serial: #./ 101 6 200 seria$ ,ata trans-er core

age 26@

R:D#12.2R .?R4AL.2R H..# :R2 .?L7 :&?R?D R=/#7.4D?E/42.

2=/#7.4D?E/42.

:+tiona$ +ro,uct ,escri+tion0 :+tiona$ seria$ nu*%er string0 4nc$u,e su++ort -or high s+ee, *o,e0 ?na%$e se$--+owere, %it in ,escri+tor an, status wor,0 .i(e o- receive 747:) e<+resse, as the %ase-2 $ogarith* othe nu*%er o- %'tes0 3ust %e at $east 10 81024 %'tes9 ihigh s+ee, su++ort is ena%$e,0 .i(e o- trans*it 747:) e<+resse, as the %ase-2 $ogarith* othe nu*%er o- %'tes0

string string %oo$ean %oo$ean ' ( )*

none none -a$se -a$se 11

' ( )*

)+

Si nal descriptions
Si nal na%e 1LC R?.?2 #./R.2 "#pe 4n+ut 4n+ut :ut+ut Function .'ste* c$ock) @0 3H() acts on rising e,ge0 3ust %e s'nchroni(e, to the #234 inter-ace0 .'nchronous reset) active high0 1$ears %u--ers an, re-attaches to the #./ %us0 u$se, high when a reset signa$ is ,etecte, on the #./ %us0 Note: Do not wire this signa$ to R?.?25 this is not nee,e, an, wou$, $ock the core in reset0 High when the ,evice is in high s+ee, *o,e 8+ossi%$' sus+en,e,90 High whi$e the ,evice is sus+en,e,0 Note: 2his signa$ is not s'nchroni(e, to 1LC5 it *a' %e use, to co*%inatoria$$' ,rive the #234 .us+en,3 +in0 High when the ,evice is in Configured state0 High i- va$i, receive, ,ata is avai$a%$e on R=DA20 Receive, ,ata %'te0 High i- the a++$ication is rea,' to acce+t the ne<t %'te0 "u*%er o- %'tes current$' avai$a%$e in the receive 747:0 High i- the a++$ication is rea,' to sen, ,ata0 Data %'te to sen,) *ust %e va$i, i- 2=VAL is high0 High i- the core is rea,' to acce+t the ne<t %'te0 "u*%er o- -ree %'te +ositions in the trans*it 747:0 2e*+orari$' su++ress trans*issions on the #./ %us0 2his *a' %e use, to +re--i$$ the trans*it %u--er %e-ore starting trans*ission0 #234 Data:ut 8con-using signa$ na*e5 this is out+ut -ro* the transceiver an, in+ut to the core90 #234 Data4n 8con-using signa$ na*e5 this is out+ut -ro* the core an, in+ut to the transceiver90 #234 2rans*it Va$i,0 #234 2rans*it Data Rea,'0 #234 Receive Active0 #234 Receive Data Va$i,0 #234 Receive ?rror0 #234 Line .tate0 #234 :+erationa$ 3o,e0 #234 2ransceiver .e$ect: se$ects %etween H. an, 7. *o,e0 #234 2er*ination .e$ect: se$ects %etween H. an, 7. ter*ination0 #234 Reset0

H4GH. ??D .#. ?"D

:ut+ut :ut+ut

:"L4"? R=VAL R=DA2 R=RDA R=L?" 2=VAL 2=DA2 2=RDA 2=R::3 2=1:RC HAEDA2A4" HAEDA2A:#2 HAE2=VAL4D HAE2=R?ADA HAER=A124V? HAER=VAL4D HAER=?RR:R HAEL4"?.2A2? HAE: 3:D? HAE=1VR.?L?12 HAE2?R3.?L?12 HAER?.?2

:ut+ut :ut+ut :ut ; %its 4n+ut :ut unsigne, 4n+ut 4n ; %its :ut+ut :ut unsigne, 4n+ut 4n ; %its :ut ; %its :ut+ut 4n+ut 4n+ut 4n+ut 4n+ut 4n 2 %its :ut 2 %its :ut+ut :ut+ut :ut+ut

&ost soft'are
Data trans-er is ,one using two %u$k en,+oints0 Data sent %' the host to the ,evice through en,+oint 1E:#2 en,s u+ in the receive 747:0 Data Bueue, in the trans*it 747: are sent to the host through en,+oint 1E4"0

usb_serial: #./ 101 6 200 seria$ ,ata trans-er core

age >6@

2he ,evice is accessi%$e -ro* so-tware running on the host0 2his t'+ica$$' reBuires interaction with the #./ ,river in the o+erating s'ste*0 How this is ,one ,e+en,s on the o+erating s'ste* use,0 0inux) Linu< 20@ has a %ui$t-in c$ass ,river -or 1D1-A13 ,evices0 2his ,river) ca$$e, c$c(ac,) works with usb_serial0 4- the ,river is insta$$e,) it shou$, auto*atica$$' ,etect the ,evice when it is +$ugge, in0 A ,evice no,e /$"v/tt%-.Mn wi$$ %e create, 8$ook at the kerne$ *essages -or the e<act ,evice na*e90 2his ,evice no,e can %e accesse, %' a++$ication so-tware as i- it were a seria$ +ort0 A$ternative$') the generic #./ seria$ ,river -or Linu<) ca$$e, usbs"rial) can %e use,0 2he ,eviceFs ro,uct 4D an, Ven,or 4D *ust %e +asse, as +ara*eters when $oa,ing the ,river0 2he ,evice wi$$ %e accessi%$e as /$"v/tt%U !n0 /oth ,rivers have +ro%$e*s with -$ow contro$: i- the ,evice sen,s *ore ,ata than can %e +rocesse, %' the host so-tware) so*e ,ata *a' %e $ost0 2his is es+ecia$$' re$evant to high s+ee, *o,e0 At $ow ,ata rates 8a -ew k/'te6s9 the +ro%$e* wi$$ not occur0 A$ternative$') the host a++$ication can ,irect$' access the #./ ,evice through libusb 20 2his a++roach +rovi,es %etter +er-or*ance than the seria$ ,rivers) es+ecia$$' in high s+ee, *o,e0 "ac ,S +) :n 3ac :. =) the ,evice is auto*atica$$' recogni(e, as a #./ *o,e*0 4t a++ears as ,evice no,e /$"v/tt%.usb,o$",XXXX0 2his ,evice can %e use, %' a++$ication so-tware as i- it were a seria$ +ort0 7$ow contro$ ,oes not work +ro+er$'0 1indows) 2he ,evice works with usbs"r.s%s 8+rovi,e, with &in,ows9 an, wi$$ show u+ as an e<tra ./Mn: +ort0 A custo* .INF -i$e is nee,e, to te$$ &in,ows that it *ust use this ,river0 Have a $ook at the sa*+$e -i$e 0p1as"r.in0 > to see how it can %e ,one0 "ote that ro,uct 4D an, Ven,or 4D in the -i$e *ust *atch those o- the ,evice0 He$+-u$ instructions can a$so %e -oun, in 2ocu,"ntation/usb/1a$1"t_s"rial.t#t in the Linu< kerne$ source tree0 2he &in,ows 2000 version o- usbs"r.s%s is notorious$' %roken an, shou$, not %e use,0 &in,ows = see*s to ,o %etter0 7$ow contro$ has not %een teste, an, +ro%a%$' ,oes not work correct$'0

Source code structure


2he *ain VHDL entit' o- the core is usb_s"rial0 4t contains -our su%-entities) as we$$ as 747:s) ,escri+tor R:3) %u--er *anage*ent $ogic an, g$ue $ogic0 2he +ackage consists o- the -o$$owing VHDL -i$es: usb_s"rial.vh$l usb_init.vh$l usb_pac&"t.vh$l usb_transact.vh$l usb_control.vh$l usb_p&1.vh$l usbt"st.vh$l 3ain entit'0 4nitia$i(ation) han,shake an, reset ,etection0 acket han,$ing0 2ransaction han,$ing0 De-au$t contro$ en,+oint0 ackage with entit' ,ec$arations0 2o+-$eve$ entit' consisting o- us%Eseria$ an, a si*+$e test a++$ication0

S#nt(esis
2he VHDL co,e in this +ackage is rea,i$' s'nthesi(a%$e -or the =i$in< .+artan-> -a*i$' o- 7 GA ,evices0 2he co,e shou$, in +rinci+$e %e +orta%$e to other 7 GA +$at-or*s0 A trick' issue cou$, %e the in-erence o- /$ock RA30 2he receive 747:) trans*it 747: an, ,escri+tor R:3 are co,e,
* http://www.libusb.org/ > contri*uted *. 2ans 23*ner usb_serial: #./ 101 6 200 seria$ ,ata trans-er core age 46@

in VHDL in such a wa' that the =i$in< s'nthesis too$ auto*atica$$' in-ers /$ock RA3 +ri*itives0 .o*e tweaking *a' %e nee,e, to get this to work with ,i--erent s'nthesis so-tware0 A 3ake-i$e is su++$ie, which invokes the =i$in< too$s to s'nthesi(e a test ,esign -or the 2ren( 2?014@ =1>.1000 *icro*o,u$e 40 &ith so*e changes) it shou$, a$so work -or ,i--erent =i$in< targets0 A constraint -i$e wi$$ %e nee,e, to *a+ 46: signa$s to s+eci-ic +ins an, to s+eci-' ti*ing constraints0 2he -i$e t"+)34.uc0 contains constraints that are suita%$e -or the 2ren( 2?014@ *o,u$e0 2he use o- 4:/ -$i+--$o+s is reco**en,e,0 &hen the ,esign is s'nthesi(e, as a =i$in< 4.? roject) 4:/ -$i+--$o+s *ust %e ena%$e, e<+$icit$' 8"ap properties -G Pac4 registers into #,%s -G #nputs and outputs90

)esource usa e
4n,ication o- resource reBuire*ents) %ase, on s'nthesis o- usb_serial as the to+ $eve$ ,esign -or a =i$in< =1>.10000 8=i$in< &e%+ack H01i9
1on-iguration "r o- s$ice -$i+ -$o+s "r o- 4-in+ut L#2s "r o- occu+ie, s$ices "r o- /$ock RA3s 2ota$ eBuiva$ent gate count 7u$$-s+ee, on$') 12; %'te 747:s 2>I ;41 4HJ 8@K9 > 204)I2H High-s+ee, su++ort) 2k R= 6 1k 2= 747:0 2;I 10@2 @10 8HK9 > 20@)IIJ

"estin
2he to+-$eve$ entit' usbt"st.vh$l *a' %e use, to test usb_serial0 4t i*+$e*ents a state *achine) res+on,ing to co**an,s receive, -ro* the host0 Aou can use *inico* 8on Linu<9 or h'+erter*ina$ 8on &in,ows9 to connect to the ,evice an, +$a' with it0 2he 'thon scri+t t"st$"v.p% thorough$' tests various %u--ering an, -$ow contro$ scenarios0 2he 1 +rogra* p"r0t"st.c uses libusb to test the %an,wi,th o- ,ata trans-ers0 7or e<a*+$e) with a 2?014@ *o,u$e connecte, to a Linu< host) 'ou cou$, ,o this: 10 Run ,a&" to %ui$, usbt"st.bit 8or use the +reco*+i$e, usbt"st_*++5)++4_hs.bit90 20 Down$oa, the .bit -i$e to the 7 GA *o,u$e0 >0 Run lsusb to check that the ,evice is recogni(e,0 A$so $ook at the kerne$ *essages to check that 1D1-A13 su++ort is recogni(e,0 4t shou$, sa' so*ething a%out a new tt%-.M+ ,evice0 40 #se ,inico, to connect to /$"v/tt%-.M+0 2'+e LH"lloL an, +ress ?nter0 2he ,evice shou$, answer Lo$$eHL0 I0 Run p%thon t"st$"v.p% /$"v/tt%-.M+ to start the torture test0 2he test takes a%out 20 *inutes to co*+$ete0 @0 Run p"r0t"st ($ 0b5a:0b5a 8as root9 to start the +er-or*ance test0

*erfor%ance
2este, un,er Linu< 20@0>1 with $i%us%-100) using as'nchronous reBuests0
Bus speed -u$$ s+ee, high s+ee, +easured ,N band'idt( 1)0;;)11; %'tes6s 4>)H2H)H04 %'tes6s +easured OU" band'idt( 1)0;;)0H> %'tes6s >2)@>I)212 %'tes6s

3 http://www.trenz-electronic.de/ usb_serial: #./ 101 6 200 seria$ ,ata trans-er core age I6@

-no'n li%itations
2he 2?.2E3:D? -eature 8*an,ator' -or high s+ee, ,evices9 is not i*+$e*ente,0 2his

shou$, not a--ect nor*a$ o+eration o- the ,evice) %ut the ,evice wou$, -ai$ #./ con-or*ance tests0
2he ,e-au$t contro$ +i+e ,oes not strict$' veri-' reBuests -ro* the host0 As a resu$t) inva$i,

reBuests -ro* the host *a' a++ear to succee, when the' shou$, have returne, an error co,e0 2his shou$, not %e an issue with a correct$' working host contro$$er) %ut it wou$, +ro%a%$' cause the ,evice to -ai$ #./ con-or*ance tests0
4n its con-iguration ,escri+tor) the core c$ai*s to su++ort A2-st'$e co**an,s0 2his is not

true) %ut it is nee,e, to get the ,evice recogni(e, %' the Linu< 1D1-A13 ,river0 4n rea$it') the core ignores the *an,ator' 1D1 reBuests .?2E?"1A .#LA2?DE1:33A"D an, G?2E?"1A .#LA2?DER?. :".?0
4n certain situations) the ,evice *a' sen, *ore %'tes than e<+ecte, %' the host0 2his is

-$agge, as a *a**le error %' the host0 2his *a' occur) -or e<a*+$e) when the host su%*its an 4" reBuest which is not a *u$ti+$e o- the *a<i*u* +acket si(e0 2o avoi, this) a$wa's su%*it 4" reBuests with the trans-er si(e set to a *u$ti+$e o- the *a<i*u* +acket si(e0 "ote that this is not a %ug in the ,evice core) rather an inconvenience in the #./ so-tware stack0
De+en,ing on 7 GA +$at-or* an, %oar, ,esign) a %us +owere, ,evice *a' not %e a%$e to

res+on, to the initia$ host reBuests a-ter +$ugging in0 7or e<a*+$e) a =i$in< 7 GA t'+ica$$' nee,s *ore than 100 *s to initia$i(e a-ter +ower on0 /' this ti*e the host wi$$ have trie, to co**unicate with the ,evice0 3ost o+erating s'ste*s wi$$ success-u$$' retr' the initia$i(ation +roce,ure0
2he a++$ication inter-ace o- the core *ust %e s'nchroni(e, to the @0 3H( #234 c$ock0 2his

is inconvenient when the core is e*%e,,e, in a $arger s'ste* with its own *aster c$ock0 2o overco*e this +ro%$e*) se+arate c$ock ,o*ains shou$, %e create, insi,e the core to ,ecou+$e the a++$ication c$ock -ro* the #234 c$ock0 the +i+e when it receives an une<+ecte, (ero-$ength +acket0 2his ha++ens i- the ,evice sen,s an e<act *u$ti+$e o- the *a<i*u* +acket si(e whi$e the host atte*+te, to rea, e<act$' that sa*e a*ount o- ,ata0

2here are severa$ %ugs in the &in,ows 2000 version o- usbs"r.s%s0 4t is known to -ree(e

usb_serial: #./ 101 6 200 seria$ ,ata trans-er core

age @6@

You might also like