?? div.vhd
字號:
--分配器
--**************庫定義、 包定義********************
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
--**************實體定義********************
Entity div is
generic(duty:integer:=5);--類屬參數說明語句
--端口說明
port(clk : in std_logic;--時鐘輸入
q : out std_logic--分頻輸出
);
end div;
--**************構造體定義********************
Architecture div10 of div is
constant period : integer:=10;--常數定義,分頻數
signal count : integer range 0 to period-1;--信號定義,計數作用
begin
process(clk)--進程,由clk這個信號啟動
begin
if rising_edge(clk) then --上升沿驅動,還有另一種寫法,見其他例程
if count<duty then
q<='0';
count<=count+1;
elsif count<period-1 then
q<='1';
count<=count+1;
else
count<=0;
end if;
end if;
end process;
end div10;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -