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

📄 taxi.vhd

📁 出租车计价器的计路程模块的源代码
💻 VHD
字号:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;


entity taxi  is
	port (  
	  clk,reset:in std_logic;--每来一个脉冲(代表运行了0.1公里)
	  en1:out std_logic;                    --超出起车里程开始记价使能信号(7元)
      count1 :out std_logic_vector (3 downto 0);--――里程数值的十分位
      count2 :out std_logic_vector (3 downto 0); --――里程数值的个位
      count3 :out std_logic_vector (3 downto 0)); --――里程数值的十位
end taxi ;


architecture aa of taxi is
begin
  process(clk,reset)
	variable mm : std_logic_vector (11 downto 0);
begin
	if reset='1' then
	  mm:="000000000000";
	elsif clk'event and clk='1' then
        if mm(3 downto 0)="1001" then--――十六进制转换成十进制
			 mm:=mm+7;
		else 
		     mm:=mm+1; 
		end if;
		if mm(7 downto 4)="1010" then
			mm:=mm+"01100000"; 
		end if;
	end if; 
	if mm(11 downto 4)>"00000111" then 
      en1<='1';
	else 
	    en1<='0';
	end if;
count1<=mm(3 downto 0);
count2<=mm(7 downto 4);
count3<=mm(11 downto 8);
end process;
end aa;

⌨️ 快捷键说明

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