微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 嵌入式设计讨论 > FPGA,CPLD和ASIC > 求一个看门狗电路的VHDL仿真代码

求一个看门狗电路的VHDL仿真代码

时间:10-02 整理:3721RD 点击:
先谢谢大侠,因为刚开始学习FPGA,对VHDL的仿真不够了解,请您多多指教!下面是看门狗顶层模块代码,求它的VHDL仿真代码,

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity wd is
PORT(
        clk     : IN  STD_LOGIC;
        start   : IN  STD_LOGIC;
        wr      : IN  STD_LOGIC;
        feeddog : IN  STD_LoGIC;
        data    : IN  STD_LOGIC_VECTOR(7 downto 0);
        reset   : OUT STD_LOGIC
        );
end wd;
architecture structural of wd is
COMPONENT wdcmp
PORT(
        start   : IN   STD_LOGIC;
        clr     : IN   STD_LOGIC;
        clk     : IN   STD_LOGIC;
        wr      : IN   STD_LOGIC;
        data    : IN   STD_LOGIC_VECTOR(7 DOWNTO 0);
        reset   : IN   STD_LOGIC
        );
END COMPONENT;
COMPONENT wdclock
PORT(
   --start   : IN   STD_LOGIC;
        clkin   : IN   STD_LOGIC;
        clr     : IN   STD_LOGIC;
        clk1ms  : IN   STD_LOGIC
   --data    : IN   STD_LOGIC_VECTOR(7 DOWNTO 0);
   --reset   : IN   STD_LOGIC;
        );
END COMPONENT;
COMPONENT wddelay
PORT(
   --start   : IN   STD_LOGIC;
        clk     : IN       STD_LOGIC;
        clr     : IN       STD_LOGIC;
        clrall  : BUFFER   STD_LOGIC
   --data    : IN   STD_LOGIC_VECTOR(7 DOWNTO 0);
   --reset   : IN   STD_LOGIC;
        );
END COMPONENT;
SIGNAL  clk1ms  :  STD_LOGIC;
SIGNAL  clkcmp  :  STD_LOGIC;
SIGNAL  reset_reg : STD_LOGIC;
SIGNAL  clrall  :  STD_LOGIC;
SIGNAL  clr     :  STD_LOGIC;

begin
        U1: wdcmp
        PORT MAP
        (
        start => start,
        clr   => clr,
        clk   => clk,
        wr    => wr,
        data  => data,
        reset => reset_reg
        );
        U2: wdclock
        PORT MAP
        (
        --start => start,
        clkin   => clk,
        clr   => clr,
        clk1ms  => clk1ms
        --wr    => wr,
        --data  => data,
        --reset => reset_reg
        );
        U3: wddelay
        PORT MAP
        (
        clk   => clk1ms,
        clr   => reset_reg,
        clrall => clrall
        );
       
        clr <= feeddog OR clrall;
        clkcmp <= clk1ms AND NOT (reset_reg);
        reset <= reset_reg;
end structural;

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

网站地图

Top