0

我正在 VHDL 书中尝试一个简单的案例问题。从源代码可以理解,它根据输入范围设置输出值。x但是,当我使用 GHDL 运行测试平台时,我无法观察到我的输入。

这是因为x是一种character类型吗?我应该在 GHDL 问题页面(https://github.com/ghdl/ghdl/issues)上提问吗?

源代码(q4_case.vhd):

entity q4_case is

  port (
    x               : in  character;    -- input
    character_class : out integer);     -- output

end entity q4_case;

architecture behav of q4_case is

begin  -- architecture behav

  -- purpose: set output depending on range of input
  -- type   : combinational
  -- inputs : x
  -- outputs: character_class
  process (x) is
  begin  -- process
    case x is
      when 'A' to 'z'       => character_class <= 1;
      when '0' to '9'       => character_class <= 2;
      when nul to usp | del => character_class <= 4;
      when others           => character_class <= 3;
    end case;
  end process;


end architecture behav;

测试台(q4_case_tb.vhd):

library ieee;
use ieee.std_logic_1164.all;

-------------------------------------------------------------------------------

entity q4_case_tb is

end entity q4_case_tb;

-------------------------------------------------------------------------------

architecture q4_case_tb of q4_case_tb is

  -- component ports
  signal x               : character;
  signal character_class : integer;

  -- clock
  signal Clk : std_logic := '1';

begin  -- architecture q4_case_tb

  -- component instantiation
  DUT : entity work.q4_case
    port map (
      x               => x,
      character_class => character_class);

  -- clock generation
  Clk <= not Clk after 10 ns;

  -- waveform generation
  WaveGen_Proc : process
  begin
    -- insert signal assignments here

    x <= 'b';
    wait until Clk = '1';
    wait until Clk = '0';

    x <= 'F';
    wait until Clk = '1';
    wait until Clk = '0';

    x <= dc3;
    wait until Clk = '1';
    wait until Clk = '0';

    x <= usp;
    wait until Clk = '1';
    wait until Clk = '0';

    x <= del;
    wait until Clk = '1';
    wait until Clk = '0';

    x <= '0';
    wait until Clk = '1';
    wait until Clk = '0';

    x <= '5';
    wait until Clk = '1';
    wait until Clk = '0';

    x <= '9';
    wait until Clk = '1';
    wait until Clk = '0';

    x <= '=';
    wait until Clk = '1';
    wait until Clk = '0';

    x <= 'Ü';
    wait until Clk = '1';
    wait until Clk = '0';


    report "End of simulation" severity failure;

  end process WaveGen_Proc;



end architecture q4_case_tb;

-------------------------------------------------------------------------------

configuration q4_case_tb_q4_case_tb_cfg of q4_case_tb is
  for q4_case_tb
  end for;
end q4_case_tb_q4_case_tb_cfg;

-------------------------------------------------------------------------------

编译并运行命令:

ghdl -a q4_case.vhd

ghdl -a q4_case_tb.vhd

ghdl -r q4_case_tb --vcd=q4_case.vcd

版本信息:

ghdl -v
GHDL 0.35 (tarball) [Dunoon edition]
 Compiled with GNAT Version: GPL 2017 (20170515-63)
 mcode code generator
Written by Tristan Gingold.

Copyright (C) 2003 - 2015 Tristan Gingold.
GHDL is free software, covered by the GNU General Public License.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

VCD 输出文件的开头如下所示。如您所见,x未处理,我无法x通过 GTKWave 查看。

VCD部分:

$date
  Thu Feb 08 09:19:40 2018
$end
$version
  GHDL v0
$end
$timescale
  1 fs
$end
$comment x is not handled $end
$var integer 32 ! character_class $end
$var reg 1 " clk $end
$scope module dut $end
$comment x is not handled $end
$var integer 32 # character_class $end
$upscope $end
$enddefinitions $end
#0
b1 !
1"
b1 #
#10000000
...
...
4

2 回答 2

2

我认为您的问题不在于 GHDL 本身,而在于它使用Verilog VCD 格式来记录波形。那个维基百科页面说

标准的四值 VCD 格式与 Verilog 硬件描述语言一起由 IEEE 标准 1364-1995 于 1996 年定义。

这四个值是 0、1、X 和 Z。

于 2018-02-08T07:59:42.773 回答
1

我没有正确检查 GHDL 文档是我的错。正如在https://ghdl.readthedocs.io/en/latest/using/Simulation.html中所写(和 Matthew 指出),VCD 格式仅支持bitbit_vectorfrom 。std.standard无法character使用 VCD 文件观察类型信号。

正如 Brain 建议的那样,从 VCD 切换到 GHW 格式解决了这个问题。对于这种情况,GKTWave 显示 GHW 文件没有任何问题。

于 2018-02-09T19:35:05.337 回答