-------------------------------------------------------- -- LCD decoder -- EE 552 Project -- Audio Processing Unit -- February, 2003 -- -- FILE NAME: lcd_decoder.vhd -- -- DESCRIPTION: This module recieves the message code -- and sends the appropriate ASCII characters to -- the driver. -------------------------------------------------------- library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; library work; use work.interface.all; entity lcd_decoder is generic(datawidth: positive := 8); port( clock: in std_logic; -- slow clock. reset: in std_logic; -- system reset. message_code: in std_logic_vector(datawidth-1 downto 0); -- message to be displayed. char_out: out std_logic_vector(datawidth-1 downto 0); -- character signal to driver. char_sent: out std_logic; -- indicate character sent. dvr_ready: in std_logic; -- detect if the driver is ready for next character. char_recvd: in std_logic -- detect if the driver has recieved and printed last character. ); end lcd_decoder; architecture Output of lcd_decoder is type state_type is (CLEAR, HOME, NOP, WELCOME, START, FINISH); type char_type is (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, carrage_return, r_arrow, space, NIL); signal state, next_state, last_state : state_type; signal char : char_type; signal home_once, char_print: std_logic; signal count : std_logic_vector(5 downto 0); begin process(clock, state, reset, dvr_ready, char_recvd, next_state, last_state, char) begin if reset = '0' then state <= CLEAR; char_sent <= '0'; elsif rising_edge(clock) then case message_code(7 downto 0) is when "00000000" => next_state <= WELCOME; when "00000001" => next_state <= START; when "00000010" => next_state <= FINISH; when others => next_state <= NOP; end case; case state is when CLEAR => home_once <= '0'; count <= "000000"; char_print <= '0'; if dvr_ready ='1' then char_sent <= '1'; char_out <= "00000001"; state <= clear; elsif char_recvd = '1' then char_sent <= '0'; state <= next_state; else state <= clear; end if; when HOME => char_print <='0'; if next_state /= last_state then state<= CLEAR; elsif dvr_ready ='1' then if home_once = '0' then home_once <= '1'; char_sent <= '1'; char_out <= "00000011"; state <= HOME; else state <= HOME; end if; elsif char_recvd = '1' then char_sent <= '0'; state <= HOME; else state <= HOME; end if; when NOP => state<= last_state; when WELCOME => last_state <= WELCOME; --prints "WELCOME" -- "APU ->" case count is when "000000" => char <= W; char_print <='1'; when "000001" => char <= E; char_print <='1'; when "000010" => char <= L; char_print <='1'; when "000011" => char <= C; char_print <='1'; when "000100" => char <= O; char_print <='1'; when "000101" => char <= M; char_print <='1'; when "000110" => char <= E; char_print <='1'; when "000111" => char <= carrage_return; char_print <='1'; when "001000" => char <= A; char_print <='1'; when "001001" => char <= P; char_print <='1'; when "001010" => char <= U; char_print <='1'; when "001011" => char <= space; char_print <='1'; when "001100" => char <= r_arrow; char_print <='1'; when others => state<= HOME; char_print <='0'; end case; when START => -- prints "BEGIN" last_state <= START; case count is when "000000" => char <= B; char_print <='1'; when "000001" => char <= E; char_print <='1'; when "000010" => char <= G; char_print <='1'; when "000011" => char <= I; char_print <='1'; when "000100" => char <= N; char_print <='1'; when others => state<= HOME; char_print <='0'; end case; when FINISH => -- prints "END" last_state <= FINISH; case count is when "000000" => char <= E; char_print <='1'; when "000001" => char <= N; char_print <='1'; when "000010" => char <= D; char_print <='1'; when others => state<= HOME; char_print <='0'; end case; end case; if char_print ='1' then case char is when A => if char_recvd = '1' then count <= count+"000001"; char_sent <= '0'; elsif dvr_ready ='1' then char_sent <= '1'; char_out <= "01000001"; end if; when B => if char_recvd = '1' then count <= count+"000001"; char_sent <= '0'; elsif dvr_ready ='1' then char_sent <= '1'; char_out <= "01000010"; end if; when C => if char_recvd = '1' then count <= count+"000001"; char_sent <= '0'; elsif dvr_ready ='1' then char_sent <= '1'; char_out <= "01000011"; end if; when D => if char_recvd = '1' then count <= count+"000001"; char_sent <= '0'; elsif dvr_ready ='1' then char_sent <= '1'; char_out <= "01000100"; end if; when E => if char_recvd = '1' then count <= count+"000001"; char_sent <= '0'; elsif dvr_ready ='1' then char_sent <= '1'; char_out <= "01000101"; end if; when F => if char_recvd = '1' then count <= count+"000001"; char_sent <= '0'; elsif dvr_ready ='1' then char_sent <= '1'; char_out <= "01000110"; end if; when G => if char_recvd = '1' then count <= count+"000001"; char_sent <= '0'; elsif dvr_ready ='1' then char_sent <= '1'; char_out <= "01000111"; end if; when H => if char_recvd = '1' then count <= count+"000001"; char_sent <= '0'; elsif dvr_ready ='1' then char_sent <= '1'; char_out <= "01001000"; end if; when I => if char_recvd = '1' then count <= count+"000001"; char_sent <= '0'; elsif dvr_ready ='1' then char_sent <= '1'; char_out <= "01001001"; end if; when J => if char_recvd = '1' then count <= count+"000001"; char_sent <= '0'; elsif dvr_ready ='1' then char_sent <= '1'; char_out <= "01001010"; end if; when K => if char_recvd = '1' then count <= count+"000001"; char_sent <= '0'; elsif dvr_ready ='1' then char_sent <= '1'; char_out <= "01001011"; end if; when L => if char_recvd = '1' then count <= count+"000001"; char_sent <= '0'; elsif dvr_ready ='1' then char_sent <= '1'; char_out <= "01001100"; end if; when M => if char_recvd = '1' then count <= count+"000001"; char_sent <= '0'; elsif dvr_ready ='1' then char_sent <= '1'; char_out <= "01001101"; end if; when N => if char_recvd = '1' then count <= count+"000001"; char_sent <= '0'; elsif dvr_ready ='1' then char_sent <= '1'; char_out <= "01001110"; end if; when O => if char_recvd = '1' then count <= count+"000001"; char_sent <= '0'; elsif dvr_ready ='1' then char_sent <= '1'; char_out <= "01001111"; end if; when P => if char_recvd = '1' then count <= count+"000001"; char_sent <= '0'; elsif dvr_ready ='1' then char_sent <= '1'; char_out <= "01010000"; end if; when Q => if char_recvd = '1' then count <= count+"000001"; char_sent <= '0'; elsif dvr_ready ='1' then char_sent <= '1'; char_out <= "01010001"; end if; when R => if char_recvd = '1' then count <= count+"000001"; char_sent <= '0'; elsif dvr_ready ='1' then char_sent <= '1'; char_out <= "01010010"; end if; when S => if char_recvd = '1' then count <= count+"000001"; char_sent <= '0'; elsif dvr_ready ='1' then char_sent <= '1'; char_out <= "01010011"; end if; when T => if char_recvd = '1' then count <= count+"000001"; char_sent <= '0'; elsif dvr_ready ='1' then char_sent <= '1'; char_out <= "01010100"; end if; when U => if char_recvd = '1' then count <= count+"000001"; char_sent <= '0'; elsif dvr_ready ='1' then char_sent <= '1'; char_out <= "01010101"; end if; when V => if char_recvd = '1' then count <= count+"000001"; char_sent <= '0'; elsif dvr_ready ='1' then char_sent <= '1'; char_out <= "01010110"; end if; when W => if char_recvd = '1' then count <= count+"000001"; char_sent <= '0'; elsif dvr_ready ='1' then char_sent <= '1'; char_out <= "01010111"; end if; when X => if char_recvd = '1' then count <= count+"000001"; char_sent <= '0'; elsif dvr_ready ='1' then char_sent <= '1'; char_out <= "01011000"; end if; when Y => if char_recvd = '1' then count <= count+"000001"; char_sent <= '0'; elsif dvr_ready ='1' then char_sent <= '1'; char_out <= "01011001"; end if; when Z => if char_recvd = '1' then count <= count+"000001"; char_sent <= '0'; elsif dvr_ready ='1' then char_sent <= '1'; char_out <= "01011010"; end if; when carrage_return => if char_recvd = '1' then count <= count+"000001"; char_sent <= '0'; elsif dvr_ready ='1' then char_sent <= '1'; char_out <= "00000010"; end if; when r_arrow => if char_recvd = '1' then count <= count+"000001"; char_sent <= '0'; elsif dvr_ready ='1' then char_sent <= '1'; char_out <= "01111110"; end if; when space => if char_recvd = '1' then count <= count+"000001"; char_sent <= '0'; elsif dvr_ready ='1' then char_sent <= '1'; char_out <= "00100000"; end if; when NIL => char_out <= "00000000"; char_sent <='0'; end case; end if; end if; end process; end Output;