如何在VHDL中使用泛型设置全局模拟文件夹?

时间:2017-02-28 08:39:40

标签: vhdl modelsim

我正在尝试将模拟输出文件夹作为testbench的通用文件夹。测试平台首先将泛型设置为某个全局可用变量,然后不同的块可以访问此变量以确定输出文件夹。

原因是现在do文件可以启动多个模拟,其中结果将被放入不同的文件夹而无需重新编译VHDL。

以下是我迄今为止所取得的成就并且有效,但看起来非常笨重。

有更好的方法吗?

.do文件:

  

设置dirname ./SimsetSmall/
  exec mkdir -p $ dirname
  vsim -G tb / gFolder = $ dirname tb_opt;跑1我们

MyPackage正文:

type tProtectedFileName is protected
    body
        variable vF : tFileName := new string'("./");
    impure function Get return string is
    begin
        return vF.all;
    end function Get;

    procedure Set (constant fIn : in string) is
    begin
        deallocate(vF);
        vF := new string'(fIN);
    end procedure Set;
end protected body tProtectedFileName;

shared variable svSimFolder : tProtectedFileName;

impure function ifGetSimFolder return string is
begin
    return svSimFolder.Get;
end function ifGetSimFolder;

procedure pSetSimFolder (constant fIn : in string) is
begin
    svSimFolder.Set(fIn);
end procedure pSetSimFolder;

最后,VHDL文件:

library ieee;
use ieee.std_logic_1164.all;
use std.textio.all;
use ieee.std_logic_textio.all;
use work.MyPackage.all;

entity tb is
    generic (gFolder : string);
end entity tb;

architecture sim of tb is
begin
    process
    begin
        pSetSimFolder(gFolder);
        wait;
    end process;

    -- in some other entity without gFolder:
    process 
        file f          : text;     
    begin
        wait for 1 ns;
        file_open(f, ifGetSimFolder & "thissim.txt", write_mode);
        file_close(f);
        wait;
    end process;
end architecture sim;

具体来说:

  • 我是否真的需要有程序和不正确的功能来调用
    Set和Get in受保护的共享变量,无法访问
    他们直接?
  • 是否还有其他(更简单)的机制来实现同样的目标?
  • Set过程需要取消引用vF访问类型。是个 deallocate / new唯一/最好的方法吗?

我知道我可以将顶级通用传播到所有块,但这是我试图避免的。

0 个答案:

没有答案
相关问题