diff options
author | Michael Abed <michaelabed@gmail.com> | 2012-03-21 13:17:47 -0400 |
---|---|---|
committer | Michael Abed <michaelabed@gmail.com> | 2012-03-21 13:17:47 -0400 |
commit | 2ac48fa0e44016a6cb49cab84a154eb7ec2dcab4 (patch) | |
tree | 9819721233275cee6e39483867818a54299a4fc1 /Countdown.v | |
download | ec311-lab4-2ac48fa0e44016a6cb49cab84a154eb7ec2dcab4.tar.gz ec311-lab4-2ac48fa0e44016a6cb49cab84a154eb7ec2dcab4.tar.bz2 ec311-lab4-2ac48fa0e44016a6cb49cab84a154eb7ec2dcab4.zip |
Initial Commit
Diffstat (limited to 'Countdown.v')
-rw-r--r-- | Countdown.v | 57 |
1 files changed, 57 insertions, 0 deletions
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 |