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

📄 decode.vhd

📁 带获胜音乐的拔河游戏机
💻 VHD
字号:
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;

entity decode is
	port(clk_in:in std_logic;								--1MHz
		 record1,record2:in std_logic_vector(1 downto 0);	--比分状态输入
		 lights:in std_logic_vector(2 downto 0);			--绳子状态输入
		 led:out std_logic_vector(7 downto 0);				--绳子解码后输出
		 q:buffer std_logic_vector(5 downto 0);				--数码管控制
		 cats:out std_logic_vector(6 downto 0));			--数码管显示	
	end decode;

architecture body_decode of decode is
	signal tmp_led:std_logic_vector(7 downto 0);			--绳子输出
	signal tmp_da1:std_logic_vector(6 downto 0);			--比分1
	signal tmp_da2:std_logic_vector(6 downto 0);			--比分2
	signal tmp:std_logic_vector(6 downto 0);				--比分显示
	begin
		led<=tmp_led;
		cats<=tmp;
		process(clk_in,lights,record1,record2,q,tmp_da2,tmp_da1,tmp)
		begin
			case lights is									--绳子状态
				when "100"=> tmp_led<="00010000";
				when "011"=> tmp_led<="00001000";
				when "010"=> tmp_led<="00000100";
				when "001"=> tmp_led<="00000010";
				when "101"=> tmp_led<="00100000";
				when "110"=> tmp_led<="01000000";
				when "111"=> tmp_led<="10000000";
				when others =>tmp_led<="00010000";
			end case;
			case record1 is									--比分状态
				when "00"=> tmp_da1<="1111110";
				when "01"=> tmp_da1<="0110000";
				when "10"=> tmp_da1<="1101101";
				when "11"=> tmp_da1<="1111001";
			end case;
			case record2 is									--比分状态
				when "00"=> tmp_da2<="1111110";
				when "01"=> tmp_da2<="0110000";
				when "10"=> tmp_da2<="1101101";
				when "11"=> tmp_da2<="1111001";
			end case;		
			if(clk_in='1') then
				q<="111110";
			end if;
			if(clk_in='0') then
				q<="011111";
			end if;
			case q is										--数码管显示控制		
				when "011111"=> tmp<=tmp_da2;
				when "111110"=> tmp<=tmp_da1;
				when others=> tmp<="0000000";
			end case;
		end process;
	end body_decode;

⌨️ 快捷键说明

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