library ieee;

use ieee.std_logic_1164.all;

use ieee.std_logic_arith.all;

use ieee.std_logic_unsigned.all;

entity projectwinddirection is

generic(winddirwidth: positive := 8);

port (clock, a,b,c,d: in std_logic;

windfirstdir: buffer std_logic_vector(winddirwidth-1 downto 0);

windseconddir: buffer std_logic_vector(winddirwidth-1 downto 0);

windthirddir: buffer std_logic_vector(winddirwidth-1 downto 0));

end projectwinddirection;

architecture behaviour of projectwinddirection is

--constants for the outgoing letters

constant lettern: std_logic_vector(winddirwidth-1 downto 0):= "01001110";

constant lettere: std_logic_vector(winddirwidth-1 downto 0):= "01000101";

constant letters: std_logic_vector(winddirwidth-1 downto 0) := "01010011";

constant letterw: std_logic_vector(winddirwidth-1 downto 0) := "01010111";

constant letterspace: std_logic_vector(winddirwidth-1 downto 0) := "00100000";

--signals

signal qn,qe,qw,qs: std_logic;

begin

changingflipflopstate: process(clock)

begin

if rising_edge(clock) then

-- a (for north), b for east, c for south, d for west

qn <= a;

qe <= b;

qs <= c;

qw <= d;

end if;

--doing the outputs

--for north

end process changingflipflopstate;

changingstate: process(clock, qn,qe,qs,qw)

begin

if rising_edge(clock) then

--for the directions

--for north

if (qn = '0') and (qe = '0') and (qs = '0') and (qw = '0') then

windfirstdir <= lettern;

windseconddir <= letterspace;

windthirddir <= letterspace;

end if;

--for the nne

if (qn = '0') and (qe = '0') and (qs = '0') and (qw = '1') then

windfirstdir <= lettern;

windseconddir <= lettern;

windthirddir <= lettere;

end if;

end if;

--for ne

if (qn = '0') and (qe = '0') and (qs = '1') and (qw = '1') then

windfirstdir <= lettern;

windseconddir <= lettere;

windthirddir <= letterspace;

end if;

--for e

if (qn = '0') and (qe = '1') and (qs = '1') and (qw = '0') then

windfirstdir <= lettere;

windseconddir <= letterspace;

windthirddir <= letterspace;

end if;

--for ese

if (qn = '0') and (qe = '1') and (qs = '0') and (qw = '0') then

windfirstdir <= lettere;

windseconddir <= letters;

windthirddir <= lettere;

end if;

--for se

if (qn = '0') and (qe = '1') and (qs = '0') and (qw = '1') then

windfirstdir <= letters;

windseconddir <= lettere;

windthirddir <= letterspace;

end if;

--for sse

if (qn = '0') and (qe = '1') and (qs = '1') and (qw = '0') then

windfirstdir <= letters;

windseconddir <= letters;

windthirddir <= lettere;

end if;

--for s

if (qn = '1') and (qe = '1') and (qs = '1') and (qw = '1') then

windfirstdir <= letters;

windseconddir <= letterspace;

windthirddir <= letterspace;

end if;

--for ssw

if (qn = '1') and (qe = '1') and (qs = '1') and (qw = '0') then

windfirstdir <= letters;

windseconddir <= letterw;

windthirddir <= letterw;

end if;

--for sw

if (qn = '1') and (qe = '1') and (qs = '0') and (qw = '0') then

windfirstdir <= letters;

windseconddir <= letterw;

windthirddir <= letterspace;

end if;

--for wsw

if (qn = '1') and (qe = '1') and (qs = '0') and (qw = '1') then

windfirstdir <= letterw;

windseconddir <= letters;

windthirddir <= letterw;

end if;

--for w

if (qn = '1') and (qe = '0') and (qs = '0') and (qw = '1') then

windfirstdir <= letterw;

windseconddir <= letterspace;

windthirddir <= letterspace;

end if;

--for wnw

if (qn = '1') and (qe = '0') and (qs = '1') and (qw = '1') then

windfirstdir <= letterw;

windseconddir <= lettern;

windthirddir <= letterw;

end if;

--for nw

if (qn = '1') and (qe = '0') and (qs = '1') and (qw = '0') then

windfirstdir <= lettern;

windseconddir <= letterw;

windthirddir <= letterspace;

end if;

--for nnw

if (qn = '1') and (qe = '0') and (qs = '0') and (qw = '0') then

windfirstdir <= lettern;

windseconddir <= lettern;

windthirddir <= letterw;

end if;

end process changingstate;

end behaviour;

 --click here to return to the original page