没有合适的资源?快使用搜索试试~ 我知道了~
乒乓求实验代码
需积分: 9 1 下载量 69 浏览量
2013-04-08
23:10:59
上传
评论
收藏 7KB TXT 举报
温馨提示
试读
10页
有关模拟乒乓球的实验的源代码,用LED灯的闪烁表示乒乓球的运动,还有正反双发,也有计数器计分。
资源推荐
资源详情
资源评论
1.VHDL³ÌÐò
Library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity corna is
port(
clr,af,aj,bf,bj,clk:in std_logic;
shift:out std_logic_vector(15 downto 0);
ah,al,bh,bl:out std_logic_vector(3 downto 0)
q:out std_logic_vector(6 downto 0);
sellread:out std_logic_vector(3 downto 0);
);
end corna;
architecture corna_arc of corna is
signal amark,bmark:integer;
signal clk1:std_logic;
signal fen:std_logic_vector(9 downto 0);
begin
process
begin
wait until clk='1';
fen<=fen+1;
clk1<=fen(7);
end process;
process(clr,clk1)
variable a,b:std_logic;
variable she:std_logic_vector(15 downto 0);
Library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity corna is
port(
clr,af,aj,bf,bj,clk:in std_logic;
shift:out std_logic_vector(15 downto 0);
ah,al,bh,bl:out std_logic_vector(3 downto 0)
q:out std_logic_vector(6 downto 0);
sellread:out std_logic_vector(3 downto 0);
);
end corna;
architecture corna_arc of corna is
signal amark,bmark:integer;
signal clk1:std_logic;
signal fen:std_logic_vector(9 downto 0);
begin
process
begin
wait until clk='1';
fen<=fen+1;
clk1<=fen(7);
end process;
process(clr,clk1)
variable a,b:std_logic;
variable she:std_logic_vector(15 downto 0);
begin
if clr='0' then
a:='0';
b:='0';
she:="0000000000000000";
amark<=0;
bmark<=0;
elsif clk1'event and clk1='1'then
if a='0'and b='0'and af='1'then
a:='1';
she:="1000000000000000";
elsif a='0' and b='0' and bf='1' then
b:='1';
she:="0000000000000001";
elsif a='1' and b='0' then
if she>128 then
if bj='1' then
amark<=amark+1;
a:='0';
b:='0';
she:="0000000000000000";
else
she:='0'&she(15 downto 1);
end if;
elsif she=0 then
amark<=amark+1;
a:='0';
b:='0';
else
if bj='1'then
if clr='0' then
a:='0';
b:='0';
she:="0000000000000000";
amark<=0;
bmark<=0;
elsif clk1'event and clk1='1'then
if a='0'and b='0'and af='1'then
a:='1';
she:="1000000000000000";
elsif a='0' and b='0' and bf='1' then
b:='1';
she:="0000000000000001";
elsif a='1' and b='0' then
if she>128 then
if bj='1' then
amark<=amark+1;
a:='0';
b:='0';
she:="0000000000000000";
else
she:='0'&she(15 downto 1);
end if;
elsif she=0 then
amark<=amark+1;
a:='0';
b:='0';
else
if bj='1'then
剩余9页未读,继续阅读
资源评论
u010217949
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功