📄 twototen.vhd
字号:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity twototen is
port(in_2:in std_logic_vector(7 downto 0);
out1:out std_logic_vector(6 downto 0);--百位
out2:out std_logic_vector(6 downto 0);--十位
out3:out std_logic_vector(6 downto 0) --个位
);
end twototen;
architecture zh of twototen is
signal a:std_logic_vector(3 downto 0);
signal b:std_logic_vector(3 downto 0);
signal c:std_logic_vector(3 downto 0);
begin
process(in_2)
variable in1 :std_logic_vector(7 downto 0);
begin
in1:=in_2(7 downto 0);
a<="0000";
b<="0000";
c<="0000";
if in1>"11000111" then --199
in1:=in1-"11001000";
a<="0010";
end if;
if in1>"01100011" then --99
in1:=in1-"01100100";
a<="0001";
end if;
if in1>"01011001" then --89
in1:=in1-"1011010";
b<="1001";
end if;
if in1>"01001111" then --79
in1:=in1-"1010000";
b<="1000";
end if;
if in1>"01000101" then --69
in1:=in1-"1000110";
b<="0111";
end if;
if in1>"00111011" then --59
in1:=in1-"1000110";
b<="0110";
end if;
if in1>"00110001" then --49
in1:=in1-"00110010";
b<="0101";
end if;
if in1>"00100111" then --39
in1:=in1-"00101000";
b<="0100";
end if;
if in1>"00011101" then --29
in1:=in1-"00011110";
b<="0011";
end if;
if in1>"00010011" then --19
in1:=in1-"00010100";
b<="0010";
end if;
if in1>"00001001" then --9
in1:=in1-"00001010";
b<="0001";
end if;
if in1<="00001001" then --9
c<=in1(3 downto 0);
end if;
end process ;
process(a)
begin
if (a="0000") then
out1<="1111110";
elsif (a="0001") then
out1<="0110000";
elsif (a="0010") then
end if;
end process ;
process(b)
begin
if (b="0000") then
out2<="1111110";
elsif (b="0001") then
out2<="0110000";
elsif (b="0010") then
out2<="1101101";
elsif (b="0011") then
out2<="1111001";
elsif (b="0100") then
out2<="0110011";
elsif (b="0101") then
out2<="1011011";
elsif (b="0110") then
out2<="1011111";
elsif (b="0111") then
out2<="1110000";
elsif (b="1000") then
out2<="1111111";
elsif (b="1001") then
out2<="1111011";
elsif (b="1010") then
out2<="1111110";
elsif (b="1011") then
out2<="0110000";
elsif (b="1100") then
out2<="1101101";
elsif (b="1101") then
out2<="1111001";
elsif (b="1110") then
out2<="0110011";
elsif (b="1111") then
out2<="1011011";
end if;
end process ;
process(c)
begin
if (c="0000") then
out3<="1111110";
elsif (c="0001") then
out3<="0110000";
elsif (c="0010") then
out3<="1101101";
elsif (c="0011") then
out3<="1111001";
elsif (c="0100") then
out3<="0110011";
elsif (c="0101") then
out3<="1011011";
elsif (c="0110") then
out3<="1011111";
elsif (c="0111") then
out3<="1110000";
elsif (c="1000") then
out3<="1111111";
elsif (c="1001") then
out3<="1111011";
elsif (c="1010") then
out3<="1111110";
elsif (c="1011") then
out3<="0110000";
elsif (c="1100") then
out3<="1101101";
elsif (c="1101") then
out3<="1111001";
elsif (c="1110") then
out3<="0110011";
elsif (c="1111") then
out3<="1011011";
end if;
end process ;
end zh;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -