📄 two_to_ten.vhd
字号:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity two_to_ten is
port( specified_temp:in std_logic_vector(9 downto 0);----设定温度
temp:in std_logic_vector(9 downto 0);---------------测量温度
show_set:std_logic;---------------------------------显示选择
inte_ten:out std_logic_vector(3 downto 0); ---------整数十位
inte_one:out std_logic_vector(3 downto 0); ---------整数个位
deci_ten:out std_logic_vector(3 downto 0); ---------小数十分位
deci_one:out std_logic_vector(3 downto 0); ---------小数百分位
dot:out std_logic);
end two_to_ten;
architecture behav of two_to_ten is
signal t:std_logic_vector(9 downto 0);
signal deci:std_logic_vector(3 downto 0);
signal inte:std_logic_vector(5 downto 0);
begin
process( show_set,inte,deci,t,specified_temp,temp)
begin
dot<='1';
if show_set='1' then t<=specified_temp;
else t<=temp;
end if;
inte<=t(9 downto 4);
deci<=t(3 downto 0);
---------------------------------------整数部分
if inte<"011110" then ----<30
if inte>="001010" then ----->=10
if inte>="010100" then inte_ten<="0010";------>=20
if inte="010100" then inte_one<="0000";end if;-----21
if inte="010101" then inte_one<="0001";end if;-----22
if inte="010110" then inte_one<="0010";end if;-----23
if inte="010111" then inte_one<="0011";end if;-----24
if inte="011000" then inte_one<="0100";end if;-----25
if inte="011001" then inte_one<="0101";end if;-----26
if inte="011010" then inte_one<="0110";end if;-----27
if inte="011011" then inte_one<="0111";end if;-----28
if inte="011100" then inte_one<="1000";end if;-----28
if inte="011101" then inte_one<="1001";end if;-----29
else inte_ten<="0001";
if inte="001010" then inte_one<="0000";end if;-----10
if inte="001011" then inte_one<="0001";end if;-----11
if inte="001100" then inte_one<="0010";end if;-----12
if inte="001101" then inte_one<="0011";end if;-----13
if inte="001110" then inte_one<="0100";end if;-----14
if inte="001111" then inte_one<="0101";end if;-----15
if inte="010000" then inte_one<="0110";end if;-----16
if inte="010001" then inte_one<="0111";end if;-----17
if inte="010010" then inte_one<="1000";end if;-----18
if inte="010011" then inte_one<="0000";end if;-----19
end if;
else inte_ten<="0000"; --00~09
inte_one<=inte(3 downto 0);
end if;
elsif inte>="110010" then ------>=50
if inte>="111100" then inte_ten<="0110";--->=60
if inte="111100" then inte_one<="0000"; ------60
elsif inte="111101" then inte_one<="0001";----61
elsif inte="111110" then inte_one<="0010";----62
elsif inte="111111" then inte_one<="0011";----63
end if;
else inte_ten<="0101";
if inte="110010" then inte_one<="0000"; ------50
elsif inte="110011" then inte_one<="0001";----51
elsif inte="110100" then inte_one<="0010";----52
elsif inte="110101" then inte_one<="0011";----53
elsif inte="110111" then inte_one<="0100";----54
elsif inte="111000" then inte_one<="0101";----55
elsif inte="111001" then inte_one<="0110";----56
elsif inte="111010" then inte_one<="0111";----57
elsif inte="111011" then inte_one<="1000";----58
elsif inte="111100" then inte_one<="1000";----59
end if;
end if;
elsif inte>="101000" then inte_ten<="0100";
if (inte>="101000" and inte<="101111") then
inte_one(2 downto 0)<=inte(2 downto 0);inte_one(3)<='0';
elsif inte="110000" then inte_one<="1000";------48
elsif inte="110001" then inte_one<="1001";------49
end if;
else inte_ten<="0011";
if inte="011110" then inte_one<="0000"; -----30
elsif inte="011111" then inte_one<="0001";-----31
elsif inte="100000" then inte_one<="0010";-----32
elsif inte="100001" then inte_one<="0011";-----33
elsif inte="100010" then inte_one<="0100";-----34
elsif inte="100011" then inte_one<="0101";-----35
elsif inte="100100" then inte_one<="0110";-----36
elsif inte="100101" then inte_one<="0111";-----37
elsif inte="100110" then inte_one<="1000";-----38
elsif inte="100111" then inte_one<="1001";-----39
end if;
end if;
-------------------------------------------小数部分
if deci(3)='1' then
if deci(2)='1' then
if deci(1)='1' then
if deci(0)='1' then deci_ten<="1001";deci_one<="0100";---1111
else deci_ten<="1000";deci_one<="1000"; ----1110
end if;
elsif deci(0)='1' then deci_ten<="1000";deci_one<="0001";---1101
else deci_ten<="0111";deci_one<="0101"; ----1100
end if;
elsif deci(1)='1' then
if deci(0)='1' then deci_ten<="0110";deci_one<="1001";---1011
else deci_ten<="0110";deci_one<="0011"; ----1010
end if;
elsif deci(0)='1' then deci_ten<="0101";deci_one<="0110";---1001
else deci_ten<="0101";deci_one<="0000"; ----1000
end if;
elsif deci(2)='1' then
if deci(1)='1' then
if deci(0)='1' then deci_ten<="0100";deci_one<="0100";---0111
else deci_ten<="0011";deci_one<="1000"; ---0110
end if;
elsif deci(0)='1' then deci_ten<="0011";deci_one<="0001";---0101
else deci_ten<="0010";deci_one<="0101"; ----0100
end if;
elsif deci(1)='1' then
if deci(0)='1' then deci_ten<="0001";deci_one<="1001";----0011
else deci_ten<="0001";deci_one<="0011"; ----0010
end if;
elsif deci(0)='1' then deci_ten<="0000";deci_one<="0110";----0001
else deci_ten<="0000";deci_one<="0000"; ----0000
end if;
end process;
end behav;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -