vhdl语言实验报告.docx

上传人:b****6 文档编号:7984058 上传时间:2023-01-27 格式:DOCX 页数:15 大小:102.68KB
下载 相关 举报
vhdl语言实验报告.docx_第1页
第1页 / 共15页
vhdl语言实验报告.docx_第2页
第2页 / 共15页
vhdl语言实验报告.docx_第3页
第3页 / 共15页
vhdl语言实验报告.docx_第4页
第4页 / 共15页
vhdl语言实验报告.docx_第5页
第5页 / 共15页
点击查看更多>>
下载资源
资源描述

vhdl语言实验报告.docx

《vhdl语言实验报告.docx》由会员分享,可在线阅读,更多相关《vhdl语言实验报告.docx(15页珍藏版)》请在冰豆网上搜索。

vhdl语言实验报告.docx

vhdl语言实验报告

电子设计自动化

多路波形发生器

指导老师:

刘彪

 

电气工程学院

电气1003班

杨黎

10291094

2012年10月27日

一、实验题目要求

1、对输入时钟信号进行分频,实现三路互差120°

的信号。

2、实现输出信号的占空比控制

clk:

输入时钟信号

reset:

同步复位信号(低电平有效)

div:

输入分频控制信号(注意:

6n分频)

ctrl:

占空比控制信号

ctrl=1时,占空比为1:

1

ctrl=2时,占空比为1:

2

ctrl=3时,占空比为2:

1

A,B,C:

三路输出信号

二、设计思路及方案

1、多路发生器的基本原理分频器而且是可调的。

因此可以先设计多个子程序分别使得信号发生器的产生的占空比分别为1:

1,1:

2,2:

1;因此先设div:

integerrange1to4;。

通过信号赋值(tmp,tmp1,tmp2)赋给输出信号A,B,C.通过n改变输出频率。

定义各个变量。

2、当resetb=0时,countQ=0;

当resetb=1时。

给脉冲时先定义分频比如果countQ<(6*div-1)时countQ<=countQ否则countQ为0。

3、当cltr=01时即H:

L=1:

1时

①如果countQ<3*div时tmp<=’0’;否者tmp<=’1’

②如果countQ<2*divorcountQ>(6*div-2))时tmp1<='1';

否者tmp1<='0';

③如果countQ(4*div-1)时tmp2<='0';

④否者tmp2<='1';

⑤A等于tmp;B=tmp2;C=tmp3;

同理:

当cltr=10时即H:

L=1:

2时

当cltr=11时即H:

L=2:

1时。

其中;公式推导如下:

当div=1,cltr=01时当div=2,cltr=01时

countQ<6countQ<12

A:

000111;A:

000000111111

B:

110001;B:

111100000011

C:

011100;C:

001111110000

A:

countQ<3时tmp=0A;countQ<6时tmp=0

Elsetmp=1Elsetmp=1

B:

countQ<2orcountQ>4时tmp=1B:

countQ<4orcountQ>10,tmp=1

Elsetmp=0Elsetmp=0

C:

countQ<1orcountQ>3时tmp=0C:

countQ<2orcountQ>7时tmp=0

Elsetmp=1Elsetmp=1

同理:

cltr=10,cltr=11.

当cltr=01时

if(countQ<3*div)thentmp<='0';elsetmp<='1';

if(countQ<2*divorcountQ>(6*div-2))thentmp1<='1';elsetmp1<='0';

if(countQ(4*div-1))thentmp2<='0';elsetmp2<='1';

当cltr=10时

if(countQ<4*div)thentmp<='0';elsetmp<='1';

if(countQ<2*div)thentmp1<='1';elsetmp1<='0';

if(countQ<2*divorcountQ>(4*div-1))thentmp2<='0';elsetmp2<='1';

当cltr=11时

if(countQ<2*div)thentmp<='0';elsetmp<='1';

if(countQ<2*divorcountQ>(4*div-1))thentmp1<='1';elsetmp1<='0';

if(countQ<4*div)thentmp2<='1';elsetmp2<='0';

将信号tmp赋给A;tmp1赋给B;tmp2赋给C;

三、流程图

Reset=0?

01

Tmp、tmp1、tmp2=0

是否有信号输入

Tmp=atmp1=btmp2=c

判定ctrl的值

123

调用相应的子程序

四、实验程序及其波形

libraryieee;

useieee.std_logic_1164.all;

useieee.std_logic_arith.all;

useieee.std_logic_unsigned.all;

entityfashengqis

port

clk:

instd_logic;

aclk:

outstd_logic;

bclk:

outstd_logic;

cclk:

outstd_logic;

resetb:

instd_logic;

div:

instd_logic_vector(1downto0);

ctrl:

instd_logic_vector(1downto0)

);

endfangshengq;

architecturebehaveoffangshengqis

signaltmp:

std_logic;

signaltmp1:

std_logic;

signaltmp2:

std_logic;

signalcnt0:

integerrange0to5:

=0;

signalcnt1:

integerrange0to11:

=0;

signalcnt2:

integerrange0to17:

=0;

signalcnt3:

integerrange0to23:

=0;

begin

process(clk,resetb,div,ctrl)

begin

ifclk'eventandclk='1'then

ifresetb='0'then

cnt0<=0;

cnt1<=0;

cnt2<=0;

cnt3<=0;

tmp<='0';

tmp1<='0';

tmp2<='0';

elsifresetb='1'then

cnt0<=cnt0+1;

cnt1<=cnt1+1;

cnt2<=cnt2+1;

cnt3<=cnt3+1;

casectrlis

when"01"=>

casedivis

when"00"=>

casecnt0is

when0=>tmp<='0';tmp1<='1';tmp2<='0';

when1=>tmp<='0';tmp1<='1';tmp2<='1';

when2=>tmp<='0';tmp1<='0';tmp2<='1';

when3=>tmp<='1';tmp1<='0';tmp2<='1';

when4=>tmp<='1';tmp1<='0';tmp2<='0';

when5=>tmp<='1';tmp1<='1';tmp2<='0';cnt0<=0;

endcase;

when"01"=>

casecnt1is

when0=>tmp<='0';tmp1<='1';tmp2<='0';

when1=>tmp<='0';tmp1<='1';tmp2<='0';

when2=>tmp<='0';tmp1<='1';tmp2<='1';

when3=>tmp<='0';tmp1<='1';tmp2<='1';

when4=>tmp<='0';tmp1<='0';tmp2<='1';

when5=>tmp<='0';tmp1<='0';tmp2<='1';

when6=>tmp<='1';tmp1<='0';tmp2<='1';

when7=>tmp<='1';tmp1<='0';tmp2<='1';

when8=>tmp<='1';tmp1<='0';tmp2<='0';

when9=>tmp<='1';tmp1<='0';tmp2<='0';

when10=>tmp<='1';tmp1<='1';tmp2<='0';

when11=>tmp<='1';tmp1<='1';tmp2<='0';cnt1<=0;

endcase;

when"10"=>

casecnt2is

when0=>tmp<='0';tmp1<='1';tmp2<='0';

when1=>tmp<='0';tmp1<='1';tmp2<='0';

when2=>tmp<='0';tmp1<='1';tmp2<='0';

when3=>tmp<='0';tmp1<='1';tmp2<='1';

when4=>tmp<='0';tmp1<='1';tmp2<='1';

when5=>tmp<='0';tmp1<='1';tmp2<='1';

when6=>tmp<='0';tmp1<='0';tmp2<='1';

when7=>tmp<='0';tmp1<='0';tmp2<='1';

when8=>tmp<='0';tmp1<='0';tmp2<='1';

when9=>tmp<='1';tmp1<='0';tmp2<='1';

when10=>tmp<='1';tmp1<='0';tmp2<='1';

when11=>tmp<='1';tmp1<='0';tmp2<='1';

when12=>tmp<='1';tmp1<='0';tmp2<='0';

when13=>tmp<='1';tmp1<='0';tmp2<='0';

when14=>tmp<='1';tmp1<='0';tmp2<='0';

when15=>tmp<='1';tmp1<='1';tmp2<='0';

when16=>tmp<='1';tmp1<='1';tmp2<='0';

when17=>tmp<='1';tmp1<='1';tmp2<='0';cnt2<=0;

endcase;

when"11"=>

casecnt3is

when0=>tmp<='0';tmp1<='1';tmp2<='0';

when1=>tmp<='0';tmp1<='1';tmp2<='0';

when2=>tmp<='0';tmp1<='1';tmp2<='0';

when3=>tmp<='0';tmp1<='1';tmp2<='0';

when4=>tmp<='0';tmp1<='1';tmp2<='1';

when5=>tmp<='0';tmp1<='1';tmp2<='1';

when6=>tmp<='0';tmp1<='1';tmp2<='1';

when7=>tmp<='0';tmp1<='1';tmp2<='1';

when8=>tmp<='0';tmp1<='0';tmp2<='1';

when9=>tmp<='0';tmp1<='0';tmp2<='1';

when10=>tmp<='0';tmp1<='0';tmp2<='1';

when11=>tmp<='0';tmp1<='0';tmp2<='1';

when12=>tmp<='1';tmp1<='0';tmp2<='1';

when13=>tmp<='1';tmp1<='0';tmp2<='1';

when14=>tmp<='1';tmp1<='0';tmp2<='1';

when15=>tmp<='1';tmp1<='0';tmp2<='1';

when16=>tmp<='1';tmp1<='0';tmp2<='0';

when17=>tmp<='1';tmp1<='0';tmp2<='0';

when18=>tmp<='1';tmp1<='0';tmp2<='0';

when19=>tmp<='1';tmp1<='0';tmp2<='0';

when20=>tmp<='1';tmp1<='1';tmp2<='0';

when21=>tmp<='1';tmp1<='1';tmp2<='0';

when22=>tmp<='1';tmp1<='1';tmp2<='0';

when23=>tmp<='1';tmp1<='1';tmp2<='0';cnt3<=0;

endcase;

endcase;

when"10"=>

casedivis

when"00"=>

casecnt0is

when0=>tmp<='0';tmp1<='1';tmp2<='0';

when1=>tmp<='0';tmp1<='1';tmp2<='0';

when2=>tmp<='0';tmp1<='0';tmp2<='1';

when3=>tmp<='0';tmp1<='0';tmp2<='1';

when4=>tmp<='1';tmp1<='0';tmp2<='0';

when5=>tmp<='1';tmp1<='0';tmp2<='0';cnt0<=0;

endcase;

when"01"=>

casecnt1is

when0=>tmp<='0';tmp1<='1';tmp2<='0';

when1=>tmp<='0';tmp1<='1';tmp2<='0';

when2=>tmp<='0';tmp1<='1';tmp2<='0';

when3=>tmp<='0';tmp1<='1';tmp2<='0';

when4=>tmp<='0';tmp1<='0';tmp2<='1';

when5=>tmp<='0';tmp1<='0';tmp2<='1';

when6=>tmp<='0';tmp1<='0';tmp2<='1';

when7=>tmp<='0';tmp1<='0';tmp2<='1';

when8=>tmp<='1';tmp1<='0';tmp2<='0';

when9=>tmp<='1';tmp1<='0';tmp2<='0';

when10=>tmp<='1';tmp1<='0';tmp2<='0';

when11=>tmp<='1';tmp1<='0';tmp2<='0';cnt1<=0;

endcase;

when"10"=>

casecnt2is

when0=>tmp<='0';tmp1<='1';tmp2<='0';

when1=>tmp<='0';tmp1<='1';tmp2<='0';

when2=>tmp<='0';tmp1<='1';tmp2<='0';

when3=>tmp<='0';tmp1<='1';tmp2<='0';

when4=>tmp<='0';tmp1<='1';tmp2<='0';

when5=>tmp<='0';tmp1<='1';tmp2<='0';

when6=>tmp<='0';tmp1<='0';tmp2<='1';

when7=>tmp<='0';tmp1<='0';tmp2<='1';

when8=>tmp<='0';tmp1<='0';tmp2<='1';

when9=>tmp<='0';tmp1<='0';tmp2<='1';

when10=>tmp<='0';tmp1<='0';tmp2<='1';

when11=>tmp<='0';tmp1<='0';tmp2<='1';

when12=>tmp<='1';tmp1<='0';tmp2<='0';

when13=>tmp<='1';tmp1<='0';tmp2<='0';

when14=>tmp<='1';tmp1<='0';tmp2<='0';

when15=>tmp<='1';tmp1<='0';tmp2<='0';

when16=>tmp<='1';tmp1<='0';tmp2<='0';

when17=>tmp<='1';tmp1<='0';tmp2<='0';cnt2<=0;

endcase;

when"11"=>

casecnt3is

when0=>tmp<='0';tmp1<='1';tmp2<='0';

when1=>tmp<='0';tmp1<='1';tmp2<='0';

when2=>tmp<='0';tmp1<='1';tmp2<='0';

when3=>tmp<='0';tmp1<='1';tmp2<='0';

when4=>tmp<='0';tmp1<='1';tmp2<='0';

when5=>tmp<='0';tmp1<='1';tmp2<='0';

when6=>tmp<='0';tmp1<='1';tmp2<='0';

when7=>tmp<='0';tmp1<='1';tmp2<='0';

when8=>tmp<='0';tmp1<='0';tmp2<='1';

when9=>tmp<='0';tmp1<='0';tmp2<='1';

when10=>tmp<='0';tmp1<='0';tmp2<='1';

when11=>tmp<='0';tmp1<='0';tmp2<='1';

when12=>tmp<='0';tmp1<='0';tmp2<='1';

when13=>tmp<='0';tmp1<='0';tmp2<='1';

when14=>tmp<='0';tmp1<='0';tmp2<='1';

when15=>tmp<='0';tmp1<='0';tmp2<='1';

when16=>tmp<='1';tmp1<='0';tmp2<='0';

when17=>tmp<='1';tmp1<='0';tmp2<='0';

when18=>tmp<='1';tmp1<='0';tmp2<='0';

when19=>tmp<='1';tmp1<='0';tmp2<='0';

when20=>tmp<='1';tmp1<='0';tmp2<='0';

when21=>tmp<='1';tmp1<='0';tmp2<='0';

when22=>tmp<='1';tmp1<='0';tmp2<='0';

when23=>tmp<='1';tmp1<='0';tmp2<='0';cnt3<=0;

endcase;

endcase;

when"11"=>

casedivis

when"00"=>

casecnt0is

when0=>tmp<='0';tmp1<='1';tmp2<='1';

when1=>tmp<='0';tmp1<='1';tmp2<='1';

when2=>tmp<='1';tmp1<='0';tmp2<='1';

when3=>tmp<='1';tmp1<='0';tmp2<='1';

when4=>tmp<='1';tmp1<='1';tmp2<='0';

when5=>tmp<='1';tmp1<='1';tmp2<='0';cnt0<=0;

endcase;

when"01"=>

casecnt1is

when0=>tmp<='0';tmp1<='1';tmp2<='1';

when1=>tmp<='0';tmp1<='1';tmp2<='1';

when2=>tmp<='0';tmp1<='1';tmp2<='1';

when3=>tmp<='0';tmp1<='1';tmp2<='1';

when4=>tmp<='1';tmp1<='0';tmp2<='1';

when5=>tmp<='1';tmp1<='0';tmp2<='1';

when6=>tmp<='1';tmp1<='0';tmp2<='1';

when7=>tmp<='1';tmp1<='0';tmp2<='1';

when8=>tmp<='1';tmp1<='1';tmp2<='0';

when9=>tmp<='1';tmp1<='1';tmp2<='0';

when10=>tmp<='1';tmp1<='1';tmp2<='0';

when11=>tmp<='1';tmp1<='1';tmp2<='0';cnt1<=0;

endcase;

when"10"=>

casecnt2is

when0=>tmp<='0';tmp1<='1';tmp2<='1';

when1=>tmp<='0';tmp1<='1';tmp2<='1';

when2=>tmp<='0';tmp1<='1';tmp2<='1';

when3=>tmp<='0';tmp1<='1';tmp2<='1';

when4=>tmp<='0';tmp1<='1';tmp2<='1';

when5=>tmp<='0';tmp1<='1';tmp2<='1';

when6=>tmp<='1';tmp1<='0';tmp2<='1';

when7=>tmp<='1';tmp1<='0';tmp2<='1';

when8=>tmp<='1';tmp1<='0';tmp2<='1';

when9=>tmp<='1';tmp1<='0';tmp2<='1';

when10=>tmp<='1';tmp1<='0';tmp2<='1';

when11=>tmp<='1';tmp1<='0';tmp2<='1';

when12=>tmp<='1';tmp1<='1';tmp2<='0';

when13=>tmp<='1';tmp1<='1';tmp2<='0';

when14=>tmp<='1';tmp1<='1';tmp2<='0';

when15=>tmp<='1';tmp1<='1';tmp2<='0';

when16=>tmp<='1';tmp1<='1';tmp2<='0';

when17=>tmp<='1';tmp1<='1';tmp2<='0';cnt2<=0;

endcase;

when"11"=>

casecnt3is

when0=>tmp<='0';tmp1<='1';tmp2<='1';

when1=>tmp<='0';tmp1<='1';tmp2<='1';

when2=>tmp<='0';tmp1<='1';tmp2<='1';

when3=>tmp<='0';tmp1<='1';tmp2<='1';

when4=>tmp<='0';tmp1<='1';tmp2<='1';

when5=>tmp<='0';tmp1<='1';tmp2<='1';

when6=>tmp<='0';tmp1<='1';tmp2<='1';

when7=>tmp<='0';tmp1<='1';t

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

当前位置:首页 > 人文社科 > 文学研究

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1