在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 1841|回复: 1

一个VHDL的问题

[复制链接]
发表于 2007-10-2 15:44:29 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
在Vhdl中,一个record能不能作为signal传递?

如下面这个程序
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
use ieee.numeric_std.all;

use work.complex_num.all;

entity w_rom is
  port(
    addr : in integer;
    dout : out complex
    );
end w_rom;

architecture arch of w_rom is
  type romtable is array (0 to 7) of complex;
  constant romdata : romtable :=
   ( ("0000000100000000","0000000000000000"),  -- 1
     ("0000000010110101","1111111101001011"),  -- 0.7071 - 0.7071i
     ("0000000000000000","1111111100000000"),  -- 0.0000 - 1.0000i
     ("1111111101001011","1111111101001011"),  -- -0.7071 - 0.7071i
     ("1111111100000000","0000000000000000"),  -- -1.0000 - 0.0000i
     ("1111111100000000","0000000000000000"),  -- -0.7071 + 0.7071i
     ("0000000000000000","0000000100000000"),  -- -0.0000 + 1.0000i
     ("0000000010110101","0000000010110101")   -- 0.7071 + 0.7071i
   );
begin
  process(addr)
  begin
    dout <= romdata(addr);
  end process;
end arch;  

complex是我定义在work.complex_num里的一个record,有re和img两个部分。我用下面这个testbench运行的时候
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;

use work.complex_num.all;

entity tb_w_rom is end tb_w_rom;

architecture arch of tb_w_rom is
  component w_rom
    port(
    addr : in integer;
    dout : out complex
    );
  end component;
  signal addr : integer;
  signal dout : complex;
begin
  c1 : w_rom port map (addr, dout);
  addr <= 1;
          --1 after 10 ns,
          --2 after 20 ns,
          --3 after 30 ns,
          --4 after 40 ns,
          --5 after 50 ns,
          --6 after 60 ns,
          --7 after 70 ns;
end arch;

在compile的时候没有任何error或者warning,但是run的时候程序就指在dout <= romdata(addr);(程序里红色)的这一行不能运行,请教一下是不是record不能这么传递。

非常感谢。
 楼主| 发表于 2007-10-3 04:49:46 | 显示全部楼层
自己发现解决方法了,虽然不知道为什么原来那样不可以,请高手指教。

解决方法是:
1,将addr的类型改为std_logic_vector(2 downto 0)
2,将红色那行改为dout <= romdata(conv_integer(addr));
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /2 下一条

×

小黑屋| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-5-4 11:32 , Processed in 0.028488 second(s), 9 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表