复杂行为电路描述.docx
- 文档编号:30665163
- 上传时间:2023-08-19
- 格式:DOCX
- 页数:14
- 大小:257.64KB
复杂行为电路描述.docx
《复杂行为电路描述.docx》由会员分享,可在线阅读,更多相关《复杂行为电路描述.docx(14页珍藏版)》请在冰豆网上搜索。
复杂行为电路描述
深圳大学实验报告
课程名称:
EDA技术
实验项目名称:
复杂电路行为描述
学院:
信息工程学院
专业:
电子信息工程
指导教师:
报告人:
学号:
班级:
实验时间:
实验报告提交时间:
教务部制
实验目的与要求:
1、熟悉顺序执行语句,能够自己编写顺序执行程序;
2、区分并掌握变量与信号的区别;
3、掌握程序执行时产生的寄存器数量。
实验内容:
1、优先级编码器
2、通用分频器
3、计时器
4、密度编码器
5、数据时延
实验方法、步骤:
1、优先级编码器
(1)使用IF语句;
写出实验代码如下:
libraryIEEE;
useIEEE.STD_LOGIC_1164.ALL;
useIEEE.STD_LOGIC_ARITH.ALL;
useIEEE.STD_LOGIC_UNSIGNED.ALL;
entityyxjis
Port(din:
inSTD_LOGIC_VECTOR(7downto1);
dout:
outSTD_LOGIC_VECTOR(2downto0));
endyxj;
architectureBehavioralofyxjis
begin
process(din)
variabletemp:
integerrange0to7;
begin
temp:
=0;
foriindin'rangeloop
if(din(i)='1')then
temp:
=i;
exit;
endif;
endloop;
dout<=conv_std_logic_vector(temp,3);
endprocess;
endBehavioral;
(2)使用CASE语句
编写实验代码如下:
libraryIEEE;
useIEEE.STD_LOGIC_1164.ALL;
useIEEE.STD_LOGIC_ARITH.ALL;
useIEEE.STD_LOGIC_UNSIGNED.ALL;
entityyxj2is
Port(din:
inSTD_LOGIC_VECTOR(7downto1);
dout:
outSTD_LOGIC_VECTOR(2downto0));
endyxj2;
architectureBehavioralofyxj2is
begin
process(din)
variabletemp:
integerrange0to7;
begin
temp:
=0;
foriindin'rangeloop
if(din(i)='1')then
temp:
=i;
exit;
endif;
endloop;
casetempis
when0=>dout<="000";
when1=>dout<="001";
when2=>dout<="010";
when3=>dout<="011";
when4=>dout<="100";
when5=>dout<="101";
when6=>dout<="110";
when7=>dout<="111";
endcase;
endprocess;
endBehavioral;
2、通用分频器
写出实验代码如下
(下面程序只能产生偶数倍频):
libraryIEEE;
useIEEE.STD_LOGIC_1164.ALL;
useIEEE.STD_LOGIC_ARITH.ALL;
useIEEE.STD_LOGIC_UNSIGNED.ALL;
entityfenpinqiis
generic(n:
integer:
=2);
Port(clk:
instd_logic;
fn:
outstd_logic);
endfenpinqi;
architectureBehavioraloffenpinqiis
begin
process(clk)
variabletemp:
integer:
=0;
begin
fn<='0';
if(clk'eventandclk='1')then
temp:
=temp+1;
endif;
if(temp=n)then
temp:
=0;
endif;
if(temp fn<='0'; else fn<='1'; endif; endprocess; endBehavioral; 3、计时器 编写实验代码如下: libraryIEEE; useIEEE.STD_LOGIC_1164.ALL; useIEEE.STD_LOGIC_ARITH.ALL; useIEEE.STD_LOGIC_UNSIGNED.ALL; entityjsqis Port(clk: inSTD_LOGIC; start: inSTD_LOGIC; stop: inSTD_LOGIC; reset: inSTD_LOGIC; digit1: outSTD_LOGIC_VECTOR(6downto0); digit2: outSTD_LOGIC_VECTOR(6downto0); digit3: outSTD_LOGIC_VECTOR(6downto0)); endjsq; architectureBehavioralofjsqis begin process(clk,start,stop,reset) variabletemp1: integerrange0to10; variabletemp2: integerrange0to6; variabletemp3: integerrange0to10; begin if(reset='1')then temp1: =0; temp2: =0; temp3: =0; elsif(clk'eventandclk='1'andstart='1'andstop='0')then temp1: =temp1+1; if(temp1=10)then temp2: =temp2+1; temp1: =0; if(temp2=6)then temp3: =temp3+1; temp2: =0; if(temp3=10)then temp3: =0; endif; endif; endif; endif; casetemp1is when0=>digit1<="1111110"; when1=>digit1<="0110000"; when2=>digit1<="1101101"; when3=>digit1<="1111001"; when4=>digit1<="0110011"; when5=>digit1<="1011011"; when6=>digit1<="1011111"; when7=>digit1<="1110000"; when8=>digit1<="1111111"; when9=>digit1<="1111011"; whenothers=>null; endcase; casetemp2is when0=>digit2<="1111110"; when1=>digit2<="0110000"; when2=>digit2<="1101101"; when3=>digit2<="1111001"; when4=>digit2<="0110011"; when5=>digit2<="1011011"; when6=>digit2<="1011111"; whenothers=>null; endcase; casetemp3is when0=>digit3<="1111110"; when1=>digit3<="0110000"; when2=>digit3<="1101101"; when3=>digit3<="1111001"; when4=>digit3<="0110011"; when5=>digit3<="1011011"; when6=>digit3<="1011111"; when7=>digit3<="1110000"; when8=>digit3<="1111111"; when9=>digit3<="1111011"; whenothers=>null; endcase; endprocess; endBehavioral; 4、密度编码器 编写实验代码如下: libraryIEEE; useIEEE.STD_LOGIC_1164.ALL; useIEEE.STD_LOGIC_ARITH.ALL; useIEEE.STD_LOGIC_UNSIGNED.ALL; entitymiduis Port(din: inSTD_LOGIC_VECTOR(7downto1); dout: outSTD_LOGIC_VECTOR(7downto0)); endmidu; architectureBehavioralofmiduis begin process(din) variabletemp: integerrange0to7; begin temp: =0; foriindin'rangeloop if(din(i)='1')then temp: =temp+1; endif; endloop; casetempis when0=>dout<="00000001"; when1=>dout<="00000010"; when2=>dout<="00000100"; when3=>dout<="00001000"; when4=>dout<="00010000"; when5=>dout<="00100000"; when6=>dout<="01000000"; when7=>dout<="10000000"; endcase; endprocess; endBehavioral; 5、数据时延 libraryIEEE; useIEEE.STD_LOGIC_1164.ALL; useIEEE.STD_LOGIC_ARITH.ALL; useIEEE.STD_LOGIC_UNSIGNED.ALL; entityshujushiyanis Port(d: inSTD_LOGIC_VECTOR(3downto0); clk: inSTD_LOGIC; sel: inintegerrange1to4; q: outSTD_LOGIC_VECTOR(3downto0)); endshujushiyan; architectureBehavioralofshujushiyanis signalinternal: std_logic_vector(15downto0): =(others=>'0'); signalq1: std_logic_vector(3downto0): =(others=>'0'); signalq2: std_logic_vector(3downto0): =(others=>'0'); signalq3: std_logic_vector(3downto0): =(others=>'0'); signalq4: std_logic_vector(3downto0): =(others=>'0'); begin process(d,clk,sel) begin if(clk'eventandclk='1')then q1<=d; q2<=q1; q3<=q2; q4<=q3; endif; endprocess; q<=q1whensel=1else q2whensel=2else q3whensel=3else q4; endBehavioral; 实验结果及分析: 1、优先级编码器 (1)使用IF语句得到仿真结果如下: 分析: 根据图中信息,使用IF语句输出结果指出了输入矢量从高位开始出现第一个‘1’的位置‘若输入矢量中没有‘1’,则输出‘000’,满足要求。 (2)使用CASE语句得到仿真结果如下: 分析: 根据图中信息,同上,使用CASE语句输出结果指出了输入矢量从高位开始出现第一个‘1’的位置,若输入矢量中没有‘1’,则输出‘000’,满足要求。 2、通用分频器: 得到的2分频结果如下: 分析: 由于在process(clk)里面用的是clk’eventandclk=’0’,所以只能出现偶数分频,上图是二分频的仿真结果。 3、计时器 仿真结果如下: 分析: 在第一个上升沿来临时,start=’1’,stop=’0’,reset=’0’,开始计数,应计时到0: 01;在第三个上升沿来临时,reset=’1’,所以复位,全部置0;第五个上升沿来临时,stop=’1’,所以暂停计时一个周期,之后继续计时;在第七个上升沿来临时,start=’0’,跟stop类似,暂停计时一个周期,之后继续计时。 由于对ISE的功能了解不全面,时钟周期未能设置为1S(当设置为1S时,仿真结果有误)。 若把时钟周期看为1S,则符合要求。 4、密度编码器 分析: 由图观察,当输入矢量din中出现n个’1’时,那么输出矢量dout(n)=’1’,dout(m)=’0’ (m≠n),满足要求。 5、数据时延 分析: sel=2时,输出信号延后输入信号两个周期,与要求一致。 寄存器分析: 由程序可知,当clk为上升沿时,q1、q2、q3、q4分别同时被赋值,所以理论上应产生4个寄存器,实验编译后实际产生的寄存器如下图: 可知,程序编译产生了4个寄存器,与理论分析符合。 实验心得 1、写程序要戒骄戒躁,不可急于求成。 2、写的程序有时候在仿真的时候可能会与书上的不一样,这时需要好好分析,不能尽信书。 指导教师批阅意见: 成绩评定: 指导教师签字: 年月日 备注: 注: 1、报告内的项目或内容设置,可根据实际情况加以调整和补充。 2、教师批改学生实验报告时间应在学生提交实验报告时间后10日内。
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 复杂 行为 电路 描述