我正在为 Windows 使用 GHDL 0.29。
以下程序打印“Hello world!”
use std.textio.all;
entity hello_world is
end hello_world;
architecture behaviour of hello_world is
begin
process
variable l : line;
begin
write (l, String'("Hello world!"));
writeline (output, l);
wait;
end process;
end behaviour;
以下程序挂起并且不打印任何内容。
use std.textio.all;
entity hello_world is
end hello_world;
architecture behaviour of hello_world is
begin
process
variable l : line;
begin
assert false report "Foo" severity note;
write (l, String'("Hello world!"));
writeline (output, l);
wait;
end process;
end behaviour;
以下程序输出两个断言,然后是“Hello world!” 信息。
use std.textio.all;
entity hello_world is
end hello_world;
architecture behaviour of hello_world is
begin
process
variable l : line;
begin
assert false report "Foo" severity note;
assert false report "bar" severity note;
write (l, String'("Hello world!"));
writeline (output, l);
wait;
end process;
end behaviour;
我尝试增加断言的数量,我发现当我有奇数个断言时,模拟会挂起。甚至它们位于何处都无关紧要。以下挂起:
assert false report "Foo" severity note;
assert false report "bar" severity note;
assert false report "zoz" severity note;
assert false report "lol" severity note;
assert false report "mok" severity note;
assert false report "antidisestablishmentarianism" severity note;
write (l, String'("Hello world!"));
writeline (output, l);
wait;
assert false report "asd" severity note;
以下将所有内容打印到“反建制主义”断言:
assert false report "Foo" severity note;
assert false report "bar" severity note;
assert false report "zoz" severity note;
assert false report "lol" severity note;
assert false report "mok" severity note;
assert false report "antidisestablishmentarianism" severity note;
write (l, String'("Hello world!"));
writeline (output, l);
wait;
assert false report "asd" severity note;
assert false report "gneeek" severity note;
编辑
这个问题更普遍,并且似乎与进程中的语句数为奇数或偶数有关。以下打印“Hello world!Hello moon!” 反复:
-- Hello world program.
use std.textio.all; -- Imports the standard textio package.
-- Defines a design entity, without any ports.
entity hello_world is
end hello_world;
architecture behaviour of hello_world is
begin
process
variable l : line;
begin
write (l, String'("Hello world!"));
write (l, String'("Hello moon!"));
writeline (output, l);
end process;
end behaviour;
虽然以下内容不打印任何内容并挂起:
-- Hello world program.
use std.textio.all; -- Imports the standard textio package.
-- Defines a design entity, without any ports.
entity hello_world is
end hello_world;
architecture behaviour of hello_world is
begin
process
variable l : line;
begin
write (l, String'("Hello world!"));
writeline (output, l);
end process;
end behaviour;
编辑(这可能会为您节省一些时间)
上面描述的奇怪行为在 Linux 下不会发生。显然,两个 GHDL 版本之一存在严重缺陷,我强烈怀疑它是 Windows 版本。我会提交错误报告。我仍然对为什么行为不同感兴趣。
编辑(我也尝试使用 0.25 版)
使用适用于 Windows 的 0.25 版时,我收到此错误:
C:\Users\AjejeBrazorf\Documents\Programming\GHDL\Example>ghdl -a 1.vhdl
1.vhdl:1:10: file textio.v93 has changed and must be reanalysed
ghdl.exe 是与 GTKWave 捆绑包一起打包的 ( https://stackoverflow.com/a/16629872/415727 )。