
※ 引述《CuckooBoy (阿書)》之銘言:
: http://ilook.tw/79gm
: 程式主要的就是在做.....
: 如水龍頭,我用LOAD去.....送出CLK,還是關掉
: 當我2個pulse時就關,多少就開....
: 請教一下
: 波形中出現黃圈的情況
: 我是用POST-PLACE &ROUTE模擬的
: 我知道那是cnt造成
: 我該如何解決 讓他平平的
: 程式要怎麼寫才不會呢?
: library IEEE;
: use IEEE.STD_LOGIC_1164.ALL;
: use IEEE.STD_LOGIC_ARITH.ALL;
: use IEEE.STD_LOGIC_UNSIGNED.ALL;
: entity MBA is
: Port ( CLK : in std_logic;
: SCLK : out std_logic;
: SDI : out std_logic;
: RCLK : out std_logic;
: OE : out std_logic);
: end MBA;
: architecture Behavioral of MBA is
: signal cnt : std_logic_vector(3 downto 0);
: signal load,sig :std_logic;
: begin
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: SCLK <= load and CLK;
: process(CLK)
: begin
: if CLK='1' and CLK'event then
: if cnt<2 then
: load <= '0';
: else
: load <= '1';
: end if;
: end if;
: end process;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
這一段改成這樣:
process(CLK)
begin
if CLK'event then
if CLK='1' then
if cnt<2 then
load <= '0';
SCLK <= '0';
else
load <= '1';
SCLK <= CLK;
end if;
else
SCLK <= '0';
end if;
end if;
end process;
http://web.cc.ncu.edu.tw/~93501025/vhdl.png
上圖中,上面的模擬是你原先的HDL code模擬,
下面的是修改後的模擬.
我這樣的寫法是避開SCLK是load and CLK.
原先的code之所以會出現一個暫時性的pluse,
是發生在load為1時,CLK正緣出現後,load還未變為0的時後,
load and CLK的結果會為1.
這種暫時性的pluse往往出現在,
兩個在某個時間點幾乎同時變化的訊號拿來做某logic的輸入.
例如:SCLK <= load and CLK;
所以要避開這個問題,就想辦法把load與CLK拆開.
(以上是我自己的推論,我是不知道書上有沒有寫,
是否完全無誤我就不清楚了.)
: process(CLK)
: begin
: if CLK='1' and CLK'event then
: if cnt < 9 then
: cnt <= cnt + 1;
: else
: cnt <= "0000";
: end if;
: end if;
: end process;
: end Behavioral;
--
Albert Einstein :
If there is any religion that could cope with modern scientific needs it
would be Buddhism.
《金剛經》離一切諸相,則名諸佛。
http://web.cc.ncu.edu.tw/~93501025/jg.doc
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.115.200.121
