library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; LIBRARY lpm; USE lpm.lpm_components.ALL; --file that does the temperature calculation entity temperature is generic( word:positive:=4; Pacewidth: positive:= 6); port( clock: in std_logic; polarity: in std_logic; indata : in std_logic_vector(word-1 downto 0) ; d5: in std_logic; d4: in std_logic; d3: in std_logic; d2 : in std_logic; d1: in std_logic; invstrobe: in std_logic; -- bcd5: buffer std_logic_vector(word-1 downto 0); -- bcd4: buffer std_logic_vector(word-1 downto 0); -- bcd3: buffer std_logic_vector(word-1 downto 0); -- bcd2: buffer std_logic_vector(word-1 downto 0); -- bcd1: buffer std_logic_vector(word-1 downto 0); ADC_CLOCK: out std_logic; number5: out std_logic_vector(7 downto 0); number4: out std_logic_vector(7 downto 0); number3: out std_logic_vector(7 downto 0); number2: out std_logic_vector(7 downto 0); number1: out std_logic_vector(7 downto 0); -- polarityout: out std_logic; polarityoutascii: out std_logic_vector(2*word -1 downto 0) ); end temperature; architecture behaviour of temperature is --declaration of signals signal bin1, bin2, bin4, bin8,pol : std_logic; signal d5read, d4read, d3read,d2read,d1read : std_logic; signal bcd5, bcd4, bcd3, bcd2, bcd1: std_logic_vector(word-1 downto 0); signal polarityout:std_logic; signal q: std_logic_vector(PaceWidth-1 downto 0); begin Pacecounter : lpm_counter GENERIC MAP (LPM_WIDTH => PaceWidth, LPM_TYPE => L_COUNTER) PORT MAP ( clock=> clock, -- sclr=> reset, q=> q); ADC_CLOCK <= q(PaceWidth-1); changingflipflopstate: process(clock) --obtains temp and polarity values from the analog to digital converter and latches them begin if rising_edge(clock) then if invstrobe = '0' then if d5 = '1' and d5read = '0' then bcd5 <= indata ; pol <= polarity; d5read <= '1'; d1read <= '0'; end if; if d4 = '1' and d4read = '0' then bcd4 <= indata ; d4read <= '1'; d5read <= '0'; end if; if d3 = '1' and d3read = '0' then bcd3 <= indata ; d3read <= '1'; d4read <= '0'; end if; if d2 = '1' and d2read = '0' then bcd2 <= indata ; d2read <= '1'; d3read <= '0'; end if; if d1 = '1' and d1read = '0' then bcd1 <= indata ; d1read <= '1'; d2read <= '0'; end if; end if; end if; polarityout <= polarity; --converts the BCD digits and polarity to ascii number5(7 downto 4) <= "0011"; number5(3 downto 0) <= bcd5 ; number4(7 downto 4) <= "0011"; number4(3 downto 0) <= bcd4 ; number3(7 downto 4) <= "0011"; number3(3 downto 0) <= bcd3 ; number2(7 downto 4) <= "0011"; number2(3 downto 0) <= bcd2 ; number1(7 downto 4) <= "0011"; number1(3 downto 0) <= bcd1 ; if polarity = '1' then --not positive like the data sheet says --- its negative polarityoutascii<= "00101101"; else polarityoutascii<= "00101011"; end if; end process changingflipflopstate; end behaviour;