x393
1.0
FPGAcodeforElphelNC393camera
dct1d_chen_reorder_out.v
Go to the documentation of this file.
1
39
`timescale 1ns/1ps
40
41
module
dct1d_chen_reorder_out
#(
42
parameter
WIDTH
=
24
43
)(
44
input
clk
,
45
input
rst
,
46
input
en
,
// sampled at timeslot of pre2_start
47
input
[
WIDTH
-
1
:
0
]
din
,
// pre2_start-X-F4-X-F2-X-F6-F5-F0-F3-X-F1-X-F7
48
input
pre2_start
,
// Two cycles ahead of F4
49
output
[
WIDTH
-
1
:
0
]
dout
,
// data in natural order: F0-F1-F2-F3-F4-F5-F6-F7
50
output
start_out
,
// 1 ahead of the first F0
51
output
reg
dv
,
// output data valid
52
output
en_out
// to be sampled when start_out is expected
53
);
54
reg
[
WIDTH
-
1
:
0
]
reord_buf_ram
[
0
:
15
];
55
reg
[
WIDTH
-
1
:
0
]
dout_r
;
56
reg
[
3
:
0
]
cntr_in
;
57
reg
pre_we_r
;
58
reg
we_r
;
59
reg
[
3
:
0
]
ina_rom
;
60
wire
[
3
:
0
]
waddr
= {
ina_rom
[
3
] ^
cntr_in
[
3
],
ina_rom
[
2
:
0
]};
61
reg
[
3
:
0
]
raddr
;
62
reg
[
2
:
0
]
per_type
;
// idle/last:0, first cycle - 1, 2-nd - 2, other - 3,... ~en->6 ->7 -> 0 (to generate pre2_start_out)
63
reg
start_out_r
;
64
reg
en_out_r
;
65
wire
stop_out
;
// qualify with en
66
assign
dout
=
dout_r
;
67
assign
start_out
=
start_out_r
;
68
assign
en_out
=
en_out_r
;
69
70
always
@(
posedge
clk
)
begin
71
if
(
rst
)
per_type
<=
0
;
72
else
if
(
pre2_start
)
per_type
<=
3'h1
;
73
else
if
(&
cntr_in
[
2
:
0
])
begin
74
if
(!
per_type
[
2
] && !
en
)
per_type
<=
3'h6
;
75
else
if
((
per_type
!=
0
) && (
per_type
!=
3
))
per_type
<=
per_type
+
1
;
76
end
77
78
if
(
rst
)
pre_we_r
<=
0
;
79
else
if
(
pre2_start
)
pre_we_r
<=
1
;
80
else
if
((
per_type
==
0
) || ((
cntr_in
==
3
) &&
per_type
[
2
]))
pre_we_r
<=
0
;
81
we_r
<=
pre_we_r
;
82
83
if
(
rst
)
cntr_in
<=
0
;
84
else
if
(
pre2_start
)
cntr_in
<= {~
cntr_in
[
3
],
3'b0
};
85
else
if
(
pre_we_r
)
cntr_in
<=
cntr_in
+
1
;
86
case
(
cntr_in
[
2
:
0
])
87
3'h0
:
ina_rom
<= {
1'b0
,
3'h4
};
88
3'h1
:
ina_rom
<= {
1'b1
,
3'h1
};
89
3'h2
:
ina_rom
<= {
1'b0
,
3'h2
};
90
3'h3
:
ina_rom
<= {
1'b1
,
3'h7
};
91
3'h4
:
ina_rom
<= {
1'b0
,
3'h6
};
92
3'h5
:
ina_rom
<= {
1'b0
,
3'h5
};
93
3'h6
:
ina_rom
<= {
1'b0
,
3'h0
};
94
3'h7
:
ina_rom
<= {
1'b1
,
3'h3
};
95
endcase
96
97
if
(
we_r
)
reord_buf_ram
[
waddr
] <=
din
;
98
99
if
((
per_type
==
2
) && (
cntr_in
==
1
))
raddr
<= {~
cntr_in
[
3
],
3'b0
};
100
else
if
((
raddr
[
2
:
0
] !=
0
) || (
per_type
!=
0
))
raddr
<=
raddr
+
1
;
101
102
if
(
en_out_r
)
dout_r
<=
reord_buf_ram
[
raddr
];
103
104
start_out_r
<= (
per_type
==
2
) && (
cntr_in
==
1
);
105
106
if
(
rst
||(
per_type
==
0
) )
en_out_r
<=
0
;
107
// else if (cntr_in == 1) en_out_r <= (per_type == 2) || !per_type[2];
108
else
if
((
cntr_in
==
1
) && (
per_type
==
2
))
en_out_r
<=
1
;
109
else
if
(
stop_out
&& !
en
)
en_out_r
<=
0
;
110
//stop_out
111
112
dv
<=
en_out_r
;
113
114
// if (rst) dv <= 0;
115
// else if (start_out_r) dv <= 1;
116
// else if ((raddr[2:0] == 0) && !en_out_r) dv <= 0;
117
end
118
119
dly01_16
dly01_16_i
(
120
.
clk
(
clk
),
// input
121
.
rst
(
rst
),
// input
122
.
dly
(
4'd8
),
// input[3:0]
123
.
din
((&
cntr_in
[
2
:
0
]) && !
en
),
// input
124
.
dout
(
stop_out
)
// output
125
);
126
127
endmodule
128
dct1d_chen_reorder_out.3258ina_rom
3258ina_romreg[3:0]
Definition:
dct1d_chen_reorder_out.v:59
dct1d_chen_reorder_out.3251dv
reg 3251dv
Definition:
dct1d_chen_reorder_out.v:51
dly01_16.10329dout
10329dout
Definition:
dly01_16.v:46
dly01_16.10327dly
[3:0] 10327dly
Definition:
dly01_16.v:44
dct1d_chen_reorder_out.3264stop_out
3264stop_outwire
Definition:
dct1d_chen_reorder_out.v:65
dct1d_chen_reorder_out.3247din
[WIDTH -1:0] 3247din
Definition:
dct1d_chen_reorder_out.v:47
dct1d_chen_reorder_out
Definition:
dct1d_chen_reorder_out.v:41
dct1d_chen_reorder_out.3245rst
3245rst
Definition:
dct1d_chen_reorder_out.v:45
dct1d_chen_reorder_out.3250start_out
3250start_out
Definition:
dct1d_chen_reorder_out.v:50
dct1d_chen_reorder_out.3262start_out_r
3262start_out_rreg
Definition:
dct1d_chen_reorder_out.v:63
dct1d_chen_reorder_out.3256pre_we_r
3256pre_we_rreg
Definition:
dct1d_chen_reorder_out.v:57
dct1d_chen_reorder_out.3254dout_r
3254dout_rreg[WIDTH-1:0]
Definition:
dct1d_chen_reorder_out.v:55
dct1d_chen_reorder_out.3260raddr
3260raddrreg[3:0]
Definition:
dct1d_chen_reorder_out.v:61
dct1d_chen_reorder_out.3263en_out_r
3263en_out_rreg
Definition:
dct1d_chen_reorder_out.v:64
dly01_16.10326rst
10326rst
Definition:
dly01_16.v:43
dct1d_chen_reorder_out.dly01_16
dly01_16_i dly01_16
Definition:
dct1d_chen_reorder_out.v:119
dct1d_chen_reorder_out.3248pre2_start
3248pre2_start
Definition:
dct1d_chen_reorder_out.v:48
dct1d_chen_reorder_out.3255cntr_in
3255cntr_inreg[3:0]
Definition:
dct1d_chen_reorder_out.v:56
dct1d_chen_reorder_out.3243WIDTH
3243WIDTH24
Definition:
dct1d_chen_reorder_out.v:42
dct1d_chen_reorder_out.3249dout
[WIDTH -1:0] 3249dout
Definition:
dct1d_chen_reorder_out.v:49
dct1d_chen_reorder_out.3252en_out
3252en_out
Definition:
dct1d_chen_reorder_out.v:52
dct1d_chen_reorder_out.3246en
3246en
Definition:
dct1d_chen_reorder_out.v:46
dct1d_chen_reorder_out.3257we_r
3257we_rreg
Definition:
dct1d_chen_reorder_out.v:58
dct1d_chen_reorder_out.3253reord_buf_ram
[0:15] 3253reord_buf_ramreg[WIDTH-1:0]
Definition:
dct1d_chen_reorder_out.v:54
dct1d_chen_reorder_out.3244clk
3244clk
Definition:
dct1d_chen_reorder_out.v:44
dct1d_chen_reorder_out.3259waddr
3259waddrwire[3:0]
Definition:
dct1d_chen_reorder_out.v:60
dly01_16.10325clk
10325clk
Definition:
dly01_16.v:42
dct1d_chen_reorder_out.3261per_type
3261per_typereg[2:0]
Definition:
dct1d_chen_reorder_out.v:62
dly01_16.10328din
10328din
Definition:
dly01_16.v:45
dsp
dct1d_chen_reorder_out.v
Generated by
1.8.12