显示 ASCII 字符的计数器输出
我有下面的代码可以数到 59。一开始很好,但在 31 之后,开始显示 ASCII 字符,如“(”、“$”、“#”等,而不是数字。知道我哪里出错了?
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.numeric_std.all;
entity counter is
port(clk: IN STD_LOGIC;
secs:OUT INTEGER RANGE 0 to 59);
end counter;
architecture counter_behav of counter is
signal countSVal: INTEGER RANGE 0 to 59:=0;
begin
process(clk)
begin
if(rising_edge(clk)) then
if(countSVal>=59) then
countSVal <= 0;
else
countSVal <= countSVal + 1;
end if;
secs <= countSVal;
end if;
end process;
end counter_behav;
I have the following code to count till 59. It starts off fine but after 31, starts to show ASCII characters like '(', '$', '#' etc., instead of numbers. Any idea where I'm going wrong?
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.numeric_std.all;
entity counter is
port(clk: IN STD_LOGIC;
secs:OUT INTEGER RANGE 0 to 59);
end counter;
architecture counter_behav of counter is
signal countSVal: INTEGER RANGE 0 to 59:=0;
begin
process(clk)
begin
if(rising_edge(clk)) then
if(countSVal>=59) then
countSVal <= 0;
else
countSVal <= countSVal + 1;
end if;
secs <= countSVal;
end if;
end process;
end counter_behav;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
由于您没有打印任何内容,我假设您正在波形查看器中查看此内容。 将显示的类型设置为整数,您可以将其设置为 AnthonyWJones 所说的 ASCII。
Since you aren't printing anything, I assume you are looking at this in a waveform viewer. Set the type shown to integer, you may have it as ASCII as AnthonyWJones said.
我不知道 vhdl 是什么,但是,您用来观察输出的内容似乎很可能不显示 32 之前的 ASCII 字符,因为这些字符将是控制字符,所以它只是妥协并向你展示他们的价值观。 由于 32 及以上是可打印字符,因此它会转而使用这些字符,因为这就是工具认为的值。
I've no idea what vhdl is, however, it seems most likely that what ever you are using to observe the output is not showing you ASCII characters prior to 32 because those would be control characters, so it just compromises and shows you their values. Since 32 and over are printable characters it switches to using those because thats what the tool thinks the values are.
插入附加信号:
然后进行从整数到字符的转换:
在调试器或波形查看器中检查 my_char 信号,您将看到 ASCII 字符。 我已经用 Aldec Active-HDL 6.1 检查过了。
Insert additional signal:
Then do the conversion from integer to character:
Check my_char signal under debugger or in waveform viewer and you will see ASCII characters. I've checked it with Aldec Active-HDL 6.1.