2017-03-23 17 views
0

我有些東西我不明白。我從VHDL開始,我不明白我怎麼能看到我的電路結果。 我試圖使用textio軟件包,並在終端上打印我的位結果,並試圖將此位打印到output_file.txt文件中,但這些暫定文件都沒有工作。用VHDL打印一下(Ubuntu 16.04)

所以我的問題是,我如何打印一個位值?他們說,當我嘗試:

error: port "s" cannot be read 

有我的代碼:

Library ieee; 
Use ieee.std_logic_1164.all; 
Use ieee.numeric_std.all; 
use std.textio.all; 

entity gate_AND is 
    port(
    x1 : in std_logic :='1'; 
    x2 : in std_logic :='0'; 
    x3 : in std_logic :='0'; 
    s : out std_logic); 
end entity; 

architecture arc of gate_AND is 

begin 

    s <= x1 and x2 and x3; 
process 

     file OutFile : TEXT open write_mode is "output_file.txt"; 
     variable L : line; 
    begin 
     write (L, s); 
     writeline (OutFile, L); 
     wait; 
    end process; 
end arc; 
+1

我懷疑's'被宣佈爲輸出,你不能把它當作一個輸入,而是讓VHDL專家談... – xhienne

+1

OP的問題將在符合IEEE Std 1076-2008標準的VHDL實現中起作用。請參見6.5.2接口對象聲明,第12段*接口對象具有以下模式之一:... - * *** out *** *允許更新接口對象的值,並且只要它是不是信號參數,請閱讀.... *)。參數是特定於子程序的。對於限制於VHDL標準的以前版本的工具,J.H.的答案是有效的。 – user1155120

+1

您還可以通過仿真波形轉儲文件和波形查看器查看電路的結果。你使用什麼VHDL工具? – user1155120

回答

1

Xhienne有正確的答案是:你不能讀取輸出端口。 您應該使用臨時信號或變量。

你的代碼改成這樣的實例:

architecture arc of gate_AND is 
begin 
    process(x1, x2, x3) 
     variable s_temp : std_logic; 
     file OutFile : TEXT open write_mode is "output_file.txt"; 
     variable L : line; 
    begin 
     s_temp := x1 and x2 and x3; 
     write (L, std_logic'IMAGE(s_temp)); 
     writeline (OutFile, L); 
     s <= s_temp; 
    end process; 
end arc; 
+1

ghdl -a --std = 08 gate_and.vhdl; ghdl -e --std = 08 gate_and; ghdl -r gate_and;更多的output_file.txt(並返回'U')。除非是信號參數(IEEE Std 1076-2008)6.5.2接口對象聲明,第12段*接口對象具有以下模式之一:... - * *** out *** *接口對象的值允許更新,如果它不是信號參數,請閱讀.... *)。參數是特定於子程序的。 – user1155120

+0

@ user1155120你是對的。把它放在一個答案,你的可能會被接受。 – JHBonarius

+0

感謝大家的回答!我知道你不能讀取輸出端口,但是當我修復這個問題時,但是我有其他錯誤信息: 'stackOverFullAdder.vhdl:24:15:error:無法解析子程序調用的重載' 是因爲一個頭文件? – Hix