显示 ASCII 字符的计数器输出

发布于 2024-07-14 12:31:48 字数 609 浏览 8 评论 0原文

我有下面的代码可以数到 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

尐籹人 2024-07-21 12:31:48

由于您没有打印任何内容,我假设您正在波形查看器中查看此内容。 将显示的类型设置为整数,您可以将其设置为 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.

墨落画卷 2024-07-21 12:31:48

我不知道 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.

_失温 2024-07-21 12:31:48

插入附加信号:

signal my_char: character;  

然后进行从整数到字符的转换:

my_char <= character'val(countSVal);       

在调试器或波形查看器中检查 my_char 信号,您将看到 ASCII 字符。 我已经用 Aldec Active-HDL 6.1 检查过了。

Insert additional signal:

signal my_char: character;  

Then do the conversion from integer to character:

my_char <= character'val(countSVal);       

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文