VHDL中数组的定义和使用

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

VHDL中数组的定义和使用

为了帮助网友解决“VHDL中数组的定义和使用?”相关的问题,中国学网通过互联网对“VHDL中数组的定义和使用?”相关的解决方案进行了整理,用户详细问题包括:RT,我想知道:VHDL中数组的定义和使用?,具体解决方案如下:解决方案1:

--定义matrix_index为数组

TYPEmatrix_indexisarray(3downto0)ofstd_logic_vector(7downto0); SIGNALa:matrix_index;--定义了数组a[4],即数组元素为a[0],a[1],a[2],a[3]

constantR:matrix_index:=(x"15",x"0F",x"0A",x"06");--定义了常数数组R[4]

--使用时跟C语言中一样,加下标就可以了,上面是用downto定义了方向,故R[0]是最后一项,如在R数组中R[0]=X"06",R[3]=X"15" 以上不知道说清楚了没,满意请及时采纳

我看还是补充一段参考程序吧

---------------------------------------

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_arith.all;

useieee.std_logic_unsigned.all;

ENTITYshift_row_invIS

PORT(

shiftrow_in:INSTD_LOGIC_VECTOR(127DOWNTO0);

shiftrow_out:OUTSTD_LOGIC_VECTOR(127DOWNTO0)

);

ENDshift_row_inv;

ARCHITECTUREbehOFshift_row_invIS

--typedescribingthebytearrayconsistingof16bytematrixarray TYPEmatrix_indexisarray(15downto0)ofstd_logic_vector(7downto0); SIGNALb,c:matrix_index;

BEGIN

--initialmappingofinputintoabytematrixarraynamedb

matrix_mapping:PROCESS(shiftrow_in)

BEGIN

FORiIN15DOWNTO0LOOP

b(15-i)<=shiftrow_in(8*i+7DOWNTO8*i);

ENDLOOP;

ENDPROCESSmatrix_mapping;

--shiftrowtransformation

--b(i)-->c(i)

--

--|04812||04812|(noshift)

--|15913|==>|13159|(1rightshift)

--|261014||101426|(2rightshift) --|371115||711153|(3rightshift)

--shiftedfirstcolumn

c(0)<=b(0);

c(1)<=b(13);

c(2)<=b(10);

c(3)<=b(7);

--shiftedsecondcolumn

c(4)<=b(4);

c(5)<=b(1);

c(6)<=b(14);

c(7)<=b(11);

--shfitedthirdcolumn

c(8)<=b(8);

c(9)<=b(5);

c(10)<=b(2);

c(11)<=b(15);

--shiftedforthcolumn

c(12)<=b(12);

c(13)<=b(9);

c(14)<=b(6);

c(15)<=b(3);

--mappingtemporarycvectorintoshiftedrowoutput matrix_mapping_back:PROCESS(c)

BEGIN

FORiIN15DOWNTO0LOOP

shiftrow_out(8*i+7DOWNTO8*i)<=c(15-i); ENDLOOP;

ENDPROCESSmatrix_mapping_back; ENDbeh;

相关文档
最新文档