Commit fe0f5941 authored by Andrey Filippov's avatar Andrey Filippov

Made separate control for sesnort histograms, channel enable and bit width

parent 35cce7c8
...@@ -355,11 +355,14 @@ ...@@ -355,11 +355,14 @@
parameter SENSOR_CTRL_RADDR = 0, // relative to SENSOR_GROUP_ADDR parameter SENSOR_CTRL_RADDR = 0, // relative to SENSOR_GROUP_ADDR
parameter SENSOR_CTRL_ADDR_MASK = 'h7ff, // parameter SENSOR_CTRL_ADDR_MASK = 'h7ff, //
// bits of the SENSOR mode register // bits of the SENSOR mode register
parameter SENSOR_MODE_WIDTH = 10, parameter SENSOR_HIST_EN_BITS = 0, // 0..3 1 - enable histogram modules, disable after processing the started frame
parameter SENSOR_HIST_EN_BITS = 0, // 0..3 1 - enable histogram modules, disable after processing the started frame parameter SENSOR_HIST_NRST_BITS = 4, // 0 - immediately reset all histogram modules
parameter SENSOR_HIST_NRST_BITS = 4, // 0 - immediately reset all histogram modules parameter SENSOR_HIST_BITS_SET = 8, // 1 - set bits 0..7 (en and nrst)
parameter SENSOR_CHN_EN_BIT = 8, // 1 - this enable channel parameter SENSOR_CHN_EN_BIT = 9, // 1 - this enable channel
parameter SENSOR_16BIT_BIT = 9, // 0 - 8 bpp mode, 1 - 16 bpp (bypass gamma). Gamma-processed data is still used for histograms parameter SENSOR_CHN_EN_BIT_SET = 10, // set SENSOR_CHN_EN_BIT bit
parameter SENSOR_16BIT_BIT = 11, // 0 - 8 bpp mode, 1 - 16 bpp (bypass gamma). Gamma-processed data is still used for histograms
parameter SENSOR_16BIT_BIT_SET = 12, // set 8/16 bit mode
// parameter SENSOR_MODE_WIDTH = 13,
parameter SENSI2C_CTRL_RADDR = 2, // 302..'h303 parameter SENSI2C_CTRL_RADDR = 2, // 302..'h303
parameter SENSI2C_CTRL_MASK = 'h7fe, parameter SENSI2C_CTRL_MASK = 'h7fe,
......
...@@ -244,7 +244,7 @@ module mcntrl_tiled_rw#( ...@@ -244,7 +244,7 @@ module mcntrl_tiled_rw#(
reg [4:0] frame_start_r; // increased length to have time from line_unfinished to suspend (external) reg [4:0] frame_start_r; // increased length to have time from line_unfinished to suspend (external)
// reg rst_frame_num_d; // reg rst_frame_num_d;
reg [MAX_TILE_WIDTH:0] tile_cols; // full number of columns in a tile reg [MAX_TILE_WIDTH:0] tile_cols; // full number of columns in a tile (in bursts?)
// reg [MAX_TILE_HEIGHT:0] tile_rows; // full number of rows in a tile // reg [MAX_TILE_HEIGHT:0] tile_rows; // full number of rows in a tile
// reg [MAX_TILE_HEIGHT-1:0] tile_rows; // full number of rows in a tile // reg [MAX_TILE_HEIGHT-1:0] tile_rows; // full number of rows in a tile
reg [MAX_TILE_HEIGHT:0] tile_rows; // full number of rows in a tile reg [MAX_TILE_HEIGHT:0] tile_rows; // full number of rows in a tile
......
...@@ -128,6 +128,7 @@ CLK_STATUS_REG_ADDR__TYPE = str ...@@ -128,6 +128,7 @@ CLK_STATUS_REG_ADDR__TYPE = str
MCONTR_TOP_16BIT_STATUS_CNTRL__TYPE = str MCONTR_TOP_16BIT_STATUS_CNTRL__TYPE = str
HIST_SAXI_ADDR_MASK = int HIST_SAXI_ADDR_MASK = int
CONTROL_RBACK_ADDR_MASK = int CONTROL_RBACK_ADDR_MASK = int
SENSOR_CHN_EN_BIT_SET__RAW = str
CMPRS_CBIT_QBANK__TYPE = str CMPRS_CBIT_QBANK__TYPE = str
CLKOUT_DIV_PCLK__RAW = str CLKOUT_DIV_PCLK__RAW = str
SENS_GAMMA_CTRL__RAW = str SENS_GAMMA_CTRL__RAW = str
...@@ -313,7 +314,7 @@ MULTICLK_MULT = int ...@@ -313,7 +314,7 @@ MULTICLK_MULT = int
SENS_LENS_POST_SCALE_MASK = int SENS_LENS_POST_SCALE_MASK = int
MEMCLK_PERIOD = float MEMCLK_PERIOD = float
BUF_IPCLK2X_SENS1__RAW = str BUF_IPCLK2X_SENS1__RAW = str
SENSOR_MODE_WIDTH__RAW = str HISTOGRAM_WIDTH__RAW = str
SENS_LENS_FAT0_OUT_MASK = int SENS_LENS_FAT0_OUT_MASK = int
SENS_SYNC_MULT__TYPE = str SENS_SYNC_MULT__TYPE = str
NUM_CYCLES_27__RAW = str NUM_CYCLES_27__RAW = str
...@@ -439,7 +440,7 @@ MULT_SAXI_CNTRL_STATUS__TYPE = str ...@@ -439,7 +440,7 @@ MULT_SAXI_CNTRL_STATUS__TYPE = str
CMPRS_FRMT_MBRM1_BITS__RAW = str CMPRS_FRMT_MBRM1_BITS__RAW = str
SCANLINE_EXTRA_PAGES = int SCANLINE_EXTRA_PAGES = int
LD_DLY_LANE1_ODELAY__RAW = str LD_DLY_LANE1_ODELAY__RAW = str
LOGGER_CONF_EN_BITS__RAW = str SENSOR_CHN_EN_BIT_SET__TYPE = str
SENS_CTRL_IGNORE_EMBED__TYPE = str SENS_CTRL_IGNORE_EMBED__TYPE = str
SENS_LENS_FAT0_IN_MASK__TYPE = str SENS_LENS_FAT0_IN_MASK__TYPE = str
RSEL = int RSEL = int
...@@ -561,6 +562,7 @@ SENSOR_FIFO_DELAY__RAW = str ...@@ -561,6 +562,7 @@ SENSOR_FIFO_DELAY__RAW = str
DLY_SET = int DLY_SET = int
CMDFRAMESEQ_CTRL__TYPE = str CMDFRAMESEQ_CTRL__TYPE = str
HISPI_FIFO_DEPTH__RAW = str HISPI_FIFO_DEPTH__RAW = str
SENSOR_HIST_BITS_SET__RAW = str
NUM_CYCLES_12 = int NUM_CYCLES_12 = int
MCNTRL_SCANLINE_FRAME_PAGE_RESET__TYPE = str MCNTRL_SCANLINE_FRAME_PAGE_RESET__TYPE = str
MCNTRL_TILED_CHN2_ADDR__TYPE = str MCNTRL_TILED_CHN2_ADDR__TYPE = str
...@@ -591,6 +593,7 @@ NUM_CYCLES_16 = int ...@@ -591,6 +593,7 @@ NUM_CYCLES_16 = int
NUM_CYCLES_15 = int NUM_CYCLES_15 = int
NUM_CYCLES_21__TYPE = str NUM_CYCLES_21__TYPE = str
CMPRS_CBIT_BAYER = int CMPRS_CBIT_BAYER = int
LOGGER_CONF_EN_BITS__RAW = str
SLEW_CLK__TYPE = str SLEW_CLK__TYPE = str
MCONTR_PHY_0BIT_DLY_SET = int MCONTR_PHY_0BIT_DLY_SET = int
HISPI_DIFF_TERM__TYPE = str HISPI_DIFF_TERM__TYPE = str
...@@ -631,6 +634,7 @@ RTC_ADDR = int ...@@ -631,6 +634,7 @@ RTC_ADDR = int
MCLK_PHASE__RAW = str MCLK_PHASE__RAW = str
SENSIO_RADDR__TYPE = str SENSIO_RADDR__TYPE = str
CLKFBOUT_MULT_PCLK__TYPE = str CLKFBOUT_MULT_PCLK__TYPE = str
VERBOSE__TYPE = str
CLK_ADDR__TYPE = str CLK_ADDR__TYPE = str
CMPRS_FORMAT = int CMPRS_FORMAT = int
SENSIO_STATUS_REG_REL = int SENSIO_STATUS_REG_REL = int
...@@ -999,7 +1003,7 @@ HISTOGRAM_ADDR_MASK = int ...@@ -999,7 +1003,7 @@ HISTOGRAM_ADDR_MASK = int
MCONTR_BUF2_RD_ADDR__RAW = str MCONTR_BUF2_RD_ADDR__RAW = str
MCONTR_TOP_16BIT_ADDR_MASK__RAW = str MCONTR_TOP_16BIT_ADDR_MASK__RAW = str
MULTICLK_DIV_DLYREF__RAW = str MULTICLK_DIV_DLYREF__RAW = str
VERBOSE__TYPE = str MCNTRL_PS_EN_RST__RAW = str
BUF_CLK1X_PCLK__TYPE = str BUF_CLK1X_PCLK__TYPE = str
MULT_SAXI_BSLOG1__RAW = str MULT_SAXI_BSLOG1__RAW = str
CLKFBOUT_MULT_PCLK__RAW = str CLKFBOUT_MULT_PCLK__RAW = str
...@@ -1227,7 +1231,6 @@ PXD_IBUF_LOW_PWR__RAW = str ...@@ -1227,7 +1231,6 @@ PXD_IBUF_LOW_PWR__RAW = str
PXD_DRIVE = int PXD_DRIVE = int
MULT_SAXI_BSLOG2__RAW = str MULT_SAXI_BSLOG2__RAW = str
CLK_CNTRL__TYPE = str CLK_CNTRL__TYPE = str
HISTOGRAM_WIDTH__RAW = str
GPIO_MASK__RAW = str GPIO_MASK__RAW = str
DFLT_REFRESH_ADDR__TYPE = str DFLT_REFRESH_ADDR__TYPE = str
SENS_GAMMA_MODE_REPET__TYPE = str SENS_GAMMA_MODE_REPET__TYPE = str
...@@ -1298,7 +1301,6 @@ FFCLK1_IOSTANDARD__RAW = str ...@@ -1298,7 +1301,6 @@ FFCLK1_IOSTANDARD__RAW = str
CMD_DONE_BIT__TYPE = str CMD_DONE_BIT__TYPE = str
SENSOR_DATA_WIDTH__TYPE = str SENSOR_DATA_WIDTH__TYPE = str
SENS_LENS_SCALES__RAW = str SENS_LENS_SCALES__RAW = str
SENSOR_MODE_WIDTH = int
RTC_BITC_PREDIV__RAW = str RTC_BITC_PREDIV__RAW = str
CMPRS_CORING_BITS__TYPE = str CMPRS_CORING_BITS__TYPE = str
STATUS_DEPTH__TYPE = str STATUS_DEPTH__TYPE = str
...@@ -1531,7 +1533,6 @@ MULT_SAXI_IRQLEN_MASK__TYPE = str ...@@ -1531,7 +1533,6 @@ MULT_SAXI_IRQLEN_MASK__TYPE = str
PICKLE__TYPE = str PICKLE__TYPE = str
SENSI2C_TBL_NBWR__RAW = str SENSI2C_TBL_NBWR__RAW = str
TABLE_FOCUS_INDEX__RAW = str TABLE_FOCUS_INDEX__RAW = str
SENSOR_MODE_WIDTH__TYPE = str
MCONTR_LINTILE_WRITE__RAW = str MCONTR_LINTILE_WRITE__RAW = str
MCNTRL_TILED_CHN2_ADDR__RAW = str MCNTRL_TILED_CHN2_ADDR__RAW = str
CMPRS_CONTROL_REG__TYPE = str CMPRS_CONTROL_REG__TYPE = str
...@@ -1678,6 +1679,7 @@ HIST_SAXI_MODE_ADDR_MASK__RAW = str ...@@ -1678,6 +1679,7 @@ HIST_SAXI_MODE_ADDR_MASK__RAW = str
FFCLK1_IBUF_LOW_PWR__TYPE = str FFCLK1_IBUF_LOW_PWR__TYPE = str
SENSOR12BITS_NVLO__TYPE = str SENSOR12BITS_NVLO__TYPE = str
MCONTR_LINTILE_EXTRAPG__TYPE = str MCONTR_LINTILE_EXTRAPG__TYPE = str
CAMSYNC_SNDEN_BIT__TYPE = str
NUM_CYCLES_06__TYPE = str NUM_CYCLES_06__TYPE = str
SCANLINE_STARTX__RAW = str SCANLINE_STARTX__RAW = str
SLEW_DQS__RAW = str SLEW_DQS__RAW = str
...@@ -1695,6 +1697,7 @@ CLK_PHASE__TYPE = str ...@@ -1695,6 +1697,7 @@ CLK_PHASE__TYPE = str
SENSOR_16BIT_BIT = int SENSOR_16BIT_BIT = int
SENSIO_DELAYS__TYPE = str SENSIO_DELAYS__TYPE = str
SENS_CTRL_EXT_CLK__RAW = str SENS_CTRL_EXT_CLK__RAW = str
SENSOR_CHN_EN_BIT_SET = int
WOI_HEIGHT = int WOI_HEIGHT = int
LOGGER_PAGE_GPS__TYPE = str LOGGER_PAGE_GPS__TYPE = str
T_REFI = int T_REFI = int
...@@ -1721,7 +1724,7 @@ SENSI2C_CMD_SOFT_SDA = int ...@@ -1721,7 +1724,7 @@ SENSI2C_CMD_SOFT_SDA = int
SENSI2C_CMD_TAND = int SENSI2C_CMD_TAND = int
CMPRS_AFIMUX_SA_LEN = int CMPRS_AFIMUX_SA_LEN = int
SENS_CTRL_QUADRANTS_EN__TYPE = str SENS_CTRL_QUADRANTS_EN__TYPE = str
MCNTRL_PS_EN_RST__RAW = str SENSOR_16BIT_BIT_SET__RAW = str
HISPI_IFD_DELAY_VALUE__TYPE = str HISPI_IFD_DELAY_VALUE__TYPE = str
CMPRS_CBIT_BAYER_BITS__RAW = str CMPRS_CBIT_BAYER_BITS__RAW = str
MULTICLK_BUF_AXIHP__TYPE = str MULTICLK_BUF_AXIHP__TYPE = str
...@@ -1816,6 +1819,7 @@ MCONTR_PHY_16BIT_ADDR__RAW = str ...@@ -1816,6 +1819,7 @@ MCONTR_PHY_16BIT_ADDR__RAW = str
SENS_CTRL_MRST__RAW = str SENS_CTRL_MRST__RAW = str
SENS_GAMMA_HEIGHT2__TYPE = str SENS_GAMMA_HEIGHT2__TYPE = str
IPCLK2X_PHASE__TYPE = str IPCLK2X_PHASE__TYPE = str
SENSOR_HIST_BITS_SET = int
MCNTRL_SCANLINE_CHN1_ADDR = int MCNTRL_SCANLINE_CHN1_ADDR = int
MULT_SAXI_HALF_BRAM_IN = int MULT_SAXI_HALF_BRAM_IN = int
CMDFRAMESEQ_ADDR_INC__RAW = str CMDFRAMESEQ_ADDR_INC__RAW = str
...@@ -1835,7 +1839,7 @@ CMPRS_GROUP_ADDR__RAW = str ...@@ -1835,7 +1839,7 @@ CMPRS_GROUP_ADDR__RAW = str
SENS_LENS_AX__RAW = str SENS_LENS_AX__RAW = str
CMPRS_JP4DIFF__RAW = str CMPRS_JP4DIFF__RAW = str
SENS_SS_MODE__RAW = str SENS_SS_MODE__RAW = str
CAMSYNC_SNDEN_BIT__TYPE = str SENSOR_16BIT_BIT_SET__TYPE = str
DEBUG_CMD_LATENCY__RAW = str DEBUG_CMD_LATENCY__RAW = str
CMPRS_CBIT_CMODE__TYPE = str CMPRS_CBIT_CMODE__TYPE = str
LOGGER_STATUS_MASK = int LOGGER_STATUS_MASK = int
...@@ -2080,6 +2084,7 @@ CMPRS_MONO16 = int ...@@ -2080,6 +2084,7 @@ CMPRS_MONO16 = int
REF_JITTER1 = float REF_JITTER1 = float
SENSI2C_TBL_DLY = int SENSI2C_TBL_DLY = int
SENSIO_STATUS__RAW = str SENSIO_STATUS__RAW = str
SENSOR_16BIT_BIT_SET = int
MCONTR_LINTILE_DIS_NEED = int MCONTR_LINTILE_DIS_NEED = int
SENS_LENS_BX_MASK = int SENS_LENS_BX_MASK = int
HISPI_FIFO_START__RAW = str HISPI_FIFO_START__RAW = str
...@@ -2150,6 +2155,7 @@ MCONTR_PHY_0BIT_DLY_SET__RAW = str ...@@ -2150,6 +2155,7 @@ MCONTR_PHY_0BIT_DLY_SET__RAW = str
NUM_CYCLES_11__RAW = str NUM_CYCLES_11__RAW = str
FFCLK1_CAPACITANCE__RAW = str FFCLK1_CAPACITANCE__RAW = str
SENSI2C_DRIVE__RAW = str SENSI2C_DRIVE__RAW = str
SENSOR_HIST_BITS_SET__TYPE = str
CMPRS_CBIT_CMODE_MONO1__TYPE = str CMPRS_CBIT_CMODE_MONO1__TYPE = str
SENS_LENS_C = int SENS_LENS_C = int
SENSOR_CTRL_ADDR_MASK__RAW = str SENSOR_CTRL_ADDR_MASK__RAW = str
......
...@@ -147,7 +147,7 @@ class X393ExportC(object): ...@@ -147,7 +147,7 @@ class X393ExportC(object):
txt += ' #define PARS_FRAMES 16 ///< Number of frames in a sequencer TODO:// move it here from <elphel/c313a.h>\n' txt += ' #define PARS_FRAMES 16 ///< Number of frames in a sequencer TODO:// move it here from <elphel/c313a.h>\n'
txt += ' #define PARS_FRAMES_MASK (PARS_FRAMES-1) ///< Maximal frame number (15 for NC393) TODO:// move it here from <elphel/c313a.h>\n' txt += ' #define PARS_FRAMES_MASK (PARS_FRAMES-1) ///< Maximal frame number (15 for NC393) TODO:// move it here from <elphel/c313a.h>\n'
txt += '#endif\n' txt += '#endif\n'
txt += 'typedef enum {DIRECT,ABSOLUTE,RELATIVE} x393cmd_t; ///< How to apply command - directly or through the command sequencer\n' txt += 'typedef enum {DIRECT,ABSOLUTE,RELATIVE,ASAP} x393cmd_t; ///< How to apply command - directly or through the command sequencer\n'
txt += """// IRQ commands applicable to several targets txt += """// IRQ commands applicable to several targets
#define X393_IRQ_NOP 0 #define X393_IRQ_NOP 0
#define X393_IRQ_RESET 1 #define X393_IRQ_RESET 1
...@@ -935,7 +935,6 @@ class X393ExportC(object): ...@@ -935,7 +935,6 @@ class X393ExportC(object):
(("X393_CMPRS_CBIT_CMODE_JP4DIFFHDRDIV2","",vrlg.CMPRS_CBIT_CMODE_JP4DIFFHDRDIV2,0,None, None, "", "jp4, 4 blocks, differential, hdr,divide by 2")), (("X393_CMPRS_CBIT_CMODE_JP4DIFFHDRDIV2","",vrlg.CMPRS_CBIT_CMODE_JP4DIFFHDRDIV2,0,None, None, "", "jp4, 4 blocks, differential, hdr,divide by 2")),
(("X393_CMPRS_CBIT_CMODE_MONO1", "", vrlg.CMPRS_CBIT_CMODE_MONO1 , 0, None, None, "", "Mono JPEG (not yet implemented)")), (("X393_CMPRS_CBIT_CMODE_MONO1", "", vrlg.CMPRS_CBIT_CMODE_MONO1 , 0, None, None, "", "Mono JPEG (not yet implemented)")),
(("X393_CMPRS_CBIT_CMODE_MONO4", "", vrlg.CMPRS_CBIT_CMODE_MONO4 , 0, None, None, "", "Mono, 4 blocks (2x2 macroblocks)")), (("X393_CMPRS_CBIT_CMODE_MONO4", "", vrlg.CMPRS_CBIT_CMODE_MONO4 , 0, None, None, "", "Mono, 4 blocks (2x2 macroblocks)")),
(("X393_CMPRS_CBIT_CMODE_JPEG18", "", vrlg.CMPRS_CBIT_CMODE_JPEG18 , 0, None, None, "", "Color 4:2:0")),
(("X393_CMPRS_CBIT_FRAMES_SINGLE", "", vrlg.CMPRS_CBIT_FRAMES_SINGLE , 0, None, None, "", "Use single-frame buffer")), (("X393_CMPRS_CBIT_FRAMES_SINGLE", "", vrlg.CMPRS_CBIT_FRAMES_SINGLE , 0, None, None, "", "Use single-frame buffer")),
(("X393_CMPRS_CBIT_FRAMES_MULTI", "", 1 , 0, None, None, "", "Use multi-frame buffer"))] (("X393_CMPRS_CBIT_FRAMES_MULTI", "", 1 , 0, None, None, "", "Use multi-frame buffer"))]
...@@ -1898,8 +1897,11 @@ class X393ExportC(object): ...@@ -1898,8 +1897,11 @@ class X393ExportC(object):
dw=[] dw=[]
dw.append(("hist_en", vrlg.SENSOR_HIST_EN_BITS, 4,15, "Enable subchannel histogram modules (may be less than 4)")) dw.append(("hist_en", vrlg.SENSOR_HIST_EN_BITS, 4,15, "Enable subchannel histogram modules (may be less than 4)"))
dw.append(("hist_nrst", vrlg.SENSOR_HIST_NRST_BITS, 4,15, "Reset off for histograms subchannels (may be less than 4)")) dw.append(("hist_nrst", vrlg.SENSOR_HIST_NRST_BITS, 4,15, "Reset off for histograms subchannels (may be less than 4)"))
dw.append(("hist_set", vrlg.SENSOR_HIST_BITS_SET, 1, 0, "Apply values in hist_en and hist_nrst fields (0 - ignore)"))
dw.append(("chn_en", vrlg.SENSOR_CHN_EN_BIT, 1, 1, "Enable this sensor channel")) dw.append(("chn_en", vrlg.SENSOR_CHN_EN_BIT, 1, 1, "Enable this sensor channel"))
dw.append(("chn_en_set", vrlg.SENSOR_CHN_EN_BIT_SET, 1, 1, "Apply chn_en value (0 - ignore)"))
dw.append(("bit16", vrlg.SENSOR_16BIT_BIT, 1, 0, "0 - 8 bpp mode, 1 - 16 bpp (bypass gamma). Gamma-processed data is still used for histograms")) dw.append(("bit16", vrlg.SENSOR_16BIT_BIT, 1, 0, "0 - 8 bpp mode, 1 - 16 bpp (bypass gamma). Gamma-processed data is still used for histograms"))
dw.append(("bit16_set", vrlg.SENSOR_16BIT_BIT_SET, 1, 0, "Apply bit16 value (0 - ignore)"))
return dw return dw
def _enc_sens_sync_mult(self): def _enc_sens_sync_mult(self):
......
...@@ -1129,7 +1129,7 @@ class X393SensCmprs(object): ...@@ -1129,7 +1129,7 @@ class X393SensCmprs(object):
tile_margin = 0 # 18x18 instead of 16x16 tile_margin = 0 # 18x18 instead of 16x16
tile_width = 4 tile_width = 4
# extra_pages = (0,1)[(compressor_left_margin % 16) != 0] # memory access block border does not cut macroblocks # extra_pages = (0,1)[(compressor_left_margin % 16) != 0] # memory access block border does not cut macroblocks
extra_pages = 1 # just testing extra_pages = 1 # just testing, 0 should be OK here
tile_vstep = 16 tile_vstep = 16
tile_height = tile_vstep + tile_margin tile_height = tile_vstep + tile_margin
......
...@@ -252,10 +252,10 @@ class X393Sensor(object): ...@@ -252,10 +252,10 @@ class X393Sensor(object):
# Functions used by sensor-related tasks # Functions used by sensor-related tasks
def func_sensor_mode (self, def func_sensor_mode (self,
hist_en, hist_en = None,
hist_nrst, hist_nrst = None,
chn_en, chn_en = None,
bits16): bits16 = None):
""" """
Combine parameters into sensor mode control word Combine parameters into sensor mode control word
@param hist_en - bit mask to enable histogram sub-modules, when 0 - disable after processing @param hist_en - bit mask to enable histogram sub-modules, when 0 - disable after processing
...@@ -267,10 +267,16 @@ class X393Sensor(object): ...@@ -267,10 +267,16 @@ class X393Sensor(object):
@return: sensor mode control word @return: sensor mode control word
""" """
rslt = 0; rslt = 0;
rslt |= (hist_en & 0xf) << vrlg.SENSOR_HIST_EN_BITS if (not hist_en is None) and (hist_nrst is None):
rslt |= (hist_nrst & 0xf) << vrlg.SENSOR_HIST_NRST_BITS rslt |= (hist_en & 0xf) << vrlg.SENSOR_HIST_EN_BITS
rslt |= ((0,1)[chn_en]) << vrlg.SENSOR_CHN_EN_BIT rslt |= (hist_nrst & 0xf) << vrlg.SENSOR_HIST_NRST_BITS
rslt |= ((0,1)[bits16]) << vrlg.SENSOR_16BIT_BIT rslt |= 1 << vrlg.SENSOR_HIST_BITS_SET;
if not chn_en is None:
rslt |= ((0,1)[chn_en]) << vrlg.SENSOR_CHN_EN_BIT
rslt |= 1 << vrlg.SENSOR_CHN_EN_BIT_SET
if not bits16 is None:
rslt |= ((0,1)[bits16]) << vrlg.SENSOR_16BIT_BIT
rslt |= 1 << vrlg.SENSOR_16BIT_BIT_SET
return rslt return rslt
def func_sensor_i2c_command (self, def func_sensor_i2c_command (self,
...@@ -490,10 +496,10 @@ class X393Sensor(object): ...@@ -490,10 +496,10 @@ class X393Sensor(object):
def set_sensor_mode (self, def set_sensor_mode (self,
num_sensor, num_sensor,
hist_en, hist_en = None,
hist_nrst, hist_nrst = None,
chn_en, chn_en = None,
bits16): bits16 = None):
""" """
Set sensor mode Set sensor mode
@param num_sensor - sensor port number (0..3) @param num_sensor - sensor port number (0..3)
...@@ -522,6 +528,10 @@ class X393Sensor(object): ...@@ -522,6 +528,10 @@ class X393Sensor(object):
hist_nrst = hist_nrst, hist_nrst = hist_nrst,
chn_en = chn_en, chn_en = chn_en,
bits16 = bits16)) bits16 = bits16))
def set_sensor_i2c_command (self, def set_sensor_i2c_command (self,
num_sensor, num_sensor,
......
...@@ -69,11 +69,14 @@ module sensor_channel#( ...@@ -69,11 +69,14 @@ module sensor_channel#(
parameter SENSOR_CTRL_RADDR = 0, //'h00 parameter SENSOR_CTRL_RADDR = 0, //'h00
parameter SENSOR_CTRL_ADDR_MASK = 'h7ff, // parameter SENSOR_CTRL_ADDR_MASK = 'h7ff, //
// bits of the SENSOR mode register // bits of the SENSOR mode register
parameter SENSOR_MODE_WIDTH = 10,
parameter SENSOR_HIST_EN_BITS = 0, // 0..3 1 - enable histogram modules, disable after processing the started frame parameter SENSOR_HIST_EN_BITS = 0, // 0..3 1 - enable histogram modules, disable after processing the started frame
parameter SENSOR_HIST_NRST_BITS = 4, // 0 - immediately reset all histogram modules parameter SENSOR_HIST_NRST_BITS = 4, // 0 - immediately reset all histogram modules
parameter SENSOR_CHN_EN_BIT = 8, // 1 - this enable channel parameter SENSOR_HIST_BITS_SET = 8, // 1 - set bits 0..7 (en and nrst)
parameter SENSOR_16BIT_BIT = 9, // 0 - 8 bpp mode, 1 - 16 bpp (bypass gamma). Gamma-processed data is still used for histograms parameter SENSOR_CHN_EN_BIT = 9, // 1 - this enable channel
parameter SENSOR_CHN_EN_BIT_SET = 10, // set SENSOR_CHN_EN_BIT bit
parameter SENSOR_16BIT_BIT = 11, // 0 - 8 bpp mode, 1 - 16 bpp (bypass gamma). Gamma-processed data is still used for histograms
parameter SENSOR_16BIT_BIT_SET = 12, // set 8/16 bit mode
// parameter SENSOR_MODE_WIDTH = 13,
parameter SENSI2C_CTRL_RADDR = 2, // 'h02..'h03 parameter SENSI2C_CTRL_RADDR = 2, // 'h02..'h03
parameter SENSI2C_CTRL_MASK = 'h7fe, parameter SENSI2C_CTRL_MASK = 'h7fe,
...@@ -432,12 +435,12 @@ module sensor_channel#( ...@@ -432,12 +435,12 @@ module sensor_channel#(
wire [31:0] sensor_ctrl_data; wire [31:0] sensor_ctrl_data;
wire sensor_ctrl_we; wire sensor_ctrl_we;
reg [SENSOR_MODE_WIDTH-1:0] mode; // reg [SENSOR_MODE_WIDTH-1:0] mode;
wire [3:0] hist_en; reg [3:0] hist_en;
wire en_mclk; // enable this channel reg en_mclk; // enable this channel
wire en_pclk; // enable in pclk domain wire en_pclk; // enable in pclk domain
wire [3:0] hist_nrst; reg [3:0] hist_nrst;
wire bit16; // 16-bit mode, 0 - 8 bit mode reg bit16; // 16-bit mode, 0 - 8 bit mode
wire [3:0] hist_rq; wire [3:0] hist_rq;
wire [3:0] hist_gr; wire [3:0] hist_gr;
wire [3:0] hist_dv; wire [3:0] hist_dv;
...@@ -472,10 +475,10 @@ module sensor_channel#( ...@@ -472,10 +475,10 @@ module sensor_channel#(
assign dav_w = bit16 ? gamma_hact_in : dav_8bit; assign dav_w = bit16 ? gamma_hact_in : dav_8bit;
assign last_in_line = ! ( bit16 ? gamma_hact_in : gamma_hact_out); assign last_in_line = ! ( bit16 ? gamma_hact_in : gamma_hact_out);
assign en_mclk = mode[SENSOR_CHN_EN_BIT]; // assign en_mclk = mode[SENSOR_CHN_EN_BIT];
assign hist_en = mode[SENSOR_HIST_EN_BITS +: 4]; // assign hist_en = mode[SENSOR_HIST_EN_BITS +: 4];
assign hist_nrst = mode[SENSOR_HIST_NRST_BITS +: 4]; // assign hist_nrst = mode[SENSOR_HIST_NRST_BITS +: 4];
assign bit16 = mode[SENSOR_16BIT_BIT]; // assign bit16 = mode[SENSOR_16BIT_BIT];
`ifdef DEBUG_RING `ifdef DEBUG_RING
...@@ -561,8 +564,16 @@ module sensor_channel#( ...@@ -561,8 +564,16 @@ module sensor_channel#(
end end
always @ (posedge mclk) begin always @ (posedge mclk) begin
if (mrst) mode <= 0; // if (mrst) mode <= 0;
else if (sensor_ctrl_we) mode <= sensor_ctrl_data[SENSOR_MODE_WIDTH-1:0]; // else if (sensor_ctrl_we) mode <= sensor_ctrl_data[SENSOR_MODE_WIDTH-1:0];
if (mrst) hist_en <= 0;
else if (sensor_ctrl_we && sensor_ctrl_data[SENSOR_HIST_BITS_SET]) hist_en <= sensor_ctrl_data[SENSOR_HIST_EN_BITS +:4];
if (mrst) hist_nrst <= 0;
else if (sensor_ctrl_we && sensor_ctrl_data[SENSOR_HIST_BITS_SET]) hist_nrst <= sensor_ctrl_data[SENSOR_HIST_NRST_BITS +:4];
if (mrst) en_mclk <= 0;
else if (sensor_ctrl_we && sensor_ctrl_data[SENSOR_CHN_EN_BIT_SET]) en_mclk <= sensor_ctrl_data[SENSOR_CHN_EN_BIT];
if (mrst) bit16 <= 0;
else if (sensor_ctrl_we && sensor_ctrl_data[SENSOR_16BIT_BIT_SET]) bit16 <= sensor_ctrl_data[SENSOR_16BIT_BIT];
end end
always @ (posedge pclk) begin always @ (posedge pclk) begin
......
...@@ -61,11 +61,14 @@ module sensors393 #( ...@@ -61,11 +61,14 @@ module sensors393 #(
parameter SENSOR_CTRL_RADDR = 0, // relative to SENSOR_GROUP_ADDR parameter SENSOR_CTRL_RADDR = 0, // relative to SENSOR_GROUP_ADDR
parameter SENSOR_CTRL_ADDR_MASK = 'h7ff, // parameter SENSOR_CTRL_ADDR_MASK = 'h7ff, //
// bits of the SENSOR mode register // bits of the SENSOR mode register
parameter SENSOR_MODE_WIDTH = 10,
parameter SENSOR_HIST_EN_BITS = 0, // 0..3 1 - enable histogram modules, disable after processing the started frame parameter SENSOR_HIST_EN_BITS = 0, // 0..3 1 - enable histogram modules, disable after processing the started frame
parameter SENSOR_HIST_NRST_BITS = 4, // 0 - immediately reset all histogram modules parameter SENSOR_HIST_NRST_BITS = 4, // 0 - immediately reset all histogram modules
parameter SENSOR_CHN_EN_BIT = 8, // 1 - this enable channel parameter SENSOR_HIST_BITS_SET = 8, // 1 - set bits 0..7 (en and nrst)
parameter SENSOR_16BIT_BIT = 9, // 0 - 8 bpp mode, 1 - 16 bpp (bypass gamma). Gamma-processed data is still used for histograms parameter SENSOR_CHN_EN_BIT = 9, // 1 - this enable channel
parameter SENSOR_CHN_EN_BIT_SET = 10, // set SENSOR_CHN_EN_BIT bit
parameter SENSOR_16BIT_BIT = 11, // 0 - 8 bpp mode, 1 - 16 bpp (bypass gamma). Gamma-processed data is still used for histograms
parameter SENSOR_16BIT_BIT_SET = 12, // set 8/16 bit mode
// parameter SENSOR_MODE_WIDTH = 13,
parameter SENSI2C_CTRL_RADDR = 2, // 302..'h303 parameter SENSI2C_CTRL_RADDR = 2, // 302..'h303
parameter SENSI2C_CTRL_MASK = 'h7fe, parameter SENSI2C_CTRL_MASK = 'h7fe,
...@@ -484,11 +487,13 @@ module sensors393 #( ...@@ -484,11 +487,13 @@ module sensors393 #(
.SENS_GAMMA_BUFFER (SENS_GAMMA_BUFFER), .SENS_GAMMA_BUFFER (SENS_GAMMA_BUFFER),
.SENSOR_CTRL_RADDR (SENSOR_CTRL_RADDR), .SENSOR_CTRL_RADDR (SENSOR_CTRL_RADDR),
.SENSOR_CTRL_ADDR_MASK (SENSOR_CTRL_ADDR_MASK), .SENSOR_CTRL_ADDR_MASK (SENSOR_CTRL_ADDR_MASK),
.SENSOR_MODE_WIDTH (SENSOR_MODE_WIDTH),
.SENSOR_CHN_EN_BIT (SENSOR_CHN_EN_BIT),
.SENSOR_HIST_EN_BITS (SENSOR_HIST_EN_BITS), .SENSOR_HIST_EN_BITS (SENSOR_HIST_EN_BITS),
.SENSOR_HIST_NRST_BITS (SENSOR_HIST_NRST_BITS), .SENSOR_HIST_NRST_BITS (SENSOR_HIST_NRST_BITS),
.SENSOR_HIST_BITS_SET (SENSOR_HIST_BITS_SET),
.SENSOR_CHN_EN_BIT (SENSOR_CHN_EN_BIT),
.SENSOR_CHN_EN_BIT_SET (SENSOR_CHN_EN_BIT_SET),
.SENSOR_16BIT_BIT (SENSOR_16BIT_BIT), .SENSOR_16BIT_BIT (SENSOR_16BIT_BIT),
.SENSOR_16BIT_BIT_SET (SENSOR_16BIT_BIT_SET),
.SENSI2C_CTRL_RADDR (SENSI2C_CTRL_RADDR), .SENSI2C_CTRL_RADDR (SENSI2C_CTRL_RADDR),
.SENSI2C_CTRL_MASK (SENSI2C_CTRL_MASK), .SENSI2C_CTRL_MASK (SENSI2C_CTRL_MASK),
.SENSI2C_CTRL (SENSI2C_CTRL), .SENSI2C_CTRL (SENSI2C_CTRL),
......
...@@ -1622,11 +1622,13 @@ assign axi_grst = axi_rst_pre; ...@@ -1622,11 +1622,13 @@ assign axi_grst = axi_rst_pre;
.SENS_GAMMA_BUFFER (SENS_GAMMA_BUFFER), .SENS_GAMMA_BUFFER (SENS_GAMMA_BUFFER),
.SENSOR_CTRL_RADDR (SENSOR_CTRL_RADDR), .SENSOR_CTRL_RADDR (SENSOR_CTRL_RADDR),
.SENSOR_CTRL_ADDR_MASK (SENSOR_CTRL_ADDR_MASK), .SENSOR_CTRL_ADDR_MASK (SENSOR_CTRL_ADDR_MASK),
.SENSOR_MODE_WIDTH (SENSOR_MODE_WIDTH),
.SENSOR_HIST_EN_BITS (SENSOR_HIST_EN_BITS), .SENSOR_HIST_EN_BITS (SENSOR_HIST_EN_BITS),
.SENSOR_CHN_EN_BIT (SENSOR_CHN_EN_BIT),
.SENSOR_HIST_NRST_BITS (SENSOR_HIST_NRST_BITS), .SENSOR_HIST_NRST_BITS (SENSOR_HIST_NRST_BITS),
.SENSOR_HIST_BITS_SET (SENSOR_HIST_BITS_SET),
.SENSOR_CHN_EN_BIT (SENSOR_CHN_EN_BIT),
.SENSOR_CHN_EN_BIT_SET (SENSOR_CHN_EN_BIT_SET),
.SENSOR_16BIT_BIT (SENSOR_16BIT_BIT), .SENSOR_16BIT_BIT (SENSOR_16BIT_BIT),
.SENSOR_16BIT_BIT_SET (SENSOR_16BIT_BIT_SET),
.SENSI2C_CTRL_RADDR (SENSI2C_CTRL_RADDR), .SENSI2C_CTRL_RADDR (SENSI2C_CTRL_RADDR),
.SENSI2C_CTRL_MASK (SENSI2C_CTRL_MASK), .SENSI2C_CTRL_MASK (SENSI2C_CTRL_MASK),
.SENSI2C_CTRL (SENSI2C_CTRL), .SENSI2C_CTRL (SENSI2C_CTRL),
...@@ -2958,9 +2960,9 @@ sata_ahci_top sata_top( ...@@ -2958,9 +2960,9 @@ sata_ahci_top sata_top(
cmprs_irq[3:0], // [15:12] Compressor done interrupts SPI: Numbers [91:88] cmprs_irq[3:0], // [15:12] Compressor done interrupts SPI: Numbers [91:88]
frseq_irq[3:0], // [11: 8] Frame sync interrupts SPI: Numbers [87:84] frseq_irq[3:0], // [11: 8] Frame sync interrupts SPI: Numbers [87:84]
mult_saxi_irq[3:0], // [ 7: 4] interrupts from mult_saxi channels SPI: Numbers [68:65] mult_saxi_irq[3:0], // [ 7: 4] interrupts from mult_saxi channels SPI: Numbers [68:65]
membridge_irq, // [3] interrupts from membridge module SPI: Number [65] membridge_irq, // [3] interrupts from membridge module SPI: Number [64]
2'b0, // [ 2: 1] Reserved SPI: Numbers [64:63] 2'b0, // [ 2: 1] Reserved SPI: Numbers [63:62]
sata_irq // [ 0] AHCI (SATA ) interrupt SPI: Number [62] sata_irq // [ 0] AHCI (SATA ) interrupt SPI: Number [61]
}), // Interrupts, PL to PS [19:0], input }), // Interrupts, PL to PS [19:0], input
.IRQP2F(), // Interrupts, PL to PS [28:0], output .IRQP2F(), // Interrupts, PL to PS [28:0], output
// Event Signals // Event Signals
......
...@@ -3247,13 +3247,19 @@ task setup_sensor_channel; ...@@ -3247,13 +3247,19 @@ task setup_sensor_channel;
// Run after histogram channel is set up? // Run after histogram channel is set up?
TEST_TITLE = "SENSOR_SETUP"; TEST_TITLE = "SENSOR_SETUP";
$display("===================== TEST_%s =========================",TEST_TITLE); $display("===================== TEST_%s =========================",TEST_TITLE);
set_sensor_mode ( set_sensor_mode_hist (
num_sensor, // input [1:0] num_sensor; num_sensor, // input [1:0] num_sensor;
4'h1, // input [3:0] hist_en; // [0..3] 1 - enable histogram modules, disable after processing the started frame 4'h1, // input [3:0] hist_en; // [0..3] 1 - enable histogram modules, disable after processing the started frame
4'h1, // input [3:0] hist_nrst; // [4..7] 0 - immediately reset histogram module 4'h1); // input [3:0] hist_nrst; // [4..7] 0 - immediately reset histogram module
1'b1, // input chn_en; // [8] 1 - enable sensor channel (0 - reset) set_sensor_mode_en (
1'b0); // input bits16; // [9] 0 - 8 bpp mode, 1 - 16 bpp (bypass gamma). Gamma-processed data is still used for histograms num_sensor, // input [1:0] num_sensor;
1'b1); // input chn_en; // [9] 1 - enable sensor channel (0 - reset)
// test i2c - manual and sequencer (same data as in 353 test fixture
set_sensor_mode_bits16 (
num_sensor, // input [1:0] num_sensor;
1'b0); // input bits16; // [11] 0 - 8 bpp mode, 1 - 16 bpp (bypass gamma). Gamma-processed data is still used for histograms
// test i2c - manual and sequencer (same data as in 353 test fixture // test i2c - manual and sequencer (same data as in 353 test fixture
TEST_TITLE = "CMPRS_EN_ARBIT"; TEST_TITLE = "CMPRS_EN_ARBIT";
...@@ -3780,6 +3786,37 @@ task set_gpio_pins; // SuppressThisWarning VEditor not always unused ...@@ -3780,6 +3786,37 @@ task set_gpio_pins; // SuppressThisWarning VEditor not always unused
endtask endtask
// x393_sensor.py // x393_sensor.py
task set_sensor_mode_hist;
input [1:0] num_sensor;
input [3:0] hist_en; // [0..3] 1 - enable histogram modules, disable after processing the started frame
input [3:0] hist_nrst; // [4..7] 0 - immediately reset histogram module
reg [31:0] tmp;
begin
tmp= {{(32-9){1'b0}},{1'b1,hist_nrst,hist_en}};
write_contol_register( SENSOR_GROUP_ADDR + num_sensor * SENSOR_BASE_INC +SENSOR_CTRL_RADDR, tmp);
end
endtask
task set_sensor_mode_en;
input [1:0] num_sensor;
input chn_en; // [9] 1 - enable sensor channel (0 - reset)
reg [31:0] tmp;
begin
tmp= {{(32-11){1'b0}},{1'b1,chn_en,9'b0}};
write_contol_register( SENSOR_GROUP_ADDR + num_sensor * SENSOR_BASE_INC +SENSOR_CTRL_RADDR, tmp);
end
endtask
task set_sensor_mode_bits16;
input [1:0] num_sensor;
input bits16; // [11] 0 - 8 bpp mode, 1 - 16 bpp (bypass gamma). Gamma-processed data is still used for histograms
reg [31:0] tmp;
begin
tmp= {{(32-13){1'b0}},{1'b1,bits16,11'b0}};
write_contol_register( SENSOR_GROUP_ADDR + num_sensor * SENSOR_BASE_INC +SENSOR_CTRL_RADDR, tmp);
end
endtask
/*
task set_sensor_mode; task set_sensor_mode;
input [1:0] num_sensor; input [1:0] num_sensor;
input [3:0] hist_en; // [0..3] 1 - enable histogram modules, disable after processing the started frame input [3:0] hist_en; // [0..3] 1 - enable histogram modules, disable after processing the started frame
...@@ -3791,9 +3828,8 @@ task set_sensor_mode; ...@@ -3791,9 +3828,8 @@ task set_sensor_mode;
tmp= {{(32-SENSOR_MODE_WIDTH){1'b0}},func_sensor_mode(hist_en, hist_nrst, chn_en,bits16)}; tmp= {{(32-SENSOR_MODE_WIDTH){1'b0}},func_sensor_mode(hist_en, hist_nrst, chn_en,bits16)};
write_contol_register( SENSOR_GROUP_ADDR + num_sensor * SENSOR_BASE_INC +SENSOR_CTRL_RADDR, tmp); write_contol_register( SENSOR_GROUP_ADDR + num_sensor * SENSOR_BASE_INC +SENSOR_CTRL_RADDR, tmp);
end end
endtask endtask
*/
// x393_sensor.py // x393_sensor.py
task set_sensor_i2c_command; task set_sensor_i2c_command;
input [1:0] num_sensor; input [1:0] num_sensor;
...@@ -4489,22 +4525,6 @@ task write_cmd_frame_sequencer; // SuppressThisWarning VEditor not always unused ...@@ -4489,22 +4525,6 @@ task write_cmd_frame_sequencer; // SuppressThisWarning VEditor not always unused
end end
endtask endtask
// x393_sensor.py // x393_sensor.py
function [SENSOR_MODE_WIDTH-1:0] func_sensor_mode;
input [3:0] hist_en; // [0..3] 1 - enable histogram modules, disable after processing the started frame
input [3:0] hist_nrst; // [4..7] 0 - immediately reset histogram module
input chn_en; // [8] 1 - enable sensor channel (0 - reset)
input bits16; // [9] 0 - 8 bpp mode, 1 - 16 bpp (bypass gamma). Gamma-processed data is still used for histograms
reg [SENSOR_MODE_WIDTH-1:0] tmp;
begin
tmp = 0;
tmp [SENSOR_HIST_EN_BITS +: 4] = hist_en;
tmp [SENSOR_HIST_NRST_BITS +: 4] = hist_nrst;
tmp [SENSOR_CHN_EN_BIT] = chn_en;
tmp [SENSOR_16BIT_BIT] = bits16;
func_sensor_mode = tmp;
end
endfunction
// x393_sensor.py // x393_sensor.py
function [31 : 0] func_sensor_i2c_command; function [31 : 0] func_sensor_i2c_command;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment