EDA课程设计之抢答器.docx
- 文档编号:17155250
- 上传时间:2023-07-22
- 格式:DOCX
- 页数:15
- 大小:16.58KB
EDA课程设计之抢答器.docx
《EDA课程设计之抢答器.docx》由会员分享,可在线阅读,更多相关《EDA课程设计之抢答器.docx(15页珍藏版)》请在冰点文库上搜索。
EDA课程设计之抢答器
抢答器
libraryIEEE;
useIEEE.STD_LOGIC_1164.ALL;
useIEEE.STD_LOGIC_ARITH.ALL;
useIEEE.STD_LOGIC_UNSIGNED.ALL;
entityf1msis
Port(CLK:
instd_logic;
CP:
outstd_logic);
endf1ms;
architectureBehavioraloff1msis
signala:
integerrange0to5000;
begin
process(CLK)
begin
if(CLK'eventandCLK='1')then
ifa=4999then
a<=0;
else
a<=a+1;
endif;
caseais
when0to2499=>CP<='1';
when2500to4999=>CP<='0';
whenothers=>CP<='Z';
endcase;
endif;
endprocess;
endBehavioral;
libraryIEEE;
useIEEE.STD_LOGIC_1164.ALL;
useIEEE.STD_LOGIC_ARITH.ALL;
useIEEE.STD_LOGIC_UNSIGNED.ALL;
entityf1Sis
Port(CLK:
instd_logic;
CP:
outstd_logic);
endf1S;
architectureBehavioraloff1Sis
signalcount:
integerrange0to50000000;
begin
process(CLK)
begin
if(CLK'eventandCLK='1')then
ifcount=49999999then
count<=0;
else
count<=count+1;
endif;
casecountis
when0to24999999=>CP<='1';
when25000000to49999999=>CP<='0';
whenothers=>CP<='Z';
endcase;
endif;
endprocess;
endBehavioral;
libraryIEEE;----库说明
useIEEE.STD_LOGIC_1164.ALL;
useIEEE.STD_LOGIC_ARITH.ALL;
useIEEE.STD_LOGIC_UNSIGNED.ALL;
entitydaojishiis
Port(clk,clr,rst:
inSTD_LOGIC;----clk时钟信号,clr复位信号,rst计时开始中止信号
high,low:
outSTD_LOGIC_VECTOR(3downto0));----计时输出信号
enddaojishi;
architecturertlofdaojishiis
signalhh:
std_logic_vector(3downto0);----定义变量
signalll:
std_logic_vector(3downto0);
begin
process(clk,clr,rst)----启动进程
begin
ifclk'eventandclk='1'then
ifclr='0'thenll<="0000";hh<="0010";----电路清零
else
ifrst='0'then
ifll="0000"then
ifhh/="0000"then
ll<="1001";
hh<=hh-1;
else
--ll="0000"andhh="0000"
endif;
elsell<=ll-1;
endif;
endif;
endif;
endif;
endprocess;
high<=hh;low<=ll;
endrtl;
libraryIEEE;--库说明
useIEEE.STD_LOGIC_1164.ALL;
useIEEE.STD_LOGIC_ARITH.ALL;
useIEEE.STD_LOGIC_UNSIGNED.ALL;
entitypanduanis
Port(CLR:
inSTD_LOGIC;----复位信号
EN:
inSTD_LOGIC;----抢答使能信号
A,B,C,D:
inSTD_LOGIC;----抢答按钮
FALSE:
bufferSTD_LOGIC_VECTOR(3downto0);----抢答提前警报
Q:
bufferSTD_LOGIC_VECTOR(3downto0));----抢答成功组显示
endpanduan;
architecturertlofpanduanis
signalTMP:
std_logic_vector(3downto0);
signalTAG:
std_logic;----设置锁存标志位
begin
TMP<=A&B&C&D;
process(CLR,EN,A,B,C,D,TMP)----启动进程
begin
ifCLR='0'then----电路清零
Q<="0000";
FALSE<="0000";
TAG<='0';
ELSIFEN='1'THEN----抢答提前报警
IFA='0'THEN
FALSE(3)<='1';
ENDIF;
IFB='0'THEN
FALSE
(2)<='1';
ENDIF;
IFC='0'THEN
FALSE
(1)<='1';
ENDIF;
IFD='0'THEN
FALSE(0)<='1';
ENDIF;
--Q<="0000";
ELSifEN='0'THEN----抢答开始
----报警信号清零
----尚未有抢答成功者出现
IFTMP="0111"THEN----A抢答成功
Q<="1000";----显示A抢答成功
TAG<='1';----锁存此状态
ELSIFTMP="1011"THEN
Q<="0100";
TAG<='1';
ELSIFTMP="1101"THEN
Q<="0010";
TAG<='1';
ELSIFTMP="1110"THEN
Q<="0001";
TAG<='1';
--else
--Q<="0000";
ENDIF;
ENDIF;
ENDPROCESS;
endrtl;
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
useIEEE.STD_LOGIC_ARITH.ALL;
entityLCDis
generic(divide_to_100k:
integer:
=500);
port(clk:
instd_logic;
Q:
instd_logic_vector(3downto0);
DATAIN:
instd_logic_vector(7downto0);
false:
instd_logic_vector(3downto0);
rw,rs,e,lcd_rst:
outstd_logic;
lcd_data:
outstd_logic_vector(7downto0));
endLCD;
architecturetclofLCDis
signalclk_100k:
std_logic;
typestateis(s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15);
signalcurrent_s:
state;
typedata_bufferisarray(0to15)ofstd_logic_vector(7downto0);
typedata_buffer1isarray(0to1)ofstd_logic_vector(7downto0);
typedata_buffer2isarray(0to7)ofstd_logic_vector(7downto0);
signaldisp_time_daojishi:
data_buffer1;
signaldisp_LCD_er:
data_buffer2;
signaldisp_LCD_sai:
data_buffer2;
constantdata_buf0:
data_buffer:
=(x"D7",x"E9",x"20",x"20",--组别ABCD
x"20",x"20",x"B1",x"F0",
x"A3",x"C1",x"A3",x"C2",
x"A3",x"C3",x"A3",x"C4");
constantdata_buf1:
data_buffer:
=(x"CC",x"E1",x"C7",x"B0",--提前抢答
x"C7",x"C0",x"B4",x"F0",
x"20",x"20",x"20",x"20",
x"20",x"20",x"20",x"20");
constantdata_buf2:
data_buffer:
=(x"B3",x"C9",x"B9",x"A5",--成功抢答
x"C7",x"C0",x"B4",x"F0",
x"20",x"20",x"20",x"20",
x"20",x"20",x"20",x"20");
constantdata_buf3:
data_buffer:
=(x"B5",x"B9",x"BC",x"C6",--倒计时20s
x"CA",x"B1",x"20",x"20",
x"32",x"30",x"20",x"20",
x"20",x"20",x"20",x"20");
begin
process(clk)
variablecnt:
integerrange0todivide_to_100k;--100K分频
begin
if(clk'eventandclk='1')thencnt:
=cnt+1;
if(cnt=divide_to_100k)thencnt:
=0;
endif;
if(cnt elseclk_100k<='1'; endif; endif; endprocess; disp_time_daojishi(0)<=DATAIN(7downto4)+x"30"; disp_time_daojishi (1)<=DATAIN(3downto0)+x"30"; process(false) begin casefalseis when"1000"=>disp_LCD_er<=(x"A1",x"C1",x"20",x"20",--A组提前抢答 x"20",x"20",x"20",x"20"); when"0100"=>disp_LCD_er<=(x"20",x"20",x"A1",x"C1",--B x"20",x"20",x"20",x"20"); when"0010"=>disp_LCD_er<=(x"20",x"20",x"20",x"20",--C x"a1",x"C1",x"20",x"20"); when"0001"=>disp_LCD_er<=(x"20",x"20",x"20",x"20",--D x"20",x"20",x"A1",x"C1"); whenothers=>disp_LCD_er<=(x"20",x"20",x"20",x"20", x"20",x"20",x"20",x"20"); endcase; endprocess; process(Q) begin caseQis when"1000"=>disp_LCD_sai<=(x"A1",x"CC",x"20",x"20",--A组抢答成功对号 x"20",x"20",x"20",x"20"); when"0100"=>disp_LCD_sai<=(x"20",x"20",x"A1",x"CC",--B x"20",x"20",x"20",x"20"); when"0010"=>disp_LCD_sai<=(x"20",x"20",x"20",x"20",--C x"A1",x"CC",x"20",x"20"); when"0001"=>disp_LCD_sai<=(x"20",x"20",x"20",x"20",--D x"20",x"20",x"A1",x"CC"); whenothers=>disp_LCD_sai<=(x"20",x"20",x"20",x"20", x"20",x"20",x"20",x"20"); endcase; endprocess; process(clk_100k) variablecnt1: integerrange0to1000; variablecnt_1: integerrange0to100; variabledata_cnt: integerrange0to16; begin if(clk_100k'eventandclk_100k='1')then casecurrent_sis whens0=>rw<='1';rs<='1';e<='1';cnt1: =cnt1+1; ifcnt1<500thenlcd_rst<='0'; elsifcnt1<1000thenlcd_rst<='1'; elsifcnt1=1000then lcd_rst<='1';cnt1: =0;current_s<=s1; endif; whens1=>cnt_1: =cnt_1+1; ifcnt_1<1*3thene<='1';rs<='0';rw<='0'; elsifcnt_1<2*3thenlcd_data<=x"0c"; elsifcnt_1<10*3thene<='0'; elsifcnt_1=10*3thencnt_1: =0;current_s<=s2; endif; whens2=>cnt_1: =cnt_1+1; ifcnt_1<1*3thene<='1';rs<='0';rw<='0'; elsifcnt_1<2*3thenlcd_data<=x"80"; elsifcnt_1<10*3thene<='0'; elsifcnt_1=10*3thencnt_1: =0;current_s<=s3; endif; whens3=> ifcnt_1<1*3thene<='1';rs<='1';rw<='0'; elsifcnt_1<2*3thenlcd_data<=data_buf0(data_cnt); elsifcnt_1=2*3thendata_cnt: =data_cnt+1; elsifcnt_1<100thene<='0'; endif; cnt_1: =cnt_1+1; ifcnt_1=100thencnt_1: =0; ifdata_cnt=16thencurrent_s<=s4; data_cnt: =0; endif; endif; whens4=>cnt_1: =cnt_1+1; ifcnt_1<1*3thene<='1';rs<='0';rw<='0'; elsifcnt_1<2*3thenlcd_data<=x"90"; elsifcnt_1<10*3thene<='0'; elsifcnt_1=10*3thencnt_1: =0;current_s<=s5; endif; whens5=> ifcnt_1<1*3thene<='1';rs<='1';rw<='0'; elsifcnt_1<2*3thenlcd_data<=data_buf1(data_cnt); elsifcnt_1=2*3thendata_cnt: =data_cnt+1; elsifcnt_1<100thene<='0'; endif; cnt_1: =cnt_1+1; ifcnt_1=100thencnt_1: =0; ifdata_cnt=16thencurrent_s<=s6; data_cnt: =0; endif; endif; whens6=>cnt_1: =cnt_1+1; ifcnt_1<1*3thene<='1';rs<='0';rw<='0'; elsifcnt_1<2*3thenlcd_data<=x"88"; elsifcnt_1<10*3thene<='0'; elsifcnt_1=10*3thencnt_1: =0;current_s<=s7; endif; whens7=> ifcnt_1<1*3thene<='1';rs<='1';rw<='0'; elsifcnt_1<2*3thenlcd_data<=data_buf2(data_cnt); elsifcnt_1=2*3thendata_cnt: =data_cnt+1; elsifcnt_1<100thene<='0'; endif; cnt_1: =cnt_1+1; ifcnt_1=100thencnt_1: =0; ifdata_cnt=16thencurrent_s<=s8; data_cnt: =0; endif; endif; whens8=>cnt_1: =cnt_1+1; ifcnt_1<1*3thene<='1';rs<='0';rw<='0'; elsifcnt_1<2*3thenlcd_data<=x"98"; elsifcnt_1<10*3thene<='0'; elsifcnt_1=10*3thencnt_1: =0;current_s<=s9; endif; whens9=> ifcnt_1<1*3thene<='1';rs<='1';rw<='0'; elsifcnt_1<2*3thenlcd_data<=data_buf3(data_cnt); elsifcnt_1=2*3thendata_cnt: =data_cnt+1; elsifcnt_1<100thene<='0'; endif; cnt_1: =cnt_1+1; ifcnt_1=100thencnt_1: =0; ifdata_cnt=16thencurrent_s<=s10; data_cnt: =0; endif; endif; whens10=>cnt_1: =cnt_1+1; ifcnt_1<1*3thene<='1';rs<='0';rw<='0'; elsifcnt_1<2*3thenlcd_data<=x"94"; elsifcnt_1<10*3thene<='0'; elsifcnt_1=10*3thencnt_1: =0;current_s<=s11; endif; whens11=> ifcnt_1<1*3thene<='1';rs<='1';rw<='0'; elsifcnt_1<2*3thenlcd_data<=disp_LCD_er(data_cnt); elsifcnt_1=2*3thendata_cnt: =data_cnt+1; elsifcnt_1<100thene<='0'; endif; cnt_1: =cnt_1+1; ifcnt_1=100thencnt_1: =0; ifdata_cnt=8thencurrent_s<=s12; data_cnt: =0; endif; endif; whens12=>cnt_1: =cnt_1+1; ifcnt_1<1*3thene<='1';rs<='0';rw<='0'; elsifcnt_1<2*3thenlcd_data<=x"8c"; elsifcnt_1<10*3thene<='0'; elsifcnt_1=10*3thencnt_1: =0;current_s<=s13; endif; whens13=> ifcnt_1<1*3thene<='1';rs<='1';rw<='0'; elsifcnt_1<2*3thenlcd_data<=disp_LCD_sai(data_cnt); elsifcnt_1=2*3thendata_cnt: =data_cnt+1; elsifcnt_1<100thene<='0'; endif; cnt_1: =cnt_1+1; ifcnt_1=100thencnt_1: =0; ifdata_cnt=8thencurrent_s<=s14; data_cnt: =0; endif; endif; whens14=>cnt_1: =cnt_1+1; ifcnt_1<1*3thene<='1
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- EDA 课程设计 抢答
![提示](https://static.bingdoc.com/images/bang_tan.gif)