summaryrefslogtreecommitdiff
path: root/part_2/ex9/divider_2500.v
blob: 305b2b6853ca37435416dfd5b9605b1f6f963508 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
`timescale 1ns / 100ps


module divider_2500 (
		clock,
		clock_ms, 
		out
		);
		
		parameter BIT_SZ = 12;
		input clock;
		input clock_ms;
		reg [BIT_SZ-1:0] count;
		
		initial count = 0;
		
		output reg out;
		
		
		always @ (posedge clock)
		begin
			if (clock_ms)
			begin
			if (count < 12'd499)
				begin
				count <= count + 1'b1;
				out <= 1'b0;
				end
			else
				begin
				out <= 1'b1;
				count <= 1'b0;		
				end
			end
		end
endmodule