我是初学者,这是我的第一个VHDL代码 它是使用计数器应用7_segment显示的代码 在编译2个代码时,主代码没有错误,而测试台代码给出了6个错误 有什么帮助吗?
主要代码:
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_arith.all;
ENTITY counter IS
port (clk,rst: IN std_logic;
count: OUT std_logic_vector(6 downto 0) );
END counter;
ARCHITECTURE rtl OF counter IS
signalcount_sig: integer range 0 to 7;
BEGIN
PROCESS(clk,rst)
begin
if(rst='1')then
count_sig<=0;
elsif(rising_edge (clk))then
count_sig<= count_sig+1;
end if;
if (count_sig=0) then count <= "1000000";
elsif (count_sig=1) then count <= "1111001";
elsif (count_sig=2) then count <= "0100100";
elsif (count_sig=3) then count <= "0110000";
elsif (count_sig=4) then count <= "0011001";
elsif (count_sig=5) then count <= "0010010";
elsif (count_sig=6) then count <= "0000010";
elsif (count_sig=7) then count <= "1111000";
end if;
end PROCESS;
END rtl;
测试台代码:
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_arith.all;
ENTITY test_counter IS
END test_counter;
ARCHITECTURE beh OF test_counter IS
COMPONENT counter IS
port (clk, rst: in std_logic;
count: out std_logic_vector(6 downto 0));
END counter;
SIGNAL clk, rst: std_logic;
SIGNAL count: std_logic_vector(6 downto 0);
BEGIN
V1: counter PORT MAP
(clk<=clk ,
rst<=rst ,
count<=count);
clock : PROCESS
begin
wait for 5 ns; clk<= not clk;
end PROCESS clock;
reset : PROCESS
begin
rst<= '1';
wait for 10 ns; rst<= '0';
wait for 80 ns;
end PROCESS reset;
END beh;
答案 0 :(得分:0)
在测试平台代码中,组件声明结尾不是END counter;
,而是:
END component counter;
或只是:
END component;
对于组件实例化,然后从端口名称(形式)到信号(实际)的映射不使用<=
而是使用=>
,因此代码实例化应该是:
V1: counter PORT MAP
(clk => clk,
rst => rst,
count => count);