VHDL-如何优雅地初始化std_logic_vector数组? [英] VHDL - How to elegantly initialize an array of std_logic_vector?

查看:1383
本文介绍了VHDL-如何优雅地初始化std_logic_vector数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试连接经典的HD44780 LCD. 我已经实现了本地ram,可以将要显示在显示器上的数据写入其中.

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:

I have defined the ram in this way:

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

我尝试过以这种方式初始化ram:

I've tried initializing the ram in this way:

lcd_mem(0 to 6) <= x"45_72_72_6F_72_73_3A";
...

但是我收到综合错误:

错误(10515):display_ber.vhd(74)处的VHDL类型不匹配错误:ram_type类型与字符串文字不匹配

Error (10515): VHDL type mismatch error at display_ber.vhd(74): ram_type type does not match string literal

有没有办法以类似的方式优雅地初始化ram块?

Is there a way to ellegantly initialize the ram block in a similar way ?

也许我应该改用字符串类型?

Perhaps I should use a string type instead ?

推荐答案

是的.请注意,您对ram_type的定义是std_logic_vector的数组.并且x"45_72_72_6F_72_73_3A"是十六进制字符串文字.这些不是同一类型,因此是您的错误.

Yes there is. Note that your definition of ram_type is an array of std_logic_vector. And x"45_72_72_6F_72_73_3A" is a hex string literal. These are not the same type, hence your error.

因此,您必须将值放入向量数组中.如:

So, you have to put the value into an array of vectors. Such as:

lcd_mem(0 to 6) <= (0 => x"45", 1 => x"72", 2 => x"72", 3 => x"6F", 4 => x"72", 5 => x"73", 6 => x"3A");

这篇关于VHDL-如何优雅地初始化std_logic_vector数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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