Vhdl代码模拟
Vhdl code simulation
我正在尝试模拟以下代码:
entity schal is port ( SW : in bit_vector(7 downto 0);
LED : out bit_vector(7 downto 0));
end schal;
architecture BEHAVIOUR of schal is
begin
INOUT_PROS : process (SW)
begin
LED <= SW;
end process INOUT_PROS;
end BEHAVIOUR;
我写了这个做文件
vsim work.schal
restart
view wave
radix hex
add wave -height 25 -radix default sim:/schal/*
force SW 01000001
run 20ns
force SW 01000000
run 20ns
这是我得到的:
如您所见,模拟仅影响第一位而不影响整个向量?
知道我应该如何调整 do 文件 以获得正确的模拟吗?
我认为您的 force
命令没有使用正确的语法。您试图强制一个二进制值,但正确的方法是 force SW 2#01000001
,2#
指定一个二进制值。
在 ModelSim 中,转到帮助 > 文档 > PDF Bookcase,然后打开 'Command Reference Manual'。这包含所有命令的文档,包括 force
.
这是阅读精美手册的时刻。请参阅命令参考手册中强制命令参数部分下的 <值> 参数说明。
A one-dimensional array of character enumeration can be forced as a sequence of character literals or as a based number with a radix of 2, 8, 10 or 16. For example, the following values are equivalent for a signal of type bit_vector (0 to 3):
您可能会注意到 IEEE Std 1076-2008 15.5.3 Based literals 告诉我们:
A based literal is an abstract literal expressed in a form that specifies the base explicitly. The base shall be at least two and at most sixteen.
有一些基于 VHDL 标准的文字不能用 force 命令表达。
还要注意问题对
的使用
force SW 01000001
与命令参考手册中的字符文字序列示例兼容。请参阅以下注意:
For based numbers in VHDL, ModelSim translates each 1 or 0 to the appropriate value for the number’s enumerated type. The translation is controlled by the translation table in the pref.tcl file. If ModelSim cannot find a translation for 0 or 1, it uses the left bound of the signal type (type’left) for that value.
另请注意问题的值和波形,SW
s 枚举的最右侧位置可以正确转换。这表明该行为与强制命令 描述不匹配。
在 VHDL 术语中,您被迫使用 scary_jeff 的答案中所示的位字符串文字,而不是字符串文字来提供值。 (都没有引号)。
根据示例,字符文字序列是正确的,但未正确翻译。您可能想知道引号是否有帮助 - 否则如何强制包含前导 space?
的字符串类型对象的值
作为早期的 MTI Modelsim 用户,模拟器最初只支持 VHDL。问题出在模拟器或示例上。
当然还有 VHDL 测试平台的使用,而不是将仿真序列嵌入到 do 文件中。
此方法可在 VHDL 模拟器之间移植:
entity schal_tb is
end entity;
architecture foo of schal_tb is
signal SW: bit_vector(7 downto 0);
signal LED: bit_vector(7 downto 0);
begin
DUT:
entity work.schal
port map (
SW => SW,
LED => LED
);
STIMULUS:
process
begin
SW <= "01000001";
wait for 20 ns;
SW <= "01000000";
wait for 20 ns;
wait for 60 ns; -- to show 100 ns on waveform
wait; -- suspends process permenently
end process;
end architecture;
并给出:
还有在线 VHDL Testbench 大纲生成器,例如 Doulos VHDL Testbench generator or this Online VHDL Testbench Template Generator。
我正在尝试模拟以下代码:
entity schal is port ( SW : in bit_vector(7 downto 0);
LED : out bit_vector(7 downto 0));
end schal;
architecture BEHAVIOUR of schal is
begin
INOUT_PROS : process (SW)
begin
LED <= SW;
end process INOUT_PROS;
end BEHAVIOUR;
我写了这个做文件
vsim work.schal
restart
view wave
radix hex
add wave -height 25 -radix default sim:/schal/*
force SW 01000001
run 20ns
force SW 01000000
run 20ns
这是我得到的:
如您所见,模拟仅影响第一位而不影响整个向量? 知道我应该如何调整 do 文件 以获得正确的模拟吗?
我认为您的 force
命令没有使用正确的语法。您试图强制一个二进制值,但正确的方法是 force SW 2#01000001
,2#
指定一个二进制值。
在 ModelSim 中,转到帮助 > 文档 > PDF Bookcase,然后打开 'Command Reference Manual'。这包含所有命令的文档,包括 force
.
这是阅读精美手册的时刻。请参阅命令参考手册中强制命令参数部分下的 <值> 参数说明。
A one-dimensional array of character enumeration can be forced as a sequence of character literals or as a based number with a radix of 2, 8, 10 or 16. For example, the following values are equivalent for a signal of type bit_vector (0 to 3):
您可能会注意到 IEEE Std 1076-2008 15.5.3 Based literals 告诉我们:
A based literal is an abstract literal expressed in a form that specifies the base explicitly. The base shall be at least two and at most sixteen.
有一些基于 VHDL 标准的文字不能用 force 命令表达。
还要注意问题对
的使用force SW 01000001
与命令参考手册中的字符文字序列示例兼容。请参阅以下注意:
For based numbers in VHDL, ModelSim translates each 1 or 0 to the appropriate value for the number’s enumerated type. The translation is controlled by the translation table in the pref.tcl file. If ModelSim cannot find a translation for 0 or 1, it uses the left bound of the signal type (type’left) for that value.
另请注意问题的值和波形,SW
s 枚举的最右侧位置可以正确转换。这表明该行为与强制命令
在 VHDL 术语中,您被迫使用 scary_jeff 的答案中所示的位字符串文字,而不是字符串文字来提供值。 (都没有引号)。
根据示例,字符文字序列是正确的,但未正确翻译。您可能想知道引号是否有帮助 - 否则如何强制包含前导 space?
的字符串类型对象的值作为早期的 MTI Modelsim 用户,模拟器最初只支持 VHDL。问题出在模拟器或示例上。
当然还有 VHDL 测试平台的使用,而不是将仿真序列嵌入到 do 文件中。
此方法可在 VHDL 模拟器之间移植:
entity schal_tb is
end entity;
architecture foo of schal_tb is
signal SW: bit_vector(7 downto 0);
signal LED: bit_vector(7 downto 0);
begin
DUT:
entity work.schal
port map (
SW => SW,
LED => LED
);
STIMULUS:
process
begin
SW <= "01000001";
wait for 20 ns;
SW <= "01000000";
wait for 20 ns;
wait for 60 ns; -- to show 100 ns on waveform
wait; -- suspends process permenently
end process;
end architecture;
并给出:
还有在线 VHDL Testbench 大纲生成器,例如 Doulos VHDL Testbench generator or this Online VHDL Testbench Template Generator。