该计划:
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_unsigned.ALL;
ENTITY comp IS
GENERIC (W : NATURAL );
PORT (A_v :IN std_logic_vector((W-1) DOWNTO 0); --vector a aan ingang
B_v :IN std_logic_vector((W-1) DOWNTO 0); --vector b aan ingang
groter :OUT std_logic; --led 'groter' actief indien a>b
gelijk :OUT std_logic); --led 'gelijk' actief indien a==b
END comp;
ARCHITECTURE behavior OF comp IS
--SIGNAL ci1, ci2: std_logic;
BEGIN
proc: PROCESS (A_v,B_v)
BEGIN
if (A_v=B_v) then
groter<='0';
gelijk<='1';
elsif (A_v>B_v) then
groter<='1';
gelijk<='0';
else
groter<='0';
gelijk<='0';
end if;
END PROCESS proc;
END behavior;
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_unsigned.ALL;
ENTITY comp_test IS
generic (w : NATURAL := 5);
END comp_test;
ARCHITECTURE structural OF comp_test IS
-- Unit Under Test: uut
COMPONENT comp
generic (w : NATURAL);
PORT (A_v :IN std_logic_vector(w-1 DOWNTO 0); --vector a aan ingang
B_v :IN std_logic_vector(w-1 DOWNTO 0); --vector b aan ingang
groter :OUT std_logic; --led 'groter' actief indien a>b
gelijk :OUT std_logic); --led 'gelijk' actief indien a==b
END COMPONENT;
FOR uut: comp USE ENTITY work.comp(behavior);
CONSTANT period : time := 100 ns;
SIGNAL end_of_sim : boolean := false;
-- NATURALerconnection (signals - ports)
SIGNAL A_v : std_logic_vector(w-1 DOWNTO 0); --vector a aan ingang
SIGNAL B_v :std_logic_vector(w-1 DOWNTO 0); --vector b aan ingang
SIGNAL groter : std_logic; --led 'groter' actief indien a>b
SIGNAL gelijk : std_logic; --led 'gelijk' actief indien a==b
BEGIN
uut : comp
GENERIC MAP (w=>5 )
PORT MAP(
A_v => A_v,
B_v => B_v,
groter => groter,
gelijk => gelijk
);
-- Test Bench: TVI-generator
tb_gen : PROCESS
VARIABLE i_v: std_logic_vector((2w-1) DOWNTO 0);
BEGIN
FOR i IN 0 TO (2**2w-1)
LOOP
A_v<=i_v(2w-1 downto w);
B_v<=i_v(w-1 downto 0);
i_v:=i_v+1;
wait for period;
END LOOP;
end_of_sim <= true;
WAIT;
END PROCESS tb_gen;
END structural;
答案 0 :(得分:2)
我警告你......你会踢自己!
VARIABLE i_v: std_logic_vector((2w-1) DOWNTO 0);
错误消息告诉您,无法解析包含值和物理单位(如2 ns,2 ms或...... 2 W)的物理数量,因为W声明会隐藏所谓的物理单位!
如果没有W的声明你会看到一个不同的错误(没有声明这样一个物理单位 - mw w kw等可以合法地声明,代表权力,同样的方式ns等预先声明代表时间。)
然而......
你的目标是将w
乘以2 ......就像在
VARIABLE i_v: std_logic_vector((2*w - 1) DOWNTO 0);
答案 1 :(得分:0)
这实际上是一个明确的错误消息,但是,我没有看到足够的代码来确定重叠是什么。
修复很简单。将名称为“w”的通用名称更改为更长的名称,例如“gWIDTH”。请注意,名称WIDTH用于包“std.textio.all;”
以下是一些可能更明显的完整示例:
architecture test1 of testbench is
signal NS : time ;
. . .
begin
MainTestProc : process
begin
. . .
wait for 5 ns ; --<<-- Error
. . .
在“等待5 ns;”信号声明“NS”在本地范围内。因此,时间单位不可见,产生的错误通常最让人困惑。