summaryrefslogtreecommitdiff
path: root/part_2/ex9/divider_2500.v
blob: f4322b7d481380e942a61d8e555f505204d62260 (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'd500)
				begin
				count <= count + 1'b1;
				out <= 1'b0;
				end
			else
				begin
				out <= 1'b1;
				count <= 1'b0;		
				end
			end
		end
endmodule