library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; --file that calculates wind direction entity winddirection 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 winddirection; architecture behaviour of winddirection 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 qa,qb,qc,qd: std_logic; begin changingstate: process(clock) begin --latch for the incoming values if rising_edge(clock) then qa <= a; qb <= b; qc <= c; qd <= d; end if; --for the directions --for north end process changingstate; --following if statements that go through the various combinations of directions --the appropriate ascii directional letters are then output changingsecondstate2: process(clock) begin if rising_edge(clock) then if (qa = '0') and (qb ='0') and (qc = '0') and (qd ='0') then --for north windfirstdir <= lettern; windseconddir <= letterspace; windthirddir <= letterspace; end if; if (qa = '0') and (qb ='0') and (qc = '0') and (qd ='1') then --for nne windfirstdir <= lettern; windseconddir <= lettern; windthirddir <= lettere; end if; if (qa = '0') and (qb ='0') and (qc = '1') and (qd ='1') then --for ne windfirstdir <= lettern; windseconddir <= lettere; windthirddir <= letterspace; end if; if (qa = '0') and (qb ='0') and (qc = '1') and (qd ='0') then --for ene windfirstdir <= lettere; windseconddir <= lettern; windthirddir <= lettere; end if; if (qa = '0') and (qb ='1') and (qc = '1') and (qd ='0') then --for e windfirstdir <= lettere; windseconddir <= letterspace; windthirddir <= letterspace; end if; if (qa = '0') and (qb ='1') and (qc = '0') and (qd ='0') then --for ese windfirstdir <= lettere; windseconddir <= letters; windthirddir <= lettere; end if; if (qa = '0') and (qb ='1') and (qc = '0') and (qd ='1') then --for se windfirstdir <= letters; windseconddir <= lettere; windthirddir <= letterspace; end if; if (qa = '0') and (qb ='1') and (qc = '1') and (qd ='1') then --for sse windfirstdir <= letters; windseconddir <= letters; windthirddir <= lettere; end if; if (qa = '1') and (qb ='1') and (qc = '1') and (qd ='1') then --for south windfirstdir <= letters; windseconddir <= letterspace; windthirddir <= letterspace; end if; if (qa = '1') and (qb ='1') and (qc = '1') and (qd ='0') then --for ssw windfirstdir <= letters; windseconddir <= letters; windthirddir <= letterw; end if; if (qa = '1') and (qb ='1') and (qc = '0') and (qd ='0') then --for sw windfirstdir <= letters; windseconddir <= letterw; windthirddir <= letterspace; end if; if (qa = '1') and (qb ='1') and (qc = '0') and (qd ='1') then --for wsw windfirstdir <= letterw; windseconddir <= letters; windthirddir <= letterw; end if; if (qa = '1') and (qb ='0') and (qc = '0') and (qd ='1') then --for w windfirstdir <= letterw; windseconddir <= letterspace; windthirddir <= letterspace; end if; if (qa = '1') and (qb ='0') and (qc = '1') and (qd ='1') then --for wnw windfirstdir <= letterw; windseconddir <= lettern; windthirddir <= letterw; end if; if (qa = '1') and (qb ='0') and (qc = '1') and (qd ='0') then --for nw windfirstdir <= lettern; windseconddir <= letterw; windthirddir <= letterspace; end if; if (qa = '1') and (qb ='0') and (qc = '0') and (qd ='0') then --for nnw windfirstdir <= lettern; windseconddir <= lettern; windthirddir <= letterw; end if; end if; end process changingsecondstate2; end behaviour;