二、设计方案
2.1调制程序
libraryieee;
useieee.std_logic_arith.all; useieee.std_logic_1164.all; useieee.std_logic_unsigned.all; entityPPPL_FSKis port(clk:instd_logic; start:instd_logic; x:instd_logic; y:outstd_logic); endPPPL_FSK;
architecturebehavofPPPL_FSKis signalq1:integerrange0to15; signalq2:integerrange0to3; signalf1,f2:std_logic; begin process(clk) begin
ifclk'eventandclk='1'then ifstart='0'thenq1<=0;
elsifq1<=7thenf1<='1';q1<=q1+1;
elsifq1=15thenf1<='0';q1<=0; elsef1<='0';q1<=q1+1; endif endif; endprocess; process(clk) begin
ifclk'eventandclk='1'then ifstart='0'thenq2<=0;
elsifq2<=0thenf2<='1';q2<=q2+1; elsifq2=1thenf2<='0';q2<=0; elsef2<='0';q2<=q2+1; endif;
endif; endprocess; process(clk,x) begin
ifclk'eventandclk='1'then ifx='0'theny<=f1; elsey<=f2; endif; endif; endprocess; endbehav;
2.2解调程序
libraryieee;
useieee.std_logic_arith.all; useieee.std_logic_1164.all; useieee.std_logic_unsigned.all; entityDL_FSKis port(clk:instd_logic; start:instd_logic; x:instd_logic; y:outstd_logic); endDL_FSK;
architecturebehavofDL_FSKis signalq:integerrange0to15; signalxx:std_logic; signalm:integerrange0to5; begin process(clk) begin
ifclk'eventandclk='1'thenxx<=x; ifstart='0'thenq<=0; elsifq=15thenq<=0; elseq<=q+1; endif; endif; endprocess; process(xx,q) begin
ifq=15thenm<=0; elsifq=10then ifm<=3theny<='0'; elsey<='1'; endif;
elsifxx'eventandxx='1'thenm<=m+1; endif; endprocess; endbehav;
三、仿真
3.1 2FSK信号的调制波形仿真
工程编译通过后,有必要对其功能和时序性进行详细的仿真测试,已验证设计结果是否满足设计要求。整个时序仿真测试流程有,建立波形文件、输入信号、设置波形参数编辑输入信号、波形文件存盘、运行仿真器和分析仿真波形等步骤。 [1]建立仿真波形文件。即选择File菜单的New选项,在弹出的文件类型编辑对话框中,选择Other Files中的Vector Weaveform File项,单击OK按钮,即出现波形文件窗口。
[2]设置仿真时间区域。对于时序仿真测试来说,将仿真时间设置在一个合理时间区域是十分重要的,一般视实际情况具体而定。本设计调制部分将仿真时间区域设为6us、周期为40ns其设计步骤实在Edit菜单中选择End Time,在弹出的Time处填上6,同理在Gride Size中Time period输入40ns,单击OK按钮。 [3]输入各工程信号的节点。即选择View菜单中的Utility Windows项的Node Finder,即可弹出如图3-6所示的对话框,在此对话框Filter项中选
Pins:all&Registers:Post-fitting,然后单击List按钮,于是在下方的Nodes Found窗口中出现设计中的PPPL_FSK工程的所有端口的引脚注明。用鼠标将时钟信号节点clk、start、x、q1、f1、q2、f2和y分别拖到波形编辑窗口,如下图所示。
图3-6 2FSK调制波形编辑器输入信号窗口
[4]设计信号波形,首先单击左侧的全屏显示按钮,使之处于适当的位置。单击时钟信号clk使之变成蓝色条,再单击右键,选择Value设置中的Count Value项,设置clk为连续变化的二进制数值,初始值为0,。单击start使之成为蓝色,再单击右键,选择Value设置中的Forcing High项,使得start变成高电平信号。单击x使之变成蓝色,再单击Waveform Editing按钮,把x变成高低电平连续变化的信号。
[5]文件存盘。选择File中的Save As项,将波形文件以默认名PPPL_FSK.vwf存盘即可。
[6]所有设置完毕后,即可启动仿真器Processing/start simulation直到出现Simulation was successful,仿真结束。仿真波形输出文件PPPL_FSK Simulation Report将自动弹出仿真图形。注意,Quartus‖的仿真波形文件中,波形编辑文件与波形仿真报告输出文件是分开的。图3-7显示了2FSK信号的调制仿真结果。
图3-7 2FSK信号的调制仿真结果图