⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 watchdog.v

📁 VERILOG HDL 实际工控项目源码
💻 V
字号:
// WARNING: Do NOT edit the input and output ports in this file in a text
// editor if you plan to continue editing the block that represents it in
// the Block Editor! File corruption is VERY likely to occur.

// Copyright (C) 1991-2004 Altera Corporation
// Any  megafunction  design,  and related netlist (encrypted  or  decrypted),
// support information,  device programming or simulation file,  and any other
// associated  documentation or information  provided by  Altera  or a partner
// under  Altera's   Megafunction   Partnership   Program  may  be  used  only
// to program  PLD  devices (but not masked  PLD  devices) from  Altera.   Any
// other  use  of such  megafunction  design,  netlist,  support  information,
// device programming or simulation file,  or any other  related documentation
// or information  is prohibited  for  any  other purpose,  including, but not
// limited to  modification,  reverse engineering,  de-compiling, or use  with
// any other  silicon devices,  unless such use is  explicitly  licensed under
// a separate agreement with  Altera  or a megafunction partner.  Title to the
// intellectual property,  including patents,  copyrights,  trademarks,  trade
// secrets,  or maskworks,  embodied in any such megafunction design, netlist,
// support  information,  device programming or simulation file,  or any other
// related documentation or information provided by  Altera  or a megafunction
// partner, remains with Altera, the megafunction partner, or their respective
// licensors. No other licenses, including any licenses needed under any third
// party's intellectual property, are provided herein.


// Generated by Quartus II Version 4.1 (Build Build 207 08/26/2004)
// Created on Mon Sep 06 09:32:31 2004

//  Module Declaration
module watchdog
(
	// {{ALTERA_ARGS_BEGIN}} DO NOT REMOVE THIS LINE!
	page, rd_add, rd_clk, g_clk, dog_en, strb, dsp_rst, rst, dir_4052
	// {{ALTERA_ARGS_END}} DO NOT REMOVE THIS LINE!
);
// Port Declaration

	// {{ALTERA_IO_BEGIN}} DO NOT REMOVE THIS LINE!
	input [3:0] page;
	input [15:12] rd_add;
	input rd_clk;
	input g_clk;
	input dog_en;
	input strb;
	output dsp_rst;
	output rst;
	output dir_4052;
	// {{ALTERA_IO_END}} DO NOT REMOVE THIS LINE!
	reg rst;
	wire feed_dog;
	
	assign dir_4052=dog_clk;
	assign feed_dog=strb|page[2]|(~rd_add[15])|(~rd_add[14])|(~rd_add[13])|rd_add[12];
	
	reg  [25:0] watch_reg;
	reg  [1:0] 	step;
	reg         dog_clk;
	
	always @(posedge rst or negedge feed_dog)
	if(rst)
	dog_clk<=0;
	else
		begin
			dog_clk=~dog_clk;
		end
	
	reg [1:0] dog_reg;
	always @(posedge rst or posedge g_clk)
	if(rst)
	dog_reg<=2'b00;
	else
		begin
			if(dog_en==0)
			dog_reg<=2'b10;
			else dog_reg<={dog_reg[0],dog_clk};
		end
		
	wire dog_end_en=^dog_reg;	
    always @(posedge g_clk)
	
	  begin
		 	case (step)
			
		 	0: begin
					rst<=0;
					step<=1;
				end
		 	1: begin
					rst<=1;
					step<=2;
				end	
		 	2: begin
				if(watch_reg>=25000000)
					begin
						watch_reg<=0;
						rst<=0;
						step<=3;
					end
				else watch_reg<=watch_reg+1;
				end
		 	3: begin
		 		if(dog_end_en)
					begin
			  		 watch_reg<=0;
			 		  rst<=0;
					end
				else if(watch_reg>=25000000)
				 	begin
					 	rst<=~rst;
						watch_reg<=0;
				 	end
         	 	 else  
					 begin
					 	watch_reg<=watch_reg+ 1;
				 	 end	
			end
			
		 endcase	
	  end
	assign dsp_rst=~rst;
endmodule

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -