-
Notifications
You must be signed in to change notification settings - Fork 0
/
COUNT.v
101 lines (95 loc) · 2.52 KB
/
COUNT.v
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 2017/07/11 09:48:33
// Design Name:
// Module Name: COUNT
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module COUNT(
input [31:0]data_in,
output reg [31:0]data_out=0
);
integer i;
always @(*)
begin
if(data_in[31]==1)
data_out<=0;
else if(data_in[31:30]==1)
data_out<=1;
else if(data_in[31:29]==1)
data_out<=2;
else if(data_in[31:28]==1)
data_out<=3;
else if(data_in[31:27]==1)
data_out<=4;
else if(data_in[31:26]==1)
data_out<=5;
else if(data_in[31:25]==1)
data_out<=6;
else if(data_in[31:24]==1)
data_out<=7;
else if(data_in[31:23]==1)
data_out<=8;
else if(data_in[31:22]==1)
data_out<=9;
else if(data_in[31:21]==1)
data_out<=10;
else if(data_in[31:20]==1)
data_out<=11;
else if(data_in[31:19]==1)
data_out<=12;
else if(data_in[31:18]==1)
data_out<=13;
else if(data_in[31:17]==1)
data_out<=14;
else if(data_in[31:16]==1)
data_out<=15;
else if(data_in[31:15]==1)
data_out<=16;
else if(data_in[31:14]==1)
data_out<=17;
else if(data_in[31:13]==1)
data_out<=18;
else if(data_in[31:12]==1)
data_out<=19;
else if(data_in[31:11]==1)
data_out<=20;
else if(data_in[31:10]==1)
data_out<=21;
else if(data_in[31:9]==1)
data_out<=22;
else if(data_in[31:8]==1)
data_out<=23;
else if(data_in[31:7]==1)
data_out<=24;
else if(data_in[31:6]==1)
data_out<=25;
else if(data_in[31:5]==1)
data_out<=26;
else if(data_in[31:4]==1)
data_out<=27;
else if(data_in[31:3]==1)
data_out<=28;
else if(data_in[31:2]==1)
data_out<=29;
else if(data_in[31:1]==1)
data_out<=30;
else if(data_in[31:0]==1)
data_out<=31;
else
data_out<=32;
end
endmodule