isp_bin is the binning of OpenISP: it divides the image into bins of BinX_g x BinY_g pixels and outputs the sum
of the pixels of every bin as one pixel. The output image is smaller by the two factors, and its pixels are wider by
the bits that the sum needs. An average is the sum scaled by an isp_point behind the module.
The module is a configuration of the general 2D window filter and adds no logic of its own: a first
isp_filter2d adds BinX_g pixels along the line, a second one adds
BinY_g lines of the narrowed image. Both have coefficients of 1, a window of the size of the factor and a stride
of the same size, so their windows tile the image. An incomplete bin at the right or the lower edge is dropped or
completed, as the border mode says.
ImageWidth_g, ImageHeight_g: dimensions of the input image.
Bin (n, m)
The pixels p'(n x BinX_g + i, m x BinY_g + j) for i = 0 to BinX_g - 1 and j = 0 to BinY_g - 1; p' is the image extended by the border mode (isp_window, section 6).
Wo, Ho
Output image. Border mode valid: Wo = floor(W / BinX_g), Ho = floor(H / BinY_g), the complete bins. Border modes zero and replicate: Wo = ceil(W / BinX_g), Ho = ceil(H / BinY_g), every bin with at least one pixel of the image.
P, Q
Pixel widths: P = PixelBits_g at the input, Q = P + log2ceil(BinX_g x BinY_g) at the output.
The module shall take pixels of P bits on a pixel stream (In_Valid, In_Ready, In_Data, In_Last, In_User).
ISP-STR-01, ISP-STR-02
BIN-IF-02
The module shall output pixels of Q bits on a pixel stream (Out_Valid, Out_Ready, Out_Data, Out_Last, Out_User).
ISP-STR-01, ISP-STR-02
BIN-IF-03
The module shall output Err_Framing, Stat_ImageOpen, Stat_EccSec and Stat_EccDed as the OR of its two filters, and pass ErrInj_BitFlip and ErrInj_Valid to the line buffers of the second filter.
ISP-STR-08, ISP-STR-10, ISP-FT-01, ISP-FT-02
BIN-IF-04
The module shall have one clock Clk and a synchronous, high-active reset Rst.
For every bin (n, m) with n < Wo and m < Ho the module shall output the sum of the pixels of the bin as pixel (n, m) of the output image, without loss of precision.
ISP-BIN-01
BIN-FN-02
In the border mode valid an incomplete bin shall give no output pixel; in the border modes zero and replicate its missing pixels shall be 0 or the nearest pixel of the image.
ISP-BIN-02
BIN-FN-03
The output image shall have Wo x Ho pixels, as one stream packet per line with the sequence flags of the line.
ISP-STR-03, ISP-STR-05, ISP-STR-06
BIN-FN-04
The module shall consist of two isp_filter2d in series with the generics of section 4; a filter whose factor is 1 shall be left out, and with both factors 1 the module shall be an isp_frame_sync. The requirements of the parts on the input stream and on the completion of an image hold for the module.
With In_Valid and Out_Ready high, the module shall hold the input for at most BinX_g - 1 clock cycles between the acceptance of the first pixels of two consecutive lines of an image in the border modes zero and replicate, and for no clock cycle between the first and the last pixel of an image in the border mode valid; in the border modes zero and replicate the input of an image that follows an image also waits while the vertical filter generates the virtual lines of the image before, in total at most max(0, (BinY_g - 1) x Wo + 2 - 2 x BinX_g) clock cycles.
ISP-STR-09
BIN-PF-02
In the border mode valid the interval between the starts of two consecutive images shall not exceed H x W + 16 clock cycles; in the border modes zero and replicate it shall not exceed H x (W + BinX_g - 1) + (BinY_g - 1) x Wo + 16 clock cycles.
The partners of the input are those of isp_frame_sync. In the border modes zero and replicate the module holds the
input for BinX_g - 1 cycles after every line, and an image that follows an image waits while the vertical filter
generates the BinY_g - 1 virtual lines of Wo pixels of the image before, at most max(0, (BinY_g - 1) x Wo + 2 -
2 x BinX_g) cycles in total (BIN-PF-01); in the border mode valid it never holds the input. The consumer of the
output may hold Out_Ready low at any beat.
A generic outside its range of section 4 (also the border mode mirror) shall stop the elaboration with a message naming the generic.
ISP-CFG-01
BIN-CF-02
The module shall be synthesizable with GHDL for the bounds of every numeric generic and every border mode.
ISP-GEN-01
BIN-CF-03
The default configuration shall be designed for 125 MHz on Microchip PolarFire; synthesis results are recorded in the verification report. The target of 150 MHz on the AMD Versal device of the reference systems (ISP-GEN-04) is open.
The sum along the line first: the second filter then stores lines of the narrowed image, a BinX_g-th of the
line buffer that a window of BinX_g x BinY_g pixels would need.
The mirror mode is not offered: a bin has no middle pixel to reflect at.
Average: an isp_point behind the module with a shift of log2(BinX_g x BinY_g) for a bin of a power of two,
or with the gain round(2^k / (BinX_g x BinY_g)) and the shift k otherwise. In the border mode zero an
incomplete bin holds fewer pixels of the image, so its average is too low; replicate keeps the level.
The two filters have the AXI4-Lite slave of their kernel; with constant coefficients it holds only read-only
registers and is left unconnected.