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

📄 drink-cnt.vhd

📁 design compile synthesis user guide
💻 VHD
字号:
entity DRINK_COUNT_VHDL is  port(NICKEL_IN, DIME_IN, QUARTER_IN, RESET: BOOLEAN;       CLK: BIT;       NICKEL_OUT, DIME_OUT, DISPENSE: out BOOLEAN);end;architecture BEHAVIOR of DRINK_COUNT_VHDL is  signal CURRENT_NICKEL_COUNT,         NEXT_NICKEL_COUNT: INTEGER range 0 to 7;  signal CURRENT_RETURN_CHANGE, NEXT_RETURN_CHANGE : BOOLEAN;begin  process    variable TEMP_NICKEL_COUNT: INTEGER range 0 to 12;  begin    -- Default assignments    NICKEL_OUT <= FALSE;    DIME_OUT <= FALSE;    DISPENSE <= FALSE;    -- CURRENT_NICKEL_COUNT <= 0;    NEXT_NICKEL_COUNT <= 0;    NEXT_RETURN_CHANGE <= FALSE;    -- Synchronous reset    if (not RESET) then      TEMP_NICKEL_COUNT := CURRENT_NICKEL_COUNT;      -- Check whether money has come in      if (NICKEL_IN) then        -- NOTE:  This design will be flattened, so        --   these multiple adders will be optimized        TEMP_NICKEL_COUNT := TEMP_NICKEL_COUNT + 1;      elsif(DIME_IN) then        TEMP_NICKEL_COUNT := TEMP_NICKEL_COUNT + 2;      elsif(QUARTER_IN) then        TEMP_NICKEL_COUNT := TEMP_NICKEL_COUNT + 5;      end if;      -- Enough deposited so far?      if(TEMP_NICKEL_COUNT >= 7) then        TEMP_NICKEL_COUNT := TEMP_NICKEL_COUNT - 7;        DISPENSE <= TRUE;      end if;      -- Return change      if(TEMP_NICKEL_COUNT >= 1 or         CURRENT_RETURN_CHANGE) then        if(TEMP_NICKEL_COUNT >= 2) then          DIME_OUT <= TRUE;          TEMP_NICKEL_COUNT := TEMP_NICKEL_COUNT - 2;          NEXT_RETURN_CHANGE <= TRUE;        end if;        if(TEMP_NICKEL_COUNT = 1) then          NICKEL_OUT <= TRUE;          TEMP_NICKEL_COUNT := TEMP_NICKEL_COUNT - 1;        end if;      end if;      NEXT_NICKEL_COUNT <= TEMP_NICKEL_COUNT;    end if;  end process;  -- Remember the return-change flag and  -- the nickel count for the next cycle  process  begin    wait until CLK'event and CLK = '1';    CURRENT_RETURN_CHANGE <= NEXT_RETURN_CHANGE;    CURRENT_NICKEL_COUNT <= NEXT_NICKEL_COUNT;  end process;end BEHAVIOR;

⌨️ 快捷键说明

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