Commit a69b7a9b authored by Andrey Filippov's avatar Andrey Filippov

added main Python program control over socket, testedimage control/acquisition through web browser

parent f34f1c1f
......@@ -62,42 +62,42 @@
<link>
<name>vivado_logs/VivadoBitstream.log</name>
<type>1</type>
<location>/home/andrey/git/x393/vivado_logs/VivadoBitstream-20151115151104872.log</location>
<location>/home/andrey/git/x393/vivado_logs/VivadoBitstream-20151117233913191.log</location>
</link>
<link>
<name>vivado_logs/VivadoOpt.log</name>
<type>1</type>
<location>/home/andrey/git/x393/vivado_logs/VivadoOpt-20151115151104872.log</location>
<location>/home/andrey/git/x393/vivado_logs/VivadoOpt-20151117233913191.log</location>
</link>
<link>
<name>vivado_logs/VivadoOptPhys.log</name>
<type>1</type>
<location>/home/andrey/git/x393/vivado_logs/VivadoOptPhys-20151115151104872.log</location>
<location>/home/andrey/git/x393/vivado_logs/VivadoOptPhys-20151117233913191.log</location>
</link>
<link>
<name>vivado_logs/VivadoOptPower.log</name>
<type>1</type>
<location>/home/andrey/git/x393/vivado_logs/VivadoOptPower-20151115151104872.log</location>
<location>/home/andrey/git/x393/vivado_logs/VivadoOptPower-20151117233913191.log</location>
</link>
<link>
<name>vivado_logs/VivadoPlace.log</name>
<type>1</type>
<location>/home/andrey/git/x393/vivado_logs/VivadoPlace-20151115151104872.log</location>
<location>/home/andrey/git/x393/vivado_logs/VivadoPlace-20151117233913191.log</location>
</link>
<link>
<name>vivado_logs/VivadoRoute.log</name>
<type>1</type>
<location>/home/andrey/git/x393/vivado_logs/VivadoRoute-20151115151104872.log</location>
<location>/home/andrey/git/x393/vivado_logs/VivadoRoute-20151117233913191.log</location>
</link>
<link>
<name>vivado_logs/VivadoSynthesis.log</name>
<type>1</type>
<location>/home/andrey/git/x393/vivado_logs/VivadoSynthesis-20151115150613168.log</location>
<location>/home/andrey/git/x393/vivado_logs/VivadoSynthesis-20151117233307674.log</location>
</link>
<link>
<name>vivado_logs/VivadoTimimgSummaryReportImplemented.log</name>
<type>1</type>
<location>/home/andrey/git/x393/vivado_logs/VivadoTimimgSummaryReportImplemented-20151115151104872.log</location>
<location>/home/andrey/git/x393/vivado_logs/VivadoTimimgSummaryReportImplemented-20151117233913191.log</location>
</link>
<link>
<name>vivado_logs/VivadoTimimgSummaryReportSynthesis.log</name>
......
......@@ -195,11 +195,12 @@ each group of 4 bits per channel : bits [1:0] - select, bit[2] - sset (0 - nop),
// reg [2:0] cur_chn; // 'b0xx - none, 'b1** - ** - channel number (should match fifo_ren*)
reg [1:0] cur_chn; // 'b0xx - none, 'b1** - ** - channel number (should match fifo_ren*)
reg [31:0] left_to_eof; // number of chunks left to end of frame
reg [31:0] left_to_eof; // number of chunks left to end of frame (one less: 3 means 4 left)
reg [3:0] fifo_flush_d; // fifo_flush* delayed by 1 clk (to detect rising edge
reg [3:0] eof_stb; // single-cycle pulse after fifo_flush is asserted
// reg [1:0] w64_cnt; // count 64-bit words in a chunk
// adjusted counters used for channel arbitration
// pessimistic FIFO content counter - decrements (form FIFO counter) on FIFO reads, knows nothing of writes
reg [35:0] counts_corr0; // registers to hold corrected (decremented currently processed ones if any) fifo count values, MSB - needs flush
reg [17:0] counts_corr1; // first arbitration level winning values
reg [8:0] counts_corr2; // second arbitration level winning values
......@@ -231,6 +232,8 @@ each group of 4 bits per channel : bits [1:0] - select, bit[2] - sset (0 - nop),
// 3'h4 :
// ({1'b0,left_to_eof[winner2 * 8 +: 2]} + 3'h1);
// Why it has priority for |counts_corr2[7:2] ? If next frame started, it may skip EOF? Or not?
// it is just to pass to a channel, actual transfer size will be decided here (depending on EOF)
wire [1:0] pre_chunk_inc_m1 = (|counts_corr2[7:2])? // Would like to increment, if not roll-over
2'h3 :
left_to_eof[winner2 * 8 +: 2];
......@@ -252,12 +255,15 @@ each group of 4 bits per channel : bits [1:0] - select, bit[2] - sset (0 - nop),
wire [26:0] chunk_ptr_rd;
wire [ 3:0] chunk_ptr_ra;
// If flushing - whatever is left to EOF, otherwise corrected FIFO contents of the winner
wire [ 7:0] items_left = counts_corr2[8] ? left_to_eof[(winner2 * 8) +: 8] : counts_corr2[7:0];
reg [5:0] afi_awid_r;
// "rollover" - roll over destination memory range
wire [2:0] max_wlen; // 0,1,2,3,7 (7 - not limited by rollover) - calculated by cmprs_afi_mux_ptr
wire [1:0] want_wleft32 = (|items_left[7:2])? 2'b11 : items_left[1:0]; // want to set wleft[3:2] if not roll-over
// wants to write (want_wleft32+1) 32-byte chunks (4,3,2,1)
wire [1:0] want_wleft32 = (|items_left[7:2])? 2'b11 : items_left[1:0]; // want to set wleft[3:2] if not roll-over (actually "3" means 2)
assign cmd_we_status_w = cmd_we && ((cmd_a & 'hc) == CMPRS_AFIMUX_STATUS_CNTRL);
assign cmd_we_mode_w = cmd_we && (cmd_a == CMPRS_AFIMUX_MODE);
......@@ -366,16 +372,22 @@ each group of 4 bits per channel : bits [1:0] - select, bit[2] - sset (0 - nop),
// TODO: change &w64_cnt[1:0] so left_to_eof[*] will be updated earlier and valid at pre_busy_w
// Done, updating at the first (not last) word of 4
// Now seems that eof_stb[i] & fifo_ren{i} == 0
if (eof_stb[0]) left_to_eof[0 * 8 +: 8] <= fifo_count0_m1 - (fifo_ren0 & (&wleft[1:0]));
// Seems needs to decrement fifo_count0_m1 regardless of &wleft[1:0] - if started, will eventually decrement
// How to make sure that decremented value always >0?
// if (eof_stb[0]) left_to_eof[0 * 8 +: 8] <= fifo_count0_m1 - (fifo_ren0 & (&wleft[1:0]));
if (eof_stb[0]) left_to_eof[0 * 8 +: 8] <= fifo_count0_m1 - fifo_ren0;
else if (fifo_ren0 & (&wleft[1:0])) left_to_eof[0 * 8 +: 8] <= left_to_eof[0 * 8 +: 8] - 1;
if (eof_stb[1]) left_to_eof[1 * 8 +: 8] <= fifo_count1_m1 - (fifo_ren1 & (&wleft[1:0]));
// if (eof_stb[1]) left_to_eof[1 * 8 +: 8] <= fifo_count1_m1 - (fifo_ren1 & (&wleft[1:0]));
if (eof_stb[1]) left_to_eof[1 * 8 +: 8] <= fifo_count1_m1 - fifo_ren1;
else if (fifo_ren1 & (&wleft[1:0])) left_to_eof[1 * 8 +: 8] <= left_to_eof[1 * 8 +: 8] - 1;
if (eof_stb[2]) left_to_eof[2 * 8 +: 8] <= fifo_count2_m1 - (fifo_ren2 & (&wleft[1:0]));
// if (eof_stb[2]) left_to_eof[2 * 8 +: 8] <= fifo_count2_m1 - (fifo_ren2 & (&wleft[1:0]));
if (eof_stb[2]) left_to_eof[2 * 8 +: 8] <= fifo_count2_m1 - fifo_ren2;
else if (fifo_ren2 & (&wleft[1:0])) left_to_eof[2 * 8 +: 8] <= left_to_eof[2 * 8 +: 8] - 1;
if (eof_stb[3]) left_to_eof[3 * 8 +: 8] <= fifo_count3_m1 - (fifo_ren3 & (&wleft[1:0]));
// if (eof_stb[3]) left_to_eof[3 * 8 +: 8] <= fifo_count3_m1 - (fifo_ren3 & (&wleft[1:0]));
if (eof_stb[3]) left_to_eof[3 * 8 +: 8] <= fifo_count3_m1 - fifo_ren3;
else if (fifo_ren3 & (&wleft[1:0])) left_to_eof[3 * 8 +: 8] <= left_to_eof[3 * 8 +: 8] - 1;
// Calculate corrected values decrementing currently served channel (if any) values by 1 (latency 1 clk)
......
......@@ -31,7 +31,8 @@
* contains all the components and scripts required to completely simulate it
* with at least one of the Free Software programs.
*******************************************************************************/
parameter FPGA_VERSION = 32'h03930070; // Fixing HiSPi xclk -0.049 -0.291 17, utilization 15139 (77.04%)
parameter FPGA_VERSION = 32'h03930071; // Fixing AXI HP multiplexer xclk -0.083 -1.968 44 / 15163 (77.17%)
// parameter FPGA_VERSION = 32'h03930070; // Fixing HiSPi xclk -0.049 -0.291 17, utilization 15139 (77.04%)
// parameter FPGA_VERSION = 32'h0393006f; // Fixing JP4 mode - xcl -0.002 -0.004 2, utilization 15144 (77.07 %)
// parameter FPGA_VERSION = 32'h0393006f; // Fixing JP4 mode - xclk -0.209/-2.744/23, utilization 15127 (76.98%)
// parameter FPGA_VERSION = 32'h0393006e; // Trying lane switch again after bug fix, failing 1 in ddr3_mclk -> ddr3_clk_div by -0.023
......
This diff is collapsed.
......@@ -22,6 +22,7 @@
@contact: andrey@elphel.coml
@deffield updated: Updated
'''
from __future__ import print_function
from __builtin__ import str
__author__ = "Andrey Filippov"
__copyright__ = "Copyright 2015, Elphel, Inc."
......@@ -43,6 +44,10 @@ from argparse import ArgumentParser
#import argparse
from argparse import RawDescriptionHelpFormatter
import time
import socket
import select
from import_verilog_parameters import ImportVerilogParameters
#from import_verilog_parameters import VerilogParameters
from verilog_utils import hx
......@@ -217,6 +222,8 @@ USAGE
parser.add_argument("-x", "--exceptions", dest="exceptions", action="count", help="Exit on more exceptions [default: %(default)s]")
parser.add_argument("-l", "--localparams", dest="localparams", action="store", default="",
help="path were modified parameters are saved [default: %(default)s]", metavar="path")
parser.add_argument("-P", "--socket-port", dest="socket_port", action="store", default="",
help="port to use for socket connection [default: %(default)s]")
# Process arguments
args = parser.parse_args()
......@@ -391,18 +398,75 @@ USAGE
'''
#TODO: use readline
'''
if args.socket_port:
PORT = int(args.socket_port) # 8888
else:
PORT = 0
HOST = '' # Symbolic name meaning all available interfaces
socket_conn = None
if PORT:
socket_conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
socket_conn.bind((HOST, PORT))
print ('Socket bind complete')
socket_conn.listen(1) # just a single request
print ('Socket now listening to a single request on port %d: send command, receive response, close'%(PORT))
except socket.error as msg:
print ('Bind failed. Error Code : %s Message %s'%( str(msg[0]),msg[1]))
socket_conn = None # do not use sockets
if (args.interactive):
line =""
while True:
line=raw_input('x393%s +%3.3fs--> '%(('','(simulated)')[args.simulated],(time.time()-tim))).strip()
soc_conn = None
prompt = 'x393%s +%3.3fs--> '%(('','(simulated)')[args.simulated],(time.time()-tim))
if socket_conn:
print(prompt , end="")
sys.stdout.flush()
ready_to_read, _, _ = select.select( #ready_to_write, in_error
[socket_conn, sys.stdin], # potential_readers,
[], # potential_writers,
[]) # potential_errs,
if sys.stdin in ready_to_read:
line=raw_input()
# print ("stdin: ", line)
elif socket_conn in ready_to_read:
try:
soc_conn, soc_addr = socket_conn.accept()
print ("Connected with %s"%(soc_addr[0] + ':' + str(soc_addr[1])))
#Sending message to connected client
#soc_conn.send('Welcome to the server. Type something and hit enter\n') #send only takes string
line = soc_conn.recv(4096) # or make it unlimited?
print ('Received from socket: ', line)
except:
continue # socket probably died, wait for the next command
else:
print ("Unexpected result from select: ready_to_read = ",ready_to_read)
continue
else: # No sockets, just command line input
line=raw_input(prompt)
# line=raw_input('x393%s +%3.3fs--> '%(('','(simulated)')[args.simulated],(time.time()-tim))).strip()
line=line.strip() # maybe also remove comment?
# Process command, return result to a socket if it was a socket, not stdin
tim=time.time()
#remove comment from the input line
if line.find("#") > 0:
had_comment=False
if line.find("#") >= 0:
line=line[:line.find("#")]
had_comment=True
lineList=line.split()
if not line:
print ('Use "quit" to exit, "help" - for help')
if not had_comment:
print ('Use "quit" to exit, "help" - for help')
elif (line == 'quit') or (line == 'exit'):
if soc_conn:
soc_conn.send('0\n') # OK\n')
soc_conn.close()
# soc_conn=None
break
elif line== 'help' :
print ("\nAvailable tasks:")
......@@ -412,7 +476,26 @@ USAGE
print ('\n"parameters" and "defines" list known defined parameters and macros')
print ("args.exception=%d, QUIET=%d"%(args.exceptions,QUIET))
print ("Enter 'R' to toggle show/hide command results, now it is %s"%(("OFF","ON")[showResult]))
print ("Use 'socket_port' [PORT] to (re-)open socket on PORT (0 or no PORT - disable socket)")
print ("Use 'pydev_predefines' to generate a parameter list to paste to vrlg.py, so Pydev will be happy")
elif (lineList[0].upper() == 'SOCKET_PORT') and (not soc_conn): # socket_conn):
if socket_conn : # close old socket (if open)
print ("Closed socket on port %d"%(PORT))
socket_conn.close()
socket_conn = None
if len(lineList) > 1: # port specified
PORT = int(lineList[1])
if PORT:
socket_conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
socket_conn.bind((HOST, PORT))
print ('Socket bind complete')
socket_conn.listen(1) # just a single request
print ('Socket now listening to a single request on port %d: send command, receive response, close'%(PORT))
except socket.error as msg:
print ('Bind failed. Error Code : %s Message %s'%( str(msg[0]),msg[1]))
socket_conn = None # do not use sockets
continue
elif lineList[0].upper() == 'R':
if len(lineList)>1:
if (lineList[1].upper() == "ON") or (lineList[1].upper() == "1") or (lineList[1].upper() == "TRUE"):
......@@ -506,6 +589,10 @@ USAGE
vrlg_text=vrlg_text[:index+1]+"\n"+predefines
except:
print ("Failed to update %s - it is either missing or does not have a '%s'"%(vrlg_path,magic))
if soc_conn:
soc_conn.send('0\n')
soc_conn.close()
# soc_conn=None
continue
try:
with open (vrlg_path, "w") as vrlg_file:
......@@ -535,7 +622,17 @@ USAGE
# strarg=line[len(lineList[0]):].strip()
rslt= execTask(cmdLine)
if showResult:
print (' Result: '+hx(rslt))
print (' Result: '+hx(rslt))
if soc_conn:
soc_conn.send(str(rslt)+'\n')
soc_conn.close()
# soc_conn=None
continue
if soc_conn:
soc_conn.send('0\n')
soc_conn.close()
# soc_conn=None
#http://stackoverflow.com/questions/11781265/python-using-getattr-to-call-function-with-variable-parameters
#*getattr(foo,bar)(*params)
return 0
......
......@@ -337,7 +337,7 @@ CMPRS_CBIT_CMODE_JP46__TYPE = str
NUM_CYCLES_17__RAW = str
DFLT_WBUF_DELAY__RAW = str
CAMSYNC_POST_MAGIC__RAW = str
MCNTRL_TEST01_CHN2_MODE__TYPE = str
NUM_CYCLES_07__RAW = str
NUM_CYCLES_24__RAW = str
NUM_CYCLES_13__RAW = str
LOGGER_CONF_MSG__RAW = str
......@@ -374,7 +374,7 @@ SENS_CTRL_QUADRANTS__TYPE = str
SENS_LENS_BY_MASK__RAW = str
SENS_CTRL_GP0__TYPE = str
DFLT_REFRESH_ADDR = int
SENS_LENS_BX_MASK__TYPE = str
HISPI_FIFO_START__TYPE = str
TEST01_SUSPEND__RAW = str
SENS_GAMMA_HEIGHT01__TYPE = str
CMPRS_HIFREQ_REG_INC = int
......@@ -511,6 +511,7 @@ STATUS_MSB_RSHFT = int
CMPRS_CONTROL_REG__RAW = str
CLKIN_PERIOD__TYPE = str
SENS_GAMMA_CTRL = int
HISPI_WAIT_ALL_LANES__TYPE = str
SENSIO_RADDR = int
BUF_CLK1X_PCLK__RAW = str
GPIO_N__TYPE = str
......@@ -525,6 +526,7 @@ BUFFER_DEPTH32__TYPE = str
CMPRS_CBIT_CMODE_JPEG18 = int
MCONTR_TOP_16BIT_REFRESH_ADDRESS = int
HISTOGRAM_RADDR0__TYPE = str
HISPI_FIFO_DEPTH__TYPE = str
LOGGER_CONF_SYN_BITS = int
NUM_CYCLES_19 = int
SENS_CTRL_GP1__TYPE = str
......@@ -533,6 +535,7 @@ SENS_CTRL_QUADRANTS_WIDTH__RAW = str
SENSOR_FIFO_DELAY__RAW = str
DLY_SET = int
CMDFRAMESEQ_CTRL__TYPE = str
HISPI_FIFO_DEPTH__RAW = str
NUM_CYCLES_12 = int
MCNTRL_SCANLINE_FRAME_PAGE_RESET__TYPE = str
MCNTRL_TILED_CHN2_ADDR__TYPE = str
......@@ -774,6 +777,7 @@ MULT_SAXI_BSLOG3__TYPE = str
CLKFBOUT_MULT__RAW = str
CMPRS_STATUS_REG_INC__RAW = str
HISTOGRAM_RADDR0__RAW = str
HISPI_KEEP_IRST = int
STATUS_ADDR_MASK = int
PXD_CAPACITANCE = str
SENS_LENS_AY = int
......@@ -994,6 +998,7 @@ MCNTRL_TILED_STARTADDR = int
TILE_HEIGHT__TYPE = str
MCNTRL_TILED_CHN4_ADDR__TYPE = str
HISPI_NUMLANES__TYPE = str
HISPI_FIFO_START = int
TILED_STARTX__TYPE = str
FFCLK0_DIFF_TERM__RAW = str
MCNTRL_PS_STATUS_CNTRL__RAW = str
......@@ -1075,6 +1080,7 @@ NUM_CYCLES_25__RAW = str
SENSOR_NUM_HISTOGRAM__RAW = str
CMPRS_CBIT_CMODE = int
HIST_SAXI_ADDR_MASK__RAW = str
HISPI_WAIT_ALL_LANES__RAW = str
MEMBRIDGE_STATUS_REG__TYPE = str
CLKIN_PERIOD__RAW = str
SENS_SYNC_MULT__RAW = str
......@@ -1340,6 +1346,7 @@ SENS_GAMMA_ADDR_MASK__RAW = str
DLY_LANE1_IDELAY__TYPE = str
SENS_LENS_BY_MASK = int
DEBUG_MASK__RAW = str
MCNTRL_TEST01_CHN2_MODE__TYPE = str
MEMBRIDGE_ADDR__RAW = str
CMPRS_COLOR_SATURATION__RAW = str
AXI_RD_ADDR_BITS = int
......@@ -1514,6 +1521,7 @@ HISPI_MMCM0 = str
HISPI_MMCM3 = str
HISPI_MMCM2 = str
MULT_SAXI_CNTRL_ADDR__TYPE = str
HISPI_KEEP_IRST__TYPE = str
MULT_SAXI_STATUS_REG__TYPE = str
MEMCLK_IOSTANDARD__TYPE = str
NUM_CYCLES_27__TYPE = str
......@@ -1851,6 +1859,7 @@ LOGGER_PAGE_MSG__RAW = str
MCONTR_TOP_16BIT_STATUS_CNTRL = int
CMPRS_CBIT_CMODE_MONO4__RAW = str
MULT_SAXI_MASK = int
SENS_LENS_BX_MASK__TYPE = str
MCNTRL_SCANLINE_WINDOW_STARTXY__TYPE = str
CMDFRAMESEQ_DEPTH__TYPE = str
DLY_LANE0_IDELAY__RAW = str
......@@ -1866,9 +1875,10 @@ CLKIN_PERIOD = int
RSEL__TYPE = str
CMDFRAMESEQ_ADDR_INC__TYPE = str
LOGGER_CONF_GPS_BITS = int
NUM_CYCLES_07__RAW = str
HISPI_FIFO_DEPTH = int
CLKFBOUT_PHASE = float
SENS_GAMMA_ADDR_DATA = int
HISPI_WAIT_ALL_LANES = int
SENS_GAMMA_ADDR_DATA__TYPE = str
CAMSYNC_DELAY__TYPE = str
DFLT_REFRESH_PERIOD__RAW = str
......@@ -1893,6 +1903,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
HISPI_KEEP_IRST__RAW = str
LOGGER_CONF_DBG__TYPE = str
AFI_SIZE64__RAW = str
SENSI2C_TBL_RNWREG = int
......@@ -1957,6 +1968,7 @@ SENSI2C_TBL_DLY = int
SENSIO_STATUS__RAW = str
MCONTR_LINTILE_DIS_NEED = int
SENS_LENS_BX_MASK = int
HISPI_FIFO_START__RAW = str
DLY_DQ_ODELAY__RAW = str
MCNTRL_TILED_PENDING_CNTR_BITS__RAW = str
CMPRS_CORING_BITS = int
......
......@@ -173,6 +173,9 @@ class X393AxiControlStatus(object):
{FILE:"vccint", ITEM:"VCCint", UNITS:"V", SCALE: 0.001},
{FILE:"vccbram", ITEM:"VCCbram", UNITS:"V", SCALE: 0.001}]
print("hwmon:")
if self.DRY_MODE:
print ("Not defined for simulation mode")
return
for par in HWMON_ITEMS:
with open(HWMON_PATH + par[FILE]) as f:
d=int(f.read())
......
......@@ -110,8 +110,9 @@ class X393CmprsAfi(object):
@param channel - AFI input channel (0..3) - with 2 AFIs - 0..1 only
@return - memory segments (1 or two) with image data, timestamp in numeric and string format
"""
print ("\n------------ channel %d --------------"%(channel))
print ("x393_sens_cmprs.GLBL_WINDOW = ", x393_sens_cmprs.GLBL_WINDOW)
if verbose >0:
print ("\n------------ channel %d --------------"%(channel))
print ("x393_sens_cmprs.GLBL_WINDOW = ", x393_sens_cmprs.GLBL_WINDOW)
if (self.DRY_MODE):
return None
CCAM_MMAP_META = 12 # extra bytes included at the end of each frame (last aligned to 32 bytes)
......@@ -123,14 +124,37 @@ class X393CmprsAfi(object):
# offs_len32 = 0x20 - CCAM_MMAP_META_LENGTH # 0x1c #from last image 32-byte chunk to lower of 3-byte image length (MSB == 0xff)
next_image = self.afi_mux_get_image_pointer(port_afi = port_afi,
channel = channel)
# Bug - got 0x20 more than start of the new image
last_image_chunk = next_image - 0x40
if last_image_chunk < 0:
last_image_chunk += circbuf_len
len32 = self.x393_mem.read_mem(cirbuf_start + last_image_chunk + (0x20 - CCAM_MMAP_META_LENGTH))
markerFF = len32 >> 24
if (markerFF != 0xff):
print ("Failed to get 0xff marker at offset 0x%08x - length word = 0x%08x)"%(cirbuf_start + last_image_chunk + (0x20 - CCAM_MMAP_META_LENGTH) + 3,len32))
return None
print ("Failed to get 0xff marker at offset 0x%08x - length word = 0x%08x, next_image = 0x%08x)"%
(cirbuf_start + last_image_chunk + (0x20 - CCAM_MMAP_META_LENGTH) + 3,len32,next_image))
if verbose >0:
for a in range ( next_image - (0x10 * num_lines_print), next_image + (0x10 * num_lines_print), 4):
d = self.x393_mem.read_mem(cirbuf_start + a)
if (a % 16) == 0:
print ("\n%08x: "%(a),end ="" )
print("%02x %02x %02x %02x "%(d & 0xff, (d >> 8) & 0xff, (d >> 16) & 0xff, (d >> 24) & 0xff), end = "")
#Try noticed (but not yet identified) bug - reduce afi_mux_get_image_pointer result by 1
next_image -= 0x20
if next_image < 0:
next_image += circbuf_len
last_image_chunk = next_image - 0x40
if last_image_chunk < 0:
last_image_chunk += circbuf_len
len32 = self.x393_mem.read_mem(cirbuf_start + last_image_chunk + (0x20 - CCAM_MMAP_META_LENGTH))
markerFF = len32 >> 24
if (markerFF != 0xff):
print ("**** Failed to get 0xff marker at CORRECTED offset 0x%08x - length word = 0x%08x, next_image = 0x%08x)"%
(cirbuf_start + last_image_chunk + (0x20 - CCAM_MMAP_META_LENGTH) + 3,len32,next_image))
return None
if verbose >0:
print ("\n-----------reduced next frame byte pointer by 0x20 -------------")
len32 &= 0xffffff
# inserted_bytes = (32 - (((len32 % 32) + CCAM_MMAP_META) % 32)) % 32
#adjusting to actual...
......@@ -174,10 +198,10 @@ class X393CmprsAfi(object):
"segments":segments}
if verbose >0 :
print ("Inserted bytes after image before meta = 0x%x"%(inserted_bytes))
print ("Image start (relative to cirbuf) = 0x%x"%(img_start))
print ("Image start (relative to cirbuf) = 0x%x, image length = 0x%x"%(img_start, len32 ))
print ("Image time stamp = %s (%f)"%(tstr, fsec))
for s in segments:
print ("start_address = 0x%x, length = 0x%x"%(s[0],s[1]))
for i,s in enumerate(segments):
print ("segment %d: start_address = 0x%x, length = 0x%x"%(i, s[0],s[1]))
return result
......
This diff is collapsed.
......@@ -74,9 +74,9 @@ SENSOR_INTERFACE_HISPI = "HISPI"
SENSOR_INTERFACES={SENSOR_INTERFACE_PARALLEL: {"mv":2800, "freq":24.0, "iface":"2V5_LVDS"},
SENSOR_INTERFACE_HISPI: {"mv":1820, "freq":24.444, "iface":"1V8_LVDS"}}
SENSOR_DEFAULTS= {SENSOR_INTERFACE_PARALLEL: {"width":2592, "height":1944, "top":0, "left":0, "slave":0x48, "i2c_delay":100},
SENSOR_DEFAULTS= {SENSOR_INTERFACE_PARALLEL: {"width":2592, "height":1944, "top":0, "left":0, "slave":0x48, "i2c_delay":100, "bayer":3},
# SENSOR_INTERFACE_HISPI: {"width":4608, "height":3288, "top":0, "left":0, "slave":0x10, "i2c_delay":100}}
SENSOR_INTERFACE_HISPI: {"width":4384, "height":3288, "top":0, "left":0, "slave":0x10, "i2c_delay":100}}
SENSOR_INTERFACE_HISPI: {"width":4384, "height":3288, "top":0, "left":0, "slave":0x10, "i2c_delay":100, "bayer":2}}
class X393SensCmprs(object):
DRY_MODE = True # True
......@@ -151,6 +151,9 @@ class X393SensCmprs(object):
(see ls /sys/devices/amba.0/e0004000.ps7-i2c/i2c-0/0-0070/output_drivers)
@param quiet - reduce output
"""
if self.DRY_MODE:
print ("Not defined for simulation mode")
return
with open ( SI5338_PATH + "/output_drivers/" + iface, "w") as f:
print("2", file = f)
with open ( SI5338_PATH + "/output_clocks/out2_freq_fract","w") as f:
......@@ -191,6 +194,9 @@ class X393SensCmprs(object):
time.sleep(0.2)
self.setSensorIfaceVoltage(sub_pair=sub_pair, voltage_mv = voltage_mv)
time.sleep(0.2)
if self.DRY_MODE:
print ("Not defined for simulation mode")
return
with open (POWER393_PATH + "/channels_en","w") as f:
print(("vcc_sens01", "vcc_sens23")[sub_pair], file = f)
if quiet == 0:
......@@ -591,15 +597,24 @@ class X393SensCmprs(object):
repet_mode = True, # Normal mode, single trigger - just for debugging TODO: re-assign?
trig = False)
return True
def specify_window (self,
window_width = None, # 2592
window_height = None, # 1944
window_width = None, # 2592
window_height = None, # 1944
window_left = None, # 0
window_top = None, # 0? 1?
cmode = None,
bayer = None,
y_quality = None,
c_quality = None, # use "same" to save None
portrait = None,
gamma = None,
black = None, # 0.04
colorsat_blue = None, # colorsat_blue, #0x180 # 0x90 for 1x
colorsat_red = None, # colorsat_red, #0x16c, # 0xb6 for x1
verbose = 1
):
global GLBL_WINDOW
if GLBL_WINDOW is None:
GLBL_WINDOW = {}
......@@ -631,11 +646,76 @@ class X393SensCmprs(object):
cmode = GLBL_WINDOW["cmode"]
except:
cmode = 0
GLBL_WINDOW = {"width": window_width,
"height": window_height,
"left": window_left,
"top": window_top,
"cmode": cmode}
if bayer is None:
try:
bayer = GLBL_WINDOW["bayer"]
except:
bayer = SENSOR_DEFAULTS[sensorType]["bayer"]
if y_quality is None:
try:
y_quality = GLBL_WINDOW["y_quality"]
except:
y_quality = 100
if c_quality is None:
try:
c_quality = GLBL_WINDOW["c_quality"]
except:
c_quality = "same"
if c_quality == "same": # to save as None, not to not save
c_quality = None
if portrait is None:
try:
portrait = GLBL_WINDOW["portrait"]
except:
portrait = False
if gamma is None:
try:
gamma = GLBL_WINDOW["gamma"]
except:
gamma = 0.57
if black is None:
try:
black = GLBL_WINDOW["black"]
except:
black = 0.04
if colorsat_blue is None:
try:
colorsat_blue = GLBL_WINDOW["colorsat_blue"]
except:
colorsat_blue = 2.0 # *0x90
if colorsat_red is None:
try:
colorsat_red = GLBL_WINDOW["colorsat_red"]
except:
colorsat_red = 2.0 # *0xb6
GLBL_WINDOW = {"width": window_width,
"height": window_height,
"left": window_left,
"top": window_top,
"cmode": cmode,
"bayer": bayer,
"y_quality": y_quality,
"c_quality": c_quality,
"portrait": portrait,
"gamma": gamma,
"black": black,
"colorsat_blue": colorsat_blue,
"colorsat_red": colorsat_red,
}
if verbose > 1:
print("GLBL_WINDOW:")
for k in GLBL_WINDOW.keys():
print ("%15s:%s"%(k,str(GLBL_WINDOW[k])))
return GLBL_WINDOW
......@@ -682,7 +762,7 @@ class X393SensCmprs(object):
window_left = None, # 0, # 0
window_top = None, # 0, # 0? 1?
last_buf_frame = 1, # - just 2-frame buffer
colorsat_blue = 0x180, # 0x90 fo 1x
colorsat_blue = 0x180, # 0x90 for 1x
colorsat_red = 0x16c, # 0xb6 for x1
verbose = 1):
"""
......
[*]
[*] GTKWave Analyzer v3.3.66 (w)1999-2015 BSI
[*] Sun Nov 15 22:03:05 2015
[*] Wed Nov 18 00:58:20 2015
[*]
[dumpfile] "/home/andrey/git/x393/simulation/x393_testbench03-20151115142219571.fst"
[dumpfile_mtime] "Sun Nov 15 22:02:48 2015"
[dumpfile_size] 287600988
[savefile] "/home/andrey/git/x393/x393_testbench03.sav"
[timestart] 69077000
[timestart] 0
[size] 1823 1180
[pos] 0 0
*-18.688070 69667459 107947388 109212388 108561548 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
*-25.097748 69667459 107947388 109212388 108561548 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
[treeopen] x393_testbench03.
[treeopen] x393_testbench03.par12_hispi_psp4l0_i.
[treeopen] x393_testbench03.par12_hispi_psp4l0_i.cmprs_channel_block[0].
......@@ -930,7 +930,7 @@ x393_testbench03.x393_i.mcntrl393_i.sens_comp_block[0].mcntrl_linear_wr_sensor_i
@1401200
-mcntr_linear_rw_sensor0
-sensor_channel_0
@800200
@c00200
-DDR3
@28
x393_testbench03.ddr3_i.SDCLK
......@@ -943,7 +943,7 @@ x393_testbench03.ddr3_i.SDBA[2:0]
x393_testbench03.ddr3_i.SDD_D[15:0]
@200
-
@1000200
@1401200
-DDR3
@c00200
-simul_sensor_0
......@@ -995,7 +995,7 @@ x393_testbench03.simul_sensor12bits_2_i.stopped
x393_testbench03.simul_sensor12bits_2_i.stoppedd
@1401200
-simul_sensor_0
@800200
@c00200
-PX1
@28
x393_testbench03.PX1_MCLK_PRE
......@@ -1029,7 +1029,7 @@ x393_testbench03.PX1_MRST
x393_testbench03.PX1_OFST
x393_testbench03.PX1_SHUTTER
x393_testbench03.PX1_VACT
@1000200
@1401200
-PX1
@c00200
-SENSOR0
......@@ -1114,9 +1114,8 @@ x393_testbench03.par12_hispi_psp4l0_i.simul_clk_div_mult_i.en
@1401200
-clk_mult_div
-par_hispi_sel
@800200
@c00200
-sens_hispi_12l4
@c00201
-lane0
@28
x393_testbench03.x393_i.sensors393_i.sensor_channel_block[0].sensor_channel_i.sens_10398_i.sens_hispi12l4_i.ipclk
......@@ -1183,7 +1182,7 @@ x393_testbench03.x393_i.sensors393_i.sensor_channel_block[0].sensor_channel_i.se
x393_testbench03.x393_i.sensors393_i.sensor_channel_block[0].sensor_channel_i.sens_10398_i.sens_hispi12l4_i.hispi_lane[0].sens_hispi_lane_i.shift_val[1:0]
@1001200
-group_end
@1401201
@1401200
-lane0
@800200
-fifo0
......@@ -1257,7 +1256,7 @@ x393_testbench03.x393_i.sensors393_i.sensor_channel_block[0].sensor_channel_i.se
-group_end
@200
-
@1000200
@1401200
-sens_hispi_12l4
@c00200
-par_hspi_0
......@@ -2256,7 +2255,7 @@ x393_testbench03.x393_i.compressor393_i.cmprs_channel_block[0].jp_channel_i.huff
-
@1401200
-stuffer_metadata
@800200
@c00200
-new_compressor
@28
x393_testbench03.x393_i.compressor393_i.cmprs_channel_block[0].jp_channel_i.frame_start_dst
......@@ -2394,10 +2393,10 @@ x393_testbench03.x393_i.compressor393_i.cmprs_channel_block[0].jp_channel_i.huff
x393_testbench03.x393_i.compressor393_i.cmprs_channel_block[0].jp_channel_i.huffman_stuffer_meta_i.bit_stuffer_metadata_i.imgsz4[21:0]
@1000200
-comressor
@1401200
-new_compressor
@800200
- new_compressor_chn2
@c00200
- new_compressor_chn2
-tile_rd_chn2
@200
-
......@@ -2636,6 +2635,7 @@ x393_testbench03.x393_i.mcntrl393_i.sens_comp_block[2].mcntrl_tiled_rd_compresso
-
@1000200
-memory
@1401200
- new_compressor_chn2
@22
x393_testbench03.x393_i.compressor393_i.genblk3.cmprs_afi0_mux_i.fifo_rdata0[63:0]
......@@ -2712,6 +2712,15 @@ x393_testbench03.x393_i.mcntrl393_i.memctrl16_i.mcontr_sequencer_i.cmd1_buf_i.we
x393_testbench03.x393_i.mcntrl393_i.memctrl16_i.mcontr_sequencer_i.cmd1_buf_i.web[3:0]
@1401200
-memctrl_sequencer_cmd1buf
@28
x393_testbench03.x393_i.compressor393_i.genblk3.cmprs_afi0_mux_i.mclk
x393_testbench03.x393_i.compressor393_i.genblk3.cmprs_afi0_mux_i.hclk
x393_testbench03.x393_i.compressor393_i.genblk3.cmprs_afi0_mux_i.fifo_rst0
x393_testbench03.x393_i.compressor393_i.genblk3.cmprs_afi0_mux_i.fifo_ren0
@200
-
@29
x393_testbench03.x393_i.compressor393_i.genblk3.cmprs_afi0_mux_i.eof_written0
@200
-
[pattern_trace] 1
......
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