EDA课程设计五进制计数器的VHDL语言设计的源程序
设计要求:1、设计一个五进制的计数器,由两个控制键SEL控制不同的计数方式2、当SEL=00时,按0、1、2、3、4、0、1、2、3、4…顺序计数3、当SEL=01时,按...
设计要求:
1、设计一个五进制的计数器,由两个控制键SEL控制不同的计数方式
2、当SEL=00时,按0、1、2、3、4、0、1、2、3、4…顺序计数
3、当SEL=01时,按0、2、4、6、8、0、2、4、6、8…顺序计数
4、当SEL=10时,按1、3、5、7、9、1、3、5、7、9…顺序计数
5、当SEL=11时,按5、4、3、2、1、5、4、3、2、1…顺序计数
6、由数码管分别译码显示控制信号和计数状态,分别用3位数码管动态显示
7、给出VHDL语言设计的源程序
十万火急!!! 展开
1、设计一个五进制的计数器,由两个控制键SEL控制不同的计数方式
2、当SEL=00时,按0、1、2、3、4、0、1、2、3、4…顺序计数
3、当SEL=01时,按0、2、4、6、8、0、2、4、6、8…顺序计数
4、当SEL=10时,按1、3、5、7、9、1、3、5、7、9…顺序计数
5、当SEL=11时,按5、4、3、2、1、5、4、3、2、1…顺序计数
6、由数码管分别译码显示控制信号和计数状态,分别用3位数码管动态显示
7、给出VHDL语言设计的源程序
十万火急!!! 展开
3个回答
展开全部
随便编了一个,能通过仿真。
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity cnt5 is
port(clk,rst:in std_logic;
SEL:in std_logic_vector(1 downto 0);
data1_out,data2_out,data3_out:out std_logic_vector(6 downto 0));
end cnt5;
architecture arch of cnt5 is
signal count:integer range 0 to 9;
signal state:std_logic_vector(1 downto 0);
begin
process(clk,rst)
begin
if rst='1' then
state<="00";data1_out<="1111110";data2_out<="1111110";data3_out<="1111110";count<=0;
elsif clk'event and clk='1' then
case state is
when "00" =>
data1_out<="1111110";data2_out<="1111110";
if count=4 then count<=0; else count<=count+1;end if;
case SEL is
when "01" => state<="01";count<=0;
when "10" => state<="10";count<=1;
when "11" => state<="11";count<=5;
when others => null;
end case;
when "01" =>
data1_out<="1111110";data2_out<="0110000";
if count=8 then count<=0; else count<=count+2;end if;
case SEL is
when "00" => state<="00";count<=0;
when "10" => state<="10";count<=1;
when "11" => state<="11";count<=5;
when others => null;
end case;
when "10" =>
data1_out<="0110000";data2_out<="1111110";
if count=9 then count<=1; else count<=count+2;end if;
case SEL is
when "00" => state<="00";count<=0;
when "01" => state<="01";count<=0;
when "11" => state<="11";count<=5;
when others => null;
end case;
when "11" =>
data1_out<="0110000";data2_out<="0110000";
if count=1 then count<=5; else count<=count-1;end if;
case SEL is
when "00" => state<="00";count<=0;
when "01" => state<="01";count<=0;
when "10" => state<="10";count<=1;
when others => null;
end case;
when others => state <= "00";
end case;
case count is
when 0 => data3_out<="1111110";
when 1 => data3_out<="0110000";
when 2 => data3_out<="1101101";
when 3 => data3_out<="1111001";
when 4 => data3_out<="0110011";
when 5 => data3_out<="1011011";
when 6 => data3_out<="1011111";
when 7 => data3_out<="1110000";
when 8 => data3_out<="1111111";
when 9 => data3_out<="1111011";
when others => data3_out<="0000000";
end case;
end if;
end process;
end arch;
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity cnt5 is
port(clk,rst:in std_logic;
SEL:in std_logic_vector(1 downto 0);
data1_out,data2_out,data3_out:out std_logic_vector(6 downto 0));
end cnt5;
architecture arch of cnt5 is
signal count:integer range 0 to 9;
signal state:std_logic_vector(1 downto 0);
begin
process(clk,rst)
begin
if rst='1' then
state<="00";data1_out<="1111110";data2_out<="1111110";data3_out<="1111110";count<=0;
elsif clk'event and clk='1' then
case state is
when "00" =>
data1_out<="1111110";data2_out<="1111110";
if count=4 then count<=0; else count<=count+1;end if;
case SEL is
when "01" => state<="01";count<=0;
when "10" => state<="10";count<=1;
when "11" => state<="11";count<=5;
when others => null;
end case;
when "01" =>
data1_out<="1111110";data2_out<="0110000";
if count=8 then count<=0; else count<=count+2;end if;
case SEL is
when "00" => state<="00";count<=0;
when "10" => state<="10";count<=1;
when "11" => state<="11";count<=5;
when others => null;
end case;
when "10" =>
data1_out<="0110000";data2_out<="1111110";
if count=9 then count<=1; else count<=count+2;end if;
case SEL is
when "00" => state<="00";count<=0;
when "01" => state<="01";count<=0;
when "11" => state<="11";count<=5;
when others => null;
end case;
when "11" =>
data1_out<="0110000";data2_out<="0110000";
if count=1 then count<=5; else count<=count-1;end if;
case SEL is
when "00" => state<="00";count<=0;
when "01" => state<="01";count<=0;
when "10" => state<="10";count<=1;
when others => null;
end case;
when others => state <= "00";
end case;
case count is
when 0 => data3_out<="1111110";
when 1 => data3_out<="0110000";
when 2 => data3_out<="1101101";
when 3 => data3_out<="1111001";
when 4 => data3_out<="0110011";
when 5 => data3_out<="1011011";
when 6 => data3_out<="1011111";
when 7 => data3_out<="1110000";
when 8 => data3_out<="1111111";
when 9 => data3_out<="1111011";
when others => data3_out<="0000000";
end case;
end if;
end process;
end arch;
展开全部
随便编了一个,能通过仿真。
library
ieee;
use
ieee.std_logic_1164.all;
use
ieee.std_logic_unsigned.all;
entity
cnt5
is
port(clk,rst:in
std_logic;
SEL:in
std_logic_vector(1
downto
0);
data1_out,data2_out,data3_out:out
std_logic_vector(6
downto
0));
end
cnt5;
architecture
arch
of
cnt5
is
signal
count:integer
range
0
to
9;
signal
state:std_logic_vector(1
downto
0);
begin
process(clk,rst)
begin
if
rst='1'
then
state<="00";data1_out<="1111110";data2_out<="1111110";data3_out<="1111110";count<=0;
elsif
clk'event
and
clk='1'
then
case
state
is
when
"00"
=>
data1_out<="1111110";data2_out<="1111110";
if
count=4
then
count<=0;
else
count<=count+1;end
if;
case
SEL
is
when
"01"
=>
state<="01";count<=0;
when
"10"
=>
state<="10";count<=1;
when
"11"
=>
state<="11";count<=5;
when
others
=>
null;
end
case;
when
"01"
=>
data1_out<="1111110";data2_out<="0110000";
if
count=8
then
count<=0;
else
count<=count+2;end
if;
case
SEL
is
when
"00"
=>
state<="00";count<=0;
when
"10"
=>
state<="10";count<=1;
when
"11"
=>
state<="11";count<=5;
when
others
=>
null;
end
case;
when
"10"
=>
data1_out<="0110000";data2_out<="1111110";
if
count=9
then
count<=1;
else
count<=count+2;end
if;
case
SEL
is
when
"00"
=>
state<="00";count<=0;
when
"01"
=>
state<="01";count<=0;
when
"11"
=>
state<="11";count<=5;
when
others
=>
null;
end
case;
when
"11"
=>
data1_out<="0110000";data2_out<="0110000";
if
count=1
then
count<=5;
else
count<=count-1;end
if;
case
SEL
is
when
"00"
=>
state<="00";count<=0;
when
"01"
=>
state<="01";count<=0;
when
"10"
=>
state<="10";count<=1;
when
others
=>
null;
end
case;
when
others
=>
state
<=
"00";
end
case;
case
count
is
when
0
=>
data3_out<="1111110";
when
1
=>
data3_out<="0110000";
when
2
=>
data3_out<="1101101";
when
3
=>
data3_out<="1111001";
when
4
=>
data3_out<="0110011";
when
5
=>
data3_out<="1011011";
when
6
=>
data3_out<="1011111";
when
7
=>
data3_out<="1110000";
when
8
=>
data3_out<="1111111";
when
9
=>
data3_out<="1111011";
when
others
=>
data3_out<="0000000";
end
case;
end
if;
end
process;
end
arch;
library
ieee;
use
ieee.std_logic_1164.all;
use
ieee.std_logic_unsigned.all;
entity
cnt5
is
port(clk,rst:in
std_logic;
SEL:in
std_logic_vector(1
downto
0);
data1_out,data2_out,data3_out:out
std_logic_vector(6
downto
0));
end
cnt5;
architecture
arch
of
cnt5
is
signal
count:integer
range
0
to
9;
signal
state:std_logic_vector(1
downto
0);
begin
process(clk,rst)
begin
if
rst='1'
then
state<="00";data1_out<="1111110";data2_out<="1111110";data3_out<="1111110";count<=0;
elsif
clk'event
and
clk='1'
then
case
state
is
when
"00"
=>
data1_out<="1111110";data2_out<="1111110";
if
count=4
then
count<=0;
else
count<=count+1;end
if;
case
SEL
is
when
"01"
=>
state<="01";count<=0;
when
"10"
=>
state<="10";count<=1;
when
"11"
=>
state<="11";count<=5;
when
others
=>
null;
end
case;
when
"01"
=>
data1_out<="1111110";data2_out<="0110000";
if
count=8
then
count<=0;
else
count<=count+2;end
if;
case
SEL
is
when
"00"
=>
state<="00";count<=0;
when
"10"
=>
state<="10";count<=1;
when
"11"
=>
state<="11";count<=5;
when
others
=>
null;
end
case;
when
"10"
=>
data1_out<="0110000";data2_out<="1111110";
if
count=9
then
count<=1;
else
count<=count+2;end
if;
case
SEL
is
when
"00"
=>
state<="00";count<=0;
when
"01"
=>
state<="01";count<=0;
when
"11"
=>
state<="11";count<=5;
when
others
=>
null;
end
case;
when
"11"
=>
data1_out<="0110000";data2_out<="0110000";
if
count=1
then
count<=5;
else
count<=count-1;end
if;
case
SEL
is
when
"00"
=>
state<="00";count<=0;
when
"01"
=>
state<="01";count<=0;
when
"10"
=>
state<="10";count<=1;
when
others
=>
null;
end
case;
when
others
=>
state
<=
"00";
end
case;
case
count
is
when
0
=>
data3_out<="1111110";
when
1
=>
data3_out<="0110000";
when
2
=>
data3_out<="1101101";
when
3
=>
data3_out<="1111001";
when
4
=>
data3_out<="0110011";
when
5
=>
data3_out<="1011011";
when
6
=>
data3_out<="1011111";
when
7
=>
data3_out<="1110000";
when
8
=>
data3_out<="1111111";
when
9
=>
data3_out<="1111011";
when
others
=>
data3_out<="0000000";
end
case;
end
if;
end
process;
end
arch;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
呵呵,我也想要这个,一模一样的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询