CRC计算VHDL代码级测试代码.docx

上传人:b****4 文档编号:6011278 上传时间:2023-05-09 格式:DOCX 页数:27 大小:168.21KB
下载 相关 举报
CRC计算VHDL代码级测试代码.docx_第1页
第1页 / 共27页
CRC计算VHDL代码级测试代码.docx_第2页
第2页 / 共27页
CRC计算VHDL代码级测试代码.docx_第3页
第3页 / 共27页
CRC计算VHDL代码级测试代码.docx_第4页
第4页 / 共27页
CRC计算VHDL代码级测试代码.docx_第5页
第5页 / 共27页
CRC计算VHDL代码级测试代码.docx_第6页
第6页 / 共27页
CRC计算VHDL代码级测试代码.docx_第7页
第7页 / 共27页
CRC计算VHDL代码级测试代码.docx_第8页
第8页 / 共27页
CRC计算VHDL代码级测试代码.docx_第9页
第9页 / 共27页
CRC计算VHDL代码级测试代码.docx_第10页
第10页 / 共27页
CRC计算VHDL代码级测试代码.docx_第11页
第11页 / 共27页
CRC计算VHDL代码级测试代码.docx_第12页
第12页 / 共27页
CRC计算VHDL代码级测试代码.docx_第13页
第13页 / 共27页
CRC计算VHDL代码级测试代码.docx_第14页
第14页 / 共27页
CRC计算VHDL代码级测试代码.docx_第15页
第15页 / 共27页
CRC计算VHDL代码级测试代码.docx_第16页
第16页 / 共27页
CRC计算VHDL代码级测试代码.docx_第17页
第17页 / 共27页
CRC计算VHDL代码级测试代码.docx_第18页
第18页 / 共27页
CRC计算VHDL代码级测试代码.docx_第19页
第19页 / 共27页
CRC计算VHDL代码级测试代码.docx_第20页
第20页 / 共27页
亲,该文档总共27页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

CRC计算VHDL代码级测试代码.docx

《CRC计算VHDL代码级测试代码.docx》由会员分享,可在线阅读,更多相关《CRC计算VHDL代码级测试代码.docx(27页珍藏版)》请在冰点文库上搜索。

CRC计算VHDL代码级测试代码.docx

CRC计算VHDL代码级测试代码

CRCComputation

1CRCMatrixComputation(Ref[1])

1.1Dimensionofmatrixis4(Ref[1])

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entitytestbenchis

GENERIC(DM:

INTEGER:

=3);------lengthofmatrixminus1-----------------------

endtestbench;

architecturemtestoftestbenchis

typematrix_typeISarray(DMdownto0)ofstd_logic_vector(DMdownto0);

typeintem_matrix_typeISarray(DMdownto0)ofmatrix_type;

signala,b,c:

matrix_type;

signaltm,tv:

intem_matrix_type;

--constantDM:

integer:

=3;------lengthofmatrixminus1-----------------------

signali,j,k,s,f:

integer;

begin

test:

process

begin

--a<=(('1','0','0','1'),('1','0','1','1'),('1','0','0','0'),('0','0','1','1'));

a<=(('1','1','0','0'),('0','0','1','0'),('0','0','0','1'),('1','0','0','0'));

waitfor20ns;

b<=a;

waitfor20ns;

b<=c;

waitfor20ns;

b<=c;

waitfor20ns;

b<=c;

wait;

endprocesstest;

-----------------the0line------------------------------------------------

Line_all:

FORkin0toDMGENERATE

Line_i:

FORiin0toDMGENERATE

Elem_all_0:

forjin0toDMGENERATE

tm(k)(j)(i)<=a(k)(i)andb(i)(j);

ENDGENERATEElem_all_0;

ENDGENERATELine_i;

ENDGENERATELine_all;

----c(0)(0)<=tm(0)(0)(0)xortm(0)(0)

(1)xortm(0)(0)

(2)xortm(0)(0)(3);-----

allc:

forkin0toDMgenerate

outc:

forjin0toDMgenerate

tv(k)(j)(0)<=tm(k)(j)(0);

c_computation:

foriin0toDM-1generate

tv(k)(j)(i+1)<=tv(k)(j)(i)xortm(k)(j)(i+1);

endgeneratec_computation;

c(k)(j)<=tv(k)(j)(DM);

endgenerateoutc;

endgenerateallc;

endmtest;

Figure1.计算结果图

1.2OriginalVersionofVHDLcode(Ref[1])

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entitytestbenchis

endtestbench;

architecturemtestoftestbenchis

typematrix_typeISarray(3downto0)ofstd_logic_vector(3downto0);

typeintem_matrix_typeISarray(3downto0)ofmatrix_type;

signala,b,c:

matrix_type;

signaltm,tv:

intem_matrix_type;

constantDM:

integer:

=3;------lengthofmatrixminus1-----------------------

signali,j,k:

integer;

begin

test:

process

begin

--a<=(('1','0','0','1'),('1','0','1','1'),('1','0','0','0'),('0','0','1','1'));

a<=(('1','1','0','0'),('0','0','1','0'),('0','0','0','1'),('1','0','0','0'));

waitfor20ns;

b<=a;

waitfor20ns;

b<=c;

waitfor20ns;

b<=c;

waitfor20ns;

b<=c;

wait;

endprocesstest;

-----------------the0line------------------------------------------------

Line_0:

FORiin0toDMGENERATE

Elem_all_0:

forjin0toDMGENERATE

tm(0)(j)(i)<=a(0)(i)andb(i)(j);

ENDGENERATEElem_all_0;

ENDGENERATELine_0;

 

tv(0)(0)(0)<=tm(0)(0)(0);

c_computation:

foriin0toDM-1generate

tv(0)(0)(i+1)<=tv(0)(0)(i)xortm(0)(0)(i+1);

endgeneratec_computation;

c(0)(0)<=tv(0)(0)(DM);

--c(0)(0)<=tm(0)(0)(0)xortm(0)(0)

(1)xortm(0)(0)

(2)xortm(0)(0)(3);

c(0)

(1)<=tm(0)

(1)(0)xortm(0)

(1)

(1)xortm(0)

(1)

(2)xortm(0)

(1)(3);

c(0)

(2)<=tm(0)

(2)(0)xortm(0)

(2)

(1)xortm(0)

(2)

(2)xortm(0)

(2)(3);

c(0)(3)<=tm(0)(3)(0)xortm(0)(3)

(1)xortm(0)(3)

(2)xortm(0)(3)(3);

-----------------the1line------------------------------------------------

Line_1:

FORiin0toDMGENERATE

Elem_all_1:

forjin0toDMGENERATE

tm

(1)(j)(i)<=a

(1)(i)andb(i)(j);

ENDGENERATEElem_all_1;

ENDGENERATELine_1;

c

(1)(0)<=tm

(1)(0)(0)xortm

(1)(0)

(1)xortm

(1)(0)

(2)xortm

(1)(0)(3);

c

(1)

(1)<=tm

(1)

(1)(0)xortm

(1)

(1)

(1)xortm

(1)

(1)

(2)xortm

(1)

(1)(3);

c

(1)

(2)<=tm

(1)

(2)(0)xortm

(1)

(2)

(1)xortm

(1)

(2)

(2)xortm

(1)

(2)(3);

c

(1)(3)<=tm

(1)(3)(0)xortm

(1)(3)

(1)xortm

(1)(3)

(2)xortm

(1)(3)(3);

-----------------the2line------------------------------------------------

Line_2:

FORiin0toDMGENERATE

Elem_all_2:

forjin0toDMGENERATE

tm

(2)(j)(i)<=a

(2)(i)andb(i)(j);

ENDGENERATEElem_all_2;

ENDGENERATELine_2;

c

(2)(0)<=tm

(2)(0)(0)xortm

(2)(0)

(1)xortm

(2)(0)

(2)xortm

(2)(0)(3);

c

(2)

(1)<=tm

(2)

(1)(0)xortm

(2)

(1)

(1)xortm

(2)

(1)

(2)xortm

(2)

(1)(3);

c

(2)

(2)<=tm

(2)

(2)(0)xortm

(2)

(2)

(1)xortm

(2)

(2)

(2)xortm

(2)

(2)(3);

c

(2)(3)<=tm

(2)(3)(0)xortm

(2)(3)

(1)xortm

(2)(3)

(2)xortm

(2)(3)(3);

-----------------the3line------------------------------------------------

Line_3:

FORiin0toDMGENERATE

Elem_all_3:

forjin0toDMGENERATE

tm(3)(j)(i)<=a(3)(i)andb(i)(j);

ENDGENERATEElem_all_3;

ENDGENERATELine_3;

c(3)(0)<=tm(3)(0)(0)xortm(3)(0)

(1)xortm(3)(0)

(2)xortm(3)(0)(3);

c(3)

(1)<=tm(3)

(1)(0)xortm(3)

(1)

(1)xortm(3)

(1)

(2)xortm(3)

(1)(3);

c(3)

(2)<=tm(3)

(2)(0)xortm(3)

(2)

(1)xortm(3)

(2)

(2)xortm(3)

(2)(3);

c(3)(3)<=tm(3)(3)(0)xortm(3)(3)

(1)xortm(3)(3)

(2)xortm(3)(3)(3);

endmtest;

 

1.3Dimensionofmatrixis12(Ref[1])

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entitytestbenchis

GENERIC(DM:

INTEGER:

=11);------lengthofmatrixminus1----------------

endtestbench;

architecturemtestoftestbenchis

typematrix_typeISarray(DMdownto0)ofstd_logic_vector(DMdownto0);

typeintem_matrix_typeISarray(DMdownto0)ofmatrix_type;

signala,b,c:

matrix_type;

signaltm,tv:

intem_matrix_type;

--constantDM:

integer:

=3;------lengthofmatrixminus1-----------------------

signali,j,k,s:

integer;

begin

test:

process

begin

a<=(('1','1','0','0','0','0','0','0','0','0','0','0'),------0----------------

('0','0','1','0','0','0','0','0','0','0','0','0'),------1----------------

('0','0','0','1','0','0','0','0','0','0','0','0'),------2----------------

('0','0','0','0','1','0','0','0','0','0','0','0'),------3----------------

('0','0','0','0','0','1','0','0','0','0','0','0'),------4----------------

('0','0','0','0','0','0','1','0','0','0','0','0'),------5----------------

('0','0','0','0','0','0','0','1','0','0','0','0'),------6----------------

('0','0','0','0','0','0','0','0','1','0','0','0'),------7----------------

('1','0','0','0','0','0','0','0','0','1','0','0'),------8----------------

('1','0','0','0','0','0','0','0','0','0','1','0'),------9----------------

('1','0','0','0','0','0','0','0','0','0','0','1'),------10----------------

('1','0','0','0','0','0','0','0','0','0','0','0')------11----------------

);

waitfor20ns;

b<=a;

s<=1;

waitfor20ns;

b<=c;

s<=2;

waitfor20ns;

b<=c;

s<=3;

waitfor20ns;

b<=c;

s<=4;

waitfor20ns;

b<=c;

s<=5;

waitfor20ns;

b<=c;

s<=6;

waitfor20ns;

b<=c;

s<=7;

waitfor20ns;

b<=c;

s<=8;

waitfor20ns;

b<=c;

s<=9;

waitfor20ns;

b<=c;

s<=10;

waitfor20ns;

b<=c;

s<=11;

waitfor20ns;

b<=c;

s<=12;

waitfor20ns;

wait;

endprocesstest;

-----------------the0line------------------------------------------------

Line_all:

FORkin0toDMGENERATE

Line_i:

FORiin0toDMGENERATE

Elem_all_0:

forjin0toDMGENERATE

tm(k)(j)(i)<=a(k)(i)andb(i)(j);

ENDGENERATEElem_all_0;

ENDGENERATELine_i;

ENDGENERATELine_all;

 

----c(0)(0)<=tm(0)(0)(0)xortm(0)(0)

(1)xortm(0)(0)

(2)xortm(0)(0)(3);-----

allc:

forkin0toDMgenerate

outc:

forjin0toDMgenerate

tv(k)(j)(0)<=tm(k)(j)(0);

c_computation:

foriin0toDM-1generate

tv(k)(j)(i+1)<=tv(k)(j)(i)xortm(k)(j)(i+1);

endgeneratec_computation;

c(k)(j)<=tv(k)(j)(DM);

endgenerateoutc;

endgenerateallc;

endmtest;

1.4Dimensionofmatrixis16(CCITT:

x16+x12+x5+1)(Ref[1])

Figure3.resultsofF16

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_unsigned.all;

entitytestbenchis

GENERIC(DM:

INTEGER:

=15);------lengthofmatrixminus1----------------

endtestbench;

architecturemtestoftestbenchis

typematrix_typeISarray(DMdownto0)ofstd_logic_vector(DMdownto0);

typeintem_matrix_typeISarray(DMdownto0)ofmatrix_type;

signala,b,c:

matrix_type;

signaltm,tv:

intem_matrix_type;

signali,j,k,s:

integer;

begin

test:

process

begin

a<=(('0','1','0','0','0','0','0','0','0','0','0','0','0','0','0','0'),------0----------------

('0','0','1','0','0','0','0','0','0','0','0','0','0','0','0','0'),------1----------------

('0','0','0','1','0','0','0','0','0','0','0','0','0','0','0','0'),------2----------------

('1','0','0','0','1','0','0','0','0','0','0','0','0','0','0','0'),------3----------------

('0','0','0','0','0','1','0','0','0','0','0','0','0','0','0','0'),------4----------------

('0','0','0','0','0','0','1','0','0','0','0','0','0','0','0','0'),------5----------------

('0','0','0','0','0','0','0','1','0','0','0','0','0','0','0','0'),------6----------------

('0','0','0','0','0','0','0','0','1','0','0','0','0','0','0','0'),------7----------------

('0','0','0','0','0','0','0','0','0','1','0','0','0','0','0','0'),------8----------------

('0','0','0','0','0','0','0','0','0','0','1','0','0','0','0','0'),------9----------------

('1','0','0','0','0','0','0','0','0','0','0','1','0','0','0','0'),------a----------------

('0','0','0','0','0','0','0','0','0','0','0','0','1','0','0','0'),------b----------------

('0','0','0','0','0','0','0','0','0','0','0','0','0','1','0','0'),------c----------------

('0','0','0','0','0','0','0','0','0','0','0','0','0','0','1','0'),------d----------------

('0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','1'),------e----------------

('1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0')------f----------------

);

waitfor20ns;

b<=a;

s<=1;

waitfor20ns;

b<=c;

s<=2;

waitfor20ns;

b<=c;

s<=3;

waitfor20ns;

b<=c;

s<=4;

waitfor20ns;

b<=c;

s<=5;

waitfor20ns;

b<=c;

s<=6;

waitfor20ns;

b<=c;

s<=7;

waitfor20ns;

b<=c;

s<=8;

waitfor20ns;

b<=c;

s<=9;

waitfor20ns;

b<=c;

s<=1

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 工程科技 > 能源化工

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2