//QxSourse information February 22, 2004 This line must be commented out by adding //. By commenting out this line you // will modify the source and therefore take full responsibility for this document/code as used // by you. // You may not publish or in any other way make this document or code or copy thereof // available to the public without QxSourse written consent. // You or your organization may in other ways use this code or information to your benefit. // QxSource is the sole owner of this document. By using this document you acknowledge that: // A) QxSource is in no way responsible for this documents/codes use or functionality. // B) QxSource is in no way responsible for damage caused by any use of this document/code // or it's functionality. // C) QxSource provides no warranties for the contents, functionality or use of this document. // D) This document is provided as is for educational purpose only. //We wish you the best use of this educational information. //==================================================================== `define TEST 1 //To include test `ifdef TEST //module CounterTest ( Reset, Clk, Count, Equ ); module CounterTest ( Reset, Clk, Count, Equ ); input Reset, Clk; output [7:0]Count; output Equ; wire [7:0]Count; wire Equ; assign Equ = (Count == 8'h0); Counter Counter1( .Reset(Reset), .Clk(Clk), .Count(Count) ); endmodule `endif //========================================= //module Counter ( Reset, Clk, Count) module Counter ( Reset, Clk, Count); input Reset, Clk; output Count; reg [7:0]Count; //Register used for counter always@(posedge Clk) begin if (!Reset) Count <= 8'h0; //8 bits of 0 else Count <= Count + 1; end endmodule