/*!
* Module:frame_num_sync
* @file frame_num_sync.v
* @date 2016-04-28
* @author Andrey Filippov
*
* @brief Propagating frame number from acquisition to compressor output
*
* @copyright Copyright (c) 2016 Elphel, Inc .
*
* License:
*
* frame_num_sync.v is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* frame_num_sync.v is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
`timescale 1ns/1ps
module frame_num_sync #(
parameter NUM_FRAME_BITS = 4,
parameter LAST_FRAME_BITS = 16,
parameter FRAME_BITS_KEEP = 4 // number of bits from mcntrl frame number used to index absolute sensor frame number
)(
// SuppressWarnings VEditor unused
input mrst,
input mclk, // for command/status
input [NUM_FRAME_BITS*4-1:0] absolute_frames, // per-channel current sensor frame number
input [3:0] first_wr_in_frame, // sensor writes first block in a frame
// input [3:0] first_rd_in_frame, // compressor gets first block in a frame
input [4*LAST_FRAME_BITS-1:0] memory_frames_sensor, // 4 channels of frame numbers as defined for memory allocation
input [4*LAST_FRAME_BITS-1:0] memory_frames_compressor, // 4 channels of frame numbers as defined for memory allocation, valid after compression (before done)
output reg [NUM_FRAME_BITS*4-1:0] compressed_frames // frame numbers valid at compressor done (TODO: keep until IRQ cleared? pointers will change anyway)
);
reg [NUM_FRAME_BITS-1:0] frames_ram0[0: (1<