summaryrefslogtreecommitdiff
path: root/tests/sat/counters.v
blob: 09e273044980bc4a5ecc9aff634ef48c98065a48 (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
module counter1(clk, rst, ping);
	input clk, rst;
	output ping;
	reg [31:0] count;

	always @(posedge clk) begin
		if (rst)
			count <= 0;
		else
			count <= count + 1;
	end

	assign ping = &count;
endmodule

module counter2(clk, rst, ping);
	input clk, rst;
	output ping;
	reg [31:0] count;

	integer i;
	reg carry;

	always @(posedge clk) begin
		carry = 1;
		for (i = 0; i < 32; i = i+1) begin
			count[i] <= !rst & (count[i] ^ carry);
			carry = count[i] & carry;
		end
	end

	assign ping = &count;
endmodule