2007-04-10, 11:16 PM
|
#3 (permalink)
|
註冊會員
|
引用:
作者: 飛鳥
|
因為小弟是第一次接觸這個~非常的不懂...
教授說要用VHDL去做~
以下是VHDL的編碼~
請問飛鳥大有可以參考的東西嗎?謝謝
語法:
-------------------------------------------------------------------
--實驗名稱:步進馬達實習
--檔案名稱:stepmotor_speed.vhd
--功 能:步進馬達轉速控制
--日 期:2003.8.8
-------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity stepmotor_speed is
port(
clk : in std_logic;
spd : in std_logic_vector(3 downto 0);
step: out std_logic_vector(3 downto 0)
);
end stepmotor_speed;
architecture arch of stepmotor_speed is
signal buf: std_logic_vector (4 downto 0);
signal dly : std_logic;
signal clk_new: std_logic;
signal cnt : std_logic_vector(1 downto 0);
begin
---------- process ---------
process(clk)
begin
if clk'event and clk='1' then
dly <= buf(4);
buf <= buf +('0' & spd);
end if;
end process;
clk_new<=buf(4) xor dly;
process(clk_new)
begin
if clk_new'event and clk_new='1' then
cnt <= cnt+1;
end if;
end process;
step <= "1000" when cnt=0 else
"0100" when cnt=1 else
"0010" when cnt=2 else
"0001";
end arch;
|
|
|
送花文章: 23,
收花文章: 5 篇, 收花: 9 次
|