4674
- 收藏
- 点赞
- 分享
- 举报
电子时钟VHDL程序与仿真
10进制计数器设计与仿真,10进制计数器,有进位C
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity counter10 is
Port ( clk : in std_logic;
reset : in std_logic;
din : in std_logic_vector(3 downto 0);
dout : out std_logic_vector(3 downto 0);
c:out std_logic);
end counter10;
architecture Behavioral of counter10 is
signal count : std_logic_vector(3 downto 0);
begin
dout <= count;
process(clk,reset,din)
begin
if reset='0'then
count <= din ;
c<='0';
elsif rising_edge(clk) then
if count = "1001" then
count <= "0000";
c<='1';
else
count <= count+1;
c<='0';
end if;
end if;
end process;
end Behavioral;
(2) 10进制计数器仿真
2. 6进制计数器设计与仿真
(1)6进制计数器VHDL程序
--文件名:counter6.vhd。
--功能:6进制计数器,有进位C
--最后修改日期:2004.3.20
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity counter6 is
Port ( clk : in std_logic;
reset : in std_logic;
din : in std_logic_vector(2 downto 0);
dout : out std_logic_vector(2 downto 0);
c:out std_logic);
end counter6;
architecture Behavioral of counter6 is
signal count : std_logic_vector(2 downto 0);
begin
dout <= count;
process(clk,reset,din)
begin
if reset= '0' then
count <= din;
c<='0';
elsif rising_edge(clk) then
if count="101" then
count<="000";
c<='1';
else
count<=count+1;
c<='0';
end if;
end if;
end process;
end Behavioral;
(2)6进制计数器仿真
3. 6进制计数器设计与仿真
(1)24进制计数器VHDL程序
--文件名:counter24.vhd。
--功能:24进制计数器。
--最后修改日期:2004.3.20
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity counter24 is
Port ( clk : in std_logic;
reset : in std_logic;
din : in std_logic_vector(5 downto 0);
dout : out std_logic_vector(5 downto 0));
end counter24;
architecture Behavioral of counter24 is
signal count : std_logic_vector(5 downto 0);
begin
dout <= count;
process(clk,reset,din)
begin
if reset= '0' then
count <= din;
elsif rising_edge(clk) then
if count(3 downto 0)="1001" then
count(3 downto 0)<="0000";
count(5 downto 4)<=count(5 downto 4) +1;
else
count(3 downto 0)<=count(3 downto 0)+1;
end if;
if count="100011" then
count<="000000";
end if;
end if;
end process;
end Behavioral;
(2)24进制计数器仿真
4. 译码器设计
(1)译码器VHDL程序
--文件名:decoder.vhd。
--功能:将4bit二进制数译码,在LED上显示相应数字。
--最后修改日期:2004.3.20
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity decoder is
Port (din:in std_logic_vector(3 downto 0 ); --四位二进制码输入
dout:out std_logic_vector(6 downto 0) ); --输出LED七段码
end decoder;
architecture Behavioral of decoder is
begin
process(din)
begin
case din is
when "0000" => dout<="0000001";--0
when "0001" => dout<="1001111";--1
when "0010" => dout<="0010010";--2
when "0011" => dout<="0000110";--3
when "0100" => dout<="1001100"; --4
when "0101" => dout<="0100100";--5
when "0110" => dout<="0100000";--6
when "0111" => dout<="0001111";--7
when "1000" => dout<="0000000";--8
when "1001" => dout<="0000100";--9
when others => dout<="1111111";
end case;
end process;
end Behavioral;
5. 顶层设计与仿真
(1)顶层设计VHDL程序
--文件名:clock.vhd。
--功能:时钟的顶层设计。
--最后修改日期:2004.3.20
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity clock is
Port ( clk : in std_logic; --1Hz
reset : in std_logic; --复位信号
dins : in std_logic_vector(6 downto 0);--秒钟预置
dinm : in std_logic_vector(6 downto 0);--分钟预置
dinh : in std_logic_vector(5 downto 0);--时钟预置
secondl: out std_logic_vector(6 downto 0);--秒钟低位输出
secondh: out std_logic_vector(6 downto 0); --秒钟高位输出
minutel: out std_logic_vector(6 downto 0); --分钟低位输出
minuteh: out std_logic_vector(6 downto 0); --分钟高位输出
hourl: out std_logic_vector(6 downto 0); --小时低位输出
hourh: out std_logic_vector(6 downto 0)); --小时高位输出
end clock;
architecture Behavioral of clock is
component counter10 is
Port ( clk : in std_logic;
reset : in std_logic;
din : in std_logic_vector(3 downto 0);
dout : out std_logic_vector(3 downto 0);
c:out std_logic);
end component;
component counter6 is
Port ( clk : in std_logic;
reset : in std_logic;
din : in std_logic_vector(2 downto 0);
dout : out std_logic_vector(2 downto 0);
c:out std_logic);
end component;
component counter24 is
Port ( clk : in std_logic;
reset : in std_logic;
din : in std_logic_vector(5 downto 0);
dout : out std_logic_vector(5 downto 0));
end component;
component decoder is
Port (din:in std_logic_vector(3 downto 0 );
dout:out std_logic_vector(6 downto 0));
end component;
signal c1,c2,c3,c4:std_logic;
signal doutsl,doutml:std_logic_vector(3 downto 0);
signal doutsh,doutmh:std_logic_vector(2 downto 0);
signal douth:std_logic_vector(5 downto 0);
signal rdoutsh,rdoutmh:std_logic_vector(3 downto 0);
signal rdouth:std_logic_vector(7 downto 0);
begin
rdoutsh <= '0'&doutsh; --将秒钟高位数据变为4位,再进行译码
rdoutmh <= '0'&doutmh; --将分钟高位数据变为4位,再进行译码
rdouth <="00"&douth; --将时钟高位数据变为4位,再进行译码
u1: counter10 port map( clk=>clk,reset=>reset,
din=>dins(3 downto 0),
dout=>doutsl,
c=>c1);
u2: counter6 port map( clk=>c1,reset=>reset,
din=>dins(6 downto 4),
dout=>doutsh,
c=>c2);
u3: counter10 port map( clk=>c2,reset=>reset,
din=>dinm(3 downto 0),
dout=>doutml,
c=>c3);
u4: counter6 port map( clk=>c3,reset=>reset,
din=>dinm(6 downto 4),
dout=>doutmh,
c=>c4);
u5: counter24 port map( clk=>c4,reset=>reset,
din=>dinh,
dout=>douth);
u6: decoder port map( din => doutsl,dout => secondl); --秒的低位
u7: decoder port map( din => rdoutsh,dout => secondh); --秒的高位
u8: decoder port map( din => doutml,dout => minutel); --分的低位
u9: decoder port map( din => rdoutmh,dout => minuteh); --分的高位
u10: decoder port map( din => rdouth(3 downto 0),dout => hourh);--时的低位
u11: decoder port map( din => rdouth(7 downto 4),dout => hourl);--时的高位
end Behavioral;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity counter10 is
Port ( clk : in std_logic;
reset : in std_logic;
din : in std_logic_vector(3 downto 0);
dout : out std_logic_vector(3 downto 0);
c:out std_logic);
end counter10;
architecture Behavioral of counter10 is
signal count : std_logic_vector(3 downto 0);
begin
dout <= count;
process(clk,reset,din)
begin
if reset='0'then
count <= din ;
c<='0';
elsif rising_edge(clk) then
if count = "1001" then
count <= "0000";
c<='1';
else
count <= count+1;
c<='0';
end if;
end if;
end process;
end Behavioral;
(2) 10进制计数器仿真
2. 6进制计数器设计与仿真
(1)6进制计数器VHDL程序
--文件名:counter6.vhd。
--功能:6进制计数器,有进位C
--最后修改日期:2004.3.20
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity counter6 is
Port ( clk : in std_logic;
reset : in std_logic;
din : in std_logic_vector(2 downto 0);
dout : out std_logic_vector(2 downto 0);
c:out std_logic);
end counter6;
architecture Behavioral of counter6 is
signal count : std_logic_vector(2 downto 0);
begin
dout <= count;
process(clk,reset,din)
begin
if reset= '0' then
count <= din;
c<='0';
elsif rising_edge(clk) then
if count="101" then
count<="000";
c<='1';
else
count<=count+1;
c<='0';
end if;
end if;
end process;
end Behavioral;
(2)6进制计数器仿真
3. 6进制计数器设计与仿真
(1)24进制计数器VHDL程序
--文件名:counter24.vhd。
--功能:24进制计数器。
--最后修改日期:2004.3.20
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity counter24 is
Port ( clk : in std_logic;
reset : in std_logic;
din : in std_logic_vector(5 downto 0);
dout : out std_logic_vector(5 downto 0));
end counter24;
architecture Behavioral of counter24 is
signal count : std_logic_vector(5 downto 0);
begin
dout <= count;
process(clk,reset,din)
begin
if reset= '0' then
count <= din;
elsif rising_edge(clk) then
if count(3 downto 0)="1001" then
count(3 downto 0)<="0000";
count(5 downto 4)<=count(5 downto 4) +1;
else
count(3 downto 0)<=count(3 downto 0)+1;
end if;
if count="100011" then
count<="000000";
end if;
end if;
end process;
end Behavioral;
(2)24进制计数器仿真
4. 译码器设计
(1)译码器VHDL程序
--文件名:decoder.vhd。
--功能:将4bit二进制数译码,在LED上显示相应数字。
--最后修改日期:2004.3.20
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity decoder is
Port (din:in std_logic_vector(3 downto 0 ); --四位二进制码输入
dout:out std_logic_vector(6 downto 0) ); --输出LED七段码
end decoder;
architecture Behavioral of decoder is
begin
process(din)
begin
case din is
when "0000" => dout<="0000001";--0
when "0001" => dout<="1001111";--1
when "0010" => dout<="0010010";--2
when "0011" => dout<="0000110";--3
when "0100" => dout<="1001100"; --4
when "0101" => dout<="0100100";--5
when "0110" => dout<="0100000";--6
when "0111" => dout<="0001111";--7
when "1000" => dout<="0000000";--8
when "1001" => dout<="0000100";--9
when others => dout<="1111111";
end case;
end process;
end Behavioral;
5. 顶层设计与仿真
(1)顶层设计VHDL程序
--文件名:clock.vhd。
--功能:时钟的顶层设计。
--最后修改日期:2004.3.20
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity clock is
Port ( clk : in std_logic; --1Hz
reset : in std_logic; --复位信号
dins : in std_logic_vector(6 downto 0);--秒钟预置
dinm : in std_logic_vector(6 downto 0);--分钟预置
dinh : in std_logic_vector(5 downto 0);--时钟预置
secondl: out std_logic_vector(6 downto 0);--秒钟低位输出
secondh: out std_logic_vector(6 downto 0); --秒钟高位输出
minutel: out std_logic_vector(6 downto 0); --分钟低位输出
minuteh: out std_logic_vector(6 downto 0); --分钟高位输出
hourl: out std_logic_vector(6 downto 0); --小时低位输出
hourh: out std_logic_vector(6 downto 0)); --小时高位输出
end clock;
architecture Behavioral of clock is
component counter10 is
Port ( clk : in std_logic;
reset : in std_logic;
din : in std_logic_vector(3 downto 0);
dout : out std_logic_vector(3 downto 0);
c:out std_logic);
end component;
component counter6 is
Port ( clk : in std_logic;
reset : in std_logic;
din : in std_logic_vector(2 downto 0);
dout : out std_logic_vector(2 downto 0);
c:out std_logic);
end component;
component counter24 is
Port ( clk : in std_logic;
reset : in std_logic;
din : in std_logic_vector(5 downto 0);
dout : out std_logic_vector(5 downto 0));
end component;
component decoder is
Port (din:in std_logic_vector(3 downto 0 );
dout:out std_logic_vector(6 downto 0));
end component;
signal c1,c2,c3,c4:std_logic;
signal doutsl,doutml:std_logic_vector(3 downto 0);
signal doutsh,doutmh:std_logic_vector(2 downto 0);
signal douth:std_logic_vector(5 downto 0);
signal rdoutsh,rdoutmh:std_logic_vector(3 downto 0);
signal rdouth:std_logic_vector(7 downto 0);
begin
rdoutsh <= '0'&doutsh; --将秒钟高位数据变为4位,再进行译码
rdoutmh <= '0'&doutmh; --将分钟高位数据变为4位,再进行译码
rdouth <="00"&douth; --将时钟高位数据变为4位,再进行译码
u1: counter10 port map( clk=>clk,reset=>reset,
din=>dins(3 downto 0),
dout=>doutsl,
c=>c1);
u2: counter6 port map( clk=>c1,reset=>reset,
din=>dins(6 downto 4),
dout=>doutsh,
c=>c2);
u3: counter10 port map( clk=>c2,reset=>reset,
din=>dinm(3 downto 0),
dout=>doutml,
c=>c3);
u4: counter6 port map( clk=>c3,reset=>reset,
din=>dinm(6 downto 4),
dout=>doutmh,
c=>c4);
u5: counter24 port map( clk=>c4,reset=>reset,
din=>dinh,
dout=>douth);
u6: decoder port map( din => doutsl,dout => secondl); --秒的低位
u7: decoder port map( din => rdoutsh,dout => secondh); --秒的高位
u8: decoder port map( din => doutml,dout => minutel); --分的低位
u9: decoder port map( din => rdoutmh,dout => minuteh); --分的高位
u10: decoder port map( din => rdouth(3 downto 0),dout => hourh);--时的低位
u11: decoder port map( din => rdouth(7 downto 4),dout => hourl);--时的高位
end Behavioral;
我来回答
回答0个
时间排序
认可量排序
暂无数据
或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币
Markdown 语法
- 加粗**内容**
- 斜体*内容*
- 删除线~~内容~~
- 引用> 引用内容
- 代码`代码`
- 代码块```编程语言↵代码```
- 链接[链接标题](url)
- 无序列表- 内容
- 有序列表1. 内容
- 缩进内容
- 图片![alt](url)
相关问答
-
2008-10-02 20:27:32
-
2008-10-02 20:20:48
-
2008-10-02 20:52:33
-
2008-10-02 20:25:24
-
2008-10-02 20:47:54
-
2008-10-02 20:42:12
-
2008-10-02 20:26:30
-
2008-10-02 20:40:04
-
2012-12-24 15:01:43
-
2017-03-01 11:39:25
-
2008-10-02 20:46:03
-
2008-10-02 20:17:49
-
2008-10-02 20:17:06
-
2016-08-18 14:06:53
-
2012-12-24 14:41:40
-
2008-10-02 20:15:51
-
2018-10-11 10:58:30
-
2008-10-02 20:18:52
-
2013-08-28 12:11:15
无更多相似问答 去提问
点击登录
-- 积分
-- E币
提问
—
收益
—
被采纳
—
我要提问
切换马甲
上一页
下一页
悬赏问答
-
5Hi3516CV610 如何使用SD卡升级固件
-
5cat /dev/logmpp 报错 <3>[ vi] [func]:vi_send_frame_node [line]:99 [info]:vi pic queue is full!
-
50如何获取vpss chn的图像修改后发送至vo
-
5FPGA通过Bt1120传YUV422数据过来,vi接收不到数据——3516dv500
-
50SS928 运行PQtools 拼接 推到设备里有一半画面会异常
-
53536AV100的sample_vdec输出到CVBS显示
-
10海思板子mpp怎么在vi阶段改变视频数据尺寸
-
10HI3559AV100 多摄像头同步模式
-
9海思ss928单路摄像头vio中加入opencv处理并显示
-
10EB-RV1126-BC-191板子运行自己编码的程序
举报反馈
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明
提醒
你的问题还没有最佳答案,是否结题,结题后将扣除20%的悬赏金
取消
确认
提醒
你的问题还没有最佳答案,是否结题,结题后将根据回答情况扣除相应悬赏金(1回答=1E币)
取消
确认