基本要求:
1、主持人按下抢答开关松起后,数码管10秒倒计时,期间哪位选手抢答成功就显示选手号码。
2、如果主持人按下抢答开关还没松起就有人抢答即为违规,对于的LED亮。
3、主持人按键可以对数码管清零。
基本模块:1、倒计时 2、抢答模块 3、led警告违规 4、显示模块
总图:
1、倒计时:
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY COUNT IS
PORT (CLK, Enable_Flag: IN STD_LOGIC;
H,L: OUT STD_LOGIC_VECTOR (3 DOWNTO 0);
G:OUT STD_LOGIC); --声音报警
END COUNT;
ARCHITECTURE behave OF COUNT IS
signal HH, LL: STD_LOGIC_VECTOR (3 DOWNTO 0);
BEGIN
PROCESS (CLK, Enable_Flag)
--VARIABLE HH, LL: STD_LOGIC_VECTOR (3 DOWNTO 0);
BEGIN
IF CLK'EVENT AND CLK='1'THEN ---允许抢答
IF Enable_Flag='0'THEN
HH<="0001";
LL<="0000";
else
IF LL=0 AND HH=0 THEN
G<='0';
ELSe
IF LL=0 THEN
LL<="1001";
HH<=HH-1;
ELSE
LL<=LL-1;
END IF;
end if;
--ELSE
--G<='1';
-- HH<="0010";
-- LL<="0000";
END IF;
END IF;
H<=HH;
L<=LL;
END PROCESS;
END behave;
2、抢答模块
library ieee;
use ieee.std_logic_1164.all;
use ieee. std_logic_arith.all;
use ieee. std_logic_unsigned.all;
-------------------------------------------------------------------
entity qiangda is
port( S1,s2,s3,s4 : in std_logic; --输入:表示4个人,为0表示有抢答
K : in std_logic; --主持人抢答开始键
G : out std_logic; --报警信号
Dout : out std_logic_vector(3 downto 0) ); --抢答结果显示
end qiangda;
--------------------------------------------------------------------
architecture behave of qiangda is
signal D : std_logic_vector(3 downto 0);
begin
process(S1,s2,s3,s4,K) --抢答结果显示
begin
if(K='0') then
D<="0000";
else
if(S1='0') then
D<="0001";
G<='0';
else
G<='1';
end if;
if(S2='0') then
D<="0010";
G<='0';
ELSE G<='1';
end if;
if(S3='0') then
D<="0011";
G<='0';
ELSE G<='1';
end if;
if(S4='0') then
D<="0100";
G<='0';
--S1<='1';
-- S2<='1';
-- S3<='1';
ELSE G<='1';
end if;
end if;
end process;
dout<=d;
end behave;
3、led警告违规
LIBRARY ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
ENTITY wg IS
PORT(K: IN std_logic;
S1, S2, S3, S4: IN std_logic;
R1, R2, R3, R4: OUT std_logic); --红色灯指示超前抢答台号
END wg;
ARCHITECTURE a OF wg IS
BEGIN
process(k,s1,s2,s3,s4)
begin
if(K='0') then
if(S1='0') then
R1<='0';
elsif(S2='0') then
R2<='0';
elsif(S3='0') then
R3<='0';
elsif (S4='0') then
R4<='0';
end if;
end if;
if k='1' then
r1<='1';
r2<='1';
r3<='1';
r4<='1';
end if;
end process;
END a;
用8个按键弹出1、2、3、4、5、6、7、1音符
程序如下:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity fenping is
port(clk_50m: in std_logic;
fmq : out std_logic;
key1: in std_logic;
key2: in std_logic;
key3: in std_logic;
key4: in std_logic;
key5: in std_logic;
key6: in std_logic;
key7: in std_logic;
key8: in std_logic
);
end;
architecture behave of fenping is
signal clk_262_r: std_logic;
signal clk_294_r: std_logic;
signal clk_330_r: std_logic;
signal clk_349_r: std_logic;
signal clk_392_r: std_logic;
signal clk_440_r: std_logic;
signal clk_494_r: std_logic;
signal clk_523_r: std_logic;
begin
u1: process (clk_50m)
variable count1: std_logic_vector(16 downto 0);
variable count2: std_logic_vector(16 downto 0);
variable count3: std_logic_vector(16 downto 0);
variable count4: std_logic_vector(16 downto 0);
variable count5: std_logic_vector(16 downto 0);
variable count6: std_logic_vector(16 downto 0);
variable count7: std_logic_vector(16 downto 0);
variable count8: std_logic_vector(16 downto 0);
begin
if clk_50m'event and clk_50m='1' then
if count1=95419 then
count1:=(others=>'0');
clk_262_r<=not clk_262_r;
else
count1:=count1+1;
end if;
end if;
if clk_50m'event and clk_50m='1' then
if count2=84459 then
count2:=(others=>'0');
clk_294_r<=not clk_294_r;
else
count2:=count2+1;
end if;
end if;
if clk_50m'event and clk_50m='1' then
if count3=75757 then
count3:=(others=>'0');
clk_330_r<=not clk_330_r;
else
count3:=count3+1;
end if;
end if;
if clk_50m'event and clk_50m='1' then
if count4=71633 then
count4:=(others=>'0');
clk_349_r<=not clk_349_r;
else
count4:=count4+1;
end if;
end if;
if clk_50m'event and clk_50m='1' then
if count5=63776 then
count5:=(others=>'0');
clk_392_r<=not clk_392_r;
else
count5:=count5+1;
end if;
end if;
if clk_50m'event and clk_50m='1' then
if count6=56818 then
count6:=(others=>'0');
clk_440_r<=not clk_440_r;
else
count6:=count6+1;
end if;
end if;
if clk_50m'event and clk_50m='1' then
if count7=50607 then
count7:=(others=>'0');
clk_494_r<=not clk_494_r;
else
count7:=count7+1;
end if;
end if;
if clk_50m'event and clk_50m='1' then
if count8=47801 then
count8:=(others=>'0');
clk_523_r<=not clk_523_r;
else
count8:=count8+1;
end if;
end if;
end process;
u2:process(key1,key2,key3,key4,key5,key6,key7,key8)
begin
if key1='0'then
fmq<=clk_262_r;
end if;
if key2='0'then
fmq<=clk_294_r;
end if;
if key3='0'then
fmq<=clk_330_r;
end if;
if key4='0'then
fmq<=clk_349_r;
end if;
if key5='0'then
fmq<=clk_392_r;
end if;
if key6='0'then
fmq<=clk_440_r;
end if;
if key7='0'then
fmq<=clk_494_r;
end if;
if key8='0'then
fmq<=clk_523_r;
end if;
end process;
end;
.SOF文件http://share.eepw.com.cn/share/download/id/79562
lcd1602滚动
视频:
原理图:
代码如下:代码虽然比较长,但是大多是一样的,比较容易写!分频程序没有呈上,相信大家都回来了!
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
entity LCD1602 is
port ( clk :in std_logic;
reset:in std_logic;
lcd_rs:out std_logic;
lcd_rw:out std_logic;
lcd_e: out std_logic;
data:out std_logic_vector(7 downto 0)
);
end LCD1602;
architecture one of LCD1602 is
signal bcd: std_logic_vector(5 downto 0);
signal cnt: std_logic_vector(9 downto 0);
begin
process(clk,reset)
begin
if clk'event and clk='1' then
bcd<=bcd+1;
cnt<=cnt+1;
case bcd is
when "000000"=>
lcd_rs<='0';
lcd_e<='1';
data<="00111000";
when "000001"=>
lcd_rs<='0';
lcd_e<='0';
when "000010"=>
lcd_rs<='0';
lcd_e<='1';
data<="00001100";
when "000011"=>
lcd_rs<='0';
lcd_e<='0';
when "000100"=>
lcd_rs<='0';
lcd_e<='1';
data<="10000001";
when "000101"=>
lcd_rs<='0';
lcd_e<='0';
when "000110"=> --xian e
lcd_rs<='1';
lcd_e<='1';
data<="01100101";
when "000111"=>
lcd_rs<='1';
lcd_e<='0';
when "001000"=>
lcd_rs<='0';
lcd_e<='1';
data<="10000010";
when "001001"=>
lcd_rs<='0';
lcd_e<='0';
when "001010"=> --xian e
lcd_rs<='1';
lcd_e<='1';
data<="01100101";
when "001011"=>
lcd_rs<='1';
lcd_e<='0';
when "001100"=>
lcd_rs<='0';
lcd_e<='1';
data<="10000011";
when "001101"=>
lcd_rs<='0';
lcd_e<='0';
when "001110"=> --xian p
lcd_rs<='1';
lcd_e<='1';
data<="01110000";
when "001111"=>
lcd_rs<='1';
lcd_e<='0';
when "010000"=>
lcd_rs<='0';
lcd_e<='1';
data<="10000100";
when "010001"=>
lcd_rs<='0';
lcd_e<='0';
when "010010"=> --xian w
lcd_rs<='1';
lcd_e<='1';
data<="01110111";
when "010011"=>
lcd_rs<='1';
lcd_e<='0';
when "010100"=>
lcd_rs<='0';
lcd_e<='1';
data<="10000110";
when "010101"=>
lcd_rs<='0';
lcd_e<='0';
when "010110"=> --xian z
lcd_rs<='1';
lcd_e<='1';
data<="01111010";
when "010111"=>
lcd_rs<='1';
lcd_e<='0';
when "011000"=>
lcd_rs<='0';
lcd_e<='1';
data<="10000111";
when "011001"=>
lcd_rs<='0';
lcd_e<='0';
when "011010"=> --xian h
lcd_rs<='1';
lcd_e<='1';
data<="01101000";
when "011011"=>
lcd_rs<='1';
lcd_e<='0';
when "011100"=>
lcd_rs<='0';
lcd_e<='1';
data<="10001000";
when "011101"=>
lcd_rs<='0';
lcd_e<='0';
when "011110"=> --xian w
lcd_rs<='1';
lcd_e<='1';
data<="01110111";
when "011111"=>
lcd_rs<='1';
lcd_e<='0';
when "100000"=>
lcd_rs<='0';
lcd_e<='1';
data<="10001001";
when "100001"=>
lcd_rs<='0';
lcd_e<='0';
when "100010"=> --xian e
lcd_rs<='1';
lcd_e<='1';
data<="01100101";
when "100011"=>
lcd_rs<='1';
lcd_e<='0';
when "100100"=>
lcd_rs<='0';
lcd_e<='1';
data<="10001010";
when "100101"=>
lcd_rs<='0';
lcd_e<='0';
when "100110"=> --xian n
lcd_rs<='1';
lcd_e<='1';
data<="01101110";
when "100111"=>
lcd_rs<='1';
lcd_e<='0';
when "101000"=>
lcd_rs<='0';
lcd_e<='1';
data<="10001011";
when "101001"=>
lcd_rs<='0';
lcd_e<='0';
when "101010"=> --xian g
lcd_rs<='1';
lcd_e<='1';
data<="01100111";
when "101011"=>
lcd_rs<='1';
lcd_e<='0';
when others=>null;
end case;
case cnt is
when "1111111110" =>
lcd_rs<='0';
lcd_e<='1';
data<="00011000";
when "1111111111"=>
lcd_rs<='0';
lcd_e<='0';
-- data<="00111000";
when others=>null;
end case;
end if;
end process;
end ;
.SOF文件下载:http://share.eepw.com.cn/share/download/id/81240
回复
有奖活动 | |
---|---|
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
【换取逻辑分析仪】自制底板并驱动ArduinoNanoRP2040ConnectLCD扩展板被打赏47分 | |
【分享评测,赢取加热台】RISC-V GCC 内嵌汇编使用被打赏38分 | |
【换取逻辑分析仪】-基于ADI单片机MAX78000的简易MP3音乐播放器被打赏48分 | |
我想要一部加热台+树莓派PICO驱动AHT10被打赏38分 | |
【换取逻辑分析仪】-硬件SPI驱动OLED屏幕被打赏36分 | |
换逻辑分析仪+上下拉与多路选择器被打赏29分 | |
Let'sdo第3期任务合集被打赏50分 | |
换逻辑分析仪+Verilog三态门被打赏27分 | |
换逻辑分析仪+Verilog多输出门被打赏24分 | |
【分享评测,赢取加热台】使用8051单片机驱动WS2812被打赏40分 |