徐振華 郭濤 郭利強(qiáng)
摘 要: 針對(duì)智能家居系統(tǒng)諸多監(jiān)測(cè)模塊無(wú)法同時(shí)完成多節(jié)點(diǎn)間高速通信的問(wèn)題,設(shè)計(jì)一種基于M?LVDS接口和千兆以太網(wǎng)接口的數(shù)據(jù)轉(zhuǎn)化模塊。該模塊結(jié)合M?LVDS接口多節(jié)點(diǎn)通信和千兆以太網(wǎng)高速數(shù)據(jù)傳輸?shù)葍?yōu)點(diǎn),以FPGA作為核心控制器,基于UDP協(xié)議搭建控制邏輯,實(shí)現(xiàn)M?LVDS與千兆以太網(wǎng)之間的數(shù)據(jù)交互。測(cè)試結(jié)果表明,數(shù)據(jù)轉(zhuǎn)換結(jié)果準(zhǔn)確、可靠,實(shí)現(xiàn)了智能家居控制平臺(tái)與多節(jié)點(diǎn)設(shè)備的高速通信。
關(guān)鍵詞: 數(shù)據(jù)轉(zhuǎn)化; 多節(jié)點(diǎn); 高速通信; FPGA; M?LVDS; 千兆以太網(wǎng)
中圖分類號(hào): TN919?34; TP336 文獻(xiàn)標(biāo)識(shí)碼: A 文章編號(hào): 1004?373X(2018)19?0023?04
Abstract: Since the numerous monitoring modules of smart home system can′t complete the high?speed communication among multiple nodes at the same time, a data conversion module based on M?LVDS interface and gigabit Ethernet interface was designed. The module combines the advantages of multi?node communication of M?LVDS interface and high?speed data transmission of gigabit Ethernet, takes FPGA as its core controller, and establishes the control logic based on UDP protocol to realize the data interaction between M?LVDS and gigabit Ethernet. The testing results show that the data conversion results are accurate and reliable, and the converter realizes the high?speed communication between the smart home control platform and multi?node device.
Keywords: data conversion; multi?node; high?speed communication; FPGA; M?LVDS; gigabit Ethernet
智能家居系統(tǒng)中對(duì)家居環(huán)境監(jiān)測(cè)的傳感器和調(diào)節(jié)單元分布式排列在不同區(qū)域,需要同時(shí)與多設(shè)備通信。由于家居環(huán)境大量視頻、聲音等監(jiān)測(cè)對(duì)象的加入,對(duì)數(shù)據(jù)傳輸?shù)母邔?shí)時(shí)性和高傳輸速率以及低功耗提出了更高的要求。為了將分布在多處的傳感器采集的大量數(shù)據(jù)統(tǒng)一分析和管理,需要實(shí)現(xiàn)多節(jié)點(diǎn)的高速互連通信。M?LVDS支持多節(jié)點(diǎn)互連的拓?fù)浣Y(jié)構(gòu),可提供高的數(shù)據(jù)傳輸速率和更低的功耗,實(shí)現(xiàn)數(shù)據(jù)的可靠高速傳輸[1]。FPGA作為核心控制器,采用太網(wǎng)物理層芯片實(shí)現(xiàn)千兆以太網(wǎng)與計(jì)算機(jī)通信。本文基于實(shí)際需求設(shè)計(jì)一種千兆以太網(wǎng)和M?LVDS接口轉(zhuǎn)換模塊,以實(shí)現(xiàn)智能家居各監(jiān)測(cè)模塊大量實(shí)時(shí)數(shù)據(jù)與系統(tǒng)平臺(tái)之間可靠、高速傳輸。
M?LVDS和千兆以太網(wǎng)接口數(shù)據(jù)轉(zhuǎn)換模塊結(jié)構(gòu)如圖1所示。主要由以太網(wǎng)通信模塊、FPGA主控模塊、M?LVDS通信模塊組成。
系統(tǒng)上電后,F(xiàn)PGA對(duì)M88E1111進(jìn)行初始化,完成相關(guān)寄存器的配置,啟動(dòng)發(fā)送數(shù)據(jù)包進(jìn)程與接收數(shù)據(jù)包進(jìn)程。數(shù)據(jù)上傳過(guò)程為多節(jié)點(diǎn)間數(shù)據(jù)經(jīng)M?LVDS接口傳輸?shù)組?LVDS通信模塊,數(shù)據(jù)完成鏈路層數(shù)據(jù)解碼后通過(guò)DDR3緩存控制器寫(xiě)入DDR3緩存。以太網(wǎng)數(shù)據(jù)傳輸模塊讀取DDR3緩存數(shù)據(jù),數(shù)據(jù)按照UDP協(xié)議在千兆以太網(wǎng)通信模塊中打包后通過(guò)GMII接口傳輸給物理層,控制平臺(tái)經(jīng)RJ45網(wǎng)口讀取數(shù)據(jù)[2]。數(shù)據(jù)下發(fā)過(guò)程與上傳過(guò)程類似,通信數(shù)據(jù)通過(guò)以太網(wǎng)接口下發(fā)至轉(zhuǎn)換器,F(xiàn)PGA解析后將其寫(xiě)入緩存中,M?LVDS通信模塊讀出FIFO緩存的數(shù)據(jù),將數(shù)據(jù)編碼后經(jīng)過(guò)M?LVDS通信模塊發(fā)送到M?LVDS總線上,總線上的設(shè)備將根據(jù)協(xié)議獲取對(duì)應(yīng)的數(shù)據(jù)。
2.1 M?LVDS通信電路設(shè)計(jì)
M?LVDS通信模塊采用SN65MLVD203全雙工收發(fā)器芯片,采用雙線差分多節(jié)點(diǎn)傳輸結(jié)構(gòu),可實(shí)現(xiàn)250 Mb/s高速通信。以時(shí)鐘源方式實(shí)現(xiàn)傳輸數(shù)據(jù)位同步,同時(shí)發(fā)送時(shí)鐘和數(shù)據(jù)。接收時(shí)按照同步時(shí)鐘接收,實(shí)現(xiàn)數(shù)據(jù)串行傳輸。M?LVDS收發(fā)器可實(shí)現(xiàn)線或功能及各節(jié)點(diǎn)間總線的共享機(jī)制與總線的非破壞性仲裁機(jī)制[3]。
通過(guò)長(zhǎng)電纜連接的節(jié)點(diǎn)之間,常因節(jié)點(diǎn)間的地線電位差導(dǎo)致節(jié)點(diǎn)地環(huán)路電流,形成差模干擾。為確保數(shù)據(jù)傳輸?shù)目煽啃?,基于TPS76333設(shè)計(jì)電源隔離電路,防止不必要的電流損害影響電子元件的工作,實(shí)現(xiàn)信號(hào)和電源的完整隔離。選用ISO7842為M?LVDS驅(qū)動(dòng)器的邏輯輸入和接收器的邏輯輸出提供數(shù)字隔離,提升數(shù)據(jù)傳輸?shù)耐暾浴?/p>
2.2 千兆以太網(wǎng)通信電路設(shè)計(jì)
千兆以太網(wǎng)物理層收發(fā)器芯片M88E1111提供自主協(xié)商、傳輸介質(zhì)自動(dòng)檢測(cè)以及網(wǎng)絡(luò)收發(fā)線對(duì)的自動(dòng)檢測(cè)和交叉,可以在五類非屏蔽雙絞線上進(jìn)行數(shù)據(jù)收發(fā)。只需外接25 MHz晶振,通過(guò)內(nèi)部鎖相環(huán)便能提供GTXCLK,RXCLK和芯片內(nèi)核的工作時(shí)鐘[4]。FPGA通過(guò)MDI管理接口配置芯片內(nèi)部寄存器,該接口為雙路信號(hào)接口分別配置時(shí)鐘信號(hào)和數(shù)據(jù)信號(hào)。通過(guò)管理接口,上層能監(jiān)視和控制物理層,實(shí)現(xiàn)不同功能,滿足多種場(chǎng)合需求。M88E1111與RJ45接口通過(guò)MDI 差分?jǐn)?shù)據(jù)線形式連接。
程序控制主要完成系統(tǒng)初始化、千兆以太網(wǎng)收發(fā)控制、UDP協(xié)議數(shù)據(jù)打包解包、上位機(jī)命令解析、DDR3緩存控制、M?LVDS通信協(xié)議等。系統(tǒng)上電初始化,根據(jù)智能家居平臺(tái)命令接收或發(fā)送數(shù)據(jù)。
3.1 千兆以太網(wǎng)控制流程
千兆以太網(wǎng)采用UDP協(xié)議實(shí)現(xiàn)與智能家居平臺(tái)通信[5]。系統(tǒng)初始化完成后通過(guò)MDIO/ MDC管理接口配置物理層寄存器,將M88E1111傳輸模式配置為1000BASE?T。接收進(jìn)程從DDR3緩存中接收數(shù)據(jù),待發(fā)送的數(shù)據(jù)包內(nèi)容以UDP IP報(bào)文的格式打包。接收DDR3緩存打包成的UDP數(shù)據(jù)包,最終以GMII格式通過(guò)接收端傳輸?shù)組88E1111,傳輸速度可達(dá)[6]1 000 Mb/s。發(fā)送進(jìn)程狀態(tài)機(jī)如圖2所示。
發(fā)送數(shù)據(jù)時(shí),狀態(tài)機(jī)初始化為IDLE,發(fā)送進(jìn)程計(jì)時(shí)器timer==32′h00400000時(shí),進(jìn)入狀態(tài)START生成IP包頭和包頭校驗(yàn)和,當(dāng)check_buffer_end==1時(shí),開(kāi)始發(fā)送8個(gè)IP前導(dǎo)碼:7個(gè)55和1個(gè)d5,隨后發(fā)送MAC目的地址和源地址、IP包頭,準(zhǔn)備發(fā)送UDP數(shù)據(jù)包,當(dāng)發(fā)送結(jié)束后,進(jìn)入SEND_CRC[7]。CRC校驗(yàn)正確crc_vaild==1則成功發(fā)送,狀態(tài)機(jī)返回初始狀態(tài)IDLE,完成一次發(fā)送。
數(shù)據(jù)接收與數(shù)據(jù)發(fā)送過(guò)程類似,接收到來(lái)自M88E1111的數(shù)據(jù)包時(shí),將GMII格式數(shù)據(jù)包先進(jìn)行前導(dǎo)碼、幀開(kāi)始符、目的MAC 地址、源MAC地址以及IP包頭檢測(cè),之后開(kāi)始接收有效數(shù)據(jù)和數(shù)據(jù)校驗(yàn)。接收數(shù)據(jù)成功后,將有效數(shù)據(jù)發(fā)送到FIFO緩存單元中。
3.2 M?LVDS通信控制流程
M?LVDS總線只規(guī)定了物理層的電氣特征,并未規(guī)定通信的高層協(xié)議[7]。按照IEEE 802.3標(biāo)準(zhǔn),利用FPGA實(shí)現(xiàn)M?LVDS通信協(xié)議數(shù)據(jù)在鏈路層與物理信令層之間的數(shù)據(jù)傳輸。通信控制將從FIFO緩存中讀取的數(shù)據(jù)按照通信協(xié)議在總線管理器中完成數(shù)據(jù)封裝拆裝、總線仲裁、差錯(cuò)控制、報(bào)文濾波以及時(shí)序控制等功能,在PLS中完成數(shù)據(jù)的編碼、解碼、位同步以及幀同步[8]。
執(zhí)行通信流程時(shí),有效數(shù)據(jù)在M?LVDS中根據(jù)協(xié)議重新打包和解包。數(shù)據(jù)包中標(biāo)示符表示對(duì)底層各節(jié)點(diǎn)的操作,分為數(shù)據(jù)上傳和命令下發(fā)。數(shù)據(jù)包中地址表示智能家居分布式監(jiān)測(cè)節(jié)點(diǎn)的地址信息,包括發(fā)出和接收節(jié)點(diǎn)的地址。多節(jié)點(diǎn)通信時(shí),地址的優(yōu)先級(jí)與地址值絕對(duì)值相關(guān),值越大優(yōu)先級(jí)越高[9]。源地址具有最高優(yōu)先級(jí)地址“1111 1111”,目的地址前4位為節(jié)點(diǎn)信息,后4位為單節(jié)點(diǎn)通道信息。SN65MLVD203把串化數(shù)據(jù)轉(zhuǎn)化為差分信號(hào)傳輸?shù)組?LVDS總線,保證數(shù)據(jù)在總線上傳輸?shù)目煽啃院涂偩€仲裁一致性。
3.3 數(shù)據(jù)轉(zhuǎn)換通信流程
數(shù)據(jù)轉(zhuǎn)換模塊的控制流程主要包括千兆以太網(wǎng)通信和M?LVDS通信之間的數(shù)據(jù)轉(zhuǎn)化。智能家居平臺(tái)發(fā)送命令時(shí),數(shù)據(jù)通過(guò)RJ45網(wǎng)口、千兆以太網(wǎng)接口到達(dá)數(shù)據(jù)轉(zhuǎn)換器。FPGA檢測(cè)標(biāo)志位判斷接收到數(shù)據(jù)后,將數(shù)據(jù)讀到千兆以太網(wǎng)通信模塊中,對(duì)命令數(shù)據(jù)解包,去除傳輸格式,讀取有效數(shù)據(jù)。將命令寫(xiě)入命令緩存中,實(shí)現(xiàn)數(shù)據(jù)跨時(shí)鐘同步。在讀信號(hào)上升沿時(shí)將數(shù)據(jù)從FIFO中讀出到M?LVDS模塊中,與命令寄存器組中的值對(duì)比,確定命令的功能、對(duì)象、觸發(fā)機(jī)制,重新生成命令數(shù)據(jù)幀,在總線管理器中按M?LVDS通信協(xié)議添加起始位、仲裁場(chǎng)、校驗(yàn)位、終止位組成M?LVDS 數(shù)據(jù)包格式,轉(zhuǎn)為串行數(shù)據(jù)發(fā)送至M?LVDS接口[10]。調(diào)用M?LVDS發(fā)送命令,經(jīng)SN65MLVD203發(fā)送給底層目標(biāo)節(jié)點(diǎn),完成一次發(fā)送。
接收上傳數(shù)據(jù)時(shí),M?LVDS的接收端口檢測(cè)到數(shù)據(jù)起始位有效時(shí)開(kāi)始接收,PLS層完成數(shù)據(jù)同步后轉(zhuǎn)化為并行數(shù)據(jù)傳輸給總線管理模塊。對(duì)M?LVDS接收的數(shù)據(jù)進(jìn)行CRC校驗(yàn)精確后,有用數(shù)據(jù)在有效標(biāo)志信號(hào)為高時(shí)傳輸?shù)紻DR3緩存中。對(duì)接收數(shù)據(jù)消抖后,把有用數(shù)據(jù)和節(jié)點(diǎn)信息寫(xiě)入DDR3中,使回傳速度處于可控范圍。千兆以太網(wǎng)通信模塊從DDR3緩存中讀出數(shù)據(jù),以并行方式傳輸至M88E1111,在 FPGA 控制下,將數(shù)據(jù)上傳到智能家居系統(tǒng)控制平臺(tái)。
功能測(cè)試平臺(tái)由信號(hào)源、M?LVDS?千兆以太網(wǎng)轉(zhuǎn)換器、控制平臺(tái)上位機(jī)搭建構(gòu)成,功能測(cè)試連接如圖3所示。調(diào)試助手提供數(shù)據(jù)接收發(fā)送操作界面,同時(shí)將上傳數(shù)據(jù)導(dǎo)出分析,驗(yàn)證數(shù)據(jù)正確性。測(cè)試時(shí)設(shè)置通信雙方IP地址等信息后啟動(dòng)連接。在命令窗口輸出要發(fā)送的數(shù)據(jù)或直接讀取網(wǎng)口數(shù)據(jù)。通過(guò)轉(zhuǎn)換網(wǎng)絡(luò)指示燈判斷以太網(wǎng)連接、數(shù)據(jù)傳輸情況,可以實(shí)時(shí)觀測(cè)上位機(jī)與FPGA 通信狀態(tài)。測(cè)試過(guò)程中信號(hào)源循環(huán)產(chǎn)生遞增數(shù)據(jù),由M?LVDS接口轉(zhuǎn)為差分信號(hào)對(duì)上傳到傳輸總線,轉(zhuǎn)換器將總線上的差分信號(hào)對(duì)轉(zhuǎn)化為串行數(shù)據(jù)輸入。
為了測(cè)試模塊功能,轉(zhuǎn)化器初始化4字節(jié)數(shù)“01010101”數(shù)據(jù)接收命令。調(diào)試助手通過(guò)以太網(wǎng)向轉(zhuǎn)化器下發(fā)讀取數(shù)據(jù)命令,讀取M?LVDS接口數(shù)據(jù)。測(cè)試結(jié)果如圖4所示。
數(shù)據(jù)傳輸開(kāi)始為4字節(jié)“01”證明轉(zhuǎn)化器能夠接收到控制命令。由調(diào)試助手接收到的多組數(shù)據(jù)分析,數(shù)據(jù)連續(xù)遞增,與信號(hào)源產(chǎn)生的數(shù)據(jù)一致,證明系統(tǒng)傳輸正確,實(shí)現(xiàn)了M?LVDS總線到千兆以太網(wǎng)的數(shù)據(jù)通信功能。測(cè)試中在系統(tǒng)中加入時(shí)間觸發(fā)和流量計(jì),通過(guò)計(jì)算一定時(shí)間內(nèi)接收到的數(shù)據(jù)量對(duì)傳輸速率進(jìn)行評(píng)估。以20組測(cè)試結(jié)果繪制成數(shù)據(jù)傳輸速度測(cè)試曲線,如圖5所示。系統(tǒng)傳輸速率穩(wěn)定在100~120 Mb/s,實(shí)現(xiàn)了數(shù)據(jù)的高速傳輸。
本文介紹了一種基于 FPGA 的 M?LVDS?千兆以太網(wǎng)轉(zhuǎn)換模塊設(shè)計(jì)方案,并測(cè)試了傳輸誤碼率和速率。智能家居平臺(tái)通過(guò)轉(zhuǎn)換器轉(zhuǎn)換功能實(shí)現(xiàn)同時(shí)控制多節(jié)點(diǎn)上監(jiān)測(cè)設(shè)備和環(huán)境調(diào)節(jié)設(shè)備的工作以及數(shù)據(jù)高速上傳。轉(zhuǎn)換模塊在不改變硬件系統(tǒng)構(gòu)架前提下可靈活實(shí)現(xiàn)多種傳輸協(xié)議,通用性強(qiáng),傳輸穩(wěn)定。
參考文獻(xiàn)
[1] 張法全,李宗敏,王國(guó)富,等.分布式多通道同步采集系統(tǒng)設(shè)計(jì)[J].電視技術(shù),2015,39(23):35?39.
ZHANG Faquan, LI Zongmin, WANG Guofu, et al. Distributed multi?channel synchronization acquisition system design [J]. TV engineering, 2015, 39(23): 35?39.
[2] 何潤(rùn)岸.基于UDP進(jìn)行大規(guī)模數(shù)據(jù)傳輸?shù)目煽總鬏斚到y(tǒng)的設(shè)計(jì)與實(shí)現(xiàn)[D].濟(jì)南:山東大學(xué),2015.
HE Runan. Design and implementation of reliable transmission system for large?scale data transmission based on UDP [D]. Jinan: Shandong University, 2015.
[3] 黃萬(wàn)偉.Xilinx FPGA高速串行傳輸技術(shù)與應(yīng)用[M].北京:電子工業(yè)出版社,2015.
HUANG Wanwei. High?speed serial transmission technology and application of Xilinx FPGA [M]. Beijing: Publishing House of Electronics Industry, 2015.
[4] 朱保琨,劉廣文.千兆以太網(wǎng)通信端口FPGA設(shè)計(jì)與實(shí)現(xiàn)[J].計(jì)算機(jī)工程與設(shè)計(jì),2016,37(9):2292?2298.
ZHU Baokun, LIU Guangwen. Design and implementation of gigabit Ethernet communication port based on FPGA [J]. Computer engineering & design, 2016, 37(9): 2292?2298.
[5] 佘顏.基于DDR3控制器的高速存儲(chǔ)接口系統(tǒng)的設(shè)計(jì)與驗(yàn)證[D].西安:西安電子科技大學(xué),2015.
SHE Yan. Design and verification of high?speed memory interface system based on DDR3 controller [D]. Xian: Xidian University, 2015.
[6] KIM J H. Buffering circuit, semiconductor device having the same, and methods thereof [J]. Journal of pharmaceutical sciences, 2015, 99(7): 3030?3040.
[7] 宋飛,馮旭哲.基于硬件協(xié)議棧芯片的高速以太網(wǎng)接口設(shè)計(jì)[J].工業(yè)儀表與自動(dòng)化裝置,2012(4):57?59.
SONG Fei, FENG Xuzhe. Design of high?speed Ethernet interface based on hardware protocol stack chip [J]. Industrial instruments and automation device, 2012(4): 57?59.
[8] 張磊,何昕,魏仲慧,等.基于千兆網(wǎng)接口的星敏感器圖像顯示與存儲(chǔ)[J].液晶與顯示,2015,30(1):114?119.
ZHANG Lei, HE Xin, WEI Zhonghui, et al. Display and storage of star sensor image based on Gigabit network interface [J]. Liquid crystals & displays, 2015, 30(1): 114?119.
[9] 阿永嘎.多位串行M?LVDS高速網(wǎng)絡(luò)式儀器總線的研究[D].杭州:浙江大學(xué),2010.
A Yongga. Research on multi?bit serial M?LVDS high speed network instrument bus [D]. Hangzhou: Zhejiang University, 2010.
[10] SONG K C, LI C X, YE L Y, et al. Signal integrity optimization of MLVDS based multi?master instrument bus [C]// 2014 IEEE International Symposium on Electromagnetic Compatibility. Raleigh: IEEE, 2014: 433?437.