CRC編碼器的設(shè)計(jì)_第1頁
CRC編碼器的設(shè)計(jì)_第2頁
CRC編碼器的設(shè)計(jì)_第3頁
CRC編碼器的設(shè)計(jì)_第4頁
CRC編碼器的設(shè)計(jì)_第5頁
已閱讀5頁,還剩21頁未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

目錄一、設(shè)計(jì)目的:3二、設(shè)計(jì)要求3三、CRC循環(huán)冗余校驗(yàn)簡介3四、CRC的編碼原理3五、CRC校驗(yàn)原理6(1)CRC碼的檢錯(cuò)方法6(2)模2除法器6(3)校驗(yàn)位的生成7(4)CRC碼的糾錯(cuò)8(5)生成多項(xiàng)式的選取8六、設(shè)計(jì)方案8(1)采用標(biāo)準(zhǔn)8(2)系統(tǒng)結(jié)構(gòu)設(shè)計(jì)9(3)模塊代碼11七、波形結(jié)果25八、心得及體會(huì)25(1)關(guān)于CRC的了解25(2)關(guān)于期待的改進(jìn)26(3)課程設(shè)計(jì)總結(jié)26九、參考文獻(xiàn):26CRC編碼器的設(shè)計(jì)一、 設(shè)計(jì)目的:掌握CRC的編碼原理及作用, 并進(jìn)行設(shè)計(jì)。二、設(shè)計(jì)要求1、闡述CRC的編碼原理及作用2、基于VHDL語言實(shí)現(xiàn)CRC的編碼 3、寫出詳細(xì)的設(shè)計(jì)報(bào)告(不少于5000字)三、 CRC循環(huán)冗余校驗(yàn)簡介循環(huán)冗余校驗(yàn)(CRC)是一種根據(jù)網(wǎng)絡(luò)數(shù)據(jù)封包或電腦檔案等數(shù)據(jù)產(chǎn)生簡短固定位數(shù)校驗(yàn)碼的一種散列函數(shù),主要用來檢測或校驗(yàn)數(shù)據(jù)傳輸或者保存后可能出現(xiàn)的錯(cuò)誤。生成的數(shù)字在傳輸或者儲(chǔ)存之前計(jì)算出來并且附加到數(shù)據(jù)后面,然后接收方進(jìn)行檢驗(yàn)確定數(shù)據(jù)是否發(fā)生變化。而且CRC碼是目前通信系統(tǒng)中最常用的一種差錯(cuò)控制編碼,利用其進(jìn)行檢錯(cuò)的過程可簡單描述為:在發(fā)送端根據(jù)要傳送的二進(jìn)制碼序列,以一定的規(guī)則產(chǎn)生一個(gè)校驗(yàn)用的監(jiān)督碼,附在原始信息后邊,構(gòu)成一個(gè)新的二進(jìn)制碼序列數(shù),然后發(fā)送出去。在接收端根據(jù)信息碼和CRC 碼之間所遵循的規(guī)則進(jìn)行檢驗(yàn),一旦傳輸過程中發(fā)生差錯(cuò),則信息碼元與監(jiān)督碼元之間的關(guān)系遭到破壞,從而可以發(fā)現(xiàn)錯(cuò)誤,乃至糾正錯(cuò)誤。四、 CRC的編碼原理循環(huán)冗余校驗(yàn)碼(cyclic redundancy check,CRC)簡稱為循環(huán)碼或CRC碼。二進(jìn)制信息沿一條信號(hào)線逐位在設(shè)備之間傳送稱為串行傳送,CRC碼常用于串行傳送過程中的檢錯(cuò)與糾錯(cuò)。CRC碼由兩部分組成,前部分是信息碼,就是需要校驗(yàn)的信息,后部分是校驗(yàn)碼。其中任意一個(gè)二進(jìn)制位碼都可以和一個(gè)系數(shù)僅為0和1取值的多項(xiàng)式一一對(duì)應(yīng)。例如:代碼對(duì)應(yīng)的多項(xiàng)式為,而多項(xiàng)式為對(duì)應(yīng)的代碼。由上可以看出,CRC 多項(xiàng)式是線性結(jié)構(gòu),可以非常容易地故意改變量據(jù)而維持 CRC 不變。所以盡管在錯(cuò)誤檢測中非常有用,CRC 并不能可靠地校驗(yàn)數(shù)據(jù)完整性。CRC碼的編碼格式如圖4.1所示,是在k位有效數(shù)據(jù)之后添加r位校驗(yàn)碼,形成總長度為n的CRC碼,簡寫作C(n,k)碼。CRC編碼的關(guān)鍵技術(shù)在于如何從k位信息簡便的得到r位校驗(yàn)碼,并根據(jù)總長度為n的CRC碼進(jìn)行糾錯(cuò)。圖4.1設(shè)被校驗(yàn)的數(shù)據(jù)是一個(gè)k位的二進(jìn)制代碼,將它表示為一個(gè)(k-1)階的多項(xiàng)式 (1-1)多項(xiàng)式(1-1)中的系數(shù)D的取值為0或1,與被校驗(yàn)的數(shù)據(jù)M一一對(duì)應(yīng);式中的x是一個(gè)偽變量,用指明各位的位置。設(shè)校驗(yàn)碼P長度為r,將被校驗(yàn)數(shù)據(jù)D左移r位后的結(jié)果為將D左移r位的目的是給D右邊添加r個(gè)0,形成(k+r)位長度二進(jìn)制代碼,其多項(xiàng)式形式為M(x)。如圖4.1所示,CRC碼由k位數(shù)據(jù)D和r位校驗(yàn)碼P組成,求校驗(yàn)碼P的多項(xiàng)式R(X)的方法如下: (4-2)Q(x)是商,R(x)是余數(shù),R(x)所對(duì)應(yīng)的二進(jìn)制代碼是校驗(yàn)碼P??梢宰C明存在一個(gè)最高次冪為n- k=r 的多項(xiàng)式G(x) ,即式(4-2)中G(x),稱為生成多項(xiàng)式。 由式(4-2)可以推導(dǎo)出 (4-3)由式(4-3)可知,CRC碼可被G(x)整除,余數(shù)必然為0.。根據(jù)這一特性,接收方將收到的CRC碼被G(x)除,若余數(shù)為0,則表明傳送過程中沒有錯(cuò)誤發(fā)生,若出現(xiàn)一位錯(cuò),根據(jù)余數(shù)與出錯(cuò)位一一對(duì)應(yīng)的關(guān)系,可利用余數(shù)對(duì)錯(cuò)誤碼進(jìn)行定位。因此,接收方可根據(jù)表4.1發(fā)現(xiàn)并糾正1位錯(cuò)。 Q6Q5Q4Q3Q2Q1Q0余數(shù)出錯(cuò)位正確1100010000無錯(cuò)誤1100011001Q01100000010Q11100110100Q21101010011Q31110010110Q41000010111Q50100010101Q6表4.1 循環(huán)校驗(yàn)碼的出錯(cuò)模式對(duì)于其驗(yàn)證碼,它的編碼規(guī)則是,如果CRC碼共長個(gè)bit,信息碼長個(gè)bit,就稱為碼:1、首先將原信息碼( bit)左移位();2、運(yùn)用一個(gè)生成多項(xiàng)式(也可看成二進(jìn)制數(shù))用模2除上面的式子,得到的余數(shù)就是利用生成多項(xiàng)式生成CRC校驗(yàn)碼。而在構(gòu)建一個(gè)新的 CRC 多項(xiàng)式或者改進(jìn)現(xiàn)有的 CRC 時(shí),一個(gè)通用的數(shù)學(xué)原則是使用滿足所有模運(yùn)算不可分解多項(xiàng)式約束條件的多項(xiàng)式。這種情況下的不可分解是指多項(xiàng)式除了與它自身之外不能被任何其它的多項(xiàng)式整除。如果 CRC 有多于一個(gè)的非零系數(shù),那么 CRC 能夠檢查出輸入消息中的所有單數(shù)據(jù)位錯(cuò)誤。同時(shí)其也可以用于檢測短于的輸入消息中的所有雙位錯(cuò)誤,其中是多項(xiàng)式的最長的不可分解部分的長度。另外,如果多項(xiàng)式可以被整除,那么不存在可以被它整除的有奇數(shù)個(gè)非零系數(shù)的多項(xiàng)式。因此,它可以用來檢測輸入消息中的奇數(shù)個(gè)錯(cuò)誤,就像奇偶校驗(yàn)函數(shù)那樣。五、 CRC校驗(yàn)原理 (1)CRC碼的檢錯(cuò)方法 假設(shè)要進(jìn)行校驗(yàn)的數(shù)據(jù)信息為一個(gè)位的二進(jìn)制數(shù)據(jù),將左移位后,用一個(gè)約定的生成多項(xiàng)式相除,將所得校驗(yàn)位拼接到的位數(shù)據(jù)后面,形成一個(gè)位的代碼,稱這個(gè)代碼為循環(huán)冗余校驗(yàn)(CRC)碼,也稱()碼。 圖5.1 CRC碼結(jié)構(gòu) (2)模2除法器模2除法與算術(shù)除法類似,但每一位除的結(jié)果不影響其它位,即不向上一位借位,所以實(shí)際上就是異或。它是CRC校驗(yàn)中的一個(gè)十分重要的部分,用于得到校驗(yàn)碼。圖5.2 模2除法器示例如圖所示,用10011來除0000,大致方法與二進(jìn)制除法相同,但是相比之下,模2除法沒有進(jìn)位與借位,所以在相減的時(shí)候,則做異或運(yùn)算。前面為0的可以直接省略,從第一位為1開始計(jì)數(shù)。(3)校驗(yàn)位的生成 假設(shè):要傳送的數(shù)據(jù)信息為:,即報(bào)文多項(xiàng)式為:約定的生成多項(xiàng)式為:則數(shù)據(jù)信息位數(shù),生成多項(xiàng)式位數(shù)為4位,所以校驗(yàn)位位數(shù)。生成校驗(yàn)位時(shí),用去除以,相除時(shí)采用“模2運(yùn)算”的多項(xiàng)式除法。 利用“模2”多項(xiàng)式除法計(jì)算的過程。則有:校驗(yàn)位為111,CRC碼為。說明:如果要校驗(yàn)CRC碼,則可將CRC碼用同一個(gè)多項(xiàng)式相除,若余數(shù)為0,則說明無錯(cuò);若余數(shù)不為0,則說明有錯(cuò)。 圖5.3 校驗(yàn)位生成示例(4)CRC碼的糾錯(cuò)在接收方將收到的CRC碼用約定的生成多項(xiàng)式去除,如果碼字沒有錯(cuò)誤,則余數(shù)為0,若有一位出錯(cuò),則余數(shù)不為0,而且不同的出錯(cuò)位置其余數(shù)不同。更換不同的碼字,余數(shù)和出錯(cuò)位的關(guān)系不變。只和碼制與生成多項(xiàng)式有關(guān)。 如果CRC碼中有一位出錯(cuò),用特定的作模2除,則會(huì)得到一個(gè)不為0的余數(shù)。若對(duì)余數(shù)補(bǔ)0后繼續(xù)除下去,則會(huì)出現(xiàn)一個(gè)有趣的現(xiàn)象:各次余數(shù)將會(huì)按照一個(gè)特定的順序循環(huán)。(5)生成多項(xiàng)式的選取 從查錯(cuò)和糾錯(cuò)的要求來看,選取的一個(gè)生成多項(xiàng)式應(yīng)滿足以下幾個(gè)條件:1、 任何一位發(fā)生錯(cuò)誤時(shí),都應(yīng)使余數(shù)不為0。2、不同位發(fā)生錯(cuò)誤時(shí),余數(shù)應(yīng)該不同。3、對(duì)余數(shù)作模2 除時(shí),應(yīng)使余數(shù)循環(huán)。六、設(shè)計(jì)方案(1)采用標(biāo)準(zhǔn)根據(jù)應(yīng)用環(huán)境與習(xí)慣的不同,CRC又可分為以下幾種標(biāo)準(zhǔn): 1、CRC-12碼;2、CRC-16碼;3、CRC-CCITT碼;4、CRC-32碼;它們都是較為常用的CRC碼,生成多項(xiàng)式分別為:CRC-CCITT:CRC-16:CRC-12:CRC-32: 標(biāo)準(zhǔn)的CRC碼是CRC-CCITT和CRC-16,其中CRC-16-CCITT的應(yīng)用最廣泛,在藍(lán)牙、X25和PPP協(xié)議中等都有應(yīng)用。故本實(shí)驗(yàn)使用CRC-CCITT標(biāo)準(zhǔn)進(jìn)行仿真,其生成多項(xiàng)式為:本實(shí)驗(yàn)采用如圖6.1所示的結(jié)構(gòu)實(shí)現(xiàn)CRC的編解碼。(2)系統(tǒng)結(jié)構(gòu)設(shè)計(jì)圖6.1 CRC校驗(yàn)系統(tǒng)結(jié)構(gòu)CRC編碼采用如圖6.2所示的結(jié)構(gòu)實(shí)現(xiàn):圖6.2 CRC編碼實(shí)現(xiàn)結(jié)構(gòu)CRC校驗(yàn)采用多項(xiàng)式除法實(shí)現(xiàn),若能除盡,則傳輸正確,否則錯(cuò)誤。實(shí)現(xiàn)結(jié)構(gòu)上,在發(fā)送端進(jìn)行CRC-CCITT標(biāo)準(zhǔn)編碼,在接收端將信源數(shù)據(jù)與編碼字串行輸入與發(fā)送端相同的CRC編碼器,若編碼字為全零,則無傳輸錯(cuò)誤,否則,傳輸出錯(cuò)。發(fā)送端CRC編碼器設(shè)計(jì)時(shí)序如圖6.3所示。接收端CRC校驗(yàn)時(shí)序與發(fā)送端相同,區(qū)別只在于無需順序移出CRC編碼字,只需判斷是否為全零即可。引入噪聲的結(jié)構(gòu)如圖7所示,其中噪聲來源為隨機(jī)產(chǎn)生的比特序列,與幀解析的數(shù)據(jù)輸出進(jìn)行異或,其原理為dout與0異或仍為dout,dout與1異或?yàn)閐out,因此噪聲序列只需隨機(jī)引入幾個(gè)1即可實(shí)現(xiàn)傳輸錯(cuò)誤的模擬。圖6.3 發(fā)送端CRC編碼時(shí)序圖圖6.4 引入噪聲仿真結(jié)構(gòu)圖6.4中frame模塊實(shí)現(xiàn)的是組幀功能,根據(jù)RS-232的組幀格式,在有效數(shù)據(jù)前加一比特起始位0,數(shù)據(jù)結(jié)束后加一比特停止位1,其時(shí)序圖如圖6.5所示。圖6.5 frame模塊端口時(shí)序圖6.4中frame receive模塊實(shí)現(xiàn)幀解析功能,它根據(jù)發(fā)送端發(fā)送的數(shù)據(jù),檢測到一個(gè)起始位零,即生成計(jì)數(shù)使能信號(hào),生成數(shù)據(jù)有效信號(hào)data_dv,其時(shí)序圖如圖6.6所示。圖6.6 receive模塊時(shí)序(3)模塊代碼(1)toplibrary IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity crc_ans is port( clk:in std_logic; reset:in std_logic; din:in std_logic; din_dv:in std_logic; noise:in std_logic; error_right:out std_logic; error_noise:out std_logic );end crc_ans;architecture behavioral of crc_ans iscomponent crc_codeport( clk:in std_logic; reset:in std_logic; din:in std_logic; din_dv:in std_logic; dout_dv:out std_logic; dout:out std_logic);end component;component crc_frame port( clk:in std_logic; reset:in std_logic; din:in std_logic; din_dv:in std_logic; dout:out std_logic);end component;component crc_frame_receiveport( clk:in std_logic; reset:in std_logic; din:in std_logic; dout_dv:out std_logic; dout:out std_logic);end component;component crc_checkport( clk:in std_logic; reset:in std_logic; din:in std_logic; din_dv:in std_logic; error:out std_logic);end component;signal code_dout,code_dout_dv:std_logic;signal frame_dout:std_logic;signal frame_receive_dout,frame_receive_dout_noise,frame_receive_dout_dv:std_logic;beginpart1:crc_codeport map ( clk=clk,reset=reset,din=din,din_dv=din_dv, dout=code_dout,dout_dv=code_dout_dv );part2:crc_frameport map ( clk=clk,reset=reset,din=code_dout,din_dv=code_dout_dv, dout=frame_dout );part3:crc_frame_receiveport map ( clk=clk,reset=reset,din=frame_dout, dout=frame_receive_dout,dout_dv=frame_receive_dout_dv );part4_no_noise:crc_checkport map ( clk=clk,reset=reset,din=frame_receive_dout,din_dv=frame_receive_dout_dv, error=error_right); frame_receive_dout_noiseclk,reset=reset,din=frame_receive_dout_noise,din_dv=frame_receive_dout_dv, error=error_noise );end behavioral;(2)codelibrary IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity crc_code is port( clk:in std_logic; reset:in std_logic; din:in std_logic; din_dv:in std_logic; dout_dv:out std_logic; dout:out std_logic );end crc_code;architecture behavioral of crc_code issignal cnt:std_logic_vector(6 downto 0);signal cnt_en:std_logic;signal d1:std_logic_vector(15 downto 0);beginprocess(clk,reset)begin if reset=0 then cnt_en=0; elsif clkevent and clk=1 then if cnt= then cnt_en=0; elsif din_dv=1 then cnt_en=1; end if; end if;end process;process(clk,reset)begin if reset=0 then cnt=; elsif clkevent and clk=1 then if cnt_en=1 then cnt=cnt+1; end if; end if;end process;process(clk,reset)begin if reset=0 then dout_dv=0; elsif clkevent and clk=1 then if din_dv=1 then dout_dv=1; elsif cnt= then dout_dv=0; end if; end if;end process; process(clk,reset)begin if reset=0 then d10); elsif clkevent and clk=1 then if din_dv=1 then d1(0)=din xor d1(15); d1(1)=d1(0); d1(2)=d1(1); d1(3)=d1(2); d1(4)=d1(3); d1(5)=d1(4) xor (din xor d1(15); d1(6)=d1(5); d1(7)=d1(6); d1(8)=d1(7); d1(9)=d1(8); d1(10)=d1(9); d1(11)=d1(10); d1(12)=d1(11) xor (din xor d1(15); d1(13)=d1(12); d1(14)=d1(13); d1(15)=d1(14);else d1(0)=0; d1(1)=d1(0); d1(2)=d1(1); d1(3)=d1(2); d1(4)=d1(3); d1(5)=d1(4); d1(6)=d1(5); d1(7)=d1(6); d1(8)=d1(7); d1(9)=d1(8); d1(10)=d1(9); d1(11)=d1(10); d1(12)=d1(11); d1(13)=d1(12); d1(14)=d1(13); d1(15)=d1(14); end if; end if;end process;process(clk,reset)begin if reset=0 then dout=0; elsif clkevent and clk=1 then if din_dv=1 then dout=din; else dout0);signal din_dv,cnt1_en,dout1_dv:std_logic;signal cnt1,cnt2:std_logic_vector(6 downto 0):=(others=0);signal dout1:std_logic;signal cnt3:std_logic_vector(6 downto 0);signal cnt2_en,flag,dout2:std_logic;beginprocess(clk,rst)begin if rst=0 then dout1_dv=0; din_dv=0;elsif clkevent and clk=1 then if cnt2= then dout1_dv=1; cnt2=cnt2+1; if cnt1= then din_dv=1; cnt1=cnt1+1; else din_dv=0; end if;else dout1_dv=0;end if;end if;end process;process(clk,rst)begin if rst=0 then dout1=0;elsif clkevent and clk=1 then if dout1_dv=1 then if din_dv=1 then dout1=din; d1(0)=din xor d1(15); d1(1)=d1(0); d1(2)=d1(1); d1(3)=d1(2); d1(4)=d1(3); d1(5)=d1(4) xor (din xor d1(15); d1(6)=d1(5); d1(7)=d1(6); d1(8)=d1(7); d1(9)=d1(8); d1(10)=d1(9); d1(11)=d1(10); d1(12)=d1(11) xor (din xor d1(15); d1(13)=d1(12); d1(14)=d1(13); d1(15)=d1(14); elsif din_dv=0 then dout1=d1(15); d1(0)=0; d1(1)=d1(0); d1(2)=d1(1); d1(3)=d1(2); d1(4)=d1(3); d1(5)=d1(4); d1(6)=d1(5); d1(7)=d1(6); d1(8)=d1(7); d1(9)=d1(8); d1(10)=d1(9); d1(11)=d1(10); d1(12)=d1(11); d1(13)=d1(12); d1(14)=d1(13); d1(15)=d1(14);end if;end if;end if;end process;process(clk,rst)beginif rst=0 then dout1=0;elsif clkevent and clk=1 then if dout1_dvevent and dout1_dv=0 then dout1=1;end if;end if;end process;flag=dout1;process(clk,rst)begin if rst=0 then flag=1;cnt30);elsif clkevent and clk=1 then if cnt3 then cnt3=cnt3+1;end if;end if;end process;process(clk,rst)begin if rst=0 then data=0; elsif clkevent and clk=1 then if cnt3= then d2(0)=dout1 xor d2(15); d2(1)=d2(0); d2(2)=d2(1); d2(3)=d2(2); d2(4)=d2(3); d2(5)=d2(4) xor (dout1 xor d2(15); d2(6)=d2(5); d2(7)=d2(6); d2(8)=d2(7); d2(9)=d2(8); d2(10)=d2(9); d2(11)=d2(10); d2(12)=d2(11) xor (dout1 xor d2(15); d2(13)=d2(12); d2(14)=d2(13); d2(15)=d2(14); if cnt2= then data=dout2; end if; end if; end if;end process;process(clk,rst)begin if rst=0 then error=1; elsif clkevent and clk=1 then if cnt3= then error=d2(0) and d2(1) and d2(2) and d2(3) and d2(4) and d2(5) and d2(6) and d2(7) and d2(8) and d2(9) and d2(10) and d2(11) and d2(12) and d2(13) and d2(14) and d2(15);end if;end if;end process;end behavioral;(4)framelibrary IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity frame isport(clk,reset:in std_logic; din,din_dv:in std_logic; dout:out std_logic);end frame;architecture behavior of frame issignal a,cnt_en :std_logic;signal cnt:integer;begincnt_en_pro:process(clk,reset)begin if reset=0 then cnt_en=0; elsif clkevent and clk=1 then if cnt=80 then cnt_en=0; elsif din_dv=1 then cnt_en=1; end if; end if;end process;cnt_pro:process(clk,reset)begin if reset=0 then cnt=0; elsif clkevent and clk=1 then if cnt=80 then cnt=0; elsif cnt_en=1 then cnt=cnt=1; end if; end if;end process;dout_pro:process(clk,reset)begin if reset=1 then dout=0;elsif ( clkevent and clk =1 ) thendind = din ;if ( din_dv=1 and cnt_en=0 ) thendout =0;elsif ( cnt_en = 1 and cnt =80 ) thendout = 0 and cnt 80 ) thendout = dind ;end if; end if;end process;end behavior;(5)receivelibrary IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity crc_frame_receive is port( clk:in std_logic; reset:in std_logic; din:in std_logic; dout_dv:out std_logic; dout:out std_logic );end crc_frame_receive;architecture behavioral of crc_frame_receive issignal cnt:std_logic_vector(6 downto 0);signal data_dv:std_logic;beginprocess(clk,reset)begin if reset=0 then data_dv=0; elsif clkevent and clk=1 then if din=0 and cnt then data_dv=1; elsif cnt= then data_dv=0; end if; end if;end process;process(clk,reset)begin if reset=0 then cnt0); elsif clkevent and clk=1 then if data_dv=1 then cnt=cnt+1;end if;end if;end process;process(clk,reset)begin if reset=0 then dout_dv=0; dout=0; elsif clkevent and clk=1 then if data_dv=1 then dout_dv=1; dout=din; elsif data_dv=0 and din=1 then dout_dv=0; dout=0; end if; end if;end process;end behavioral;(6)checklibrary IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity crc_check is port( clk:in std_logic; reset:in std_logic; din:in std_logic; din_dv:in std_logic; error:out std_logic );end crc_check;architecture behavioral of crc_check issignal cnt:std_logic_vector(6 downto 0);signal cnt_en,din1:std_logic;signal d1:std_logic_vector(15 downto 0);beginprocess(clk,reset)begin if reset=0 then cnt_en=0; elsif clkevent and clk=1 then if cnt= then cnt_en=0; elsif din_dv=1 then cnt_en=1;end if; end if;end process;process(clk,reset)begin if reset=0 then cnt=; elsif clkevent and clk=1 then if cnt_en=1 then cnt=cnt+1; end if; end if;end process;process(clk,reset)begin if reset=0 then d10); elsif clkevent and clk=1 then if din_dv=1 then d1(0)=din xor d1(15); d1(1)=d1(0); d1(2)=d1(1); d1(3)=d1(2); d1(4)=d1(3); d1(5)=d1(4) xor (din xor d1(15); d1(6)=d1(5); d1(7)=d1(6); d1(8)=d1(7); d1(9)=d1(8); d1(10)=d1(9); d1(11)=d1(10); d1(12)=d1(11) xor (din xor d1(15); d1(13)=d1(12); d1(14)=d1(13); d1(15)=d1(14); end if; end if;end process;process(clk,reset)begin if reset=0 then error=1; elsif clkevent and clk=1 then if din_dv=0 and cnt= then if d

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論