Commit eb0f6b26 authored by Andrey Filippov's avatar Andrey Filippov

Added EOF/SOF swoitch for i2c sequencer, bitstream version c4

parent 28c07f7d
[*] [*]
[*] GTKWave Analyzer v3.3.66 (w)1999-2015 BSI [*] GTKWave Analyzer v3.3.66 (w)1999-2015 BSI
[*] Thu Oct 27 01:40:51 2016 [*] Sat Oct 29 21:44:32 2016
[*] [*]
[dumpfile] "/home/eyesis/git/x393-neon/simulation/x393_dut-20161026180017757.fst" [dumpfile] "/home/eyesis/git/x393-neon/simulation/x393_dut-20161028224636205.fst"
[dumpfile_mtime] "Thu Oct 27 01:39:08 2016" [dumpfile_mtime] "Sat Oct 29 06:54:57 2016"
[dumpfile_size] 418439836 [dumpfile_size] 487758287
[savefile] "/home/eyesis/git/x393-neon/cocotb/x393_cocotb_03.sav" [savefile] "/home/eyesis/git/x393-neon/cocotb/x393_cocotb_03.sav"
[timestart] 0 [timestart] 0
[size] 1814 1171 [size] 1814 1171
[pos] 0 0 [pos] 0 0
*-27.006804 350100000 53094051 136169617 216213845 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 *-25.418884 64300000 53094051 136169617 426878253 -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_dut. [treeopen] x393_dut.
[treeopen] x393_dut.simul_sensor12bits_2_i. [treeopen] x393_dut.simul_sensor12bits_2_i.
[treeopen] x393_dut.simul_sensor12bits_3_i. [treeopen] x393_dut.simul_sensor12bits_3_i.
...@@ -25,10 +25,14 @@ ...@@ -25,10 +25,14 @@
[treeopen] x393_dut.x393_i.event_logger_i.i_logger_arbiter. [treeopen] x393_dut.x393_i.event_logger_i.i_logger_arbiter.
[treeopen] x393_dut.x393_i.event_logger_i.i_nmea_decoder. [treeopen] x393_dut.x393_i.event_logger_i.i_nmea_decoder.
[treeopen] x393_dut.x393_i.event_logger_i.i_rs232_rcv. [treeopen] x393_dut.x393_i.event_logger_i.i_rs232_rcv.
[treeopen] x393_dut.x393_i.frame_sequencer_block[0].
[treeopen] x393_dut.x393_i.frame_sequencer_block[0].cmd_frame_sequencer_i.
[treeopen] x393_dut.x393_i.mult_saxi_wr_i.mult_saxi_wr_pointers_i. [treeopen] x393_dut.x393_i.mult_saxi_wr_i.mult_saxi_wr_pointers_i.
[treeopen] x393_dut.x393_i.sensors393_i.
[treeopen] x393_dut.x393_i.sensors393_i.sensor_channel_block[0]. [treeopen] x393_dut.x393_i.sensors393_i.sensor_channel_block[0].
[treeopen] x393_dut.x393_i.sensors393_i.sensor_channel_block[0].sensor_channel_i. [treeopen] x393_dut.x393_i.sensors393_i.sensor_channel_block[0].sensor_channel_i.
[treeopen] x393_dut.x393_i.sensors393_i.sensor_channel_block[0].sensor_channel_i.sensor_i2c_io_i. [treeopen] x393_dut.x393_i.sensors393_i.sensor_channel_block[0].sensor_channel_i.sensor_i2c_io_i.
[treeopen] x393_dut.x393_i.sensors393_i.sensor_channel_block[0].sensor_channel_i.sensor_i2c_io_i.sensor_i2c_i.
[treeopen] x393_dut.x393_i.sensors393_i.sensor_channel_block[1].sensor_channel_i. [treeopen] x393_dut.x393_i.sensors393_i.sensor_channel_block[1].sensor_channel_i.
[treeopen] x393_dut.x393_i.sensors393_i.sensor_channel_block[1].sensor_channel_i.sens_sync_i. [treeopen] x393_dut.x393_i.sensors393_i.sensor_channel_block[1].sensor_channel_i.sens_sync_i.
[treeopen] x393_dut.x393_i.sensors393_i.sensor_channel_block[2]. [treeopen] x393_dut.x393_i.sensors393_i.sensor_channel_block[2].
...@@ -41,7 +45,7 @@ ...@@ -41,7 +45,7 @@
[treeopen] x393_dut.x393_i.sensors393_i.sensor_channel_block[3].sensor_channel_i.sens_sync_i. [treeopen] x393_dut.x393_i.sensors393_i.sensor_channel_block[3].sensor_channel_i.sens_sync_i.
[treeopen] x393_dut.x393_i.timing393_i. [treeopen] x393_dut.x393_i.timing393_i.
[treeopen] x393_dut.x393_i.timing393_i.camsync393_i. [treeopen] x393_dut.x393_i.timing393_i.camsync393_i.
[sst_width] 282 [sst_width] 307
[signals_width] 319 [signals_width] 319
[sst_expanded] 1 [sst_expanded] 1
[sst_vpaned_height] 486 [sst_vpaned_height] 486
...@@ -1907,9 +1911,9 @@ x393_dut.x393_i.timing393_i.camsync393_i.trigger_condition ...@@ -1907,9 +1911,9 @@ x393_dut.x393_i.timing393_i.camsync393_i.trigger_condition
x393_dut.x393_i.timing393_i.camsync393_i.trigger_condition_filtered x393_dut.x393_i.timing393_i.camsync393_i.trigger_condition_filtered
@22 @22
x393_dut.x393_i.timing393_i.camsync393_i.input_pattern[9:0] x393_dut.x393_i.timing393_i.camsync393_i.input_pattern[9:0]
@c00023 @c00022
x393_dut.x393_i.timing393_i.camsync393_i.input_use[9:0] x393_dut.x393_i.timing393_i.camsync393_i.input_use[9:0]
@29 @28
(0)x393_dut.x393_i.timing393_i.camsync393_i.input_use[9:0] (0)x393_dut.x393_i.timing393_i.camsync393_i.input_use[9:0]
(1)x393_dut.x393_i.timing393_i.camsync393_i.input_use[9:0] (1)x393_dut.x393_i.timing393_i.camsync393_i.input_use[9:0]
(2)x393_dut.x393_i.timing393_i.camsync393_i.input_use[9:0] (2)x393_dut.x393_i.timing393_i.camsync393_i.input_use[9:0]
...@@ -1920,15 +1924,57 @@ x393_dut.x393_i.timing393_i.camsync393_i.input_use[9:0] ...@@ -1920,15 +1924,57 @@ x393_dut.x393_i.timing393_i.camsync393_i.input_use[9:0]
(7)x393_dut.x393_i.timing393_i.camsync393_i.input_use[9:0] (7)x393_dut.x393_i.timing393_i.camsync393_i.input_use[9:0]
(8)x393_dut.x393_i.timing393_i.camsync393_i.input_use[9:0] (8)x393_dut.x393_i.timing393_i.camsync393_i.input_use[9:0]
(9)x393_dut.x393_i.timing393_i.camsync393_i.input_use[9:0] (9)x393_dut.x393_i.timing393_i.camsync393_i.input_use[9:0]
@1401201 @1401200
-group_end -group_end
@1001200 @1001200
-group_end -group_end
-group_end -group_end
-group_end -group_end
@1000200
-camsync_ext_int
@800200
-sequencers_0
-cmd_frame_seq0
@28
x393_dut.x393_i.frame_sequencer_block[0].cmd_frame_sequencer_i.frame_sync
@22
x393_dut.x393_i.frame_sequencer_block[0].cmd_frame_sequencer_i.frame_no[3:0]
@1000200
-cmd_frame_seq0
@800200
-i2c_seq_0
@28
x393_dut.x393_i.sensors393_i.sensor_channel_block[0].sensor_channel_i.sensor_i2c_io_i.sensor_i2c_i.frame_sync
x393_dut.x393_i.sensors393_i.sensor_channel_block[0].sensor_channel_i.sensor_i2c_io_i.sensor_i2c_i.req_clr
@c00028
x393_dut.x393_i.sensors393_i.sensor_channel_block[0].sensor_channel_i.sensor_i2c_io_i.sensor_i2c_i.wpage0_inc[1:0]
@28
(0)x393_dut.x393_i.sensors393_i.sensor_channel_block[0].sensor_channel_i.sensor_i2c_io_i.sensor_i2c_i.wpage0_inc[1:0]
(1)x393_dut.x393_i.sensors393_i.sensor_channel_block[0].sensor_channel_i.sensor_i2c_io_i.sensor_i2c_i.wpage0_inc[1:0]
@1401200
-group_end
@28
x393_dut.x393_i.sensors393_i.sensor_channel_block[0].sensor_channel_i.sensor_i2c_io_i.sensor_i2c_i.sync_to_seq
@29
x393_dut.x393_i.sensors393_i.sensor_channel_block[0].sensor_channel_i.sensor_i2c_io_i.sensor_i2c_i.sync_to_eof
@22
x393_dut.x393_i.sensors393_i.sensor_channel_block[0].sensor_channel_i.sensor_i2c_io_i.sensor_i2c_i.frame_num_seq[3:0]
x393_dut.x393_i.sensors393_i.sensor_channel_block[0].sensor_channel_i.sensor_i2c_io_i.sensor_i2c_i.frame_num[3:0]
@28
x393_dut.x393_i.sensors393_i.sensor_channel_block[0].sensor_channel_i.sensor_i2c_io_i.sensor_i2c_i.eof_mclk
x393_dut.x393_i.sensors393_i.sensor_channel_block[0].sensor_channel_i.sensor_i2c_io_i.sensor_i2c_i.use_eof
@1000200
-i2c_seq_0
@800200
-sensor_channel0
@200 @200
- -
@28
x393_dut.x393_i.sensors393_i.sensor_channel_block[0].sensor_channel_i.eof_mclk
x393_dut.x393_i.sensors393_i.sensor_channel_block[0].sensor_channel_i.eof_out
x393_dut.x393_i.sensors393_i.sensor_channel_block[0].sensor_channel_i.eof_out_r
@1000200 @1000200
-camsync_ext_int -sensor_channel0
-sequencers_0
[pattern_trace] 1 [pattern_trace] 1
[pattern_trace] 0 [pattern_trace] 0
...@@ -35,7 +35,8 @@ ...@@ -35,7 +35,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'h039300c3; //parallel - fixing timestamps parameter FPGA_VERSION = 32'h039300c4; //parallel - option to use EOF for i2c sequencer timing met, 79.66%
// parameter FPGA_VERSION = 32'h039300c3; //parallel - fixing timestamps -0.209/47, 79.86%
// parameter FPGA_VERSION = 32'h039300c2; //parallel - external sync for Eyesis -0.160/71 79.84% // parameter FPGA_VERSION = 32'h039300c2; //parallel - external sync for Eyesis -0.160/71 79.84%
// parameter FPGA_VERSION = 32'h039300c1; //parallel - modified after troubleshooting simulation -0.069/41, 79.90 % // parameter FPGA_VERSION = 32'h039300c1; //parallel - modified after troubleshooting simulation -0.069/41, 79.90 %
// parameter FPGA_VERSION = 32'h039300c0; //parallel - changing LOGGER_PAGE_IMU 3->0 (how it was in 353) -0.044/16, 79.59% // parameter FPGA_VERSION = 32'h039300c0; //parallel - changing LOGGER_PAGE_IMU 3->0 (how it was in 353) -0.044/16, 79.59%
......
...@@ -386,6 +386,7 @@ ...@@ -386,6 +386,7 @@
parameter SENSI2C_CMD_RUN = 13, // [13:12]3 - run i2c, 2 - stop i2c (needed before software i2c), 1,0 - no change to run state parameter SENSI2C_CMD_RUN = 13, // [13:12]3 - run i2c, 2 - stop i2c (needed before software i2c), 1,0 - no change to run state
parameter SENSI2C_CMD_RUN_PBITS = 1, parameter SENSI2C_CMD_RUN_PBITS = 1,
parameter SENSI2C_CMD_USE_EOF = 8, // [9:8] - 0: advance sequencer at SOF, 1 - advance sequencer at EOF
parameter SENSI2C_CMD_SOFT_SDA = 6, // [7:6] - SDA software control: 0 - nop, 1 - low, 2 - active high, 3 - float parameter SENSI2C_CMD_SOFT_SDA = 6, // [7:6] - SDA software control: 0 - nop, 1 - low, 2 - active high, 3 - float
parameter SENSI2C_CMD_SOFT_SCL = 4, // [5:4] - SCL software control: 0 - nop, 1 - low, 2 - active high, 3 - float parameter SENSI2C_CMD_SOFT_SCL = 4, // [5:4] - SCL software control: 0 - nop, 1 - low, 2 - active high, 3 - float
......
...@@ -1900,6 +1900,7 @@ class X393ExportC(object): ...@@ -1900,6 +1900,7 @@ class X393ExportC(object):
dw.append(("soft_scl", vrlg.SENSI2C_CMD_SOFT_SCL, 2,0, "Control SCL pin (when stopped): 0 - nop, 1 - low, 2 - high (driven), 3 - float ")) dw.append(("soft_scl", vrlg.SENSI2C_CMD_SOFT_SCL, 2,0, "Control SCL pin (when stopped): 0 - nop, 1 - low, 2 - high (driven), 3 - float "))
dw.append(("soft_sda", vrlg.SENSI2C_CMD_SOFT_SDA, 2,0, "Control SDA pin (when stopped): 0 - nop, 1 - low, 2 - high (driven), 3 - float ")) dw.append(("soft_sda", vrlg.SENSI2C_CMD_SOFT_SDA, 2,0, "Control SDA pin (when stopped): 0 - nop, 1 - low, 2 - high (driven), 3 - float "))
dw.append(("eof_not_sof", vrlg.SENSI2C_CMD_USE_EOF, 2,0, "Advance I2C sequencer: 0 - SOF, 1 - EOF"))
dw.append(("cmd_run", vrlg.SENSI2C_CMD_RUN-1, 2,0, "Sequencer run/stop control: 0,1 - nop, 2 - stop, 3 - run ")) dw.append(("cmd_run", vrlg.SENSI2C_CMD_RUN-1, 2,0, "Sequencer run/stop control: 0,1 - nop, 2 - stop, 3 - run "))
dw.append(("reset", vrlg.SENSI2C_CMD_RESET, 1,0, "Sequencer reset all FIFO (takes 16 clock pulses), also - stops i2c until run command")) dw.append(("reset", vrlg.SENSI2C_CMD_RESET, 1,0, "Sequencer reset all FIFO (takes 16 clock pulses), also - stops i2c until run command"))
......
...@@ -2280,6 +2280,10 @@ jpeg_sim_multi 8 ...@@ -2280,6 +2280,10 @@ jpeg_sim_multi 8
measure_all "*DI" measure_all "*DI"
setup_all_sensors True None 0xf setup_all_sensors True None 0xf
set_sensor_io_ctl all None None 1 # Set ARO low - check if it is still needed? set_sensor_io_ctl all None None 1 # Set ARO low - check if it is still needed?
#use EOF instead of SOF for i2c sequencer advance
set_sensor_i2c_command all False None None None None None None True
#just testing #just testing
set_gpio_ports 1 1 # enable software gpio pins and porta (camsync) set_gpio_ports 1 1 # enable software gpio pins and porta (camsync)
set_gpio_pins 0 1 # pin 0 low, pin 1 - high set_gpio_pins 0 1 # pin 0 low, pin 1 - high
......
...@@ -287,6 +287,7 @@ class X393Sensor(object): ...@@ -287,6 +287,7 @@ class X393Sensor(object):
advance_FIFO = None, advance_FIFO = None,
sda = None, sda = None,
scl = None, scl = None,
use_eof = None,
verbose = 1): verbose = 1):
""" """
@param rst_cmd - reset all FIFO (takes 16 clock pulses), also - stops i2c until run command @param rst_cmd - reset all FIFO (takes 16 clock pulses), also - stops i2c until run command
...@@ -296,6 +297,7 @@ class X393Sensor(object): ...@@ -296,6 +297,7 @@ class X393Sensor(object):
@param advance_FIFO - advance i2c read FIFO @param advance_FIFO - advance i2c read FIFO
@param sda - control SDA line (stopped mode only): I<nput>, L<ow> or 0, High or 1 @param sda - control SDA line (stopped mode only): I<nput>, L<ow> or 0, High or 1
@param scl - control SCL line (stopped mode only): I<nput>, L<ow> or 0, High or 1 @param scl - control SCL line (stopped mode only): I<nput>, L<ow> or 0, High or 1
@param use_eof - advance sequencer at EOF, not at SOF
@param verbose - verbose level @param verbose - verbose level
@return combined command word. @return combined command word.
active_sda and early_release_0 should be defined both to take effect (any of the None skips setting these parameters) active_sda and early_release_0 should be defined both to take effect (any of the None skips setting these parameters)
...@@ -338,6 +340,10 @@ class X393Sensor(object): ...@@ -338,6 +340,10 @@ class X393Sensor(object):
rslt |= 1 << vrlg.SENSI2C_CMD_ACIVE rslt |= 1 << vrlg.SENSI2C_CMD_ACIVE
if advance_FIFO: if advance_FIFO:
rslt |= 1 << vrlg.SENSI2C_CMD_FIFO_RD rslt |= 1 << vrlg.SENSI2C_CMD_FIFO_RD
if not use_eof is None:
rslt |= 1 << (vrlg.SENSI2C_CMD_USE_EOF + 1)
rslt |= (0,1)[use_eof] << (vrlg.SENSI2C_CMD_USE_EOF)
rslt |= parse_sda_scl(sda) << vrlg.SENSI2C_CMD_SOFT_SDA rslt |= parse_sda_scl(sda) << vrlg.SENSI2C_CMD_SOFT_SDA
rslt |= parse_sda_scl(scl) << vrlg.SENSI2C_CMD_SOFT_SCL rslt |= parse_sda_scl(scl) << vrlg.SENSI2C_CMD_SOFT_SCL
if verbose>0: if verbose>0:
...@@ -554,6 +560,7 @@ class X393Sensor(object): ...@@ -554,6 +560,7 @@ class X393Sensor(object):
advance_FIFO = None, advance_FIFO = None,
sda = None, sda = None,
scl = None, scl = None,
use_eof = None,
verbose = 1): verbose = 1):
""" """
@param num_sensor - sensor port number (0..3) or all @param num_sensor - sensor port number (0..3) or all
...@@ -564,6 +571,7 @@ class X393Sensor(object): ...@@ -564,6 +571,7 @@ class X393Sensor(object):
@param advance_FIFO - advance i2c read FIFO @param advance_FIFO - advance i2c read FIFO
@param sda - control SDA line (stopped mode only): I<nput>, L<ow> or 0, High or 1 @param sda - control SDA line (stopped mode only): I<nput>, L<ow> or 0, High or 1
@param scl - control SCL line (stopped mode only): I<nput>, L<ow> or 0, High or 1 @param scl - control SCL line (stopped mode only): I<nput>, L<ow> or 0, High or 1
@param use_eof - advance sequencer at EOF, not at SOF
@param verbose - verbose level @param verbose - verbose level
active_sda and early_release_0 should be defined both to take effect (any of the None skips setting these parameters) active_sda and early_release_0 should be defined both to take effect (any of the None skips setting these parameters)
...@@ -579,6 +587,7 @@ class X393Sensor(object): ...@@ -579,6 +587,7 @@ class X393Sensor(object):
advance_FIFO = advance_FIFO, advance_FIFO = advance_FIFO,
sda = sda, sda = sda,
scl = scl, scl = scl,
use_eof = use_eof,
verbose = verbose) verbose = verbose)
return return
...@@ -595,6 +604,7 @@ class X393Sensor(object): ...@@ -595,6 +604,7 @@ class X393Sensor(object):
advance_FIFO = advance_FIFO, advance_FIFO = advance_FIFO,
sda = sda, sda = sda,
scl = scl, scl = scl,
use_eof = use_eof,
verbose = verbose-1)) verbose = verbose-1))
def set_sensor_i2c_table_reg_wr (self, def set_sensor_i2c_table_reg_wr (self,
......
...@@ -90,6 +90,7 @@ module sensor_channel#( ...@@ -90,6 +90,7 @@ module sensor_channel#(
parameter SENSI2C_CMD_RESET = 14, // [14] reset all FIFO (takes 16 clock pulses), also - stops i2c until run command parameter SENSI2C_CMD_RESET = 14, // [14] reset all FIFO (takes 16 clock pulses), also - stops i2c until run command
parameter SENSI2C_CMD_RUN = 13, // [13:12]3 - run i2c, 2 - stop i2c (needed before software i2c), 1,0 - no change to run state parameter SENSI2C_CMD_RUN = 13, // [13:12]3 - run i2c, 2 - stop i2c (needed before software i2c), 1,0 - no change to run state
parameter SENSI2C_CMD_RUN_PBITS = 1, parameter SENSI2C_CMD_RUN_PBITS = 1,
parameter SENSI2C_CMD_USE_EOF = 8, // [9:8] - 0: advance sequencer at SOF, 1 - advance sequencer at EOF
parameter SENSI2C_CMD_SOFT_SDA = 6, // [7:6] - SDA software control: 0 - nop, 1 - low, 2 - active high, 3 - float parameter SENSI2C_CMD_SOFT_SDA = 6, // [7:6] - SDA software control: 0 - nop, 1 - low, 2 - active high, 3 - float
parameter SENSI2C_CMD_SOFT_SCL = 4, // [5:4] - SCL software control: 0 - nop, 1 - low, 2 - active high, 3 - float parameter SENSI2C_CMD_SOFT_SCL = 4, // [5:4] - SCL software control: 0 - nop, 1 - low, 2 - active high, 3 - float
parameter SENSI2C_CMD_FIFO_RD = 3, // advance I2C read data FIFO by 1 parameter SENSI2C_CMD_FIFO_RD = 3, // advance I2C read data FIFO by 1
...@@ -416,6 +417,7 @@ module sensor_channel#( ...@@ -416,6 +417,7 @@ module sensor_channel#(
wire hact; // line active @posedge ipclk wire hact; // line active @posedge ipclk
wire sof; // start of frame wire sof; // start of frame
wire eof; // end of frame wire eof; // end of frame
wire eof_mclk; // to be used by i2c sequencer
wire sof_out_sync; // sof filtetred, optionally decimated (for linescan mode) wire sof_out_sync; // sof filtetred, optionally decimated (for linescan mode)
...@@ -644,6 +646,7 @@ module sensor_channel#( ...@@ -644,6 +646,7 @@ module sensor_channel#(
.SENSI2C_CMD_RESET (SENSI2C_CMD_RESET), .SENSI2C_CMD_RESET (SENSI2C_CMD_RESET),
.SENSI2C_CMD_RUN (SENSI2C_CMD_RUN), .SENSI2C_CMD_RUN (SENSI2C_CMD_RUN),
.SENSI2C_CMD_RUN_PBITS (SENSI2C_CMD_RUN_PBITS), .SENSI2C_CMD_RUN_PBITS (SENSI2C_CMD_RUN_PBITS),
.SENSI2C_CMD_USE_EOF (SENSI2C_CMD_USE_EOF),
.SENSI2C_CMD_SOFT_SDA (SENSI2C_CMD_SOFT_SDA), .SENSI2C_CMD_SOFT_SDA (SENSI2C_CMD_SOFT_SDA),
.SENSI2C_CMD_SOFT_SCL (SENSI2C_CMD_SOFT_SCL), .SENSI2C_CMD_SOFT_SCL (SENSI2C_CMD_SOFT_SCL),
.SENSI2C_CMD_FIFO_RD (SENSI2C_CMD_FIFO_RD), .SENSI2C_CMD_FIFO_RD (SENSI2C_CMD_FIFO_RD),
...@@ -676,6 +679,8 @@ module sensor_channel#( ...@@ -676,6 +679,8 @@ module sensor_channel#(
.status_rq (sens_i2c_status_rq), // output .status_rq (sens_i2c_status_rq), // output
.status_start (sens_i2c_status_start), // input .status_start (sens_i2c_status_start), // input
.frame_sync (sof_out_mclk), // input .frame_sync (sof_out_mclk), // input
.eof_mclk (eof_mclk), // End of frame for i2c sequencer (will not work for linescan mode: either disable or make
// division as in sof_out_mclk
.frame_num_seq (frame_num_seq), // input[3:0] .frame_num_seq (frame_num_seq), // input[3:0]
.scl (sns_scl), // inout .scl (sns_scl), // inout
.sda (sns_sda) // inout .sda (sns_sda) // inout
...@@ -692,7 +697,7 @@ module sensor_channel#( ...@@ -692,7 +697,7 @@ module sensor_channel#(
reg hist_gr0_r; reg hist_gr0_r;
wire sol_mclk; wire sol_mclk;
wire sof_mclk; wire sof_mclk;
wire eof_mclk; // wire eof_mclk;
wire alive_hist0_rq = hist_rq[0] && !hist_rq0_r; wire alive_hist0_rq = hist_rq[0] && !hist_rq0_r;
wire alive_hist0_gr = hist_gr[0] && !hist_gr0_r; wire alive_hist0_gr = hist_gr[0] && !hist_gr0_r;
// sof_out_mclk - already exists // sof_out_mclk - already exists
...@@ -739,15 +744,6 @@ module sensor_channel#( ...@@ -739,15 +744,6 @@ module sensor_channel#(
.busy() // output .busy() // output
); );
pulse_cross_clock pulse_cross_clock_eof_mclk_i (
// .rst (prst), // input
.rst (prsts), // input extended to include sensor reset and rst_mmcm
.src_clk (pclk), // input
.dst_clk (mclk), // input
.in_pulse (eof), // input
.out_pulse (eof_mclk), // output
.busy() // output
);
pulse_cross_clock pulse_cross_clock_dout_valid_1cyc_mclk_i ( pulse_cross_clock pulse_cross_clock_dout_valid_1cyc_mclk_i (
// .rst (prst), // input // .rst (prst), // input
...@@ -771,6 +767,14 @@ module sensor_channel#( ...@@ -771,6 +767,14 @@ module sensor_channel#(
`endif `endif
pulse_cross_clock pulse_cross_clock_eof_mclk_i (
.rst (prsts), // input extended to include sensor reset and rst_mmcm
.src_clk (pclk), // input
.dst_clk (mclk), // input
.in_pulse (eof), // input
.out_pulse (eof_mclk), // output
.busy() // output
);
......
...@@ -53,6 +53,7 @@ module sensor_i2c#( ...@@ -53,6 +53,7 @@ module sensor_i2c#(
parameter SENSI2C_CMD_RESET = 14, // [14] reset all FIFO (takes 16 clock pulses), also - stops i2c until run command parameter SENSI2C_CMD_RESET = 14, // [14] reset all FIFO (takes 16 clock pulses), also - stops i2c until run command
parameter SENSI2C_CMD_RUN = 13, // [13:12]3 - run i2c, 2 - stop i2c (needed before software i2c), 1,0 - no change to run state parameter SENSI2C_CMD_RUN = 13, // [13:12]3 - run i2c, 2 - stop i2c (needed before software i2c), 1,0 - no change to run state
parameter SENSI2C_CMD_RUN_PBITS = 1, parameter SENSI2C_CMD_RUN_PBITS = 1,
parameter SENSI2C_CMD_USE_EOF = 8, // [9:8] - 0: advance sequencer at SOF, 1 - advance sequencer at EOF
parameter SENSI2C_CMD_SOFT_SDA = 6, // [7:6] - SDA software control: 0 - nop, 1 - low, 2 - active high, 3 - float parameter SENSI2C_CMD_SOFT_SDA = 6, // [7:6] - SDA software control: 0 - nop, 1 - low, 2 - active high, 3 - float
parameter SENSI2C_CMD_SOFT_SCL = 4, // [5:4] - SCL software control: 0 - nop, 1 - low, 2 - active high, 3 - float parameter SENSI2C_CMD_SOFT_SCL = 4, // [5:4] - SCL software control: 0 - nop, 1 - low, 2 - active high, 3 - float
parameter SENSI2C_CMD_FIFO_RD = 3, // advance I2C read data FIFO by 1 parameter SENSI2C_CMD_FIFO_RD = 3, // advance I2C read data FIFO by 1
...@@ -88,6 +89,7 @@ module sensor_i2c#( ...@@ -88,6 +89,7 @@ module sensor_i2c#(
input status_start,// Acknowledge of the first status packet byte (address) input status_start,// Acknowledge of the first status packet byte (address)
input frame_sync, // @posedge mclk increment/reset frame number input frame_sync, // @posedge mclk increment/reset frame number
input [NUM_FRAME_BITS-1:0] frame_num_seq, // frame number from the command sequencer (to sync i2c) input [NUM_FRAME_BITS-1:0] frame_num_seq, // frame number from the command sequencer (to sync i2c)
input eof_mclk, // frame end (use as alternative i2c sequencer increment (disable for linescan mode)
input sda_in, // i2c SDA input input sda_in, // i2c SDA input
input scl_in, // i2c SCL input input scl_in, // i2c SCL input
output scl_out, // i2c SCL output output scl_out, // i2c SCL output
...@@ -186,10 +188,14 @@ module sensor_i2c#( ...@@ -186,10 +188,14 @@ module sensor_i2c#(
wire sda_en_hard; wire sda_en_hard;
wire scl_hard; wire scl_hard;
reg use_eof; // advance sequencer with eof, not sof
`ifdef I2C_FRAME_INDEPENDENT `ifdef I2C_FRAME_INDEPENDENT
localparam sync_to_seq = 0; localparam sync_to_seq = 0;
localparam sync_to_eof = 0;
`else `else
reg sync_to_seq; reg sync_to_seq;
reg sync_to_eof;
`endif `endif
reg [5:0] last_wp; // last written write pointer reg [5:0] last_wp; // last written write pointer
reg [5:0] last_wp_d; // last written write pointer, delayed to match rpointer reg [5:0] last_wp_d; // last written write pointer, delayed to match rpointer
...@@ -209,6 +215,7 @@ module sensor_i2c#( ...@@ -209,6 +215,7 @@ module sensor_i2c#(
assign set_ctrl_w = we_cmd && ((wa & ~SENSI2C_CTRL_MASK) == SENSI2C_CTRL );// ==0 assign set_ctrl_w = we_cmd && ((wa & ~SENSI2C_CTRL_MASK) == SENSI2C_CTRL );// ==0
assign set_status_w = we_cmd && ((wa & ~SENSI2C_CTRL_MASK) == SENSI2C_STATUS );// ==0 assign set_status_w = we_cmd && ((wa & ~SENSI2C_CTRL_MASK) == SENSI2C_STATUS );// ==0
assign pre_wpage0_inc = (!wen && !(|wen_r) && !wpage0_inc[0]) && (req_clr || reset_on) ; assign pre_wpage0_inc = (!wen && !(|wen_r) && !wpage0_inc[0]) && (req_clr || reset_on) ;
/// assign pre_wpage0_inc = (!wen && !(|wen_r) && !(|wpage0_inc)) && (req_clr || reset_on) ; /// assign pre_wpage0_inc = (!wen && !(|wen_r) && !(|wpage0_inc)) && (req_clr || reset_on) ;
assign fifo_wr_pointers_outw = fifo_wr_pointers_ram[wpage_wr[3:0]]; // valid next after command assign fifo_wr_pointers_outw = fifo_wr_pointers_ram[wpage_wr[3:0]]; // valid next after command
...@@ -328,6 +335,10 @@ module sensor_i2c#( ...@@ -328,6 +335,10 @@ module sensor_i2c#(
if (i2c_enrun || mrst) sda_en_soft <= 0; if (i2c_enrun || mrst) sda_en_soft <= 0;
else if (set_ctrl_w && !di[SENSI2C_CMD_TABLE] && |di[SENSI2C_CMD_SOFT_SDA +:2]) sda_en_soft <= di[SENSI2C_CMD_SOFT_SDA +:2] != 3; else if (set_ctrl_w && !di[SENSI2C_CMD_TABLE] && |di[SENSI2C_CMD_SOFT_SDA +:2]) sda_en_soft <= di[SENSI2C_CMD_SOFT_SDA +:2] != 3;
if (mrst) use_eof <= 0;
else if (set_ctrl_w && !di[SENSI2C_CMD_TABLE] && di[SENSI2C_CMD_USE_EOF + 1]) use_eof <= di[SENSI2C_CMD_USE_EOF];
if (set_ctrl_w && !di[SENSI2C_CMD_TABLE] && |di[SENSI2C_CMD_SOFT_SDA +:2]) sda_soft <= di[SENSI2C_CMD_SOFT_SDA + 1]; if (set_ctrl_w && !di[SENSI2C_CMD_TABLE] && |di[SENSI2C_CMD_SOFT_SDA +:2]) sda_soft <= di[SENSI2C_CMD_SOFT_SDA + 1];
if (active_cmd) begin if (active_cmd) begin
...@@ -340,16 +351,17 @@ module sensor_i2c#( ...@@ -340,16 +351,17 @@ module sensor_i2c#(
// reset pointers in all 16 pages: // reset pointers in all 16 pages:
reset_on <= reset_cmd || (reset_on && !(wpage0_inc[0] && ( wpage0[3:0] == 4'hf))); reset_on <= reset_cmd || (reset_on && !(wpage0_inc[0] && ( wpage0[3:0] == 4'hf)));
// request to clear pointer(s)? for one page - during reset or delayed frame sync (if previous was not finished) // request to clear pointer(s)? for one page - during reset or delayed frame sync (if previous was not finished)
req_clr <= frame_sync || (req_clr && !wpage0_inc[0]); req_clr <= (use_eof ? eof_mclk : frame_sync) || (req_clr && !wpage0_inc[0]);
`ifndef I2C_FRAME_INDEPENDENT `ifndef I2C_FRAME_INDEPENDENT
sync_to_seq <= frame_sync || (reset_on && ( wpage0[3:0] == 4'hf)); sync_to_seq <= !use_eof && (frame_sync || (reset_on && ( wpage0[3:0] == 4'hf)));
sync_to_eof <= use_eof && (eof_mclk || (reset_on && ( wpage0[3:0] == 4'hf)));
`endif `endif
if (reset_cmd) wpage0 <= 0; if (reset_cmd) wpage0 <= 0;
else if (wpage0_inc[0]) wpage0 <= wpage0 + 1; else if (wpage0_inc[0]) wpage0 <= wpage0 + 1;
else if (sync_to_seq) wpage0 <= frame_num_seq; else if (sync_to_seq || sync_to_eof) wpage0 <= sync_to_eof?(frame_num_seq-1):frame_num_seq;
if (reset_cmd) wpage_prev <= 4'hf; if (reset_cmd) wpage_prev <= 4'hf;
else if (wpage0_inc[0]) wpage_prev <= wpage0; else if (wpage0_inc[0]) wpage_prev <= wpage0;
......
...@@ -53,6 +53,7 @@ module sensor_i2c_io#( ...@@ -53,6 +53,7 @@ module sensor_i2c_io#(
parameter SENSI2C_CMD_RESET = 14, // [14] reset all FIFO (takes 16 clock pulses), also - stops i2c until run command parameter SENSI2C_CMD_RESET = 14, // [14] reset all FIFO (takes 16 clock pulses), also - stops i2c until run command
parameter SENSI2C_CMD_RUN = 13, // [13:12]3 - run i2c, 2 - stop i2c (needed before software i2c), 1,0 - no change to run state parameter SENSI2C_CMD_RUN = 13, // [13:12]3 - run i2c, 2 - stop i2c (needed before software i2c), 1,0 - no change to run state
parameter SENSI2C_CMD_RUN_PBITS = 1, parameter SENSI2C_CMD_RUN_PBITS = 1,
parameter SENSI2C_CMD_USE_EOF = 8, // [9:8] - 0: advance sequencer at SOF, 1 - advance sequencer at EOF
parameter SENSI2C_CMD_SOFT_SDA = 6, // [7:6] - SDA software control: 0 - nop, 1 - low, 2 - active high, 3 - float parameter SENSI2C_CMD_SOFT_SDA = 6, // [7:6] - SDA software control: 0 - nop, 1 - low, 2 - active high, 3 - float
parameter SENSI2C_CMD_SOFT_SCL = 4, // [5:4] - SCL software control: 0 - nop, 1 - low, 2 - active high, 3 - float parameter SENSI2C_CMD_SOFT_SCL = 4, // [5:4] - SCL software control: 0 - nop, 1 - low, 2 - active high, 3 - float
parameter SENSI2C_CMD_FIFO_RD = 3, // advance I2C read data FIFO by 1 parameter SENSI2C_CMD_FIFO_RD = 3, // advance I2C read data FIFO by 1
...@@ -91,6 +92,7 @@ module sensor_i2c_io#( ...@@ -91,6 +92,7 @@ module sensor_i2c_io#(
output status_rq, // input request to send status downstream output status_rq, // input request to send status downstream
input status_start,// Acknowledge of the first status packet byte (address) input status_start,// Acknowledge of the first status packet byte (address)
input frame_sync, // increment/reset frame number input frame_sync, // increment/reset frame number
input eof_mclk, // End of frame for i2c sequencer (will not work for linescan mode: either disable or make division upsteram
input [NUM_FRAME_BITS-1:0] frame_num_seq, // frame number from the command sequencer (to sync i2c) input [NUM_FRAME_BITS-1:0] frame_num_seq, // frame number from the command sequencer (to sync i2c)
inout scl, inout scl,
inout sda inout sda
...@@ -116,6 +118,7 @@ module sensor_i2c_io#( ...@@ -116,6 +118,7 @@ module sensor_i2c_io#(
.SENSI2C_CMD_RESET (SENSI2C_CMD_RESET), .SENSI2C_CMD_RESET (SENSI2C_CMD_RESET),
.SENSI2C_CMD_RUN (SENSI2C_CMD_RUN), .SENSI2C_CMD_RUN (SENSI2C_CMD_RUN),
.SENSI2C_CMD_RUN_PBITS (SENSI2C_CMD_RUN_PBITS), .SENSI2C_CMD_RUN_PBITS (SENSI2C_CMD_RUN_PBITS),
.SENSI2C_CMD_USE_EOF (SENSI2C_CMD_USE_EOF),
.SENSI2C_CMD_SOFT_SDA (SENSI2C_CMD_SOFT_SDA), .SENSI2C_CMD_SOFT_SDA (SENSI2C_CMD_SOFT_SDA),
.SENSI2C_CMD_SOFT_SCL (SENSI2C_CMD_SOFT_SCL), .SENSI2C_CMD_SOFT_SCL (SENSI2C_CMD_SOFT_SCL),
.SENSI2C_CMD_FIFO_RD (SENSI2C_CMD_FIFO_RD), .SENSI2C_CMD_FIFO_RD (SENSI2C_CMD_FIFO_RD),
...@@ -145,6 +148,7 @@ module sensor_i2c_io#( ...@@ -145,6 +148,7 @@ module sensor_i2c_io#(
.status_start (status_start), // input .status_start (status_start), // input
.frame_sync (frame_sync), // input .frame_sync (frame_sync), // input
.frame_num_seq (frame_num_seq), // input[3:0] .frame_num_seq (frame_num_seq), // input[3:0]
.eof_mclk (eof_mclk), // input
.scl_in (scl_in), // input .scl_in (scl_in), // input
.sda_in (sda_in), // input .sda_in (sda_in), // input
.scl_out (scl_out), // output .scl_out (scl_out), // output
......
...@@ -80,6 +80,7 @@ module sensors393 #( ...@@ -80,6 +80,7 @@ module sensors393 #(
parameter SENSI2C_CMD_RESET = 14, // [14] reset all FIFO (takes 16 clock pulses), also - stops i2c until run command parameter SENSI2C_CMD_RESET = 14, // [14] reset all FIFO (takes 16 clock pulses), also - stops i2c until run command
parameter SENSI2C_CMD_RUN = 13, // [13:12]3 - run i2c, 2 - stop i2c (needed before software i2c), 1,0 - no change to run state parameter SENSI2C_CMD_RUN = 13, // [13:12]3 - run i2c, 2 - stop i2c (needed before software i2c), 1,0 - no change to run state
parameter SENSI2C_CMD_RUN_PBITS = 1, parameter SENSI2C_CMD_RUN_PBITS = 1,
parameter SENSI2C_CMD_USE_EOF = 8, // [9:8] - 0: advance sequencer at SOF, 1 - advance sequencer at EOF
parameter SENSI2C_CMD_SOFT_SDA = 6, // [7:6] - SDA software control: 0 - nop, 1 - low, 2 - active high, 3 - float parameter SENSI2C_CMD_SOFT_SDA = 6, // [7:6] - SDA software control: 0 - nop, 1 - low, 2 - active high, 3 - float
parameter SENSI2C_CMD_SOFT_SCL = 4, // [5:4] - SCL software control: 0 - nop, 1 - low, 2 - active high, 3 - float parameter SENSI2C_CMD_SOFT_SCL = 4, // [5:4] - SCL software control: 0 - nop, 1 - low, 2 - active high, 3 - float
parameter SENSI2C_CMD_FIFO_RD = 3, // advance I2C read data FIFO by 1 parameter SENSI2C_CMD_FIFO_RD = 3, // advance I2C read data FIFO by 1
...@@ -508,6 +509,7 @@ module sensors393 #( ...@@ -508,6 +509,7 @@ module sensors393 #(
.SENSI2C_CMD_RESET (SENSI2C_CMD_RESET), .SENSI2C_CMD_RESET (SENSI2C_CMD_RESET),
.SENSI2C_CMD_RUN (SENSI2C_CMD_RUN), .SENSI2C_CMD_RUN (SENSI2C_CMD_RUN),
.SENSI2C_CMD_RUN_PBITS (SENSI2C_CMD_RUN_PBITS), .SENSI2C_CMD_RUN_PBITS (SENSI2C_CMD_RUN_PBITS),
.SENSI2C_CMD_USE_EOF (SENSI2C_CMD_USE_EOF),
.SENSI2C_CMD_SOFT_SDA (SENSI2C_CMD_SOFT_SDA), .SENSI2C_CMD_SOFT_SDA (SENSI2C_CMD_SOFT_SDA),
.SENSI2C_CMD_SOFT_SCL (SENSI2C_CMD_SOFT_SCL), .SENSI2C_CMD_SOFT_SCL (SENSI2C_CMD_SOFT_SCL),
.SENSI2C_CMD_FIFO_RD (SENSI2C_CMD_FIFO_RD), .SENSI2C_CMD_FIFO_RD (SENSI2C_CMD_FIFO_RD),
......
No preview for this file type
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