【正文】
圖 41 HDB3 譯碼的模型框圖 上圖中雙 /單極性變換電路有兩個(gè)正負(fù)整流電路組成。正整流電路提取正電平碼部分;負(fù)整流電路提取負(fù)電平部分。 V 碼檢測電路包括 +V 碼檢測和 V 碼檢測兩部分。根據(jù)編碼規(guī)則, V脈沖必然是同極性脈沖。當(dāng)無 V脈沖時(shí),傳號脈沖“ +1”和“ 1”交替出現(xiàn)。當(dāng)連續(xù)出現(xiàn)兩個(gè)“ +1”或“ 1”時(shí),若無誤碼,則后一個(gè)一定是 V脈沖。時(shí)鐘提取 電路用于提取同步時(shí)鐘???V扣 B 電路在 V脈沖和同步時(shí)鐘的控制下,完成扣 V扣 B的功能。 由于雙 /單極性變換電路涉及到雙極性信號,無法在 FPGA 中實(shí)現(xiàn),需加外圍硬件電路。 正整流 負(fù)整流 +V 碼檢測 V 碼檢測 相加器 相加器 扣 V 扣 B 時(shí)鐘提取 11 2) 扣 V扣 B 模塊建模 扣 V扣 B模塊有三個(gè)輸入信號,即時(shí)鐘信號、 V碼信號和來自正、負(fù)整流輸出的和路信號。由于該和路信號可能包含有 B 脈沖和 V 脈沖,因此需要在扣 V扣 B模塊中,去除 V和 B 脈沖。本模塊的建模方法是,用 V碼檢測模塊所檢測出的 V碼信號,去控制一個(gè)移位寄存器,若未碰到 V 脈沖,則整流輸出合成信號在時(shí)鐘的節(jié)拍下,順利通過移位寄存器,當(dāng)碰到有 V 脈沖時(shí),該 V 脈沖將使移位寄存器清零??紤]到四連 0,即 V 脈沖及其前面的三個(gè)碼元應(yīng)為 0 碼,所以,可設(shè)置四位的移位寄存器,當(dāng) V碼清零時(shí),同時(shí)將移存器中的四位碼全變?yōu)?0。不管是否有 B脈沖,在此模塊中,一并清零,因而無需另設(shè)扣 B電路。另外移位四位寄存器起到延時(shí)四位時(shí)鐘周期的作用,以使所檢測出的 V 脈沖與信號流中的 V脈沖位置對齊,保證清零的準(zhǔn)確性???V扣 B模塊框圖如圖 44。 圖 42 扣 V 扣 B模塊框圖 5 實(shí)際電路連接圖 HDB3 編譯碼器電路連接圖 12 6 總結(jié) 通過一步步有條不紊的分析和思考,更重要的是在設(shè)計(jì)中,根據(jù)實(shí)際情況,對設(shè)計(jì)初期的思想做不斷完善和改進(jìn),因?yàn)樵谠O(shè)計(jì)之前的思路,只能說是一個(gè)大體的方向,很多時(shí)候,實(shí)際的操作和設(shè)計(jì)要細(xì)致和復(fù)雜的多,或者原來的想法根本就行不通,得從實(shí)際設(shè)計(jì)的角度一步步來完成了這樣一個(gè)系統(tǒng)設(shè)計(jì)。 總結(jié) 一下實(shí)際操作的設(shè)計(jì)過程,可得到如下設(shè)計(jì)流程圖: 參考文獻(xiàn) ( 1)鄧勇、周擇、鄧斌著《數(shù)字電路設(shè)計(jì)完全手冊》 .國防工業(yè)出版社。 2021; ( 2)朱正偉著《 EAD 技術(shù)及應(yīng)用》 .清華大學(xué)出版社。 2021; ( 3)全國大學(xué)生電子設(shè)計(jì)組委會(huì)著《電子系統(tǒng)設(shè)計(jì)實(shí)踐》 2021; ( 4)林明權(quán)著《 VHDL 數(shù)字控制系統(tǒng)設(shè)計(jì)范例》 . 電子工業(yè)出版社 ( 5)馮濤著《可編程邏輯器件開發(fā)技術(shù) MAX+ plusⅡ入 門與提高》 人民郵電出版社 ( 6)王毓銀著《數(shù)字電路邏輯設(shè)計(jì)》 高等教育出版社 ( 7)趙俊超著《集成電路設(shè)計(jì) VHDL 語言教程》 北京希望出版社 調(diào)試達(dá)到要求、完成設(shè)計(jì) 學(xué)習(xí) VHDL 語言設(shè)計(jì) 分析 HDB3 碼編 /解碼器功能 確定設(shè)計(jì)方案 應(yīng)用 VHDL 進(jìn)行編程 對系統(tǒng)仿真測試、選擇合適芯片并定義管腳 仿真不通過 系統(tǒng)功能的硬件測試 13 附錄 1:基于 VHDL 語言的 HDB3 碼編 /譯碼器 設(shè) 計(jì) 程 序 插 V模塊 use 。 entity hdb3a is port(reset,clk,datain: in std_logic。 dout: out std_logic_vector(1 downto 0))。 end entity。 architecture rtl of hdb3a is signal counter:integer range 0 to 3。整數(shù) begin process(reset,clk,datain) is begin if reset=39。039。 then counter=0。dout=00。 elsif(clk=39。139。 and clk39。event) then if datain=39。039。 then counter=counter+1。 if counter=3 then 連 4個(gè) 0了 dout=11。 counter=0。 else dout=00。 沒連 4個(gè) 0 end if。 else dout=01。 1 碼 counter=0。 end if。 end if。 end process。 end。 補(bǔ) B模塊 library ieee。 use 。 use 。 entity hdb is port(reset,clk:in std_logic。 datain: in std_logic_vector(1 downto 0)。輸入 dout: out std_logic_vector(1 downto 0))。輸出 14 end。 architecture rtl of hdb is signal D1,D0:std_logic_vector(3 downto 0)。兩組 4 位移位寄存器 signal flag,even:integer range 0 to 1。兩個(gè)標(biāo)記 begin process(clk,datain)is begin if(clk=39。139。 and clk39。event)then檢測上升沿 D1(3)=datain(1)。數(shù)據(jù)輸入 D0(3)=datain(0)。 D1(2 downto 0)=D1(3 downto 1)。 D0(2 downto 0)=D0(3 downto 1)。 end if。 end process。 process(reset,clk,D1,D0) is begin if reset=39。039。 then flag=0。 even=0。 elsif(clk=39。139。 and clk39。event)then if (D1(3)=39。139。 and D0(3)=39。139。)then flag=1。檢測有 V 碼輸入 else flag=0。 end if。 if(D1(0)=39。039。 and D0(0)=39。139。)then even=even+1。在下一個(gè) V 到來之前檢測 1的個(gè)數(shù) elsif(D1(0)=39。139。 and D0(0)=39。139。)then even=0。下一個(gè) V到來清零 end if。 end if。 end process。 process(reset,clk) is begin if reset=39。039。 then dout=00。 elsif(clk=39。139。 and clk39。event) then if(flag=0 and even=0 and (D1(3)=39。139。 and D0(3)=39。139。)) then dout=10。輸出 B 碼 else dout=D1(0)amp。D0(0)。 end if。 end if。 15 end process。 end。 極性變換 library ieee。 use 。 use 。 entity hdb3c is port(reset,clk: in std_logic。 datain: in std_logic_vector(1 downto 0)。 dout: out std_logic_vector(1 downto 0))。 end entity。 architecture rtl of hdb3c is signal even:std_logic。定義一個(gè)信號 even begin process(reset,clk,datain)is begin if reset=39。039。 then even=39。039。 dout=00。 elsif(clk=39。139。 and clk39。event)then if datain=11 then if even=39。139。 then dout=11。 負(fù)電平 1 else dout=01。 正電平 1 end if。 elsif(datain=01 or datain=10) then if even=39。139。 then even=39。039。 dout=01。 else even=39。139。 dout=11。 end if。 else dout=00。 end if。 end if。 end process。 end。 16 頂層文件 library ieee。 use 。 use 。 entity hdb3 is port(reset,clk,datain:in std_logic。 dout: out std_logic_vector(1 downto 0))。 end。 architecture rtl of hdb3 is ponent hdb3a is調(diào)用 V檢測器聲明語句 port(reset,clk,datain: in std_logic。 dout: out std_logic_vector(1 downto 0))。 end ponent。 ponent hdb is調(diào)用 B檢測器聲明語句 port(reset,clk:in std_logic。 datain: in std_logic_vector(1 downto 0)。 dout: out std_logic_vector(1 downto 0))。 end ponent。 ponent hdb3c is調(diào)用極性轉(zhuǎn)換聲明語句 port(reset,clk: in std_logic。 datain: in std_logic_vector(1 downto 0)。 dout: out std_logic_vector(1 downto 0))。 end ponent。 signal d1,d2:std_logic_vector(1 downto 0)。 begin A: hdb3a port map(reset,clk,datain,d1)。端口映射 B: hdb port map(reset,clk,d1,d2)。 C: hdb3c port map(reset,clk,d2,dout)。 end。 譯碼 library ieee。 use 。 use 。 entity hdb3decoder is port(clk:in std_logic。 datain:in std_logic_vector(1 downto 0)。 17 dout:out std_logic)。 end hdb3decoder。 architecture rtl of hdb3decoder is signal D1,D0:std_logic_vector(3 downto 0)。兩個(gè) 4 位移位寄存器 signal t:std_logic_vector(1 downto 0)。 begin t=datain。 process(clk,datain)is begin if(clk=39。139。 and clk39。event)then D1(2 downto 1)=D1(3 downto 2)。進(jìn)行移位 D0(2 downto 1)=D0(3 downto 2)。 end if。 end process。 process(clk,datain) is begin if(clk=39。139。 and clk39。event)then if ((t=11 and D1(3 downto 0)=0001 and D0(3 downto 0)=0001)or (t=01 and D1(3 downto 0)=0