VHDL integer'image返回" 0 QUOT; [英] VHDL integer'image Returns "0"

查看:232
本文介绍了VHDL integer'image返回" 0 QUOT;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我的困境:

我很新在VHDL编程,和我目前工作的一个独立研究项目的大学班级。我已经取得了一些进展血统,但我碰到的一个问题,我一直没能解决。

I'm very new to programming in VHDL, and I'm currently working on an independent study project for a university class. I've made some descent headway, but I've run into an issue I haven't been able to solve.

我想要做的是显示注册(或寄存器),LCD显示器上,并将它定期更新。暂且,这些值将永远是整数。

What I'm trying to do is to display a "register" (or registers) on an LCD monitor and have it update periodically. For the time being, these values will always be integer numbers.

我已经写了code这正常显示在屏幕上的数字如果的值作为从不更改作为硬$ C变量传递$ CD值。不过,我想通过增加它更新一个变量,然后传递给我的功能并显示。

I have code written which displays numbers properly on the screen if that value is passed as a variable that is never altered or as a hard-coded value. However, I want to update a variable by adding to it, then pass that to my function and display it.

基本上我想要做的是这样的:

Essentially what I'm trying to do is this:

'X'时钟滴答,增加一个寄存器的值,它传递给它返回一个新的屏幕我update_screen函数,然后显示下文。但是,一旦我增加或重新分配,通过改变(似乎并不重要,如果它是变量或信号),我看到的是0在屏幕上。

Every 'x' clock ticks, increment a register's value, pass that to my update_screen function which returns a new screen, and then display that further below. However, once I increment or change through reassignment (doesn't seem to matter if it is variable or a signal), all I see is '0' on the screen.

所以...以下$ C $,除非我取消注释行c正确地更新我的显示。在这一点上,它只是显示0。

So... The following code properly updates my display unless I uncomment the commented lines. At that point, it just shows '0'.

--currentRegVal := currentRegVal + 1;
--screenVal <= 25;

-- screen holds the values for the current screen
-- The second argument is the row on the screen to be updated
-- The third argument is the value to display there
screen := update_screen(screen, 1, currentRegVal);
screen := update_screen(screen, 0, screenVal + 25);

这个问题似乎从integer'image属性所产生的(或者更准确地说,我的理解它)。当我通过在硬codeD值或没有被改变一个变量,它返回我的期望。然而,当我修改的变量/信号中的任何方式似乎返回字符串0。

The problem seems to be stemming from the integer'image attribute (or more accurately, my understanding of it). When I pass in a hardcoded value or a variable that hasn't been altered, it returns what I expect. However, as soon as I modified the variable/signal in ANY way it seems to return the string "0".

下面是我的update_screen功能:

Below is my update_screen function:

function update_screen(screen: screenData; reg, regVal: integer) return screenData is
    -- A function may declare local variables. These do not retain their values between successive calls,
   -- but are re-initialised each time. Array-type parameters may be unconstrained:
    constant screenWidth: integer := screen'length(2);
    constant strRegVal: string := integer'image(regVal);
    constant strRegLen: integer := strRegVal'length;

    variable newScreen: screenData := screen;
begin
    for dex in 1 to screenWidth loop
        if dex <= strRegLen then
            newScreen(reg, dex-1) := strRegVal(dex);

        else
            newScreen(reg, dex-1) := ' ';
        end if;

        -- The next two ifs were my attempt to figure out what
        -- was going on... 

        --The value itself never seems to be 0... the screen is not all 5's
        if regVal = 0 then
            newScreen := (others => (others => '5'));
        end if;

        -- But the string value is "0" if the variable/signal is ever modified...
        -- 'd' shows up in the designated row.
        if strRegVal = "0" then
            newScreen(reg*3, 1) := 'd';
        end if;
    end loop;
    return newScreen;
end update_screen;

几个重要的点(加2011-07-26):


  • 我使用Quartus II免费(网络)版设计/编译我的项目。

  • 的code这是更新变量是一个过程。

  • 在原发帖的时候,我采取的唯一措施是编译我的code和烧录Altera FPGA DE2板的结果(我不知道如何执行任何模拟)。

在此先感谢您的帮助和建议。此外,正如我所说,我是新来的VHDL编程,所以如果有一个更好的方法做一些事情,我在这里做,请让我知道。我还想对语言本身大大AP preciate有用链接到任何资源。

Thanks in advance for any help and advice. Also, as I said, I'm new to VHDL programming, so if there is a much better way to do something I'm doing here, please let me know. I would also greatly appreciate useful links to any resources about the language itself.

更新(2011-07-26):

我下载GHDL马丁·汤普森建议,但我还没有实际使用它尚未因为我不知道如何去与我目前的Quartus II工程这样做(或者,如果我甚至可以)。我不得不做一些阅读之前,它是对我有用。不过,昨天我设法安装的ModelSim-Altera的随的Quartus II直接作用,让我进行一些模拟。

I downloaded GHDL as Martin Thompson suggested, but I have not actually used it yet because I'm not sure how to go about doing so with my current Quartus II project (or if I even can). I'll have to do some reading before it is useful to me. However, yesterday I managed to install ModelSim-Altera which works directly with Quartus II and allowed me to perform some simulation.

我尽我所能去建立一些波形,让我来测试,而我至少能够检查code,我认为是失败的执行。然而,在模拟过程中,我在该画面对象不包含我想要的* screen_update *函数运行后包含值多种方式核实。当在Altera的DE2运行,但是,它仍然失败。

I did my best to set up some waveforms that would allow me to test, and I was at least able to examine the execution of the code which I believed to be failing. However, during simulation, I've verified in multiple ways that the "screen" object does contain the value I want it to contain after the *screen_update* function runs. When running on the Altera DE2, however, it still fails.


  • 注意的:我没核实取决于直接设置在屏幕不同的价值观在特定元素的值在屏幕实际执行更新与否在 currentRegVal 是奇数还是偶数。

  • Note: I did verify that the screen actually does update by directly setting the value of a particular element on the screen to different values depending on whether or not the currentRegVal is even or odd.

我就打算发布一些code的明天,但现在:

I'll plan on posting some code tomorrow, but for now:

什么原因那里,模拟将提供不同的结果?我的猜测是值得由于具有定时,但它实际上只是一个猜测。如果我是正确的,我怎么能去试图解决这个问题?

推荐答案

假设这code是一个过程:

Assuming this code is in a process:

screenVal <= 25;
-... snip...    
screen := update_screen(screen, 0, screenVal + 25);

这篇关于VHDL integer'image返回&QUOT; 0 QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆