OpenCores
URL https://opencores.org/ocsvn/hamming/hamming/trunk

Subversion Repositories hamming

[/] [hamming/] [trunk/] [ham_7_4_dec.v] - Blame information for rev 15

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 soneryesil
///
2
module ham_7_4_dec(
3
 
4
clk,
5
reset,
6
datain,
7
dvin,
8
dvout,
9
code);
10
 
11
input clk, reset, datain, dvin;
12
output dvout;
13
reg dvout;
14
output code;
15
reg code;
16
 
17
 
18
 
19
reg [6:0]
20
datareg;
21
reg [6:0]
22
outdatareg;
23
 
24
 
25
reg [2:0]
26
cntr,
27
ocntr,
28
scntr;
29
 
30
reg [2:0]
31
s_;
32
 
33
reg ocntr_en;
34
 
35
wire
36
and2,
37
and1,
38
and0,
39
xor2,
40
xor1,
41
xor0,
42
err;
43
 
44
assign and2 = datareg[0] & cntr[2];
45
assign and1 = datareg[0] & cntr[1];
46
assign and0 = datareg[0] & cntr[0];
47
 
48
assign xor2 = and2 ^ s_[2];
49
assign xor1 = and1 ^ s_[1];
50
assign xor0 = and0 ^ s_[0];
51
 
52
assign err = (!scntr[2])&(!scntr[1])&scntr[0];
53
 
54
/////////////////////////////////////////////////
55
 
56
 
57
always@(posedge clk or negedge reset)
58
 
59
if (!reset)
60
 
61
s_<=0;
62
 
63
else if (cntr==0)
64
 
65
s_<=0;
66
 
67
else if ( (!dvin)||(cntr==7) )
68
 
69
s_<={xor2,xor1,xor0};
70
 
71
/////////////////////////////////////////////////
72
always@(posedge clk or negedge reset)
73
 
74
if (!reset)
75
 
76
scntr<=0;
77
 
78
else if (cntr==7)
79
 
80
scntr<={xor2, xor1, xor0};
81
 
82
else if (scntr!=0)
83
 
84
scntr<=scntr-1;
85
 
86
/////////////////////////////////////////////////
87
 
88
always@(posedge clk or negedge reset)
89
 
90
if (!reset)
91
 
92
cntr<=0;
93
 
94
else if (cntr==7)
95
 
96
cntr<=0;
97
 
98
else if (!dvin)
99
 
100
cntr<=cntr+1;
101
 
102
/////////////////////////////////////////////////
103
 
104
always@(posedge clk or negedge reset)
105
 
106
if(!reset)
107
 
108
datareg<=0;
109
 
110
else if (!dvin)
111
 
112
datareg<={datareg[5:0], datain};
113
 
114
 
115
/////////////////////////////////////////////////
116
always@(posedge clk or negedge reset)
117
 
118
if (!reset)
119
 
120
ocntr<=0;
121
 
122
else if (ocntr_en)
123
 
124
ocntr<=ocntr+1;
125
 
126
 
127
/////////////////////////////////////////////////
128
always@(posedge clk or negedge reset)
129
 
130
if (!reset)
131
 
132
ocntr_en<=0;
133
 
134
else if (cntr==7)
135
 
136
ocntr_en<=1;
137
 
138
else if ( (ocntr==7)&&(cntr!=7) )
139
 
140
ocntr_en<=0;
141
 
142
/////////////////////////////////////////////////
143
 
144
always@(posedge clk or negedge reset)
145
 
146
if (!reset)
147
 
148
dvout<=1;
149
 
150
else if (ocntr==7)
151
 
152
dvout<=1;
153
 
154
else if (ocntr_en)
155
 
156
dvout<=0;
157
 
158
 
159
/////////////////////////////////////////////////
160
always@(posedge clk or negedge reset)
161
 
162
if (!reset)
163
 
164
outdatareg<=0;
165
 
166
else if (cntr==7)
167
 
168
outdatareg<=datareg;
169
 
170
else if (ocntr_en)
171
 
172
outdatareg<={outdatareg[5:0],1'b0};
173
 
174
/////////////////////////////////////////////////
175
always@(posedge clk or negedge reset)
176
 
177
if (!reset)
178
 
179
code<=0;
180
 
181
else
182
 
183
code<=outdatareg[6]^err;
184
 
185
/////////////////////////////////////////////////
186
 
187
 
188
endmodule
189
 
190
 
191
 
192
 
193
 
194
 
195
 
196
 
197
 
198
 
199
 
200
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.