Commit baf9eed0 authored by Andrey Filippov's avatar Andrey Filippov

More tests with 4 sesnor and 4 compressor channels, turned off debug ring define

parent 514c0372
...@@ -4,6 +4,7 @@ syntax_* ...@@ -4,6 +4,7 @@ syntax_*
simulation/* simulation/*
ise_* ise_*
attic/* attic/*
hardware_tests/*
IVERILOG_INCLUDE.v IVERILOG_INCLUDE.v
x393.prj x393.prj
*DEBUG_VDT* *DEBUG_VDT*
...@@ -13,14 +14,16 @@ x393.prj ...@@ -13,14 +14,16 @@ x393.prj
*.pickle *.pickle
py393/dbg/* py393/dbg/*
includes/x393_cur_params_sim.vh includes/x393_cur_params_sim.vh
includes/x393_cur_params_target_gen.vh includes/x393_cur_params_target_*.vh
py393/exp_gpio.py py393/exp_gpio.py
py393/mon_gpio.py py393/mon_gpio.py
savefile01.sav savefile01.sav
x353 x353
compressor_jp/huff_fifo353.v
x393_testbench0-a1.sav x393_testbench0-a1.sav
x393_testbench01-*.sav x393_testbench01-*.sav
x393_testbench01.gtkw x393_testbench01.gtkw
x393_testbench01_backup.sav x393_testbench01_backup.sav
x393_testbench01_debug_membridge.sav x393_testbench01_debug_membridge.sav
x393_testbench02.sav x393_testbench02.sav
x393_testbench02-0.sav
...@@ -62,42 +62,42 @@ ...@@ -62,42 +62,42 @@
<link> <link>
<name>vivado_logs/VivadoBitstream.log</name> <name>vivado_logs/VivadoBitstream.log</name>
<type>1</type> <type>1</type>
<location>/home/andrey/git/x393/vivado_logs/VivadoBitstream-20150915011906545.log</location> <location>/home/andrey/git/x393/vivado_logs/VivadoBitstream-20150916155306201.log</location>
</link> </link>
<link> <link>
<name>vivado_logs/VivadoOpt.log</name> <name>vivado_logs/VivadoOpt.log</name>
<type>1</type> <type>1</type>
<location>/home/andrey/git/x393/vivado_logs/VivadoOpt-20150915011906545.log</location> <location>/home/andrey/git/x393/vivado_logs/VivadoOpt-20150916155306201.log</location>
</link> </link>
<link> <link>
<name>vivado_logs/VivadoOptPhys.log</name> <name>vivado_logs/VivadoOptPhys.log</name>
<type>1</type> <type>1</type>
<location>/home/andrey/git/x393/vivado_logs/VivadoOptPhys-20150915011906545.log</location> <location>/home/andrey/git/x393/vivado_logs/VivadoOptPhys-20150916155306201.log</location>
</link> </link>
<link> <link>
<name>vivado_logs/VivadoOptPower.log</name> <name>vivado_logs/VivadoOptPower.log</name>
<type>1</type> <type>1</type>
<location>/home/andrey/git/x393/vivado_logs/VivadoOptPower-20150915011906545.log</location> <location>/home/andrey/git/x393/vivado_logs/VivadoOptPower-20150916155306201.log</location>
</link> </link>
<link> <link>
<name>vivado_logs/VivadoPlace.log</name> <name>vivado_logs/VivadoPlace.log</name>
<type>1</type> <type>1</type>
<location>/home/andrey/git/x393/vivado_logs/VivadoPlace-20150915011906545.log</location> <location>/home/andrey/git/x393/vivado_logs/VivadoPlace-20150916155306201.log</location>
</link> </link>
<link> <link>
<name>vivado_logs/VivadoRoute.log</name> <name>vivado_logs/VivadoRoute.log</name>
<type>1</type> <type>1</type>
<location>/home/andrey/git/x393/vivado_logs/VivadoRoute-20150915011906545.log</location> <location>/home/andrey/git/x393/vivado_logs/VivadoRoute-20150916155306201.log</location>
</link> </link>
<link> <link>
<name>vivado_logs/VivadoSynthesis.log</name> <name>vivado_logs/VivadoSynthesis.log</name>
<type>1</type> <type>1</type>
<location>/home/andrey/git/x393/vivado_logs/VivadoSynthesis-20150915011906545.log</location> <location>/home/andrey/git/x393/vivado_logs/VivadoSynthesis-20150916153820807.log</location>
</link> </link>
<link> <link>
<name>vivado_logs/VivadoTimimgSummaryReportImplemented.log</name> <name>vivado_logs/VivadoTimimgSummaryReportImplemented.log</name>
<type>1</type> <type>1</type>
<location>/home/andrey/git/x393/vivado_logs/VivadoTimimgSummaryReportImplemented-20150915011906545.log</location> <location>/home/andrey/git/x393/vivado_logs/VivadoTimimgSummaryReportImplemented-20150916155306201.log</location>
</link> </link>
<link> <link>
<name>vivado_logs/VivadoTimimgSummaryReportSynthesis.log</name> <name>vivado_logs/VivadoTimimgSummaryReportSynthesis.log</name>
......
parameter FPGA_VERSION = 32'h03930033; parameter FPGA_VERSION = 32'h03930034;
\ No newline at end of file \ No newline at end of file
/******************************************************************************* /* This is a generated file with the current DDR3 memory timing parameters */
* File: x393_cur_params_target.vh
* Date:2015-02-07 localparam DLY_LANE0_ODELAY = 80'hd8e8181c1c221c201b20;
* Author: Andrey Filippov localparam DLY_LANE0_IDELAY = 72'h2078807c88797c7884;
* Description: Memory controller parameters that need adjustment during training localparam DLY_LANE1_ODELAY = 80'hd8e31a181b1a1c1c1c1a;
* Target ,pde localparam DLY_LANE1_IDELAY = 72'h247b747b7882787c7c;
* Copyright (c) 2015 Elphel, Inc. localparam DLY_CMDA = 256'hd4d4d4dadcd3dbd0484848484848484848d4d4ccd4d4dcd9ccd8d4d4d3d3dbd0;
* x393_cur_params_target.vh is free software; you can redistribute it and/or modify localparam DLY_PHASE = 8'h32;
* it under the terms of the GNU General Public License as published by // localparam DFLT_WBUF_DELAY = 4'h8;
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* x393_cur_params_target.vh 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 <http://www.gnu.org/licenses/> .
*******************************************************************************/
localparam DLY_LANE0_ODELAY = 80'hd85c1014141814181218;
localparam DLY_LANE0_IDELAY = 72'h2c7a8380897c807b88;
localparam DLY_LANE1_ODELAY = 80'hd8581812181418181814;
localparam DLY_LANE1_IDELAY = 72'h108078807a887c8280;
localparam DLY_CMDA = 256'hd3d3d3d4dcd1d8cc494949494949494949d4d3ccd3d3dbd4ccd4d2d3d1d2d8cc;
localparam DLY_PHASE = 8'h33;
// localparam DFLT_WBUF_DELAY = 4'h9;
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -137,7 +137,11 @@ class X393CmprsAfi(object): ...@@ -137,7 +137,11 @@ class X393CmprsAfi(object):
sec = self.x393_mem.read_mem(cirbuf_start + last_image_chunk + (0x20 - CCAM_MMAP_META_SEC)) sec = self.x393_mem.read_mem(cirbuf_start + last_image_chunk + (0x20 - CCAM_MMAP_META_SEC))
usec = self.x393_mem.read_mem(cirbuf_start + last_image_chunk + (0x20 - CCAM_MMAP_META_USEC)) usec = self.x393_mem.read_mem(cirbuf_start + last_image_chunk + (0x20 - CCAM_MMAP_META_USEC))
fsec=sec + usec/1000000.0 fsec=sec + usec/1000000.0
tstr = time.strftime("%b %d %Y %H:%M:%S", time.gmtime(fsec)) try:
tstr = time.strftime("%b %d %Y %H:%M:%S", time.gmtime(fsec))
except:
tstr = "%f (0x%x, 0x%x)"%(fsec, sec,usec)
print ("**** Bad timestamp = ",tstr)
segments = ((cirbuf_start + img_start, len32 ),) segments = ((cirbuf_start + img_start, len32 ),)
if (img_start + len32) > circbuf_len: # split in two segments if (img_start + len32) > circbuf_len: # split in two segments
segments = ((cirbuf_start + img_start, circbuf_len - img_start), segments = ((cirbuf_start + img_start, circbuf_len - img_start),
......
...@@ -595,8 +595,8 @@ class X393Jpeg(object): ...@@ -595,8 +595,8 @@ class X393Jpeg(object):
y_quality = y_quality, y_quality = y_quality,
c_quality = c_quality, c_quality = c_quality,
portrait = portrait, portrait = portrait,
height = x393_sens_cmprs.GLBL_WINDOW["height"], height = x393_sens_cmprs.GLBL_WINDOW["height"] & 0xfff0,
width = x393_sens_cmprs.GLBL_WINDOW["width"], width = x393_sens_cmprs.GLBL_WINDOW["width"] & 0xfff0,
color_mode = color_mode, color_mode = color_mode,
byrshift = byrshift, byrshift = byrshift,
verbose = verbose - 1) verbose = verbose - 1)
...@@ -703,4 +703,108 @@ class X393Jpeg(object): ...@@ -703,4 +703,108 @@ class X393Jpeg(object):
""" """
ff d9 ff d9
""" """
"""
Camera compressors testing sequence
cd /usr/local/verilog/; test_mcntrl.py @hargs -x -v
Next 2 lines needed to use jpeg functionality if the program was started w/o setup_all_sensors True None 0xf
specify_phys_memory
specify_window
# Initialize memory with current calibration.
measure_all "*DI"
# Run 'measure_all' again (but w/o arguments) to perform full calibration (~10 minutes) and save results.
# Needed after new bitstream
# setup_all_sensors , 3-rd argument - bitmask of sesnors to initialize
setup_all_sensors True None 0xf
#reset all compressors
compressor_control 0 0
compressor_control 1 0
compressor_control 2 0
compressor_control 3 0
#next line to make compressor aways use the same input video frame buffer (default - 2 ping-pong frame buffers)
#axi_write_single_w 0x6c4 0
# Set Bayer = 3 (probably #1 and #3 need different hact/pxd delays to use the same compressor bayer for all channels)
compressor_control 0 None None None None None 3
compressor_control 1 None None None None None 2
compressor_control 2 None None None None None 3
compressor_control 3 None None None None None 2
#Gamma 0.57
program_gamma 0 0 0.57 0.04
program_gamma 1 0 0.57 0.04
program_gamma 2 0 0.57 0.04
program_gamma 3 0 0.57 0.04
#colors - outdoor
write_sensor_i2c 0 1 0 0x9035000a
write_sensor_i2c 0 1 0 0x902c000e
write_sensor_i2c 0 1 0 0x902d000d
write_sensor_i2c 1 1 0 0x9035000a
write_sensor_i2c 1 1 0 0x902c000e
write_sensor_i2c 1 1 0 0x902d000d
write_sensor_i2c 2 1 0 0x9035000a
write_sensor_i2c 2 1 0 0x902c000e
write_sensor_i2c 2 1 0 0x902d000d
write_sensor_i2c 3 1 0 0x9035000a
write_sensor_i2c 3 1 0 0x902c000e
write_sensor_i2c 3 1 0 0x902d000d
#colors indoor
write_sensor_i2c 0 1 0 0x90350009
write_sensor_i2c 0 1 0 0x902c000f
write_sensor_i2c 0 1 0 0x902d000a
write_sensor_i2c 1 1 0 0x90350009
write_sensor_i2c 1 1 0 0x902c000f
write_sensor_i2c 1 1 0 0x902d000a
write_sensor_i2c 2 1 0 0x90350009
write_sensor_i2c 2 1 0 0x902c000f
write_sensor_i2c 2 1 0 0x902d000a
write_sensor_i2c 3 1 0 0x90350009
write_sensor_i2c 3 1 0 0x902c000f
write_sensor_i2c 3 1 0 0x902d000a
#exposure 0x400 lines (default was 0x797)
write_sensor_i2c 0 1 0 0x90090400
write_sensor_i2c 1 1 0 0x90090400
write_sensor_i2c 2 1 0 0x90090400
write_sensor_i2c 3 1 0 0x90090400
#exposure 0x500 lines (default was 0x797)
write_sensor_i2c 0 1 0 0x90090500
write_sensor_i2c 1 1 0 0x90090500
write_sensor_i2c 2 1 0 0x90090500
write_sensor_i2c 3 1 0 0x90090500
#Get rid of the corrupted last pixel column
#longer line (default 0xa1f)
write_sensor_i2c 0 1 0 0x90040a23
write_sensor_i2c 1 1 0 0x90040a23
write_sensor_i2c 2 1 0 0x90040a23
write_sensor_i2c 3 1 0 0x90040a23
#increase scanline write (memory controller) width in 16-bursts (was 0xa2)
axi_write_single_w 0x696 0x079800a3
axi_write_single_w 0x686 0x079800a3
axi_write_single_w 0x6a6 0x079800a3
axi_write_single_w 0x6b6 0x079800a3
#run copmpressors once (#1 - stop gracefully, 0 - reset, 2 - single, 3 - repetitive with sync to sensors)
compressor_control 0 2
compressor_control 1 2
compressor_control 2 2
compressor_control 3 2
jpeg_write "/www/pages/img0.jpeg" 0
jpeg_write "/www/pages/img1.jpeg" 1
jpeg_write "/www/pages/img2.jpeg" 2
jpeg_write "/www/pages/img3.jpeg" 3
"""
...@@ -1112,6 +1112,8 @@ class X393McntrlAdjust(object): ...@@ -1112,6 +1112,8 @@ class X393McntrlAdjust(object):
print (self.adjustment_state['cmda_bspe']) print (self.adjustment_state['cmda_bspe'])
return None return None
cmda_odly_lin=cmda_odly_data['ldly'] cmda_odly_lin=cmda_odly_data['ldly']
self.x393_axi_tasks.enable_refresh(0) self.x393_axi_tasks.enable_refresh(0)
self.x393_mcntrl_timing.axi_set_phase(phase,quiet=quiet) self.x393_mcntrl_timing.axi_set_phase(phase,quiet=quiet)
self.x393_mcntrl_timing.axi_set_cmda_odelay(combine_delay(cmda_odly_lin),quiet=quiet) self.x393_mcntrl_timing.axi_set_cmda_odelay(combine_delay(cmda_odly_lin),quiet=quiet)
...@@ -2864,9 +2866,11 @@ class X393McntrlAdjust(object): ...@@ -2864,9 +2866,11 @@ class X393McntrlAdjust(object):
quiet) quiet)
if not phase_ok: if not phase_ok:
print ("Failed to set phase=%d for dly=%d- that should not happen (phase_dqso)- "%(phase,dqs_lin)) print ("Failed to set phase=%d for dly=%d- that should not happen (phase_dqso)- "%(phase,dqs_lin))
print (self.adjustment_state['cmda_bspe']) # See if it was meant "not phase_ok", not "phase_ok is None":
print ("phase_ok = ",phase_ok)
return None # no valid CMDA ODELAY exists for this phase if phase_ok is None:
print (self.adjustment_state['cmda_bspe'])
return None # no valid CMDA ODELAY exists for this phase
#set DQS IDELAY and DQ IDELAY matching phase #set DQS IDELAY and DQ IDELAY matching phase
dqs_idelay=dqsi_dqi_for_phase[phase][DQSI_KEY] # 2-element list dqs_idelay=dqsi_dqi_for_phase[phase][DQSI_KEY] # 2-element list
dq_idelay= dqsi_dqi_for_phase[phase][DQI_KEY] # 16-element list dq_idelay= dqsi_dqi_for_phase[phase][DQI_KEY] # 16-element list
......
...@@ -488,7 +488,9 @@ class X393SensCmprs(object): ...@@ -488,7 +488,9 @@ class X393SensCmprs(object):
GLBL_WINDOW = {"width": window_width, GLBL_WINDOW = {"width": window_width,
"height": window_height, "height": window_height,
"left": window_left, "left": window_left,
"top": window_top} "top": window_top}
def specify_phys_memory(self, def specify_phys_memory(self,
circbuf_chn_size= 0x1000000, circbuf_chn_size= 0x1000000,
verbose = 1): verbose = 1):
...@@ -737,7 +739,7 @@ class X393SensCmprs(object): ...@@ -737,7 +739,7 @@ class X393SensCmprs(object):
self.x393Sensor.set_sensor_i2c_command ( self.x393Sensor.set_sensor_i2c_command (
num_sensor = num_sensor, num_sensor = num_sensor,
num_bytes = 3, num_bytes = 3,
dly = 100, # ??None, dly = 100, # ??None, # 20 ns per 1 of cycle duration. Standard i2c - dly = 125
scl_ctl = None, scl_ctl = None,
sda_ctl = None) sda_ctl = None)
self.x393Sensor.set_sensor_i2c_command ( self.x393Sensor.set_sensor_i2c_command (
......
...@@ -205,6 +205,7 @@ class X393Sensor(object): ...@@ -205,6 +205,7 @@ class X393Sensor(object):
1/True/'H' - high level 1/True/'H' - high level
@return: i2c control word @return: i2c control word
""" """
print ("func_sensor_i2c_command(): rst_cmd= ",rst_cmd,", run_cmd=",run_cmd,", num_bytes = ",num_bytes,", dly = ",dly)
rslt = 0 rslt = 0
rslt |= (0,1)[rst_cmd] << vrlg.SENSI2C_CMD_RESET rslt |= (0,1)[rst_cmd] << vrlg.SENSI2C_CMD_RESET
if not run_cmd is None: if not run_cmd is None:
...@@ -215,9 +216,10 @@ class X393Sensor(object): ...@@ -215,9 +216,10 @@ class X393Sensor(object):
rslt |= 1 << vrlg.SENSI2C_CMD_BYTES rslt |= 1 << vrlg.SENSI2C_CMD_BYTES
rslt |= num_bytes << (vrlg.SENSI2C_CMD_BYTES - vrlg.SENSI2C_CMD_BYTES_PBITS) rslt |= num_bytes << (vrlg.SENSI2C_CMD_BYTES - vrlg.SENSI2C_CMD_BYTES_PBITS)
if not dly is None: if not dly is None:
dly &= (1 << vrlg.SENSI2C_CMD_BYTES_PBITS) -1 dly &= (1 << vrlg.SENSI2C_CMD_DLY_PBITS) -1
rslt |= 1 << vrlg.SENSI2C_CMD_BYTES rslt |= 1 << vrlg.SENSI2C_CMD_DLY
rslt |= dly << (vrlg.SENSI2C_CMD_BYTES - vrlg.SENSI2C_CMD_BYTES_PBITS) rslt |= dly << (vrlg.SENSI2C_CMD_DLY - vrlg.SENSI2C_CMD_DLY_PBITS)
print ("func_sensor_i2c_command(): dly = ",dly," rslt=",rslt)
scl=0 scl=0
if not scl_ctl is None: if not scl_ctl is None:
if (scl_ctl is False) or (scl_ctl == 0) or (scl_ctl == "0") or (scl_ctl.upper() == "L"): if (scl_ctl is False) or (scl_ctl == 0) or (scl_ctl == "0") or (scl_ctl.upper() == "L"):
...@@ -597,6 +599,27 @@ class X393Sensor(object): ...@@ -597,6 +599,27 @@ class X393Sensor(object):
if not post_scale is None: if not post_scale is None:
self.x393_axi_tasks.write_control_register(reg_addr, func_lens_data(num_sub_sensor, vrlg.SENS_LENS_POST_SCALE, post_scale, 4)) self.x393_axi_tasks.write_control_register(reg_addr, func_lens_data(num_sub_sensor, vrlg.SENS_LENS_POST_SCALE, post_scale, 4))
def program_gamma (self,
num_sensor,
sub_channel,
gamma = 0.57,
black = 0.04,
page = 0):
"""
Program gamma tables for specified sensor port and subchannel
@param num_sensor - sensor port number (0..3)
@param num_sub_sensor - sub-sensor attached to the same port through multiplexer (0..3)
@param gamma - gamma value (1.0 - linear)
@param black - black level, 1.0 corresponds to 256 for 8bit values
@param page - gamma table page number (only used if SENS_GAMMA_BUFFER > 0
"""
self.program_curves(num_sensor = num_sensor,
sub_channel = sub_channel,
curves_data = self.calc_gamma257(gamma = gamma,
black = black,
rshift = 6) * 4,
page = page)
def program_curves (self, def program_curves (self,
num_sensor, num_sensor,
sub_channel, sub_channel,
...@@ -608,7 +631,7 @@ class X393Sensor(object): ...@@ -608,7 +631,7 @@ class X393Sensor(object):
@param num_sub_sensor - sub-sensor attached to the same port through multiplexer (0..3) @param num_sub_sensor - sub-sensor attached to the same port through multiplexer (0..3)
@param curves_data - either 1028-element list (257 per color component) or a file path @param curves_data - either 1028-element list (257 per color component) or a file path
with the same data, same as for Verilog $readmemh with the same data, same as for Verilog $readmemh
@param page - gammma table page number (only used if SENS_GAMMA_BUFFER > 0 @param page - gamma table page number (only used if SENS_GAMMA_BUFFER > 0
""" """
def set_sensor_gamma_table_addr ( def set_sensor_gamma_table_addr (
num_sensor, num_sensor,
...@@ -656,7 +679,31 @@ class X393Sensor(object): ...@@ -656,7 +679,31 @@ class X393Sensor(object):
set_sensor_gamma_table_data ( set_sensor_gamma_table_data (
num_sensor = num_sensor, num_sensor = num_sensor,
data18 = data18) data18 = data18)
def calc_gamma257(self,
gamma,
black,
rshift = 6
):
"""
@brief Calculate gamma table (as array of 257 unsigned short values)
@param gamma - gamma value (1.0 - linear)
@param black - black level, 1.0 corresponds to 256 for 8bit values
@return array of 257 int elements (for a single color), right-shifted to match original 0..0x3ff range
"""
black256 = max(0.0, min(255, black * 256.0))
k= 1.0 / (256.0 - black256)
gamma =max(0.13, min(gamma, 10.0))
gtable = []
for i in range (257):
x=k * (i - black256)
x = max(x, 0.0)
ig = int (0.5 + 65535.0 * pow(x, gamma))
ig = min(ig, 0xffff)
gtable.append(ig >> rshift)
return gtable
def set_sensor_gamma_heights (self, def set_sensor_gamma_heights (self,
num_sensor, num_sensor,
height0_m1, height0_m1,
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
`ifndef SYSTEM_DEFINES `ifndef SYSTEM_DEFINES
`define SYSTEM_DEFINES `define SYSTEM_DEFINES
`define PRELOAD_BRAMS `define PRELOAD_BRAMS
`define DEBUG_RING 1 // `define DEBUG_RING 1
`define MEMBRIDGE_DEBUG_WRITE 1 `define MEMBRIDGE_DEBUG_WRITE 1
// Enviroment-dependent options // Enviroment-dependent options
`ifdef IVERILOG `ifdef IVERILOG
......
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