如何用vhdl寫delay |
答題得分者是:㊣
|
jacksonhuang
一般會員 發表:26 回覆:22 積分:9 註冊:2004-04-20 發送簡訊給我 |
|
㊣
版主 發表:261 回覆:2302 積分:1667 註冊:2005-01-04 發送簡訊給我 |
假設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;
------
------------------------------------------------------------------------- 走是為了到另一境界,停是為了欣賞人生;未走過千山萬水,怎知生命的虛實與輕重!? |
jacksonhuang
一般會員 發表:26 回覆:22 積分:9 註冊:2004-04-20 發送簡訊給我 |
|
㊣
版主 發表:261 回覆:2302 積分:1667 註冊:2005-01-04 發送簡訊給我 |
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 發送簡訊給我 |
|
㊣
版主 發表:261 回覆:2302 積分:1667 註冊:2005-01-04 發送簡訊給我 |
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 發送簡訊給我 |
請問: 宣告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 發送簡訊給我 |
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 發送簡訊給我 |
謝謝大大的回答,我本來的程式裡是沒有定義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 發送簡訊給我 |
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 發送簡訊給我 |
謝謝大大的解釋,目前那個錯誤己經沒有了,不過還是有一個奇怪的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 發送簡訊給我 |
PROCESS(clock,X1,state,nxstate,reset) ==>PROCESS(clock,X1,reset) 應該就ok了
------
------------------------------------------------------------------------- 走是為了到另一境界,停是為了欣賞人生;未走過千山萬水,怎知生命的虛實與輕重!? |
jacksonhuang
一般會員 發表:26 回覆:22 積分:9 註冊:2004-04-20 發送簡訊給我 |
謝謝大大的解答~不過我把
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 發送簡訊給我 |
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 發送簡訊給我 |
|
㊣
版主 發表:261 回覆:2302 積分:1667 註冊:2005-01-04 發送簡訊給我 |
Yes,我是使用Max+plus II測試的
------
------------------------------------------------------------------------- 走是為了到另一境界,停是為了欣賞人生;未走過千山萬水,怎知生命的虛實與輕重!? |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |