Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
x393
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
x393
Commits
0631243b
Commit
0631243b
authored
Aug 05, 2016
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added bayer input to histograms, separated bayer, page, en and repet control in gamma modules
parent
fe0f5941
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
281 additions
and
145 deletions
+281
-145
x393_parameters.vh
includes/x393_parameters.vh
+11
-6
vrlg.py
py393/vrlg.py
+30
-18
x393_export_c.py
py393/x393_export_c.py
+8
-4
x393_sensor.py
py393/x393_sensor.py
+21
-9
sens_gamma.v
sensor/sens_gamma.v
+61
-20
sens_histogram.v
sensor/sens_histogram.v
+3
-3
sens_histogram_snglclk.v
sensor/sens_histogram_snglclk.v
+5
-5
sensor_channel.v
sensor/sensor_channel.v
+60
-37
sensors393.v
sensor/sensors393.v
+15
-7
x393.v
x393.v
+5
-1
x393_testbench03.tf
x393_testbench03.tf
+62
-35
No files found.
includes/x393_parameters.vh
View file @
0631243b
...
...
@@ -416,12 +416,16 @@
parameter SENS_GAMMA_HEIGHT01 = 'h2, // bits [15:0] - height minus 1 of image 0, [31:16] - height-1 of image1
parameter SENS_GAMMA_HEIGHT2 = 'h3, // bits [15:0] - height minus 1 of image 2 ( no need for image 3)
// bits of the SENS_GAMMA_CTRL mode register
parameter SENS_GAMMA_MODE_WIDTH = 5, // does not include trig
parameter SENS_GAMMA_MODE_BAYER = 0,
parameter SENS_GAMMA_MODE_PAGE = 2,
parameter SENS_GAMMA_MODE_EN = 3,
parameter SENS_GAMMA_MODE_REPET = 4,
parameter SENS_GAMMA_MODE_TRIG = 5,
// parameter SENS_GAMMA_MODE_WIDTH = 5, // does not include trig
parameter SENS_GAMMA_MODE_BAYER = 0,
parameter SENS_GAMMA_MODE_BAYER_SET = 2,
parameter SENS_GAMMA_MODE_PAGE = 3,
parameter SENS_GAMMA_MODE_PAGE_SET = 4,
parameter SENS_GAMMA_MODE_EN = 5,
parameter SENS_GAMMA_MODE_EN_SET = 6,
parameter SENS_GAMMA_MODE_REPET = 7,
parameter SENS_GAMMA_MODE_REPET_SET = 8,
parameter SENS_GAMMA_MODE_TRIG = 9,
// Vignetting correction / pixel value scaling - controlled via single data word (same as in 252), some of bits [23:16]
// are used to select register, bits 25:24 - select sub-frame
...
...
@@ -498,6 +502,7 @@
parameter HISTOGRAM_LEFT_TOP = 'h0,
parameter HISTOGRAM_WIDTH_HEIGHT = 'h1, // 1.. 2^16, 0 - use HACT
parameter [1:0] XOR_HIST_BAYER = 2'b00,// invert bayer setting
//sensor_i2c_io other parameters
parameter integer SENSI2C_DRIVE= 12,
parameter SENSI2C_IBUF_LOW_PWR= "TRUE",
...
...
py393/vrlg.py
View file @
0631243b
...
...
@@ -123,6 +123,7 @@ SS_EN__RAW = str
CLKIN_PERIOD_PCLK
=
int
SENSI2C_STATUS_REG_REL__TYPE
=
str
SENSI2C_CMD_RUN_PBITS__RAW
=
str
XOR_HIST_BAYER__TYPE
=
str
HIST_SAXI_AWCACHE__RAW
=
str
CLK_STATUS_REG_ADDR__TYPE
=
str
MCONTR_TOP_16BIT_STATUS_CNTRL__TYPE
=
str
...
...
@@ -340,7 +341,7 @@ WINDOW_WIDTH = int
CLK_CNTRL__RAW
=
str
MCONTR_LINTILE_EXTRAPG_BITS
=
int
MCONTR_LINTILE_RST_FRAME__TYPE
=
str
HISTOGRAM_TOP
=
int
LAST_BUF_FRAME__RAW
=
str
FCLK1_PERIOD
=
float
CMPRS_AFIMUX_RADDR1__RAW
=
str
MCNTRL_TEST01_CHN1_STATUS_CNTRL__RAW
=
str
...
...
@@ -451,7 +452,7 @@ CMDFRAMESEQ_ADDR_BASE__RAW = str
MCONTR_LINTILE_SKIP_LATE__TYPE
=
str
DEBUG_ADDR__RAW
=
str
CONTROL_ADDR__RAW
=
str
TILED_STARTY__RAW
=
str
SENSI2C_CMD_RESET
=
int
RTC_BITC_PREDIV
=
int
CMPRS_FRMT_MBCM1_BITS__TYPE
=
str
SENS_CTRL_QUADRANTS_EN__RAW
=
str
...
...
@@ -605,7 +606,7 @@ SENSI2C_TBL_SA__TYPE = str
BUF_IPCLK_SENS3__TYPE
=
str
MCNTRL_TILED_MODE
=
int
MCNTRL_TILED_WINDOW_STARTXY__TYPE
=
str
HISTOGRAM_HEIGHT
=
int
CMPRS_COLOR20__TYPE
=
str
MCNTRL_TEST01_CHN2_STATUS_CNTRL__RAW
=
str
LOGGER_CONF_SYN
=
int
MCNTRL_TILED_CHN4_ADDR__RAW
=
str
...
...
@@ -624,6 +625,7 @@ SIMULATE_CMPRS_CMODE1 = int
MULT_SAXI_CNTRL_ADDR
=
int
MULTICLK_BUF_SYNC__TYPE
=
str
HIST_SAXI_ADDR_REL__RAW
=
str
SENS_GAMMA_MODE_PAGE_SET__RAW
=
str
CMPRS_CBIT_CMODE_MONO4__TYPE
=
str
HIST_SAXI_MODE_WIDTH__RAW
=
str
SENS_LENS_AX
=
int
...
...
@@ -667,13 +669,14 @@ SENS_LENS_AX__TYPE = str
PXD_DRIVE__TYPE
=
str
HIST_SAXI_NRESET
=
int
MULT_SAXI_HALF_BRAM_IN__RAW
=
str
HISTOGRAM_HEIGHT
=
int
SENSI2C_TBL_SA__RAW
=
str
CMPRS_CBIT_CMODE_JP4__RAW
=
str
MULTICLK_BUF_AXIHP__RAW
=
str
CLK_STATUS__TYPE
=
str
GPIO_SET_STATUS__RAW
=
str
SENS_JTAG_TCK
=
int
CMPRS_COLOR20__TYPE
=
str
XOR_HIST_BAYER__RAW
=
str
DEBUG_STATUS_REG_ADDR__TYPE
=
str
REFRESH_OFFSET__TYPE
=
str
SENS_CTRL_ARST__RAW
=
str
...
...
@@ -690,7 +693,6 @@ SDCLK_PHASE__RAW = str
SENS_SYNC_RADDR__TYPE
=
str
BUF_IPCLK_SENS0__TYPE
=
str
SENSI2C_CMD_RUN__RAW
=
str
SENS_GAMMA_MODE_WIDTH__TYPE
=
str
MCNTRL_TILED_STARTADDR__TYPE
=
str
DLY_LD_MASK
=
int
MCONTR_LINTILE_BYTE32
=
int
...
...
@@ -797,7 +799,7 @@ HISPI_CAPACITANCE__TYPE = str
MCONTR_LINTILE_KEEP_OPEN__TYPE
=
str
SENS_LENS_POST_SCALE
=
int
LOGGER_STATUS_REG_ADDR__TYPE
=
str
SS_MOD
E
=
str
MEMBRIDGE_LO_ADDR64__TYP
E
=
str
MCONTR_CMD_WR_ADDR__RAW
=
str
CMDFRAMESEQ_CTRL
=
int
DLY_LD__TYPE
=
str
...
...
@@ -842,9 +844,11 @@ PXD_CLK_DIV_BITS__RAW = str
CMPRS_FRMT_LMARG_BITS
=
int
CMDSEQMUX_ADDR
=
int
CMPRS_CBIT_CMODE_JP4DIFFHDR__TYPE
=
str
SENS_GAMMA_MODE_PAGE_SET
=
int
MCNTRL_SCANLINE_PENDING_CNTR_BITS__TYPE
=
str
SENSI2C_TBL_NBWR
=
int
DLY_DQS_IDELAY__RAW
=
str
SENS_SYNC_RADDR
=
int
CONTROL_RBACK_ADDR_MASK__TYPE
=
str
MCONTR_BUF4_WR_ADDR
=
int
SENS_DIVCLK_DIVIDE__RAW
=
str
...
...
@@ -955,13 +959,13 @@ MCNTRL_SCANLINE_STATUS_REG_CHN1_ADDR = int
RTC_SET_USEC__TYPE
=
str
MULT_SAXI_BSLOG3__RAW
=
str
CMPRS_TIMEOUT_BITS__TYPE
=
str
SENS_GAMMA_MODE_WIDTH__RAW
=
str
PHASE_CLK2X_PCLK__TYPE
=
str
FFCLK1_DIFF_TERM__TYPE
=
str
WRITELEV_OFFSET
=
int
MCONTR_PHY_0BIT_ADDR_MASK__TYPE
=
str
MULT_SAXI_ADV_RD__RAW
=
str
SENS_SYNC_RADDR
=
int
SENS_GAMMA_MODE_EN_SET__RAW
=
str
SENS_GAMMA_MODE_BAYER_SET__TYPE
=
str
T_RFC__RAW
=
str
WBUF_DLY_DFLT__TYPE
=
str
HISPI_DELAY_CLK0__RAW
=
str
...
...
@@ -991,6 +995,7 @@ MEMBRIDGE_SIZE64 = int
SENSOR_IMAGE_TYPE1__RAW
=
str
MCONTR_PHY_0BIT_CKE_EN__TYPE
=
str
CMPRS_FRMT_MBCM1_BITS
=
int
SENS_GAMMA_MODE_REPET_SET__TYPE
=
str
HISTOGRAM_RAM_MODE__TYPE
=
str
AFI_LO_ADDR64
=
int
NUM_CYCLES_07__TYPE
=
str
...
...
@@ -1082,6 +1087,7 @@ MCONTR_PHY_0BIT_DLY_RST__TYPE = str
TILED_KEEP_OPEN__RAW
=
str
AXI_WRADDR_LATENCY__TYPE
=
str
MULT_SAXI_IRQLEN_ADDR
=
int
XOR_HIST_BAYER
=
int
MULTICLK_BUF_XCLK__TYPE
=
str
MCONTR_TOP_0BIT_ADDR__TYPE
=
str
CLKFBOUT_PHASE_SENSOR__RAW
=
str
...
...
@@ -1097,7 +1103,6 @@ CAMSYNC_EXTERNAL_BIT__RAW = str
HISTOGRAM_WIDTH
=
int
MCNTRL_SCANLINE_WINDOW_X0Y0__TYPE
=
str
HISPI_IBUF_LOW_PWR__RAW
=
str
MCNTRL_PS_STATUS_REG_ADDR
=
int
SENSI2C_TBL_NBRD__TYPE
=
str
SENSI2C_CMD_ACIVE_SDA
=
int
MCONTR_PHY_0BIT_ADDR__TYPE
=
str
...
...
@@ -1124,7 +1129,7 @@ CMPRS_CBIT_FOCUS_BITS = int
LOGGER_CONF_SYN__RAW
=
str
CMPRS_COLOR20
=
int
SENSI2C_CMD_TABLE__RAW
=
str
LAST_BUF_FRAME__RAW
=
str
SENSIO_DELAYS__TYPE
=
str
ADDRESS_NUMBER__TYPE
=
str
WSEL__TYPE
=
str
CMPRS_AFIMUX_CYCBITS__RAW
=
str
...
...
@@ -1258,6 +1263,7 @@ CAMSYNC_POST_MAGIC__TYPE = str
NUM_CYCLES_29__TYPE
=
str
RTC_SET_SEC__TYPE
=
str
CAMSYNC_ADDR
=
int
FFCLK1_CAPACITANCE__RAW
=
str
RTC_SET_CORR__TYPE
=
str
PHASE_WIDTH__RAW
=
str
SLEW_DQ__RAW
=
str
...
...
@@ -1268,7 +1274,7 @@ MEMBRIDGE_START64__TYPE = str
CMPRS_CBIT_CMODE_JP46
=
int
MEMCLK_CAPACITANCE__TYPE
=
str
MCONTR_BUF0_WR_ADDR__RAW
=
str
SENS_GAMMA_MODE_WIDTH
=
int
HISTOGRAM_TOP
=
int
SENS_SS_MODE
=
str
SENSOR12BITS_TDDO
=
int
CAMSYNC_TRIG_DST
=
int
...
...
@@ -1553,6 +1559,7 @@ DLY_LANE1_DQS_WLV_IDELAY = long
MULTICLK_PHASE_DLYREF
=
float
HIST_SAXI_ADDR_REL
=
int
CMDFRAMESEQ_ADDR_BASE
=
int
STATUS_SEQ_SHFT__RAW
=
str
SENS_SS_MODE__TYPE
=
str
CMPRS_AFIMUX_RADDR0
=
int
CMPRS_FRMT_MBCM1_BITS__RAW
=
str
...
...
@@ -1618,6 +1625,7 @@ PXD_SLEW__RAW = str
MULT_SAXI_STATUS_REG
=
int
CLKIN_PERIOD_SENSOR__TYPE
=
str
QUADRANTS_PXD_HACT_VACT__TYPE
=
str
SENS_GAMMA_MODE_BAYER_SET__RAW
=
str
SENSOR_PRIORITY__TYPE
=
str
SENS_LENS_BY__RAW
=
str
MCNTRL_PS_CMD__TYPE
=
str
...
...
@@ -1695,7 +1703,7 @@ WRITELEV_OFFSET__RAW = str
READ_PATTERN_OFFSET
=
int
CLK_PHASE__TYPE
=
str
SENSOR_16BIT_BIT
=
int
SENSIO_DELAYS__TYPE
=
str
MCNTRL_PS_STATUS_REG_ADDR
=
int
SENS_CTRL_EXT_CLK__RAW
=
str
SENSOR_CHN_EN_BIT_SET
=
int
WOI_HEIGHT
=
int
...
...
@@ -1782,8 +1790,9 @@ SENSI2C_IBUF_LOW_PWR__RAW = str
SENSI2C_STATUS_REG_REL
=
int
AXI_RDADDR_LATENCY__RAW
=
str
SENSOR_CTRL_ADDR_MASK
=
int
SENS_GAMMA_MODE_BAYER_SET
=
int
NUM_CYCLES_16__TYPE
=
str
MEMBRIDGE_LO_ADDR64__TYP
E
=
str
SS_MOD
E
=
str
CMDFRAMESEQ_MASK__RAW
=
str
SENSOR12BITS_TMD__TYPE
=
str
SENS_CTRL_LD_DLY__TYPE
=
str
...
...
@@ -1978,7 +1987,7 @@ TABLE_CORING_INDEX__TYPE = str
HISTOGRAM_RADDR1__RAW
=
str
SENSI2C_CMD_TAND__TYPE
=
str
MCONTR_LINTILE_EXTRAPG_BITS__RAW
=
str
SENS_BANDWIDTH
=
str
HISTOGRAM_HEIGHT__RAW
=
str
MCNTRL_SCANLINE_MODE__RAW
=
str
LOGGER_BIT_HALF_PERIOD__TYPE
=
str
FRAME_START_ADDRESS_INC__RAW
=
str
...
...
@@ -2006,7 +2015,7 @@ MCONTR_PHY_STATUS_CNTRL__RAW = str
DLY_LANE0_DQS_WLV_IDELAY
=
long
MCNTRL_SCANLINE_STATUS_CNTRL
=
int
CMDSEQMUX_MASK__TYPE
=
str
SENSI2C_CMD_RESET
=
int
TILED_STARTY__RAW
=
str
SENSI2C_TBL_NABRD__TYPE
=
str
NUM_CYCLES_01__RAW
=
str
WINDOW_HEIGHT__RAW
=
str
...
...
@@ -2017,6 +2026,7 @@ PHASE_CLK2X_PCLK__RAW = str
MCNTRL_TEST01_STATUS_REG_CHN1_ADDR__TYPE
=
str
MCONTR_TOP_0BIT_ADDR__RAW
=
str
HISPI_IBUF_LOW_PWR
=
str
SENS_GAMMA_MODE_REPET_SET
=
int
HISPI_KEEP_IRST__RAW
=
str
LOGGER_CONF_DBG__TYPE
=
str
AFI_SIZE64__RAW
=
str
...
...
@@ -2045,7 +2055,7 @@ DLY_CMDA__TYPE = str
CLKFBOUT_MULT__TYPE
=
str
DEBUG_MASK
=
int
MCONTR_PHY_0BIT_CMDA_EN__RAW
=
str
S
TATUS_SEQ_SHFT__RAW
=
str
S
ENS_GAMMA_MODE_PAGE_SET__TYPE
=
str
IDELAY_VALUE
=
int
DQSTRI_LAST__TYPE
=
str
HISTOGRAM_RADDR2__TYPE
=
str
...
...
@@ -2153,7 +2163,7 @@ BUF_IPCLK2X_SENS0__TYPE = str
MULTICLK_BUF_SYNC__RAW
=
str
MCONTR_PHY_0BIT_DLY_SET__RAW
=
str
NUM_CYCLES_11__RAW
=
str
FFCLK1_CAPACITANCE
__RAW
=
str
SENS_GAMMA_MODE_REPET_SET
__RAW
=
str
SENSI2C_DRIVE__RAW
=
str
SENSOR_HIST_BITS_SET__TYPE
=
str
CMPRS_CBIT_CMODE_MONO1__TYPE
=
str
...
...
@@ -2194,6 +2204,7 @@ MULTICLK_IN_PERIOD = int
MCONTR_TOP_0BIT_MCONTR_EN__RAW
=
str
MULTICLK_PHASE_FB__RAW
=
str
TABLE_HUFFMAN_INDEX__TYPE
=
str
SENS_GAMMA_MODE_EN_SET__TYPE
=
str
RTC_SET_STATUS__RAW
=
str
SENS_CTRL_QUADRANTS
=
int
LD_DLY_PHASE__TYPE
=
str
...
...
@@ -2228,6 +2239,7 @@ CMDFRAMESEQ_DEPTH__RAW = str
SENS_LENS_BX_MASK__RAW
=
str
SENSI2C_TBL_NBWR_BITS__RAW
=
str
WRITE_BLOCK_OFFSET__RAW
=
str
SENS_GAMMA_MODE_EN_SET
=
int
MCONTR_LINTILE_SINGLE__RAW
=
str
MCNTRL_TILED_FRAME_PAGE_RESET__RAW
=
str
SENS_GAMMA_BUFFER__TYPE
=
str
...
...
@@ -2264,7 +2276,7 @@ DEBUG_SET_STATUS__TYPE = str
HISTOGRAM_START_PAGE
=
int
RTC_SEC_USEC_ADDR__RAW
=
str
MCNTRL_PS_ADDR
=
int
HISTOGRAM_HEIGHT__RAW
=
str
SENS_BANDWIDTH
=
str
MEMCLK_IBUF_LOW_PWR
=
str
HISPI_DELAY_CLK3__RAW
=
str
CAMSYNC_TRIG_DST__TYPE
=
str
...
...
py393/x393_export_c.py
View file @
0631243b
...
...
@@ -1951,10 +1951,14 @@ class X393ExportC(object):
def
_enc_gamma_ctl
(
self
):
dw
=
[]
dw
.
append
((
"bayer"
,
0
,
2
,
0
,
"Bayer color shift (pixel to gamma table)"
))
dw
.
append
((
"page"
,
2
,
1
,
0
,
"Table page (only available if SENS_GAMMA_BUFFER in Verilog)"
))
dw
.
append
((
"en"
,
3
,
1
,
1
,
"Enable module"
))
dw
.
append
((
"repet"
,
4
,
1
,
1
,
"Repetitive (normal) mode. Set 0 for testing of the single-frame mode"
))
dw
.
append
((
"trig"
,
5
,
1
,
0
,
"Single trigger used when repetitive mode is off (self clearing bit)"
))
dw
.
append
((
"bayer_set"
,
2
,
1
,
0
,
"Set 'bayer' field"
))
dw
.
append
((
"page"
,
3
,
1
,
0
,
"Table page (only available if SENS_GAMMA_BUFFER in Verilog)"
))
dw
.
append
((
"page_set"
,
4
,
1
,
0
,
"Set 'page' field"
))
dw
.
append
((
"en"
,
5
,
1
,
1
,
"Enable module"
))
dw
.
append
((
"en_set"
,
6
,
1
,
1
,
"Set 'en' field"
))
dw
.
append
((
"repet"
,
7
,
1
,
1
,
"Repetitive (normal) mode. Set 0 for testing of the single-frame mode"
))
dw
.
append
((
"repet_set"
,
8
,
1
,
1
,
"Set 'repet' field"
))
dw
.
append
((
"trig"
,
9
,
1
,
0
,
"Single trigger used when repetitive mode is off (self clearing bit)"
))
return
dw
def
_enc_gamma_tbl_addr
(
self
):
...
...
py393/x393_sensor.py
View file @
0631243b
...
...
@@ -457,11 +457,11 @@ class X393Sensor(object):
return
rslt
def
func_sensor_gamma_ctl
(
self
,
bayer
=
0
,
table_page
=
0
,
en_input
=
Tru
e
,
repet_mode
=
Tru
e
,
# Normal mode, single trigger - just for debugging TODO: re-assign?
trig
=
False
):
bayer
=
None
,
table_page
=
None
,
en_input
=
Non
e
,
repet_mode
=
Non
e
,
# Normal mode, single trigger - just for debugging TODO: re-assign?
trig
=
False
):
"""
@param bayer - Bayer shift (0..3)
@param table_page - Gamma table page
...
...
@@ -471,10 +471,22 @@ class X393Sensor(object):
@return combined control word
"""
rslt
=
0
rslt
|=
(
bayer
&
3
)
<<
vrlg
.
SENS_GAMMA_MODE_BAYER
rslt
|=
(
0
,
1
)[
table_page
]
<<
vrlg
.
SENS_GAMMA_MODE_PAGE
rslt
|=
(
0
,
1
)[
en_input
]
<<
vrlg
.
SENS_GAMMA_MODE_EN
rslt
|=
(
0
,
1
)[
repet_mode
]
<<
vrlg
.
SENS_GAMMA_MODE_REPET
if
not
bayer
is
None
:
rslt
|=
(
bayer
&
3
)
<<
vrlg
.
SENS_GAMMA_MODE_BAYER
rslt
|=
1
<<
vrlg
.
SENS_GAMMA_MODE_BAYER_SET
if
not
table_page
is
None
:
rslt
|=
(
0
,
1
)[
table_page
]
<<
vrlg
.
SENS_GAMMA_MODE_PAGE
rslt
|=
1
<<
vrlg
.
SENS_GAMMA_MODE_PAGE_SET
if
not
en_input
is
None
:
rslt
|=
(
0
,
1
)[
en_input
]
<<
vrlg
.
SENS_GAMMA_MODE_EN
rslt
|=
1
<<
vrlg
.
SENS_GAMMA_MODE_EN_SET
if
not
repet_mode
is
None
:
rslt
|=
(
0
,
1
)[
repet_mode
]
<<
vrlg
.
SENS_GAMMA_MODE_REPET
rslt
|=
1
<<
vrlg
.
SENS_GAMMA_MODE_REPET_SET
rslt
|=
(
0
,
1
)[
trig
]
<<
vrlg
.
SENS_GAMMA_MODE_TRIG
return
rslt
...
...
sensor/sens_gamma.v
View file @
0631243b
...
...
@@ -48,12 +48,26 @@ module sens_gamma #(
parameter
SENS_GAMMA_ADDR_DATA
=
'h1
,
// bit 20 ==1 - table address, bit 20==0 - table data (18 bits)
parameter
SENS_GAMMA_HEIGHT01
=
'h2
,
// bits [15:0] - height minus 1 of image 0, [31:16] - height-1 of image1
parameter
SENS_GAMMA_HEIGHT2
=
'h3
,
// bits [15:0] - height minus 1 of image 2 ( no need for image 3)
parameter
SENS_GAMMA_MODE_WIDTH
=
5
,
// does not include trig
parameter
SENS_GAMMA_MODE_BAYER
=
0
,
parameter
SENS_GAMMA_MODE_PAGE
=
2
,
parameter
SENS_GAMMA_MODE_EN
=
3
,
parameter
SENS_GAMMA_MODE_REPET
=
4
,
parameter
SENS_GAMMA_MODE_TRIG
=
5
,
// parameter SENS_GAMMA_MODE_WIDTH = 5, // does not include trig
// parameter SENS_GAMMA_MODE_BAYER = 0,
// parameter SENS_GAMMA_MODE_PAGE = 2,
// parameter SENS_GAMMA_MODE_EN = 3,
// parameter SENS_GAMMA_MODE_REPET = 4,
// parameter SENS_GAMMA_MODE_TRIG = 5,
parameter
SENS_GAMMA_MODE_BAYER
=
0
,
parameter
SENS_GAMMA_MODE_BAYER_SET
=
2
,
parameter
SENS_GAMMA_MODE_PAGE
=
3
,
parameter
SENS_GAMMA_MODE_PAGE_SET
=
4
,
parameter
SENS_GAMMA_MODE_EN
=
5
,
parameter
SENS_GAMMA_MODE_EN_SET
=
6
,
parameter
SENS_GAMMA_MODE_REPET
=
7
,
parameter
SENS_GAMMA_MODE_REPET_SET
=
8
,
parameter
SENS_GAMMA_MODE_TRIG
=
9
,
parameter
[
1
:
0
]
XOR_GAMMA_BAYER
=
2'b11
// invert bayer setting - just for gamma tables (to match 353)
)
(
...
...
@@ -104,17 +118,22 @@ module sens_gamma #(
reg
[
17
:
0
]
tdata
;
// wire set_taddr_data_w;
reg
[
12
:
0
]
taddr
;
// two high bits - select channnel (in buffered mode), in non-buffered - 1 bit less, only 10 bits each table
reg
[
SENS_GAMMA_MODE_WIDTH
-
1
:
0
]
mode
=
0
;
reg
[
SENS_GAMMA_MODE_WIDTH
-
1
:
0
]
mode_mclk
=
0
;
//
reg [SENS_GAMMA_MODE_WIDTH-1:0] mode=0;
//
reg [SENS_GAMMA_MODE_WIDTH-1:0] mode_mclk=0;
reg
[
15
:
0
]
height0_m1
;
// set @ posedge mclk, used at pclk, but should be OK
reg
[
15
:
0
]
height1_m1
;
reg
[
15
:
0
]
height2_m1
;
wire
[
1
:
0
]
bayer
;
wire
table_page
;
//part of the mode register
wire
en_input
;
wire
repet_mode
;
reg
[
1
:
0
]
bayer
;
reg
table_page
;
//part of the mode register
reg
en_input
;
reg
repet_mode
;
reg
[
1
:
0
]
bayer_mclk
;
reg
table_page_mclk
;
reg
en_input_mclk
;
reg
repet_mode_mclk
;
reg
[
1
:
0
]
sensor_subchn
;
// select sensor from the multiplexed ones
reg
sof_r
;
...
...
@@ -196,10 +215,10 @@ module sens_gamma #(
(
ram_chn_d2
[
0
]
?
table_rdata1
:
table_rdata0
)
;
// assign {table_diff_w[7:0],table_base_w[9:0]} = table_rdata;
assign
bayer
=
mode
[
SENS_GAMMA_MODE_BAYER
+:
2
]
;
assign
table_page
=
mode
[
SENS_GAMMA_MODE_PAGE
]
;
// TODO: re-assign?
assign
en_input
=
mode
[
SENS_GAMMA_MODE_EN
]
;
assign
repet_mode
=
mode
[
SENS_GAMMA_MODE_REPET
]
;
// TODO: re-assign?
//
assign bayer = mode[SENS_GAMMA_MODE_BAYER +: 2];
//
assign table_page = mode[SENS_GAMMA_MODE_PAGE]; // TODO: re-assign?
//
assign en_input = mode[SENS_GAMMA_MODE_EN];
//
assign repet_mode = mode[SENS_GAMMA_MODE_REPET]; // TODO: re-assign?
//AF2015 assign sync_bayer=hact_d[1] && ~hact_d[2];
assign
interp_data
[
9
:
0
]
=
table_base_r
[
9
:
0
]
+
table_mult_r
[
17
:
8
]
+
table_mult_r
[
7
]
;
//round
...
...
@@ -224,8 +243,20 @@ module sens_gamma #(
else
if
(
set_taddr_w
)
taddr
<=
cmd_data
[
12
:
0
]
;
else
if
(
set_tdata_r
)
taddr
<=
taddr
+
1
;
if
(
mrst
)
mode_mclk
<=
0
;
else
if
(
set_ctrl_w
)
mode_mclk
<=
cmd_data
[
SENS_GAMMA_MODE_WIDTH
-
1
:
0
]
;
// if (mrst) mode_mclk <= 0;
// else if (set_ctrl_w) mode_mclk <= cmd_data[SENS_GAMMA_MODE_WIDTH-1:0];
if
(
mrst
)
bayer_mclk
<=
0
;
else
if
(
set_ctrl_w
&&
cmd_data
[
SENS_GAMMA_MODE_BAYER_SET
])
bayer_mclk
<=
cmd_data
[
SENS_GAMMA_MODE_BAYER
+:
2
]
;
if
(
mrst
)
table_page_mclk
<=
0
;
else
if
(
set_ctrl_w
&&
cmd_data
[
SENS_GAMMA_MODE_PAGE_SET
])
table_page_mclk
<=
cmd_data
[
SENS_GAMMA_MODE_PAGE
]
;
if
(
mrst
)
en_input_mclk
<=
0
;
else
if
(
set_ctrl_w
&&
cmd_data
[
SENS_GAMMA_MODE_EN_SET
])
en_input_mclk
<=
cmd_data
[
SENS_GAMMA_MODE_EN
]
;
if
(
mrst
)
repet_mode_mclk
<=
0
;
else
if
(
set_ctrl_w
&&
cmd_data
[
SENS_GAMMA_MODE_REPET_SET
])
repet_mode_mclk
<=
cmd_data
[
SENS_GAMMA_MODE_REPET
]
;
if
(
mrst
)
set_tdata_ram
<=
0
;
else
set_tdata_ram
<=
{
4
{
set_tdata_w
}}
&
...
...
@@ -247,7 +278,12 @@ module sens_gamma #(
always
@
(
posedge
pclk
)
begin
if
(
prst
)
begin
mode
<=
0
;
// mode <= 0;
bayer
<=
0
;
table_page
<=
0
;
en_input
<=
0
;
repet_mode
<=
0
;
hact_d
<=
0
;
// bayer_nset <= 0;
// bayer0_latched <= 0;
...
...
@@ -258,7 +294,12 @@ module sens_gamma #(
frame_run
<=
0
;
end
else
begin
mode
<=
mode_mclk
;
// mode <= mode_mclk;
bayer
<=
bayer_mclk
;
table_page
<=
table_page_mclk
;
en_input
<=
en_input_mclk
;
repet_mode
<=
repet_mode_mclk
;
hact_d
<=
{
hact_d
[
4
:
0
]
,
hact_in
};
// bayer_nset <= frame_run && (bayer_nset || hact_in);
// bayer0_latched <= bayer_nset? bayer0_latched : bayer[0];
...
...
sensor/sens_histogram.v
View file @
0631243b
...
...
@@ -61,7 +61,7 @@ module sens_histogram #(
input
eof
,
input
hact
,
input
[
7
:
0
]
hist_di
,
// 8-bit pixel data
input
[
1
:
0
]
bayer
,
input
mclk
,
input
hist_en
,
// @mclk - gracefully enable/disable histogram
input
hist_rst
,
// @mclk - immediately disable if true
...
...
@@ -277,10 +277,10 @@ module sens_histogram #(
if
(
monochrome_pclk
)
bayer_pclk
[
1
]
<=
0
;
else
if
(
!
hact
&&
hact_d
[
0
])
bayer_pclk
[
1
]
<=
!
bayer_pclk
[
1
]
;
else
if
(
pre_first_line
&&
!
hact
)
bayer_pclk
[
1
]
<=
XOR_HIST_BAYER
[
1
]
;
else
if
(
pre_first_line
&&
!
hact
)
bayer_pclk
[
1
]
<=
XOR_HIST_BAYER
[
1
]
^
bayer
[
1
]
;
if
(
monochrome_pclk
)
bayer_pclk
[
0
]
<=
0
;
else
if
(
!
hact
)
bayer_pclk
[
0
]
<=
XOR_HIST_BAYER
[
0
]
;
else
if
(
!
hact
)
bayer_pclk
[
0
]
<=
XOR_HIST_BAYER
[
0
]
^
bayer
[
0
]
;
else
bayer_pclk
[
0
]
<=
~
bayer_pclk
[
0
]
;
end
...
...
sensor/sens_histogram_snglclk.v
View file @
0631243b
...
...
@@ -60,7 +60,7 @@ module sens_histogram_snglclk #(
input
eof
,
input
hact
,
input
[
7
:
0
]
hist_di
,
// 8-bit pixel data
input
[
1
:
0
]
bayer
,
input
mclk
,
input
hist_en
,
// @mclk - gracefully enable/disable histogram
input
hist_rst
,
// @mclk - immediately disable if true
...
...
@@ -232,9 +232,9 @@ module sens_histogram_snglclk #(
en_new
<=
!
hist_rst_pclk
&&
hist_en_pclk
;
if
(
!
hact
&&
hact_d
[
0
])
bayer_pclk
[
1
]
<=
!
bayer_pclk
[
1
]
;
else
if
(
pre_first_line
&&
!
hact
)
bayer_pclk
[
1
]
<=
XOR_HIST_BAYER
[
1
]
;
else
if
(
pre_first_line
&&
!
hact
)
bayer_pclk
[
1
]
<=
XOR_HIST_BAYER
[
1
]
^
bayer
[
1
]
;
if
(
!
hact
)
bayer_pclk
[
0
]
<=
XOR_HIST_BAYER
[
0
]
;
if
(
!
hact
)
bayer_pclk
[
0
]
<=
XOR_HIST_BAYER
[
0
]
^
bayer
[
0
]
;
else
bayer_pclk
[
0
]
<=
~
bayer_pclk
[
0
]
;
end
...
...
@@ -281,12 +281,12 @@ module sens_histogram_snglclk #(
if
(
!
hist_en_pclk
||
!
(
|
hor_woi
))
odd_pix
<=
0
;
else
odd_pix
<=
~
odd_pix
;
if
(
!
hist_en_pclk
||
!
((
XOR_HIST_BAYER
[
0
]
^
left
[
0
])
?
hor_woi
[
1
]
:
hor_woi
[
0
]))
memen_even
[
0
]
<=
0
;
if
(
!
hist_en_pclk
||
!
((
bayer
[
0
]
^
XOR_HIST_BAYER
[
0
]
^
left
[
0
])
?
hor_woi
[
1
]
:
hor_woi
[
0
]))
memen_even
[
0
]
<=
0
;
else
memen_even
[
0
]
<=
~
memen_even
[
0
]
;
memen_even
[
6
:
1
]
<=
memen_even
[
5
:
0
]
;
if
(
!
hist_en_pclk
||
!
((
XOR_HIST_BAYER
[
0
]
^
left
[
0
])
?
hor_woi
[
0
]
:
hor_woi
[
1
]))
memen_odd
[
0
]
<=
0
;
if
(
!
hist_en_pclk
||
!
((
bayer
[
0
]
^
XOR_HIST_BAYER
[
0
]
^
left
[
0
])
?
hor_woi
[
0
]
:
hor_woi
[
1
]))
memen_odd
[
0
]
<=
0
;
else
memen_odd
[
0
]
<=
~
memen_odd
[
0
]
;
memen_odd
[
6
:
1
]
<=
memen_odd
[
5
:
0
]
;
...
...
sensor/sensor_channel.v
View file @
0631243b
...
...
@@ -120,12 +120,15 @@ module sensor_channel#(
parameter
SENS_GAMMA_HEIGHT01
=
'h2
,
// bits [15:0] - height minus 1 of image 0, [31:16] - height-1 of image1
parameter
SENS_GAMMA_HEIGHT2
=
'h3
,
// bits [15:0] - height minus 1 of image 2 ( no need for image 3)
// bits of the SENS_GAMMA_CTRL mode register
parameter
SENS_GAMMA_MODE_WIDTH
=
5
,
// does not include trig
parameter
SENS_GAMMA_MODE_BAYER
=
0
,
parameter
SENS_GAMMA_MODE_PAGE
=
2
,
parameter
SENS_GAMMA_MODE_EN
=
3
,
parameter
SENS_GAMMA_MODE_REPET
=
4
,
parameter
SENS_GAMMA_MODE_TRIG
=
5
,
parameter
SENS_GAMMA_MODE_BAYER
=
0
,
parameter
SENS_GAMMA_MODE_BAYER_SET
=
2
,
parameter
SENS_GAMMA_MODE_PAGE
=
3
,
parameter
SENS_GAMMA_MODE_PAGE_SET
=
4
,
parameter
SENS_GAMMA_MODE_EN
=
5
,
parameter
SENS_GAMMA_MODE_EN_SET
=
6
,
parameter
SENS_GAMMA_MODE_REPET
=
7
,
parameter
SENS_GAMMA_MODE_REPET_SET
=
8
,
parameter
SENS_GAMMA_MODE_TRIG
=
9
,
// Vignetting correction / pixel value scaling - controlled via single data word (same as in 252), some of bits [23:16]
// are used to select register, bits 25:24 - select sub-frame
parameter
SENS_LENS_RADDR
=
'h3c
,
...
...
@@ -200,7 +203,8 @@ module sensor_channel#(
// sens_hist registers
parameter
HISTOGRAM_LEFT_TOP
=
'h0
,
parameter
HISTOGRAM_WIDTH_HEIGHT
=
'h1
,
// 1.. 2^16, 0 - use HACT
parameter
[
1
:
0
]
XOR_HIST_BAYER
=
2'b00
,
// invert bayer setting
//sensor_i2c_io other parameters
parameter
integer
SENSI2C_DRIVE
=
12
,
parameter
SENSI2C_IBUF_LOW_PWR
=
"TRUE"
,
...
...
@@ -1047,20 +1051,23 @@ module sensor_channel#(
)
;
sens_gamma
#(
.
SENS_NUM_SUBCHN
(
SENS_NUM_SUBCHN
)
,
.
SENS_GAMMA_BUFFER
(
SENS_GAMMA_BUFFER
)
,
.
SENS_GAMMA_ADDR
(
SENS_GAMMA_ADDR
)
,
.
SENS_GAMMA_ADDR_MASK
(
SENS_GAMMA_ADDR_MASK
)
,
.
SENS_GAMMA_CTRL
(
SENS_GAMMA_CTRL
)
,
.
SENS_GAMMA_ADDR_DATA
(
SENS_GAMMA_ADDR_DATA
)
,
.
SENS_GAMMA_HEIGHT01
(
SENS_GAMMA_HEIGHT01
)
,
.
SENS_GAMMA_HEIGHT2
(
SENS_GAMMA_HEIGHT2
)
,
.
SENS_GAMMA_MODE_WIDTH
(
SENS_GAMMA_MODE_WIDTH
)
,
.
SENS_GAMMA_MODE_BAYER
(
SENS_GAMMA_MODE_BAYER
)
,
.
SENS_GAMMA_MODE_PAGE
(
SENS_GAMMA_MODE_PAGE
)
,
.
SENS_GAMMA_MODE_EN
(
SENS_GAMMA_MODE_EN
)
,
.
SENS_GAMMA_MODE_REPET
(
SENS_GAMMA_MODE_REPET
)
,
.
SENS_GAMMA_MODE_TRIG
(
SENS_GAMMA_MODE_TRIG
)
.
SENS_NUM_SUBCHN
(
SENS_NUM_SUBCHN
)
,
.
SENS_GAMMA_BUFFER
(
SENS_GAMMA_BUFFER
)
,
.
SENS_GAMMA_ADDR
(
SENS_GAMMA_ADDR
)
,
.
SENS_GAMMA_ADDR_MASK
(
SENS_GAMMA_ADDR_MASK
)
,
.
SENS_GAMMA_CTRL
(
SENS_GAMMA_CTRL
)
,
.
SENS_GAMMA_ADDR_DATA
(
SENS_GAMMA_ADDR_DATA
)
,
.
SENS_GAMMA_HEIGHT01
(
SENS_GAMMA_HEIGHT01
)
,
.
SENS_GAMMA_HEIGHT2
(
SENS_GAMMA_HEIGHT2
)
,
.
SENS_GAMMA_MODE_BAYER
(
SENS_GAMMA_MODE_BAYER
)
,
.
SENS_GAMMA_MODE_BAYER_SET
(
SENS_GAMMA_MODE_BAYER_SET
)
,
.
SENS_GAMMA_MODE_PAGE
(
SENS_GAMMA_MODE_PAGE
)
,
.
SENS_GAMMA_MODE_PAGE_SET
(
SENS_GAMMA_MODE_PAGE_SET
)
,
.
SENS_GAMMA_MODE_EN
(
SENS_GAMMA_MODE_EN
)
,
.
SENS_GAMMA_MODE_EN_SET
(
SENS_GAMMA_MODE_EN_SET
)
,
.
SENS_GAMMA_MODE_REPET
(
SENS_GAMMA_MODE_REPET
)
,
.
SENS_GAMMA_MODE_REPET_SET
(
SENS_GAMMA_MODE_REPET_SET
)
,
.
SENS_GAMMA_MODE_TRIG
(
SENS_GAMMA_MODE_TRIG
)
)
sens_gamma_i
(
// .rst (rst), // input
.
pclk
(
pclk
)
,
// input
...
...
@@ -1091,12 +1098,13 @@ module sensor_channel#(
.
HISTOGRAM_ADDR
(
HISTOGRAM_ADDR0
)
,
.
HISTOGRAM_ADDR_MASK
(
HISTOGRAM_ADDR_MASK
)
,
.
HISTOGRAM_LEFT_TOP
(
HISTOGRAM_LEFT_TOP
)
,
.
HISTOGRAM_WIDTH_HEIGHT
(
HISTOGRAM_WIDTH_HEIGHT
)
.
HISTOGRAM_WIDTH_HEIGHT
(
HISTOGRAM_WIDTH_HEIGHT
)
,
.
XOR_HIST_BAYER
(
XOR_HIST_BAYER
)
`ifdef
DEBUG_RING
,.
DEBUG_CMD_LATENCY
(
DEBUG_CMD_LATENCY
)
`endif
)
sens_histogram_0_i
(
.
mrst
(
mrst
)
,
// input
.
mrst
(
mrst
)
,
// input
.
prst
(
prsts
)
,
// input extended to include sensor reset and rst_mmcm
.
pclk
(
pclk
)
,
// input
.
pclk2x
(
pclk2x
)
,
// input
...
...
@@ -1104,6 +1112,7 @@ module sensor_channel#(
.
eof
(
gamma_eof_out
)
,
// input
.
hact
(
gamma_hact_out
)
,
// input
.
hist_di
(
gamma_pxd_out
)
,
// input[7:0]
.
bayer
(
gamma_bayer
)
,
// input[1:0]
.
mclk
(
mclk
)
,
// input
.
hist_en
(
hist_en
[
0
])
,
// input
.
hist_rst
(
!
hist_nrst
[
0
])
,
// input
...
...
@@ -1139,7 +1148,8 @@ module sensor_channel#(
.
HISTOGRAM_ADDR
(
HISTOGRAM_ADDR0
)
,
.
HISTOGRAM_ADDR_MASK
(
HISTOGRAM_ADDR_MASK
)
,
.
HISTOGRAM_LEFT_TOP
(
HISTOGRAM_LEFT_TOP
)
,
.
HISTOGRAM_WIDTH_HEIGHT
(
HISTOGRAM_WIDTH_HEIGHT
)
.
HISTOGRAM_WIDTH_HEIGHT
(
HISTOGRAM_WIDTH_HEIGHT
)
,
.
XOR_HIST_BAYER
(
XOR_HIST_BAYER
)
`ifdef
DEBUG_RING
,.
DEBUG_CMD_LATENCY
(
DEBUG_CMD_LATENCY
)
`endif
...
...
@@ -1150,7 +1160,8 @@ module sensor_channel#(
.
sof
(
gamma_sof_out
)
,
// input
.
eof
(
gamma_eof_out
)
,
// input
.
hact
(
gamma_hact_out
)
,
// input
.
hist_di
(
gamma_pxd_out
)
,
// input[7:0]
.
hist_di
(
gamma_pxd_out
)
,
// input[7:0]
.
bayer
(
gamma_bayer
)
,
// input[1:0]
.
mclk
(
mclk
)
,
// input
.
hist_en
(
hist_en
[
0
])
,
// input
.
hist_rst
(
!
hist_nrst
[
0
])
,
// input
...
...
@@ -1190,7 +1201,8 @@ module sensor_channel#(
.
HISTOGRAM_ADDR
(
HISTOGRAM_ADDR1
)
,
.
HISTOGRAM_ADDR_MASK
(
HISTOGRAM_ADDR_MASK
)
,
.
HISTOGRAM_LEFT_TOP
(
HISTOGRAM_LEFT_TOP
)
,
.
HISTOGRAM_WIDTH_HEIGHT
(
HISTOGRAM_WIDTH_HEIGHT
)
.
HISTOGRAM_WIDTH_HEIGHT
(
HISTOGRAM_WIDTH_HEIGHT
)
,
.
XOR_HIST_BAYER
(
XOR_HIST_BAYER
)
`ifdef
DEBUG_RING
,.
DEBUG_CMD_LATENCY
(
DEBUG_CMD_LATENCY
)
`endif
...
...
@@ -1202,7 +1214,8 @@ module sensor_channel#(
.
sof
(
gamma_sof_out
)
,
// input
.
eof
(
gamma_eof_out
)
,
// input
.
hact
(
gamma_hact_out
)
,
// input
.
hist_di
(
gamma_pxd_out
)
,
// input[7:0]
.
hist_di
(
gamma_pxd_out
)
,
// input[7:0]
.
bayer
(
gamma_bayer
)
,
// input[1:0]
.
mclk
(
mclk
)
,
// input
.
hist_en
(
hist_en
[
1
])
,
// input
.
hist_rst
(
!
hist_nrst
[
1
])
,
// input
...
...
@@ -1236,7 +1249,8 @@ module sensor_channel#(
.
HISTOGRAM_ADDR
(
HISTOGRAM_ADDR1
)
,
.
HISTOGRAM_ADDR_MASK
(
HISTOGRAM_ADDR_MASK
)
,
.
HISTOGRAM_LEFT_TOP
(
HISTOGRAM_LEFT_TOP
)
,
.
HISTOGRAM_WIDTH_HEIGHT
(
HISTOGRAM_WIDTH_HEIGHT
)
.
HISTOGRAM_WIDTH_HEIGHT
(
HISTOGRAM_WIDTH_HEIGHT
)
,
.
XOR_HIST_BAYER
(
XOR_HIST_BAYER
)
`ifdef
DEBUG_RING
,.
DEBUG_CMD_LATENCY
(
DEBUG_CMD_LATENCY
)
`endif
...
...
@@ -1247,7 +1261,8 @@ module sensor_channel#(
.
sof
(
gamma_sof_out
)
,
// input
.
eof
(
gamma_eof_out
)
,
// input
.
hact
(
gamma_hact_out
)
,
// input
.
hist_di
(
gamma_pxd_out
)
,
// input[7:0]
.
hist_di
(
gamma_pxd_out
)
,
// input[7:0]
.
bayer
(
gamma_bayer
)
,
// input[1:0]
.
mclk
(
mclk
)
,
// input
.
hist_en
(
hist_en
[
1
])
,
// input
.
hist_rst
(
!
hist_nrst
[
1
])
,
// input
...
...
@@ -1285,7 +1300,8 @@ module sensor_channel#(
.
HISTOGRAM_ADDR
(
HISTOGRAM_ADDR2
)
,
.
HISTOGRAM_ADDR_MASK
(
HISTOGRAM_ADDR_MASK
)
,
.
HISTOGRAM_LEFT_TOP
(
HISTOGRAM_LEFT_TOP
)
,
.
HISTOGRAM_WIDTH_HEIGHT
(
HISTOGRAM_WIDTH_HEIGHT
)
.
HISTOGRAM_WIDTH_HEIGHT
(
HISTOGRAM_WIDTH_HEIGHT
)
,
.
XOR_HIST_BAYER
(
XOR_HIST_BAYER
)
`ifdef
DEBUG_RING
,.
DEBUG_CMD_LATENCY
(
DEBUG_CMD_LATENCY
)
`endif
...
...
@@ -1297,7 +1313,8 @@ module sensor_channel#(
.
sof
(
gamma_sof_out
)
,
// input
.
eof
(
gamma_eof_out
)
,
// input
.
hact
(
gamma_hact_out
)
,
// input
.
hist_di
(
gamma_pxd_out
)
,
// input[7:0]
.
hist_di
(
gamma_pxd_out
)
,
// input[7:0]
.
bayer
(
gamma_bayer
)
,
// input[1:0]
.
mclk
(
mclk
)
,
// input
.
hist_en
(
hist_en
[
2
])
,
// input
.
hist_rst
(
!
hist_nrst
[
2
])
,
// input
...
...
@@ -1331,7 +1348,8 @@ module sensor_channel#(
.
HISTOGRAM_ADDR
(
HISTOGRAM_ADDR2
)
,
.
HISTOGRAM_ADDR_MASK
(
HISTOGRAM_ADDR_MASK
)
,
.
HISTOGRAM_LEFT_TOP
(
HISTOGRAM_LEFT_TOP
)
,
.
HISTOGRAM_WIDTH_HEIGHT
(
HISTOGRAM_WIDTH_HEIGHT
)
.
HISTOGRAM_WIDTH_HEIGHT
(
HISTOGRAM_WIDTH_HEIGHT
)
,
.
XOR_HIST_BAYER
(
XOR_HIST_BAYER
)
`ifdef
DEBUG_RING
,.
DEBUG_CMD_LATENCY
(
DEBUG_CMD_LATENCY
)
`endif
...
...
@@ -1342,7 +1360,8 @@ module sensor_channel#(
.
sof
(
gamma_sof_out
)
,
// input
.
eof
(
gamma_eof_out
)
,
// input
.
hact
(
gamma_hact_out
)
,
// input
.
hist_di
(
gamma_pxd_out
)
,
// input[7:0]
.
hist_di
(
gamma_pxd_out
)
,
// input[7:0]
.
bayer
(
gamma_bayer
)
,
// input[1:0]
.
mclk
(
mclk
)
,
// input
.
hist_en
(
hist_en
[
2
])
,
// input
.
hist_rst
(
!
hist_nrst
[
2
])
,
// input
...
...
@@ -1380,7 +1399,8 @@ module sensor_channel#(
.
HISTOGRAM_ADDR
(
HISTOGRAM_ADDR3
)
,
.
HISTOGRAM_ADDR_MASK
(
HISTOGRAM_ADDR_MASK
)
,
.
HISTOGRAM_LEFT_TOP
(
HISTOGRAM_LEFT_TOP
)
,
.
HISTOGRAM_WIDTH_HEIGHT
(
HISTOGRAM_WIDTH_HEIGHT
)
.
HISTOGRAM_WIDTH_HEIGHT
(
HISTOGRAM_WIDTH_HEIGHT
)
,
.
XOR_HIST_BAYER
(
XOR_HIST_BAYER
)
`ifdef
DEBUG_RING
,.
DEBUG_CMD_LATENCY
(
DEBUG_CMD_LATENCY
)
`endif
...
...
@@ -1392,7 +1412,8 @@ module sensor_channel#(
.
sof
(
gamma_sof_out
)
,
// input
.
eof
(
gamma_eof_out
)
,
// input
.
hact
(
gamma_hact_out
)
,
// input
.
hist_di
(
gamma_pxd_out
)
,
// input[7:0]
.
hist_di
(
gamma_pxd_out
)
,
// input[7:0]
.
bayer
(
gamma_bayer
)
,
// input[1:0]
.
mclk
(
mclk
)
,
// input
.
hist_en
(
hist_en
[
3
])
,
// input
.
hist_rst
(
!
hist_nrst
[
3
])
,
// input
...
...
@@ -1427,7 +1448,8 @@ module sensor_channel#(
.
HISTOGRAM_ADDR
(
HISTOGRAM_ADDR3
)
,
.
HISTOGRAM_ADDR_MASK
(
HISTOGRAM_ADDR_MASK
)
,
.
HISTOGRAM_LEFT_TOP
(
HISTOGRAM_LEFT_TOP
)
,
.
HISTOGRAM_WIDTH_HEIGHT
(
HISTOGRAM_WIDTH_HEIGHT
)
.
HISTOGRAM_WIDTH_HEIGHT
(
HISTOGRAM_WIDTH_HEIGHT
)
,
.
XOR_HIST_BAYER
(
XOR_HIST_BAYER
)
`ifdef
DEBUG_RING
,.
DEBUG_CMD_LATENCY
(
DEBUG_CMD_LATENCY
)
`endif
...
...
@@ -1438,7 +1460,8 @@ module sensor_channel#(
.
sof
(
gamma_sof_out
)
,
// input
.
eof
(
gamma_eof_out
)
,
// input
.
hact
(
gamma_hact_out
)
,
// input
.
hist_di
(
gamma_pxd_out
)
,
// input[7:0]
.
hist_di
(
gamma_pxd_out
)
,
// input[7:0]
.
bayer
(
gamma_bayer
)
,
// input[1:0]
.
mclk
(
mclk
)
,
// input
.
hist_en
(
hist_en
[
3
])
,
// input
.
hist_rst
(
!
hist_nrst
[
3
])
,
// input
...
...
sensor/sensors393.v
View file @
0631243b
...
...
@@ -119,12 +119,15 @@ module sensors393 #(
parameter
SENS_GAMMA_HEIGHT01
=
'h2
,
// bits [15:0] - height minus 1 of image 0, [31:16] - height-1 of image1
parameter
SENS_GAMMA_HEIGHT2
=
'h3
,
// bits [15:0] - height minus 1 of image 2 ( no need for image 3)
// bits of the SENS_GAMMA_CTRL mode register
parameter
SENS_GAMMA_MODE_WIDTH
=
5
,
// does not include trig
parameter
SENS_GAMMA_MODE_BAYER
=
0
,
parameter
SENS_GAMMA_MODE_PAGE
=
2
,
parameter
SENS_GAMMA_MODE_EN
=
3
,
parameter
SENS_GAMMA_MODE_REPET
=
4
,
parameter
SENS_GAMMA_MODE_TRIG
=
5
,
parameter
SENS_GAMMA_MODE_BAYER
=
0
,
parameter
SENS_GAMMA_MODE_BAYER_SET
=
2
,
parameter
SENS_GAMMA_MODE_PAGE
=
3
,
parameter
SENS_GAMMA_MODE_PAGE_SET
=
4
,
parameter
SENS_GAMMA_MODE_EN
=
5
,
parameter
SENS_GAMMA_MODE_EN_SET
=
6
,
parameter
SENS_GAMMA_MODE_REPET
=
7
,
parameter
SENS_GAMMA_MODE_REPET_SET
=
8
,
parameter
SENS_GAMMA_MODE_TRIG
=
9
,
// Vignetting correction / pixel value scaling - controlled via single data word (same as in 252), some of bits [23:16]
// are used to select register, bits 25:24 - select sub-frame
...
...
@@ -201,6 +204,7 @@ module sensors393 #(
parameter
HISTOGRAM_LEFT_TOP
=
'h0
,
parameter
HISTOGRAM_WIDTH_HEIGHT
=
'h1
,
// 1.. 2^16, 0 - use HACT
parameter
[
1
:
0
]
XOR_HIST_BAYER
=
2'b00
,
// 11 // invert bayer setting
//sensor_i2c_io other parameters
parameter
integer
SENSI2C_DRIVE
=
12
,
parameter
SENSI2C_IBUF_LOW_PWR
=
"TRUE"
,
...
...
@@ -527,11 +531,14 @@ module sensors393 #(
.
SENS_GAMMA_ADDR_DATA
(
SENS_GAMMA_ADDR_DATA
)
,
.
SENS_GAMMA_HEIGHT01
(
SENS_GAMMA_HEIGHT01
)
,
.
SENS_GAMMA_HEIGHT2
(
SENS_GAMMA_HEIGHT2
)
,
.
SENS_GAMMA_MODE_WIDTH
(
SENS_GAMMA_MODE_WIDTH
)
,
.
SENS_GAMMA_MODE_BAYER
(
SENS_GAMMA_MODE_BAYER
)
,
.
SENS_GAMMA_MODE_BAYER_SET
(
SENS_GAMMA_MODE_BAYER_SET
)
,
.
SENS_GAMMA_MODE_PAGE
(
SENS_GAMMA_MODE_PAGE
)
,
.
SENS_GAMMA_MODE_PAGE_SET
(
SENS_GAMMA_MODE_PAGE_SET
)
,
.
SENS_GAMMA_MODE_EN
(
SENS_GAMMA_MODE_EN
)
,
.
SENS_GAMMA_MODE_EN_SET
(
SENS_GAMMA_MODE_EN_SET
)
,
.
SENS_GAMMA_MODE_REPET
(
SENS_GAMMA_MODE_REPET
)
,
.
SENS_GAMMA_MODE_REPET_SET
(
SENS_GAMMA_MODE_REPET_SET
)
,
.
SENS_GAMMA_MODE_TRIG
(
SENS_GAMMA_MODE_TRIG
)
,
.
SENS_LENS_RADDR
(
SENS_LENS_RADDR
)
,
.
SENS_LENS_ADDR_MASK
(
SENS_LENS_ADDR_MASK
)
,
...
...
@@ -595,6 +602,7 @@ module sensors393 #(
.
HISTOGRAM_RADDR3
(
HISTOGRAM_RADDR3
)
,
.
HISTOGRAM_ADDR_MASK
(
HISTOGRAM_ADDR_MASK
)
,
.
HISTOGRAM_LEFT_TOP
(
HISTOGRAM_LEFT_TOP
)
,
.
XOR_HIST_BAYER
(
XOR_HIST_BAYER
)
,
.
HISTOGRAM_WIDTH_HEIGHT
(
HISTOGRAM_WIDTH_HEIGHT
)
,
.
SENSI2C_DRIVE
(
SENSI2C_DRIVE
)
,
.
SENSI2C_IBUF_LOW_PWR
(
SENSI2C_IBUF_LOW_PWR
)
,
...
...
x393.v
View file @
0631243b
...
...
@@ -1664,11 +1664,14 @@ assign axi_grst = axi_rst_pre;
.
SENS_GAMMA_ADDR_DATA
(
SENS_GAMMA_ADDR_DATA
)
,
.
SENS_GAMMA_HEIGHT01
(
SENS_GAMMA_HEIGHT01
)
,
.
SENS_GAMMA_HEIGHT2
(
SENS_GAMMA_HEIGHT2
)
,
.
SENS_GAMMA_MODE_WIDTH
(
SENS_GAMMA_MODE_WIDTH
)
,
.
SENS_GAMMA_MODE_BAYER
(
SENS_GAMMA_MODE_BAYER
)
,
.
SENS_GAMMA_MODE_BAYER_SET
(
SENS_GAMMA_MODE_BAYER_SET
)
,
.
SENS_GAMMA_MODE_PAGE
(
SENS_GAMMA_MODE_PAGE
)
,
.
SENS_GAMMA_MODE_PAGE_SET
(
SENS_GAMMA_MODE_PAGE_SET
)
,
.
SENS_GAMMA_MODE_EN
(
SENS_GAMMA_MODE_EN
)
,
.
SENS_GAMMA_MODE_EN_SET
(
SENS_GAMMA_MODE_EN_SET
)
,
.
SENS_GAMMA_MODE_REPET
(
SENS_GAMMA_MODE_REPET
)
,
.
SENS_GAMMA_MODE_REPET_SET
(
SENS_GAMMA_MODE_REPET_SET
)
,
.
SENS_GAMMA_MODE_TRIG
(
SENS_GAMMA_MODE_TRIG
)
,
.
SENS_LENS_RADDR
(
SENS_LENS_RADDR
)
,
.
SENS_LENS_ADDR_MASK
(
SENS_LENS_ADDR_MASK
)
,
...
...
@@ -1732,6 +1735,7 @@ assign axi_grst = axi_rst_pre;
.
HISTOGRAM_ADDR_MASK
(
HISTOGRAM_ADDR_MASK
)
,
.
HISTOGRAM_LEFT_TOP
(
HISTOGRAM_LEFT_TOP
)
,
.
HISTOGRAM_WIDTH_HEIGHT
(
HISTOGRAM_WIDTH_HEIGHT
)
,
.
XOR_HIST_BAYER
(
XOR_HIST_BAYER
)
,
.
SENSI2C_DRIVE
(
SENSI2C_DRIVE
)
,
.
SENSI2C_IBUF_LOW_PWR
(
SENSI2C_IBUF_LOW_PWR
)
,
.
SENSI2C_IOSTANDARD
(
SENSI2C_IOSTANDARD
)
,
...
...
x393_testbench03.tf
View file @
0631243b
...
...
@@ -3269,13 +3269,22 @@ task setup_sensor_channel;
TEST_TITLE = "GAMMA_CTL";
$display("===================== TEST_%s =========================",TEST_TITLE);
set_sensor_gamma_ctl (// doing last to enable sensor data when everything else is set up
num_sensor, // input [1:0] num_sensor; // sensor channel number (0..3)
2'h0, // 2'h3, // input [1:0] bayer; // bayer shift (0..3)
0, // input table_page; // table page (only used if SENS_GAMMA_BUFFER)
1'b1, // input en_input; // enable channel input
1'b1, // input repet_mode; // Normal mode, single trigger - just for debugging
1'b0); // input trig; // pass next frame
set_sensor_gamma_ctl_bayer (// doing last to enable sensor data when everything else is set up
num_sensor, // input [1:0] num_sensor; // sensor channel number (0..3)
2'h0); // 2'h3, // input [1:0] bayer; // bayer shift (0..3)
set_sensor_gamma_ctl_page (// doing last to enable sensor data when everything else is set up
num_sensor, // input [1:0] num_sensor; // sensor channel number (0..3)
0); // input table_page; // table page (only used if SENS_GAMMA_BUFFER)
set_sensor_gamma_ctl_en_input (// doing last to enable sensor data when everything else is set up
num_sensor, // input [1:0] num_sensor; // sensor channel number (0..3)
1'b1); // input en_input; // enable channel input
set_sensor_gamma_ctl_repet (// doing last to enable sensor data when everything else is set up
num_sensor, // input [1:0] num_sensor; // sensor channel number (0..3)
1'b1); // input repet_mode; // Normal mode, single trigger - just for debugging
set_sensor_gamma_ctl_trig (// doing last to enable sensor data when everything else is set up
num_sensor, // input [1:0] num_sensor; // sensor channel number (0..3)
1'b0); // input trig; // pass next frame
// temporarily putting in the very end as it takes about 30 usec to program curves (TODO: see how to make it faster for simulation)
end
endtask // setup_sensor_channel
...
...
@@ -4269,28 +4278,64 @@ task set_sensor_gamma_heights;
endtask
// x393_sensor.py
task set_sensor_gamma_ctl;
task set_sensor_gamma_ctl
_bayer
;
input [1:0] num_sensor; // sensor channel number (0..3)
input [1:0] bayer; // bayer shift (0..3)
reg [31:0] data;
reg [29:0] reg_addr;
begin
data = {{32-3{1'b0}},1'b1,bayer};
reg_addr = (SENSOR_GROUP_ADDR + num_sensor * SENSOR_BASE_INC) + SENS_GAMMA_RADDR + SENS_GAMMA_CTRL;
write_contol_register(reg_addr, data);
end
endtask
task set_sensor_gamma_ctl_page;
input [1:0] num_sensor; // sensor channel number (0..3)
input table_page; // table page (only used if SENS_GAMMA_BUFFER)
reg [31:0] data;
reg [29:0] reg_addr;
begin
data = {{32-5{1'b0}},1'b1,table_page,3'b0};
reg_addr = (SENSOR_GROUP_ADDR + num_sensor * SENSOR_BASE_INC) + SENS_GAMMA_RADDR + SENS_GAMMA_CTRL;
write_contol_register(reg_addr, data);
end
endtask
task set_sensor_gamma_ctl_en_input;
input [1:0] num_sensor; // sensor channel number (0..3)
input en_input; // enable channel input
reg [31:0] data;
reg [29:0] reg_addr;
begin
data = {{32-7{1'b0}},1'b1,en_input,5'b0};
reg_addr = (SENSOR_GROUP_ADDR + num_sensor * SENSOR_BASE_INC) + SENS_GAMMA_RADDR + SENS_GAMMA_CTRL;
write_contol_register(reg_addr, data);
end
endtask
task set_sensor_gamma_ctl_repet;
input [1:0] num_sensor; // sensor channel number (0..3)
input repet_mode; // Normal mode, single trigger - just for debugging
input trig; // pass next frame
reg [31:0] data;
reg [29:0] reg_addr;
begin
data = {{32-9{1'b0}},1'b1,repet_mode,7'b0};
reg_addr = (SENSOR_GROUP_ADDR + num_sensor * SENSOR_BASE_INC) + SENS_GAMMA_RADDR + SENS_GAMMA_CTRL;
write_contol_register(reg_addr, data);
end
endtask
task set_sensor_gamma_ctl_trig;
input [1:0] num_sensor; // sensor channel number (0..3)
input trig; // pass next frame
reg [31:0] data;
reg [29:0] reg_addr;
begin
data = func_sensor_gamma_ctl (
bayer,
table_page,
en_input,
repet_mode,
trig);
data = {{32-10{1'b0}},trig,9'b0};
reg_addr = (SENSOR_GROUP_ADDR + num_sensor * SENSOR_BASE_INC) + SENS_GAMMA_RADDR + SENS_GAMMA_CTRL;
write_contol_register(reg_addr, data);
end
endtask
// x393_sensor.py
...
...
@@ -4629,24 +4674,6 @@ function [31 : 0] func_sensor_jtag_ctl;
endfunction
// x393_sensor.py
function [31 : 0] func_sensor_gamma_ctl;
input [1:0] bayer;
input table_page;
input en_input;
input repet_mode; // Normal mode, single trigger - just for debugging TODO: re-assign?
input trig;
reg [31 : 0] tmp;
begin
tmp = 0;
tmp[SENS_GAMMA_MODE_BAYER +: 2] = bayer;
tmp [SENS_GAMMA_MODE_PAGE] = table_page;
tmp [SENS_GAMMA_MODE_EN] = en_input;
tmp [SENS_GAMMA_MODE_REPET] = repet_mode;
tmp [SENS_GAMMA_MODE_TRIG] = trig;
func_sensor_gamma_ctl = tmp;
end
endfunction
// ****************** compressor related tasks and functions *************************
// x393_cmprs.py
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment