【问题标题】:Applying 7-segment display using counter VHDL使用计数器 VHDL 应用 7 段显示
【发布时间】:2014-12-21 03:41:41
【问题描述】:

我是初学者,这是我的第一个 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;

【问题讨论】:

    标签: vhdl


    【解决方案1】:

    在测试台代码中,组件声明端不是END counter;而是:

    END component counter;
    

    或者只是:

    END component;
    

    对于组件实例化,那么从端口名称(形式)到信号(实际)的映射不使用&lt;=而是=&gt;,所以代码实例化应该是:

    V1: counter PORT MAP
      (clk   => clk,
       rst   => rst,
       count => count);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-12-04
      • 1970-01-01
      • 1970-01-01
      • 2021-04-23
      • 1970-01-01
      • 2022-12-04
      • 1970-01-01
      相关资源
      最近更新 更多