微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 嵌入式设计讨论 > FPGA,CPLD和ASIC > 求助关于VHDL实现累加器

求助关于VHDL实现累加器

时间:10-02 整理:3721RD 点击:
就是会随着每个时钟上升沿加一,然后输出八位二进制数。

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity xiangwei is
port(   rst : in std_logic;
         clk : in std_logic;
         SHLout  : out std_logic_vector(7 downto 0));
            end;
architecture rtl of xiangwei is
begin
    process(clk)
     variable suanzhu : std_logic_vector(7 downto 0):="00000000";
     begin
        if (clk'event and clk='1') then
            if(rst='0') then
                suanzhu:="00000000";                 
             end if;
             if(rst='1') then                 
                if(suanzhu<256) then
                      suanzhu:=suanzhu+1;
                      SHLout<=suanzhu;   
                 else
                      suanzhu:="00000000";
                 end if;
             end if;                 
        end if;         
                 end process;
end;

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top