2016-07-06 78 views
0

我在VHDL包中有幾個函數和過程。 我想問一下,是否有一種方法可以忽略這些項目。 我知道端口映射的open關鍵字。 我正在使用虛擬信號分配給程序。但它可能是更有效的方式來做到這一點。忽略返回值過程/函數VHDL

¿VHDL有這樣的事嗎? 如果我設置了信號打開我得到以下錯誤: 「的模式進行正式E5必須有關聯的實際」

由於提前, 安東尼

編輯:代碼

procedure reg2ind 
(signal reg : in std_logic_vector(15 downto 0); 
    signal e1,e2,e3,e4,e5,e6,e7,e8 : out std_logic; 
    signal e9,e10,e11,e12,e13,e14,e15,e16 : out std_logic) is 
begin 
    e1 <= reg(0); 
    e2 <= reg(1);  
    e3 <= reg(2); 
    e4 <= reg(3); 
    e5 <= reg(4); 
    e6 <= reg(5); 
    e7 <= reg(6); 
    e8 <= reg(7); 
    e9 <= reg(8); 
    e10 <= reg(9); 
    e11 <= reg(10); 
    e12 <= reg(11); 
    e13 <= reg(12); 
    e14 <= reg(13); 
    e15 <= reg(14); 
    e16 <= reg(15); 
end reg2ind; 

當我使用它:

reg2ind(val183,ord_p.err.err_17,ord_p.err.err_18, 
ord_p.err.err_19,ord_p.err.err_20,open,open,open,open,open,open, 
open,open,open,open, open,open); 
+1

請添加一些代碼,以便我們可以看到錯誤來自哪裏 –

+0

有了這麼多的參數,我堅持命名關聯作爲開始。 –

+0

是的,我已經聲明瞭幾種記錄數據類型。但我無法定製我想要的所有代碼。我宣佈這個過程將16位寄存器移動到我的記錄數據類型中的某個數據字段,以便壓縮更多數據。 – antonio92

回答

1

缺乏MCVE的是下並不重要站在分析的錯誤。

參見IEEE標準107-2008,10.7過程調用語句,第4段:

For each formal parameter of a procedure, a procedure call shall specify exactly one corresponding actual parameter. This actual parameter is specified either explicitly, by an association element (other than the actual open) in the association list or, in the absence of such an association element, by a default expression (see 6.5.2).

見4.2子程序聲明,4.2.2.3信號參數第1段:

For a formal parameter of class signal, references to the signal, the driver of the signal, or both, are passed into the subprogram call.

和第6段:

If an actual signal is associated with a signal parameter of any mode, the actual shall be denoted by a static signal name. It is an error if a conversion function or type conversion appears in either the formal part or the actual part of an association element that associates an actual signal with a formal signal parameter.

另見14.6動態闡述,第2,b)(部分):

Execution of a subprogram call involves the elaboration of the parameter association list. ...

動態處理與開放不兼容,它可以刪除其他調用相同過程可能需要的驅動程序。

所以如4.2子程序聲明中所示的規則4.2.2.3信號參數段落6要求實際是一個靜態信號名稱。

過程的這個特定示例是不感興趣的,只需將數組輸入的元素分配給信號輸出即可。

一種MCVE:

library ieee; 
use ieee.std_logic_1164.all; 

entity foo is 
end entity; 

architecture fum of foo is 
    procedure reg2ind 
    (signal reg : in std_logic_vector(15 downto 0); 
     signal e1,e2,e3,e4,e5,e6,e7,e8 : out std_logic; 
     signal e9,e10,e11,e12,e13,e14,e15,e16 : out std_logic) is 
    begin 
     e1 <= reg(0); 
     e2 <= reg(1);  
     e3 <= reg(2); 
     e4 <= reg(3); 
     e5 <= reg(4); 
     e6 <= reg(5); 
     e7 <= reg(6); 
     e8 <= reg(7); 
     e9 <= reg(8); 
     e10 <= reg(9); 
     e11 <= reg(10); 
     e12 <= reg(11); 
     e13 <= reg(12); 
     e14 <= reg(13); 
     e15 <= reg(14); 
     e16 <= reg(15); 
    end procedure reg2ind; 

    signal val183: std_logic_vector (15 downto 0); 
    type err_record is 
     record 
      err_17: std_logic; 
      err_18: std_logic; 
      err_19: std_logic; 
      err_20: std_logic; 
     end record; 
    type some_record is 
     record 
     err: err_record; 
     end record; 

    signal ord_p: some_record; 

    signal open5, open6, open7, 
      open8, open9, open10, 
      open11, open12, open13, 
      open14, open15, open16:  std_logic; 
begin 

    reg2ind(val183,ord_p.err.err_17,ord_p.err.err_18, 
    ord_p.err.err_19,ord_p.err.err_20,open5,open6,open7,open8,open5,open6, 
    open7,open8,open9,open10, open11,open12); -- with dummy outputs 

    -- reg2ind(val183,ord_p.err.err_17,ord_p.err.err_18, 
    -- ord_p.err.err_19,ord_p.err.err_20,open,open,open,open,open,open, 
    -- open,open,open,open, open,open); -- as presented FAILS 


end architecture; 

有興趣的讀者可以探索使用基於信號參數的限制。

最簡單的解決辦法可能是使用聚合分配對象的元素重新排列,以實際的排序,而不是匹配過程調用的:

(ord_p.err.err_20, ord_p.err.err_19, ord_p.err.err_18, ord_p.err.err_17) <= 
     val183(3 downto 0); 

重新排列目標允許右手邊是切片名稱而不是聚合,這也將需要一個合格的表達式。這比過程調用的文本複雜性要少。

通過使用過程調用來隱藏細節的任何動力可以伴隨着提供具有更少參數的過程。

函數調用是表達式,它在語義上不可能忽略它們的結果值。您可以將包含函數調用或過程調用語句的語句放在條件執行的語句中(例如if語句,case語句)。