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 @@ ...@@ -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-20151115151104872.log</location> <location>/home/andrey/git/x393/vivado_logs/VivadoBitstream-20151117233913191.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-20151115151104872.log</location> <location>/home/andrey/git/x393/vivado_logs/VivadoOpt-20151117233913191.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-20151115151104872.log</location> <location>/home/andrey/git/x393/vivado_logs/VivadoOptPhys-20151117233913191.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-20151115151104872.log</location> <location>/home/andrey/git/x393/vivado_logs/VivadoOptPower-20151117233913191.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-20151115151104872.log</location> <location>/home/andrey/git/x393/vivado_logs/VivadoPlace-20151117233913191.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-20151115151104872.log</location> <location>/home/andrey/git/x393/vivado_logs/VivadoRoute-20151117233913191.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-20151115150613168.log</location> <location>/home/andrey/git/x393/vivado_logs/VivadoSynthesis-20151117233307674.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-20151115151104872.log</location> <location>/home/andrey/git/x393/vivado_logs/VivadoTimimgSummaryReportImplemented-20151117233913191.log</location>
</link> </link>
<link> <link>
<name>vivado_logs/VivadoTimimgSummaryReportSynthesis.log</name> <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), ...@@ -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 [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 [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] 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 [3:0] eof_stb; // single-cycle pulse after fifo_flush is asserted
// reg [1:0] w64_cnt; // count 64-bit words in a chunk // reg [1:0] w64_cnt; // count 64-bit words in a chunk
// adjusted counters used for channel arbitration // 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 [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 [17:0] counts_corr1; // first arbitration level winning values
reg [8:0] counts_corr2; // second 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), ...@@ -231,6 +232,8 @@ each group of 4 bits per channel : bits [1:0] - select, bit[2] - sset (0 - nop),
// 3'h4 : // 3'h4 :
// ({1'b0,left_to_eof[winner2 * 8 +: 2]} + 3'h1); // ({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 wire [1:0] pre_chunk_inc_m1 = (|counts_corr2[7:2])? // Would like to increment, if not roll-over
2'h3 : 2'h3 :
left_to_eof[winner2 * 8 +: 2]; 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), ...@@ -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 [26:0] chunk_ptr_rd;
wire [ 3:0] chunk_ptr_ra; 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]; wire [ 7:0] items_left = counts_corr2[8] ? left_to_eof[(winner2 * 8) +: 8] : counts_corr2[7:0];
reg [5:0] afi_awid_r; 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 [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_status_w = cmd_we && ((cmd_a & 'hc) == CMPRS_AFIMUX_STATUS_CNTRL);
assign cmd_we_mode_w = cmd_we && (cmd_a == CMPRS_AFIMUX_MODE); 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), ...@@ -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 // 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 // Done, updating at the first (not last) word of 4
// Now seems that eof_stb[i] & fifo_ren{i} == 0 // 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; 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; 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; 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; 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) // Calculate corrected values decrementing currently served channel (if any) values by 1 (latency 1 clk)
......
...@@ -31,7 +31,8 @@ ...@@ -31,7 +31,8 @@
* contains all the components and scripts required to completely simulate it * contains all the components and scripts required to completely simulate it
* with at least one of the Free Software programs. * 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 - 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'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 // parameter FPGA_VERSION = 32'h0393006e; // Trying lane switch again after bug fix, failing 1 in ddr3_mclk -> ddr3_clk_div by -0.023
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
@contact: andrey@elphel.coml @contact: andrey@elphel.coml
@deffield updated: Updated @deffield updated: Updated
''' '''
from __future__ import print_function
from __builtin__ import str from __builtin__ import str
__author__ = "Andrey Filippov" __author__ = "Andrey Filippov"
__copyright__ = "Copyright 2015, Elphel, Inc." __copyright__ = "Copyright 2015, Elphel, Inc."
...@@ -43,6 +44,10 @@ from argparse import ArgumentParser ...@@ -43,6 +44,10 @@ from argparse import ArgumentParser
#import argparse #import argparse
from argparse import RawDescriptionHelpFormatter from argparse import RawDescriptionHelpFormatter
import time import time
import socket
import select
from import_verilog_parameters import ImportVerilogParameters from import_verilog_parameters import ImportVerilogParameters
#from import_verilog_parameters import VerilogParameters #from import_verilog_parameters import VerilogParameters
from verilog_utils import hx from verilog_utils import hx
...@@ -217,6 +222,8 @@ USAGE ...@@ -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("-x", "--exceptions", dest="exceptions", action="count", help="Exit on more exceptions [default: %(default)s]")
parser.add_argument("-l", "--localparams", dest="localparams", action="store", default="", parser.add_argument("-l", "--localparams", dest="localparams", action="store", default="",
help="path were modified parameters are saved [default: %(default)s]", metavar="path") 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 # Process arguments
args = parser.parse_args() args = parser.parse_args()
...@@ -391,18 +398,75 @@ USAGE ...@@ -391,18 +398,75 @@ USAGE
''' '''
#TODO: use readline #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): if (args.interactive):
line ="" line =""
while True: 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() tim=time.time()
#remove comment from the input line #remove comment from the input line
if line.find("#") > 0: had_comment=False
if line.find("#") >= 0:
line=line[:line.find("#")] line=line[:line.find("#")]
had_comment=True
lineList=line.split() lineList=line.split()
if not line: if not line:
if not had_comment:
print ('Use "quit" to exit, "help" - for help') print ('Use "quit" to exit, "help" - for help')
elif (line == 'quit') or (line == 'exit'): elif (line == 'quit') or (line == 'exit'):
if soc_conn:
soc_conn.send('0\n') # OK\n')
soc_conn.close()
# soc_conn=None
break break
elif line== 'help' : elif line== 'help' :
print ("\nAvailable tasks:") print ("\nAvailable tasks:")
...@@ -412,7 +476,26 @@ USAGE ...@@ -412,7 +476,26 @@ USAGE
print ('\n"parameters" and "defines" list known defined parameters and macros') print ('\n"parameters" and "defines" list known defined parameters and macros')
print ("args.exception=%d, QUIET=%d"%(args.exceptions,QUIET)) 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 ("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") 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': elif lineList[0].upper() == 'R':
if len(lineList)>1: if len(lineList)>1:
if (lineList[1].upper() == "ON") or (lineList[1].upper() == "1") or (lineList[1].upper() == "TRUE"): if (lineList[1].upper() == "ON") or (lineList[1].upper() == "1") or (lineList[1].upper() == "TRUE"):
...@@ -506,6 +589,10 @@ USAGE ...@@ -506,6 +589,10 @@ USAGE
vrlg_text=vrlg_text[:index+1]+"\n"+predefines vrlg_text=vrlg_text[:index+1]+"\n"+predefines
except: except:
print ("Failed to update %s - it is either missing or does not have a '%s'"%(vrlg_path,magic)) 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 continue
try: try:
with open (vrlg_path, "w") as vrlg_file: with open (vrlg_path, "w") as vrlg_file:
...@@ -536,6 +623,16 @@ USAGE ...@@ -536,6 +623,16 @@ USAGE
rslt= execTask(cmdLine) rslt= execTask(cmdLine)
if showResult: 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 #http://stackoverflow.com/questions/11781265/python-using-getattr-to-call-function-with-variable-parameters
#*getattr(foo,bar)(*params) #*getattr(foo,bar)(*params)
return 0 return 0
......
...@@ -337,7 +337,7 @@ CMPRS_CBIT_CMODE_JP46__TYPE = str ...@@ -337,7 +337,7 @@ CMPRS_CBIT_CMODE_JP46__TYPE = str
NUM_CYCLES_17__RAW = str NUM_CYCLES_17__RAW = str
DFLT_WBUF_DELAY__RAW = str DFLT_WBUF_DELAY__RAW = str
CAMSYNC_POST_MAGIC__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_24__RAW = str
NUM_CYCLES_13__RAW = str NUM_CYCLES_13__RAW = str
LOGGER_CONF_MSG__RAW = str LOGGER_CONF_MSG__RAW = str
...@@ -374,7 +374,7 @@ SENS_CTRL_QUADRANTS__TYPE = str ...@@ -374,7 +374,7 @@ SENS_CTRL_QUADRANTS__TYPE = str
SENS_LENS_BY_MASK__RAW = str SENS_LENS_BY_MASK__RAW = str
SENS_CTRL_GP0__TYPE = str SENS_CTRL_GP0__TYPE = str
DFLT_REFRESH_ADDR = int DFLT_REFRESH_ADDR = int
SENS_LENS_BX_MASK__TYPE = str HISPI_FIFO_START__TYPE = str
TEST01_SUSPEND__RAW = str TEST01_SUSPEND__RAW = str
SENS_GAMMA_HEIGHT01__TYPE = str SENS_GAMMA_HEIGHT01__TYPE = str
CMPRS_HIFREQ_REG_INC = int CMPRS_HIFREQ_REG_INC = int
...@@ -511,6 +511,7 @@ STATUS_MSB_RSHFT = int ...@@ -511,6 +511,7 @@ STATUS_MSB_RSHFT = int
CMPRS_CONTROL_REG__RAW = str CMPRS_CONTROL_REG__RAW = str
CLKIN_PERIOD__TYPE = str CLKIN_PERIOD__TYPE = str
SENS_GAMMA_CTRL = int SENS_GAMMA_CTRL = int
HISPI_WAIT_ALL_LANES__TYPE = str
SENSIO_RADDR = int SENSIO_RADDR = int
BUF_CLK1X_PCLK__RAW = str BUF_CLK1X_PCLK__RAW = str
GPIO_N__TYPE = str GPIO_N__TYPE = str
...@@ -525,6 +526,7 @@ BUFFER_DEPTH32__TYPE = str ...@@ -525,6 +526,7 @@ BUFFER_DEPTH32__TYPE = str
CMPRS_CBIT_CMODE_JPEG18 = int CMPRS_CBIT_CMODE_JPEG18 = int
MCONTR_TOP_16BIT_REFRESH_ADDRESS = int MCONTR_TOP_16BIT_REFRESH_ADDRESS = int
HISTOGRAM_RADDR0__TYPE = str HISTOGRAM_RADDR0__TYPE = str
HISPI_FIFO_DEPTH__TYPE = str
LOGGER_CONF_SYN_BITS = int LOGGER_CONF_SYN_BITS = int
NUM_CYCLES_19 = int NUM_CYCLES_19 = int
SENS_CTRL_GP1__TYPE = str SENS_CTRL_GP1__TYPE = str
...@@ -533,6 +535,7 @@ SENS_CTRL_QUADRANTS_WIDTH__RAW = str ...@@ -533,6 +535,7 @@ SENS_CTRL_QUADRANTS_WIDTH__RAW = str
SENSOR_FIFO_DELAY__RAW = str SENSOR_FIFO_DELAY__RAW = str
DLY_SET = int DLY_SET = int
CMDFRAMESEQ_CTRL__TYPE = str CMDFRAMESEQ_CTRL__TYPE = str
HISPI_FIFO_DEPTH__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
...@@ -774,6 +777,7 @@ MULT_SAXI_BSLOG3__TYPE = str ...@@ -774,6 +777,7 @@ MULT_SAXI_BSLOG3__TYPE = str
CLKFBOUT_MULT__RAW = str CLKFBOUT_MULT__RAW = str
CMPRS_STATUS_REG_INC__RAW = str CMPRS_STATUS_REG_INC__RAW = str
HISTOGRAM_RADDR0__RAW = str HISTOGRAM_RADDR0__RAW = str
HISPI_KEEP_IRST = int
STATUS_ADDR_MASK = int STATUS_ADDR_MASK = int
PXD_CAPACITANCE = str PXD_CAPACITANCE = str
SENS_LENS_AY = int SENS_LENS_AY = int
...@@ -994,6 +998,7 @@ MCNTRL_TILED_STARTADDR = int ...@@ -994,6 +998,7 @@ MCNTRL_TILED_STARTADDR = int
TILE_HEIGHT__TYPE = str TILE_HEIGHT__TYPE = str
MCNTRL_TILED_CHN4_ADDR__TYPE = str MCNTRL_TILED_CHN4_ADDR__TYPE = str
HISPI_NUMLANES__TYPE = str HISPI_NUMLANES__TYPE = str
HISPI_FIFO_START = int
TILED_STARTX__TYPE = str TILED_STARTX__TYPE = str
FFCLK0_DIFF_TERM__RAW = str FFCLK0_DIFF_TERM__RAW = str
MCNTRL_PS_STATUS_CNTRL__RAW = str MCNTRL_PS_STATUS_CNTRL__RAW = str
...@@ -1075,6 +1080,7 @@ NUM_CYCLES_25__RAW = str ...@@ -1075,6 +1080,7 @@ NUM_CYCLES_25__RAW = str
SENSOR_NUM_HISTOGRAM__RAW = str SENSOR_NUM_HISTOGRAM__RAW = str
CMPRS_CBIT_CMODE = int CMPRS_CBIT_CMODE = int
HIST_SAXI_ADDR_MASK__RAW = str HIST_SAXI_ADDR_MASK__RAW = str
HISPI_WAIT_ALL_LANES__RAW = str
MEMBRIDGE_STATUS_REG__TYPE = str MEMBRIDGE_STATUS_REG__TYPE = str
CLKIN_PERIOD__RAW = str CLKIN_PERIOD__RAW = str
SENS_SYNC_MULT__RAW = str SENS_SYNC_MULT__RAW = str
...@@ -1340,6 +1346,7 @@ SENS_GAMMA_ADDR_MASK__RAW = str ...@@ -1340,6 +1346,7 @@ SENS_GAMMA_ADDR_MASK__RAW = str
DLY_LANE1_IDELAY__TYPE = str DLY_LANE1_IDELAY__TYPE = str
SENS_LENS_BY_MASK = int SENS_LENS_BY_MASK = int
DEBUG_MASK__RAW = str DEBUG_MASK__RAW = str
MCNTRL_TEST01_CHN2_MODE__TYPE = str
MEMBRIDGE_ADDR__RAW = str MEMBRIDGE_ADDR__RAW = str
CMPRS_COLOR_SATURATION__RAW = str CMPRS_COLOR_SATURATION__RAW = str
AXI_RD_ADDR_BITS = int AXI_RD_ADDR_BITS = int
...@@ -1514,6 +1521,7 @@ HISPI_MMCM0 = str ...@@ -1514,6 +1521,7 @@ HISPI_MMCM0 = str
HISPI_MMCM3 = str HISPI_MMCM3 = str
HISPI_MMCM2 = str HISPI_MMCM2 = str
MULT_SAXI_CNTRL_ADDR__TYPE = str MULT_SAXI_CNTRL_ADDR__TYPE = str
HISPI_KEEP_IRST__TYPE = str
MULT_SAXI_STATUS_REG__TYPE = str MULT_SAXI_STATUS_REG__TYPE = str
MEMCLK_IOSTANDARD__TYPE = str MEMCLK_IOSTANDARD__TYPE = str
NUM_CYCLES_27__TYPE = str NUM_CYCLES_27__TYPE = str
...@@ -1851,6 +1859,7 @@ LOGGER_PAGE_MSG__RAW = str ...@@ -1851,6 +1859,7 @@ LOGGER_PAGE_MSG__RAW = str
MCONTR_TOP_16BIT_STATUS_CNTRL = int MCONTR_TOP_16BIT_STATUS_CNTRL = int
CMPRS_CBIT_CMODE_MONO4__RAW = str CMPRS_CBIT_CMODE_MONO4__RAW = str
MULT_SAXI_MASK = int MULT_SAXI_MASK = int
SENS_LENS_BX_MASK__TYPE = str
MCNTRL_SCANLINE_WINDOW_STARTXY__TYPE = str MCNTRL_SCANLINE_WINDOW_STARTXY__TYPE = str
CMDFRAMESEQ_DEPTH__TYPE = str CMDFRAMESEQ_DEPTH__TYPE = str
DLY_LANE0_IDELAY__RAW = str DLY_LANE0_IDELAY__RAW = str
...@@ -1866,9 +1875,10 @@ CLKIN_PERIOD = int ...@@ -1866,9 +1875,10 @@ CLKIN_PERIOD = int
RSEL__TYPE = str RSEL__TYPE = str
CMDFRAMESEQ_ADDR_INC__TYPE = str CMDFRAMESEQ_ADDR_INC__TYPE = str
LOGGER_CONF_GPS_BITS = int LOGGER_CONF_GPS_BITS = int
NUM_CYCLES_07__RAW = str HISPI_FIFO_DEPTH = int
CLKFBOUT_PHASE = float CLKFBOUT_PHASE = float
SENS_GAMMA_ADDR_DATA = int SENS_GAMMA_ADDR_DATA = int
HISPI_WAIT_ALL_LANES = int
SENS_GAMMA_ADDR_DATA__TYPE = str SENS_GAMMA_ADDR_DATA__TYPE = str
CAMSYNC_DELAY__TYPE = str CAMSYNC_DELAY__TYPE = str
DFLT_REFRESH_PERIOD__RAW = str DFLT_REFRESH_PERIOD__RAW = str
...@@ -1893,6 +1903,7 @@ PHASE_CLK2X_PCLK__RAW = str ...@@ -1893,6 +1903,7 @@ PHASE_CLK2X_PCLK__RAW = str
MCNTRL_TEST01_STATUS_REG_CHN1_ADDR__TYPE = str MCNTRL_TEST01_STATUS_REG_CHN1_ADDR__TYPE = str
MCONTR_TOP_0BIT_ADDR__RAW = str MCONTR_TOP_0BIT_ADDR__RAW = str
HISPI_IBUF_LOW_PWR = str HISPI_IBUF_LOW_PWR = str
HISPI_KEEP_IRST__RAW = str
LOGGER_CONF_DBG__TYPE = str LOGGER_CONF_DBG__TYPE = str
AFI_SIZE64__RAW = str AFI_SIZE64__RAW = str
SENSI2C_TBL_RNWREG = int SENSI2C_TBL_RNWREG = int
...@@ -1957,6 +1968,7 @@ SENSI2C_TBL_DLY = int ...@@ -1957,6 +1968,7 @@ SENSI2C_TBL_DLY = int
SENSIO_STATUS__RAW = str SENSIO_STATUS__RAW = str
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
DLY_DQ_ODELAY__RAW = str DLY_DQ_ODELAY__RAW = str
MCNTRL_TILED_PENDING_CNTR_BITS__RAW = str MCNTRL_TILED_PENDING_CNTR_BITS__RAW = str
CMPRS_CORING_BITS = int CMPRS_CORING_BITS = int
......
...@@ -173,6 +173,9 @@ class X393AxiControlStatus(object): ...@@ -173,6 +173,9 @@ class X393AxiControlStatus(object):
{FILE:"vccint", ITEM:"VCCint", UNITS:"V", SCALE: 0.001}, {FILE:"vccint", ITEM:"VCCint", UNITS:"V", SCALE: 0.001},
{FILE:"vccbram", ITEM:"VCCbram", UNITS:"V", SCALE: 0.001}] {FILE:"vccbram", ITEM:"VCCbram", UNITS:"V", SCALE: 0.001}]
print("hwmon:") print("hwmon:")
if self.DRY_MODE:
print ("Not defined for simulation mode")
return
for par in HWMON_ITEMS: for par in HWMON_ITEMS:
with open(HWMON_PATH + par[FILE]) as f: with open(HWMON_PATH + par[FILE]) as f:
d=int(f.read()) d=int(f.read())
......
...@@ -110,6 +110,7 @@ class X393CmprsAfi(object): ...@@ -110,6 +110,7 @@ class X393CmprsAfi(object):
@param channel - AFI input channel (0..3) - with 2 AFIs - 0..1 only @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 @return - memory segments (1 or two) with image data, timestamp in numeric and string format
""" """
if verbose >0:
print ("\n------------ channel %d --------------"%(channel)) print ("\n------------ channel %d --------------"%(channel))
print ("x393_sens_cmprs.GLBL_WINDOW = ", x393_sens_cmprs.GLBL_WINDOW) print ("x393_sens_cmprs.GLBL_WINDOW = ", x393_sens_cmprs.GLBL_WINDOW)
if (self.DRY_MODE): if (self.DRY_MODE):
...@@ -123,14 +124,37 @@ class X393CmprsAfi(object): ...@@ -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) # 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, next_image = self.afi_mux_get_image_pointer(port_afi = port_afi,
channel = channel) 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, 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 last_image_chunk = next_image - 0x40
if last_image_chunk < 0: if last_image_chunk < 0:
last_image_chunk += circbuf_len last_image_chunk += circbuf_len
len32 = self.x393_mem.read_mem(cirbuf_start + last_image_chunk + (0x20 - CCAM_MMAP_META_LENGTH)) len32 = self.x393_mem.read_mem(cirbuf_start + last_image_chunk + (0x20 - CCAM_MMAP_META_LENGTH))
markerFF = len32 >> 24 markerFF = len32 >> 24
if (markerFF != 0xff): 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)) 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 return None
if verbose >0:
print ("\n-----------reduced next frame byte pointer by 0x20 -------------")
len32 &= 0xffffff len32 &= 0xffffff
# inserted_bytes = (32 - (((len32 % 32) + CCAM_MMAP_META) % 32)) % 32 # inserted_bytes = (32 - (((len32 % 32) + CCAM_MMAP_META) % 32)) % 32
#adjusting to actual... #adjusting to actual...
...@@ -174,10 +198,10 @@ class X393CmprsAfi(object): ...@@ -174,10 +198,10 @@ class X393CmprsAfi(object):
"segments":segments} "segments":segments}
if verbose >0 : if verbose >0 :
print ("Inserted bytes after image before meta = 0x%x"%(inserted_bytes)) 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)) print ("Image time stamp = %s (%f)"%(tstr, fsec))
for s in segments: for i,s in enumerate(segments):
print ("start_address = 0x%x, length = 0x%x"%(s[0],s[1])) print ("segment %d: start_address = 0x%x, length = 0x%x"%(i, s[0],s[1]))
return result return result
......
...@@ -39,8 +39,11 @@ import x393_axi_control_status ...@@ -39,8 +39,11 @@ import x393_axi_control_status
import x393_utils import x393_utils
#import time #import time
import x393_sens_cmprs import x393_sens_cmprs
import x393_sensor
import x393_cmprs
import x393_cmprs_afi import x393_cmprs_afi
import vrlg import vrlg
import time
STD_QUANT_TBLS = { STD_QUANT_TBLS = {
"Y_landscape":( 16, 11, 10, 16, 24, 40, 51, 61, "Y_landscape":( 16, 11, 10, 16, 24, 40, 51, 61,
12, 12, 14, 19, 26, 58, 60, 55, 12, 12, 14, 19, 26, 58, 60, 55,
...@@ -162,7 +165,8 @@ class X393Jpeg(object): ...@@ -162,7 +165,8 @@ class X393Jpeg(object):
x393_utils=None x393_utils=None
x393_cmprs_afi = None x393_cmprs_afi = None
x393_sens_cmprs = None x393_sens_cmprs = None
x393Sensor = None
x393Cmprs = None
verbose=1 verbose=1
def __init__(self, debug_mode=1,dry_mode=True, saveFileName=None): def __init__(self, debug_mode=1,dry_mode=True, saveFileName=None):
self.DEBUG_MODE= debug_mode self.DEBUG_MODE= debug_mode
...@@ -173,6 +177,8 @@ class X393Jpeg(object): ...@@ -173,6 +177,8 @@ class X393Jpeg(object):
self.x393_cmprs_afi = x393_cmprs_afi.X393CmprsAfi(debug_mode,dry_mode) self.x393_cmprs_afi = x393_cmprs_afi.X393CmprsAfi(debug_mode,dry_mode)
self.x393_utils= x393_utils.X393Utils(debug_mode,dry_mode, saveFileName) # should not overwrite save file path self.x393_utils= x393_utils.X393Utils(debug_mode,dry_mode, saveFileName) # should not overwrite save file path
self.x393_sens_cmprs = x393_sens_cmprs.X393SensCmprs(debug_mode,dry_mode, saveFileName) self.x393_sens_cmprs = x393_sens_cmprs.X393SensCmprs(debug_mode,dry_mode, saveFileName)
self.x393Sensor = x393_sensor.X393Sensor(debug_mode,dry_mode, saveFileName)
self.x393Cmprs = x393_cmprs.X393Cmprs(debug_mode,dry_mode, saveFileName)
try: try:
self.verbose=vrlg.VERBOSE self.verbose=vrlg.VERBOSE
...@@ -627,6 +633,135 @@ class X393Jpeg(object): ...@@ -627,6 +633,135 @@ class X393Jpeg(object):
return {"header":buf, return {"header":buf,
"quantization":qtables["fpga"], "quantization":qtables["fpga"],
"huffman": self.huff_tables[FPGA_HUFFMAN_TABLE]} "huffman": self.huff_tables[FPGA_HUFFMAN_TABLE]}
def jpeg_acquire_write(self,
file_path = "img.jpeg",
channel = 0,
cmode = None, # vrlg.CMPRS_CBIT_CMODE_JPEG18, # read it from the saved
bayer = None,
y_quality = None,
c_quality = None,
portrait = None,
gamma = None, # 0.57,
black = None, # 0.04,
colorsat_blue = None, # 2.0, colorsat_blue, #0x180 # 0x90 for 1x
colorsat_red = None, # 2.0, colorsat_red, #0x16c, # 0xb6 for x1
server_root = "/www/pages/",
verbose = 1):
"""
Acquire JPEG/JP4 image(s), wait completion, create file(s)
@param file_path - camera file system path (starts with "/") or relative to web server root
@param channel - compressor channel
@param cmode - 0: color JPEG, 5 - JP4
@param bayer - Bayer shift
@param y_quality - 1..100 - quantization quality for Y component
@param c_quality - 1..100 - quantization quality for color components ("same" - use y_quality)
@param portrait - False - use normal order, True - transpose for portrait mode images
@param gamma - gamma value (1.0 - linear)
@param black - black level, 1.0 corresponds to 256 for 8bit values
@param colorsat_blue - color saturation for blue (10 bits), 0x90 for 100%
@param colorsat_red - color saturation for red (10 bits), 0xb6 for 100%
@param server_root - files ystem path to the web server root directory
@param verbose - verbose level
"""
window = self.x393_sens_cmprs.specify_window(verbose = verbose) # will be updated if more parameters are specified
#First update quality/portrait/compression mode
if (y_quality is not None) or (c_quality is not None) or (portrait is not None):
window = self.x393_sens_cmprs.specify_window(y_quality= y_quality,
c_quality = c_quality,
portrait = portrait,
verbose = verbose)
self.set_qtables(chn = channel,
index = 0, # index of a table pair
y_quality = window["y_quality"],
c_quality = window["c_quality"],
portrait = window["portrait"],
verbose = verbose)
# recalculate gamma if needed with program_gamma
if (gamma is not None) or (black is not None):
window = self.x393_sens_cmprs.specify_window(gamma= gamma,
black = black)
self.x393Sensor.program_gamma (num_sensor = channel,
sub_channel = 0,
gamma = window["gamma"],
black = window["black"],
page = 0)
# Update compressor settings if needed setup_compressor
if (cmode is not None) or (bayer is not None) or (colorsat_blue is not None) or (colorsat_red is not None):
window = self.x393_sens_cmprs.specify_window(cmode= cmode,
bayer = bayer,
colorsat_blue = colorsat_blue,
colorsat_red = colorsat_red,
verbose = verbose)
self.x393_sens_cmprs.setup_compressor(chn = channel, # All
cmode = window["cmode"],
bayer = window["bayer"],
qbank = 0,
dc_sub = 1,
multi_frame = 1,
focus_mode = 0,
coring = 0,
window_width = window["width"], #None, # 2592, # 2592
window_height = window["height"], #None, # 1944, # 1944
window_left = window["left"], #None, # 0, # 0
window_top = window["top"], #None, # 0, # 0? 1?
last_buf_frame = 1, # - just 2-frame buffer
colorsat_blue = min(int(round(window["colorsat_blue"]*0x90)),1023),
colorsat_red = min(int(round(window["colorsat_red"]*0xb6)),1023),
verbose = verbose)
# read and save image pointer for each channel (report mode/status should be configured appropriately) afi_mux_get_image_pointer
old_pointers=[]
for i in range(4):
old_pointers.append(self.x393_cmprs_afi.afi_mux_get_image_pointer(
port_afi= 0,
channel = i))
#start single-frame acquisition (on each channel)
self.x393Cmprs.compressor_control(chn = channel,
run_mode = 2)
#Wait with timeout for all enabled images
channel_mask = [False, False, False, False]
try:
if (channel == all) or (channel[0].upper() == "A"): #all is a built-in function
for i in range(4):
channel_mask[i]=True
else:
channel_mask[int(channel)]=True
except:
channel_mask[int(channel)]=True
now = time.time()
timeout_time = now + 1.0 #seconds
#print("channel_mask = ",channel_mask, "channel = ",channel )
while time.time() < timeout_time:
allNew = True;
for i, en in enumerate(channel_mask):
if en:
if self.x393_cmprs_afi.afi_mux_get_image_pointer(port_afi= 0, channel = i) == old_pointers[i]: # frame pointer is not updated
allNew = False;
break;
if allNew: # all selected channels have updated frame pointers
break
numChannels=0;
for en in channel_mask:
if en:
numChannels+=1
#Now generate JPEG/JP4 file
self.jpeg_write(file_path = file_path,
channel = channel,
y_quality = window["y_quality"],
c_quality = window["c_quality"],
portrait = window["portrait"],
byrshift = window["bayer"],
server_root = server_root,
verbose = verbose)
if verbose > 0:
self.x393_sens_cmprs.specify_window(verbose = 2)
return numChannels
def jpeg_write(self, def jpeg_write(self,
file_path = "img.jpeg", file_path = "img.jpeg",
channel = 0, channel = 0,
...@@ -656,7 +791,7 @@ class X393Jpeg(object): ...@@ -656,7 +791,7 @@ class X393Jpeg(object):
allFiles = True allFiles = True
except: except:
pass pass
window = self.x393_sens_cmprs.specify_window() window = self.x393_sens_cmprs.specify_window(verbose = verbose)
if window["cmode"] == vrlg.CMPRS_CBIT_CMODE_JP4: if window["cmode"] == vrlg.CMPRS_CBIT_CMODE_JP4:
file_path = file_path.replace(".jpeg",".jp4") file_path = file_path.replace(".jpeg",".jp4")
elif window["cmode"] == vrlg.CMPRS_CBIT_CMODE_JP46: elif window["cmode"] == vrlg.CMPRS_CBIT_CMODE_JP46:
...@@ -728,13 +863,16 @@ class X393Jpeg(object): ...@@ -728,13 +863,16 @@ class X393Jpeg(object):
channel = channel, channel = channel,
cirbuf_start = x393_sens_cmprs.GLBL_CIRCBUF_STARTS[channel], cirbuf_start = x393_sens_cmprs.GLBL_CIRCBUF_STARTS[channel],
circbuf_len = x393_sens_cmprs.GLBL_CIRCBUF_CHN_SIZE, circbuf_len = x393_sens_cmprs.GLBL_CIRCBUF_CHN_SIZE,
verbose = 1) verbose = verbose)
if verbose > 0 :
print ("meta = ",meta) print ("meta = ",meta)
if verbose > 1 :
for s in meta["segments"]: for s in meta["segments"]:
print ("start_address = 0x%x, length = 0x%x"%(s[0],s[1])) print ("start_address = 0x%x, length = 0x%x"%(s[0],s[1]))
with open (server_root+file_path, "w+b") as bf: with open (server_root+file_path, "w+b") as bf:
bf.write(jpeg_data["header"]) bf.write(jpeg_data["header"])
for s in meta["segments"]: for s in meta["segments"]:
if verbose > 1 :
print ("start_address = 0x%x, length = 0x%x"%(s[0],s[1])) print ("start_address = 0x%x, length = 0x%x"%(s[0],s[1]))
self.x393_mem._mem_write_to_file (bf = bf, self.x393_mem._mem_write_to_file (bf = bf,
start_addr = s[0], start_addr = s[0],
...@@ -839,7 +977,7 @@ cd /usr/local/verilog/; test_mcntrl.py @hargs ...@@ -839,7 +977,7 @@ cd /usr/local/verilog/; test_mcntrl.py @hargs
measure_all "*DI" measure_all "*DI"
setup_all_sensors True None 0xf setup_all_sensors True None 0xf
#compressor_control all None None None None None 3 #compressor_control all None None None None None 3
set_sensor_hispi_lanes 0 1 2 3 0 #set_sensor_hispi_lanes 0 1 2 3 0
compressor_control all None None None None None 2 compressor_control all None None None None None 2
program_gamma all 0 0.57 0.04 program_gamma all 0 0.57 0.04
write_sensor_i2c 0 1 0 0x030600b4 write_sensor_i2c 0 1 0 0x030600b4
...@@ -860,8 +998,6 @@ print_sensor_i2c 0 0x3070 0xff 0x10 0 ...@@ -860,8 +998,6 @@ print_sensor_i2c 0 0x3070 0xff 0x10 0
#test - running 8, 8-bit #test - running 8, 8-bit
write_sensor_i2c 0 1 0 0x30700101 write_sensor_i2c 0 1 0 0x30700101
#Exposure 0x800 lines
write_sensor_i2c 0 1 0 0x30120800
#default gain = 0xa, set red and blue (outdoors) #default gain = 0xa, set red and blue (outdoors)
write_sensor_i2c 0 1 0 0x3028000a write_sensor_i2c 0 1 0 0x3028000a
...@@ -873,6 +1009,9 @@ write_sensor_i2c 0 1 0 0x3028000a ...@@ -873,6 +1009,9 @@ write_sensor_i2c 0 1 0 0x3028000a
write_sensor_i2c 0 1 0 0x302c000b write_sensor_i2c 0 1 0 0x302c000b
write_sensor_i2c 0 1 0 0x302e0010 write_sensor_i2c 0 1 0 0x302e0010
#Exposure 0x800 lines
write_sensor_i2c 0 1 0 0x30120800
write_sensor_i2c 0 1 0 0x301a001c write_sensor_i2c 0 1 0 0x301a001c
print_sensor_i2c 0 0x31c6 0xff 0x10 0 print_sensor_i2c 0 0x31c6 0xff 0x10 0
......
...@@ -74,9 +74,9 @@ SENSOR_INTERFACE_HISPI = "HISPI" ...@@ -74,9 +74,9 @@ SENSOR_INTERFACE_HISPI = "HISPI"
SENSOR_INTERFACES={SENSOR_INTERFACE_PARALLEL: {"mv":2800, "freq":24.0, "iface":"2V5_LVDS"}, 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_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":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): class X393SensCmprs(object):
DRY_MODE = True # True DRY_MODE = True # True
...@@ -151,6 +151,9 @@ class X393SensCmprs(object): ...@@ -151,6 +151,9 @@ class X393SensCmprs(object):
(see ls /sys/devices/amba.0/e0004000.ps7-i2c/i2c-0/0-0070/output_drivers) (see ls /sys/devices/amba.0/e0004000.ps7-i2c/i2c-0/0-0070/output_drivers)
@param quiet - reduce output @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: with open ( SI5338_PATH + "/output_drivers/" + iface, "w") as f:
print("2", file = f) print("2", file = f)
with open ( SI5338_PATH + "/output_clocks/out2_freq_fract","w") as f: with open ( SI5338_PATH + "/output_clocks/out2_freq_fract","w") as f:
...@@ -191,6 +194,9 @@ class X393SensCmprs(object): ...@@ -191,6 +194,9 @@ class X393SensCmprs(object):
time.sleep(0.2) time.sleep(0.2)
self.setSensorIfaceVoltage(sub_pair=sub_pair, voltage_mv = voltage_mv) self.setSensorIfaceVoltage(sub_pair=sub_pair, voltage_mv = voltage_mv)
time.sleep(0.2) time.sleep(0.2)
if self.DRY_MODE:
print ("Not defined for simulation mode")
return
with open (POWER393_PATH + "/channels_en","w") as f: with open (POWER393_PATH + "/channels_en","w") as f:
print(("vcc_sens01", "vcc_sens23")[sub_pair], file = f) print(("vcc_sens01", "vcc_sens23")[sub_pair], file = f)
if quiet == 0: if quiet == 0:
...@@ -598,8 +604,17 @@ class X393SensCmprs(object): ...@@ -598,8 +604,17 @@ class X393SensCmprs(object):
window_left = None, # 0 window_left = None, # 0
window_top = None, # 0? 1? window_top = None, # 0? 1?
cmode = None, 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 verbose = 1
): ):
global GLBL_WINDOW global GLBL_WINDOW
if GLBL_WINDOW is None: if GLBL_WINDOW is None:
GLBL_WINDOW = {} GLBL_WINDOW = {}
...@@ -631,11 +646,76 @@ class X393SensCmprs(object): ...@@ -631,11 +646,76 @@ class X393SensCmprs(object):
cmode = GLBL_WINDOW["cmode"] cmode = GLBL_WINDOW["cmode"]
except: except:
cmode = 0 cmode = 0
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, GLBL_WINDOW = {"width": window_width,
"height": window_height, "height": window_height,
"left": window_left, "left": window_left,
"top": window_top, "top": window_top,
"cmode": cmode} "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 return GLBL_WINDOW
...@@ -682,7 +762,7 @@ class X393SensCmprs(object): ...@@ -682,7 +762,7 @@ class X393SensCmprs(object):
window_left = None, # 0, # 0 window_left = None, # 0, # 0
window_top = None, # 0, # 0? 1? window_top = None, # 0, # 0? 1?
last_buf_frame = 1, # - just 2-frame buffer 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 colorsat_red = 0x16c, # 0xb6 for x1
verbose = 1): verbose = 1):
""" """
......
[*] [*]
[*] GTKWave Analyzer v3.3.66 (w)1999-2015 BSI [*] 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] "/home/andrey/git/x393/simulation/x393_testbench03-20151115142219571.fst"
[dumpfile_mtime] "Sun Nov 15 22:02:48 2015" [dumpfile_mtime] "Sun Nov 15 22:02:48 2015"
[dumpfile_size] 287600988 [dumpfile_size] 287600988
[savefile] "/home/andrey/git/x393/x393_testbench03.sav" [savefile] "/home/andrey/git/x393/x393_testbench03.sav"
[timestart] 69077000 [timestart] 0
[size] 1823 1180 [size] 1823 1180
[pos] 0 0 [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.
[treeopen] x393_testbench03.par12_hispi_psp4l0_i. [treeopen] x393_testbench03.par12_hispi_psp4l0_i.
[treeopen] x393_testbench03.par12_hispi_psp4l0_i.cmprs_channel_block[0]. [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 ...@@ -930,7 +930,7 @@ x393_testbench03.x393_i.mcntrl393_i.sens_comp_block[0].mcntrl_linear_wr_sensor_i
@1401200 @1401200
-mcntr_linear_rw_sensor0 -mcntr_linear_rw_sensor0
-sensor_channel_0 -sensor_channel_0
@800200 @c00200
-DDR3 -DDR3
@28 @28
x393_testbench03.ddr3_i.SDCLK x393_testbench03.ddr3_i.SDCLK
...@@ -943,7 +943,7 @@ x393_testbench03.ddr3_i.SDBA[2:0] ...@@ -943,7 +943,7 @@ x393_testbench03.ddr3_i.SDBA[2:0]
x393_testbench03.ddr3_i.SDD_D[15:0] x393_testbench03.ddr3_i.SDD_D[15:0]
@200 @200
- -
@1000200 @1401200
-DDR3 -DDR3
@c00200 @c00200
-simul_sensor_0 -simul_sensor_0
...@@ -995,7 +995,7 @@ x393_testbench03.simul_sensor12bits_2_i.stopped ...@@ -995,7 +995,7 @@ x393_testbench03.simul_sensor12bits_2_i.stopped
x393_testbench03.simul_sensor12bits_2_i.stoppedd x393_testbench03.simul_sensor12bits_2_i.stoppedd
@1401200 @1401200
-simul_sensor_0 -simul_sensor_0
@800200 @c00200
-PX1 -PX1
@28 @28
x393_testbench03.PX1_MCLK_PRE x393_testbench03.PX1_MCLK_PRE
...@@ -1029,7 +1029,7 @@ x393_testbench03.PX1_MRST ...@@ -1029,7 +1029,7 @@ x393_testbench03.PX1_MRST
x393_testbench03.PX1_OFST x393_testbench03.PX1_OFST
x393_testbench03.PX1_SHUTTER x393_testbench03.PX1_SHUTTER
x393_testbench03.PX1_VACT x393_testbench03.PX1_VACT
@1000200 @1401200
-PX1 -PX1
@c00200 @c00200
-SENSOR0 -SENSOR0
...@@ -1114,9 +1114,8 @@ x393_testbench03.par12_hispi_psp4l0_i.simul_clk_div_mult_i.en ...@@ -1114,9 +1114,8 @@ x393_testbench03.par12_hispi_psp4l0_i.simul_clk_div_mult_i.en
@1401200 @1401200
-clk_mult_div -clk_mult_div
-par_hispi_sel -par_hispi_sel
@800200 @c00200
-sens_hispi_12l4 -sens_hispi_12l4
@c00201
-lane0 -lane0
@28 @28
x393_testbench03.x393_i.sensors393_i.sensor_channel_block[0].sensor_channel_i.sens_10398_i.sens_hispi12l4_i.ipclk 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 ...@@ -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] 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 @1001200
-group_end -group_end
@1401201 @1401200
-lane0 -lane0
@800200 @800200
-fifo0 -fifo0
...@@ -1257,7 +1256,7 @@ x393_testbench03.x393_i.sensors393_i.sensor_channel_block[0].sensor_channel_i.se ...@@ -1257,7 +1256,7 @@ x393_testbench03.x393_i.sensors393_i.sensor_channel_block[0].sensor_channel_i.se
-group_end -group_end
@200 @200
- -
@1000200 @1401200
-sens_hispi_12l4 -sens_hispi_12l4
@c00200 @c00200
-par_hspi_0 -par_hspi_0
...@@ -2256,7 +2255,7 @@ x393_testbench03.x393_i.compressor393_i.cmprs_channel_block[0].jp_channel_i.huff ...@@ -2256,7 +2255,7 @@ x393_testbench03.x393_i.compressor393_i.cmprs_channel_block[0].jp_channel_i.huff
- -
@1401200 @1401200
-stuffer_metadata -stuffer_metadata
@800200 @c00200
-new_compressor -new_compressor
@28 @28
x393_testbench03.x393_i.compressor393_i.cmprs_channel_block[0].jp_channel_i.frame_start_dst 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 ...@@ -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] 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 @1000200
-comressor -comressor
@1401200
-new_compressor -new_compressor
@800200
- new_compressor_chn2
@c00200 @c00200
- new_compressor_chn2
-tile_rd_chn2 -tile_rd_chn2
@200 @200
- -
...@@ -2636,6 +2635,7 @@ x393_testbench03.x393_i.mcntrl393_i.sens_comp_block[2].mcntrl_tiled_rd_compresso ...@@ -2636,6 +2635,7 @@ x393_testbench03.x393_i.mcntrl393_i.sens_comp_block[2].mcntrl_tiled_rd_compresso
- -
@1000200 @1000200
-memory -memory
@1401200
- new_compressor_chn2 - new_compressor_chn2
@22 @22
x393_testbench03.x393_i.compressor393_i.genblk3.cmprs_afi0_mux_i.fifo_rdata0[63:0] 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 ...@@ -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] x393_testbench03.x393_i.mcntrl393_i.memctrl16_i.mcontr_sequencer_i.cmd1_buf_i.web[3:0]
@1401200 @1401200
-memctrl_sequencer_cmd1buf -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 @200
- -
[pattern_trace] 1 [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