📄 tlc5620.vhd
字号:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity tlc5620 is
port(
clk,rng,a0,a1:in std_logic;
ladc,load:buffer std_logic;
data:out std_logic;
daclk:buffer std_logic
);
end;
architecture arc of tlc5620 is
signal count:std_logic_vector(3 downto 0);
signal ct:std_logic_vector(1 downto 0);
signal ck,tp:std_logic;
signal q:std_logic_vector(7 downto 0);
signal sload,sa0,sa1,srng:std_logic;
type rom is array(0 to 62) of integer range 0 to 255;
constant sindata:rom:=(255, 254,252,249,245,239,233,225,217,207,197,186,174,162,150,137,124,112,99,87,75,64,53,43,34,
26,19,13,8,4,1,0,1,4,8,13,19,26,34,43,53,64,75,87,99,112,124,137,150,162,174,186,197,207,217,225,
233,239,245,249,252,254,255);
begin
daclk<=ck and load;
ladc<='0';
load<=sload;
sa0<=a0;
sa1<=a1;
srng<=rng;
process(clk)
begin
if rising_edge(clk) then
if ct<="01" then
ck<='1';
else
ck<='0';
end if;
ct<=ct+1;
end if;
end process;
process(ck)
begin
if rising_edge(ck) then
if count<="1010" then --发送的数据为11位
sload<='1';
tp<='1';
else
sload<='0';
tp<='0';
end if;
count<=count+1;
end if;
end process;
process(daclk)
begin
if rising_edge(daclk) then --发送的数据:A1,A0,RNG,D(7 downto)
if sload='1' then
case count is
when "0000"=>data<=sa1;
when "0001"=>data<=sa0;
when "0010"=>data<=srng;
when "0011"=>data<=q(7);
when "0100"=>data<=q(6);
when "0101"=>data<=q(5);
when "0110"=>data<=q(4);
when "0111"=>data<=q(3);
when "1000"=>data<=q(2);
when "1001"=>data<=q(1);
when "1010"=>data<=q(0);
when others=>null;
-- when others=>data<='Z';
end case;
end if;
end if;
end process;
process(tp)
variable tmp:integer range 0 to 255;
begin
if rising_edge(tp) then
if tmp=62 then
tmp:=0;
else
tmp:=tmp+1;
end if;
q<=conv_std_logic_vector(sindata(tmp),8);
-- q<=conv_std_logic_vector(tmp,8);
-- case tmp is
-- when 00=>q<=x"ff"; when 01=>q<=x"fe";when 02=>q<=conv_std_logic_vector(252,8);
-- when 03=>q<=conv_std_logic_vector(249,8);when 04=>q<=conv_std_logic_vector(245,8);
-- when 05=>q<=conv_std_logic_vector(239,8);when 06=>q<=conv_std_logic_vector(233,8);
-- when 07=>q<=conv_std_logic_vector(225,8);when 08=>q<=conv_std_logic_vector(217,8);
-- when 09=>q<=conv_std_logic_vector(207,8);when 10=>q<=conv_std_logic_vector(197,8);
-- when 11=>q<=conv_std_logic_vector(186,8);when 12=>q<=conv_std_logic_vector(174,8);
-- when 13=>q<=conv_std_logic_vector(162,8);when 14=>q<=conv_std_logic_vector(150,8);
-- when 15=>q<=conv_std_logic_vector(137,8);when 16=>q<=conv_std_logic_vector(124,8);
-- when 17=>q<=conv_std_logic_vector(112,8);when 18=>q<=conv_std_logic_vector(99,8);
-- when 19=>q<=conv_std_logic_vector(87,8);when 20=>q<=conv_std_logic_vector(75,8);
-- when 21=>q<=conv_std_logic_vector(64,8);when 22=>q<=conv_std_logic_vector(53,8);
-- when 23=>q<=conv_std_logic_vector(43,8);when 24=>q<=conv_std_logic_vector(34,8);
-- when 25=>q<=conv_std_logic_vector(26,8);when 26=>q<=conv_std_logic_vector(19,8);
-- when 27=>q<=conv_std_logic_vector(13,8);when 28=>q<=conv_std_logic_vector(8,8);
-- when 29=>q<=conv_std_logic_vector(4,8);when 30=>q<=conv_std_logic_vector(1,8);
-- when 31=>q<=conv_std_logic_vector(0,8);when 32=>q<=conv_std_logic_vector(0,8);
-- when 33=>q<=conv_std_logic_vector(1,8);when 34=>q<=conv_std_logic_vector(4,8);
-- when 35=>q<=conv_std_logic_vector(8,8);when 36=>q<=conv_std_logic_vector(13,8);
-- when 37=>q<=conv_std_logic_vector(19,8);when 38=>q<=conv_std_logic_vector(26,8);
-- when 39=>q<=conv_std_logic_vector(34,8);when 40=>q<=conv_std_logic_vector(43,8);
-- when 41=>q<=conv_std_logic_vector(53,8);when 42=>q<=conv_std_logic_vector(64,8);
-- when 43=>q<=conv_std_logic_vector(75,8);when 44=>q<=conv_std_logic_vector(87,8);
-- when 45=>q<=conv_std_logic_vector(99,8);when 46=>q<=conv_std_logic_vector(112,8);
-- when 47=>q<=conv_std_logic_vector(124,8);when 48=>q<=conv_std_logic_vector(137,8);
-- when 49=>q<=conv_std_logic_vector(150,8);when 50=>q<=conv_std_logic_vector(162,8);
-- when 51=>q<=conv_std_logic_vector(174,8);when 52=>q<=conv_std_logic_vector(186,8);
-- when 53=>q<=conv_std_logic_vector(197,8);when 54=>q<=conv_std_logic_vector(207,8);
-- when 55=>q<=conv_std_logic_vector(217,8);when 56=>q<=conv_std_logic_vector(225,8);
-- when 57=>q<=conv_std_logic_vector(233,8);when 58=>q<=conv_std_logic_vector(239,8);
-- when 59=>q<=conv_std_logic_vector(245,8);when 60=>q<=conv_std_logic_vector(249,8);
-- when 61=>q<=conv_std_logic_vector(252,8);when 62=>q<=conv_std_logic_vector(254,8);
-- when 63=>q<=conv_std_logic_vector(255,8);
-- when others=>null;
-- end case;
end if;
end process;
end arc;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -