線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:2756
推到 Plurk!
推到 Facebook!

如何用vhdl寫delay

答題得分者是:
jacksonhuang
一般會員


發表:26
回覆:22
積分:9
註冊:2004-04-20

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-03-29 19:38:13 IP:140.124.xxx.xxx 未訂閱
請問: 假設在我的design裡面,有一個pin是clock,它接到晶片上的clock 腳,我想在每一次clock來的時候就做一件特定的事,但是晶片上的 clock太快了,要如何讓clock不要這快 謝謝~~

版主


發表:261
回覆:2302
積分:1667
註冊:2005-01-04

發送簡訊給我
#2 引用回覆 回覆 發表時間:2005-03-29 20:12:08 IP:203.71.xxx.xxx 未訂閱
假設clk為輸入clock,定義dff(20 downto 0)
process(clk)
 dff<=dff 1;
end process;
x1<=dff(2);  如此看你要多慢,去改dff()裡面的值即可,dff(0)=clock/2
          ;  dff(1)=clock/4,以此類推    process(x1)
             ; 做特定的事
end process;
==================================== 生命的目的,在幻化出多采多姿的組合。 生活的意義,在捕捉住稍縱即逝的感動。 ====================================
發表人 - ㊣ 於 2005/03/29 20:13:52
------
-------------------------------------------------------------------------
走是為了到另一境界,停是為了欣賞人生;未走過千山萬水,怎知生命的虛實與輕重!?
jacksonhuang
一般會員


發表:26
回覆:22
積分:9
註冊:2004-04-20

發送簡訊給我
#3 引用回覆 回覆 發表時間:2005-03-30 11:08:45 IP:140.124.xxx.xxx 未訂閱
謝謝大大的解釋 不過因為我是最近這兩天才開始看vhdl的,所以對於一些語法還不是很熟 所以我有兩個地方想請問大大 1.dff(20 downto 0)要定義在那裡面,是定義在ARCHITECTURE下的begin之前嗎 ,還有怎麼定義(像宣告一個signal像是SIGNAL temp : bit;) 2.x1<=dff(2)是要寫在ARCHITECTURE的begin之內嗎 謝謝 ps.不好意思~我是個初學者

版主


發表:261
回覆:2302
積分:1667
註冊:2005-01-04

發送簡訊給我
#4 引用回覆 回覆 發表時間:2005-03-30 12:25:00 IP:211.22.xxx.xxx 未訂閱
1>是的,如下定義: ARCHITECTURE..... signal dff:STD_LOGIC_VECTOR(20 downto 0);  BEGIN    2>是的,程式都要寫在ARCHITECTURE X1 OF XX IS ~~~ END X1之間    
==================================== 生命的目的,在幻化出多采多姿的組合。 生活的意義,在捕捉住稍縱即逝的感動。 ====================================
------
-------------------------------------------------------------------------
走是為了到另一境界,停是為了欣賞人生;未走過千山萬水,怎知生命的虛實與輕重!?
jacksonhuang
一般會員


發表:26
回覆:22
積分:9
註冊:2004-04-20

發送簡訊給我
#5 引用回覆 回覆 發表時間:2005-03-30 13:31:02 IP:140.124.xxx.xxx 未訂閱
不好意思,我又有問題了 當我宣告SIGNAL dff:STD_LOGIC_VECTOR(20 DOWNTO 0)之後 在ARCHITECTURE裡面寫 PROCESS(clock) BEGIN dff <= dff 1; END PROCESS; 它會有can't determine definition of operator " "--found 0 possible definitions 還有x1也還定義在ARCHITECTURE下begin之前嗎~那還如何定義 謝謝

版主


發表:261
回覆:2302
積分:1667
註冊:2005-01-04

發送簡訊給我
#6 引用回覆 回覆 發表時間:2005-03-30 14:17:27 IP:211.22.xxx.xxx 未訂閱
PROCESS(clk)
 BEGIN
  IF clk' EVENT AND clk='1' THEN
     dff<=dff 1;
  END IF;
 END PROCESS;    
是的,定義如下: signal D1:STD_LOGIC; P.S:如果你有書,找一下吧.基本定義書上都有.
==================================== 生命的目的,在幻化出多采多姿的組合。 生活的意義,在捕捉住稍縱即逝的感動。 ====================================
------
-------------------------------------------------------------------------
走是為了到另一境界,停是為了欣賞人生;未走過千山萬水,怎知生命的虛實與輕重!?
jacksonhuang
一般會員


發表:26
回覆:22
積分:9
註冊:2004-04-20

發送簡訊給我
#7 引用回覆 回覆 發表時間:2005-03-30 18:10:27 IP:140.124.xxx.xxx 未訂閱
請問: 宣告dff:STD_LOGIC_VECTOR(20 DOWNTO 0),dff的type是 布林的嗎? 因為我寫 PROCESS(clock) BEGIN IF(clock'event and clock='1')THEN dff <= dff 1; END IF; END PROCESS; 它在dff<=dff 1這一行還是會有can't determine definition of operator " "--found 0 possible definitions的錯誤 謝謝. 不好意思~一直麻煩你

版主


發表:261
回覆:2302
積分:1667
註冊:2005-01-04

發送簡訊給我
#8 引用回覆 回覆 發表時間:2005-03-30 18:53:46 IP:211.22.xxx.xxx 未訂閱
dff type是標準邏輯向量    LIBRARY ieee; USE ieee.std_logic_1164.all; USE ieee.std_logic_arith.all;    看檔案頭你這幾行有沒有定義到.我的程式compiler OK      
==================================== 生命的目的,在幻化出多采多姿的組合。 生活的意義,在捕捉住稍縱即逝的感動。 ====================================
------
-------------------------------------------------------------------------
走是為了到另一境界,停是為了欣賞人生;未走過千山萬水,怎知生命的虛實與輕重!?
jacksonhuang
一般會員


發表:26
回覆:22
積分:9
註冊:2004-04-20

發送簡訊給我
#9 引用回覆 回覆 發表時間:2005-03-31 01:16:45 IP:140.124.xxx.xxx 未訂閱
謝謝大大的回答,我本來的程式裡是沒有定義USE ieee.std_logic_arith.all; 但是我把它加進去後再complier,還是會有相同的錯誤 我把我的code貼在這裡,請大大幫我看看(這是一個traffic control的程式) LIBRARY ieee; USE ieee.std_logic_1164.ALL; USE ieee.std_logic_arith.ALL; ENTITY Traffic_Controller IS PORT ( clock : in bit; reset : in bit; red1 : out bit; yellow1 : out bit; green1 : OUT bit; red2 : OUT bit; yellow2 : OUT bit; green2 : OUT bit ); END Traffic_Controller; ARCHITECTURE behavior OF Traffic_Controller IS TYPE state_t IS(init,s0,s1,s2,s3); SIGNAL state,nxstate: state_t; SIGNAL green1_temp : bit; SIGNAL yellow1_temp : bit; SIGNAL red1_temp : bit; SIGNAL green2_temp : bit; SIGNAL yellow2_temp : bit; SIGNAL red2_temp : bit; SHARED VARIABLE count : integer; SIGNAL dff:STD_LOGIC_VECTOR(20 DOWNTO 0); SIGNAL X1:STD_LOGIC; BEGIN PROCESS(state) BEGIN green1_temp <= '0'; yellow1_temp <= '0'; red1_temp <= '0'; green2_temp <= '0'; yellow2_temp <= '0'; red2_temp <= '0'; CASE state IS WHEN init => green1_temp <= '0'; yellow1_temp <= '0'; red1_temp <= '0'; green2_temp <= '0'; yellow2_temp <= '0'; red2_temp <= '0'; nxstate <= s0; WHEN s0 => green1_temp <='1'; red2_temp <= '1'; nxstate <= s1; WHEN s1 => yellow1_temp <='1'; red2_temp <='1'; nxstate <=s2; WHEN s2 => red1_temp <='1'; green2_temp <='1'; nxstate <=s3; WHEN s3 => red1_temp <='1'; yellow2_temp <='1'; nxstate <=s0; END CASE; END PROCESS; PROCESS(clock) BEGIN IF(clock'event and clock='1')THEN dff <= dff 1; END IF; END PROCESS; X1<=dff(2); state_clocking : PROCESS(reset,clock) BEGIN IF(reset = '1' )THEN state <=init; ELSE IF(X1)THEN state <= nxstate; END IF; END IF; END PROCESS state_clocking; green1 <= green1_temp; yellow1 <= yellow1_temp; red1 <=red1_temp; green2 <= green2_temp; yellow2 <= yellow2_temp; red2 <= red2_temp; END behavior;

版主


發表:261
回覆:2302
積分:1667
註冊:2005-01-04

發送簡訊給我
#10 引用回覆 回覆 發表時間:2005-03-31 02:18:40 IP:59.113.xxx.xxx 未訂閱
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_arith.ALL;    ENTITY Traffic_Controller IS
PORT
(
        clock : in bit;
        reset : in bit;
        red1 : out bit;
        yellow1 : out bit;
        green1 : OUT bit;
        red2 : OUT bit;
        yellow2 : OUT bit;
        green2 : OUT bit);    END Traffic_Controller;    ARCHITECTURE behavior OF Traffic_Controller IS
TYPE state_t IS(init,s0,s1,s2,s3);
SIGNAL state,nxstate: state_t;
SIGNAL green1_temp : bit;
SIGNAL yellow1_temp : bit;
SIGNAL red1_temp : bit;
SIGNAL green2_temp : bit;
SIGNAL yellow2_temp : bit;
SIGNAL red2_temp : bit;
SHARED VARIABLE count : integer;
SIGNAL dff:unsigned(20 DOWNTO 0);
SIGNAL X1:STD_LOGIC;
BEGIN    PROCESS(state)
BEGIN
green1_temp <= '0';
yellow1_temp <= '0';
red1_temp <= '0';
green2_temp <= '0';
yellow2_temp <= '0';
red2_temp <= '0';
CASE state IS
WHEN init =>
        green1_temp <= '0';
        yellow1_temp <= '0';
        red1_temp <= '0';
        green2_temp <= '0';
        yellow2_temp <= '0';
        red2_temp <= '0';
        nxstate <= s0;
WHEN s0 =>
        green1_temp <='1';
        red2_temp <= '1';
        nxstate <= s1;
WHEN s1 =>
        yellow1_temp <='1';
        red2_temp <='1';
        nxstate <=s2;
WHEN s2 =>
        red1_temp <='1';
        green2_temp <='1';
        nxstate <=s3;
WHEN s3 =>
        red1_temp <='1';
        yellow2_temp <='1';
        nxstate <=s0;    END CASE;
END PROCESS;    PROCESS(clock)
BEGIN
IF clock' event and clock='1' THEN --clock 與event要空一格
        dff <= dff 1;
END IF;
END PROCESS;    X1<=dff(2);    PROCESS(reset,clock)
BEGIN
IF(reset = '1' )THEN
        state <=init;
ELSIF(X1='1')THEN                      --else if 語法錯誤,判斷式也錯.
        state <= nxstate; 
--END IF; -------------------------------多一行end if
END IF;
END PROCESS;
green1 <= green1_temp;
yellow1 <= yellow1_temp;
red1 <=red1_temp;
green2 <= green2_temp;
yellow2 <= yellow2_temp;
red2 <= red2_temp;
END behavior;    
程式已經ok,我compiler all pass! 錯誤的地方我有標出來.你再看看. P.S:以後貼程式請縮排!不知如何做請參考 : http://delphi.ktop.com.tw/topic.php?TOPIC_ID=48259
==================================== 生命的目的,在幻化出多采多姿的組合。 生活的意義,在捕捉住稍縱即逝的感動。 ====================================
------
-------------------------------------------------------------------------
走是為了到另一境界,停是為了欣賞人生;未走過千山萬水,怎知生命的虛實與輕重!?
jacksonhuang
一般會員


發表:26
回覆:22
積分:9
註冊:2004-04-20

發送簡訊給我
#11 引用回覆 回覆 發表時間:2005-03-31 14:57:12 IP:140.124.xxx.xxx 未訂閱
謝謝大大的解釋,目前那個錯誤己經沒有了,不過還是有一個奇怪的warning 這個warning是signal or variable state may not be assigned a new value in every possible path through the Process Statement. Signal or variable state holds its previous value in every path with no new value assignment, which may create a combinational loop in the current design. 看起來像是在PROCESS(clock,X1,state,nxstate,reset)裡面不能assign value 給state,但是若是我把state <= nxstate;放在PROCESS(clock)(紅字)裡面,就不會有那個warning,但是若是我沒有把它寫在PROCESS(clock,X1,state,nxstate,reset),那個delay就沒有效果了  
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_arith.ALL;    ENTITY Traffic_Controller IS
PORT
(
        clock : in bit;
        reset : in bit;
        red1 : out bit;
        yellow1 : out bit;
        green1 : OUT bit;
        red2 : OUT bit;
        yellow2 : OUT bit;
        green2 : OUT bit);    END Traffic_Controller;    ARCHITECTURE behavior OF Traffic_Controller IS
                TYPE state_t IS(init,s0,s1,s2,s3);
                SIGNAL state,nxstate: state_t;
                SIGNAL green1_temp : bit;
                SIGNAL yellow1_temp : bit;
                SIGNAL red1_temp : bit;
                SIGNAL green2_temp : bit;
                SIGNAL yellow2_temp : bit;
                SIGNAL red2_temp : bit;
                SHARED VARIABLE count : integer;
                SIGNAL dff:unsigned(10 DOWNTO 0);
                SIGNAL X1:STD_LOGIC;
                BEGIN    PROCESS(state)
BEGIN
                green1_temp <= '0';
                yellow1_temp <= '0';
                red1_temp <= '0';
                green2_temp <= '0';
                yellow2_temp <= '0';
                red2_temp <= '0';
                CASE state IS
                WHEN init =>
                        green1_temp <= '0';
                        yellow1_temp <= '0';
                        red1_temp <= '0';
                        green2_temp <= '0';
                        yellow2_temp <= '0';
                        red2_temp <= '0';
                        nxstate <= s0;
                WHEN s0 =>
                        green1_temp <='1';
                        red2_temp <= '1';
                        nxstate <= s1;
                WHEN s1 =>
                        yellow1_temp <='1';
                        red2_temp <='1';
                        nxstate <=s2;
                WHEN s2 =>
                        red1_temp <='1';
                        green2_temp <='1';
                        nxstate <=s3;
                WHEN s3 =>
                        red1_temp <='1';
                        yellow2_temp <='1';
                        nxstate <=s0;                    END CASE;
END PROCESS;
PROCESS(clock)
BEGIN
                IF clock'event and clock='1' THEN
                        dff <= dff 1;
                        --state <= nxstate;
                END IF;
END PROCESS;    X1<=dff(0);    PROCESS(clock,X1,state,nxstate,reset)
BEGIN
                IF reset = '1' THEN
                        state <=init;
                ELSIF X1='1' THEN
                        state <= nxstate; 
                END IF;
END PROCESS;
                green1 <= green1_temp;
                yellow1 <= yellow1_temp;
                red1 <=red1_temp;
                green2 <= green2_temp;
                yellow2 <= yellow2_temp;
                red2 <= red2_temp;
END behavior;    
謝謝

版主


發表:261
回覆:2302
積分:1667
註冊:2005-01-04

發送簡訊給我
#12 引用回覆 回覆 發表時間:2005-03-31 16:25:02 IP:211.22.xxx.xxx 未訂閱
PROCESS(clock,X1,state,nxstate,reset)    ==>PROCESS(clock,X1,reset)    應該就ok了        
==================================== 生命的目的,在幻化出多采多姿的組合。 生活的意義,在捕捉住稍縱即逝的感動。 ====================================
------
-------------------------------------------------------------------------
走是為了到另一境界,停是為了欣賞人生;未走過千山萬水,怎知生命的虛實與輕重!?
jacksonhuang
一般會員


發表:26
回覆:22
積分:9
註冊:2004-04-20

發送簡訊給我
#13 引用回覆 回覆 發表時間:2005-03-31 18:07:02 IP:140.124.xxx.xxx 未訂閱
謝謝大大的解答~不過我把 PROCESS(clock,X1,state,nxstate,reset) 改成 PROCESS(clock,X1,reset) 還是有signal or variable state may not be assigned a new value in every possible path through the Process Statement. Signal or variable state holds its previous value in every path with no new value assignment, which may create a combinational loop in the current design的warning 而且另外還會有 signal nxstate is in statement,but is not in sensitivity list的warning 謝謝

版主


發表:261
回覆:2302
積分:1667
註冊:2005-01-04

發送簡訊給我
#14 引用回覆 回覆 發表時間:2005-04-01 00:00:43 IP:59.113.xxx.xxx 未訂閱
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_arith.ALL;    ENTITY Traffic_Controller IS
PORT
(
        clock : in bit;
        reset : in bit;
        red1 : out bit;
        yellow1 : out bit;
        green1 : OUT bit;
        red2 : OUT bit;
        yellow2 : OUT bit;
        green2 : OUT bit);    END Traffic_Controller;    ARCHITECTURE behavior OF Traffic_Controller IS
                TYPE state_t IS(init,s0,s1,s2,s3);
                SIGNAL state,nxstate: state_t;
                SIGNAL green1_temp : bit;
                SIGNAL yellow1_temp : bit;
                SIGNAL red1_temp : bit;
                SIGNAL green2_temp : bit;
                SIGNAL yellow2_temp : bit;
                SIGNAL red2_temp : bit;
                SHARED VARIABLE count : integer;
                SIGNAL dff:unsigned(10 DOWNTO 0);
                SIGNAL X1:STD_LOGIC;
                BEGIN    PROCESS(state)
BEGIN
                green1_temp <= '0';
                yellow1_temp <= '0';
                red1_temp <= '0';
                green2_temp <= '0';
                yellow2_temp <= '0';
                red2_temp <= '0';
                CASE state IS
                WHEN init =>
                        green1_temp <= '0';
                        yellow1_temp <= '0';
                        red1_temp <= '0';
                        green2_temp <= '0';
                        yellow2_temp <= '0';
                        red2_temp <= '0';
                        nxstate <= s0;
                WHEN s0 =>
                        green1_temp <='1';
                        red2_temp <= '1';
                        nxstate <= s1;
                WHEN s1 =>
                        yellow1_temp <='1';
                        red2_temp <='1';
                        nxstate <=s2;
                WHEN s2 =>
                        red1_temp <='1';
                        green2_temp <='1';
                        nxstate <=s3;
                WHEN s3 =>
                        red1_temp <='1';
                        yellow2_temp <='1';
                        nxstate <=s0;                    END CASE;
END PROCESS;
PROCESS(clock)
BEGIN
                IF clock'event and clock='1' THEN
                        dff <= dff 1;
                END IF;
END PROCESS;    X1<=dff(0);    PROCESS(clock,X1,state,nxstate,reset)
BEGIN
                IF reset = '1' THEN
                        state <=init;
                ELSIF  X1='1' THEN
                        state <= nxstate; 
                END IF;
END PROCESS;
                green1 <= green1_temp;
                yellow1 <= yellow1_temp;
                red1 <=red1_temp;
                green2 <= green2_temp;
                yellow2 <= yellow2_temp;
                red2 <= red2_temp;
END behavior;
你把上面的CODE貼到你的檔案裡,再試試吧!! 確定一下你的檔案有指定路徑:File->Project->Set Project to Current File 我有試過,上述程式Compiler ALL PASS!
==================================== 生命的目的,在幻化出多采多姿的組合。 生活的意義,在捕捉住稍縱即逝的感動。 ====================================
------
-------------------------------------------------------------------------
走是為了到另一境界,停是為了欣賞人生;未走過千山萬水,怎知生命的虛實與輕重!?
jacksonhuang
一般會員


發表:26
回覆:22
積分:9
註冊:2004-04-20

發送簡訊給我
#15 引用回覆 回覆 發表時間:2005-04-01 00:52:00 IP:140.124.xxx.xxx 未訂閱
謝謝大大~不過那個warning(signal or variable state may not be assigned a new value ...)還是會出現 我想請問一下你的環境是不是max-plusII,因為我是用quartusII4.1,所以我找不到你說的File->Project->Set Project to Current File,不知道這有沒有影響 真的很謝謝你~~~~

版主


發表:261
回覆:2302
積分:1667
註冊:2005-01-04

發送簡訊給我
#16 引用回覆 回覆 發表時間:2005-04-01 01:44:53 IP:59.113.xxx.xxx 未訂閱
Yes,我是使用Max+plus II測試的        
==================================== 生命的目的,在幻化出多采多姿的組合。 生活的意義,在捕捉住稍縱即逝的感動。 ====================================
------
-------------------------------------------------------------------------
走是為了到另一境界,停是為了欣賞人生;未走過千山萬水,怎知生命的虛實與輕重!?
系統時間:2024-04-30 18:49:10
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!