s:
=s+1;
elses:
=0;
endif;
endif;
ifs=tthenfull<='1';
elsefull<='0';
endif;
endprocessP2;
P3:
process(full)
variablec:
std_logic;
begin
iffull'eventandfull='1'then
c:
=notc;
ifc='1'then
oclk<='1';
elseoclk<='0';
endif;
endif;
endprocessP3;
end;
其仿真波形为:
3、测频
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entitycpis
port(clkk:
instd_logic;
en,rst,load:
outstd_logic);
end;
architecturecp_1ofcpis
signaldiv2:
std_logic;
begin
process(clkk)
begin
if(clkk'eventandclkk='1')then
div2<=notdiv2;
endif;
endprocess;
process(clkk,div2)
begin
if(clkk='0'anddiv2='0')then
rst<='1';
elserst<='0';
endif;
endprocess;
load<=notdiv2;
en<=div2;
end;
其仿真波形为:
4、计数器
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entityjishuis
port(rst,en,clk:
instd_logic;
Q:
outstd_logic_vector(3downto0);
cout:
outstd_logic);
end;
architecturecntofjishuis
signalcnt:
std_logic_vector(3downto0);
begin
process(rst,en,clk)
begin
ifrst='1'thencnt<="0000";
elsif(clk'eventandclk='1')anden='1'then
ifcnt="1001"then
cnt<="0000";cout<='1';
else
cnt<=cnt+1;
cout<='0';
endif;
endif;
endprocess;
Q<=cnt;
end;
在源程序中COUT是计数器的进位输出;Q[3..0]是计数器的状态输出;CLK是时钟输入端;RST是复位控制端;当RST=1时,Q[3..0]=0,EN是使能控制输入端,当EN=1时,计数器计数,当EN=0时,计数器保持状态不变。
编译成功后,其仿真波形如下:
在项目编译仿真成功后,将设计的十进制计数器电路设置成可调用的元件jishu.sym用于以下的顶层设计。
5、16位寄存器
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entitysuocunis
port(load:
instd_logic;
din:
instd_logic_vector(15downto0);
dout:
outstd_logic_vector(15downto0));
end;
architecturesuoofsuocunis
begin
process(load,din)
begin
if(load'eventandload='1')then
dout<=din;
endif;
endprocess;
end;
在源程序中load是锁存信号,上升沿触发;din[3..0]是寄存器输入;dout[3..0]是寄存器输出。
编译成功后生成元件图如下图,以便顶层模块的调用。
4位寄存器
寄存器是在计数结束后,利用触发器的上升沿吧最新的频率测量值保存起来,这样在计数的过程中可不必一直看数码显示器,显示器将最终的频率读数定期进行更新,其输出作为动态扫描电路的输入。
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entitysuois
port(load:
instd_logic;
din:
instd_logic_vector(3downto0);
dout:
outstd_logic_vector(3downto0));
end;
architecturesuo_1ofsuois
begin
process(load,din)
begin
if(load'eventandload='1')then
dout<=din;
endif;
endprocess;
end;
在源程序中load是锁存信号,上升沿触发;din[3..0]是寄存器输入;dout[3..0]是寄存器输出。
编译成功后生成元件图如下图,以便顶层模块的调用。
6、译码器
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entityledsis
port(clk:
instd_logic;
Din:
instd_logic_vector(15downto0);
sg:
outstd_logic_vector(6downto0);
bt:
outstd_logic_vector(1downto0));
end;
architectureled_1ofledsis
signalcnt8:
std_logic_vector(1downto0);
signalq:
std_logic_vector(3downto0);
begin
P1:
process(cnt8,Din,q)
begin
casecnt8is
when"00"=>bt<="00";q<=Din(3downto0);
when"01"=>bt<="01";q<=Din(7downto4);
when"10"=>bt<="10";q<=Din(11downto8);
when"11"=>bt<="11";q<=Din(15downto12);
whenothers=>null;
endcase;
caseqis
when"0000"=>sg<="0111111";
when"0001"=>sg<="0000110";
when"0010"=>sg<="1011011";
when"0011"=>sg<="1001111";
when"0100"=>sg<="1100110";
when"0101"=>sg<="1101101";
when"0110"=>sg<="1111101";
when"0111"=>sg<="0000111";
when"1000"=>sg<="1111111";
when"1001"=>sg<="1101111";
whenothers=>null;
endcase;
endprocessP1;
P2:
process(clk)
begin
if(clk'eventandclk='1')then
cnt8<=cnt8+1;
endif;
endprocessP2;
end;
编译成功后,其波形图为:
7、译码
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entitydividis
port(clk50:
instd_logic;
qlkhz:
outstd_logic);
end;
architecturedivofdividis
begin
K1:
process(clk50)
variablecout:
integer:
=0;
begin
if(clk50'eventandclk50='1')then
cout:
=cout+1;
ifcout<=24999thenqlkhz<='1';
elsifcout<=49999thenqlkhz<='1';
elsecout:
=0;
endif;
endif;
endprocess;
end;
编译成功后,其波形图为:
8、动态扫描电路
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entitydongtaiis
port(q200hz:
instd_logic;
bt:
instd_logic_vector(1downto0);
sg:
instd_logic_vector(6downto0);
led0,led1,led2,led3:
outstd_logic_vector(6downto0));
end;
architecturebehavofdongtaiis
begin
process(q200hz)
begin
if(q200hz'eventandq200hz='1')then
casebtis
when"00"=>led0<=sg(6downto0);
when"01"=>led1<=sg(6downto0);
when"10"=>led2<=sg(6downto0);
when"11"=>led3<=sg(6downto0);
whenothers=>null;
endcase;
endif;
endprocess;
end;
仿真波形如下:
编译成功后生成元件图如下图,以便顶层模块的调用。
9、分频设计
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_signed.all;
entityfpis
port(clk:
instd_logic;
oclk:
outstd_logic);
end;
architecturefp_1offpis
signalfull:
std_logic;
begin
P1:
process(clk)
variables:
integerrange0to99;
begin
if(clk'eventandclk='1')then
ifs<99then
s:
=s+1;
elsifs>99thens:
=0;
elsifs=99thenfull<='1';
endif;
endif;
endprocessP1;
P2:
process(full)
variablec:
std_logic;
begin
iffull='1'then
c:
=notc;
ifc='1'then
oclk<='1';
elseoclk<='0';
endif;
endif;
endprocessP2;
end;
编译成功后,其波形图为:
三.设计体会
通过对EDA技术这门课程的学习,心得体会甚多。
虽然一开始觉得什么都不懂,但是通过一次次的实验,我们真的学到了不少的东西。
往往书本上的知识在实际使用或实验时都应该加以修改,使之更适合实际应用,也更简洁。
这次EDA课程设计,使我更加的了解了EDA,VHDL语言和外部设备的接线。
也让我更加了解了EDA设计的流程和原理。
通过本次设计,让我很好的锻炼了理论联系实际,与具体项目、课题相结合开发、设计产品的能力。
既让我们懂得了怎样把理论应用于实际,又让我们懂得了在实践中遇到的问题怎样用理论去解决。
在本次设计中,我们还需要一些上课时没有牢固的知识,于是图书馆和INTERNET成了我们很好的助手。
在查阅资料的过程中,我们要判断优劣、取舍相关知识,不知不觉中我们查阅资料的能力也得到了很好的锻炼。
我们学习的知识是有限的,在以后的工作中我们肯定会遇到许多未知的领域,这方面的能力便会使我们受益非浅。
在设计过程中,总是遇到这样或那样的问题。
有时发现一个问题的时候,需要做大量的工作,花大量的时间才能解决。
自然而然,我的耐心便在其中建立起来了。
为以后的工作积累了经验,增强了信心。
我认为,不仅仅是此次考查设计,在整个这学期的实验中,不仅培养了独立思考、动手操作的能力,在各种其它能力上也都有了提高。
更重要的是,在实验课上,我们学会了很多学习的方法。
而这是日后罪实用的,真的是受益匪浅。
我已从中真正体会到了,做设计不是为顺利完成而做,而是为了学会遇到问题懂得去解决而做。
虽然实践问题会遇到很多,每一次实验其实真的可以让人学到很多知识。
只有自己懂得去总结,才能从中体会到收获。
四.参考文献:
[1]潘松VHDL实用教程[M]成都电子科技大学出版社,2000
[2]卢毅,赖杰VHDL与数字电路设计[M]北京科学出版社,2001[3]徐志军大规模可编程逻辑器件及其应用[M]成都电子科技大学出版社,2004.2
[4]赵曙光可编程逻辑器件原理、开发与应用[M]西安电子科技大学出版社,2000.6