课 程 设 计
题 目:EDA拔河游戏机课程设计
作 者: XXX
专 业: 动化
班 级: XXX
学 号: XXXXX
指导老师: XXX
2012年X月X日
容基求参考资料等
容:
电子拔河游戏机种容纳甲乙双方参赛游戏电路排发光二极表示拔河电子绳甲乙双方通纽开关发光二极方终点延伸延伸某方发光二极时 该方获胜连续赛局定胜负
基求:
1设计进行拔河游戏电路
2电路9发光二极开机中间发亮拔河中心点
3游戏双方持钮迅速断动产生脉谁快亮点谁方移动次亮点移动次
4亮点移方终端二极时方获胜时双方钮均作输出保持复位亮点恢复中心
5数码显示获胜者盘数
参考资料:
[1] 潘松著EDA技术实教程(第二版) 北京:科学出版社2005
[2] 康华光编电子技术基础 模拟部分 北京:高教出版社2006
[3] 阎石编数字电子技术基础 北京:高教出版社2003
总体设计思想
1基原理
设计容知需十进制计数器双方钮次数计数通译码器显示数码设计求50MHz频率设计1KHz频率设计程序进行分频显视控制部分设计求发光二极显示游戏状态双方十次亮点先十次移动次脉进行计数十次移位需接入清零端复位程序组装起
2设计框图
译码器
编码
电路
选择
开关
整形
电路
逆
计数器
控制电路
图1 拔河机游戏机框图
二设计步骤调试程
1总体设计电路
总体电路图仿真图图(25)示仿真图知电路设计误实现动AB两键时分产生两脉信号整形分加逆计数器逆计数器输出代码译码器译码驱动电指示灯点亮产生位移亮点移方终端控制电路作状态锁定双方键产生输入脉起作动复位键C亮点回中点位置次C键赛重新开始
图2 电路图
2模块设计相应模块程序
1顶层文件
library IEEE
use IEEEstd_logic_1164all
use IEEEstd_logic_unsignedall
entity bahe is
port(
player1player2in std_logic 玩家12输入
clk_inin std_logic clk_in(1MHZ)
resetin std_logic 重置键
row out std_logic_vector(7 downto 0)
col out std_logic_vector(7 downto 0)
ledout std_logic_vector(7 downto 0) 绳子
catsout std_logic_vector(6 downto 0) 分
qout std_logic_vector(5 downto 0) 数码控制
musout std_logic) 蜂鸣输出
end bahe
architecture body_bahe of bahe is
分频模块
component division
port(
clk_inin std_logic 1MHZ输入
clk_100clk_5clk_1out std_logic)100HZ5Hz1HZ
end component
计数模块
component count
port(
clk_1in std_logic 1HZ输入
swin std_logic 状态开关
player1player2in std_logic 选手输入
sum1sum2out std_logic_vector(4 downto 0)) 计数结果输出
end component
较模块
component cmp
port(
clk_100in std_logic 100hz
clk_1in std_logic 1hz
swout std_logic 状态开关输出
resetin std_logic 重置
startin std_logic 开始
sum1sum2in std_logic_vector(4 downto 0)计数结果输入
music_beginout std_logic 音乐
record1record2out std_logic_vector(1 downto 0)分输出
lightsout std_logic_vector(2 downto 0)) 拔河绳子显示
end component
音乐模块
component music
port(
resetin std_logic 重置
clkin std_logic 1MHz
clk_5in std_logic 5hz
music_beginin std_logic 音乐开始
musout std_logic)
end component
译码模块
component decode
port(
clk_inin std_logic 1mHZ
record1record2in std_logic_vector(1 downto 0) 分输入
lightsin std_logic_vector(2 downto 0) 拔河绳子输入
ledout std_logic_vector(7 downto 0) 输出LED
qbuffer std_logic_vector(5 downto 0) 数码控制
catsout std_logic_vector(6 downto 0) 数码显示分
)
end component
倒计时模块
component daojishi
port(
clk_inclk_1resetin std_logic
row out std_logic_vector(7 downto 0)
col out std_logic_vector(7 downto 0)
start out std_logic
)
end component
分频器输出
signal clk_100clk_5clk_1std_logic 时钟信号
计数器输出
signal sum1sum2std_logic_vector(4 downto 0) 计数结果
较器输出
signal swstd_logic 状态开关
signal record1record2std_logic_vector(1 downto 0) 分
signal lightsstd_logic_vector(2 downto 0) 绳子
signal music_beginstd_logic
解码器输出
signal tmp_ledstd_logic_vector(7 downto 0) LED显示
signal tmp_qstd_logic_vector(5 downto 0) 数码控制
signal tmp_catstd_logic_vector(6 downto 0) 数码显示分
倒计时器输出
signal tmp_startstd_logic
begin
cats
div division port map(clk_in>clk_inclk_100>clk_100clk_5>clk_5clk_1>clk_1)
cnt count port map(
clk_1>clk_1sw>swplayer1>player1player2>player2
sum1>sum1sum2>sum2)
com cmp port map(
clk_100>clk_100clk_1>clk_1sw>swreset>reset
start>tmp_startsum1>sum1sum2>sum2music_begin>music_begin
record1>record1record2>record2lights>lights)
dec decode port map(
clk_in>clk_inrecord1>record1record2>record2
lights>lightsled>tmp_ledq>tmp_qcats>tmp_cat)
mu music port map(
reset>resetclk>clk_inclk_5>clk_5
music_begin>music_beginmus>mus)
dao daojishi port map(
clk_in>clk_inclk_1>clk_1reset>reset
start>tmp_startcol>colrow>row)
end body_bahe
2CMP模块
library IEEE
use IEEEstd_logic_1164all
use IEEEstd_logic_unsignedall
entity cmp is
port(clk_100in std_logic 100HZ输入
clk_1in std_logic 1HZ输入
resetin std_logic 重置
startin std_logic 开始
sum1sum2in std_logic_vector(4 downto 0) 计数输入
record1record2out std_logic_vector(1 downto 0) 分输出
music_beginout std_logic 音乐开始
swout std_logic 状态输出
lightsout std_logic_vector(2 downto 0)) 绳子状态
end cmp
architecture body_cmp of cmp is
signal tmp_record1std_logic_vector(1 downto 0) 分
signal tmp_record2std_logic_vector(1 downto 0)
signal tmpstd_logic_vector(2 downto 0) 绳子状态
signal tmp_stastd_logic 状态
signal s1s2std_logic_vector(4 downto 0) 计数
begin
record1
process(clk_100) 判断赛状态
begin
if(start'1') then
if(clk_100'event and clk_100'1') then
tmp_sta<'1'
end if
end if
if(clk_100'event and clk_100'1') then 意分3赛结束开始播放音乐
if(tmp_record111 or tmp_record211) then
tmp_sta<'0'
music_begin<'1'
end if
if(tmp001 or tmp111) then 绳子头进入等状态
tmp_sta<'0'
end if
if(reset'1') then 复位状态零
tmp_sta<'0'
music_begin<'0'
end if
end if
end process
s1
process(clk_1reset) 控制绳子移位
begin
if(reset'1') then
tmp<100 绳子初始状态100
tmp_record1<00
tmp_record2<00
else
if(clk_1'event and clk_1'1') then
if(tmp_sta'1') then
if(s1>s2) then tmp
else
if(tmp001) then 绳子左头左计分器加1
tmp_record1
elsif(tmp111) then 绳子右头右记分器加1
tmp_record2
end if
end if
end if
end if
end process
end body_cmp
3.COUT模块
use IEEEstd_logic_1164all
use IEEEstd_logic_unsignedall
entity count is
library IEEE
port(clk_1in std_logic 1HZ输入
swin std_logic 状态判断输入
player1player2in std_logic 选手输入
sum1sum2out std_logic_vector(4 downto 0)) 计数输出
end count
architecture body_count of count is
signal p1p2std_logic_vector(4 downto 0) 计数输出
begin
sum1
begin
if(sw'1') then 处赛状态
if(clk_1'0') then
if(player1'event and player1'1') then
p1
if(player2'event and player2'1') then
p2
else
p1<00000
p2<00000
end if 赛状态结束
else p1<00000
p2<00000
end if
end process
end body_count
4.daojishi模块
library IEEE
use IEEEstd_logic_1164all
use IEEEstd_logic_unsignedall
entity daojishi is
port(clk_1clk_inreset in std_logic
row out std_logic_vector(7 downto 0)
col out std_logic_vector(7 downto 0)
start out std_logic)
end daojishi
architecture body_daojishi of daojishi is
type state is (s0s1s2s3s4s5s6s7s8s9s10)
signal present_statestates10
signal numstd_logic_vector(2 downto 0)000
begin
p3process(clk_in)
begin
if clk_in'event and clk_in'1' then
if num101 then num<000
else num
when s9>
case num is
when 000> col<11111111 row<11111111
when 001> col<11011111 row<01110100
when 010> col<11101111 row<01010100
when 011> col<11110111 row<01010100
when 100> col<11111011 row<01111100
when others> col<00000000 row<00000000
end case
when s8>
case num is
when 000> col<11111111 row<11111111
when 001> col<11011111 row<01111100
when 010> col<11101111 row<01010100
when 011> col<11110111 row<01010100
when 100> col<11111011 row<01111100
when others> col<00000000 row<00000000
end case
when s7>
case num is
when 000> col<11111111 row<11111111
when 001> col<11011111 row<01000000
when 010> col<11101111 row<01000000
when 011> col<11110111 row<01000000
when 100> col<11111011 row<01111100
when others> col<00000000 row<00000000
end case
when s6>
case num is
when 000> col<11111111 row<11111111
when 001> col<11011111 row<01111100
when 010> col<11101111 row<01010100
when 011> col<11110111 row<01010100
when 100> col<11111011 row<01011100
when others> col<00000000 row<00000000
end case
when s5>
case num is
when 000> col<11111111 row<11111111
when 001> col<11011111 row<01110100
when 010> col<11101111 row<01010100
when 011> col<11110111 row<01010100
when 100> col<11111011 row<01011100
when others> col<00000000 row<00000000
end case
when s4>
case num is
when 000> col<11111111 row<11111111
when 001> col<11011111 row<01110000
when 010> col<11101111 row<00010000
when 011> col<11110111 row<00010000
when 100> col<11111011 row<01111100
when others> col<00000000 row<00000000
end case
when s3>
case num is
when 000> col<11111111 row<11111111
when 001> col<11011111 row<01010100
when 010> col<11101111 row<01010100
when 011> col<11110111 row<01010100
when 100> col<11111011 row<01111100
when others> col<00000000 row<00000000
end case
when s2>
case num is
when 000> col<11111111 row<11111111
when 001> col<11011111 row<01011100
when 010> col<11101111 row<01010100
when 011> col<11110111 row<01010100
when 100> col<11111011 row<01110100
when others> col<00000000 row<00000000
end case
when s1>
case num is
when 000> col<11111111 row<11111111
when 001> col<11011111 row<00000000
when 010> col<11101111 row<00000000
when 011> col<11110111 row<00000000
when 100> col<11111011 row<01111100
when others> col<00000000 row<00000000
end case
when s0>
case num is
when 000> col<11111111 row<11111111
when 001> col<11011111 row<01111100
when 010> col<11101111 row<01000100
when 011> col<11110111 row<01000100
when 100> col<11111011 row<01111100
when others> col<00000000 row<00000000
end case
when others>
case num is
when 000> col<00000000 row<00000000
when 001> col<00000000 row<00000000
when 010> col<00000000 row<00000000
when 011> col<00000000 row<00000000
when 100> col<00000000 row<00000000
when others> col<00000000 row<00000000
end case
end case
end if
end if
end process p3
p4process(clk_1)
begin
if reset'1' then present_state
if clk_1'event and clk_1'1' then
case present_state is
when s10> present_state
end case
end if
end if
end process p4
end body_daojishi
library IEEE
use IEEEstd_logic_1164all
use IEEEstd_logic_unsignedall
entity decode is
port(clk_inin std_logic 1MHz
record1record2in std_logic_vector(1 downto 0) 分状态输入
lightsin std_logic_vector(2 downto 0) 绳子状态输入
ledout std_logic_vector(7 downto 0) 绳子解码输出
qbuffer std_logic_vector(5 downto 0) 数码控制
catsout std_logic_vector(6 downto 0)) 数码显示
end decode
architecture body_decode of decode is
signal tmp_ledstd_logic_vector(7 downto 0) 绳子输出
signal tmp_da1std_logic_vector(6 downto 0) 分1
signal tmp_da2std_logic_vector(6 downto 0) 分2
signal tmpstd_logic_vector(6 downto 0) 分显示
begin
led
begin
case lights is 绳子状态
when 100> tmp_led<00010000
when 011> tmp_led<00001000
when 010> tmp_led<00000100
when 001> tmp_led<00000010
when 101> tmp_led<00100000
when 110> tmp_led<01000000
when 111> tmp_led<10000000
when others >tmp_led<00010000
end case
case record1 is 分状态
when 00> tmp_da1<1111110
when 01> tmp_da1<0110000
when 10> tmp_da1<1101101
when 11> tmp_da1<1111001
end case
case record2 is 分状态
when 00> tmp_da2<1111110
when 01> tmp_da2<0110000
when 10> tmp_da2<1101101
when 11> tmp_da2<1111001
end case
if(clk_in'1') then
q<111110
end if
if(clk_in'0') then
q<011111
end if
case q is 数码显示控制
when 011111> tmp
end case
end process
end body_decode
3仿真仿真结果分析
创建仿真波形文件输入引脚input引脚付出值保存仿真波形文件开始仿真仿真没出错观察仿真波形图仿真波形图:
(1)a输入频率b时观察led:低电规左移动a方移动符合设计求见仿真图1
(2)改变输入a bb输入频率a波形波形图知低电右边移动b方移动符合设计求见仿真图2
仿真图1
仿真图2
4实验调试结果
编程载配置选择Assignments —Assignments Editor Assignments Edito窗口中选择pin标签页图分配引脚重编译进行编程载SOPC开发板进行功验证验证key 1key10观察led灯数码显示变化否符合设计求果设计符合程序进行更改知道符合设计求
三结心体会
EDA课程设计求做拔河游戏机电路9发光二极开中间发亮拔河中心点游戏双方持钮迅速断动产生脉谁快亮点谁方移动十次亮点移动次亮点移方终端二极时方获胜时双方钮均作输出保持复位亮点恢复中心数码显示双方键次数
通次课程设计更加感理实际间差异越越强烈感掌握门技术唯办法办法实践通实践书知识应实践发现问题真正掌握知识学致然遇问题时验学工作
四参考资料
[1] 潘 松EDA技术实教程(第二版) 北京:科学出版社2005
[2] 谭京生EDA技术应[M]西安:西安电子科技学出版社2001
[3] 徐志军CPLDFPGA开发应[M]北京:电子工业出版社2001
[4] 朱正伟EDA技术应[M]北京:清华学出版社2005
[5] 潘 松VHDL实教程[M]成:电子科技学出版社2001
文档香网(httpswwwxiangdangnet)户传
《香当网》用户分享的内容,不代表《香当网》观点或立场,请自行判断内容的真实性和可靠性!
该内容是文档的文本内容,更好的格式请下载文档