📄 gpsdecoder.vhd
字号:
--File Name: GPSdecoder
--Function : extract data,time,and status of GPS infomation
--Data : 2008.3.29
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity GPSdecoder is
port(GPSinfo :in std_logic_vector(7 downto 0);
wr :in std_logic;
ale :out std_logic;
ABus :out std_logic_vector(7 downto 0);
DBus :out std_logic_vector(7 downto 0)
);
end GPSdecoder;
architecture Behavioral of GPSdecoder is
--define address
constant month_add : std_logic_vector(7 downto 0):="11111000"; --f8
constant day_add : std_logic_vector(7 downto 0):="11111001"; --f9
constant year_add : std_logic_vector(7 downto 0):="11111010"; --fa
constant hour_add : std_logic_vector(7 downto 0):="11111011"; --fb
constant minu_add : std_logic_vector(7 downto 0):="11111100"; --fc
constant secd_add : std_logic_vector(7 downto 0):="11111101"; --fd
constant state_add : std_logic_vector(7 downto 0):="11111110"; --fe
constant nullc : std_logic_vector(7 downto 0):="00000000";
--define signal
signal state : std_logic_vector(4 downto 0) := "00000";
signal comma : std_logic_vector(3 downto 0) := "0000";
signal temp1,temp2,temp3,sumt : std_logic_vector(7 downto 0);
signal num : std_logic_vector(7 downto 0);
--begin
begin
pro1:process(wr,num)
begin
if rising_edge(wr) then
num <= GPSinfo;
end if;
end process;
pro2:process(wr)
--$GPRMC,0123456789
--24 47 50 52 4d 43 2c 30 31 32 33 34 35 36 37 38 39
begin
if rising_edge(wr) then
case state is
when "00000" =>
ale <= '0';
if num="00100100" then --$ 24
state <= state + 1;
else
state <= "00000";
end if;
when "00001" =>
--ale <= '0';
if num="01000111" then --G 47
state <= state + 1;
else
state <= "00000";
end if;
when "00010" =>
--ale <= '0';
if num="01010000" then --P 50
state <= state + 1;
else
state <= "00000";
end if;
when "00011" =>
--ale <= '0';
if num="01010010" then --R 52
state <= state + 1;
else
state <= "00000";
end if;
when "00100" =>
--ale <= '0';
if num="01001101" then --M 4d
state <= state + 1;
else
state <= "00000";
end if;
when "00101" =>
--ale <= '0';
if num="01000011" then --C 43
state <= state + 1;
else
state <= "00000";
end if;
when "00110" => --comma
--ale <= '0';
state <= state + 1;
when "00111" => --hour high
temp1 <= "0" & num(3 downto 0) & "000"; --*8
temp2 <= "000" & num(3 downto 0) & "0"; --*2
--ale <= '0';
state <= state + 1;
when "01000" => --hour low
temp3 <= "0000" & num(3 downto 0);
sumt <= temp1 + temp2;
state <= state + 1;
when "01001" => --minu high
temp1 <= "0" & num(3 downto 0) & "000"; --*8
temp2 <= "000" & num(3 downto 0) & "0"; --*2
--output hour
ABus <= hour_add;
DBus <= sumt + temp3;
ale <= '1';
--
state <= state + 1;
when "01010" => --minu low
temp3 <= "0000" & num(3 downto 0);
sumt <= temp1 + temp2;
ale <= '0';
state <= state + 1;
when "01011" => --second high
temp1 <= "0" & num(3 downto 0) & "000"; --*8
temp2 <= "000" & num(3 downto 0) & "0"; --*2
--output minute
ABus <= minu_add;
DBus <= sumt + temp3;
ale <= '1';
--
state <= state + 1;
when "01100" => --second low
temp3 <= "0000" & num(3 downto 0);
sumt <= temp1 + temp2;
ale <= '0';
state <= state + 1;
when "01101" => --.
--output second
ABus <= secd_add;
DBus <= sumt +temp3;
ale <= '1';
state <= "11010";
when "11010" => --minisecond
ale <= '0';
state <= state + 1;
when "11011" =>
state <= state +1;
when "11100" =>
state <= state + 1;
when "11101" => --,
state <= "01110";
when "01110" => --status
temp1 <= num;
state <= state + 1;
when "01111" => --comma
comma <= "0011";
--output status
ABus <= state_add;
DBus <= temp1;
ale <= '1';
--
state <= state +1;
when "10000" =>
ale <= '0';
if num="00101100" then --comma
comma <= comma + 1;
state <= state +1;
else
state <= state;
end if;
when "10001" =>
if comma="1001" then --day high
state <= state + 1;
temp1 <= "0" & num(3 downto 0) & "000"; --*8
temp2 <= "000" & num(3 downto 0) & "0"; --*2
else
state <= "10000";
end if;
when "10010" => --day low
comma <= "0000";
temp3 <= "0000" & num(3 downto 0);
sumt <= temp1 + temp2;
state <= state + 1;
when "10011" => --month high
temp1 <= "0" & num(3 downto 0) & "000"; --*8
temp2 <= "000" & num(3 downto 0) & "0"; --*2
--output day
ABus <= day_add;
DBus <= sumt + temp3;
ale <= '1';
--
state <= state + 1;
when "10100" => --month low
temp3 <= "0000" & num(3 downto 0);
sumt <= temp1 + temp2;
ale <= '0';
state <= state +1;
when "10101" => --year high
temp1 <= "0" & num(3 downto 0) & "000"; --*8
temp2 <= "000" & num(3 downto 0) & "0"; --*2
--output month
ABus <= month_add;
DBus <= sumt + temp3;
ale <= '1';
--
state <= state + 1;
when "10110" => --year low
temp3 <= "0000" & num(3 downto 0);
sumt <= temp1 + temp2;
ale <= '0';
state <= state + 1;
when "10111" => --comma
--output year
ABus <= year_add;
DBus <= sumt + temp3;
ale <= '1';
--
state <= "00000";
when others =>
ale <= '0';
state <= "00000";
end case;
end if;
end process;
end Behavioral;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -