BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / embedded-system / #12073同步于 2012/4/19
该镜像源已超过 30 天没有更新,可能在源站已被删除。
Embedded_System机器人发帖

问一个VHDL 函数的问题

zhibo05
2012/4/19镜像同步0 回复
文件ahb_func.vhd的内容如下: library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; package ahb_funct is function nb_bits (A : INTEGER) return NATURAL; end ahb_funct; package body ahb_funct is function nb_bits (A : INTEGER) return NATURAL is variable logres : NATURAL ; begin logres := 1; for i in 0 to 30 loop if 2**i <= A then logres := i+1; end if; end loop; return logres; end nb_bits; end ahb_funct; 文件tb.vhd的内容如下: library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use work.ahb_funct.all; library novas; use novas.pkg.all; entity tb is generic ( fifo_length: in integer:= 4); end architecture rtl of tb is signal count: std_logic_vector(nb_bits(fifo_length)-1 downto 0); begin dump_pr: process begin fsdbDumpfile("tb.fsdb"); fsdbDumpvars(0, "tb"); wait; end process; end rtl; 仿真后用Debussy查看count信号,为什么是count[-1:0]?正确的应该是count[2:0]。 函数nb_bits哪里有错误么? 望高手指正!
订阅后,新回复会通过你的通知中心匿名送达。
0 条回复
暂无回复 · 你可以订阅本帖等待新回复。