You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VHDL秒级与分钟级脉冲计数器实现疑问求助

VHDL脉冲计数器实现问题求助

刚入门学习VHDL,对后续学习方向很迷茫,因对知识点理解不全面,不确定当前做法是否正确,特此求助。

需求说明

  • 1位Pulse_In输入;
  • 接收1000Hz时钟信号的1位Clock输入;
  • 两个16位输出Pulse_sec、Pulse_min;
  • 统计Pulse_In输入的脉冲上升沿数量,Pulse_sec输出每秒脉冲数,Pulse_min输出过去一分钟的脉冲数,且输出需在每秒结束时更新。

尝试代码

时钟生成模块

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity clock_gen is
  port(clock: out bit);
end entity;

architecture behav of clock_gen is
  constant frequency: integer:= 1000;
  constant period: time:= 1000ms/frequency;
begin 
 clock: process
 begin 
   clock <= '0','1' after period/2;
   wait for period;
 end process clock;
end architecture;

计数器模块

entity PulseCounter is
  port(Pulse_in: in bit;
       Clock: in bit;
       Pulse_sec, Pulse_min: out integer range 0 to 15);
end entity;

architecture my_counter of PulseCounter is
begin
    process
      variable seconds: integer:=0;
    begin
      if (Clock='1' and Clock'last_value='0') then
        if (Pulse_in='1' and seconds/=59) then
           Pulse_sec := Pulse_sec + 1;
           Pulse_min := Pulse_min + Pulse_sec;
           seconds := seconds + 1;
        end if;
      end if;
      wait on Clock;
    end process;
end architecture;

疑问点

不确定上述实体定义是否符合需求,也不清楚进程逻辑是否正确。

内容的提问来源于stack exchange,提问作者Sabaudian

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.10 14:35:09