?? buzzer.vhd
字號:
-- 向蜂鳴器發送一定頻率的方波可以使蜂鳴器發出相應的音調,該實驗通過設計一個狀態機和分頻
-- 器使蜂鳴器發出"多來咪發梭拉西多"的音調。
--
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY buzzer IS
PORT (
clk : IN std_logic;
rst : IN std_logic;
out_bit : OUT std_logic);
END buzzer;
ARCHITECTURE arch OF buzzer IS
SIGNAL clk_div1 : std_logic_vector(3 DOWNTO 0); --基頻分頻計數器,基頻為4M
SIGNAL clk_div2 : std_logic_vector(12 DOWNTO 0); --音階分頻計數器,由基頻分頻產生各個音階
SIGNAL cnt : std_logic_vector(21 DOWNTO 0); --各音階發聲時間長短計數器
SIGNAL state : std_logic_vector(2 DOWNTO 0);
--各個音調的分頻系數
CONSTANT duo : std_logic_vector(12 DOWNTO 0) :="0111011101110";
CONSTANT lai : std_logic_vector(12 DOWNTO 0) := "0110101001101";
CONSTANT mi : std_logic_vector(12 DOWNTO 0) := "0101111011010";
CONSTANT fa : std_logic_vector(12 DOWNTO 0) := "0101100110001";
CONSTANT suo : std_logic_vector(12 DOWNTO 0) := "0100111110111";
CONSTANT la : std_logic_vector(12 DOWNTO 0) := "0100011100001";
CONSTANT xi : std_logic_vector(12 DOWNTO 0) := "0011111101000";
CONSTANT duo1 : std_logic_vector(12 DOWNTO 0) := "0011101110111";
SIGNAL out_bit_tmp :std_logic;
BEGIN
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -