VHDL - 限定表达式必须与上下文隐含的表达式类型相匹配 [英] VHDL - Qualified Expression must match the type that is implied for the expression by context

查看:76
本文介绍了VHDL - 限定表达式必须与上下文隐含的表达式类型相匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题是对我的最后一个问题.

正如我之前提到的,我正在尝试连接到经典的 HD44780 LCD.我已经实现了本地 ram,我将希望在显示器上显示的数据写入其中.

As I mentioned before, I'm trying to interface to a classic HD44780 LCD. I have implemented local ram to which I write the data I wish to show up on the display.

ram 是这样定义的(与上一个问题略有不同):

The ram is defined this way (slight change from last question):

type ram_type is array (integer range <>) of std_logic_vector(7 downto 0);
signal lcd_mem : ram_type(0 to 16*2-1);

我想在 LCD 的某个位置显示一堆常量字符和一个数字,我尝试通过这种方式直接写入 lcd_mem 来做到这一点:

I would like to display a bunch of constant characters and a number in a certain location on the LCD, I tried doing this by writing directly to lcd_mem this way:

lcd_mem <= (0 => x"45", 1 => x"72", 2 => x"72", 3 => x"6F", 4 => x"72", 5 => x"73", 6 => x"3A", 15 => x"30",    16 => x"54", 17 => x"58", 18 => x"3A", 30 => x"4D", 31 => x"3A", others => x"20");

第 79 行:

lcd_mem(22 to 28) <= get_ascii(1234567); --to_integer(unsigned(n_bits(39 downto 20)))

整数 1234567 稍后将被 to_integer 注释替换.

the integer 1234567 will later be replaced by the to_integer comment.

我已经编写了 get_ascii 函数,该函数应该通过将 0x30 添加到 bcd 表示将整数转换为 bcd 表示而不是 ascii.这是函数的一部分:

I have written the get_ascii function which is supposed to convert the integer into bcd representation and than to ascii by adding 0x30 to the bcd representation. Here is a part of the function:

variable num    : ram_type(0 to 16*2-1);
variable temp   : std_logic_vector(number'range);
variable bcd    : unsigned ((4*7-1) downto 0) := (others => '0');
.
.
.
num(0) := std_logic_vector(bcd(3 downto 0) + x"30");
num(1) := std_logic_vector(bcd(7 downto 4) + x"30");
num(2) := std_logic_vector(bcd(11 downto 8) + x"30");
num(3) := std_logic_vector(bcd(15 downto 12) + x"30");
num(4) := std_logic_vector(bcd(19 downto 16) + x"30");
num(5) := std_logic_vector(bcd(23 downto 20) + x"30");
num(6) := std_logic_vector(bcd(27 downto 24) + x"30");          
return num;

编译时出现以下错误:

错误 (10511): display_ber.vhd(79) 处的 VHDL 限定表达式错误:限定表达式中指定的 get_ascii 类型必须与上下文隐含的 ram_type 类型匹配

Error (10511): VHDL Qualified Expression error at display_ber.vhd(79): get_ascii type specified in Qualified Expression must match ram_type type that is implied for expression by context

我无法安静地理解消息的含义.我尝试定义一个更短的 ram_type(0 到 6) 变量来接收来自 get_ascii 函数的值,但这没有帮助.

I can't quiet understand the meaning of the message. I have tried defining a shorter variable of ram_type(0 to 6) to receive the value from the get_ascii function but that didn't help.

推荐答案

好吧,这显然是因为我在包和架构中都定义了类型ram_type".

Ok, apparently this happen because I defined the type "ram_type" in both the package and the architecture.

删除架构中的ram_type"定义后,错误消失了.

After deleting the "ram_type" definition in the architecture the error is gone.

这篇关于VHDL - 限定表达式必须与上下文隐含的表达式类型相匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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