是否可以使用vhdl打印波形中的字符串

时间:2016-11-17 18:18:15

标签: vhdl quartus

说它是针对FSM的,我想在每个时钟周期打印出当前状态。我该怎么做呢?我需要什么数据类型?

1 个答案:

答案 0 :(得分:2)

是的,例如波形ModelSim可以显示string,这可以非常方便。下面是一个简单的例子:

architecture sim of tb is

  signal info : string(1 to 20);

  function string_fill(msg : string; len : natural) return string is
    variable res_v : string(1 to len);
  begin
    res_v := (others => ' ');  -- Fill with spaces to blank all for a start
    res_v(1 to msg'length) := msg;
    return res_v;
  end function;

begin

  process is
  begin
    info <= string_fill("Hello VHDL", info'length);
    wait for 100 ns;
    info <= string_fill("Hi Bren", info'length);
    wait for 100 ns;
    info <= string_fill("end of sim", info'length);
    wait for 100 ns;
    wait;
  end process;

end architecture;

显示:

enter image description here

请注意,在VHDL中字符串操作可能有点棘手,但如果您只需要一些简单的调试输出,那么上面的操作就可以了。