iandphp的个人空间 https://blog1.eetop.cn/?1708816 [收藏] [复制] [分享] [RSS] 这是我的空间

日志

vhdl代码

已有 4 次阅读| 2025-5-23 17:02 |系统分类:芯片设计

hdl;toolbar:false">library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
 
entity counter is
    Port ( clk : in STD_LOGIC;
           reset : in STD_LOGIC;
           count_out : out STD_LOGIC_VECTOR(3 downto 0));
end counter;
 
architecture Behavioral of counter is
    signal count : unsigned(3 downto 0) := (others => '0');  -- 使用unsigned类型定义内部计数器变量
begin
    process(clk, reset)
    begin
        if reset = '1' then
            count <= (others => '0');  -- 复位操作使用unsigned类型直接赋值0
        elsif clk'event and clk = '1' then  -- 时钟上升沿触发计数操作
            count <= count + 1;  -- 使用unsigned类型进行加法操作,自动处理溢出问题
        end if;
        count_out <= std_logic_vector(count);  -- 将unsigned类型转换为std_logic_vector以匹配输出端口类型
    end process;
end Behavioral;



点赞

评论 (0 个评论)

facelist

您需要登录后才可以评论 登录 | 注册

  • 0

    周排名
  • 0

    月排名
  • 0

    总排名
  • 54

    关注
  • 7

    粉丝
  • 49

    好友
  • 19

    获赞
  • 27

    评论
  • 6380

    访问数

手机版| 小黑屋| 关于我们| 联系我们| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2025-5-24 04:56 , Processed in 0.106057 second(s), 14 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
返回顶部