1

初心者向けの質問が 2 つあります。配列のデータを vhdl のテキスト ファイルに出力しようとしています。これを行うために多くのオンライン ガイドを参照しているにもかかわらず、常に「ファイルが存在しません」というメッセージが表示されます。何がうまくいかないかについて何か提案はありますか?

次に、以下の配列シグナルを書き込み関数の引数として使用しようとすると、エラーが発生します。非定数データをオペランドとして他にどのように使用できますか?

entity Top_Module is
Port ( clk : in  STD_LOGIC);
end Top_Module;

architecture Behavioral of Top_Module is

type array_1 is array (0 to 127) of integer range -128 to 127;
signal sample_1: array_1  := (104,40,-40,-104,-128,-104,-40,40,104,127,104,40,40,-4);
constant  a :std_logic_vector(3 downto 0):= "0111";
begin


process(clk)    -- process for writing the outputs to the "*.txt" file
file result_file: text  is out "fft_output.txt";
variable outline:line;
constant tmp_fft:integer:=0;
begin
    if(clk'event and clk='1') then
                --tmp_fft  :=to_integer(signed(sample_1));
                write(outline,a);
                writeline(result_file,outline);
    end if;
end process;
4

2 に答える 2

1

Morten の回答に加えて、集約されたデフォルト値のすべての要素を表していませんでした。これは、閉じ括弧の前にsample_1追加することで解決できます。, others => 0

あなたのVHDL設計仕様はIEEE Std 1076-1987に準拠していたので、ghdlの --std=87 フラグを使用して、私が座っていた文字列変換ルーチンを使用して少しまとめました。(そして、-1987 の 'VALUE の欠如は面倒でした):

library ieee;
use ieee.std_logic_1164.all;
use std.textio.all;

entity Top_Module is
Port ( clk : in  std_logic);
end Top_Module;

architecture Behavioral of Top_Module is
    function slv_image(constant inp: std_logic_vector) return string is
        variable image_str: string (1 to inp'length);
        alias input_str:  std_logic_vector (1 to inp'length) is inp;
    begin
        for i in input_str'range loop
            case input_str(i) is
                when 'U' => image_str(i) := 'U';
                when 'X' => image_str(i) := 'X';
                when '0' => image_str(i) := '0';
                when '1' => image_str(i) := '1';
                when 'Z' => image_str(i) := 'Z';
                when 'H' => image_str(i) := 'H';
                when 'L' => image_str(i) := 'L';
                when 'W' => image_str(i) := 'W';
                when '-' => image_str(i) := '-';
            -- image_str(i) := character'VALUE(std_ulogic'IMAGE(input_str(i)));
            end case;
        end loop;
        return image_str;
    end;
    type array_1 is array (0 to 127) of integer range -128 to 127;
    signal sample_1: array_1  := (104,40,-40,-104,-128,-104,-40,40,104,127,104,40,40,-4, others => 0);
    constant  a : std_logic_vector(3 downto 0):= "0111";
begin

Unlabelled:
    process(clk)    -- process for writing the outputs to the "*.txt" file
        file result_file: text  is out "fft_output.txt";
        -- file result_file : text open write_mode is "fft_output.txt";
        variable outline: line;
        constant tmp_fft:integer := 0;
    begin
        if(clk'event and clk='1') then
                    --tmp_fft  :=to_integer(signed(sample_1));
                    write(outline,slv_image(a));
                    writeline(result_file,outline);
        end if;
    end process;
end Behavioral; -- architecture;

テストベンチの場合:

library ieee;
use ieee.std_logic_1164.all;

entity tb_topmod is
end tb_topmod;

architecture foo of tb_topmod is
    signal clk:  std_logic := '0';
    component Top_Module   -- no is
        Port ( clk : in  std_logic);
    end component;
    for DUT: Top_Module use entity work.Top_Module(Behavioral);
begin
DUT:
    Top_Module   -- entity work.Top_Module
        port map (clk => clk);
CLOCK:
    process
    begin
        wait for 20 ns;
        clk <= not clk;
        if Now > 100 ns then
            wait;
        end if;
    end process;
end foo;

ghdl -a --std=87 topmod.vhdl
ghdl -e --std=87 tb_topmod foo
ghdl -r tb_topmod foo

(設計を分析し、詳細化し、実行 (シミュレート) します。)

ファイル fft_output.txt ファイルには次が含まれます。

もっと fft*
0111
0111
0111

Nowこれは、テスト ベンチのCLOCKプロセスでのテストで期待される出力です。設計仕様では、 のデフォルト値のみが提供されますa

VHDL -1987 ツールを本当に使用していますか?

于 2014-10-08T16:03:40.117 に答える