ã·ãªãŒãºã®ä»¥åã®èšäº
ãããããä»æ¥ãç§ã¯äŒçµ±ãæã¡ç ŽããReddã³ã³ãã¬ãã¯ã¹ã§ã¯ãªããéåžžã®ã¬ã€ã¢ãŠãã§ãããžã§ã¯ãããããã°ããŸãããŸããå§åçå€æ°ã®èªè ã¯ãã®ãããªè€åæœèšã«ã¢ã¯ã»ã¹ã§ããªãããAli Expressã«ã¯ã¢ã¯ã»ã¹ã§ããããšãç¥ã£ãŠãããããããã2ã€ç®ã¯ãUSBããã€ã¹ãšãã¹ãã®ãã¢ãæ¥ç¶ãããåºããã§ã³ã¹ã§å²ãã ããæ°ãã«çºçããå¹²æžã«å¯ŸåŠãããããã®ãé¢åã ããã§ãã
2017幎ã«ãç§ã¯ãããã¯ãŒã¯äžã§æ¢æã®ãœãªã¥ãŒã·ã§ã³ãæ¢ããŠããŠããã®ãããªçŽ æŽããããã®ãã€ãŸããã®ç¥å ãèŠã€ããŸãããä»ã§ã¯ããã¹ãŠãå°çšã®ããŒãäžã«ãããŸãããã©ãã«ãã¶ã€ãªã³ã¯ã¹ã®ã·ã³ãã«ãªãã¬ããããŒãã®åçããããããã«WaveShareã®ããŒããæ¥ç¶ãããŠããŸããïŒè©³ããã¯ãã¡ããã芧ãã ããïŒããã®ããŒãã®åçãèŠãŠã¿ãŸãããã
åæã«2ã€ã®USBã³ãã¯ã¿ããããŸããããã«ãå³ã¯ãããã䞊ååãããŠããããšã瀺ããŠããŸãã USBããã€ã¹ãã¿ã€ãAãœã±ããã«æ¥ç¶ããã±ãŒãã«ãããUSBã³ãã¯ã¿ã«æ¥ç¶ããŸããããããã¹ãã«æ¥ç¶ããŸãããããŠãOpenVizslaãããžã§ã¯ãã®èª¬æã¯ããã®æ¹æ³ãæ©èœãããšè¿°ã¹ãŠããŸããå¯äžã®æ®å¿µãªããšã¯ããããžã§ã¯ãèªäœãèªã¿ã«ããããšã§ããããªãã¯ãããgithubã§åãããšãã§ããŸãããããŒãžã«ç€ºãããŠããã¢ã«ãŠã³ããžã®ãªã³ã¯ãäžããŸããããšã«ãã誰ãããããèŠã€ããŸãããããã¯MiGenã®ããã«ããçŽãããŸãããã2017幎ã«èŠã€ããããŒãžã§ã³ïŒhttpïŒ// githubã com / ultraembedded / coresãã¯ãªãŒã³ãªVerilogäžã«ãããusb_snifferãã©ã³ãããããŸããããã§ã¯ããã¹ãŠãçŽæ¥ULPIãçµç±ããã®ã§ã¯ãªããULPIããUTMIãžã®ã³ã³ããŒã¿ãŒãçµç±ããŸãïŒãããã®åå£ãªåèªã¯ãé«éUSB 2.0ãã£ãã«ãããã»ããµãšFPGAãç解ã§ãããã¹ãšäžèŽãããç©çã¬ãã«ã®è¶ å°ååè·¯ã§ãïŒããã®åŸããã®UTMIã§ã®ã¿æ©èœããŸããããã§ãã¹ãŠãã©ã®ããã«æ©èœããããç§ã¯ç解ããŠããŸããããã®ããããã¹ãŠãå°é£ã§ã¯ãªãæãããããšãããã«ãããã®ã§ãäžããéçºããããšãéžæããŸããã
ã©ã®ããŒããŠã§ã¢ã§äœæ¥ã§ããŸãã
ã¿ã€ãã«ããã®è³ªåãžã®çãã¯ç°¡åã§ããFPGAãšå€éšã¡ã¢ãªãæã£ãŠãã人ãªã誰ã§ãã§ãããã¡ããããã®ã·ãªãŒãºã§ã¯ã¢ã«ãã©FPGAïŒIntelïŒã®ã¿ãåãäžããŸãããã ããULPIãã€ã¯ãåè·¯ïŒãã®ãã³ã«ãã«ããïŒããã®ããŒã¿ã¯60 MHzã§å®è¡ãããããšã«æ³šæããŠãã ãããé·ãã¯ã€ã€ãŒã¯ããã§ã¯åãå ¥ããããŸããã CLKã©ã€ã³ãGCKã°ã«ãŒãããã®FPGAå ¥åã«æ¥ç¶ããããšãéèŠã§ããããããªããšããã¹ãŠãæ©èœããŠå€±æããŸãããããå±éºã«ããããªãæ¹ãè¯ããããã°ã©ã ã§è»¢éããããšã¯ãå§ãããŸãããç§ã¯è©Šããããã¹ãŠã¯GCKã°ã«ãŒãããèãžã®ã¯ã€ã€ãŒã§çµãããŸããã
ä»æ¥ã®å®éšã®ããã«ãç§ã®ãªã¯ãšã¹ãã§ãå人ãç§ã«ãã®ãããªã·ã¹ãã ãã¯ãã ä»ãããŸããïŒ
FPGAãšSDRAMãåãããã€ã¯ãã¢ãžã¥ãŒã«ïŒFPGA AC608ãšãããã¬ãŒãºã§ALI Expressã§ãããæ¢ããŠãã ããïŒïŒããã³WaveShareã®åãULPIããŒããããã¯ãã¢ãžã¥ãŒã«ã売ãæã®1人ããã®åçã§ã©ã®ããã«èŠãããã§ããã±ãŒã¹ããããžãå€ãã®ãé¢åãªã®ã§ã
ã¡ãªã¿ã«ãç§ã®ã±ãŒã¹ã®åçã®ããã«ãéæ°åã¯éåžžã«èå³æ·±ããã®ã§ããã¢ãã«ã§ããœãªããã¬ã€ã€ãŒãæç»ããã¹ã©ã€ãµãŒã§å¡ãã€ã¶ãïŒããšãã°ã40ïŒ ïŒãèšå®ããŠãäžãšäžãããŒãã®ãœãªããã¬ã€ã€ãŒãäœæããå¿ èŠãããããšãäŒããŸãããã®çµæã3Dããªã³ã¿ãŒèªäœããã®ææ°ãåŒã蟌ã¿ãŸãããšãŠãå¿«é©ã
äžè¬ã«ãããŒããŠã§ã¢ãèŠã€ããæ¹æ³ã¯æ確ã§ãã次ã«ãã¢ãã©ã€ã¶ãŒã®èšèšãéå§ããŸããããããç§ãã¡ã¯éå»2ã€ã®èšäºïŒããã§ã¯ããŒããŠã§ã¢ã§äœæ¥ããããã§ã¯ããã«ã¢ã¯ã»ã¹ã§ããŸãïŒã§ã¢ãã©ã€ã¶ãŒèªäœãäœæããŸããã次ã«ãULPIãã€ã¯ãåè·¯ããã®ããŒã¿ããã£ããããåé¡æåã®ããããèšèšããŸãã
é ãã§ããããš
ããžãã¯ã¢ãã©ã€ã¶ãŒã®å Žåããã¹ãŠãç°¡åã§ã·ã³ãã«ã§ãããããŒã¿ããããŸãããããã«æ¥ç¶ããŠæ¢±å ãéå§ããAVALON_STãã¹ã«éä¿¡ããŸãããããã§ã¯ãã¹ãŠãããè€éã§ãã ULPIä»æ§ã¯ããã«ãããŸããéå±ãªããã¹ãã®93æã®ã·ãŒããå人çã«ãããã¯ç§ãèœèã«é§ãç«ãŠãŸãã WaveShareããŒãã«ã€ã³ã¹ããŒã«ãããŠããUSB3300ãããã®èª¬æã¯ãå°ãåçŽã«èŠããŸããããããå ¥æã§ããŸãããã®2017幎12æ以æ¥ããŸã åæ°ãæºããŠããŸãããããã€ç ã®ã¢ãããŒããæããã®ã§ãæã ããã¥ã¡ã³ããèªãã§ããã«ãããéããŸããã
説æãããULPIã«ã¯äžé£ã®ã¬ãžã¹ã¿ããããäœæ¥ãéå§ããåã«å ¥åããå¿ èŠãããããšãæããã§ããããã¯äž»ã«ãã«ã¢ããæµæãšçµç«¯æµæã«ãããã®ã§ãããã€ã³ãã説æããåçã¯ããã«ãããŸãïŒ
圹å²ïŒãã¹ããŸãã¯ããã€ã¹ïŒãšéžæããé床ã«å¿ããŠãç°ãªãæµæãå«ããå¿ èŠããããŸããããããç§ãã¡ã¯ãã¹ãã§ãããã€ã¹ã§ããããŸããïŒãã¹äžã®ã¡ã€ã³ããã€ã¹ã«å¹²æžããªãããã«ããã¹ãŠã®æµæãåæããå¿ èŠããããŸããããã¯ãã¬ãžã¹ã¿ã«æžã蟌ãããšã«ãã£ãŠè¡ãããŸãã
ããŠããããŠã¹ããŒããäœåé床ãéžæããå¿ èŠããããŸãããããè¡ãã«ã¯ãã¬ãžã¹ã¿ã«æžã蟌ãå¿ èŠããããŸãã
ãã¹ãŠãæ§æããããããŒã¿ã®ãã§ãããéå§ã§ããŸããããããULPIã®ååã§ã¯ãæåãLPãã¯ãããŒãã³ããæå³ããŸãããããŠãèã®æ°ãéåžžã«æžã£ãããããã®ãããªççãªãããã³ã«ãçºçããŸããããããã³ã«ã詳ããèŠãŠã¿ãŸãããã
ULPIãããã³ã«
ULPIãããã³ã«ã¯ãäžè¬ã®äººã«ãšã£ãŠã¯å°ãå€ãã£ãŠããŸããããããããã¥ã¡ã³ãã«åº§ã£ãŠçæ³ãããšãå€ããå°ãªããç解ã§ããæ©èœãçŸãå§ããŸããéçºè ã䜿çšããé£çµ¡å ã®æ°ãæ¬åœã«æžããããã«ããããåªåãããããšãæããã«ãªãã€ã€ãããŸãã
ããã§ã¯å®å šãªããã¥ã¡ã³ããåå ¥åããããšã¯ããŸãããèªåãæãéèŠãªããšã«å¶éããŸãããããããã®äžã§æãéèŠãªã®ã¯ä¿¡å·ã®æ¹åã§ãããããæãåºãããšã¯äžå¯èœ
ã§ããæ¯ååçãèŠãã®ãè¯ãã§ããULPILINKã¯FPGAã§ãã
ããŒã¿åä¿¡ã®ã¿ã€ãã³ã°å³
éæ¢æã«ã¯ãIDLEã³ãã³ãã«å¯Ÿå¿ããå®æ°0x00ãããŒã¿ãã¹ã«çºè¡ããå¿ èŠããããŸããããŒã¿ãUSBãã¹ããã®ãã®ã§ããå Žåã亀æãããã³ã«ã¯æ¬¡ã®ããã«ãªããŸã
ããµã€ã¯ã«ã¯ãDIRä¿¡å·ã1ã«é£ã¶ããšããå§ãŸããŸãããŸããã·ã¹ãã ãããŒã¿ãã¹ã®æ¹åãåãæ¿ããæéãããããã«ã1ã¯ããã¯ãµã€ã¯ã«ãããŸããããã«-çµæžã®å¥è·¡ãå§ãŸããŸãã NXTä¿¡å·ã®ååã確èªããŸããïŒåŒç€Ÿããéä¿¡ãããå Žåã¯ã次ãæå³ããŸãããããŠãããã¯å®å šã«ç°ãªãä¿¡å·ã§ãã DIRã1ã®å ŽåãNXT C / DãåŒã³åºããŸããäœã¬ãã«-ããŒã ããããŸããé«-ããŒã¿ã
ã€ãŸããåžžã«é«DIRã§9ãããïŒDATAãã¹ãšNXTä¿¡å·ïŒãä¿®æ£ãããïŒæåã®ã¯ããã¯ããœãããŠã§ã¢ã§ãã£ã«ã¿ãªã³ã°ããïŒããŸãã¯DIRãé¢éžããåŸã2çªç®ã®ã¯ããã¯ããéå§ããå¿ èŠããããŸããDIRã©ã€ã³ããŒãã«ãªããšãããŒã¿ãã¹ãåãæ¿ããŠæžã蟌ã¿ãIDLEã³ãã³ãã®ãããŒããã£ã¹ããåéããŸãã
ããŒã¿åä¿¡ã§-ããã¯æããã§ãã次ã«ãã¬ãžã¹ã¿ã䜿çšããŠäœæ¥ãåæããŸãã
ULPIã¬ãžã¹ã¿ãžã®æžã蟌ã¿ã®ã¿ã€ãã³ã°å³
ã¬ãžã¹ã¿ãŒã«æžã蟌ãã«ã¯ã次ã®äžæçãªå®¶ã䜿çšãããŸãïŒç§ã¯GOST 2.105ã«åãã£ãŠããããã«æããŠããã®ã§ãæå³çã«å°éçšèªã«åãæ¿ããŸããããããŠããã¯éå±ãªã®ã§ãããããé¢ããŸãïŒïŒ
ãŸããç¶æ DIR = 0ãåŸ ã€å¿ èŠããããŸããã¯ããã¯T0ã§ãããŒã¿ãã¹ã«TXD CMDå®æ°ãèšå®ããå¿ èŠããããŸããã©ãããæå³ã§ããïŒããã«ã¯ããããŸããããããã¥ã¡ã³ããå°ãæãäžãããšãç®çã®å€ãããã«ããããšãããããŸãã
ã€ãŸããäžäœããŒã¿ãããã¯å€ "10"ïŒãã€ãå šäœã®å Žåããã¹ã¯ã¯0x80ïŒã«èšå®ãããäžäœãããã¯ã¬ãžã¹ã¿çªå·ã§ãã
次ã«ãNXTä¿¡å·ãåºãã®ãåŸ ã€å¿ èŠããããŸãããã®ä¿¡å·ã«ããããã€ã¯ãåè·¯ã¯ãããç§ãã¡ã®å£°ãèããããšã確èªããŸããäžã®å³ã§ã¯ãã¯ããã¯T2ã§ãããåŸ ã£ãŠã次ã®ã¯ããã¯ïŒT3ïŒã§ããŒã¿ãèšå®ããŸãããã¯ããã¯T4ã§ãULPIã¯ããŒã¿ãåä¿¡ããNXTãåé€ããŸãããããŠãSTPã§ãŠããã亀æãµã€ã¯ã«ã®çµäºãããŒã¯ããŸãããŸããT5ã§ã¯ãããŒã¿ã¯å éšã¬ãžã¹ã¿ã«ã©ãããããŸããããã»ã¹ã¯çµäºããŸãããããã¯ãå°æ°ã®çµè«ã«å¯ŸããèŠè¿ãã§ãããã ããããŒã¿ã®æžã蟌ã¿ã¯èµ·åæã«ã®ã¿è¡ãå¿ èŠããããããåœç¶ãéçºã«èŠåŽããããšã«ãªããŸãããããã¯ç¹ã«äœæ¥ã«åœ±é¿ãäžããããã§ã¯ãããŸããã
ULPIã¬ãžã¹ã¿ããã®èªã¿åãã®ã¿ã€ãã³ã°å³
æ£çŽãªãšãããå®éã®ã¿ã¹ã¯ã§ã¯ãã¬ãžã¹ã¿ãŒã®èªã¿åãã¯ããã»ã©éèŠã§ã¯ãããŸãããããããèŠãŠã¿ãŸããããèªã¿åãã¯ãå°ãªããšãã¬ã³ãŒããæ£ããå®è£ ãããŠããããšã確èªããã®ã«åœ¹ç«ã¡ãŸãã
ç§ãã¡ã®åã«ã¯ãåã®2ã€ã®ä»®èšäœå® ããã®ççºçãªæ··åç©ãããããšãããããŸããã¬ãžã¹ã¿ãžã®æžã蟌ã¿ãšåãããã«ã¢ãã¬ã¹ãèšå®ããããŒã¿ã®èªã¿åãèŠåã«åŸã£ãŠããŒã¿ãååŸããŸãã
äžæïŒããããã¹ãŠã圢äœããªãŒãããã³ã®èšèšãå§ããŸãããã
é ã®æ§é å³
äžèšã®èª¬æãããããããã«ããããã¯2ã€ã®ãã¹ã«åæã«æ¥ç¶ããå¿ èŠããããŸããã¬ãžã¹ã¿ã«ã¢ã¯ã»ã¹ããããã®AVALON_MMãšãRAMã«æ ŒçŽããããŒã¿ãçºè¡ããããã®AVALON_STã§ããé ã®äžã®äž»ãªãã®ã¯è³ã§ãããããã£ãŠãããã¯ã以åã«æ€èšããã¿ã€ã ãã€ã¢ã°ã©ã ãçæããã¹ããŒããã·ã³ã§ããå¿ èŠããããŸãã
ããŒã¿ãåä¿¡ããæ©èœããéçºãå§ããŸããããããã§ã¯ãULPIãã¹ããã®ãããŒã«åœ±é¿ãäžããããšã¯ã§ããªãããšã«æ³šæããŠãã ãããããããã®ããŒã¿ã¯ããããè¡ãå§ããããè¡ããŸãã AVALON_STãã¹ã®æºåãã§ããŠãããã©ããã¯é¢ä¿ãããŸããããããã£ãŠããã¹ãå©çšã§ããªãããšãåã«ç¡èŠããŸããå®éã®åæè£ çœ®ã§ã¯ãæºåãã§ããŠããªãããŒã¿åºåã®å Žåã«ã¢ã©ãŒã 衚瀺ãè¿œå ããããšãå¯èœã§ããèšäºã®ãã¬ãŒã ã¯ãŒã¯å ã§ã¯ãã¹ãŠãåçŽã§ããã¹ããªã®ã§ãå°æ¥ã®ããã«ãããèŠããŠãããŸãããããŸããããžãã¯ã¢ãã©ã€ã¶ãŒã®ããã«ãã¹ã®å¯çšæ§ã確ä¿ããããã«ãå€éšFIFOãããã¯ããããŸããå šäœãšããŠãããŒã¿ã¹ããªãŒã ãåä¿¡ããããã®ãªãŒãããã³ã®é·ç§»ã°ã©ãã¯æ¬¡ã®ãšããã§ãã
DIRãé¢éž-åãåãå§ããŸããã wait1ã§1ã¯ããã¯ãåæ¢ããDIRã1ã®éã«ãããåãå ¥ããŸãããŒãã«èœã¡ãŸãã-ã¯ããã¯ã®åŸã§ïŒãããå¿ èŠã§ãããšããäºå®ã§ã¯ãããŸããããä»ã®ãšããã¯wait2ç¶æ ãèšå®ããŸãïŒã¢ã€ãã«ã«æ»ããŸããã
ãããŸã§ã®ãšããããã¹ãŠãç°¡åã§ãã D0_D7ã©ã€ã³ã ãã§ãªããNXTã©ã€ã³ãAVALON_STãã¹ã«æ¥ç¶ããå¿ èŠãããããšãå¿ããªãã§ãã ãããããã«ãããçŸåšéä¿¡ãããŠãããã®ïŒã³ãã³ããŸãã¯ããŒã¿ïŒã決å®ãããŸãã
ã¬ãžã¹ã¿æžã蟌ã¿ãµã€ã¯ã«ã¯ãäºæž¬ã§ããªãå®è¡æéãæã€å¯èœæ§ããããŸãã AVALON_MMãã¹ã®èŠ³ç¹ããã¯ãããã¯ããŸãè¯ããããŸããããããã£ãŠãå°ãããªãããŒã«ããŸãããããã¡ã¬ãžã¹ã¿ãäœæããŸããããããŒã¿ãããã«å ¥ããšãAVALON_MMãã¹ãããã«è§£æŸãããŸããéçºäžã®ãªãŒãããã³ã®èŠ³ç¹ããã¯ãhave_regå ¥åä¿¡å·ïŒã¬ãžã¹ã¿å ã®ããŒã¿ãåä¿¡ãããéä¿¡ããå¿ èŠããããŸãïŒãšreg_servedåºåä¿¡å·ïŒã¬ãžã¹ã¿çºè¡ããã»ã¹ãå®äºããããšãæå³ããŸãïŒã衚瀺ãããŸãããªãŒãããã³ã®é·ç§»ã°ã©ãã®ã¬ãžã¹ã¿ã«æžã蟌ãããžãã¯ãè¿œå ããŸãã
DIR = 1ã®æ¡ä»¶ãèµ€ã§åŒ·èª¿è¡šç€ºããŠãåªå 床ãæãé«ãããšãæ確ã«ããŸããã次ã«ããªãŒãããã³ã®æ°ãããã©ã³ãã§DIRä¿¡å·ã®ãŒãå€ã®æåŸ å€ãé€å€ããããšãã§ããŸããç°ãªãå€ã§ãã©ã³ãã«ãã°ã€ã³ããããšã¯ãåã«äžå¯èœã§ãã SET_CMDwç¶æ ã¯ãçŽç²ã«ä»®æ³ã§ããå¯èœæ§ãæãé«ããããéè²ã§ãããããã¯å®è¡ããã¢ã¯ã·ã§ã³ã§ãïŒèª°ãããŒã¿ãã¹äžã§ã移è¡äžã«å¯Ÿå¿ããå®æ°ãèšå®ããããšãæ°ã«ããŸããïŒãšããããSTPwç¶æ ã§ã¯ãreg_servedä¿¡å·ã1ã¯ããã¯ãµã€ã¯ã«ã®éã³ããã³ã°ããŠãAVALON_MMãã¹ã®BSYä¿¡å·ãã¯ãªã¢ããæ°ããæžã蟌ã¿ãµã€ã¯ã«ãå¯èœã«ããããšãã§ããŸãã
ããŠãULPIã¬ãžã¹ã¿ãèªã¿åãããã®åå²ãè¿œå ããããšã¯æ®ããŸããããã§ã¯ãæ£å察ã§ãããã¹ãµãŒãã¹ãã·ã³ã¯èŠæ±ãéä¿¡ããå¿çãåŸ ã¡ãŸããããŒã¿ãåä¿¡ããããšã圌ã¯ãããåŠçã§ããŸãããããŠããã¯ãã¹ã®äžæåæ¢ãããŒãªã³ã°ã§åäœããŸãããããã¯ãã§ã«ãã®ãã·ã³ã®åé¡ã§ããä»æ¥ãç§ã¯èª¿æ»ã«åãçµãããšã«ããŸãããããŒã¿ã®èŠæ±-BSYãç»å ŽããŸãããBSYãæ¶ããæ¹æ³-èªã¿åãããŒã¿ãåä¿¡ã§ããŸããå šäœãšããŠãã°ã©ãã¯æ¬¡ã®åœ¢åŒãåããŸãã
ãããããéçºã®éçšã§ãããã€ãã®èª¿æŽãè¡ãããŸãããããã§ã¯ããã®ã°ã©ãã䜿çšããŸããçµå±ã®ãšãããããã¯ã¬ããŒãã§ã¯ãªããéçºæ¹æ³è«ã«é¢ãã説æã§ãããŸãããã®ææ³ã§ã¯ãæåã«é·ç§»ã°ã©ããæç»ããå¿ èŠããããŸãã次ã«ããã®å³ã«åŸã£ãŠããããã¢ããã®è©³çŽ°ã«åãããŠèª¿æŽãããããžãã¯ãå®è¡ããŸãã
AVALON_MMåŽããã®ãªãŒãããã³å®è£ ã®æ©èœ
AVALON_MMãã¹ã䜿çšããå Žåã2ã€ã®æ¹æ³ããããŸãã1ã€ç®ã¯ããã¹ã¢ã¯ã»ã¹é 延ãäœæããããšã§ãããã®ã¡ã«ããºã ã«ã€ããŠã¯ä»¥åã®èšäºã®1ã€ã§èª¬æããŸããããåé¡ãããããšãèŠåããŸããã2çªç®ã®æ¹æ³ã¯ã¯ã©ã·ãã¯ã§ããã¹ããŒã¿ã¹ã¬ãžã¹ã¿ãå ¥åããŸãããã©ã³ã¶ã¯ã·ã§ã³ã®éå§æã«ãå®äºæã«BSYä¿¡å·ãèšå®ããŸã-ãªã»ããããããŠããã¹ãŠã®è²¬ä»»ããã¹ãã¹ã¿ãŒããžãã¯ïŒNios IIããã»ããµãŸãã¯JTAGããªããžïŒã«å²ãåœãŠãŸããåãªãã·ã§ã³ã«ã¯ãç¬èªã®é·æãšçæããããŸãããã¹é 延ã䜿çšããããªã¢ã³ãã¯æ¢ã«å®è¡ããŠããã®ã§ãå€æŽã®ããã«ãã¹ããŒã¿ã¹ã¬ãžã¹ã¿ã䜿çšããŠä»æ¥ãã¹ãŠãå®è¡ããŸãããã
ã¡ã€ã³ãã·ã³ãèšèš
æåã«æ³šç®ãããã®ã¯ãç§ã®ãæ°ã«å ¥ãã®RSããªã¬ãŒã§ãã2å°ã®ãã·ã³ããããŸãã1ã€ç®ã¯AVALON_MMãã¹ã«å¯Ÿå¿ãã2ã€ç®ã¯ULPIã€ã³ã¿ãŒãã§ãŒã¹ã«å¯Ÿå¿ããŸãããããã®éã®æ¥ç¶ãããã€ãã®ãã©ã°ãééããããšãããããŸãããåãã©ã°ã«æžã蟌ãããšãã§ããããã»ã¹ã¯1ã€ã ãã§ããåãªãŒãããã³ã¯ãç¬èªã®ããã»ã¹ã«ãã£ãŠå®è£ ãããŸããã©ããã£ãŠïŒãã°ããã®éãRSããªã¬ãŒã®è¿œå ãéå§ããŸããã2ããããªã®ã§ã2ã€ã®RSããªããããããã§çæããå¿ èŠããããŸããã¯ããã©ããïŒ
//
always_ff @(posedge ulpi_clk)
begin
//
if (reg_served)
write_busy <= 0;
else if (have_reg)
write_busy <= 1;
//
if (read_finished)
read_busy <= 0;
else if (reg_request)
read_busy <= 1;
end
1ã€ã®ããã»ã¹ã¯reg_servedãåŒã³åºãã2çªç®ã®ããã»ã¹ã¯have_regãåŒã³åºããŸãããããŠãç¬èªã®ããã»ã¹ã®RSããªããããããã¯ããããã«åºã¥ããŠwrite_busyä¿¡å·ãçæããŸããåæ§ã«ãread_busyã¯read_finishedãšreg_requestãã圢æãããŸããå¥ã®æ¹æ³ã§è¡ãããšãã§ããŸãããã¯ãªãšã€ãã£ããã¹ã®ãã®æ®µéã§ã¯ããã®æ¹æ³ã奜ãã§ãã
ããã¯ãBSYãã©ã°ãèšå®ãããæ¹æ³ã§ããé»è²ã¯æžã蟌ã¿ããã»ã¹çšãéè²ã¯èªã¿åãããã»ã¹çšã§ããVerilogovããã»ã¹ã«ã¯ãéåžžã«èå³æ·±ãæ©èœã1ã€ãããŸãããã®äžã§ãå€ãå²ãåœãŠãããšãã§ããã®ã¯1åã§ã¯ãªããè€æ°åã§ãããããã£ãŠãä¿¡å·ã1ã¯ããã¯ãµã€ã¯ã«ã®éé¢éžããããå Žåã¯ãããã»ã¹ã®æåã«ãããç¡å¹ã«ãïŒäž¡æ¹ã®ä¿¡å·ãããã§ç¡å¹ã«ãªãããšãããããŸãïŒã1ã¯ããã¯ãµã€ã¯ã«äžã«å®è¡ãããæ¡ä»¶ã«ãã£ãŠ1ã«èšå®ããŸããæ¡ä»¶ãå ¥åãããšãããã©ã«ããäžæžããããŸãããã以å€ã®å Žåã¯ãã¹ãŠæ©èœããŸãããããã£ãŠãããŒã¿ããŒããžã®æžã蟌ã¿ã¯ã1ã¯ããã¯ãµã€ã¯ã«ã®have_regä¿¡å·ã®ãã€ã¯ãªããéå§ããå¶åŸ¡ããŒããžã®ããã0ã®æžã蟌ã¿ã¯ãreg_requestä¿¡å·ã®ãã€ã¯ãªããéå§ããŸãã
åãããã¹ãã
// AVALON_MM
always_ff @(posedge ulpi_clk)
begin
// ,
//
have_reg <= 0;
reg_request <= 0;
if (write == 1)
begin
case (address)
0 : addr_to_ulpi <= writedata [5:0];
//
1 : begin
data_to_ulpi <= writedata [7:0];
have_reg <= 1;
end
2 : begin
//
reg_request <= writedata[0];
force_reset = writedata [31];
end
3: begin end
endcase
end
end
äžèšã§èŠãããã«ã察å¿ããRSããªããããããã1ã«èšå®ããã«ã¯ã1ã¯ããã¯ãµã€ã¯ã«ã§ååã§ãããããŠããã®ç¬éãããèšå®ãããBSYä¿¡å·ãã¹ããŒã¿ã¹ã¬ãžã¹ã¿ããèªã¿åããå§ããŸãã
åãããã¹ãã
// AVALON_MM
always_comb
begin
case (address)
// ( )
0 : readdata <= {26'b0, addr_to_ulpi};
//
1 : readdata <= {23'b0, data_from_ulpi};
// 2 - , -
//
3 : readdata <= {30'b0, (reg_request | read_busy), (have_reg | write_busy)};
default: readdata <= 0;
endcase
end
å®éãåœç¶ã®ããšãªãããAVALON_MMãã¹ã§æ©èœããããã»ã¹ã«ç²ŸéããŠããŸãã
ulpi_dataãã¹ã§ã®äœæ¥ã®ååã«ã€ããŠãæãåºãããŠãã ããããã®ãã¹ã¯åæ¹åã§ãããããã£ãŠãæšæºã®ææ³ã䜿çšããŠäœæ¥ããå¿ èŠããããŸããããã¯ã察å¿ããããŒãã®å®£èšæ¹æ³ã§ãã
inout [7:0] ulpi_data,
ãã®ãã¹ããèªã¿åãããšã¯ã§ããŸãããçŽæ¥æžã蟌ãããšã¯ã§ããŸããã代ããã«ãã¬ã³ãŒãã®ã³ããŒãäœæããŸãã
logic [7:0] ulpi_d = 0;
ãããŠããã®ã³ããŒã次ã®ãã«ããã¬ã¯ãµãä»ããŠã¡ã€ã³ãã¹ã«æ¥ç¶ããŸãã
// inout-
assign ulpi_data = (ulpi_dir == 0) ? ulpi_d : 8'hzz;
ã¡ã€ã³ãã·ã³ã®ããžãã¯ã«ã€ããŠã¯ãVerilogã³ãŒãå ã§ã§ããã ãã³ã¡ã³ãããããã«ããŸãããé·ç§»ã°ã©ãã®éçºäžã«äºæ³ããããã«ãå®éã®å®è£ ã§ã¯ãããžãã¯ãå€å°å€æŽãããŠããŸããããã€ãã®å·ã¯æšãŠãããŸãããããã§ããã°ã©ããšãœãŒã¹ããã¹ããæ¯èŒããŠãããã§è¡ãããŠãããã¹ãŠã®ããšãç解ããŠããã ããã°å¹žãã§ãããããã£ãŠããã®ãã·ã³ã«ã€ããŠã¯è§ŠããŸãããå®çšçãªå®éšã®çµæã«åºã¥ããŠãå€æŽåã®æç¹ã§ã®ã¢ãžã¥ãŒã«ã®å šæãåç §çšã«åç §ããããšããå§ãããŸãã
ã¢ãžã¥ãŒã«ã®å
šæã
module ULPIhead
(
input reset,
output clk66,
// AVALON_MM
input [1:0] address,
input write,
input [31:0] writedata,
input read,
output logic [31:0] readdata = 0,
// AVALON_ST
input logic source_ready,
output logic source_valid = 0,
output logic [15:0] source_data = 0,
// ULPI
inout [7:0] ulpi_data,
output logic ulpi_stp = 0,
input ulpi_nxt,
input ulpi_dir,
input ulpi_clk,
output ulpi_rst
);
logic have_reg = 0;
logic reg_served = 0;
logic reg_request = 0;
logic read_finished = 0;
logic [5:0] addr_to_ulpi;
logic [7:0] data_to_ulpi;
logic [7:0] data_from_ulpi;
logic write_busy = 0;
logic read_busy = 0;
logic [7:0] ulpi_d = 0;
logic force_reset = 0;
//
always_ff @(posedge ulpi_clk)
begin
//
if (reg_served)
write_busy <= 0;
else if (have_reg)
write_busy <= 1;
//
if (read_finished)
read_busy <= 0;
else if (reg_request)
read_busy <= 1;
end
// AVALON_MM
always_comb
begin
case (address)
// ( )
0 : readdata <= {26'b0, addr_to_ulpi};
//
1 : readdata <= {23'b0, data_from_ulpi};
// 2 - , -
//
3 : readdata <= {30'b0, (reg_request | read_busy), (have_reg | write_busy)};
default: readdata <= 0;
endcase
end
// AVALON_MM
always_ff @(posedge ulpi_clk)
begin
// ,
//
have_reg <= 0;
reg_request <= 0;
if (write == 1)
begin
case (address)
0 : addr_to_ulpi <= writedata [5:0];
//
1 : begin
data_to_ulpi <= writedata [7:0];
have_reg <= 1;
end
2 : begin
//
reg_request <= writedata[0];
force_reset = writedata [31];
end
3: begin end
endcase
end
end
//
enum {idle,
wait1,wr_st,
wait_nxt_w,hold_w,
wait_nxt_r,wait_dir1,latch,wait_dir0
} state = idle;
always_ff @ (posedge ulpi_clk)
begin
if (reset)
begin
state <= idle;
end else
begin
//
source_valid <= 0;
reg_served <= 0;
ulpi_stp <= 0;
read_finished <= 0;
case (state)
idle: begin
if (ulpi_dir)
state <= wait1;
else if (have_reg)
begin
// ,
// ,
//
ulpi_d [7:6] <= 2'b10;
ulpi_d [5:0] <= addr_to_ulpi;
state <= wait_nxt_w;
end
else if (reg_request)
begin
// -
ulpi_d [7:6] <= 2'b11;
ulpi_d [5:0] <= addr_to_ulpi;
state <= wait_nxt_r;
end
end
// TURN_AROUND
wait1 : begin
state <= wr_st;
// ,
source_valid <= 1;
source_data <= {7'h0,!ulpi_nxt,ulpi_data};
end
// DIR - AVALON_ST
wr_st : begin
if (ulpi_dir)
begin
// ,
source_valid <= 1;
source_data <= {7'h0,!ulpi_nxt,ulpi_data};
end else
// wait2,
// , - .
state <= idle;
end
wait_nxt_w : begin
if (ulpi_nxt)
begin
ulpi_d <= data_to_ulpi;
state <= hold_w;
end
end
hold_w: begin
// , ULPI
// . NXT
// ...
if (ulpi_nxt) begin
// , AVALON_MM
reg_served <= 1;
ulpi_d <= 0; // idle
ulpi_stp <= 1; // STP
state <= idle; // - idle
end
end
// STPw ...
// ...
// . , NXT
// ,
wait_nxt_r : begin
if (ulpi_nxt)
begin
ulpi_d <= 0; //
state <= wait_dir1;
end
end
// ,
wait_dir1: begin
if (ulpi_dir)
state <= latch;
end
//
// -
latch: begin
data_from_ulpi <= ulpi_data;
state <= wait_dir0;
end
// ,
wait_dir0: begin
if (!ulpi_dir)
begin
state <= idle;
read_finished <= 1;
end
end
default: begin
state <= idle;
end
endcase
end
end
// inout-
assign ulpi_data = (ulpi_dir == 0) ? ulpi_d : 8'hzz;
// reset ,
assign ulpi_rst = reset | force_reset;
assign clk66 = ulpi_clk;
endmodule
ããã°ã©ããŒã¬ã€ã
ULPIã¬ãžã¹ã¿ã¢ãã¬ã¹ããŒãïŒ+0ïŒ
äœæ¥ãè¡ããããã¹ã®ULPIã¬ãžã¹ã¿ã®ã¢ãã¬ã¹ã¯ããªãã»ãã+0ã§ããŒãã«é 眮ããå¿ èŠããããŸã
ULPIã¬ãžã¹ã¿ããŒã¿ããŒãïŒ+4ïŒ
ãã®ããŒãã«æžã蟌ãå ŽåïŒã¬ãžã¹ã¿ã¢ãã¬ã¹ã®ããŒãã«ã¢ãã¬ã¹ãèšå®ãããULPIã¬ãžã¹ã¿ãžã®æžã蟌ã¿ããã»ã¹ãèªåçã«éå§ãããŸããåã®æžã蟌ã¿ã®ããã»ã¹ãå®äºãããŸã§ããã®ããŒããžã®æžã蟌ã¿ã¯çŠæ¢ãããŠããŸãã
èªã¿åãæïŒãã®ããŒãã¯ãULPIã¬ãžã¹ã¿ããæåŸã«èªã¿åãããå€ãè¿ããŸãã
ULPIå¶åŸ¡ããŒãïŒ+8ïŒ
èªã¿åãå€ã¯åžžã«ãŒãã§ããæžã蟌ã¿ã®ãããå²ãåœãŠã¯æ¬¡ã®ãšããã§ãã
ããã0-åäžã®å€ãæžã蟌ããšããULPIã¬ãžã¹ã¿ã®èªã¿åãããã»ã¹ãéå§ããŸããULPIã¬ãžã¹ã¿ã®ã¢ãã¬ã¹ã¯ãULPIã¬ãžã¹ã¿ã®ã¢ãã¬ã¹ããŒãã«èšå®ãããŠããŸãã
ããã31-1ãæžã蟌ããšããRESETä¿¡å·ãULPIãããã«éä¿¡ããã
æ®ãã®ãããã¯äºçŽãããŠããŸãã
ã¹ããŒã¿ã¹ããŒãïŒ+ 0x0CïŒ
èªã¿åãå°çšã
ããã0-WRITE_BUSYã1ã®å ŽåãULPIã¬ãžã¹ã¿ãžã®æžã蟌ã¿ããã»ã¹ãé²è¡äžã§ãã
ããã1-READ_BUSYã1ã®å ŽåãULPIã¬ãžã¹ã¿ããã®èªã¿åãããã»ã¹ãé²è¡äžã§ãã
æ®ãã®ãããã¯äºçŽãããŠããŸãã
çµè«
USBã¢ãã©ã€ã¶ãŒãããã®ç©ççãªç·šææ¹æ³ã«ã€ããŠç¥ããULPIãã€ã¯ãåè·¯ãæäœããããã®åºæ¬çãªãªãŒãããã³ãèšèšãããã®ãããã«SystemVerilogãã©ããã¢ãžã¥ãŒã«ã®ãã©ãããå®è£ ããŸããã次ã®èšäºã§ã¯ãã¢ããªã³ã°ããã»ã¹ã確èªãããã®ã¢ãžã¥ãŒã«ãã·ãã¥ã¬ãŒãããŠãããå®éã«ã³ãŒããå®æãããçµæã«åºã¥ããŠãå®éã®å®éšãè¡ããŸããã€ãŸããæåŸãŸã§å°ãªããšã4ã€ã®èšäºããããŸãã