⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lcd_control.vhd

📁 MP3 for XPLA3 XILINX.CPLD,必须在XILINX的FPGA芯片下使用,因为IP核是xilinx
💻 VHD
字号:
-- **************************************************************
-- File:  		lcd_control.vhd
--
-- Purpose: 	This file implements the LCD Control section of the
--			user interface.  This module inputs and outputs are 
--			described below. All outputs are registered to provide
--			stability in the signal output. 
--
--			Inputs:
--			- play_stat[2:0] -  describes the current play status
--			- mute_stat - describes the current mute status
--			- vol_lvl[5:0] - volume level
--			- bat_lvl[3:0] - current battery voltage
--			- track[5:0] - track number
--			- download - indicates when a song download is active
--			- error - indicates when an error has occured
--			- song_start - indicates the start of a new song			
--
--			Outputs:
--			- play_icon
--			- pause_icon
--			- stop_icon
--			- fwd_icon
--			- rwd_icon
--			- mute_icon
--			- vol_icon[6:0]
--			- bat_icon[2:0]
--			- track_icon[13:0]
--			- err_icon
--			- downld_icon
--			- volt_ready
--		
-- Created:		10/28/99	CLH
-- Revised: 	11/9/99		CLH
-- Revised:		11-14-99 ALS
-- Revised:		11-26-99 ALS
-- Revised:		11-28-99 ALS
-- Revised:		12-2-99 ALS
-- **************************************************************

library IEEE;
use IEEE.std_logic_1164.all;
use ieee.std_logic_arith.all;

entity lcd_control is
  
  port(
	-- *********** input signals ***********************************
	upd_track	: in STD_LOGIC;
	song_start	: in STD_LOGIC;
	error		: in STD_LOGIC;
	downld	: in STD_LOGIC;
	track		: in STD_LOGIC_VECTOR(4 downto 0);
	play_stat	: in STD_LOGIC_VECTOR(2 downto 0);

	-- *********** output signals **********************************
	play_icon	: inout STD_LOGIC;
	fwd_icon	: inout STD_LOGIC;
	rwd_icon	: inout STD_LOGIC;
	error_icon	: out STD_LOGIC;
	downld_icon	: out STD_LOGIC;
	track_icon	: inout STD_LOGIC_VECTOR(6 downto 0);

	-- *********** STANDARD INPUT SIGNALS **************************
	clock 	: in STD_LOGIC;
	reset		: in STD_LOGIC
	);
end lcd_control;

architecture behave of lcd_control is

	-- *********** CONSTANT DECLARATIONS ***************************
	--  standard signals 
	constant RESET_ACTIVE	: STD_LOGIC := '1';
	constant REG_DELAY	: time := 3 ns;
	constant I_ON		: STD_LOGIC := '1';
	constant I_OFF		: STD_LOGIC := '0';	

	-- ************** CONSTANT DECLARATIONS FOR PLAY STATUS*************
	constant PLAY_CODE	: std_logic_vector(2 downto 0) := "000"; -- play_stat code for play
	constant RWD_CODE		: std_logic_vector(2 downto 0) := "001"; -- play_stat code for rewind
	constant STOP_CODE	: std_logic_vector(2 downto 0) := "010"; -- play_stat code for stop
	constant FWD_CODE		: std_logic_vector(2 downto 0) := "011"; -- play_stat code for fast forward

	-- ************** SIGNAL DECLARATIONS FOR PLAY STATUS*************
	signal play_com		: STD_LOGIC;
	signal fwd_com		: STD_LOGIC;
	signal rwd_com		: STD_LOGIC;
	signal error_com		: STD_LOGIC;
	signal downld_com		: STD_LOGIC;
	signal track_com		: STD_LOGIC_VECTOR(6 downto 0);

	-- ************** CONSTANT DECLARATIONS FOR TRACK NUMBER *************
	-- BINARY TRACK NUMBERS 0 THROUGH 9
	constant BIN0		: STD_LOGIC_VECTOR(3 downto 0) := "0000";
	constant BIN1		: STD_LOGIC_VECTOR(3 downto 0) := "0001";
	constant BIN2		: STD_LOGIC_VECTOR(3 downto 0) := "0010";
	constant BIN3		: STD_LOGIC_VECTOR(3 downto 0) := "0011";
	constant BIN4		: STD_LOGIC_VECTOR(3 downto 0) := "0100";
	constant BIN5		: STD_LOGIC_VECTOR(3 downto 0) := "0101";
	constant BIN6		: STD_LOGIC_VECTOR(3 downto 0) := "0110";
	constant BIN7		: STD_LOGIC_VECTOR(3 downto 0) := "0111";
	constant BIN8		: STD_LOGIC_VECTOR(3 downto 0) := "1000";
	constant BIN9		: STD_LOGIC_VECTOR(3 downto 0) := "1001";


	-- BCD TRACK NUMBERS 0 THROUGH 9
	constant BCD0		: STD_LOGIC_VECTOR(6 downto 0) := "0000000";
	constant BCD1		: STD_LOGIC_VECTOR(6 downto 0) := "0000110";
	constant BCD2		: STD_LOGIC_VECTOR(6 downto 0) := "1011011";
	constant BCD3		: STD_LOGIC_VECTOR(6 downto 0) := "1001111";
	constant BCD4		: STD_LOGIC_VECTOR(6 downto 0) := "1100110";
	constant BCD5		: STD_LOGIC_VECTOR(6 downto 0) := "1101101";
	constant BCD6		: STD_LOGIC_VECTOR(6 downto 0) := "1111100";
	constant BCD7		: STD_LOGIC_VECTOR(6 downto 0) := "0000111";
	constant BCD8		: STD_LOGIC_VECTOR(6 downto 0) := "1111111";
	constant BCD9		: STD_LOGIC_VECTOR(6 downto 0) := "1100111";


	
	begin

	-- ************* Process: SEQUENTIAL **************
	-- Purpose: Synchronize state machines
	-- Components: None

	SEQUENTIAL: process(reset, clock)
	begin
		if reset =  RESET_ACTIVE then
			play_icon <= '0' ;
			fwd_icon <= '0' ;
			rwd_icon <= '0' ;
			error_icon <= '0' ;
			downld_icon <= '0' ;
			track_icon <=(others => '0') ;
			
		elsif clock'event and (clock = '1') then
			play_icon <= play_com ;
			fwd_icon <= fwd_com ;
			rwd_icon <= rwd_com ;
			error_icon <= error_com ;
			downld_icon <= downld_com ;
			if song_start = '1' or error = '1' or downld = '1' or upd_track = '1' then
				track_icon <= track_com ;
			else
				track_icon <= track_icon ;
			end if;


		end if;
	end process SEQUENTIAL;


	-- ************** PROCESS: PLAY_ICONS ******************************
	PLAY_ICONS: process(play_stat, error, downld)
	begin
		play_com <= I_OFF;
		fwd_com <= I_OFF;
		rwd_com <= I_OFF;	
		error_com <= I_OFF;
		downld_com <= I_OFF;
	
		if(error = '1') then
			error_com <= I_ON;
		elsif (downld = '1') then
			downld_com <= I_ON;	
		else
	
			case play_stat is
	
				when PLAY_CODE =>
					play_com <= I_ON;

				when FWD_CODE =>
					fwd_com <= I_ON;

				when RWD_CODE =>
					rwd_com <= I_ON;
				when others =>
			end case;
			end if;
	end process PLAY_ICONS;

	-- ************** PROCESS: TRACK_NUMBER ******************************
	TRACK_NUMBER: process(track, error, downld)
	begin
	track_com <= BCD0;
		if not(error = '1' or downld = '1') then
			case track(4 downto 1) is
			when BIN0 =>
				track_com <= BCD0;			
			when BIN1 =>
				track_com <= BCD1;
			when BIN2 =>
				track_com <= BCD2;
			when BIN3 => 
				track_com <= BCD3;
			when BIN4 => 
				track_com <= BCD4;
			when BIN5 => 
				track_com <= BCD5;
			when BIN6 => 
				track_com <= BCD6;
			when BIN7 => 
				track_com <= BCD7;
			when BIN8 => 
				track_com <= BCD8;
			when BIN9 => 
				track_com <= BCD9;
			when others =>
			end case;
		end if;
	end process TRACK_NUMBER;

end behave;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -