From 2ac48fa0e44016a6cb49cab84a154eb7ec2dcab4 Mon Sep 17 00:00:00 2001 From: Michael Abed Date: Wed, 21 Mar 2012 13:17:47 -0400 Subject: Initial Commit --- Countdown.v | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 Countdown.v (limited to 'Countdown.v') diff --git a/Countdown.v b/Countdown.v new file mode 100644 index 0000000..78e4162 --- /dev/null +++ b/Countdown.v @@ -0,0 +1,57 @@ +`timescale 1ns / 1ps +////////////////////////////////////////////////////////////////////////////////// +// Company: +// Engineer: +// +// Create Date: 14:51:02 03/16/2012 +// Design Name: +// Module Name: Countdown +// Project Name: +// Target Devices: +// Tool versions: +// Description: +// +// Dependencies: +// +// Revision: +// Revision 0.01 - File Created +// Additional Comments: +// +////////////////////////////////////////////////////////////////////////////////// +module Countdown( + input clk_1hz, + input rst, + input start, + input [7:0] init, + output [7:0] t + ); + +reg [7:0] t; +reg running = 0; + +always @(init) begin + if (!running) begin + t = init; + end else begin + t = t; + end +end + +always @(posedge clk_1hz) begin + if (running) begin + t <= t - 1; + end else begin + t <= init; + end +end + +always @(posedge start) begin + running = 1; +end + +always @(rst) begin + running = 0; + t = 0; +end + +endmodule -- cgit v1.2.3