ELGIP-123 Pulse generator 4 for FPM7

This commit is contained in:
Christos Spirotis 2021-05-10 17:01:57 +01:00
commit 58a760f5a7
28 changed files with 8578 additions and 5 deletions

View file

@ -180,24 +180,24 @@
"fields": {
"ram_rd_addr" : {
"type" : "r",
"bit_len" : "9",
"bit_len" : "8",
"reset" : "0",
"description" : "Current RAM read address"
},
"reserved_0" : {
"type" : "rsv",
"bit_len" : "7",
"bit_len" : "8",
"description" : "Reserved bits"
},
"return_addr" : {
"type" : "r",
"bit_len" : "9",
"bit_len" : "8",
"reset" : "0",
"description" : "Current return address"
},
"reserved_1" : {
"type" : "rsv",
"bit_len" : "7",
"bit_len" : "8",
"description" : "Reserved bits"
}
}
@ -205,7 +205,7 @@
"trigger" : {
"address" : "6",
"type" : "r",
"width" : "12",
"width" : "6",
"reset" : "0",
"description" : "Trigger input vector value"
},

View file

@ -0,0 +1,509 @@
[{
"ip_name": "pulse_generator_4",
"bus": "csr",
"addr_width" : "11",
"description": "Generate Fire-Requests, based on the absolute position and PD inputs - W&H specific variant",
"addr_hi_bit" : "10",
"addr_lo_bit" : "5",
"sub_blocks": {
"local": {
"instance": "",
"process": "cpp, txt",
"offset": "0x0"
},
"generic_sequencer_17": {
"instance": "channel",
"process": "enabled",
"offset": "0x20"
}
},
"registers": {
"ip_id" : {
"address" : "0",
"width" : "32",
"description" : "Unique ID for this IP block",
"fields": {
"ip_number" : {
"type" : "c",
"bit_len" : "8",
"reset" : "0x13",
"description" : "IP identifier number"
},
"mfr_number" : {
"type" : "c",
"bit_len" : "8",
"reset" : "0xFF",
"description" : "Manufacturer number"
},
"reserved" : {
"type" : "rsv",
"bit_len" : "16",
"description" : "Reserved bits"
}
}
},
"ip_ver" : {
"address" : "1",
"width" : "32",
"description" : "IP Version",
"fields": {
"minor_number" : {
"type" : "c",
"bit_len" : "8",
"reset" : "0x00",
"description" : "Minor number"
},
"major_number" : {
"type" : "c",
"bit_len" : "8",
"reset" : "0x04",
"description" : "Major number"
},
"reserved" : {
"type" : "rsv",
"bit_len" : "16",
"description" : "Reserved bits"
}
}
},
"pulse_gen_control_w": {
"address": "2",
"width": "21",
"description": "",
"fields": {
"enable": {
"type": "w",
"bit_len": "1",
"reset": "0x0",
"description": "Pulse-Generator Enable"
},
"bypass_channel_controller": {
"type": "w",
"bit_len": "1",
"reset": "0x0",
"description": "By-Pass Ch-Ctrl (=> Fractional Divider only)"
},
"reserved_0": {
"type": "rsv",
"bit_len": "1",
"description": ""
},
"bypass_delay_equalizer": {
"type": "w",
"bit_len": "1",
"reset": "0x0",
"description": "Bypass Delay Equalization"
},
"sw_control_dp_dir": {
"type": "w",
"bit_len": "1",
"reset": "0x0",
"description": "Dual-Phase Direction, when Ch-Ctrl is bypassed"
},
"reserved_1": {
"type": "rsv",
"bit_len": "6",
"description": ""
},
"wh_apply_corr_en": {
"type": "w",
"bit_len": "1",
"reset": "0x0",
"description": "Enable WH wheel correction "
},
"pp_apply_corr_en": {
"type": "w",
"bit_len": "1",
"reset": "0x0",
"description": "Enable Pixel-Pitch Correction "
},
"tof_comp_enable": {
"type": "w",
"bit_len": "1",
"reset": "0x0",
"description": "Enable Time-of-Flight Compensation"
},
"reserved_2": {
"type": "rsv",
"bit_len": "3",
"description": ""
},
"enable_output": {
"type": "w",
"bit_len": "1",
"reset": "0x0",
"description": "Enable fire-request output"
},
"trigger_abort_fire": {
"type": "w",
"bit_len": "1",
"reset": "0x0",
"description": "Abort pending request of fire-request issued by Ch-Ctrl"
},
"reset_diag_regs" : {
"type": "w",
"bit_len": "1",
"reset": "0x0",
"description": "Reset the local PD and Fire-Request counters"
},
"clr_pd_queue" : {
"type": "w0",
"bit_len": "1",
"reset": "0x0",
"description": "Clear PD Queue"
}
}
},
"pulse_gen_control_r": {
"address": "3",
"width": "15",
"description": "",
"fields": {
"reserved_0": {
"type": "rsv",
"bit_len": "5",
"description": ""
},
"pd_queue_error_flag": {
"type": "r",
"bit_len": "1",
"reset": "0x0",
"description": "PD Queue Overflow Error"
},
"delay_equalizer_error_flag": {
"type": "r",
"bit_len": "1",
"reset": "0x0",
"description": "Delay Equalizer Overflow Error"
},
"reserved_1": {
"type": "rsv",
"bit_len": "1",
"description": ""
},
"ch_mask_status": {
"type": "r",
"bit_len": "1",
"reset": "0x0",
"description": "ch_mask status"
},
"fire_enable_status": {
"type": "r",
"bit_len": "1",
"reset": "0x0",
"description": "fire enable status"
},
"dual_phase_directionality_select_status": {
"type": "r",
"bit_len": "1",
"reset": "0x0",
"description": "Dual-Phase Direction status"
},
"reserved_2": {
"type": "rsv",
"bit_len": "3",
"description": ""
},
"tof_sat_flag": {
"type": "r",
"bit_len": "1",
"reset": "0x0",
"description": "Asserted when the current encoder velocity value falls outside of the range covered by the ToF compensation LUT. Velocity saturation is therefore applied."
}
}
},
"pd_offset_dir_0": {
"type": "w",
"address": "4",
"reset": "0x00",
"width": "32",
"description": "PD Offset for DIR-0"
},
"pd_offset_dir_1": {
"type": "w",
"address": "5",
"reset": "0x00",
"width": "32",
"description": "PD Offset for DIR-1"
},
"channel_delay": {
"type": "w",
"address": "6",
"reset": "0x00",
"width": "16",
"description": "Channel Delay (Delay Equalization)"
},
"channel_controller_control_w": {
"address": "7",
"width": "16",
"description": "",
"fields": {
"start_seq_trigger": {
"type": "w0",
"bit_len": "1",
"reset": "0x0",
"description": "Ch-Ctrl Sequencer Start-Request"
},
"reserved0": {
"type": "rsv",
"bit_len": "7",
"description": ""
},
"sequencer_start_address": {
"type": "w",
"bit_len": "8",
"reset" : "0x0",
"description": "Ch-Ctrl Sequencer Start-Address"
}
}
},
"channel_controller_control_r": {
"address": "8",
"width": "2",
"description": "",
"fields": {
"reserved0": {
"type": "rsv",
"bit_len": "1",
"description": ""
},
"busy": {
"type": "r",
"bit_len": "1",
"reset": "0x0",
"description": "Ch-Ctrl Sequencer Busy"
}
}
},
"fractional_divider_control": {
"address": "9",
"width": "3",
"description": "Fractional Divider Control Register",
"fields": {
"enable": {
"type": "w",
"bit_len": "1",
"reset": "0x0",
"description": "Fractional Divider Enable"
},
"udp_max_pos": {
"type": "w",
"bit_len": "1",
"reset": "0x0",
"description": "Clear the encoder jitter for DIR-0"
},
"udp_min_pos": {
"type": "w",
"bit_len": "1",
"reset": "0x0",
"description": "Clear the encoder jitter for DIR-1"
}
}
},
"divider_ratio_int": {
"type": "w",
"address": "10",
"reset": "0x00",
"width": "10",
"description": "Integer part of the Division ratio"
},
"divider_ratio_fraction": {
"type": "w",
"address": "11",
"reset": "0x00",
"width": "24",
"description": "Fractional part of the Division ratio"
},
"subpixel_phase_num": {
"type": "w",
"address": "12",
"reset": "0x01",
"width": "6",
"description": "Number of sub-pixel phases to be generated"
},
"abs_position_max": {
"type": "r",
"address": "13",
"reset": "0x00",
"width": "32",
"subtype": "signed",
"description": "Absolute Position Maximum"
},
"abs_position_min": {
"type": "r",
"address": "14",
"reset": "0x00",
"width": "32",
"subtype": "signed",
"description": "Absolute Position Minimum"
},
"abs_position": {
"type": "r",
"address": "15",
"reset": "0x00",
"width": "32",
"subtype": "signed",
"description": "Current Absolute Position "
},
"pd_counter": {
"type": "r",
"address": "16",
"reset": "0x00",
"width": "16",
"description": "PD counter"
},
"fire_req_counter": {
"type": "r",
"address": "17",
"reset": "0x00",
"width": "24",
"description": "Fire-Request counter"
},
"enc_speed_meas_window": {
"address": "18",
"width": "20",
"type": "w",
"reset": "0x0C350",
"description": "Encoder speed measurement window length [clock cycles @100MHz]"
},
"enc_speed": {
"address": "19",
"width": "20",
"type": "r",
"reset": "0x0",
"subtype": "signed",
"description": "Encoder Velocity: balance between positive and negative encoder steps over the measurement window"
},
"tof_compensation_w": {
"address": "20",
"width": "32",
"description": "Time-of-Flight Compensation",
"fields": {
"enc_speed_norm": {
"type": "w",
"bit_len": "16",
"reset": "0x0100",
"description": "Encoder Speed Normalization factor: allow to match the encoder-speed range to the address bus width of the ToF Compensation LUT. With the default value (256), an encoder-speed measurement equal to k selects LUT address k)"
},
"reserved0": {
"type": "rsv",
"bit_len": "16",
"description": ""
}
}
},
"tof_compensation_r": {
"address": "21",
"width": "32",
"description": "Time-of-Flight Compensation",
"fields": {
"reserved0": {
"type": "rsv",
"bit_len": "16",
"description": ""
},
"tof_lut_comp": {
"type": "r",
"bit_len": "16",
"reset": "0x0",
"description": "Current value of the Time-of-Flight compensation"
}
}
},
"pixel_pitch_corr_stripe_num": {
"type": "w",
"address": "22",
"reset": "0x00",
"width": "24",
"description": "Number of stripes to be considered for pixel pitch correction: corresponds to the number of pixels composing the label, head width included)"
},
"pixel_pitch_pos_err_2_corr": {
"type": "w",
"address": "23",
"reset": "0x00",
"width": "32",
"description": "Static value used by the logic to compute pixel-pitch correction: need to be set to the number of 2^32/stripe_num, where stripe_num is the value programmed in pixel_pitch_corr_stripe_num"
},
"pixel_pitch_skip_corr_thres": {
"type": "w",
"address": "24",
"reset": "0x400000",
"width": "24",
"description": "Alignment error threshold causing a correction to be skipped, expressed in encoder steps (24-bits integer) "
},
"pixel_pitch_loop_filter_corr": {
"address": "25",
"width": "32",
"description": "Loop filter coefficient for pixel-pitch correction",
"fields": {
"delta_error_coeff": {
"type": "w",
"bit_len": "16",
"reset": "0x0100",
"description": "Loop Filter delta-error coefficient"
},
"tot_error_coeff": {
"type": "w",
"bit_len": "16",
"reset": "0x0100",
"description": "Loop Filter tot-error coefficient"
}
}
},
"pixel_pitch_pos_err_curr": {
"type": "r",
"address": "26",
"reset": "0x00",
"width": "32",
"subtype": "signed",
"description": "Pixel-pitch misalignment measured on the last rotation [encoder steps], represented as signed, fixed point with 24-bits integer part and 8-bits mantissa"
},
"pixel_pitch_pos_err_max": {
"type": "r",
"address": "27",
"reset": "0x00",
"width": "32",
"subtype": "signed",
"description": "Maximum recorded value of pixel-pitch misalignment [encoder steps], represented as signed, fixed point with 24-bits integer part and 8-bits mantissa"
},
"pixel_pitch_pos_err_min": {
"type": "r",
"address": "28",
"reset": "0x00",
"width": "32",
"subtype": "signed",
"description": "Minimum recorded value of pixel-pitch misalignment [encoder steps], represented as signed, fixed point with 24-bits integer part and 8-bits mantissa"
},
"pixel_pitch_div_ratio_corr": {
"type": "r",
"address": "29",
"reset": "0x00",
"width": "32",
"subtype": "signed",
"description": "Division-Ratio Correction (32-LSBs)"
},
"pixel_pitch_corr_cnt": {
"type": "r",
"address": "30",
"reset": "0x00",
"width": "16",
"description": "Pixel-pitch corrections count"
},
"channel_controller_seq": {
"type": "w",
"address": "512",
"reset": "0x00",
"width": "32",
"description": "Ch-Ctrl buffer offset (size=256)"
},
"ToF_Comp_LUT": {
"type": "w",
"address": "1024",
"reset": "0x00",
"width": "16",
"description": "The LUT size is 512x16"
}
}
}]

View file

@ -0,0 +1,83 @@
# Simulation macro
.main clear
# Cleanup libraries
foreach lib [list work OSVVM] {
file delete -force -- $lib
vlib $lib
}
set COMP_ONLY 0
set TB_PATH ./../src/test
set SRC_PATH ../src
set COMMON_PATH ../../../common/0/src
set SEQUENCER_PATH ../../../generic_sequencer/17
set OSVVM_PATH ../../../common/0/src/test/OSVVM
set WORKLIB work
vlib ./work
vmap work ./work
if {$COMP_ONLY == 0} {
# Compile the constrained random related packages
vlib OSVVM
vcom -2008 -work OSVVM \
$OSVVM_PATH/RandomBasePkg.vhd \
$OSVVM_PATH/SortListPkg_int.vhd \
$OSVVM_PATH/RandomPkg.vhd \
$OSVVM_PATH/NamePkg.vhd \
$OSVVM_PATH/MessagePkg.vhd \
$OSVVM_PATH/CoveragePkg.vhd
}
# compile the UUTs:
vcom -2008 -work work $COMMON_PATH/common_pkg.vhd
vcom -2008 -work $WORKLIB $COMMON_PATH/altera/sync_fifo.vhd
vcom -2008 -work $WORKLIB $COMMON_PATH/queue_and_delay.vhd
vcom -2008 -work $WORKLIB $COMMON_PATH/dpram_sclk.vhd
vcom -2008 -work $WORKLIB $COMMON_PATH/altera/alt_rw_dp_ram.vhd
#vcom -2008 -work $WORKLIB $SEQUENCER_PATH/src/altera/generic_seq_ram_16.vhd
vcom -2008 -work $WORKLIB $SEQUENCER_PATH/src/generic_sequencer_17_cmd_pkg.vhd
vcom -2008 -work $WORKLIB $SEQUENCER_PATH/src/generic_sequencer_17_pkg_auto.vhd
vcom -2008 -work $WORKLIB $SEQUENCER_PATH/src/generic_sequencer_17_csr_regs_auto.vhd
vcom -2008 -work $WORKLIB $SEQUENCER_PATH/src/generic_sequencer_17.vhd
vcom -2008 -work $WORKLIB $SRC_PATH/simple_frac_div_4.vhd
vcom -2008 -work $WORKLIB $SRC_PATH/pulse_generator_4_pkg_auto.vhd
vcom -2008 -work $WORKLIB $SRC_PATH/pulse_generator_4_csr_regs_auto.vhd
vcom -2008 -work $WORKLIB $SRC_PATH/pulse_generator_4.vhd
# Compile the testbench and the other components supporting the test
if {$COMP_ONLY == 0} {
# Test support packages
vcom -2008 -work $WORKLIB $COMMON_PATH/test/common_test_pkg.vhd
vcom -2008 -work $WORKLIB $COMMON_PATH/test/log_pkg.vhd
vcom -2008 -work $WORKLIB $COMMON_PATH/test/avalon_verify_pkg.vhd
# Testbench
vcom -2008 -work $WORKLIB $TB_PATH/ch_ctrl_cfg_tb.vhd
vsim -t ps work.ch_ctrl_cfg_tb
#add wave /ch_ctrl_cfg_tb/*
#add wave ch_ctrl_cfg_tb/iUUT/*
# remove warnings from standard numeric/arithmetic packages (speed-up simulation)
set StdArithNoWarnings 1
set NumericStdNoWarnings 1
do wave_ch_ctrl_cfg.do
when -label end_of_simulation {test_completed == true} {echo "Simulation Completed"; stop ;}
run -all
#run 1 ms;
}

View file

@ -0,0 +1,82 @@
# Simulation macro Net-Sync testbench
.main clear
# Cleanup libraries
foreach lib [list work OSVVM] {
file delete -force -- $lib
vlib $lib
}
set COMP_ONLY 0
set TB_PATH ./../src/test
set SRC_PATH ../src
set COMMON_PATH ../../../common/0/src
set SEQUENCER_PATH ../../../generic_sequencer/17
set OSVVM_PATH ../../../common/0/src/test/OSVVM
set WORKLIB work
vlib ./work
vmap work ./work
if {$COMP_ONLY == 0} {
# Compile the constrained random related packages
vlib OSVVM
vcom -2008 -work OSVVM \
$OSVVM_PATH/RandomBasePkg.vhd \
$OSVVM_PATH/SortListPkg_int.vhd \
$OSVVM_PATH/RandomPkg.vhd \
$OSVVM_PATH/NamePkg.vhd \
$OSVVM_PATH/MessagePkg.vhd \
$OSVVM_PATH/CoveragePkg.vhd
}
# compile the UUTs:
vcom -2008 -work work $COMMON_PATH/common_pkg.vhd
vcom -2008 -work $WORKLIB $COMMON_PATH/altera/sync_fifo.vhd
vcom -2008 -work $WORKLIB $COMMON_PATH/queue_and_delay.vhd
vcom -2008 -work $WORKLIB $COMMON_PATH/dpram_sclk.vhd
vcom -2008 -work $WORKLIB $COMMON_PATH/altera/alt_rw_dp_ram.vhd
#vcom -2008 -work $WORKLIB $SEQUENCER_PATH/src/altera/generic_seq_ram_16.vhd
vcom -2008 -work $WORKLIB $SEQUENCER_PATH/src/generic_sequencer_17_cmd_pkg.vhd
vcom -2008 -work $WORKLIB $SEQUENCER_PATH/src/generic_sequencer_17_pkg_auto.vhd
vcom -2008 -work $WORKLIB $SEQUENCER_PATH/src/generic_sequencer_17_csr_regs_auto.vhd
vcom -2008 -work $WORKLIB $SEQUENCER_PATH/src/generic_sequencer_17.vhd
vcom -2008 -work $WORKLIB $SRC_PATH/simple_frac_div_4.vhd
vcom -2008 -work $WORKLIB $SRC_PATH/pulse_generator_4_pkg_auto.vhd
vcom -2008 -work $WORKLIB $SRC_PATH/pulse_generator_4_csr_regs_auto.vhd
vcom -2008 -work $WORKLIB $SRC_PATH/pulse_generator_4.vhd
# Compile the testbench and the other components supporting the test
if {$COMP_ONLY == 0} {
# Test support packages
vcom -2008 -work $WORKLIB $COMMON_PATH/test/common_test_pkg.vhd
vcom -2008 -work $WORKLIB $COMMON_PATH/test/log_pkg.vhd
vcom -2008 -work $WORKLIB $COMMON_PATH/test/avalon_verify_pkg.vhd
# Testbench
vcom -2008 -work $WORKLIB $TB_PATH/pd_jitter_verify_tb.vhd
vsim -t ps work.pd_jitter_verify_tb
#add wave /pd_jitter_verify_tb/*
#add wave /pd_jitter_verify_tb/iUUT/*
# remove warnings from standard numeric/arithmetic packages (speed-up simulation)
set StdArithNoWarnings 1
set NumericStdNoWarnings 1
do wave_pd_jitter.do
when -label end_of_simulation {test_completed == true} {echo "Simulation Completed"; stop ;}
run -all
#run 1 ms;
}

View file

@ -0,0 +1,67 @@
# Simulation macro
.main clear
# Cleanup libraries
foreach lib [list work OSVVM] {
file delete -force -- $lib
vlib $lib
}
set COMP_ONLY 0
set TB_PATH ./../src/test
set OSVVM_PATH ../../../common/0/src/test/OSVVM
set COMMON_PATH ../../../common/0/src
set WORKLIB work
vlib ./work
vmap work ./work
if {$COMP_ONLY == 0} {
# Compile the constrained random related packages
vlib OSVVM
vcom -2008 -work OSVVM \
$OSVVM_PATH/RandomBasePkg.vhd \
$OSVVM_PATH/SortListPkg_int.vhd \
$OSVVM_PATH/RandomPkg.vhd \
$OSVVM_PATH/NamePkg.vhd \
$OSVVM_PATH/MessagePkg.vhd \
$OSVVM_PATH/CoveragePkg.vhd
}
# compile the UUTs:
vcom -2008 -work $WORKLIB ../src/simple_frac_div_4.vhd
# Compile the testbench and the other components supporting the test
if {$COMP_ONLY == 0} {
# Test support packages
vcom -2008 -work $WORKLIB $COMMON_PATH/test/common_test_pkg.vhd
vcom -2008 -work $WORKLIB $COMMON_PATH/test/log_pkg.vhd
# Testbench
vcom -2008 -work $WORKLIB $TB_PATH/simple_frac_div_tb.vhd
vsim -t ps work.simple_frac_div_tb
#add wave /simple_frac_div_tb/*
#add wave /simple_frac_div_tb/iUUT/*
# remove warnings from standard numeric/arithmetic packages (speed-up simulation)
set StdArithNoWarnings 1
set NumericStdNoWarnings 1
do wave_simple_frac_div.do
when -label end_of_simulation {test_completed == true} {echo "Simulation Completed"; stop ;}
run -all
#run 1 ms;
}

View file

@ -0,0 +1,86 @@
# Simulation macro
.main clear
# Cleanup libraries
foreach lib [list work OSVVM] {
file delete -force -- $lib
vlib $lib
}
set COMP_ONLY 0
set TB_PATH ./../src/test
set SRC_PATH ../src
set COMMON_PATH ../../../common/0/src
set SEQUENCER_PATH ../../../generic_sequencer/17
set FPM_PATH ../../../fire_pulse_manager/7/src
set OSVVM_PATH ../../../common/0/src/test/OSVVM
set WORKLIB work
vlib ./work
vmap work ./work
if {$COMP_ONLY == 0} {
# Compile the constrained random related packages
vlib OSVVM
vcom -2008 -work OSVVM \
$OSVVM_PATH/RandomBasePkg.vhd \
$OSVVM_PATH/SortListPkg_int.vhd \
$OSVVM_PATH/RandomPkg.vhd \
$OSVVM_PATH/NamePkg.vhd \
$OSVVM_PATH/MessagePkg.vhd \
$OSVVM_PATH/CoveragePkg.vhd
}
# compile the UUTs:
vcom -2008 -work work $COMMON_PATH/common_pkg.vhd
vcom -2008 -work $WORKLIB $COMMON_PATH/altera/sync_fifo.vhd
vcom -2008 -work $WORKLIB $COMMON_PATH/queue_and_delay.vhd
vcom -2008 -work $WORKLIB $COMMON_PATH/dpram_sclk.vhd
vcom -2008 -work $WORKLIB $COMMON_PATH/altera/alt_rw_dp_ram.vhd
#vcom -2008 -work $WORKLIB $SEQUENCER_PATH/src/altera/generic_seq_ram_16.vhd
vcom -2008 -work $WORKLIB $SEQUENCER_PATH/src/generic_sequencer_17_cmd_pkg.vhd
vcom -2008 -work $WORKLIB $SEQUENCER_PATH/src/generic_sequencer_17_pkg_auto.vhd
vcom -2008 -work $WORKLIB $SEQUENCER_PATH/src/generic_sequencer_17_csr_regs_auto.vhd
vcom -2008 -work $WORKLIB $SEQUENCER_PATH/src/generic_sequencer_17.vhd
vcom -2008 -work $WORKLIB $SRC_PATH/simple_frac_div_4.vhd
vcom -2008 -work $WORKLIB $SRC_PATH/pulse_generator_4_pkg_auto.vhd
vcom -2008 -work $WORKLIB $SRC_PATH/pulse_generator_4_csr_regs_auto.vhd
vcom -2008 -work $WORKLIB $SRC_PATH/pulse_generator_4.vhd
vcom -2008 -work $WORKLIB $FPM_PATH/simple_enc_vel_detect_6.vhd
# Compile the testbench and the other components supporting the test
if {$COMP_ONLY == 0} {
# Test support packages
vcom -2008 -work $WORKLIB $COMMON_PATH/test/common_test_pkg.vhd
vcom -2008 -work $WORKLIB $COMMON_PATH/test/log_pkg.vhd
vcom -2008 -work $WORKLIB $COMMON_PATH/test/avalon_verify_pkg.vhd
# Testbench
vcom -2008 -work $WORKLIB $TB_PATH/tof_comp_tb.vhd
vsim -t ps work.tof_comp_tb
#add wave tof_comp_tb/*
#add wave tof_comp_tb/iUUT/*
#add wave tof_comp_tb/iVEL/*
# remove warnings from standard numeric/arithmetic packages (speed-up simulation)
set StdArithNoWarnings 1
set NumericStdNoWarnings 1
do wave_tof_comp.do
when -label end_of_simulation {test_completed == true} {echo "Simulation Completed"; stop ;}
run -all
#run 1 ms;
}

View file

@ -0,0 +1,255 @@
onerror {resume}
quietly WaveActivateNextPane {} 0
add wave -noupdate /ch_ctrl_cfg_tb/reset_n
add wave -noupdate /ch_ctrl_cfg_tb/clk
add wave -noupdate /ch_ctrl_cfg_tb/wheel_error
add wave -noupdate /ch_ctrl_cfg_tb/rotation_idx
add wave -noupdate -radix decimal /ch_ctrl_cfg_tb/iUUT/wh_rotat_cnt
add wave -noupdate /ch_ctrl_cfg_tb/wh_pos_err_r
add wave -noupdate /ch_ctrl_cfg_tb/div_ratio_corr_rr
add wave -noupdate /ch_ctrl_cfg_tb/wheel_corr_on
add wave -noupdate /ch_ctrl_cfg_tb/pos_error
add wave -noupdate /ch_ctrl_cfg_tb/pos_error_old
add wave -noupdate /ch_ctrl_cfg_tb/div_ratio_corr_r
add wave -noupdate /ch_ctrl_cfg_tb/div_ratio_r
add wave -noupdate -radix hexadecimal /ch_ctrl_cfg_tb/iUUT/div_ratio
add wave -noupdate -radix hexadecimal /ch_ctrl_cfg_tb/iUUT/div_ratio_i
add wave -noupdate -radix hexadecimal /ch_ctrl_cfg_tb/iUUT/div_ratio_corr
add wave -noupdate -radix decimal /ch_ctrl_cfg_tb/iUUT/wh_loop_filt_tot
add wave -noupdate -radix decimal /ch_ctrl_cfg_tb/iUUT/wh_loop_filt_delta
add wave -noupdate -radix decimal /ch_ctrl_cfg_tb/iUUT/wh_pos_err_old
add wave -noupdate -radix decimal /ch_ctrl_cfg_tb/iUUT/wh_tot_err
add wave -noupdate -radix decimal /ch_ctrl_cfg_tb/iUUT/wh_delta_err
add wave -noupdate -radix decimal /ch_ctrl_cfg_tb/iUUT/wh_loop_err
add wave -noupdate /ch_ctrl_cfg_tb/wh_pos_err_r
add wave -noupdate -radix decimal /ch_ctrl_cfg_tb/iUUT/wh_pos_err_curr
add wave -noupdate /ch_ctrl_cfg_tb/init
add wave -noupdate /ch_ctrl_cfg_tb/pd_in
add wave -noupdate /ch_ctrl_cfg_tb/skip_pd
add wave -noupdate /ch_ctrl_cfg_tb/wheel_pos
add wave -noupdate -radix decimal /ch_ctrl_cfg_tb/abs_position
add wave -noupdate /ch_ctrl_cfg_tb/dp_dir
add wave -noupdate /ch_ctrl_cfg_tb/fire_req
add wave -noupdate /ch_ctrl_cfg_tb/fire_req_vec
add wave -noupdate /ch_ctrl_cfg_tb/start_of_image_vec
add wave -noupdate /ch_ctrl_cfg_tb/filtered_pd
add wave -noupdate /ch_ctrl_cfg_tb/ch_pd
add wave -noupdate /ch_ctrl_cfg_tb/ch_mask
add wave -noupdate /ch_ctrl_cfg_tb/raw_fire_req
add wave -noupdate -radix hexadecimal /ch_ctrl_cfg_tb/avs_address
add wave -noupdate /ch_ctrl_cfg_tb/avs_write
add wave -noupdate -radix hexadecimal /ch_ctrl_cfg_tb/avs_writedata
add wave -noupdate /ch_ctrl_cfg_tb/avs_read
add wave -noupdate -radix hexadecimal /ch_ctrl_cfg_tb/avs_readdata
add wave -noupdate -radix hexadecimal /ch_ctrl_cfg_tb/avs_m
add wave -noupdate -radix hexadecimal /ch_ctrl_cfg_tb/avs_s
add wave -noupdate /ch_ctrl_cfg_tb/pd_in_cnt
add wave -noupdate /ch_ctrl_cfg_tb/pd_out_cnt
add wave -noupdate /ch_ctrl_cfg_tb/test_completed
add wave -noupdate /ch_ctrl_cfg_tb/setup
add wave -noupdate /ch_ctrl_cfg_tb/running
add wave -noupdate /ch_ctrl_cfg_tb/passed
add wave -noupdate /ch_ctrl_cfg_tb/failed
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/fire_req
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/fire_req_vec
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/start_of_image_vec
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/start_of_image
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/start_image_flag
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/start_img
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/new_pixel
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/subpix_phase
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/subpix_phase_cnt
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/subpixel_phase_num
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/wh_apply_corr_en
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/wh_error_meas_avail
add wave -noupdate /ch_ctrl_cfg_tb/pos_error
add wave -noupdate -radix hexadecimal /ch_ctrl_cfg_tb/iUUT/wh_pos_err_abs
add wave -noupdate -radix hexadecimal /ch_ctrl_cfg_tb/iUUT/wh_skip_corr_thres
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/wh_skip_corr
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/wh_corr_ready
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/wh_error_meas_started
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/init_wh
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/loc_pd_d
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/wh_meas_event
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/wh_img_end
add wave -noupdate -radix unsigned /ch_ctrl_cfg_tb/iUUT/wh_img_pixel_cnt
add wave -noupdate -radix unsigned /ch_ctrl_cfg_tb/iUUT/wh_image_pixel_len
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/first_img_started
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/wh_error_meas_avail
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/wh_corr_ready_v
add wave -noupdate -radix decimal /ch_ctrl_cfg_tb/iUUT/start_pos
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/abs_pos_d
add wave -noupdate -radix decimal /ch_ctrl_cfg_tb/iUUT/basic_pos_error
add wave -noupdate -radix unsigned /ch_ctrl_cfg_tb/iUUT/wh_pos_err_abs
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/wh_skip_corr_thres
add wave -noupdate -radix hexadecimal /ch_ctrl_cfg_tb/iUUT/wh_pos_err
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/wh_pos_err_max
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/wh_pos_err_min
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/wh_pos_err_2_corr
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/div_ratio_corr_new
add wave -noupdate -radix decimal /ch_ctrl_cfg_tb/iUUT/pos_error
add wave -noupdate -radix hexadecimal /ch_ctrl_cfg_tb/iUUT/div_ratio_corr_ext
add wave -noupdate -radix hexadecimal /ch_ctrl_cfg_tb/iUUT/div_ratio
add wave -noupdate -radix hexadecimal /ch_ctrl_cfg_tb/iUUT/div_ratio_i
add wave -noupdate -radix hexadecimal /ch_ctrl_cfg_tb/iUUT/div_ratio_corr
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/clk
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/reset_n
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/init
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/pd_in
add wave -noupdate -radix decimal /ch_ctrl_cfg_tb/iUUT/abs_position
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/dp_dir
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/filtered_pd
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/ch_pd
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/ch_mask
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/enc_pulse
add wave -noupdate -radix hexadecimal /ch_ctrl_cfg_tb/iUUT/avs_address
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/avs_write
add wave -noupdate -radix hexadecimal /ch_ctrl_cfg_tb/iUUT/avs_writedata
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/avs_read
add wave -noupdate -radix hexadecimal /ch_ctrl_cfg_tb/iUUT/avs_readdata
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/init_de
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/init_qd
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/enable
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/loc_pd
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/pd_queue_error
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/ch_ctrl_start_req
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/pd_pulse
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/filt_pd
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/filt_pd_d
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/ch_ctrl_write
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/ch_ctrl_read
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/ch_ctrl_busy
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/enable_i
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/ch_mask_i
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/bypass_ch_ctrl
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/bypass_delay_equal
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/div_pulse
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/gated_pulse
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/retimed_pulse
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/avs_write_i
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/avs_read_d
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/avs_read_i
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/de_queue_error
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/cnt_dir
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/dp_dir_i
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/ch_ctrl_start_req_i
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/set_first_pd
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/dp_dir_d
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/start_img_req
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/start_img_req_d
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/start_img
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/start_img_d
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/start_img_dd
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/fire_enable
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/img_completed
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/sw_ctrl_dp_dir
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/enable_out
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/ch_ctrl_start_req_d
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/add_img_size
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/add_img_size_d
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/abort_fire
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/ch_ctrl_csr_write
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/ch_ctrl_csr_read
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/frac_div_en_i
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/upd_max_pos
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/upd_min_pos
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/frac_div_en
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/gen_filt_pd
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/upd_max_pos_i
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/upd_min_pos_i
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/dir_change
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/first_pd
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/pd_in_d
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/filt_pd_i
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/abs_pos_lsb
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/ch_ctrl_start_req_ii
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/prevent_div_restart
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/rst_jitter
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/rst_diag_regs
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/fire_req
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/mid_cross
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/mid_crossed
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/zero_cross
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/close_to_zero
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/close_to_mid
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/div_pulse_i
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/spitting_enable
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/spit_pulse
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/seq_bus_valid
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/spit_nco_msb
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/abs_pos_msb_old
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/ch_ctrl_csr_addr
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/ch_ctrl_trigger_in
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/avs_addr
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/init_v
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/ch_ctrl_start_addr
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/ch_ctrl_address
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/img_size
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/pixel_cnt
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/ch_ctrl_vector_out
add wave -noupdate -radix unsigned /ch_ctrl_cfg_tb/iUUT/ch_offset
add wave -noupdate -radix unsigned /ch_ctrl_cfg_tb/iUUT/ch_delay
add wave -noupdate -radix hexadecimal /ch_ctrl_cfg_tb/iUUT/avs_readdata_i
add wave -noupdate -radix hexadecimal /ch_ctrl_cfg_tb/iUUT/ch_ctrl_writedata
add wave -noupdate -radix hexadecimal /ch_ctrl_cfg_tb/iUUT/ch_ctrl_readdata
add wave -noupdate -radix hexadecimal /ch_ctrl_cfg_tb/iUUT/ch_ctrl_csr_writedata
add wave -noupdate -radix hexadecimal /ch_ctrl_cfg_tb/iUUT/ch_ctrl_csr_readdata
add wave -noupdate -radix unsigned /ch_ctrl_cfg_tb/iUUT/ch_offset_dir0
add wave -noupdate -radix unsigned /ch_ctrl_cfg_tb/iUUT/ch_offset_dir1
add wave -noupdate -radix decimal /ch_ctrl_cfg_tb/iUUT/abs_pos_max
add wave -noupdate -radix decimal /ch_ctrl_cfg_tb/iUUT/abs_pos_min
add wave -noupdate -radix decimal /ch_ctrl_cfg_tb/iUUT/last_pd_pos
add wave -noupdate -radix unsigned /ch_ctrl_cfg_tb/iUUT/fire_req_cnt
add wave -noupdate -radix hexadecimal /ch_ctrl_cfg_tb/iUUT/seq_bus_data
add wave -noupdate -radix hexadecimal /ch_ctrl_cfg_tb/iUUT/spit_nco
add wave -noupdate -radix hexadecimal /ch_ctrl_cfg_tb/iUUT/spit_nco_inc
add wave -noupdate -radix hexadecimal /ch_ctrl_cfg_tb/iUUT/div_ratio
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/div_ratio_i
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/div_ratio_corr
add wave -noupdate -divider {PD Queue}
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/iPD_queue/USE_EXT_TIME
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/iPD_queue/QUEUE_SIZE
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/iPD_queue/rstN
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/iPD_queue/clk
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/iPD_queue/init
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/iPD_queue/cnt_dir
add wave -noupdate -radix decimal /ch_ctrl_cfg_tb/iUUT/iPD_queue/delay
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/iPD_queue/ext_time
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/iPD_queue/wave_in
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/iPD_queue/wave_out
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/iPD_queue/ovf_error
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/iPD_queue/toggle_in
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/iPD_queue/toggle_out
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/iPD_queue/time_elapsed
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/iPD_queue/wave_in_d
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/iPD_queue/wave_out_i
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/iPD_queue/pending_trans
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/iPD_queue/fifo_rd_en
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/iPD_queue/fifo_empty
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/iPD_queue/fifo_full
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/iPD_queue/cnt_dir_i
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/iPD_queue/wave_out_i_d
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/iPD_queue/new_event
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/iPD_queue/wave_out_ii
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/iPD_queue/shf_enable
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/iPD_queue/delay_line
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/iPD_queue/local_time_d
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/iPD_queue/event_time
TreeUpdate [SetDefaultTree]
WaveRestoreCursors {{Cursor 1} {2135755000 ps} 0} {{Cursor 2} {15451360286 ps} 0}
quietly wave cursor active 2
configure wave -namecolwidth 293
configure wave -valuecolwidth 216
configure wave -justifyvalue left
configure wave -signalnamewidth 0
configure wave -snapdistance 10
configure wave -datasetprefix 0
configure wave -rowmargin 4
configure wave -childrowmargin 2
configure wave -gridoffset 0
configure wave -gridperiod 1
configure wave -griddelta 40
configure wave -timeline 0
configure wave -timelineunits ps
update
WaveRestoreZoom {17886802338 ps} {19427520930 ps}

View file

@ -0,0 +1,148 @@
onerror {resume}
quietly WaveActivateNextPane {} 0
add wave -noupdate /pd_jitter_verify_tb/reset_n
add wave -noupdate /pd_jitter_verify_tb/clk
add wave -noupdate /pd_jitter_verify_tb/init
add wave -noupdate /pd_jitter_verify_tb/pd_in
add wave -noupdate -radix decimal /pd_jitter_verify_tb/abs_position
add wave -noupdate /pd_jitter_verify_tb/dp_dir
add wave -noupdate /pd_jitter_verify_tb/filtered_pd
add wave -noupdate /pd_jitter_verify_tb/ch_pd
add wave -noupdate /pd_jitter_verify_tb/pd_in_cnt
add wave -noupdate /pd_jitter_verify_tb/pd_out_cnt
add wave -noupdate /pd_jitter_verify_tb/ch_mask
add wave -noupdate -radix hexadecimal /pd_jitter_verify_tb/avs_address
add wave -noupdate /pd_jitter_verify_tb/avs_write
add wave -noupdate -radix hexadecimal /pd_jitter_verify_tb/avs_writedata
add wave -noupdate /pd_jitter_verify_tb/avs_read
add wave -noupdate /pd_jitter_verify_tb/avs_readdatavalid
add wave -noupdate -radix hexadecimal /pd_jitter_verify_tb/avs_readdata
add wave -noupdate /pd_jitter_verify_tb/avs_m
add wave -noupdate /pd_jitter_verify_tb/avs_s
add wave -noupdate /pd_jitter_verify_tb/test_completed
add wave -noupdate /pd_jitter_verify_tb/setup
add wave -noupdate /pd_jitter_verify_tb/running
add wave -noupdate /pd_jitter_verify_tb/error_flag
add wave -noupdate /pd_jitter_verify_tb/passed
add wave -noupdate /pd_jitter_verify_tb/failed
add wave -noupdate /pd_jitter_verify_tb/iUUT/clk
add wave -noupdate /pd_jitter_verify_tb/iUUT/reset_n
add wave -noupdate /pd_jitter_verify_tb/iUUT/init
add wave -noupdate /pd_jitter_verify_tb/iUUT/pd_in
add wave -noupdate -radix decimal /pd_jitter_verify_tb/iUUT/abs_position
add wave -noupdate /pd_jitter_verify_tb/iUUT/dp_dir
add wave -noupdate /pd_jitter_verify_tb/iUUT/gen_filt_pd
add wave -noupdate /pd_jitter_verify_tb/iUUT/filtered_pd
add wave -noupdate /pd_jitter_verify_tb/iUUT/pd_pulse
add wave -noupdate /pd_jitter_verify_tb/iUUT/first_pd
add wave -noupdate /pd_jitter_verify_tb/iUUT/filt_pd
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_pd
add wave -noupdate -radix decimal /pd_jitter_verify_tb/iUUT/last_pd_pos
add wave -noupdate /pd_jitter_verify_tb/iUUT/close_to_zero
add wave -noupdate /pd_jitter_verify_tb/iUUT/close_to_mid
add wave -noupdate /pd_jitter_verify_tb/iUUT/mid_cross
add wave -noupdate /pd_jitter_verify_tb/iUUT/mid_crossed
add wave -noupdate /pd_jitter_verify_tb/iUUT/zero_cross
add wave -noupdate /pd_jitter_verify_tb/iUUT/abs_pos_msb_old
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_mask
add wave -noupdate -radix hexadecimal /pd_jitter_verify_tb/iUUT/avs_address
add wave -noupdate /pd_jitter_verify_tb/iUUT/avs_write
add wave -noupdate -radix hexadecimal /pd_jitter_verify_tb/iUUT/avs_writedata
add wave -noupdate /pd_jitter_verify_tb/iUUT/avs_read
add wave -noupdate /pd_jitter_verify_tb/iUUT/avs_readdatavalid
add wave -noupdate -radix hexadecimal /pd_jitter_verify_tb/iUUT/avs_readdata
add wave -noupdate /pd_jitter_verify_tb/iUUT/init_de
add wave -noupdate /pd_jitter_verify_tb/iUUT/init_qd
add wave -noupdate /pd_jitter_verify_tb/iUUT/enable
add wave -noupdate /pd_jitter_verify_tb/iUUT/loc_pd
add wave -noupdate /pd_jitter_verify_tb/iUUT/pd_queue_error
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_ctrl_start_req
add wave -noupdate /pd_jitter_verify_tb/iUUT/filt_pd_d
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_ctrl_write
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_ctrl_read
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_ctrl_busy
add wave -noupdate /pd_jitter_verify_tb/iUUT/enable_i
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_mask_i
add wave -noupdate /pd_jitter_verify_tb/iUUT/bypass_ch_ctrl
add wave -noupdate /pd_jitter_verify_tb/iUUT/bypass_delay_equal
add wave -noupdate /pd_jitter_verify_tb/iUUT/div_pulse
add wave -noupdate /pd_jitter_verify_tb/iUUT/gated_pulse
add wave -noupdate /pd_jitter_verify_tb/iUUT/retimed_pulse
add wave -noupdate /pd_jitter_verify_tb/iUUT/avs_write_i
add wave -noupdate /pd_jitter_verify_tb/iUUT/avs_read_d
add wave -noupdate /pd_jitter_verify_tb/iUUT/avs_read_i
add wave -noupdate /pd_jitter_verify_tb/iUUT/de_queue_error
add wave -noupdate /pd_jitter_verify_tb/iUUT/cnt_dir
add wave -noupdate /pd_jitter_verify_tb/iUUT/dp_dir_i
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_ctrl_start_req_i
add wave -noupdate /pd_jitter_verify_tb/iUUT/set_first_pd
add wave -noupdate /pd_jitter_verify_tb/iUUT/dp_dir_d
add wave -noupdate /pd_jitter_verify_tb/iUUT/pulse_scale_out
add wave -noupdate /pd_jitter_verify_tb/iUUT/start_img_req
add wave -noupdate /pd_jitter_verify_tb/iUUT/start_img_req_d
add wave -noupdate /pd_jitter_verify_tb/iUUT/start_img
add wave -noupdate /pd_jitter_verify_tb/iUUT/start_img_d
add wave -noupdate /pd_jitter_verify_tb/iUUT/start_img_dd
add wave -noupdate /pd_jitter_verify_tb/iUUT/fire_enable
add wave -noupdate /pd_jitter_verify_tb/iUUT/img_completed
add wave -noupdate /pd_jitter_verify_tb/iUUT/sw_ctrl_dp_dir
add wave -noupdate /pd_jitter_verify_tb/iUUT/enable_out
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_ctrl_start_req_d
add wave -noupdate /pd_jitter_verify_tb/iUUT/add_img_size
add wave -noupdate /pd_jitter_verify_tb/iUUT/add_img_size_d
add wave -noupdate /pd_jitter_verify_tb/iUUT/abort_fire
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_ctrl_csr_write
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_ctrl_csr_read
add wave -noupdate /pd_jitter_verify_tb/iUUT/frac_div_en_i
add wave -noupdate /pd_jitter_verify_tb/iUUT/upd_max_pos
add wave -noupdate /pd_jitter_verify_tb/iUUT/upd_min_pos
add wave -noupdate /pd_jitter_verify_tb/iUUT/frac_div_en
add wave -noupdate /pd_jitter_verify_tb/iUUT/upd_max_pos_i
add wave -noupdate /pd_jitter_verify_tb/iUUT/upd_min_pos_i
add wave -noupdate /pd_jitter_verify_tb/iUUT/dir_change
add wave -noupdate /pd_jitter_verify_tb/iUUT/pd_in_d
add wave -noupdate /pd_jitter_verify_tb/iUUT/filt_pd_i
add wave -noupdate /pd_jitter_verify_tb/iUUT/abs_pos_lsb
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_ctrl_start_req_ii
add wave -noupdate /pd_jitter_verify_tb/iUUT/prevent_div_restart
add wave -noupdate /pd_jitter_verify_tb/iUUT/rst_jitter
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_ctrl_csr_addr
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_ctrl_trigger_in
add wave -noupdate /pd_jitter_verify_tb/iUUT/avs_addr
add wave -noupdate /pd_jitter_verify_tb/iUUT/init_v
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_ctrl_start_addr
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_ctrl_address
add wave -noupdate /pd_jitter_verify_tb/iUUT/avs_address_i
add wave -noupdate /pd_jitter_verify_tb/iUUT/img_size
add wave -noupdate /pd_jitter_verify_tb/iUUT/pixel_cnt
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_ctrl_vector_out
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_offset
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_delay
add wave -noupdate /pd_jitter_verify_tb/iUUT/avs_readdata_i
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_ctrl_writedata
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_ctrl_readdata
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_ctrl_csr_writedata
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_ctrl_csr_readdata
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_offset_dir0
add wave -noupdate /pd_jitter_verify_tb/iUUT/ch_offset_dir1
add wave -noupdate /pd_jitter_verify_tb/iUUT/abs_pos_max
add wave -noupdate /pd_jitter_verify_tb/iUUT/abs_pos_min
add wave -noupdate /pd_jitter_verify_tb/iUUT/div_ratio
TreeUpdate [SetDefaultTree]
WaveRestoreCursors {{Cursor 1} {35005000 ps} 0}
quietly wave cursor active 1
configure wave -namecolwidth 281
configure wave -valuecolwidth 146
configure wave -justifyvalue left
configure wave -signalnamewidth 0
configure wave -snapdistance 10
configure wave -datasetprefix 0
configure wave -rowmargin 4
configure wave -childrowmargin 2
configure wave -gridoffset 0
configure wave -gridperiod 1
configure wave -griddelta 40
configure wave -timeline 0
configure wave -timelineunits ps
update
WaveRestoreZoom {85023836 ps} {100488220 ps}

View file

@ -0,0 +1,77 @@
onerror {resume}
quietly WaveActivateNextPane {} 0
add wave -noupdate /simple_frac_div_tb/reset_n
add wave -noupdate /simple_frac_div_tb/clk
add wave -noupdate /simple_frac_div_tb/enable
add wave -noupdate /simple_frac_div_tb/dir
add wave -noupdate -radix hexadecimal /simple_frac_div_tb/offset
add wave -noupdate -radix hexadecimal /simple_frac_div_tb/ratio
add wave -noupdate -radix decimal /simple_frac_div_tb/abs_pos
add wave -noupdate /simple_frac_div_tb/fire
add wave -noupdate -radix unsigned /simple_frac_div_tb/fire_cnt
add wave -noupdate /simple_frac_div_tb/div_ratio
add wave -noupdate /simple_frac_div_tb/pixel_offset
add wave -noupdate /simple_frac_div_tb/ideal_fire
add wave -noupdate /simple_frac_div_tb/firing_error
add wave -noupdate /simple_frac_div_tb/pos
add wave -noupdate /simple_frac_div_tb/test_completed
add wave -noupdate /simple_frac_div_tb/configuring
add wave -noupdate /simple_frac_div_tb/running
add wave -noupdate /simple_frac_div_tb/passed
add wave -noupdate /simple_frac_div_tb/failed
add wave -noupdate /simple_frac_div_tb/pTB_CTRL/delta_pos
add wave -noupdate /simple_frac_div_tb/pTB_CTRL/init_pos
add wave -noupdate /simple_frac_div_tb/pTB_CTRL/dir_m
add wave -noupdate /simple_frac_div_tb/pTB_CTRL/tot_steps
add wave -noupdate /simple_frac_div_tb/pTB_CTRL/result
add wave -noupdate /simple_frac_div_tb/pTB_CTRL/test_idx
add wave -noupdate /simple_frac_div_tb/iUUT/clk
add wave -noupdate /simple_frac_div_tb/iUUT/enable
add wave -noupdate /simple_frac_div_tb/iUUT/upd_max_pos
add wave -noupdate /simple_frac_div_tb/iUUT/upd_min_pos
add wave -noupdate -radix decimal /simple_frac_div_tb/iUUT/abs_pos_max
add wave -noupdate -radix decimal /simple_frac_div_tb/iUUT/abs_pos_min
add wave -noupdate /simple_frac_div_tb/iUUT/dir
add wave -noupdate -radix hexadecimal /simple_frac_div_tb/iUUT/offset
add wave -noupdate -radix hexadecimal /simple_frac_div_tb/iUUT/ratio
add wave -noupdate -radix decimal /simple_frac_div_tb/iUUT/abs_pos
add wave -noupdate /simple_frac_div_tb/iUUT/fire
add wave -noupdate -radix unsigned /simple_frac_div_tb/iUUT/fire_cnt
add wave -noupdate /simple_frac_div_tb/iUUT/enable_d
add wave -noupdate /simple_frac_div_tb/iUUT/start
add wave -noupdate /simple_frac_div_tb/iUUT/inc_pos
add wave -noupdate /simple_frac_div_tb/iUUT/dec_pos
add wave -noupdate /simple_frac_div_tb/iUUT/new_max
add wave -noupdate /simple_frac_div_tb/iUUT/new_min
add wave -noupdate /simple_frac_div_tb/iUUT/delta_wrap
add wave -noupdate -radix decimal /simple_frac_div_tb/iUUT/pos_diff
add wave -noupdate -radix decimal /simple_frac_div_tb/iUUT/pos_max
add wave -noupdate -radix decimal /simple_frac_div_tb/iUUT/pos_min
add wave -noupdate -radix decimal /simple_frac_div_tb/iUUT/dist_pos
add wave -noupdate -radix decimal /simple_frac_div_tb/iUUT/dist_neg
add wave -noupdate /simple_frac_div_tb/iUUT/update
add wave -noupdate -radix unsigned /simple_frac_div_tb/iUUT/fire_cnt_i
add wave -noupdate /simple_frac_div_tb/iUUT/zeros
add wave -noupdate -radix unsigned /simple_frac_div_tb/iUUT/delta_pos
add wave -noupdate -radix decimal /simple_frac_div_tb/iUUT/pos_diff
add wave -noupdate -radix unsigned /simple_frac_div_tb/iUUT/abs_pos_d
add wave -noupdate -radix decimal /simple_frac_div_tb/iUUT/ideal_fire
add wave -noupdate -radix decimal /simple_frac_div_tb/iUUT/firing_error
TreeUpdate [SetDefaultTree]
WaveRestoreCursors {{Cursor 1} {212441 ps} 0}
quietly wave cursor active 1
configure wave -namecolwidth 266
configure wave -valuecolwidth 182
configure wave -justifyvalue left
configure wave -signalnamewidth 0
configure wave -snapdistance 10
configure wave -datasetprefix 0
configure wave -rowmargin 4
configure wave -childrowmargin 2
configure wave -gridoffset 0
configure wave -gridperiod 1
configure wave -griddelta 40
configure wave -timeline 0
configure wave -timelineunits ps
update
WaveRestoreZoom {3225966927 ps} {3226491215 ps}

View file

@ -0,0 +1,270 @@
onerror {resume}
quietly WaveActivateNextPane {} 0
add wave -noupdate /tof_comp_tb/reset_n
add wave -noupdate /tof_comp_tb/clk
add wave -noupdate /tof_comp_tb/init
add wave -noupdate /tof_comp_tb/pd_in
add wave -noupdate -radix decimal /tof_comp_tb/abs_position
add wave -noupdate /tof_comp_tb/dp_dir
add wave -noupdate /tof_comp_tb/fire_req
add wave -noupdate /tof_comp_tb/filtered_pd
add wave -noupdate /tof_comp_tb/ch_pd
add wave -noupdate /tof_comp_tb/ch_mask
add wave -noupdate /tof_comp_tb/raw_fire_req
add wave -noupdate /tof_comp_tb/avs_address
add wave -noupdate /tof_comp_tb/avs_write
add wave -noupdate /tof_comp_tb/avs_writedata
add wave -noupdate /tof_comp_tb/avs_read
add wave -noupdate /tof_comp_tb/avs_readdatavalid
add wave -noupdate /tof_comp_tb/avs_readdata
add wave -noupdate /tof_comp_tb/avs_m
add wave -noupdate /tof_comp_tb/avs_s
add wave -noupdate /tof_comp_tb/step_pos
add wave -noupdate /tof_comp_tb/step_neg
add wave -noupdate -radix decimal /tof_comp_tb/vel_meas
add wave -noupdate -radix unsigned /tof_comp_tb/iUUT/tof_lut_addr
add wave -noupdate -radix unsigned /tof_comp_tb/iUUT/tof_lut_comp
add wave -noupdate -radix unsigned /tof_comp_tb/iUUT/ch_delay
add wave -noupdate -radix unsigned /tof_comp_tb/iUUT/ch_delay_i
add wave -noupdate /tof_comp_tb/end_of_stimuli
add wave -noupdate /tof_comp_tb/test_completed
add wave -noupdate /tof_comp_tb/setup
add wave -noupdate /tof_comp_tb/running
add wave -noupdate /tof_comp_tb/passed
add wave -noupdate /tof_comp_tb/failed
add wave -noupdate /tof_comp_tb/vel_meas_cnt
add wave -noupdate /tof_comp_tb/vel_upd_flag
add wave -noupdate /tof_comp_tb/iUUT/clk
add wave -noupdate /tof_comp_tb/iUUT/reset_n
add wave -noupdate /tof_comp_tb/iUUT/init
add wave -noupdate /tof_comp_tb/iUUT/pd_in
add wave -noupdate -radix decimal /tof_comp_tb/iUUT/abs_position
add wave -noupdate /tof_comp_tb/fire_cnt
add wave -noupdate /tof_comp_tb/raw_fire_cnt
add wave -noupdate /tof_comp_tb/iUUT/dp_dir
add wave -noupdate -radix decimal /tof_comp_tb/iUUT/enc_vel
add wave -noupdate -radix hexadecimal /tof_comp_tb/iUUT/norm_enc_vel
add wave -noupdate /tof_comp_tb/iUUT/fire_req
add wave -noupdate /tof_comp_tb/iUUT/tof_comp_enable
add wave -noupdate -radix unsigned /tof_comp_tb/iUUT/tof_lut_wr_addr
add wave -noupdate -radix unsigned /tof_comp_tb/iUUT/tof_lut_addr
add wave -noupdate -radix unsigned /tof_comp_tb/iUUT/ch_delay
add wave -noupdate -radix unsigned /tof_comp_tb/iUUT/ch_delay_i
add wave -noupdate /tof_comp_tb/iUUT/tof_saturation
add wave -noupdate /tof_comp_tb/iUUT/tof_sat_flag
add wave -noupdate /tof_comp_tb/iUUT/gated_pulse
add wave -noupdate /tof_comp_tb/iUUT/retimed_pulse
add wave -noupdate -radix unsigned /tof_comp_tb/iUUT/enc_speed_norm_coeff
add wave -noupdate -radix hexadecimal /tof_comp_tb/iUUT/tof_lut_wr_data
add wave -noupdate -radix unsigned /tof_comp_tb/iUUT/tof_lut_wr_q
add wave -noupdate -radix unsigned /tof_comp_tb/iUUT/tof_lut_comp
add wave -noupdate -radix unsigned /tof_comp_tb/iUUT/tof_lut_comp_i
add wave -noupdate -radix decimal /tof_comp_tb/iVEL/vel_meas
add wave -noupdate /tof_comp_tb/iVEL/sampling_pulse
add wave -noupdate /tof_comp_tb/iUUT/filtered_pd
add wave -noupdate /tof_comp_tb/iUUT/ch_pd
add wave -noupdate /tof_comp_tb/iUUT/ch_mask
add wave -noupdate /tof_comp_tb/iUUT/raw_fire_req
add wave -noupdate /tof_comp_tb/iUUT/enc_pulse
add wave -noupdate /tof_comp_tb/iUUT/avs_address
add wave -noupdate /tof_comp_tb/iUUT/avs_write
add wave -noupdate /tof_comp_tb/iUUT/avs_writedata
add wave -noupdate /tof_comp_tb/iUUT/avs_read
add wave -noupdate /tof_comp_tb/iUUT/avs_readdatavalid
add wave -noupdate /tof_comp_tb/iUUT/avs_readdata
add wave -noupdate /tof_comp_tb/iUUT/init_de
add wave -noupdate /tof_comp_tb/iUUT/init_qd
add wave -noupdate /tof_comp_tb/iUUT/enable
add wave -noupdate /tof_comp_tb/iUUT/loc_pd
add wave -noupdate /tof_comp_tb/iUUT/pd_queue_error
add wave -noupdate /tof_comp_tb/iUUT/ch_ctrl_start_req
add wave -noupdate /tof_comp_tb/iUUT/pd_pulse
add wave -noupdate /tof_comp_tb/iUUT/filt_pd
add wave -noupdate /tof_comp_tb/iUUT/filt_pd_d
add wave -noupdate /tof_comp_tb/iUUT/ch_ctrl_write
add wave -noupdate /tof_comp_tb/iUUT/ch_ctrl_read
add wave -noupdate /tof_comp_tb/iUUT/ch_ctrl_busy
add wave -noupdate /tof_comp_tb/iUUT/enable_i
add wave -noupdate /tof_comp_tb/iUUT/ch_mask_i
add wave -noupdate /tof_comp_tb/iUUT/bypass_ch_ctrl
add wave -noupdate /tof_comp_tb/iUUT/bypass_delay_equal
add wave -noupdate /tof_comp_tb/iUUT/div_pulse
add wave -noupdate /tof_comp_tb/iUUT/gated_pulse
add wave -noupdate /tof_comp_tb/iUUT/retimed_pulse
add wave -noupdate /tof_comp_tb/iUUT/avs_write_i
add wave -noupdate /tof_comp_tb/iUUT/avs_read_d
add wave -noupdate /tof_comp_tb/iUUT/avs_read_i
add wave -noupdate /tof_comp_tb/iUUT/de_queue_error
add wave -noupdate /tof_comp_tb/iUUT/cnt_dir
add wave -noupdate /tof_comp_tb/iUUT/dp_dir_i
add wave -noupdate /tof_comp_tb/iUUT/ch_ctrl_start_req_i
add wave -noupdate /tof_comp_tb/iUUT/set_first_pd
add wave -noupdate /tof_comp_tb/iUUT/dp_dir_d
add wave -noupdate /tof_comp_tb/iUUT/pulse_scale_out
add wave -noupdate /tof_comp_tb/iUUT/start_img_req
add wave -noupdate /tof_comp_tb/iUUT/start_img_req_d
add wave -noupdate /tof_comp_tb/iUUT/start_img
add wave -noupdate /tof_comp_tb/iUUT/start_img_d
add wave -noupdate /tof_comp_tb/iUUT/start_img_dd
add wave -noupdate /tof_comp_tb/iUUT/fire_enable
add wave -noupdate /tof_comp_tb/iUUT/img_completed
add wave -noupdate /tof_comp_tb/iUUT/sw_ctrl_dp_dir
add wave -noupdate /tof_comp_tb/iUUT/enable_out
add wave -noupdate /tof_comp_tb/iUUT/ch_ctrl_start_req_d
add wave -noupdate /tof_comp_tb/iUUT/add_img_size
add wave -noupdate /tof_comp_tb/iUUT/add_img_size_d
add wave -noupdate /tof_comp_tb/iUUT/abort_fire
add wave -noupdate /tof_comp_tb/iUUT/ch_ctrl_csr_write
add wave -noupdate /tof_comp_tb/iUUT/ch_ctrl_csr_read
add wave -noupdate /tof_comp_tb/iUUT/frac_div_en_i
add wave -noupdate /tof_comp_tb/iUUT/upd_max_pos
add wave -noupdate /tof_comp_tb/iUUT/upd_min_pos
add wave -noupdate /tof_comp_tb/iUUT/frac_div_en
add wave -noupdate /tof_comp_tb/iUUT/gen_filt_pd
add wave -noupdate /tof_comp_tb/iUUT/upd_max_pos_i
add wave -noupdate /tof_comp_tb/iUUT/upd_min_pos_i
add wave -noupdate /tof_comp_tb/iUUT/dir_change
add wave -noupdate /tof_comp_tb/iUUT/first_pd
add wave -noupdate /tof_comp_tb/iUUT/pd_in_d
add wave -noupdate /tof_comp_tb/iUUT/filt_pd_i
add wave -noupdate /tof_comp_tb/iUUT/abs_pos_lsb
add wave -noupdate /tof_comp_tb/iUUT/ch_ctrl_start_req_ii
add wave -noupdate /tof_comp_tb/iUUT/prevent_div_restart
add wave -noupdate /tof_comp_tb/iUUT/rst_jitter
add wave -noupdate /tof_comp_tb/iUUT/rst_diag_regs
add wave -noupdate /tof_comp_tb/iUUT/fire_req
add wave -noupdate /tof_comp_tb/iUUT/mid_cross
add wave -noupdate /tof_comp_tb/iUUT/mid_crossed
add wave -noupdate /tof_comp_tb/iUUT/zero_cross
add wave -noupdate /tof_comp_tb/iUUT/close_to_zero
add wave -noupdate /tof_comp_tb/iUUT/close_to_mid
add wave -noupdate /tof_comp_tb/iUUT/div_pulse_i
add wave -noupdate /tof_comp_tb/iUUT/spitting_enable
add wave -noupdate /tof_comp_tb/iUUT/spit_pulse
add wave -noupdate /tof_comp_tb/iUUT/seq_bus_valid
add wave -noupdate /tof_comp_tb/iUUT/spit_nco_msb
add wave -noupdate /tof_comp_tb/iUUT/wh_apply_corr_en
add wave -noupdate /tof_comp_tb/iUUT/wh_error_meas_avail
add wave -noupdate /tof_comp_tb/iUUT/wh_corr_ready
add wave -noupdate /tof_comp_tb/iUUT/wh_error_meas_started
add wave -noupdate /tof_comp_tb/iUUT/init_wh
add wave -noupdate /tof_comp_tb/iUUT/loc_pd_d
add wave -noupdate /tof_comp_tb/iUUT/wh_meas_event
add wave -noupdate /tof_comp_tb/iUUT/tof_lut_wr_en
add wave -noupdate /tof_comp_tb/iUUT/tof_comp_enable
add wave -noupdate /tof_comp_tb/iUUT/abs_pos_msb_old
add wave -noupdate /tof_comp_tb/iUUT/ch_ctrl_csr_addr
add wave -noupdate /tof_comp_tb/iUUT/ch_ctrl_trigger_in
add wave -noupdate /tof_comp_tb/iUUT/wh_corr_ready_v
add wave -noupdate /tof_comp_tb/iUUT/avs_addr
add wave -noupdate /tof_comp_tb/iUUT/init_v
add wave -noupdate /tof_comp_tb/iUUT/ch_ctrl_start_addr
add wave -noupdate /tof_comp_tb/iUUT/ch_ctrl_address
add wave -noupdate -radix unsigned /tof_comp_tb/iUUT/tof_lut_wr_addr
add wave -noupdate -radix unsigned /tof_comp_tb/iUUT/tof_lut_addr
add wave -noupdate -radix unsigned /tof_comp_tb/iUUT/tof_lut_comp
add wave -noupdate -radix unsigned /tof_comp_tb/iUUT/tof_lut_comp_i
add wave -noupdate -radix unsigned /tof_comp_tb/iUUT/ch_delay
add wave -noupdate -radix unsigned /tof_comp_tb/iUUT/ch_delay_i
add wave -noupdate /tof_comp_tb/iUUT/tof_saturation
add wave -noupdate /tof_comp_tb/iUUT/tof_sat_flag
add wave -noupdate /tof_comp_tb/iUUT/avs_address_i
add wave -noupdate /tof_comp_tb/iUUT/enc_vel_i
add wave -noupdate /tof_comp_tb/iUUT/wh_rotat_cnt
add wave -noupdate /tof_comp_tb/iUUT/basic_pos_error
add wave -noupdate /tof_comp_tb/iUUT/wh_loop_filt_tot
add wave -noupdate /tof_comp_tb/iUUT/wh_loop_filt_delta
add wave -noupdate -radix unsigned /tof_comp_tb/iUUT/enc_speed_norm_coeff
add wave -noupdate -radix hexadecimal /tof_comp_tb/iUUT/tof_lut_wr_data
add wave -noupdate -radix unsigned /tof_comp_tb/iUUT/tof_lut_wr_q
add wave -noupdate /tof_comp_tb/iUUT/img_size
add wave -noupdate /tof_comp_tb/iUUT/pixel_cnt
add wave -noupdate /tof_comp_tb/iUUT/ch_ctrl_vector_out
add wave -noupdate /tof_comp_tb/iUUT/wh_pos_err
add wave -noupdate /tof_comp_tb/iUUT/wh_pos_err_max
add wave -noupdate /tof_comp_tb/iUUT/wh_pos_err_old
add wave -noupdate /tof_comp_tb/iUUT/wh_tot_err
add wave -noupdate /tof_comp_tb/iUUT/wh_delta_err
add wave -noupdate /tof_comp_tb/iUUT/norm_enc_vel
add wave -noupdate /tof_comp_tb/iUUT/ch_offset
add wave -noupdate -radix decimal /tof_comp_tb/iVEL/vel_meas
add wave -noupdate /tof_comp_tb/iUUT/avs_readdata_i
add wave -noupdate /tof_comp_tb/iUUT/ch_ctrl_writedata
add wave -noupdate /tof_comp_tb/iUUT/ch_ctrl_readdata
add wave -noupdate /tof_comp_tb/iUUT/ch_ctrl_csr_writedata
add wave -noupdate /tof_comp_tb/iUUT/ch_ctrl_csr_readdata
add wave -noupdate /tof_comp_tb/iUUT/ch_offset_dir0
add wave -noupdate /tof_comp_tb/iUUT/ch_offset_dir1
add wave -noupdate /tof_comp_tb/iUUT/abs_pos_max
add wave -noupdate /tof_comp_tb/iUUT/abs_pos_min
add wave -noupdate /tof_comp_tb/iUUT/last_pd_pos
add wave -noupdate /tof_comp_tb/iUUT/fire_req_cnt
add wave -noupdate /tof_comp_tb/iUUT/seq_bus_data
add wave -noupdate /tof_comp_tb/iUUT/spit_nco
add wave -noupdate /tof_comp_tb/iUUT/spit_nco_inc
add wave -noupdate /tof_comp_tb/iUUT/start_pos
add wave -noupdate /tof_comp_tb/iUUT/abs_pos_d
add wave -noupdate /tof_comp_tb/iUUT/wh_pos_err_2_corr
add wave -noupdate /tof_comp_tb/iUUT/div_ratio
add wave -noupdate /tof_comp_tb/iUUT/div_ratio_i
add wave -noupdate /tof_comp_tb/iUUT/div_ratio_corr
add wave -noupdate /tof_comp_tb/iUUT/div_ratio_corr_new
add wave -noupdate /tof_comp_tb/iUUT/pos_error
add wave -noupdate /tof_comp_tb/iUUT/wh_loop_err
add wave -noupdate /tof_comp_tb/iUUT/div_ratio_corr_ext
add wave -noupdate /tof_comp_tb/iVEL/clk
add wave -noupdate /tof_comp_tb/iVEL/init
add wave -noupdate /tof_comp_tb/iVEL/step_pos
add wave -noupdate /tof_comp_tb/iVEL/step_neg
add wave -noupdate /tof_comp_tb/iVEL/init_i
add wave -noupdate /tof_comp_tb/iVEL/sampling_pulse
add wave -noupdate /tof_comp_tb/iVEL/sampling_per_cnt
add wave -noupdate /tof_comp_tb/iVEL/vel_meas_i
add wave -noupdate /tof_comp_tb/iVEL/vel_meas_sat_pos
add wave -noupdate /tof_comp_tb/iVEL/vel_meas_sat_neg
add wave -noupdate -divider {Delay Equalizer}
add wave -noupdate /tof_comp_tb/iUUT/gPULSE_DELAY_EQUAL/iDE/rstN
add wave -noupdate /tof_comp_tb/iUUT/gPULSE_DELAY_EQUAL/iDE/clk
add wave -noupdate /tof_comp_tb/iUUT/gPULSE_DELAY_EQUAL/iDE/init
add wave -noupdate /tof_comp_tb/iUUT/gPULSE_DELAY_EQUAL/iDE/cnt_dir
add wave -noupdate -radix decimal /tof_comp_tb/iUUT/gPULSE_DELAY_EQUAL/iDE/delay
add wave -noupdate /tof_comp_tb/iUUT/gPULSE_DELAY_EQUAL/iDE/ext_time
add wave -noupdate /tof_comp_tb/iUUT/gPULSE_DELAY_EQUAL/iDE/wave_in
add wave -noupdate /tof_comp_tb/iUUT/gPULSE_DELAY_EQUAL/iDE/wave_out
add wave -noupdate /tof_comp_tb/iUUT/gPULSE_DELAY_EQUAL/iDE/ovf_error
add wave -noupdate /tof_comp_tb/iUUT/gPULSE_DELAY_EQUAL/iDE/toggle_in
add wave -noupdate /tof_comp_tb/iUUT/gPULSE_DELAY_EQUAL/iDE/toggle_out
add wave -noupdate /tof_comp_tb/iUUT/gPULSE_DELAY_EQUAL/iDE/time_elapsed
add wave -noupdate /tof_comp_tb/iUUT/gPULSE_DELAY_EQUAL/iDE/wave_in_d
add wave -noupdate /tof_comp_tb/iUUT/gPULSE_DELAY_EQUAL/iDE/wave_out_i
add wave -noupdate /tof_comp_tb/iUUT/gPULSE_DELAY_EQUAL/iDE/pending_trans
add wave -noupdate /tof_comp_tb/iUUT/gPULSE_DELAY_EQUAL/iDE/fifo_rd_en
add wave -noupdate /tof_comp_tb/iUUT/gPULSE_DELAY_EQUAL/iDE/fifo_empty
add wave -noupdate /tof_comp_tb/iUUT/gPULSE_DELAY_EQUAL/iDE/fifo_full
add wave -noupdate /tof_comp_tb/iUUT/gPULSE_DELAY_EQUAL/iDE/cnt_dir_i
add wave -noupdate /tof_comp_tb/iUUT/gPULSE_DELAY_EQUAL/iDE/wave_out_i_d
add wave -noupdate /tof_comp_tb/iUUT/gPULSE_DELAY_EQUAL/iDE/new_event
add wave -noupdate /tof_comp_tb/iUUT/gPULSE_DELAY_EQUAL/iDE/wave_out_ii
add wave -noupdate /tof_comp_tb/iUUT/gPULSE_DELAY_EQUAL/iDE/shf_enable
add wave -noupdate /tof_comp_tb/iUUT/gPULSE_DELAY_EQUAL/iDE/delay_line
add wave -noupdate -radix unsigned /tof_comp_tb/iUUT/gPULSE_DELAY_EQUAL/iDE/int_time
add wave -noupdate /tof_comp_tb/iUUT/gPULSE_DELAY_EQUAL/iDE/local_time_d
add wave -noupdate -radix unsigned /tof_comp_tb/iUUT/gPULSE_DELAY_EQUAL/iDE/event_time
TreeUpdate [SetDefaultTree]
WaveRestoreCursors {{Cursor 1} {10895000 ps} 0} {{Cursor 2} {121098274 ps} 0}
quietly wave cursor active 1
configure wave -namecolwidth 394
configure wave -valuecolwidth 100
configure wave -justifyvalue left
configure wave -signalnamewidth 0
configure wave -snapdistance 10
configure wave -datasetprefix 0
configure wave -rowmargin 4
configure wave -childrowmargin 2
configure wave -gridoffset 0
configure wave -gridperiod 1
configure wave -griddelta 40
configure wave -timeline 0
configure wave -timelineunits ps
update
WaveRestoreZoom {0 ps} {220244480 ps}

View file

@ -0,0 +1,972 @@
-------------------------------------------------------------------------------
-- Title : Pulse Generator
-- Project : ELGIP
-------------------------------------------------------------------------------
-- File : Pulse Generator.vhd
-- Author : Gianmarco Girau
-- Company : Global Inkjet Systems
-- Created : 2016-10-24
-- Last update: 2021-04-12
-- SVN ID : Git
-- Standard : VHDL'93
-------------------------------------------------------------------------------
-- Description:
-- The Pulse Generator implements the following functionalities:
-- PD queue, with channel specific offset (positional)
-- Fire-Request-Generation (Fractional Divider)
-- Spitting Functionality
-- Delay Equalization: compensate for the difference in the channel latency
-- when daisy-chaining multiple EMBs.
-- Pulse-Width conditioning, for transmission over the POF (to be moved out
-- from the block in the future)
-- Channel control: Mask/Unmask pulse generation based on PD, image length,
-- directionality etc.
-------------------------------------------------------------------------------
-- altera vhdl_input_version vhdl_2008
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
library work;
use work.common_pkg.all;
entity pulse_generator_4 is
generic(
PD_QUEUE_SIZE : natural range 32 to 1024 := 64;
PULSE_DELAY_EQUAL_EN : boolean := true;
SPITTING_EN : boolean := true;
BIDIR_CH_OFFSET_EN : boolean := true;
DIAG_COUNTERS : boolean := true;
TOF_COMP_EN : boolean := false;
PIXEL_PITCH_CORR_EN : boolean := false);
port(
clk : in std_logic;
reset_n : in std_logic := '1';
--
init : in std_logic;
-- Sequencer I/Os
pd_in : in std_logic;
abs_position : in std_logic_vector(31 downto 0);
enc_vel : in std_logic_vector(19 downto 0) := (others => '0');
enc_speed_meas_w : out std_logic_vector(19 downto 0);
dp_dir : out std_logic;
fire_req_vec : out std_logic_vector(31 downto 0);
start_of_image_vec : out std_logic_vector(31 downto 0);
stream_busy_a : in std_logic := '0';
stream_busy_b : in std_logic := '0';
-- diagnostic outputs
filtered_pd : out std_logic;
ch_pd : out std_logic;
ch_mask : out std_logic;
raw_fire_req : out std_logic;
enc_pulse : out std_logic;
-----------------------------------------------------------------------
-- Avalon MM Interface
-----------------------------------------------------------------------
avs_address : in std_logic_vector(10 downto 0);
avs_write : in std_logic;
avs_writedata : in std_logic_vector(31 downto 0);
avs_read : in std_logic;
avs_readdata : out std_logic_vector(31 downto 0));
end entity pulse_generator_4;
architecture rtl of pulse_generator_4 is
component dpram_sclk is
generic (
DATA_WIDTH : natural;
ADDR_WIDTH : natural);
port (
clk : in std_logic;
addr_a : in std_logic_vector(ADDR_WIDTH-1 downto 0);
we_a : in std_logic := '1';
data_a : in std_logic_vector(DATA_WIDTH-1 downto 0);
q_a : out std_logic_vector(DATA_WIDTH-1 downto 0);
addr_b : in std_logic_vector(ADDR_WIDTH-1 downto 0);
we_b : in std_logic := '1';
data_b : in std_logic_vector(DATA_WIDTH-1 downto 0);
q_b : out std_logic_vector(DATA_WIDTH-1 downto 0));
end component dpram_sclk;
-- constants
constant CSR_IP_ID : std_logic_vector(31 downto 0) := x"0000FF13";
constant CSR_IP_VER : std_logic_vector(31 downto 0) := x"00000303";
constant TOF_COMP_LUT_DEPTH : natural := 512;
constant TOF_COMP_LUT_WIDTH : natural := 16;
signal init_de, init_qd, enable, loc_pd, pd_queue_error : std_logic;
signal ch_ctrl_start_req, pd_pulse, filt_pd, filt_pd_d : std_logic;
signal ch_ctrl_write, ch_ctrl_read, ch_ctrl_busy, enable_i : std_logic;
signal ch_mask_i, bypass_ch_ctrl, bypass_delay_equal : std_logic;
signal div_pulse, gated_pulse, retimed_pulse : std_logic;
signal avs_write_i, avs_read_d, avs_read_i, de_queue_error : std_logic;
signal cnt_dir, dp_dir_i, ch_ctrl_start_req_i : std_logic;
signal set_first_pd : std_logic;
signal dp_dir_d, loc_pd_d, loc_pd_dd : std_logic;
signal start_img_req, start_img_req_d, start_img, start_img_d : std_logic;
signal start_img_dd, fire_enable, img_completed : std_logic;
signal sw_ctrl_dp_dir, enable_out, ch_ctrl_start_req_d : std_logic;
signal add_img_size, add_img_size_d, abort_fire : std_logic;
signal ch_ctrl_csr_write, ch_ctrl_csr_read, frac_div_en_i : std_logic;
signal upd_max_pos, upd_min_pos, frac_div_en, gen_filt_pd : std_logic;
signal upd_max_pos_i, upd_min_pos_i, dir_change, first_pd : std_logic;
signal pd_in_d, filt_pd_i, abs_pos_lsb, ch_ctrl_start_req_ii : std_logic := '0';
signal prevent_div_restart, rst_jitter, rst_diag_regs : std_logic;
signal fire_req, start_of_image, new_pixel : std_logic;
signal mid_cross, mid_crossed, zero_cross : std_logic;
signal close_to_zero, close_to_mid : std_logic;
signal div_pulse_i, spitting_enable, spit_pulse : std_logic;
signal seq_bus_valid, spit_nco_msb : std_logic;
signal wh_apply_corr_en, wh_error_meas_avail, wh_corr_ready : std_logic;
signal wh_error_meas_started, init_wh : std_logic;
signal wh_meas_event, wh_img_end, first_img_started : std_logic;
signal tof_lut_wr_en, tof_comp_enable : std_logic;
signal tof_saturation, tof_sat_flag : std_logic;
signal wh_apply_corr_en_d, wh_corr_start, wh_skip_corr : std_logic;
signal wh_img_2nd_half, wh_img_2nd_half_d : std_logic;
signal selected_pulse, selected_pulse_d, clr_pd_queue : std_logic;
signal zero_gap_mode, start_image_flag : std_logic;
signal use_ch_offset_dir1, add_ppc_regs, add_tof_comp_regs : std_logic;
signal add_delay_eq_reg, add_diag_reg : std_logic;
--
signal abs_pos_msb_old : std_logic_vector( 1 downto 0);
signal ch_ctrl_csr_addr : std_logic_vector( 3 downto 0);
signal wh_corr_ready_v, ch_ctrl_trigger_in : std_logic_vector( 5 downto 0);
signal avs_addr : std_logic_vector( 4 downto 0);
signal subpix_phase_cnt, subpixel_phase_num : std_logic_vector( 5 downto 0);
signal init_v : std_logic_vector( 7 downto 0);
signal ch_ctrl_start_addr, bpe_top : std_logic_vector( 7 downto 0);
signal ch_ctrl_address : std_logic_vector( 7 downto 0);
signal tof_lut_wr_addr, tof_lut_addr : std_logic_vector( 8 downto 0);
signal wh_rotat_cnt, gnd_16 : std_logic_vector(15 downto 0);
signal wh_loop_filt_tot, wh_loop_filt_delta : std_logic_vector(15 downto 0);
signal ch_delay, ch_delay_i : std_logic_vector(15 downto 0);
signal enc_speed_norm_coeff, tof_lut_wr_data : std_logic_vector(15 downto 0);
signal tof_lut_wr_q, tof_lut_comp : std_logic_vector(15 downto 0);
signal tof_lut_comp_i : std_logic_vector(15 downto 0);
signal pd_cnt : std_logic_vector(15 downto 0);
signal enc_speed_meas_w_i, enc_vel_i : std_logic_vector(19 downto 0);
signal img_size, pixel_cnt : std_logic_vector(23 downto 0);
signal ch_ctrl_vector_out : std_logic_vector(23 downto 0);
signal wh_skip_corr_thres : std_logic_vector(23 downto 0);
signal wh_img_pixel_cnt, wh_image_pixel_len : std_logic_vector(23 downto 0);
signal basic_pos_error_sat : std_logic_vector(23 downto 0);
signal fire_req_cnt : std_logic_vector(23 downto 0);
signal norm_enc_vel : std_logic_vector(35 downto 0);
signal ch_offset, avs_readdata_i : std_logic_vector(31 downto 0);
signal ch_ctrl_writedata, ch_ctrl_readdata : std_logic_vector(31 downto 0);
signal ch_ctrl_csr_writedata : std_logic_vector(31 downto 0);
signal ch_ctrl_csr_readdata : std_logic_vector(31 downto 0);
signal ch_offset_dir0, ch_offset_dir1 : std_logic_vector(31 downto 0);
signal abs_pos_max, abs_pos_min : std_logic_vector(31 downto 0);
signal last_pd_pos, basic_pos_error : std_logic_vector(31 downto 0);
signal seq_bus_data, spit_nco, spit_nco_inc : std_logic_vector(31 downto 0);
signal start_pos, abs_pos_d : std_logic_vector(31 downto 0);
signal subpix_phase : std_logic_vector(31 downto 0);
signal wh_pos_err_2_corr : std_logic_vector(31 downto 0);
signal wh_pos_err_max, wh_pos_err_min : std_logic_vector(31 downto 0);
signal wh_pos_err, wh_pos_err_curr : std_logic_vector(31 downto 0);
signal wh_pos_err_old, wh_pos_err_abs : std_logic_vector(31 downto 0);
signal wh_tot_err, wh_delta_err : std_logic_vector(31 downto 0);
signal div_ratio, div_ratio_i : std_logic_vector(33 downto 0);
signal div_ratio_corr, div_ratio_corr_new : std_logic_vector(33 downto 0);
signal wh_loop_err_delta, wh_loop_err_tot : std_logic_vector(47 downto 0);
signal pos_error, wh_loop_err : std_logic_vector(47 downto 0);
signal div_ratio_corr_ext : std_logic_vector(63 downto 0);
begin
-----------------------------------------------------------------------------
-- PD Jitter management
-----------------------------------------------------------------------------
-- Filter PD pulses in the following situations:
-- I. dp_dir = '0', no new max on abs_pos
-- II. dp_dir = '1', no new min on abs_pos
pd_pulse <= pd_in and not pd_in_d;
gen_filt_pd <= '1' when pd_pulse = '1' and (first_pd = '1' or
(dp_dir_i = '0' and close_to_zero = '1' and signed(abs_position) > signed(last_pd_pos)) or
(dp_dir_i = '0' and close_to_mid = '1' and unsigned(abs_position) > unsigned(last_pd_pos)) or
(dp_dir_i = '1' and close_to_zero = '1' and signed(abs_position) < signed(last_pd_pos)) or
(dp_dir_i = '1' and close_to_mid = '1' and unsigned(abs_position) < unsigned(last_pd_pos))) else '0';
close_to_zero <= '1' when abs_position(31 downto 30) = "00" or abs_position(31 downto 30) = "11" else '0';
close_to_mid <= '1' when abs_position(31 downto 30) = "01" or abs_position(31 downto 30) = "10" else '0';
set_first_pd <= '1' when init_qd = '1' or (dp_dir_i = '0' and upd_max_pos_i = '1') or (dp_dir_i = '1' and upd_min_pos_i = '1') or rst_jitter = '1' or (mid_cross = '1' and mid_crossed = '0') else '0';
pPD_JITTER_MNG : process(clk)
begin
if(clk = '1' and clk'event) then
pd_in_d <= pd_in;
if(set_first_pd = '1') then
first_pd <= '1';
elsif(filt_pd = '1') then
first_pd <= '0';
end if;
filt_pd <= gen_filt_pd;
filt_pd_d <= filt_pd;
if(set_first_pd = '1' or gen_filt_pd = '1') then
last_pd_pos <= abs_position;
end if;
abs_pos_msb_old <= abs_position(31 downto 30);
if(init_qd = '1' or zero_cross = '1') then
mid_crossed <= '0';
elsif(mid_cross = '1') then
mid_crossed <= '1';
end if;
end if;
end process pPD_JITTER_MNG;
mid_cross <= '1' when (dp_dir_i = '0' and abs_position(31 downto 30) = "10" and abs_pos_msb_old = "01") or (dp_dir_i = '1' and abs_position(31 downto 30) = "01" and abs_pos_msb_old = "10") else '0';
zero_cross <= '1' when (dp_dir_i = '0' and abs_position(31 downto 30) = "00" and abs_pos_msb_old = "11") or (dp_dir_i = '1' and abs_position(31 downto 30) = "11" and abs_pos_msb_old = "00") else '0';
filtered_pd <= filt_pd;
-----------------------------------------------------------------------------
-- PD Queue
-----------------------------------------------------------------------------
-- To implement the PD queuse a standard queue-and-delay block is used,
-- driven by the absolute position instead of a time counter. To prevent
-- confusing the queue-and-delay block, a PD pulse is de-asserted only on the
-- next increment of absolute position
pLOC_PD_IN : process(clk)
begin
if(clk = '1' and clk'event) then
abs_pos_lsb <= abs_position(0);
if(filt_pd = '1' and filt_pd_d = '0') then
filt_pd_i <= '1';
elsif(init = '1' or (filt_pd = '0' and filt_pd_i = '1' and abs_position(0) /= abs_pos_lsb)) then
filt_pd_i <= '0';
end if;
end if;
end process pLOC_PD_IN;
-- Note on the maximum size of queue: long PD queues must be taken care of at SW
-- level, here the size is limited to 128 (on the PMB it was 16)
iPD_queue: entity work.queue_and_delay
generic map (
USE_EXT_TIME => true,
QUEUE_SIZE => 2*PD_QUEUE_SIZE)
port map (
rstN => reset_n,
clk => clk,
init => init_qd,
cnt_dir => cnt_dir,
delay => ch_offset,
ext_time => abs_position,
wave_in => filt_pd_i,
wave_out => loc_pd,
ovf_error => pd_queue_error);
-- make sure the PD queue is always cleared whenever there is a change of direction
dir_change <= dp_dir_i xor dp_dir_d;
gBYDIR_CH_OFF: if BIDIR_CH_OFFSET_EN = true generate
use_ch_offset_dir1 <= '1';
else generate
use_ch_offset_dir1 <= '0';
end generate gBYDIR_CH_OFF;
-- channel offset selection
pCH_OFF_SEL : process(clk)
begin
if(clk = '1' and clk'event) then
if(use_ch_offset_dir1 = '1') then
if(dp_dir_i = '0') then
ch_offset <= ch_offset_dir0;
else
ch_offset <= ch_offset_dir1;
end if;
else
ch_offset <= ch_offset_dir0;
end if;
end if;
end process pCH_OFF_SEL;
-- output to the monitoring point/event-logger
ch_pd <= loc_pd;
-- enable the queue_and_delay counter to count backward
cnt_dir <= ch_ctrl_vector_out(0);
pDIR_CHG : process(clk)
begin
if(clk = '1' and clk'event) then
init_qd <= not enable or init or dir_change or clr_pd_queue or wh_corr_start;
if(bypass_ch_ctrl = '1') then
dp_dir_i <= sw_ctrl_dp_dir;
else
dp_dir_i <= ch_ctrl_vector_out(0);
end if;
dp_dir_d <= dp_dir_i;
end if;
end process pDIR_CHG;
dp_dir <= dp_dir_i;
-----------------------------------------------------------------------------
-- Channel control
-----------------------------------------------------------------------------
-- Generate a gating signal to apply to the divider output.
-- The gating signal is generated through a generic sequencer:
-- Sequencer triggers:
-- - Absolute position (bus)
-- - PD (from PD queue)
-- Sequencer outputs
-- - Gating signal (ch_mask)
i_channel_control : entity work.generic_sequencer_17
generic map (
TRIGGER_WIDTH => 6,
VECTOR_WIDTH => 24,
BUS_WIDTH => 32,
POS_WIDTH => 24,
SEQ_DEPTH => 256,
ADD_VEC_PIPE => false,
VECT_CPU_EN => false,
VECT_RAMP_EN => false,
BUS_BURST_EN => SPITTING_EN,
POS_BUS_EN => true,
ALU_EN => false,
QUEUE_EN => false)
port map (
clk => clk,
reset_n => reset_n,
avs_csr_address => ch_ctrl_csr_addr,
avs_csr_write => ch_ctrl_csr_write,
avs_csr_writedata => ch_ctrl_csr_writedata,
avs_csr_read => ch_ctrl_csr_read,
avs_csr_readdata => ch_ctrl_csr_readdata,
avs_seq_address => ch_ctrl_address,
avs_seq_write => ch_ctrl_write,
avs_seq_writedata => ch_ctrl_writedata,
avs_seq_read => ch_ctrl_read,
avs_seq_readdata => ch_ctrl_readdata,
start_req => ch_ctrl_start_req,
start_addr => ch_ctrl_start_addr,
trigger_in => ch_ctrl_trigger_in,
pos_in => abs_position(23 downto 0),
busy => ch_ctrl_busy,
vector_out => ch_ctrl_vector_out,
bus_data => seq_bus_data,
bus_valid => seq_bus_valid,
bus_ack => '1');
ch_ctrl_trigger_in <= (0 => loc_pd, 1 => fire_enable, 2 => gated_pulse, 3 => (not fire_enable), 4 => (not stream_busy_a), 5 => (not stream_busy_b));
ch_mask_i <= fire_enable or ch_ctrl_vector_out(1) or bypass_ch_ctrl;
-- output to the monitoring point/event-logger
ch_mask <= ch_mask_i;
start_img_req <= ch_ctrl_vector_out(2);
add_img_size <= ch_ctrl_vector_out(3);
prevent_div_restart <= ch_ctrl_vector_out(4);
--rst_jitter <= ch_ctrl_vector_out(5); -- The actual assignment is
--latched exactly as dp_dir to make sure both of them change at the same
--clock cycle
zero_gap_mode <= ch_ctrl_vector_out(7);
ch_ctrl_start_req_i <= ch_ctrl_start_req_ii and enable and not init;
ch_ctrl_start_req <= ch_ctrl_start_req_i and not ch_ctrl_start_req_d;
pGEN_IMAGE: process(clk)
begin
if(clk = '1' and clk'event) then
ch_ctrl_start_req_d <= ch_ctrl_start_req_i;
start_img_req_d <= start_img_req;
start_img_d <= start_img;
start_img_dd <= start_img_d;
add_img_size_d <= add_img_size;
if(img_completed = '1' or enable = '0' or abort_fire = '1') then
fire_enable <= '0';
elsif(start_img_dd = '1' and fire_enable = '0') then
fire_enable <= '1';
end if;
if(start_img = '1' and fire_enable = '0') then
img_size <= X"00" & ch_ctrl_vector_out(23 downto 8);
elsif(add_img_size = '1' and add_img_size_d = '0') then
img_size <= std_logic_vector(unsigned(img_size)+unsigned(ch_ctrl_vector_out(23 downto 8)));
end if;
if (start_img = '1' and (fire_enable = '0' or zero_gap_mode = '1')) then
pixel_cnt <= (others => '0');
elsif(fire_enable = '1' and new_pixel = '1') then
pixel_cnt <= std_logic_vector(unsigned(pixel_cnt)+1);
end if;
if(init = '1' or enable = '0' or new_pixel = '1') then
start_image_flag <= '0';
elsif(start_img = '1') then
start_image_flag <= '1';
end if;
end if;
end process pGEN_IMAGE;
start_of_image <= start_image_flag and fire_req;
start_img <= start_img_req and not start_img_req_d;
img_completed <= '1' when fire_enable = '1' and unsigned(pixel_cnt) = unsigned(img_size) else '0';
-----------------------------------------------------------------------------
-- Fractional Divider
-----------------------------------------------------------------------------
iFracDiv : entity work.simple_frac_div_4
port map (
clk => clk,
enable => frac_div_en,
dir => dp_dir_i,
upd_max_pos => upd_max_pos,
upd_min_pos => upd_min_pos,
abs_pos_max => abs_pos_max,
abs_pos_min => abs_pos_min,
offset => (others => '0'),
ratio => div_ratio_i,
abs_pos => abs_position,
enc_pulse => enc_pulse,
fire => div_pulse_i,
fire_cnt => open);
div_pulse <= div_pulse_i when spitting_enable = '0' else spit_pulse;
-- In case upd_min_pos/upd_max_pos are asserted as a consequence of init, you
-- need to guarantee a sufficient delay to make sure abs_pos get reset before
-- updating min/max pos
p_pulse_div_switch : process(clk)
begin
if(clk = '1' and clk'event) then
rst_jitter <= ch_ctrl_vector_out(5);
upd_max_pos <= upd_max_pos_i or init_v(0) or dir_change or (rst_jitter and not dp_dir_i);
upd_min_pos <= upd_min_pos_i or init_v(0) or dir_change or (rst_jitter and dp_dir_i);
frac_div_en <= frac_div_en_i and enable and not init and not ((start_img and not prevent_div_restart and not bypass_ch_ctrl) or dir_change);
end if;
end process p_pulse_div_switch;
-- output to the monitoring point/event-logger
raw_fire_req <= div_pulse;
-----------------------------------------------------------------------------
-- W&H Div-Ratio Correction for Flexo/CI cylinders
-----------------------------------------------------------------------------
gPP_CORR_GEN: if PIXEL_PITCH_CORR_EN = true generate
add_ppc_regs <= '1';
pDIV_RATIO_CORR : process(clk)
begin
if(clk = '1' and clk'event) then
-- latch the absolute-position to prevent excessive degradation of timing
abs_pos_d <= abs_position;
if(init_wh = '1' or wh_img_end = '1') then
wh_img_pixel_cnt <= (others => '0');
elsif(fire_enable = '1' and div_pulse = '1') then
wh_img_pixel_cnt <= std_logic_vector(unsigned(wh_img_pixel_cnt)+1);
end if;
loc_pd_d <= loc_pd;
wh_apply_corr_en_d <= wh_apply_corr_en;
init_wh <= init or (not enable) or (not wh_apply_corr_en);
if(init_wh = '1') then
div_ratio_corr <= (others => '0');
elsif(wh_corr_ready = '1' and wh_skip_corr = '0') then
div_ratio_corr <= std_logic_vector(signed(div_ratio_corr)+signed(div_ratio_corr_new));
end if;
div_ratio_i <= std_logic_vector(signed(div_ratio)+signed(div_ratio_corr));
wh_img_2nd_half_d <= wh_img_2nd_half;
if(init_wh = '1' or wh_skip_corr = '1') then
first_img_started <= '0';
elsif(wh_img_2nd_half = '1' and wh_img_2nd_half_d = '0') then
first_img_started <= '1';
end if;
if(init_wh = '1' or wh_skip_corr = '1') then
wh_error_meas_started <= '0';
elsif(wh_meas_event = '1' and first_img_started = '1') then
wh_error_meas_started <= not wh_error_meas_started;
end if;
if(wh_meas_event = '1' and wh_error_meas_started = '0') then
start_pos <= abs_pos_d;
end if;
if((loc_pd_d and wh_img_end) = '1' or wh_skip_corr = '1') then
basic_pos_error <= (others => '0');
elsif(wh_meas_event = '1' and wh_error_meas_started = '1') then
if(loc_pd_d = '1') then
basic_pos_error <= std_logic_vector(resize(signed(abs_pos_d)-signed(start_pos), basic_pos_error'length));
else
basic_pos_error <= std_logic_vector(resize(signed(start_pos)-signed(abs_pos_d), basic_pos_error'length));
end if;
end if;
if(wh_error_meas_started = '1' and (loc_pd_d or wh_img_end) = '1') then
wh_error_meas_avail <= '1';
else
wh_error_meas_avail <= '0';
end if;
wh_corr_ready_v <= wh_corr_ready_v(wh_corr_ready_v'left-1 downto 0) & wh_error_meas_avail;
pos_error <= std_logic_vector(signed(basic_pos_error_sat & 24x"0") - signed(div_ratio));
if(init_wh = '1' or wh_skip_corr = '1') then
wh_pos_err_old <= (others => '0');
elsif(wh_corr_ready_v(0) = '1') then
wh_pos_err_old <= wh_pos_err;
end if;
wh_loop_err_delta <= std_logic_vector(signed(wh_delta_err)*signed(wh_loop_filt_delta));
wh_loop_err_tot <= std_logic_vector(signed(wh_tot_err)*signed(wh_loop_filt_tot));
wh_loop_err <= std_logic_vector(signed(wh_loop_err_delta)+signed(wh_loop_err_tot));
if(wh_corr_ready_v(2) = '1') then
div_ratio_corr_ext <= std_logic_vector(signed(wh_loop_err(wh_loop_err'left-8 downto 8))*signed(wh_pos_err_2_corr));
end if;
-- Compute the absolute value of the position-error. Use a simple 1's
-- complement if you need to do sign inversion
if(wh_pos_err(wh_pos_err'left) = '1') then
wh_pos_err_abs <= not wh_pos_err;
else
wh_pos_err_abs <= wh_pos_err;
end if;
if(init_wh = '1') then
wh_pos_err_curr <= (others => '0');
elsif(wh_corr_ready_v(0) = '1') then
wh_pos_err_curr <= wh_pos_err;
end if;
if(wh_corr_ready_v(1) = '1' and unsigned(wh_pos_err_abs) > unsigned(wh_skip_corr_thres & X"00") and first_img_started = '1') then
wh_skip_corr <= '1';
elsif(loc_pd = '1') then
wh_skip_corr <= '0';
end if;
if(init_wh = '1') then
wh_pos_err_max <= (others => '0');
elsif(wh_corr_ready = '1' and signed(wh_pos_err) > signed(wh_pos_err_max)) then
wh_pos_err_max <= wh_pos_err;
end if;
if(init_wh = '1') then
wh_pos_err_min <= (others => '0');
elsif(wh_corr_ready = '1' and signed(wh_pos_err) < signed(wh_pos_err_min)) then
wh_pos_err_min <= wh_pos_err;
end if;
if(init_wh = '1') then
wh_rotat_cnt <= (others => '0');
elsif(wh_corr_ready = '1') then
wh_rotat_cnt <= std_logic_vector(unsigned(wh_rotat_cnt)+1);
end if;
end if;
end process pDIV_RATIO_CORR;
wh_img_end <= '1' when unsigned(wh_img_pixel_cnt) = unsigned(wh_image_pixel_len) else '0';
wh_img_2nd_half <= '1' when unsigned(wh_img_pixel_cnt) >= unsigned(wh_image_pixel_len(wh_image_pixel_len'left downto 1)) else '0';
wh_corr_start <= wh_apply_corr_en and not wh_apply_corr_en_d;
wh_meas_event <= loc_pd_d xor wh_img_end;
div_ratio_corr_new <= std_logic_vector(resize(signed(div_ratio_corr_ext(div_ratio_corr_ext'left downto 16)),div_ratio'length));
wh_corr_ready <= wh_corr_ready_v(wh_corr_ready_v'left);
-- saturate the basic position error when exceeding the size of a 24-bits
-- signed number
bpe_top <= basic_pos_error(31 downto 24);
basic_pos_error_sat <= basic_pos_error(23 downto 0) when (signed(bpe_top) = 0 or signed(bpe_top) = -1) else X"7FFFFF" when signed(bpe_top) > 0 else X"800000";
-- No need to use 24 bits mantissa for pos_error, 8 bits are plenty
wh_pos_err <= pos_error(pos_error'left downto 16);
wh_tot_err <= wh_pos_err;
wh_delta_err <= std_logic_vector(signed(wh_pos_err)-signed(wh_pos_err_old));
end generate gPP_CORR_GEN;
gNOT_PP_CORR_GEN: if PIXEL_PITCH_CORR_EN = false generate
add_ppc_regs <= '0';
--
div_ratio_i <= div_ratio;
div_ratio_corr <= (others => '0');
wh_corr_start <= '0';
wh_rotat_cnt <= (others => '0');
wh_pos_err_curr <= (others => '0');
wh_pos_err_min <= (others => '0');
wh_pos_err_max <= (others => '0');
end generate gNOT_PP_CORR_GEN;
-----------------------------------------------------------------------------
-- Spitting logic
-----------------------------------------------------------------------------
gSPIT_LOGIC: if SPITTING_EN generate
pSPITTING_LOGIC : process(clk)
begin
if(clk = '1' and clk'event) then
spitting_enable <= ch_ctrl_vector_out(6);
if(seq_bus_valid = '1') then
spit_nco_inc <= seq_bus_data;
end if;
if(spitting_enable = '0') then
spit_nco <= (others => '0');
else
spit_nco <= std_logic_vector(unsigned(spit_nco)+unsigned(spit_nco_inc));
end if;
spit_nco_msb <= spit_nco(spit_nco'left);
spit_pulse <= spit_nco(spit_nco'left) and not spit_nco_msb;
end if;
end process pSPITTING_LOGIC;
else generate
spitting_enable <= '0';
spit_pulse <= '0';
end generate gSPIT_LOGIC;
-----------------------------------------------------------------------------
-- Pulse Gating
-----------------------------------------------------------------------------
gated_pulse <= div_pulse and ch_mask_i and enable_out;
-----------------------------------------------------------------------------
-- Delay Equalization
-----------------------------------------------------------------------------
-- compendate for variation in the channel delay when daisy-chaining multiple
-- EMBs/HMBs:
gPULSE_DELAY_EQUAL: if PULSE_DELAY_EQUAL_EN = true generate
add_delay_eq_reg <= '1';
iDE: entity work.queue_and_delay
generic map (
DELAY_WIDTH => 16,
USE_EXT_TIME => false,
QUEUE_SIZE => 256)
port map (
rstN => reset_n,
clk => clk,
init => init_de,
cnt_dir => '0',
delay => ch_delay_i,
ext_time => (others => '0'),
wave_in => gated_pulse,
wave_out => retimed_pulse,
ovf_error => de_queue_error);
init_de <= (not enable) or bypass_delay_equal;
end generate gPULSE_DELAY_EQUAL;
gNOT_PULSE_DELAY_EQUAL: if PULSE_DELAY_EQUAL_EN = false generate
add_delay_eq_reg <= '0';
retimed_pulse <= gated_pulse;
de_queue_error <= '0';
end generate gNOT_PULSE_DELAY_EQUAL;
p_delay_equal_switch : process(clk)
begin
if(clk = '1' and clk'event) then
if(bypass_delay_equal = '1') then
selected_pulse <= gated_pulse;
else
selected_pulse <= retimed_pulse;
end if;
selected_pulse_d <= selected_pulse;
end if;
end process p_delay_equal_switch;
-- perform edge detection to remove the pulse-width inserted either by
-- ch-ctrl sequencer or delay-equalization
fire_req <= selected_pulse and not selected_pulse_d;
-----------------------------------------------------------------------------
-- Sub-Pixel Phase generation
-----------------------------------------------------------------------------
-- Split fire-request stream into sub-pixel offset
pSUBPIXEL_GEN : process(clk)
variable first_pixel : std_logic;
begin
if(clk = '1' and clk'event) then
if(fire_enable = '0' or new_pixel = '1') then
subpix_phase_cnt <= (others => '0');
elsif(fire_req = '1') then
subpix_phase_cnt <= std_logic_vector(unsigned(subpix_phase_cnt)+1);
end if;
if(fire_enable = '0' or new_pixel = '1') then
subpix_phase <= (0 => '1', others => '0');
elsif(fire_req = '1') then
subpix_phase <= subpix_phase(30 downto 0) & subpix_phase(31);
end if;
if(fire_req = '1') then
fire_req_vec <= subpix_phase;
else
fire_req_vec <= (others => '0');
end if;
if(fire_req = '1' and start_image_flag = '1') then
start_of_image_vec <= subpix_phase;
else
start_of_image_vec <= (others => '0');
end if;
end if;
end process pSUBPIXEL_GEN;
-- new pixel flag is asserted on the last phase of the pixel.
new_pixel <= '1' when subpix_phase_cnt = subpixel_phase_num else '0';
--fire_req_vec <= (0 => fire_req, others => '0');
--start_of_image_vec <= (0 => start_of_image, others => '0');
-----------------------------------------------------------------------------
-- Time-of-Flight Compensation
-----------------------------------------------------------------------------
gTOF_COMP_GEN: if TOF_COMP_EN = true and PULSE_DELAY_EQUAL_EN = true generate
add_tof_comp_regs <= '1';
pTOF_COMP : process(clk)
begin
if(clk = '1' and clk'event) then
-- if the encoder speed is negative, do a 1's complement (no need to
-- waste resources with the 2's complement).
-- Note: you don't really care to know whether the encoder speed
-- matches the direction used for generating fire-request, because
-- fire-request are not generated in the wrong direction
if(enc_vel(enc_vel'left) = '1') then
enc_vel_i <= not enc_vel;
else
enc_vel_i <= enc_vel;
end if;
if(tof_saturation = '1') then
tof_lut_addr <= (others => '1');
else
tof_lut_addr <= norm_enc_vel(norm_enc_vel'left-19 downto (norm_enc_vel'left-19-tof_lut_addr'left));
end if;
if(init or (not enable) or (not tof_comp_enable)) then
tof_sat_flag <= '0';
elsif(tof_saturation = '1') then
tof_sat_flag <= '1';
end if;
ch_delay_i <= std_logic_vector(unsigned(ch_delay)+unsigned(tof_lut_comp));
if(tof_comp_enable = '1') then
tof_lut_comp <= tof_lut_comp_i;
else
tof_lut_comp <= (others => '0');
end if;
end if;
end process pTOF_COMP;
norm_enc_vel <= std_logic_vector(unsigned(enc_vel_i)*unsigned(enc_speed_norm_coeff));
tof_saturation <= '1' when unsigned(norm_enc_vel(norm_enc_vel'left downto norm_enc_vel'left-18)) /= 0 else '0';
--iTOF_COMP_LUT : entity work.dpram_sclk
iTOF_COMP_LUT : dpram_sclk
generic map (
DATA_WIDTH => TOF_COMP_LUT_WIDTH,
ADDR_WIDTH => log2(TOF_COMP_LUT_DEPTH))
port map (
clk => clk,
addr_a => tof_lut_wr_addr,
we_a => tof_lut_wr_en,
data_a => tof_lut_wr_data,
q_a => tof_lut_wr_q,
addr_b => tof_lut_addr,
we_b => '0',
data_b => gnd_16,
q_b => tof_lut_comp_i);
gnd_16 <= (others => '0');
end generate gTOF_COMP_GEN;
gTOF_COMP_NOGEN: if TOF_COMP_EN = false or PULSE_DELAY_EQUAL_EN = false generate
add_tof_comp_regs <= '0';
ch_delay_i <= ch_delay;
tof_sat_flag <= '0';
tof_lut_wr_q <= (others => '0');
tof_lut_comp <= (others => '0');
end generate gTOF_COMP_NOGEN;
-----------------------------------------------------------------------------
-- Local Diagnostic registers
-----------------------------------------------------------------------------
gDIAG_CNT: if DIAG_COUNTERS = true generate
add_diag_reg <= '1';
pEdgeDetect_Cnt : process(clk)
begin
if(clk = '1' and clk'event) then
loc_pd_dd <= loc_pd;
if(init = '1' or enable = '0' or rst_diag_regs = '1') then
pd_cnt <= (others => '0');
elsif(loc_pd = '1' and loc_pd_dd = '0') then
pd_cnt <= std_logic_vector(unsigned(pd_cnt)+1);
end if;
if(init = '1' or enable = '0' or rst_diag_regs = '1') then
fire_req_cnt <= (others => '0');
elsif(new_pixel = '1') then
fire_req_cnt <= std_logic_vector(unsigned(fire_req_cnt)+1);
end if;
end if;
end process pEdgeDetect_Cnt;
else generate
add_diag_reg <= '0';
end generate gDIAG_CNT;
gNOT_DIAG_CNT: if DIAG_COUNTERS = false generate
pd_cnt <= (others => '0');
fire_req_cnt <= (others => '0');
end generate gNOT_DIAG_CNT;
-----------------------------------------------------------------------------
-- C&S registers (Avalon-MM I/F)
-----------------------------------------------------------------------------
-- Memory partitioning:
-- Relative addresses between 0 and 511 => C&S regs
-- Relative addresses between 512 and 1023 => Sequencer RAM
avs_write_i <= '1' when avs_write = '1' and avs_address(10 downto 9) = "00" else '0';
ch_ctrl_write <= '1' when avs_write = '1' and avs_address(10 downto 9) = "01" else '0';
ch_ctrl_csr_write <= '1' when avs_write = '1' and avs_address(10 downto 5) = "000001" else '0';
tof_lut_wr_en <= '1' when avs_write = '1' and avs_address(10 downto 9) = "10" else '0';
avs_read_i <= '1' when avs_read = '1' and avs_address(10 downto 9) = "00" else '0';
ch_ctrl_read <= '1' when avs_read = '1' and avs_address(10 downto 9) = "01" else '0';
ch_ctrl_csr_read <= '1' when avs_read = '1' and avs_address(10 downto 5) = "000001" else '0';
avs_addr <= avs_address(4 downto 0);
ch_ctrl_address <= avs_address(ch_ctrl_address'range);
ch_ctrl_csr_addr <= avs_address(ch_ctrl_csr_addr'range);
tof_lut_wr_addr <= avs_address(tof_lut_wr_addr'range);
ch_ctrl_writedata <= avs_writedata;
ch_ctrl_csr_writedata <= avs_writedata;
tof_lut_wr_data <= avs_writedata(tof_lut_wr_data'range);
pINIT : process(clk)
begin
if(clk = '1' and clk'event) then
if(init = '1') then
init_v <= (others => '1');
else
init_v <= '0' & init_v(init_v'high downto 1);
end if;
end if;
end process pINIT;
enable <= enable_i and not init_v(4);
enc_speed_meas_w <= enc_speed_meas_w_i;
pulse_generator_4_csr_regs_i : entity work.pulse_generator_4_csr_regs
generic map (
ADDR_DECODE_WIDTH => 5
)
port map (
-- Clock and reset
clk => clk,
rst_n => reset_n,
-- auto-generated
-- Internal signal ports
pulse_gen_control_w_enable => enable_i,
pulse_gen_control_w_bypass_channel_controller => bypass_ch_ctrl,
pulse_gen_control_w_bypass_delay_equalizer => bypass_delay_equal,
pulse_gen_control_w_sw_control_dp_dir => sw_ctrl_dp_dir,
pulse_gen_control_w_wh_apply_corr_en => wh_apply_corr_en,
pulse_gen_control_w_pp_apply_corr_en => open,
pulse_gen_control_w_tof_comp_enable => tof_comp_enable,
pulse_gen_control_w_enable_output => enable_out,
pulse_gen_control_w_trigger_abort_fire => abort_fire,
pulse_gen_control_w_reset_diag_regs => rst_diag_regs,
pd_offset_dir_0 => ch_offset_dir0,
pd_offset_dir_1 => ch_offset_dir1,
channel_delay => ch_delay,
channel_controller_control_w_sequencer_start_address => ch_ctrl_start_addr,
fractional_divider_control_enable => upd_max_pos_i,
fractional_divider_control_udp_max_pos => upd_max_pos_i,
fractional_divider_control_udp_min_pos => upd_min_pos_i,
divider_ratio_int => div_ratio(33 downto 24),
divider_ratio_fraction => div_ratio(23 downto 0),
subpixel_phase_num => subpixel_phase_num,
enc_speed_meas_window => enc_speed_meas_w_i,
tof_compensation_w_enc_speed_norm => enc_speed_norm_coeff,
pixel_pitch_corr_stripe_num => wh_image_pixel_len,
pixel_pitch_pos_err_2_corr => wh_pos_err_2_corr,
pixel_pitch_skip_corr_thres => wh_skip_corr_thres,
pixel_pitch_loop_filter_corr_delta_error_coeff => wh_loop_filt_delta,
pixel_pitch_loop_filter_corr_tot_error_coeff => wh_loop_filt_tot,
channel_controller_seq => open,
ToF_Comp_LUT => open,
pulse_gen_control_w_clr_pd_queue => clr_pd_queue,
channel_controller_control_w_start_seq_trigger => ch_ctrl_start_req_ii,
pulse_gen_control_r_pd_queue_error_flag => pd_queue_error,
pulse_gen_control_r_delay_equalizer_error_flag => de_queue_error,
pulse_gen_control_r_ch_mask_status => ch_mask_i,
pulse_gen_control_r_fire_enable_status => fire_enable,
pulse_gen_control_r_dual_phase_directionality_select_status => dp_dir,
pulse_gen_control_r_tof_sat_flag => tof_sat_flag,
channel_controller_control_r_busy => ch_ctrl_busy,
abs_position_max => abs_pos_max,
abs_position_min => abs_pos_min,
abs_position => abs_position,
pd_counter => pd_cnt,
fire_req_counter => fire_req_cnt,
enc_speed => enc_vel,
tof_compensation_r_tof_lut_comp => tof_lut_comp,
pixel_pitch_pos_err_curr => wh_pos_err_curr,
pixel_pitch_pos_err_max => wh_pos_err_max,
pixel_pitch_pos_err_min => wh_pos_err_min,
pixel_pitch_div_ratio_corr => div_ratio_corr(31 downto 0),
pixel_pitch_corr_cnt => wh_rotat_cnt,
-- end auto-generated
-- Slave bus port
avs_address => avs_addr(4 downto 0),
avs_write => avs_write_i,
avs_writedata => avs_writedata,
avs_read => avs_read_i,
avs_readdata => avs_readdata_i
);
avs_readdata <= avs_readdata_i when avs_address(10 downto 5) = "000000" else
ch_ctrl_csr_readdata when avs_address(10 downto 5) = "000001" else
ch_ctrl_readdata when avs_address(10 downto 5) = "01----" else
X"0000" & tof_lut_wr_q when avs_address(10 downto 5) = "10----" else
X"BAD1BAD0";
end architecture rtl;

View file

@ -0,0 +1,90 @@
-------------------------------------------------------------------------------
-- Title : PULSE_GENERATOR_4 Block
-- Project : UNKNOWN
-------------------------------------------------------------------------------
-- File : pulse_generator_4_csr_decode_auto.vhd
-- Author : auto-generated
-- Company : Global Inkjet Systems
-- Created : 2021-04-15
-- Platform :
-- Standard : VHDL 2008
-------------------------------------------------------------------------------
-- Description:
-- Generate Fire-Requests, based on the absolute position and PD inputs - W&H specific variant
-------------------------------------------------------------------------------
-- Copyright (c) 2017, 2018 Global Inkjet Systems
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
----------------------- AUTO-GENERATED FILE. DO NOT EDIT ----------------------
-------------------------------------------------------------------------------
-- altera vhdl_input_version vhdl_2008
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity pulse_generator_4_csr_decode is
generic (
ADDR_DECODE_HI_BIT : natural range 1 to 32 := 10;
ADDR_DECODE_LO_BIT : natural range 1 to 32 := 5
);
port (
-- auto-generated
-- Decoded read/write strobes and returned read data
local_write : out std_logic;
local_read : out std_logic;
local_readdata : in std_logic_vector(31 downto 0);
generic_sequencer_17_channel_write: out std_logic;
generic_sequencer_17_channel_read: out std_logic;
generic_sequencer_17_channel_readdata: in std_logic_vector(31 downto 0);
-- end auto-generated
-- Avalon CSR slave interface
avs_address : in std_logic_vector(ADDR_DECODE_HI_BIT downto ADDR_DECODE_LO_BIT);
avs_write : in std_logic;
avs_read : in std_logic;
avs_readdata : out std_logic_vector(31 downto 0)
);
end entity;
architecture rtl of pulse_generator_4_csr_decode is
begin
-- auto-generated
avs_readdata <= local_readdata or generic_sequencer_17_channel_readdata;
-- end auto-generated
process(all) is
begin
-- auto-generated
local_write <= '0';
local_read <= '0';
generic_sequencer_17_channel_write <= '0';
generic_sequencer_17_channel_read <= '0';
case avs_address is
when std_logic_vector(to_unsigned(0, 6)) =>
local_write <= avs_write;
local_read <= avs_read;
when std_logic_vector(to_unsigned(1, 6)) =>
generic_sequencer_17_channel_write <= avs_write;
generic_sequencer_17_channel_read <= avs_read;
when others =>
null;
end case;
-- end auto-generated
end process;
end rtl;

View file

@ -0,0 +1,580 @@
-------------------------------------------------------------------------------
-- Title : PULSE_GENERATOR_4 Block
-- Project : UNKNOWN
-------------------------------------------------------------------------------
-- File : pulse_generator_4_csr_regs_auto.vhd
-- Author : auto-generated
-- Company : Global Inkjet Systems
-- Created : 2021-04-15
-- Platform :
-- Standard : VHDL 2008
-------------------------------------------------------------------------------
-- Description:
-- Generate Fire-Requests, based on the absolute position and PD inputs - W&H specific variant
-------------------------------------------------------------------------------
-- Copyright (c) 2017, 2018 Global Inkjet Systems
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
----------------------- AUTO-GENERATED FILE. DO NOT EDIT ----------------------
-------------------------------------------------------------------------------
-- altera vhdl_input_version vhdl_2008
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use work.pulse_generator_4_pkg.all;
entity pulse_generator_4_csr_regs is
generic (
ADDR_DECODE_WIDTH : natural range 1 to 32 := 8
);
port (
-- Clock and reset
clk : in std_logic;
rst_n : in std_logic;
-- auto-generated
-- Internal signal ports
pulse_gen_control_w_enable : out std_logic;
pulse_gen_control_w_bypass_channel_controller : out std_logic;
pulse_gen_control_w_bypass_delay_equalizer : out std_logic;
pulse_gen_control_w_sw_control_dp_dir : out std_logic;
pulse_gen_control_w_wh_apply_corr_en : out std_logic;
pulse_gen_control_w_pp_apply_corr_en : out std_logic;
pulse_gen_control_w_tof_comp_enable : out std_logic;
pulse_gen_control_w_enable_output : out std_logic;
pulse_gen_control_w_trigger_abort_fire : out std_logic;
pulse_gen_control_w_reset_diag_regs : out std_logic;
pd_offset_dir_0 : out std_logic_vector (31 downto 0);
pd_offset_dir_1 : out std_logic_vector (31 downto 0);
channel_delay : out std_logic_vector (15 downto 0);
channel_controller_control_w_sequencer_start_address : out std_logic_vector (7 downto 0);
fractional_divider_control_enable : out std_logic;
fractional_divider_control_udp_max_pos : out std_logic;
fractional_divider_control_udp_min_pos : out std_logic;
divider_ratio_int : out std_logic_vector (9 downto 0);
divider_ratio_fraction : out std_logic_vector (23 downto 0);
subpixel_phase_num : out std_logic_vector (5 downto 0);
enc_speed_meas_window : out std_logic_vector (19 downto 0);
tof_compensation_w_enc_speed_norm : out std_logic_vector (15 downto 0);
pixel_pitch_corr_stripe_num : out std_logic_vector (23 downto 0);
pixel_pitch_pos_err_2_corr : out std_logic_vector (31 downto 0);
pixel_pitch_skip_corr_thres : out std_logic_vector (23 downto 0);
pixel_pitch_loop_filter_corr_delta_error_coeff : out std_logic_vector (15 downto 0);
pixel_pitch_loop_filter_corr_tot_error_coeff : out std_logic_vector (15 downto 0);
channel_controller_seq : out std_logic_vector (31 downto 0);
ToF_Comp_LUT : out std_logic_vector (15 downto 0);
pulse_gen_control_w_clr_pd_queue : out std_logic;
channel_controller_control_w_start_seq_trigger : out std_logic;
pulse_gen_control_r_pd_queue_error_flag : in std_logic;
pulse_gen_control_r_delay_equalizer_error_flag : in std_logic;
pulse_gen_control_r_ch_mask_status : in std_logic;
pulse_gen_control_r_fire_enable_status : in std_logic;
pulse_gen_control_r_dual_phase_directionality_select_status : in std_logic;
pulse_gen_control_r_tof_sat_flag : in std_logic;
channel_controller_control_r_busy : in std_logic;
abs_position_max : in std_logic_vector (31 downto 0);
abs_position_min : in std_logic_vector (31 downto 0);
abs_position : in std_logic_vector (31 downto 0);
pd_counter : in std_logic_vector (15 downto 0);
fire_req_counter : in std_logic_vector (23 downto 0);
enc_speed : in std_logic_vector (19 downto 0);
tof_compensation_r_tof_lut_comp : in std_logic_vector (15 downto 0);
pixel_pitch_pos_err_curr : in std_logic_vector (31 downto 0);
pixel_pitch_pos_err_max : in std_logic_vector (31 downto 0);
pixel_pitch_pos_err_min : in std_logic_vector (31 downto 0);
pixel_pitch_div_ratio_corr : in std_logic_vector (31 downto 0);
pixel_pitch_corr_cnt : in std_logic_vector (15 downto 0);
-- end auto-generated
-- Slave bus port
avs_address : in std_logic_vector(ADDR_DECODE_WIDTH-1 downto 0);
avs_write : in std_logic;
avs_writedata : in std_logic_vector(31 downto 0);
avs_read : in std_logic;
avs_readdata : out std_logic_vector(31 downto 0)
);
end entity;
architecture rtl of pulse_generator_4_csr_regs is
signal next_avs_readdata : std_logic_vector(31 downto 0);
signal avs_readdata_reg : std_logic_vector(31 downto 0);
-- auto-generated
signal pulse_gen_control_w_enable_reg : std_logic;
signal pulse_gen_control_w_bypass_channel_controller_reg : std_logic;
signal pulse_gen_control_w_bypass_delay_equalizer_reg : std_logic;
signal pulse_gen_control_w_sw_control_dp_dir_reg : std_logic;
signal pulse_gen_control_w_wh_apply_corr_en_reg : std_logic;
signal pulse_gen_control_w_pp_apply_corr_en_reg : std_logic;
signal pulse_gen_control_w_tof_comp_enable_reg : std_logic;
signal pulse_gen_control_w_enable_output_reg : std_logic;
signal pulse_gen_control_w_trigger_abort_fire_reg : std_logic;
signal pulse_gen_control_w_reset_diag_regs_reg : std_logic;
signal pd_offset_dir_0_reg : std_logic_vector (31 downto 0);
signal pd_offset_dir_1_reg : std_logic_vector (31 downto 0);
signal channel_delay_reg : std_logic_vector (15 downto 0);
signal channel_controller_control_w_sequencer_start_address_reg : std_logic_vector (7 downto 0);
signal fractional_divider_control_enable_reg : std_logic;
signal fractional_divider_control_udp_max_pos_reg : std_logic;
signal fractional_divider_control_udp_min_pos_reg : std_logic;
signal divider_ratio_int_reg : std_logic_vector (9 downto 0);
signal divider_ratio_fraction_reg : std_logic_vector (23 downto 0);
signal subpixel_phase_num_reg : std_logic_vector (5 downto 0);
signal enc_speed_meas_window_reg : std_logic_vector (19 downto 0);
signal tof_compensation_w_enc_speed_norm_reg : std_logic_vector (15 downto 0);
signal pixel_pitch_corr_stripe_num_reg : std_logic_vector (23 downto 0);
signal pixel_pitch_pos_err_2_corr_reg : std_logic_vector (31 downto 0);
signal pixel_pitch_skip_corr_thres_reg : std_logic_vector (23 downto 0);
signal pixel_pitch_loop_filter_corr_delta_error_coeff_reg : std_logic_vector (15 downto 0);
signal pixel_pitch_loop_filter_corr_tot_error_coeff_reg : std_logic_vector (15 downto 0);
signal channel_controller_seq_reg : std_logic_vector (31 downto 0);
signal ToF_Comp_LUT_reg : std_logic_vector (15 downto 0);
signal pulse_gen_control_w_clr_pd_queue_reg : std_logic;
signal channel_controller_control_w_start_seq_trigger_reg : std_logic;
signal next_pulse_gen_control_w_enable : std_logic;
signal next_pulse_gen_control_w_bypass_channel_controller : std_logic;
signal next_pulse_gen_control_w_bypass_delay_equalizer : std_logic;
signal next_pulse_gen_control_w_sw_control_dp_dir : std_logic;
signal next_pulse_gen_control_w_wh_apply_corr_en : std_logic;
signal next_pulse_gen_control_w_pp_apply_corr_en : std_logic;
signal next_pulse_gen_control_w_tof_comp_enable : std_logic;
signal next_pulse_gen_control_w_enable_output : std_logic;
signal next_pulse_gen_control_w_trigger_abort_fire : std_logic;
signal next_pulse_gen_control_w_reset_diag_regs : std_logic;
signal next_pd_offset_dir_0 : std_logic_vector (31 downto 0);
signal next_pd_offset_dir_1 : std_logic_vector (31 downto 0);
signal next_channel_delay : std_logic_vector (15 downto 0);
signal next_channel_controller_control_w_sequencer_start_address : std_logic_vector (7 downto 0);
signal next_fractional_divider_control_enable : std_logic;
signal next_fractional_divider_control_udp_max_pos : std_logic;
signal next_fractional_divider_control_udp_min_pos : std_logic;
signal next_divider_ratio_int : std_logic_vector (9 downto 0);
signal next_divider_ratio_fraction : std_logic_vector (23 downto 0);
signal next_subpixel_phase_num : std_logic_vector (5 downto 0);
signal next_enc_speed_meas_window : std_logic_vector (19 downto 0);
signal next_tof_compensation_w_enc_speed_norm : std_logic_vector (15 downto 0);
signal next_pixel_pitch_corr_stripe_num : std_logic_vector (23 downto 0);
signal next_pixel_pitch_pos_err_2_corr : std_logic_vector (31 downto 0);
signal next_pixel_pitch_skip_corr_thres : std_logic_vector (23 downto 0);
signal next_pixel_pitch_loop_filter_corr_delta_error_coeff : std_logic_vector (15 downto 0);
signal next_pixel_pitch_loop_filter_corr_tot_error_coeff : std_logic_vector (15 downto 0);
signal next_channel_controller_seq : std_logic_vector (31 downto 0);
signal next_ToF_Comp_LUT : std_logic_vector (15 downto 0);
signal next_pulse_gen_control_w_clr_pd_queue : std_logic;
signal next_channel_controller_control_w_start_seq_trigger : std_logic;
-- end auto-generated
begin
-- Export registers interface read data to output port
avs_readdata <= avs_readdata_reg;
-- auto-generated
-- Export internal write registers to output ports
pulse_gen_control_w_enable <= pulse_gen_control_w_enable_reg;
pulse_gen_control_w_bypass_channel_controller <= pulse_gen_control_w_bypass_channel_controller_reg;
pulse_gen_control_w_bypass_delay_equalizer <= pulse_gen_control_w_bypass_delay_equalizer_reg;
pulse_gen_control_w_sw_control_dp_dir <= pulse_gen_control_w_sw_control_dp_dir_reg;
pulse_gen_control_w_wh_apply_corr_en <= pulse_gen_control_w_wh_apply_corr_en_reg;
pulse_gen_control_w_pp_apply_corr_en <= pulse_gen_control_w_pp_apply_corr_en_reg;
pulse_gen_control_w_tof_comp_enable <= pulse_gen_control_w_tof_comp_enable_reg;
pulse_gen_control_w_enable_output <= pulse_gen_control_w_enable_output_reg;
pulse_gen_control_w_trigger_abort_fire <= pulse_gen_control_w_trigger_abort_fire_reg;
pulse_gen_control_w_reset_diag_regs <= pulse_gen_control_w_reset_diag_regs_reg;
pd_offset_dir_0 <= pd_offset_dir_0_reg;
pd_offset_dir_1 <= pd_offset_dir_1_reg;
channel_delay <= channel_delay_reg;
channel_controller_control_w_sequencer_start_address <= channel_controller_control_w_sequencer_start_address_reg;
fractional_divider_control_enable <= fractional_divider_control_enable_reg;
fractional_divider_control_udp_max_pos <= fractional_divider_control_udp_max_pos_reg;
fractional_divider_control_udp_min_pos <= fractional_divider_control_udp_min_pos_reg;
divider_ratio_int <= divider_ratio_int_reg;
divider_ratio_fraction <= divider_ratio_fraction_reg;
subpixel_phase_num <= subpixel_phase_num_reg;
enc_speed_meas_window <= enc_speed_meas_window_reg;
tof_compensation_w_enc_speed_norm <= tof_compensation_w_enc_speed_norm_reg;
pixel_pitch_corr_stripe_num <= pixel_pitch_corr_stripe_num_reg;
pixel_pitch_pos_err_2_corr <= pixel_pitch_pos_err_2_corr_reg;
pixel_pitch_skip_corr_thres <= pixel_pitch_skip_corr_thres_reg;
pixel_pitch_loop_filter_corr_delta_error_coeff <= pixel_pitch_loop_filter_corr_delta_error_coeff_reg;
pixel_pitch_loop_filter_corr_tot_error_coeff <= pixel_pitch_loop_filter_corr_tot_error_coeff_reg;
channel_controller_seq <= channel_controller_seq_reg;
ToF_Comp_LUT <= ToF_Comp_LUT_reg;
pulse_gen_control_w_clr_pd_queue <= pulse_gen_control_w_clr_pd_queue_reg;
channel_controller_control_w_start_seq_trigger <= channel_controller_control_w_start_seq_trigger_reg;
-- Export AVS write bus to write pulse register ports
-- end auto-generated
-- Process to calculate next state, generate output read/write pulses
-- and write pulse register output
process (all)
begin
-- Default reads to 0. (Allows ORing of busses.)
next_avs_readdata <= (others => '0');
-- auto-generated
-- Default the internal write register next values to be current state
next_pulse_gen_control_w_enable <= pulse_gen_control_w_enable_reg;
next_pulse_gen_control_w_bypass_channel_controller <= pulse_gen_control_w_bypass_channel_controller_reg;
next_pulse_gen_control_w_bypass_delay_equalizer <= pulse_gen_control_w_bypass_delay_equalizer_reg;
next_pulse_gen_control_w_sw_control_dp_dir <= pulse_gen_control_w_sw_control_dp_dir_reg;
next_pulse_gen_control_w_wh_apply_corr_en <= pulse_gen_control_w_wh_apply_corr_en_reg;
next_pulse_gen_control_w_pp_apply_corr_en <= pulse_gen_control_w_pp_apply_corr_en_reg;
next_pulse_gen_control_w_tof_comp_enable <= pulse_gen_control_w_tof_comp_enable_reg;
next_pulse_gen_control_w_enable_output <= pulse_gen_control_w_enable_output_reg;
next_pulse_gen_control_w_trigger_abort_fire <= pulse_gen_control_w_trigger_abort_fire_reg;
next_pulse_gen_control_w_reset_diag_regs <= pulse_gen_control_w_reset_diag_regs_reg;
next_pd_offset_dir_0 <= pd_offset_dir_0_reg;
next_pd_offset_dir_1 <= pd_offset_dir_1_reg;
next_channel_delay <= channel_delay_reg;
next_channel_controller_control_w_sequencer_start_address <= channel_controller_control_w_sequencer_start_address_reg;
next_fractional_divider_control_enable <= fractional_divider_control_enable_reg;
next_fractional_divider_control_udp_max_pos <= fractional_divider_control_udp_max_pos_reg;
next_fractional_divider_control_udp_min_pos <= fractional_divider_control_udp_min_pos_reg;
next_divider_ratio_int <= divider_ratio_int_reg;
next_divider_ratio_fraction <= divider_ratio_fraction_reg;
next_subpixel_phase_num <= subpixel_phase_num_reg;
next_enc_speed_meas_window <= enc_speed_meas_window_reg;
next_tof_compensation_w_enc_speed_norm <= tof_compensation_w_enc_speed_norm_reg;
next_pixel_pitch_corr_stripe_num <= pixel_pitch_corr_stripe_num_reg;
next_pixel_pitch_pos_err_2_corr <= pixel_pitch_pos_err_2_corr_reg;
next_pixel_pitch_skip_corr_thres <= pixel_pitch_skip_corr_thres_reg;
next_pixel_pitch_loop_filter_corr_delta_error_coeff <= pixel_pitch_loop_filter_corr_delta_error_coeff_reg;
next_pixel_pitch_loop_filter_corr_tot_error_coeff <= pixel_pitch_loop_filter_corr_tot_error_coeff_reg;
next_channel_controller_seq <= channel_controller_seq_reg;
next_ToF_Comp_LUT <= ToF_Comp_LUT_reg;
-- Default the write-clear register next values to 0
next_pulse_gen_control_w_clr_pd_queue <= '0';
next_channel_controller_control_w_start_seq_trigger <= '0';
-- Default the read- and write-pulse register pulse outputs to 0
-- end auto-generated
-- Bus write active
if avs_write = '1' then
case avs_address is
-- auto-generated
-- Write (and write pulse) register case statements
when CSR_TOF_COMP_LUT_ADDR =>
next_ToF_Comp_LUT <= avs_writedata(15 downto 0);
when CSR_CHANNEL_CONTROLLER_CONTROL_W_ADDR =>
next_channel_controller_control_w_sequencer_start_address <= avs_writedata(15 downto 8);
next_channel_controller_control_w_start_seq_trigger <= avs_writedata(0);
when CSR_CHANNEL_CONTROLLER_SEQ_ADDR =>
next_channel_controller_seq <= avs_writedata(31 downto 0);
when CSR_CHANNEL_DELAY_ADDR =>
next_channel_delay <= avs_writedata(15 downto 0);
when CSR_DIVIDER_RATIO_FRACTION_ADDR =>
next_divider_ratio_fraction <= avs_writedata(23 downto 0);
when CSR_DIVIDER_RATIO_INT_ADDR =>
next_divider_ratio_int <= avs_writedata(9 downto 0);
when CSR_ENC_SPEED_MEAS_WINDOW_ADDR =>
next_enc_speed_meas_window <= avs_writedata(19 downto 0);
when CSR_FRACTIONAL_DIVIDER_CONTROL_ADDR =>
next_fractional_divider_control_enable <= avs_writedata(0);
next_fractional_divider_control_udp_max_pos <= avs_writedata(1);
next_fractional_divider_control_udp_min_pos <= avs_writedata(2);
when CSR_PD_OFFSET_DIR_0_ADDR =>
next_pd_offset_dir_0 <= avs_writedata(31 downto 0);
when CSR_PD_OFFSET_DIR_1_ADDR =>
next_pd_offset_dir_1 <= avs_writedata(31 downto 0);
when CSR_PIXEL_PITCH_CORR_STRIPE_NUM_ADDR =>
next_pixel_pitch_corr_stripe_num <= avs_writedata(23 downto 0);
when CSR_PIXEL_PITCH_LOOP_FILTER_CORR_ADDR =>
next_pixel_pitch_loop_filter_corr_delta_error_coeff <= avs_writedata(15 downto 0);
next_pixel_pitch_loop_filter_corr_tot_error_coeff <= avs_writedata(31 downto 16);
when CSR_PIXEL_PITCH_POS_ERR_2_CORR_ADDR =>
next_pixel_pitch_pos_err_2_corr <= avs_writedata(31 downto 0);
when CSR_PIXEL_PITCH_SKIP_CORR_THRES_ADDR =>
next_pixel_pitch_skip_corr_thres <= avs_writedata(23 downto 0);
when CSR_PULSE_GEN_CONTROL_W_ADDR =>
next_pulse_gen_control_w_bypass_channel_controller <= avs_writedata(1);
next_pulse_gen_control_w_bypass_delay_equalizer <= avs_writedata(3);
next_pulse_gen_control_w_clr_pd_queue <= avs_writedata(20);
next_pulse_gen_control_w_enable <= avs_writedata(0);
next_pulse_gen_control_w_enable_output <= avs_writedata(17);
next_pulse_gen_control_w_pp_apply_corr_en <= avs_writedata(12);
next_pulse_gen_control_w_reset_diag_regs <= avs_writedata(19);
next_pulse_gen_control_w_sw_control_dp_dir <= avs_writedata(4);
next_pulse_gen_control_w_tof_comp_enable <= avs_writedata(13);
next_pulse_gen_control_w_trigger_abort_fire <= avs_writedata(18);
next_pulse_gen_control_w_wh_apply_corr_en <= avs_writedata(11);
when CSR_SUBPIXEL_PHASE_NUM_ADDR =>
next_subpixel_phase_num <= avs_writedata(5 downto 0);
when CSR_TOF_COMPENSATION_W_ADDR =>
next_tof_compensation_w_enc_speed_norm <= avs_writedata(15 downto 0);
when others =>
null;
-- end auto-generated
end case;
end if;
-- Bus read active
if avs_read = '1' then
-- Default the next_avs_readdata to 0
next_avs_readdata <= x"00000000";
case avs_address(ADDR_DECODE_WIDTH-1 downto 0) is
-- auto-generated
-- Write and read (incl. constant) case statements
when CSR_TOF_COMP_LUT_ADDR =>
next_avs_readdata(15 downto 0) <= ToF_Comp_LUT_reg;
when CSR_ABS_POSITION_ADDR =>
next_avs_readdata(31 downto 0) <= abs_position;
when CSR_ABS_POSITION_MAX_ADDR =>
next_avs_readdata(31 downto 0) <= abs_position_max;
when CSR_ABS_POSITION_MIN_ADDR =>
next_avs_readdata(31 downto 0) <= abs_position_min;
when CSR_CHANNEL_CONTROLLER_CONTROL_R_ADDR =>
next_avs_readdata(1) <= channel_controller_control_r_busy;
when CSR_CHANNEL_CONTROLLER_CONTROL_W_ADDR =>
next_avs_readdata(15 downto 8) <= channel_controller_control_w_sequencer_start_address_reg;
when CSR_CHANNEL_CONTROLLER_SEQ_ADDR =>
next_avs_readdata(31 downto 0) <= channel_controller_seq_reg;
when CSR_CHANNEL_DELAY_ADDR =>
next_avs_readdata(15 downto 0) <= channel_delay_reg;
when CSR_DIVIDER_RATIO_FRACTION_ADDR =>
next_avs_readdata(23 downto 0) <= divider_ratio_fraction_reg;
when CSR_DIVIDER_RATIO_INT_ADDR =>
next_avs_readdata(9 downto 0) <= divider_ratio_int_reg;
when CSR_ENC_SPEED_ADDR =>
next_avs_readdata(19 downto 0) <= enc_speed;
when CSR_ENC_SPEED_MEAS_WINDOW_ADDR =>
next_avs_readdata(19 downto 0) <= enc_speed_meas_window_reg;
when CSR_FIRE_REQ_COUNTER_ADDR =>
next_avs_readdata(23 downto 0) <= fire_req_counter;
when CSR_FRACTIONAL_DIVIDER_CONTROL_ADDR =>
next_avs_readdata(0) <= fractional_divider_control_enable_reg;
next_avs_readdata(1) <= fractional_divider_control_udp_max_pos_reg;
next_avs_readdata(2) <= fractional_divider_control_udp_min_pos_reg;
when CSR_IP_ID_ADDR =>
next_avs_readdata(7 downto 0) <= std_logic_vector(to_unsigned(16#13#, 8));
next_avs_readdata(15 downto 8) <= std_logic_vector(to_unsigned(16#FF#, 8));
when CSR_IP_VER_ADDR =>
next_avs_readdata(15 downto 8) <= std_logic_vector(to_unsigned(16#04#, 8));
next_avs_readdata(7 downto 0) <= (others => '0');
when CSR_PD_COUNTER_ADDR =>
next_avs_readdata(15 downto 0) <= pd_counter;
when CSR_PD_OFFSET_DIR_0_ADDR =>
next_avs_readdata(31 downto 0) <= pd_offset_dir_0_reg;
when CSR_PD_OFFSET_DIR_1_ADDR =>
next_avs_readdata(31 downto 0) <= pd_offset_dir_1_reg;
when CSR_PIXEL_PITCH_CORR_CNT_ADDR =>
next_avs_readdata(15 downto 0) <= pixel_pitch_corr_cnt;
when CSR_PIXEL_PITCH_CORR_STRIPE_NUM_ADDR =>
next_avs_readdata(23 downto 0) <= pixel_pitch_corr_stripe_num_reg;
when CSR_PIXEL_PITCH_DIV_RATIO_CORR_ADDR =>
next_avs_readdata(31 downto 0) <= pixel_pitch_div_ratio_corr;
when CSR_PIXEL_PITCH_LOOP_FILTER_CORR_ADDR =>
next_avs_readdata(15 downto 0) <= pixel_pitch_loop_filter_corr_delta_error_coeff_reg;
next_avs_readdata(31 downto 16) <= pixel_pitch_loop_filter_corr_tot_error_coeff_reg;
when CSR_PIXEL_PITCH_POS_ERR_2_CORR_ADDR =>
next_avs_readdata(31 downto 0) <= pixel_pitch_pos_err_2_corr_reg;
when CSR_PIXEL_PITCH_POS_ERR_CURR_ADDR =>
next_avs_readdata(31 downto 0) <= pixel_pitch_pos_err_curr;
when CSR_PIXEL_PITCH_POS_ERR_MAX_ADDR =>
next_avs_readdata(31 downto 0) <= pixel_pitch_pos_err_max;
when CSR_PIXEL_PITCH_POS_ERR_MIN_ADDR =>
next_avs_readdata(31 downto 0) <= pixel_pitch_pos_err_min;
when CSR_PIXEL_PITCH_SKIP_CORR_THRES_ADDR =>
next_avs_readdata(23 downto 0) <= pixel_pitch_skip_corr_thres_reg;
when CSR_PULSE_GEN_CONTROL_R_ADDR =>
next_avs_readdata(8) <= pulse_gen_control_r_ch_mask_status;
next_avs_readdata(6) <= pulse_gen_control_r_delay_equalizer_error_flag;
next_avs_readdata(10) <= pulse_gen_control_r_dual_phase_directionality_select_status;
next_avs_readdata(9) <= pulse_gen_control_r_fire_enable_status;
next_avs_readdata(5) <= pulse_gen_control_r_pd_queue_error_flag;
next_avs_readdata(14) <= pulse_gen_control_r_tof_sat_flag;
when CSR_PULSE_GEN_CONTROL_W_ADDR =>
next_avs_readdata(1) <= pulse_gen_control_w_bypass_channel_controller_reg;
next_avs_readdata(3) <= pulse_gen_control_w_bypass_delay_equalizer_reg;
next_avs_readdata(0) <= pulse_gen_control_w_enable_reg;
next_avs_readdata(17) <= pulse_gen_control_w_enable_output_reg;
next_avs_readdata(12) <= pulse_gen_control_w_pp_apply_corr_en_reg;
next_avs_readdata(19) <= pulse_gen_control_w_reset_diag_regs_reg;
next_avs_readdata(4) <= pulse_gen_control_w_sw_control_dp_dir_reg;
next_avs_readdata(13) <= pulse_gen_control_w_tof_comp_enable_reg;
next_avs_readdata(18) <= pulse_gen_control_w_trigger_abort_fire_reg;
next_avs_readdata(11) <= pulse_gen_control_w_wh_apply_corr_en_reg;
when CSR_SUBPIXEL_PHASE_NUM_ADDR =>
next_avs_readdata(5 downto 0) <= subpixel_phase_num_reg;
when CSR_TOF_COMPENSATION_R_ADDR =>
next_avs_readdata(31 downto 16) <= tof_compensation_r_tof_lut_comp;
when CSR_TOF_COMPENSATION_W_ADDR =>
next_avs_readdata(15 downto 0) <= tof_compensation_w_enc_speed_norm_reg;
-- end auto-generated
-- Default an active read on non-existent register
when others =>
next_avs_readdata <= x"00000000";
end case;
end if;
end process;
-- Process to update internal state
process (clk, rst_n)
begin
if rst_n = '0' then
avs_readdata_reg <= (others => '0');
-- auto-generated
-- Reset internal write registers
pulse_gen_control_w_enable_reg <= '0';
pulse_gen_control_w_bypass_channel_controller_reg <= '0';
pulse_gen_control_w_bypass_delay_equalizer_reg <= '0';
pulse_gen_control_w_sw_control_dp_dir_reg <= '0';
pulse_gen_control_w_wh_apply_corr_en_reg <= '0';
pulse_gen_control_w_pp_apply_corr_en_reg <= '0';
pulse_gen_control_w_tof_comp_enable_reg <= '0';
pulse_gen_control_w_enable_output_reg <= '0';
pulse_gen_control_w_trigger_abort_fire_reg <= '0';
pulse_gen_control_w_reset_diag_regs_reg <= '0';
pd_offset_dir_0_reg <= (others => '0');
pd_offset_dir_1_reg <= (others => '0');
channel_delay_reg <= (others => '0');
channel_controller_control_w_sequencer_start_address_reg <= (others => '0');
fractional_divider_control_enable_reg <= '0';
fractional_divider_control_udp_max_pos_reg <= '0';
fractional_divider_control_udp_min_pos_reg <= '0';
divider_ratio_int_reg <= (others => '0');
divider_ratio_fraction_reg <= (others => '0');
subpixel_phase_num_reg <= std_logic_vector(to_unsigned(16#01#, 6));
enc_speed_meas_window_reg <= std_logic_vector(to_unsigned(16#0C350#, 20));
tof_compensation_w_enc_speed_norm_reg <= std_logic_vector(to_unsigned(16#0100#, 16));
pixel_pitch_corr_stripe_num_reg <= (others => '0');
pixel_pitch_pos_err_2_corr_reg <= (others => '0');
pixel_pitch_skip_corr_thres_reg <= std_logic_vector(to_unsigned(16#400000#, 24));
pixel_pitch_loop_filter_corr_delta_error_coeff_reg <= std_logic_vector(to_unsigned(16#0100#, 16));
pixel_pitch_loop_filter_corr_tot_error_coeff_reg <= std_logic_vector(to_unsigned(16#0100#, 16));
channel_controller_seq_reg <= (others => '0');
ToF_Comp_LUT_reg <= (others => '0');
pulse_gen_control_w_clr_pd_queue_reg <= '0';
channel_controller_control_w_start_seq_trigger_reg <= '0';
-- end auto-generated
elsif (clk'event and clk = '1') then
avs_readdata_reg <= next_avs_readdata;
-- auto-generated
-- Internal write register state updates
pulse_gen_control_w_enable_reg <= next_pulse_gen_control_w_enable;
pulse_gen_control_w_bypass_channel_controller_reg <= next_pulse_gen_control_w_bypass_channel_controller;
pulse_gen_control_w_bypass_delay_equalizer_reg <= next_pulse_gen_control_w_bypass_delay_equalizer;
pulse_gen_control_w_sw_control_dp_dir_reg <= next_pulse_gen_control_w_sw_control_dp_dir;
pulse_gen_control_w_wh_apply_corr_en_reg <= next_pulse_gen_control_w_wh_apply_corr_en;
pulse_gen_control_w_pp_apply_corr_en_reg <= next_pulse_gen_control_w_pp_apply_corr_en;
pulse_gen_control_w_tof_comp_enable_reg <= next_pulse_gen_control_w_tof_comp_enable;
pulse_gen_control_w_enable_output_reg <= next_pulse_gen_control_w_enable_output;
pulse_gen_control_w_trigger_abort_fire_reg <= next_pulse_gen_control_w_trigger_abort_fire;
pulse_gen_control_w_reset_diag_regs_reg <= next_pulse_gen_control_w_reset_diag_regs;
pd_offset_dir_0_reg <= next_pd_offset_dir_0;
pd_offset_dir_1_reg <= next_pd_offset_dir_1;
channel_delay_reg <= next_channel_delay;
channel_controller_control_w_sequencer_start_address_reg <= next_channel_controller_control_w_sequencer_start_address;
fractional_divider_control_enable_reg <= next_fractional_divider_control_enable;
fractional_divider_control_udp_max_pos_reg <= next_fractional_divider_control_udp_max_pos;
fractional_divider_control_udp_min_pos_reg <= next_fractional_divider_control_udp_min_pos;
divider_ratio_int_reg <= next_divider_ratio_int;
divider_ratio_fraction_reg <= next_divider_ratio_fraction;
subpixel_phase_num_reg <= next_subpixel_phase_num;
enc_speed_meas_window_reg <= next_enc_speed_meas_window;
tof_compensation_w_enc_speed_norm_reg <= next_tof_compensation_w_enc_speed_norm;
pixel_pitch_corr_stripe_num_reg <= next_pixel_pitch_corr_stripe_num;
pixel_pitch_pos_err_2_corr_reg <= next_pixel_pitch_pos_err_2_corr;
pixel_pitch_skip_corr_thres_reg <= next_pixel_pitch_skip_corr_thres;
pixel_pitch_loop_filter_corr_delta_error_coeff_reg <= next_pixel_pitch_loop_filter_corr_delta_error_coeff;
pixel_pitch_loop_filter_corr_tot_error_coeff_reg <= next_pixel_pitch_loop_filter_corr_tot_error_coeff;
channel_controller_seq_reg <= next_channel_controller_seq;
ToF_Comp_LUT_reg <= next_ToF_Comp_LUT;
pulse_gen_control_w_clr_pd_queue_reg <= next_pulse_gen_control_w_clr_pd_queue;
channel_controller_control_w_start_seq_trigger_reg <= next_channel_controller_control_w_start_seq_trigger;
-- end auto-generated
end if;
end process;
end rtl;

View file

@ -0,0 +1,146 @@
-- Block name: pulse_generator_4
-- And now for some register addresses...
-- altera vhdl_input_version vhdl_2008
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
package pulse_generator_4_pkg is
constant CSR_LOCAL_ADDR : std_logic_vector(31 downto 0) := 32x"00000000";
constant CSR_LOCAL_ADDR_INT : integer := 16#00000000#;
constant CSR_GENERIC_SEQUENCER_17_CHANNEL_ADDR : std_logic_vector(31 downto 0) := 32x"00000020";
constant CSR_GENERIC_SEQUENCER_17_CHANNEL_ADDR_INT : integer := 16#00000020#;
constant CSR_IP_ID_ADDR : std_logic_vector(10 downto 0) := 11x"000";
constant CSR_IP_ID_ADDR_US : unsigned(10 downto 0) := 11x"000";
constant CSR_IP_ID_ADDR_INT : integer := 16#00000000#;
subtype CSR_IP_ID_IP_NUMBER is natural range 7 downto 0;
subtype CSR_IP_ID_MFR_NUMBER is natural range 15 downto 8;
constant CSR_IP_VER_ADDR : std_logic_vector(10 downto 0) := 11x"001";
constant CSR_IP_VER_ADDR_US : unsigned(10 downto 0) := 11x"001";
constant CSR_IP_VER_ADDR_INT : integer := 16#00000001#;
subtype CSR_IP_VER_MINOR_NUMBER is natural range 7 downto 0;
subtype CSR_IP_VER_MAJOR_NUMBER is natural range 15 downto 8;
constant CSR_PULSE_GEN_CONTROL_W_ADDR : std_logic_vector(10 downto 0) := 11x"002";
constant CSR_PULSE_GEN_CONTROL_W_ADDR_US : unsigned(10 downto 0) := 11x"002";
constant CSR_PULSE_GEN_CONTROL_W_ADDR_INT : integer := 16#00000002#;
subtype CSR_PULSE_GEN_CONTROL_W_ENABLE is natural range 0 downto 0;
subtype CSR_PULSE_GEN_CONTROL_W_BYPASS_CHANNEL_CONTROLLER is natural range 1 downto 1;
subtype CSR_PULSE_GEN_CONTROL_W_BYPASS_DELAY_EQUALIZER is natural range 3 downto 3;
subtype CSR_PULSE_GEN_CONTROL_W_SW_CONTROL_DP_DIR is natural range 4 downto 4;
subtype CSR_PULSE_GEN_CONTROL_W_WH_APPLY_CORR_EN is natural range 11 downto 11;
subtype CSR_PULSE_GEN_CONTROL_W_PP_APPLY_CORR_EN is natural range 12 downto 12;
subtype CSR_PULSE_GEN_CONTROL_W_TOF_COMP_ENABLE is natural range 13 downto 13;
subtype CSR_PULSE_GEN_CONTROL_W_ENABLE_OUTPUT is natural range 17 downto 17;
subtype CSR_PULSE_GEN_CONTROL_W_TRIGGER_ABORT_FIRE is natural range 18 downto 18;
subtype CSR_PULSE_GEN_CONTROL_W_RESET_DIAG_REGS is natural range 19 downto 19;
subtype CSR_PULSE_GEN_CONTROL_W_CLR_PD_QUEUE is natural range 20 downto 20;
constant CSR_PULSE_GEN_CONTROL_R_ADDR : std_logic_vector(10 downto 0) := 11x"003";
constant CSR_PULSE_GEN_CONTROL_R_ADDR_US : unsigned(10 downto 0) := 11x"003";
constant CSR_PULSE_GEN_CONTROL_R_ADDR_INT : integer := 16#00000003#;
subtype CSR_PULSE_GEN_CONTROL_R_PD_QUEUE_ERROR_FLAG is natural range 5 downto 5;
subtype CSR_PULSE_GEN_CONTROL_R_DELAY_EQUALIZER_ERROR_FLAG is natural range 6 downto 6;
subtype CSR_PULSE_GEN_CONTROL_R_CH_MASK_STATUS is natural range 8 downto 8;
subtype CSR_PULSE_GEN_CONTROL_R_FIRE_ENABLE_STATUS is natural range 9 downto 9;
subtype CSR_PULSE_GEN_CONTROL_R_DUAL_PHASE_DIRECTIONALITY_SELECT_STATUS is natural range 10 downto 10;
subtype CSR_PULSE_GEN_CONTROL_R_TOF_SAT_FLAG is natural range 14 downto 14;
constant CSR_PD_OFFSET_DIR_0_ADDR : std_logic_vector(10 downto 0) := 11x"004";
constant CSR_PD_OFFSET_DIR_0_ADDR_US : unsigned(10 downto 0) := 11x"004";
constant CSR_PD_OFFSET_DIR_0_ADDR_INT : integer := 16#00000004#;
constant CSR_PD_OFFSET_DIR_1_ADDR : std_logic_vector(10 downto 0) := 11x"005";
constant CSR_PD_OFFSET_DIR_1_ADDR_US : unsigned(10 downto 0) := 11x"005";
constant CSR_PD_OFFSET_DIR_1_ADDR_INT : integer := 16#00000005#;
constant CSR_CHANNEL_DELAY_ADDR : std_logic_vector(10 downto 0) := 11x"006";
constant CSR_CHANNEL_DELAY_ADDR_US : unsigned(10 downto 0) := 11x"006";
constant CSR_CHANNEL_DELAY_ADDR_INT : integer := 16#00000006#;
constant CSR_CHANNEL_CONTROLLER_CONTROL_W_ADDR : std_logic_vector(10 downto 0) := 11x"007";
constant CSR_CHANNEL_CONTROLLER_CONTROL_W_ADDR_US : unsigned(10 downto 0) := 11x"007";
constant CSR_CHANNEL_CONTROLLER_CONTROL_W_ADDR_INT : integer := 16#00000007#;
subtype CSR_CHANNEL_CONTROLLER_CONTROL_W_START_SEQ_TRIGGER is natural range 0 downto 0;
subtype CSR_CHANNEL_CONTROLLER_CONTROL_W_SEQUENCER_START_ADDRESS is natural range 15 downto 8;
constant CSR_CHANNEL_CONTROLLER_CONTROL_R_ADDR : std_logic_vector(10 downto 0) := 11x"008";
constant CSR_CHANNEL_CONTROLLER_CONTROL_R_ADDR_US : unsigned(10 downto 0) := 11x"008";
constant CSR_CHANNEL_CONTROLLER_CONTROL_R_ADDR_INT : integer := 16#00000008#;
subtype CSR_CHANNEL_CONTROLLER_CONTROL_R_BUSY is natural range 1 downto 1;
constant CSR_FRACTIONAL_DIVIDER_CONTROL_ADDR : std_logic_vector(10 downto 0) := 11x"009";
constant CSR_FRACTIONAL_DIVIDER_CONTROL_ADDR_US : unsigned(10 downto 0) := 11x"009";
constant CSR_FRACTIONAL_DIVIDER_CONTROL_ADDR_INT : integer := 16#00000009#;
subtype CSR_FRACTIONAL_DIVIDER_CONTROL_ENABLE is natural range 0 downto 0;
subtype CSR_FRACTIONAL_DIVIDER_CONTROL_UDP_MAX_POS is natural range 1 downto 1;
subtype CSR_FRACTIONAL_DIVIDER_CONTROL_UDP_MIN_POS is natural range 2 downto 2;
constant CSR_DIVIDER_RATIO_INT_ADDR : std_logic_vector(10 downto 0) := 11x"00A";
constant CSR_DIVIDER_RATIO_INT_ADDR_US : unsigned(10 downto 0) := 11x"00A";
constant CSR_DIVIDER_RATIO_INT_ADDR_INT : integer := 16#0000000A#;
constant CSR_DIVIDER_RATIO_FRACTION_ADDR : std_logic_vector(10 downto 0) := 11x"00B";
constant CSR_DIVIDER_RATIO_FRACTION_ADDR_US : unsigned(10 downto 0) := 11x"00B";
constant CSR_DIVIDER_RATIO_FRACTION_ADDR_INT : integer := 16#0000000B#;
constant CSR_SUBPIXEL_PHASE_NUM_ADDR : std_logic_vector(10 downto 0) := 11x"00C";
constant CSR_SUBPIXEL_PHASE_NUM_ADDR_US : unsigned(10 downto 0) := 11x"00C";
constant CSR_SUBPIXEL_PHASE_NUM_ADDR_INT : integer := 16#0000000C#;
constant CSR_ABS_POSITION_MAX_ADDR : std_logic_vector(10 downto 0) := 11x"00D";
constant CSR_ABS_POSITION_MAX_ADDR_US : unsigned(10 downto 0) := 11x"00D";
constant CSR_ABS_POSITION_MAX_ADDR_INT : integer := 16#0000000D#;
constant CSR_ABS_POSITION_MIN_ADDR : std_logic_vector(10 downto 0) := 11x"00E";
constant CSR_ABS_POSITION_MIN_ADDR_US : unsigned(10 downto 0) := 11x"00E";
constant CSR_ABS_POSITION_MIN_ADDR_INT : integer := 16#0000000E#;
constant CSR_ABS_POSITION_ADDR : std_logic_vector(10 downto 0) := 11x"00F";
constant CSR_ABS_POSITION_ADDR_US : unsigned(10 downto 0) := 11x"00F";
constant CSR_ABS_POSITION_ADDR_INT : integer := 16#0000000F#;
constant CSR_PD_COUNTER_ADDR : std_logic_vector(10 downto 0) := 11x"010";
constant CSR_PD_COUNTER_ADDR_US : unsigned(10 downto 0) := 11x"010";
constant CSR_PD_COUNTER_ADDR_INT : integer := 16#00000010#;
constant CSR_FIRE_REQ_COUNTER_ADDR : std_logic_vector(10 downto 0) := 11x"011";
constant CSR_FIRE_REQ_COUNTER_ADDR_US : unsigned(10 downto 0) := 11x"011";
constant CSR_FIRE_REQ_COUNTER_ADDR_INT : integer := 16#00000011#;
constant CSR_ENC_SPEED_MEAS_WINDOW_ADDR : std_logic_vector(10 downto 0) := 11x"012";
constant CSR_ENC_SPEED_MEAS_WINDOW_ADDR_US : unsigned(10 downto 0) := 11x"012";
constant CSR_ENC_SPEED_MEAS_WINDOW_ADDR_INT : integer := 16#00000012#;
constant CSR_ENC_SPEED_ADDR : std_logic_vector(10 downto 0) := 11x"013";
constant CSR_ENC_SPEED_ADDR_US : unsigned(10 downto 0) := 11x"013";
constant CSR_ENC_SPEED_ADDR_INT : integer := 16#00000013#;
constant CSR_TOF_COMPENSATION_W_ADDR : std_logic_vector(10 downto 0) := 11x"014";
constant CSR_TOF_COMPENSATION_W_ADDR_US : unsigned(10 downto 0) := 11x"014";
constant CSR_TOF_COMPENSATION_W_ADDR_INT : integer := 16#00000014#;
subtype CSR_TOF_COMPENSATION_W_ENC_SPEED_NORM is natural range 15 downto 0;
constant CSR_TOF_COMPENSATION_R_ADDR : std_logic_vector(10 downto 0) := 11x"015";
constant CSR_TOF_COMPENSATION_R_ADDR_US : unsigned(10 downto 0) := 11x"015";
constant CSR_TOF_COMPENSATION_R_ADDR_INT : integer := 16#00000015#;
subtype CSR_TOF_COMPENSATION_R_TOF_LUT_COMP is natural range 31 downto 16;
constant CSR_PIXEL_PITCH_CORR_STRIPE_NUM_ADDR : std_logic_vector(10 downto 0) := 11x"016";
constant CSR_PIXEL_PITCH_CORR_STRIPE_NUM_ADDR_US : unsigned(10 downto 0) := 11x"016";
constant CSR_PIXEL_PITCH_CORR_STRIPE_NUM_ADDR_INT : integer := 16#00000016#;
constant CSR_PIXEL_PITCH_POS_ERR_2_CORR_ADDR : std_logic_vector(10 downto 0) := 11x"017";
constant CSR_PIXEL_PITCH_POS_ERR_2_CORR_ADDR_US : unsigned(10 downto 0) := 11x"017";
constant CSR_PIXEL_PITCH_POS_ERR_2_CORR_ADDR_INT : integer := 16#00000017#;
constant CSR_PIXEL_PITCH_SKIP_CORR_THRES_ADDR : std_logic_vector(10 downto 0) := 11x"018";
constant CSR_PIXEL_PITCH_SKIP_CORR_THRES_ADDR_US : unsigned(10 downto 0) := 11x"018";
constant CSR_PIXEL_PITCH_SKIP_CORR_THRES_ADDR_INT : integer := 16#00000018#;
constant CSR_PIXEL_PITCH_LOOP_FILTER_CORR_ADDR : std_logic_vector(10 downto 0) := 11x"019";
constant CSR_PIXEL_PITCH_LOOP_FILTER_CORR_ADDR_US : unsigned(10 downto 0) := 11x"019";
constant CSR_PIXEL_PITCH_LOOP_FILTER_CORR_ADDR_INT : integer := 16#00000019#;
subtype CSR_PIXEL_PITCH_LOOP_FILTER_CORR_DELTA_ERROR_COEFF is natural range 15 downto 0;
subtype CSR_PIXEL_PITCH_LOOP_FILTER_CORR_TOT_ERROR_COEFF is natural range 31 downto 16;
constant CSR_PIXEL_PITCH_POS_ERR_CURR_ADDR : std_logic_vector(10 downto 0) := 11x"01A";
constant CSR_PIXEL_PITCH_POS_ERR_CURR_ADDR_US : unsigned(10 downto 0) := 11x"01A";
constant CSR_PIXEL_PITCH_POS_ERR_CURR_ADDR_INT : integer := 16#0000001A#;
constant CSR_PIXEL_PITCH_POS_ERR_MAX_ADDR : std_logic_vector(10 downto 0) := 11x"01B";
constant CSR_PIXEL_PITCH_POS_ERR_MAX_ADDR_US : unsigned(10 downto 0) := 11x"01B";
constant CSR_PIXEL_PITCH_POS_ERR_MAX_ADDR_INT : integer := 16#0000001B#;
constant CSR_PIXEL_PITCH_POS_ERR_MIN_ADDR : std_logic_vector(10 downto 0) := 11x"01C";
constant CSR_PIXEL_PITCH_POS_ERR_MIN_ADDR_US : unsigned(10 downto 0) := 11x"01C";
constant CSR_PIXEL_PITCH_POS_ERR_MIN_ADDR_INT : integer := 16#0000001C#;
constant CSR_PIXEL_PITCH_DIV_RATIO_CORR_ADDR : std_logic_vector(10 downto 0) := 11x"01D";
constant CSR_PIXEL_PITCH_DIV_RATIO_CORR_ADDR_US : unsigned(10 downto 0) := 11x"01D";
constant CSR_PIXEL_PITCH_DIV_RATIO_CORR_ADDR_INT : integer := 16#0000001D#;
constant CSR_PIXEL_PITCH_CORR_CNT_ADDR : std_logic_vector(10 downto 0) := 11x"01E";
constant CSR_PIXEL_PITCH_CORR_CNT_ADDR_US : unsigned(10 downto 0) := 11x"01E";
constant CSR_PIXEL_PITCH_CORR_CNT_ADDR_INT : integer := 16#0000001E#;
constant CSR_CHANNEL_CONTROLLER_SEQ_ADDR : std_logic_vector(10 downto 0) := 11x"200";
constant CSR_CHANNEL_CONTROLLER_SEQ_ADDR_US : unsigned(10 downto 0) := 11x"200";
constant CSR_CHANNEL_CONTROLLER_SEQ_ADDR_INT : integer := 16#00000200#;
constant CSR_TOF_COMP_LUT_ADDR : std_logic_vector(10 downto 0) := 11x"400";
constant CSR_TOF_COMP_LUT_ADDR_US : unsigned(10 downto 0) := 11x"400";
constant CSR_TOF_COMP_LUT_ADDR_INT : integer := 16#00000400#;
end package pulse_generator_4_pkg;

View file

@ -0,0 +1,166 @@
-------------------------------------------------------------------------------
-- Title : simple_frac_div_4
-- Project : EMB-1
-------------------------------------------------------------------------------
-- File : simple_frac_div_4.vhd
-- Author : Gianmarco Girau
-- Company : Global Inkjet Systems
-- Created : 2017-12-04
-- Last update: 2021-04-14
-- SVN ID : Git
-- Standard : VHDL'2008
-------------------------------------------------------------------------------
-- Description:
-- Simple Fractional Divider: this version of the fractional divider identifies
-- the optimal encoder position to generate a fire-pulse, but it does not
-- identy the optimal fire time. Therefore the resulting resolution is equal to
-- +/-1/2 encoder pulse.
-- The identification of the optimal absolute position for the fire request
-- employs an iterative algorithm which checks, for every increment of the
-- absolute position, in the intended direction, whether the position error at
-- the current position is lower than the error at the next position. If the
-- result of the check is positive, the fire request will be issued at the
-- current absolute position, otherwise the check is repeated at the next step.
-------------------------------------------------------------------------------
-- altera vhdl_input_version vhdl_2008
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity simple_frac_div_4 is
port(
clk : in std_logic;
enable : in std_logic;
upd_max_pos : in std_logic;
upd_min_pos : in std_logic;
abs_pos_max : out std_logic_vector(31 downto 0);
abs_pos_min : out std_logic_vector(31 downto 0);
dir : in std_logic;
offset : in std_logic_vector(33 downto 0);
ratio : in std_logic_vector(33 downto 0);
abs_pos : in std_logic_vector(31 downto 0);
enc_pulse : out std_logic;
fire : out std_logic;
fire_cnt : out std_logic_vector(31 downto 0));
end entity simple_frac_div_4;
architecture rtl of simple_frac_div_4 is
signal enable_d, start : std_logic;
signal update, fire_gen : std_logic;
signal inc_pos, dec_pos : std_logic;
signal new_max, new_min : std_logic;
signal delta_wrap, start_d : std_logic;
signal check_first : std_logic;
signal check_others : std_logic;
signal firing_error_comp : std_logic;
signal firing_error_is_0 : std_logic;
signal firing_error_is_1 : std_logic;
--
signal zeros, delta_pos : std_logic_vector(15 downto 0);
signal fire_cnt_i : std_logic_vector(31 downto 0);
signal pos_diff : std_logic_vector(31 downto 0);
signal pos_max, pos_min : std_logic_vector(31 downto 0);
signal dist_pos, dist_neg : std_logic_vector(31 downto 0);
signal abs_pos_d : std_logic_vector(31 downto 0);
signal ideal_fire : std_logic_vector(49 downto 0);
signal firing_error : std_logic_vector(49 downto 0);
begin
zeros <= (others => '0');
-----------------------------------------------------------------------------
-- Min/Max Absolute Position Tracking (and jitter rejection)
-----------------------------------------------------------------------------
pPOS_TRACK : process(clk)
begin
if(clk = '1' and clk'event) then
abs_pos_d <= abs_pos;
if(new_max = '1' or upd_max_pos = '1') then
pos_max <= abs_pos;
end if;
if(new_min = '1' or upd_min_pos = '1') then
pos_min <= abs_pos;
end if;
-- enc_pulse output replaces the enc_out from the EMS, because the EMS
-- does not support encoder jitter tracking anymore.
-- Note: because of the absolute position, enc_pulse is redundant and
-- used only for diagnostic purpose.
enc_pulse <= (new_max and not dir) or (new_min and dir);
end if;
end process pPOS_TRACK;
pos_diff <= std_logic_vector(signed(abs_pos) - signed(abs_pos_d));
dist_pos <= std_logic_vector(signed(abs_pos)-signed(pos_max));
dist_neg <= std_logic_vector(signed(pos_min)-signed(abs_pos));
inc_pos <= '1' when pos_diff(31) = '0' and pos_diff(2 downto 0) = "001" else '0';
dec_pos <= '1' when pos_diff(31) = '1' and pos_diff(2 downto 0) = "111" else '0';
new_max <= '1' when inc_pos = '1' and dir = '0' and dist_pos(31) = '0' and unsigned(dist_pos(3 downto 0)) /= 0 else '0';
new_min <= '1' when dec_pos = '1' and dir = '1' and dist_neg(31) = '0' and unsigned(dist_neg(3 downto 0)) /= 0 else '0';
abs_pos_min <= pos_min;
abs_pos_max <= pos_max;
-----------------------------------------------------------------------------
-- Fractional Divider Logic
-----------------------------------------------------------------------------
pFD_REGs : process(clk)
begin
if(clk = '1' and clk'event) then
enable_d <= enable;
start_d <= start;
if(enable = '0') then
delta_pos <= (others => '0');
elsif(delta_wrap = '1') then
-- Decrement delta_pos of 64
delta_pos <= (6 => '1', others => '0');
elsif(new_min = '1' or new_max = '1') then
delta_pos <= std_logic_vector(unsigned(delta_pos)+1);
end if;
if(unsigned(delta_pos) = 127 and update = '1') then
delta_wrap <= '1';
else
delta_wrap <= '0';
end if;
-- ideal_fire: represents the ideal fire position (normalized 2**RATIO_FRACT_W)
if(start = '1') then
ideal_fire <= zeros & offset;
elsif(fire_gen = '1') then
ideal_fire <= std_logic_vector(unsigned(ideal_fire)+unsigned(ratio));
elsif(delta_wrap = '1') then
-- Decrement delta_pos of 64 (normalized 2**RATIO_FRACT_W)
--ideal_fire <= std_logic_vector(unsigned(ideal_fire)- X"3F000000");
ideal_fire <= ideal_fire(ideal_fire'left downto 36) & std_logic_vector(unsigned(ideal_fire(35 downto 24))- 12X"03F") & ideal_fire(23 downto 0);
end if;
firing_error <= std_logic_vector(unsigned(ideal_fire(ideal_fire'left downto 24)) - unsigned(delta_pos)) & X"000000";
update <= enable and (start_d or new_min or new_max);
check_first <= enable and start_d;
check_others <= enable and (new_min or new_max);
fire <= fire_gen;
if(enable = '0') then
fire_cnt_i <= (others => '0');
elsif(fire_gen = '1') then
fire_cnt_i <= std_logic_vector(unsigned(fire_cnt_i)+1);
end if;
end if;
end process pFD_REGs;
-- firing_error_comp is asserted when firing_error(firing_error'left downto 24) is
-- either 0 or 1:
firing_error_comp <= '1' when unsigned(firing_error(firing_error'left downto 25)) = 0 else '0';
firing_error_is_0 <= firing_error_comp and (not firing_error(24));
firing_error_is_1 <= firing_error_comp and firing_error(24);
fire_gen <= '1' when (check_first = '1' and firing_error_is_0 = '1') or (check_others = '1' and firing_error_is_1 = '1') else '0';
start <= enable and not enable_d;
fire_cnt <= fire_cnt_i;
end architecture rtl;

View file

@ -0,0 +1,256 @@
30000000
1000000F
C0000003
C0000004
30000001
30000000
20000001
C0000008
30006424
30006400
81000032
23000001
30000000
C000000E
C000000F
30000011
30000010
23000001
C0000013
30006434
30006410
81000032
23000001
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000

View file

@ -0,0 +1,256 @@
30000000
1000000F
C0000003
C0000004
30000001
30000000
20000001
C0000008
30006424
30006400
81000032
23000001
30000000
C000000E
C000000F
30000011
30000010
23000001
C0000013
30006434
30006410
81000032
23000001
C0000013
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000

View file

@ -0,0 +1,256 @@
30000000
1000000F
C0000003
C0000004
30000000
30000000
20000001
C0000008
30006424
30006400
81000032
23000001
30000000
C000000E
C000000F
30000010
30000010
23000001
C0000013
30006434
30006410
81000032
23000001
C0000013
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000

View file

@ -0,0 +1,863 @@
-------------------------------------------------------------------------------
-- Title : ch_ctrl_cfg_tb
-- Project : Pulse-Generator
-------------------------------------------------------------------------------
-- File : ch_ctrl_cfg_tb.vhd
-- Author : GMG
-- Company : Global Inkjet Systems
-- Created : 2019-05-17
-- Last update: 2020-04-16
-- SVN ID : Git
-- Standard : VHDL'2008
-------------------------------------------------------------------------------
-- Description:
-- Allows to verify Pulse-Generator with customs Ch-Ctrl configurations
-------------------------------------------------------------------------------
library std;
use std.textio.all;
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.std_logic_textio.all;
use ieee.math_real.all;
use work.log_pkg.all;
use work.avalon_verify_pkg.all;
use work.pulse_generator_4_pkg.all;
entity ch_ctrl_cfg_tb is
-- ..
end entity ch_ctrl_cfg_tb;
architecture behav of ch_ctrl_cfg_tb is
constant CLK_PERIOD : time := 10 ns;
-- Logging Verbosity Level
constant VERBOSITY_LEVEL : verb_level_t := VMEDIUM;
constant seq_config_file : string := "./../src/test/ch_ctrl_cfg2.cfg";
type cfg_data_t is array (natural range <>) of std_logic_vector(31 downto 0);
constant SEQ_SIZE : natural := 256;
subtype seq_cfg_data_t is cfg_data_t(0 to SEQ_SIZE-1);
-- Total number of wheel rotations to simulate
constant TOTAL_ROTATIONS : natural := 100;
-- DIV_RATIO: head-pitch/ encoder-global-resolution
constant DIV_RATIO : real := 4.23;
-- Nominal image size, in pixel
constant IMG_LEN : natural := 100;
-- Nominal Distance between PDs, in encoder pulses, which corresponds to the
-- wheel circumference
constant WHEEL_CIRCUM : real := real(IMG_LEN)*DIV_RATIO;
-- number of Rotations before stopping the simulation
-- constant SIM_ROTATIONS : natural := TOTAL_ROTATIONS;
constant SIM_ROTATIONS : natural := 90;
constant APPLY_CORR_EN : boolean := true;
constant APPLY_EMUL_CORR : boolean := false;
constant SKIP_PD_EN : boolean := true;
constant PD_OFFSET : natural := 10;
constant HALF_RNG_CROSS : std_logic_vector(31 downto 0) := X"7FFFFFFF";
constant FULL_RNG_CROSS : std_logic_vector(31 downto 0) := X"FFFFFFFF";
--constant INIT_ABS_POS : std_logic_vector(31 downto 0) := std_logic_vector(signed(HALF_RNG_CROSS)-50 -PD_OFFSET);
--constant INIT_ABS_POS : std_logic_vector(31 downto 0) := std_logic_vector(signed(HALF_RNG_CROSS)-421 -PD_OFFSET);
constant INIT_ABS_POS : std_logic_vector(31 downto 0) := std_logic_vector(signed(FULL_RNG_CROSS)-421 -PD_OFFSET);
--constant INIT_ABS_POS : std_logic_vector(31 downto 0) := (others => '0');
-- Correction Loop Filter constants
constant LOOP_FILT_DELTA : real := 1.0;
constant LOOP_FILT_TOT : real := 1.0;
type wheel_error_t is array (0 to TOTAL_ROTATIONS-1) of integer;
/*
signal wheel_error : wheel_error_t := (
0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
2, 2, 3, 3, 4, 4, 5, 5, 4, 4,
3, 3, 2, 2, 1, 1, 0, 0, -1, -1,
-2, -2, -3, -3, -4, -4, -5, -5, -4, -4,
-3, -3, -2, -2, -1, -1, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 1, 1,
1, 1, 0, 0, -1, -1, -1, -1, 0, 0, others => 0);
*/
/*
signal wheel_error : wheel_error_t := (
0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
2, 2, 3, 3, 4, 4, 5, 5, 4, 4,
3, 3, 2, 2, 1, 1, 0, 0, -1, -1,
-2, -2, -3, -3, -4, -4, -5, -5, -4, -4,
-3, -3, -2, -2, -1, -1, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 1, 1,
1, 1, 0, 0, -1, -1, -1, -1, 0, 0, -40, 0, 0, +80, others => 0);
*/
/*
signal wheel_error : wheel_error_t := (
0, 0, 0, 0, 0, -1, -1, -1, -1, -1,
-2, -2, -3, -3, -4, -4, -5, -5, -4, -4,
-3, -3, -2, -2, -1, -1, 0, 0, 1, 1,
2, 2, 3, 3, 4, 4, 5, 5, 4, 4,
3, 3, 2, 2, 1, 1, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 1, 1,
1, 1, 0, 0, -1, -1, -1, -1, 0, 0, -40, 0, 0, +80, others => 0);
*/
/*
signal wheel_error : wheel_error_t := (
0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
2, 2, 3, 3, 4, 4, 5, 5, 4, 4,
3, 3, 2, 2, 1, 1, 0, 0, -1, -1,
-2, -2, -3, -3, -4, -4, -5, -5, -4, -4,
-3, -3, -2, -2, -1, -1, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 1, 1,
1, 1, 0, 0, -1, -1, -1, -1, 0, 0, -40, 0, 0, +80, others => +40);
*/
signal wheel_error : wheel_error_t := (
0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
2, 2, 3, 3, 4, 4, 5, 5, 4, 4,
3, 3, 2, 2, 1, 1, 0, 0, -1, -1,
-2, -2, -3, -3, -4, -4, -5, -5, -4, -4,
-3, -3, -2, -2, -1, -1, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 1, 1,
1, 1, 0, 0, -1, -1, -1, -1, 0, 0, -40, -40, -40, others => +40);
-----------------------------------------------------------------------------
-- Signal declarations
-----------------------------------------------------------------------------
signal reset_n : std_logic := '0';
signal clk : std_logic := '0';
signal init : std_logic;
signal pd_in : std_logic;
signal abs_position : std_logic_vector(31 downto 0);
signal dp_dir : std_logic;
signal fire_req : std_logic;
signal fire_req_vec : std_logic_vector(31 downto 0);
signal start_of_image_vec : std_logic_vector(31 downto 0);
signal filtered_pd : std_logic;
signal ch_pd : std_logic;
signal ch_mask : std_logic;
signal raw_fire_req : std_logic;
signal avs_address : std_logic_vector(10 downto 0);
signal avs_write : std_logic;
signal avs_writedata : std_logic_vector(31 downto 0);
signal avs_read : std_logic;
signal avs_readdatavalid : std_logic;
signal avs_readdata : std_logic_vector(31 downto 0);
--
signal avs_m : mm_m_rec_t;
signal avs_s : mm_s_rec_t;
--
signal pd_in_cnt : integer;
signal pd_out_cnt : integer;
--
signal end_of_stimuli : boolean;
signal test_completed : boolean;
signal setup : boolean;
signal running : boolean;
signal passed : boolean;
signal failed : boolean;
shared variable error_flag : boolean;
signal wheel_pos : integer;
signal pos_error : real;
signal pos_error_old : real;
signal rotation_idx : natural;
signal div_ratio_corr_r : real;
signal div_ratio_corr_rr : real;
signal div_ratio_r : real;
signal wh_pos_err_r : real;
signal wheel_corr_on : std_logic;
signal skip_pd : std_logic;
-----------------------------------------------------------------------------
-- TB Functions / Procedures
-----------------------------------------------------------------------------
procedure wait_latency(
signal clk : in std_logic;
cycles : in natural) is
begin
for i in 1 to cycles loop
wait until clk = '1' and clk'event;
end loop; -- i
end procedure wait_latency;
procedure read_cfg_file(
fname : in string;
num_data : in natural;
read_data : out cfg_data_t) is
file f_id : text;
variable status : file_open_status;
variable InLine : line;
variable word : std_logic_vector(31 downto 0);
begin
file_open(status, f_id, fname, read_mode);
if(status /= open_ok) then
log("ERROR: Failed to open file " & fname & ".", VLOW);
error_flag := true;
else
READ_LOOP: for idx in 0 to num_data-1 loop
readline(f_id, InLine);
hread(InLine, word);
read_data(idx) := word;
end loop; -- READ_LOOP
file_close(f_id);
end if;
end procedure read_cfg_file;
-- load ch-ctrl sequencer configuration
procedure load_seq_cfg(
fname : in string;
signal seq_s_rec : in mm_s_rec_t;
signal seq_m_rec : out mm_m_rec_t) is
variable seq_data : seq_cfg_data_t;
variable offset : natural;
variable addr : std_logic_vector(31 downto 0);
begin
read_cfg_file(fname, SEQ_SIZE, seq_data);
log("Configuring Ch-Ctrl RAM ...", VMEDIUM);
offset :=512;
for n in 0 to SEQ_SIZE-1 loop
addr := std_logic_vector(to_unsigned(offset+n,32));
--log("Ch-Ctrl Cfg: Addr = " & to_string(n) & ", data = 0x" & to_hstring(seq_data(n)) & ".", VMEDIUM);
mm_32b_write(addr, seq_data(n), seq_s_rec, seq_m_rec);
end loop; -- n
end procedure load_seq_cfg;
procedure set_div_ratio(
div_ratio : real;
signal mm_s_rec : in mm_s_rec_t;
signal mm_m_rec : out mm_m_rec_t) is
variable addr : std_logic_vector(31 downto 0) := (others => '0');
variable data : std_logic_vector(31 downto 0) := (others => '0');
variable ratio_int : integer;
variable ratio_slv : std_logic_vector(33 downto 0);
begin
-- set the division ratio
ratio_int := integer(div_ratio*real(2**24));
ratio_slv := std_logic_vector(to_unsigned(ratio_int, 34));
-- Set the integer part of the div-ratio
data(31 downto 10) := (others => '0');
data( 9 downto 0) := ratio_slv(33 downto 24);
addr := std_logic_vector(resize(unsigned(CSR_DIVIDER_RATIO_INT_ADDR), 32));
mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
-- Set the fractional part of the div-ratio
data(31 downto 24) := (others => '0');
data(23 downto 0) := ratio_slv(23 downto 0);
addr := std_logic_vector(resize(unsigned(CSR_DIVIDER_RATIO_FRACTION_ADDR), 32));
mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
end procedure set_div_ratio;
procedure enable_wheel_corr(
enable : std_logic;
signal mm_s_rec : in mm_s_rec_t;
signal mm_m_rec : out mm_m_rec_t) is
variable addr : std_logic_vector(31 downto 0) := (others => '0');
variable data : std_logic_vector(31 downto 0) := (others => '0');
begin
-- Read the current value of the cotrl register
addr := std_logic_vector(resize(unsigned(CSR_PULSE_GEN_CONTROL_W_ADDR), 32));
mm_32b_read(addr, data, mm_s_rec, mm_m_rec);
data(11) := enable;
-- Write back the updated value
mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
if(enable = '0') then
log("Wheel Correction Disabled:", VMEDIUM);
else
log("Wheel Correction Enabled:", VMEDIUM);
end if;
end procedure enable_wheel_corr;
procedure apply_pg_cfg(
div_ratio : real;
offset_dir0 : integer;
offset_dir1 : integer;
delay : integer;
signal mm_s_rec : in mm_s_rec_t;
signal mm_m_rec : out mm_m_rec_t) is
variable addr : std_logic_vector(31 downto 0) := (others => '0');
variable data : std_logic_vector(31 downto 0) := (others => '0');
variable ratio_int : integer;
variable ratio_slv : std_logic_vector(33 downto 0);
begin
log_separator_line(VMEDIUM);
log("Configuring Pulse-Generator registers ...", VMEDIUM);
log_separator_line(VMEDIUM);
log("Div-Ratio = " & to_string(div_ratio), VMEDIUM);
-- Disable/Re-enable first the whole pulse_generator
addr := std_logic_vector(resize(unsigned(CSR_PULSE_GEN_CONTROL_W_ADDR), 32));
data := (others => '0');
mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
data := (0 => '1', 16 => '1', others => '0');
mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
-- Disable the Channel Controller sequencer
addr := std_logic_vector(resize(unsigned(CSR_CHANNEL_CONTROLLER_CONTROL_W_ADDR), 32));
data := (others => '0');
mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
-- Set the division ratio
set_div_ratio(div_ratio, mm_s_rec, mm_m_rec);
-- Disable/Enable the fractional divider
addr := std_logic_vector(resize(unsigned(CSR_FRACTIONAL_DIVIDER_CONTROL_ADDR), 32));
data := (others => '0');
mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
data := (0 => '1', others => '0');
mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
-- Configure the rest of the pulse_generator:
-- Configure the Channel Offset (Both DIR_0 and DIR_1):
-- DIR_0
addr := std_logic_vector(resize(unsigned(CSR_PD_OFFSET_DIR_0_ADDR),32));
data := std_logic_vector(to_unsigned(offset_dir0, 32));
mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
-- DIR_1
addr := std_logic_vector(resize(unsigned(CSR_PD_OFFSET_DIR_1_ADDR), 32));
data := std_logic_vector(to_unsigned(offset_dir1, 32));
mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
-- Configure the Channel Delay:
addr := std_logic_vector(resize(unsigned(CSR_CHANNEL_DELAY_ADDR), 32));
data := std_logic_vector(to_unsigned(delay, 32));
mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
-- enable the ch-ctrl sequencer
addr := std_logic_vector(to_unsigned(32+3, 32));
data := (0 => '1', others => '0');
mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
-- issue a start_req to the ch-ctrl sequencer
addr := std_logic_vector(resize(unsigned(CSR_CHANNEL_CONTROLLER_CONTROL_W_ADDR), 32));
data := (0 => '1', others => '0');
mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
-- Specify the image-length for wheel correction
addr := std_logic_vector(resize(unsigned(CSR_PIXEL_PITCH_CORR_STRIPE_NUM_ADDR), 32));
data := std_logic_vector(to_unsigned(IMG_LEN, 32));
mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
-- Compute the constant for W&H Correction
addr := std_logic_vector(resize(unsigned(CSR_PIXEL_PITCH_POS_ERR_2_CORR_ADDR), 32));
data := std_logic_vector(to_unsigned(integer(round((1.0/real(IMG_LEN))*(2.0**32))), 32));
mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
-- set the threshold for skipping correctiion to 256
addr := std_logic_vector(resize(unsigned(CSR_PIXEL_PITCH_SKIP_CORR_THRES_ADDR), 32));
data := std_logic_vector(to_unsigned((256), 32));
mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
-- enable the pulse-generator + Enable W&H Correction
addr := std_logic_vector(resize(unsigned(CSR_PULSE_GEN_CONTROL_W_ADDR), 32));
data := (0 => '1', 11 => '1', 16 => '1', others => '0');
mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
log("Wheel Correction Enabled:", VMEDIUM);
log_separator_line(VMEDIUM);
end procedure apply_pg_cfg;
-----------------------------------------------------------------------------
-- End declarative part
-----------------------------------------------------------------------------
begin -- architecture behav
clk <= not clk after 0.5*CLK_PERIOD;
-----------------------------------------------------------------------------
-- UUT
-----------------------------------------------------------------------------
iUUT : entity work.pulse_generator_4
generic map (
PULSE_DELAY_EQUAL_EN => true,
PIXEL_PITCH_CORR_EN => true)
port map (
clk => clk,
reset_n => reset_n,
init => init,
pd_in => pd_in,
abs_position => abs_position,
dp_dir => dp_dir,
fire_req_vec => fire_req_vec,
start_of_image_vec => start_of_image_vec,
filtered_pd => filtered_pd,
ch_pd => ch_pd,
ch_mask => ch_mask,
raw_fire_req => raw_fire_req,
avs_address => avs_address,
avs_write => avs_write,
avs_writedata => avs_writedata,
avs_read => avs_read,
avs_readdata => avs_readdata);
fire_req <= fire_req_vec(0);
pGET_WH_ERR : process
alias wh_pos_err is <<signal iUUT.wh_pos_err_curr : std_logic_vector(31 downto 0)>>;
alias wh_corr_meas_ready is <<signal iUUT.wh_corr_ready_v : std_logic_vector(5 downto 0)>>;
alias div_ratio_corr is <<signal iUUT.div_ratio_corr : std_logic_vector(33 downto 0)>>;
variable pos_error : real;
variable div_ratio_corr_r : real;
begin
if(SKIP_PD_EN = false) then
wh_pos_err_r <= real(to_integer(signed(wh_pos_err)))/256.0;
wait until clk = '1' and clk'event;
else
wh_pos_err_r <= 0.0;
div_ratio_corr_rr <= 0.0;
-- wait until the first PD;
wait until rising_edge(ch_pd);
-- measur the error, then apply correction
while end_of_stimuli = false loop
wait until rising_edge(wh_corr_meas_ready(2));
wait until clk = '0' and clk'event;
pos_error := real(to_integer(signed(wh_pos_err)))/256.0;
wh_pos_err_r <= pos_error;
log("Rotation #" & to_string(rotation_idx) & ": pos_error = " & to_string(pos_error) & ".", VMEDIUM);
wait_latency(clk, 10);
div_ratio_corr_r := real(to_integer(signed(div_ratio_corr)))/(2.0**24);
div_ratio_corr_rr <= div_ratio_corr_r;
log("Division Ratio Correction =" & to_string(div_ratio_corr_r) & ".", VMEDIUM);
end loop;
wait until running = false;
if(abs(pos_error) > DIV_RATIO) then
error_flag := true;
log("ERROR: simulation ended with a misalignment error bigger than 1 pixel.", VLOW);
end if;
end if;
end process pGET_WH_ERR;
-----------------------------------------------------------------------------
-- Avalon interface
-----------------------------------------------------------------------------
clk_clk <= clk;
reset_reset_n <= reset_n;
avs_s.mm_readdata <= avs_readdata;
avs_s.mm_readdatavalid <= avs_readdatavalid;
avs_s.mm_waitrequest <= '0';
avs_s.use_readvalid <= true;
avs_address <= avs_m.mm_address(avs_address'range);
avs_write <= avs_m.mm_write;
avs_writedata <= avs_m.mm_writedata;
avs_read <= avs_m.mm_read;
pCNT_CH_PD : process(reset_n, clk)
begin
if(reset_n = '0') then
pd_out_cnt <= 0;
elsif(clk = '1' and clk'event) then
if(ch_pd = '1') then
pd_out_cnt <= pd_out_cnt + 1;
end if;
end if;
end process pCNT_CH_PD;
-----------------------------------------------------------------------------
-- Testbench Logic
-----------------------------------------------------------------------------
pSTIMULI : process
begin
end_of_stimuli <= false;
pd_in <= '0';
pd_in_cnt <= 0;
--
abs_position <= INIT_ABS_POS;
wheel_pos <= 0;
-- wait until init is deasserted
wait until falling_edge(init);
wait for 1 us;
-- send the initial PD event
wait until clk = '1' and clk'event;
log("Issueing Initial PD ...", VLOW);
pd_in <= '1';
pd_in_cnt <= pd_in_cnt + 1;
wait until clk = '1' and clk'event;
pd_in <= '0';
while pd_in_cnt < TOTAL_ROTATIONS loop
wait_latency(clk, 50);
abs_position <= std_logic_vector(signed(abs_position)+ 1);
if((wheel_pos + 1) = integer(WHEEL_CIRCUM+real(wheel_error(pd_in_cnt))+0.5)) then
-- it's time to issue a new PD
if(skip_pd = '0') then
pd_in <= '1';
else
log("Skipped PD (PD count = " & to_string(pd_in_cnt) & ").", VLOW);
end if;
pd_in_cnt <= pd_in_cnt + 1;
wheel_pos <= 0;
wait until clk = '1' and clk'event;
pd_in <= '0';
else
wheel_pos <= wheel_pos + 1;
end if;
end loop;
-- completed
end_of_stimuli <= true;
wait;
end process pSTIMULI;
pSKIP_PD : process
begin
if(pd_in_cnt = 47 or pd_in_cnt = 6 or pd_in_cnt = 49 or
pd_in_cnt = 43 or pd_in_cnt = 48 or pd_in_cnt = 55 or
pd_in_cnt = 62 or pd_in_cnt = 71 or pd_in_cnt = 72) then
if(SKIP_PD_EN = true) then
skip_pd <= '1';
end if;
else
skip_pd <= '0';
end if;
wait until clk = '1' and clk'event;
end process pSKIP_PD;
-----------------------------------------------------------------------------
-- Measure Error, Apply external correction
-----------------------------------------------------------------------------
pMEAS_CORR : process
variable measure_started : boolean;
variable pos_error_avail : boolean;
variable start_pos : integer;
alias div_ratio_corr is <<signal iUUT.div_ratio_corr : std_logic_vector(33 downto 0)>>;
alias div_ratio_i is <<signal iUUT.div_ratio_i : std_logic_vector(33 downto 0)>>;
procedure apply_correction(pos_error: in real) is
variable div_ratio_new : real;
variable div_ratio_man : real;
variable div_ratio_vec : std_logic_vector(33 downto 0);
variable tot_error : real;
variable delta_error : real;
begin
-- compute the total and the delta loop error
tot_error := pos_error;
delta_error := pos_error-pos_error_old;
-- Compute the correction through a 2nd order loop filter
div_ratio_new := div_ratio_r + (delta_error*LOOP_FILT_DELTA+tot_error*LOOP_FILT_TOT)*(1.0/real(IMG_LEN));
div_ratio_r <= div_ratio_new;
div_ratio_corr_r <= div_ratio_new - DIV_RATIO;
div_ratio_vec(33 downto 24) := std_logic_vector(to_unsigned(integer(floor(div_ratio_new)),10));
div_ratio_man := (div_ratio_new - floor(div_ratio_new))*(2.0**24);
div_ratio_vec(23 downto 0) := std_logic_vector(to_unsigned(integer(floor(div_ratio_man)),24));
-- force the correction into the UUT:
if(APPLY_EMUL_CORR = true) then
div_ratio_i <= force div_ratio_vec;
end if;
-- save the correction value
log("Division Ratio Correction =" & to_string(div_ratio_new-DIV_RATIO) & ".", VMEDIUM);
end procedure apply_correction;
-- The correction is computed emulating fixed-point numbers
-- (pos_err-to-correction is represented with a 32 bits mantissa)
procedure apply_correction_int(pos_error: in real) is
variable div_ratio_new : real;
variable div_ratio_man : real;
variable div_ratio_vec : std_logic_vector(33 downto 0);
variable pos_err_to_corr : integer := integer(round((1.0/real(IMG_LEN))*(2.0**32)));
variable tot_error : real;
variable delta_error : real;
begin
-- compute the total and the delta loop error
tot_error := pos_error;
delta_error := pos_error-pos_error_old;
if(APPLY_EMUL_CORR = true) then
-- Compute the correction through a 2nd order loop filter
div_ratio_new := div_ratio_r + (delta_error*LOOP_FILT_DELTA+tot_error*LOOP_FILT_TOT)*real(pos_err_to_corr)/(2.0**32);
div_ratio_corr_r <= div_ratio_new - DIV_RATIO;
div_ratio_r <= div_ratio_new;
div_ratio_vec(33 downto 24) := std_logic_vector(to_unsigned(integer(floor(div_ratio_new)),10));
div_ratio_man := (div_ratio_new - floor(div_ratio_new))*(2.0**24);
div_ratio_vec(23 downto 0) := std_logic_vector(to_unsigned(integer(floor(div_ratio_man)),24));
else
div_ratio_new := real(to_integer(unsigned(div_ratio_i(33 downto 24)))) + real(to_integer(unsigned(div_ratio_i(23 downto 0))))/(2.0**24);
div_ratio_corr_r <= div_ratio_new - DIV_RATIO;
div_ratio_r <= div_ratio_new;
end if;
--log("tot_error = " & to_string(tot_error) & ", delta_error = " & to_string(delta_error), VMEDIUM);
--log("tot_error-norm = " & to_string(256.0*tot_error) & ", delta_error-norm = " & to_string(256.0*delta_error), VMEDIUM);
-- force the correction into the UUT:
if(APPLY_EMUL_CORR = true) then
div_ratio_i <= force div_ratio_vec;
end if;
-- save the correction value
log("Division Ratio Correction =" & to_string(div_ratio_new-DIV_RATIO) & ".", VMEDIUM);
end procedure apply_correction_int;
begin
pos_error <= 0.0;
pos_error_old <= 0.0;
rotation_idx <= 0;
div_ratio_corr_r <= 0.0;
div_ratio_r <= DIV_RATIO;
measure_started := false;
pos_error_avail := false;
-- wait until the first PD;
wait until rising_edge(ch_pd);
-- measur the error, then apply correction
while end_of_stimuli = false loop
if SKIP_PD_EN = false then
wait until rising_edge(ch_pd) or falling_edge(ch_mask);
if(rising_edge(ch_pd) and falling_edge(ch_mask)) then
pos_error_old <= pos_error;
pos_error <= -DIV_RATIO;
pos_error_avail := true;
rotation_idx <= rotation_idx + 1;
elsif(rising_edge(ch_pd)) then
if(measure_started = false) then
start_pos := to_integer(signed(abs_position));
measure_started := true;
else
pos_error_old <= pos_error;
pos_error <= real(to_integer(signed(abs_position)) - start_pos) - DIV_RATIO;
rotation_idx <= rotation_idx + 1;
measure_started := false;
pos_error_avail := true;
end if;
elsif(falling_edge(ch_mask)) then
if(measure_started = false) then
start_pos := to_integer(signed(abs_position));
measure_started := true;
else
pos_error_old <= pos_error;
pos_error <= -(real(to_integer(signed(abs_position)) - start_pos)) - DIV_RATIO;
rotation_idx <= rotation_idx + 1;
measure_started := false;
pos_error_avail := true;
end if;
end if;
if(pos_error_avail = true) then
-- Do not remove this wait statement: it makes sures previous signal
-- assignment are executed before computing the corrections
wait until clk = '0' and clk'event;
log("Rotation #" & to_string(rotation_idx) & ": pos_error = " & to_string(pos_error) & ".", VMEDIUM);
if(APPLY_CORR_EN = true) then
--apply_correction(pos_error);
apply_correction_int(pos_error);
end if;
pos_error_avail := false;
end if;
else
-- When PD are skipped, do not try to measure the position error in the
-- testbench
wait until rising_edge(ch_pd);
rotation_idx <= rotation_idx + 1;
wait_latency(clk, 20);
end if;
end loop;
end process pMEAS_CORR;
-----------------------------------------------------------------------------
-- Testbench Main
-----------------------------------------------------------------------------
pTB_CTRL : process
variable addr : std_logic_vector(31 downto 0) := (others => '0');
variable data : std_logic_vector(31 downto 0) := (others => '0');
begin
-- Set the verbosity level for logging
set_log_verbosity(VERBOSITY_LEVEL);
--set_log_verbosity(VHIGH);
-- initilialize the Avalon master-bus
mm_m_init(avs_m);
log_header("Ch-Ctrl Config verification:", VLOW);
setup <= false;
running <= false;
passed <= false;
error_flag := false;
init <= '0';
wheel_corr_on <= '0';
-- Reset
reset_n <= '0';
wait for 100 ns;
wait until clk = '1' and clk'event;
reset_n <= '1';
---------------------------------------------------------------------------
-- Pulse-Generator Configuration
---------------------------------------------------------------------------
wait for 200 ns;
-- Configure Ch-Ctrl RAM
load_seq_cfg(seq_config_file, avs_s, avs_m);
apply_pg_cfg(
div_ratio => DIV_RATIO,
offset_dir0 => PD_OFFSET,
offset_dir1 => 0,
delay => 0,
mm_s_rec => avs_s, mm_m_rec => avs_m);
wheel_corr_on <= '1';
---------------------------------------------------------------------------
-- Movement Simulation
---------------------------------------------------------------------------
log("Forward Movement:", VLOW);
log_separator_line(VLOW);
wait for 200 ns;
wait until clk = '1' and clk'event;
init <= '1';
wait until clk = '1' and clk'event;
wait until clk = '1' and clk'event;
wait until clk = '1' and clk'event;
init <= '0';
wait for 200 ns;
running <= true;
wait until clk = '1' and clk'event;
-- Disable Wheel Correction after a while
if(SIM_ROTATIONS >= 50) then
-- disable wheel corrections
wait until rotation_idx = 30;
wait for 200 ns;
enable_wheel_corr(enable => '0', mm_s_rec => avs_s, mm_m_rec => avs_m);
wheel_corr_on <= '0';
-- re-enable wheel corrections
wait until rotation_idx = 40;
wait for 200 ns;
enable_wheel_corr(enable => '1', mm_s_rec => avs_s, mm_m_rec => avs_m);
wheel_corr_on <= '1';
end if;
wait until (end_of_stimuli = true) or (pd_in_cnt = SIM_ROTATIONS + 1);
running <= false;
passed <= true after 100 ns;
wait;
end process pTB_CTRL;
failed <= error_flag after 100 ns;
pREPORT_RESULT : process
begin
wait until failed = true or passed = true;
wait for 1 us;
log_separator_line(VLOW);
if(failed = true) then
log("FAILURE: test completed with errors.", VLOW);
elsif(passed = true) then
log("SUCCESS: test successfully completed.", VLOW);
end if;
log_separator_line(VLOW);
test_completed <= true;
end process pREPORT_RESULT;
end architecture behav;

View file

@ -0,0 +1,266 @@
##/////////////////////////////////////////////////////////////////////////////
## Title : wheel_correction_analysis
##/////////////////////////////////////////////////////////////////////////////
## File : wheel_correction_analysis.py
## Author : Gianmarco Girau
## Company : GIS
## Target : HMB Console
## Dependency : none
##/////////////////////////////////////////////////////////////////////////////
## Description: Analyze misalignment error from wheel corrections
##/////////////////////////////////////////////////////////////////////////////
## Last update: 2019-05-30
##/////////////////////////////////////////////////////////////////////////////
## Revisions :
## Date Version Author Description
## 2019-05-30 01.00.0a gmg Created
##/////////////////////////////////////////////////////////////////////////////
from bokeh.plotting import figure, output_file, show
from bokeh.layouts import gridplot
from functools import reduce
# log_from_console = 1 => analyze logs from SMB/HMB Console
# log_from_console = 0 => analyze logs from SMB DebugView++
log_from_console = 0
enc_res = 1.41667*1.0e-6
pd_num = []
pd_time = []
pd_pos = []
##/////////////////////////////////////////////////////////////////////////////
## Get data from the log file
##/////////////////////////////////////////////////////////////////////////////
def get_pd_data(data_filename):
global log_from_console
pd_num = []
pd_time = []
pd_pos = []
f_log = open((data_filename), 'r')
if log_from_console == 1:
for line in f_log:
target = '<Detected-PD>'
idx = line.find(target)
if idx != -1:
tmp = line[idx + len(target):].split('#')
clist = tmp[1].split(',')
pd_num.append(int(clist[0]))
# print('PD Event = {:d}'.format(pd_num[-1]))
target = 'Time = '
idx = line.find(target)
clist = line[idx + len(target):].split(None)
pd_time.append(float(clist[0][0:-1]))
target = 'abs_pos = '
idx = line.find(target)
clist = line[idx + len(target):].split(None)
pd_pos.append(float(clist[0][0:-1]))
else:
for line in f_log:
target = 'addToHistory Added Product Detect FIFO entry: entryId: '
idx = line.find(target)
if idx != -1:
clist = line[idx + len(target):].split(None)
pd_num.append(int(clist[0]))
# print('PD Event = {:d}'.format(pd_num[-1]))
target = 'coarseTime: '
idx = line.find(target)
clist = line[idx + len(target):].split(None)
coarse_time = float(clist[0])
target = 'fineTime: '
idx = line.find(target)
clist = line[idx + len(target):].split(None)
fine_time = float(clist[0])
pd_time.append(float(coarse_time)+float(fine_time)*1.0e-8)
target = ' position: '
idx = line.find(target)
clist = line[idx + len(target):].split(None)
pd_pos.append(float(clist[0]))
f_log.closed
return [pd_num, pd_time, pd_pos]
def save_raw_data(pd_num, pd_time, pd_pos, outfile):
f_data = open(outfile, 'w')
f_data.write("PD event, Time, Position" + '\n')
for idx in range(0, len(pd_num)):
f_data.write("{0:d}, {1:f}, {2:f}".format(pd_num[idx], pd_time[idx], pd_pos[idx]) + '\n')
f_data.close
def avg(lst):
return reduce(lambda a, b: a + b, lst) / len(lst)
def plot_pd_dat(pd_num, pd_time, pd_pos, outfile, flexo_label=''):
# output to static HTML file
output_file((outfile) + '.html')
plot_w = 500
plot_h = 500
toolset = "pan,box_zoom,reset,save"
delta_pd = []
N = len(pd_num)
for idx in range(1, N):
delta_pd.append(pd_pos[idx] - pd_pos[idx - 1])
pd_avg = avg(delta_pd)
print("PD average distance = {:f} [encoder pulses]".format(pd_avg))
pd_var = []
pd_var.append(0.0)
for idx in range(1, N):
pd_var.append(delta_pd[idx-1]-pd_avg)
data_range = max(delta_pd)-min(delta_pd)
if data_range == 0.0:
data_range = 1.0
plot_range = [min(delta_pd)-data_range, max(delta_pd)+data_range]
# PD variation on a cycle-by-cycle basis
pd_cbc = []
pd_cbc.append(0.0)
for idx in range(1, N):
pd_cbc.append(pd_var[idx]-pd_var[idx-1])
print("Maximum variation on a cycle basis = {0}".format(max(pd_cbc)))
print("Minimum variation on a cycle basis = {0}".format(min(pd_cbc)))
# Compute the average linear encoder speed over a Flexo wheel rotation
enc_speed = []
enc_speed.append(0.0)
enc_speed.append(0.0)
for idx in range(1, N):
enc_speed.append(enc_res*delta_pd[idx-1]/(pd_time[idx]-pd_time[idx-1]))
# create a new plot
this_legend = 'Min = {0:f}'.format(min(delta_pd)) + '\n' + 'Max = {0:f}'.format(max(delta_pd))
s1 = figure(width=plot_w, plot_height=plot_h, title='PD distance [encoder pulses]', x_axis_label='PD Event',
y_axis_label='PD distance [encoder pulses]', tools=toolset,y_range=plot_range)
s1.circle(pd_num[1:], delta_pd, size=5, color="navy", alpha=0.5, legend=this_legend)
data_range = max(pd_var)-min(pd_var)
if data_range == 0.0:
data_range = 1.0
plot_range = [min(pd_var)-data_range, max(pd_var)+data_range]
this_legend = 'Min = {0:f}'.format(min(pd_var[1:N])) + '\n' + 'Max = {0:f}'.format(max(pd_var[1:N]))
s2 = figure(width=plot_w, height=plot_h, x_range=s1.x_range, y_range=plot_range, title='PD variation from average',
x_axis_label='PD Event', y_axis_label='PD Variation from average[Encoder Steps]',
tools=toolset)
s2.triangle(pd_num[1:], pd_var[1:N], size=10, color="olive", alpha=0.5, legend=this_legend)
data_range = max(pd_cbc)-min(pd_cbc)
if data_range == 0.0:
data_range = 1.0
plot_range = [min(pd_cbc)-data_range, max(pd_cbc)+data_range]
this_legend = 'Min = {0:f}'.format(min(pd_cbc[1:N])) + '\n' + 'Max = {0:f}'.format(max(pd_cbc[1:N]))
s3 = figure(width=plot_w, height=plot_h, x_range=s1.x_range, y_range=plot_range,
title='PD distance variation from the previous rotation',
x_axis_label='PD Event', y_axis_label='PD Variation [Encoder Steps]',
tools=toolset)
s3.circle(pd_num[1:], pd_cbc[1:N], size=10, color="firebrick", alpha=0.5,legend=this_legend)
data_range = max(enc_speed) - min(enc_speed)
if data_range == 0.0:
data_range = 1.0
plot_range = [min(enc_speed) - data_range, max(enc_speed) + data_range]
s4 = figure(width=plot_w, height=plot_h, x_range=s1.x_range, y_range=plot_range, title='Average linear encoder speed over a Flexo wheel rotation',
x_axis_label='PD Event', y_axis_label='Encoder Velocity',
tools=toolset)
s4.triangle(pd_num[1:], enc_speed[2:N+1], size=10, color="navy", alpha=0.5)
p = gridplot([[s1], [s2], [s3], [s4]])
#p = gridplot([[s1]])
# show the results
show(p)
##/////////////////////////////////////////////////////////////////////////////
## Plot-data
##/////////////////////////////////////////////////////////////////////////////
#1
#data_set = 'data-set'
data_set = './MiRAFLEX-tests-2019-09-13/2019-09-13_10mmin_direct_no_pd_maschine'
data_file = "{0}.txt".format(data_set)
csv_file = "{0}.csv".format(data_set)
[pd_num, pd_time, pd_pos] = get_pd_data(data_file)
save_raw_data(pd_num, pd_time, pd_pos, csv_file)
plot_pd_dat(pd_num, pd_time, pd_pos, data_set)
#2
data_set = './MiRAFLEX-tests-2019-09-13/2019-09-13_10mmin_no_pd_mschine'
data_file = "{0}.txt".format(data_set)
csv_file = "{0}.csv".format(data_set)
[pd_num, pd_time, pd_pos] = get_pd_data(data_file)
save_raw_data(pd_num, pd_time, pd_pos, csv_file)
plot_pd_dat(pd_num, pd_time, pd_pos, data_set)
#3
data_set = './MiRAFLEX-tests-2019-09-13/2019-09-13_15mmin_ramp_no_pd_maschine'
data_file = "{0}.txt".format(data_set)
csv_file = "{0}.csv".format(data_set)
[pd_num, pd_time, pd_pos] = get_pd_data(data_file)
save_raw_data(pd_num, pd_time, pd_pos, csv_file)
plot_pd_dat(pd_num, pd_time, pd_pos, data_set)
#4
data_set = './MiRAFLEX-tests-2019-09-13/2019-09-13_20mmin_direct_no_pd_maschine'
data_file = "{0}.txt".format(data_set)
csv_file = "{0}.csv".format(data_set)
[pd_num, pd_time, pd_pos] = get_pd_data(data_file)
save_raw_data(pd_num, pd_time, pd_pos, csv_file)
plot_pd_dat(pd_num, pd_time, pd_pos, data_set)
#5
data_set = './MiRAFLEX-tests-2019-09-13/2019-09-13_20mmin_direct_no_pd_maschine_02'
data_file = "{0}.txt".format(data_set)
csv_file = "{0}.csv".format(data_set)
[pd_num, pd_time, pd_pos] = get_pd_data(data_file)
save_raw_data(pd_num, pd_time, pd_pos, csv_file)
plot_pd_dat(pd_num, pd_time, pd_pos, data_set)
#6
data_set = './MiRAFLEX-tests-2019-09-13/2019-09-13_30mmin_ramp_no_pd_maschine'
data_file = "{0}.txt".format(data_set)
csv_file = "{0}.csv".format(data_set)
[pd_num, pd_time, pd_pos] = get_pd_data(data_file)
save_raw_data(pd_num, pd_time, pd_pos, csv_file)
plot_pd_dat(pd_num, pd_time, pd_pos, data_set)
#7
data_set = './MiRAFLEX-tests-2019-09-13/2019-09-13_30mmin_ramp_no_pd_maschine_02'
data_file = "{0}.txt".format(data_set)
csv_file = "{0}.csv".format(data_set)
[pd_num, pd_time, pd_pos] = get_pd_data(data_file)
save_raw_data(pd_num, pd_time, pd_pos, csv_file)
plot_pd_dat(pd_num, pd_time, pd_pos, data_set)

View file

@ -0,0 +1,76 @@
# HMB log file
< 2019_07_30_h09:39:37 > Loading Configuration file ./config/default.cfg
< 2019_07_30_h09:39:37 > Encoder Resolution = 20.0000000000
< 2019_07_30_h09:39:37 > Print-Head Resolution type = dpi
< 2019_07_30_h09:39:37 > Print-Head Resolution = 1200.0000000000
< 2019_07_30_h09:39:37 > Encoder Source = 0
< 2019_07_30_h09:39:37 > Internal Encoder Frequency = 5000.0000000000
< 2019_07_30_h09:39:37 > Encoder Phase = 1
< 2019_07_30_h09:39:37 > Encoder Edge = 2
< 2019_07_30_h09:39:37 > Encoder Directionality = 0
< 2019_07_30_h09:39:37 > PD Source = 3
< 2019_07_30_h09:39:37 > PD Edge = 0
< 2019_07_30_h09:39:37 > Print-Mode = Continuous
< 2019_07_30_h09:39:37 > PD-Type = None
< 2019_07_30_h09:39:37 > Image Length = 0.0000000000 pixel
< 2019_07_30_h09:39:37 > Gap Length = 0.0000000000 pixel
< 2019_07_30_h09:39:37 > Print-Head Width = 0.0000000000 pixel
< 2019_07_30_h09:39:37 > Forward-Pass Pre-Print Buffer Length = 0.0000000000 pixel
< 2019_07_30_h09:39:37 > Swathe Length = 0.0000000000 pixel
< 2019_07_30_h09:39:37 > Reverse-Pass Offset = 0.0000000000 pixel
< 2019_07_30_h09:39:37 > Pre-Print Additional Movement = 0.0000000000 mm
< 2019_07_30_h09:39:37 > Daisy-Chain Enable = 1
< 2019_07_30_h09:39:37 > Daisy-Chain Position = 1
< 2019_07_30_h09:39:37 > Daisy-Chain Length = 1
< 2019_07_30_h09:39:37 > Configuration file loaded.
< 2019_07_30_h09:39:37 > Make sure to be connected to the EMB Server and press the button 'Apply' to configure the EMB
< 2019_07_30_h09:39:37 > Starting Remote-Server on port 6124
< 2019_07_30_h09:39:46 > ERROR: Unable to connect to the EMB-server on IP address 192.168.79.139
< 2019_07_30_h09:40:21 > Opened connection to IP 192.168.79.139, Port 6121
< 2019_07_30_h09:40:21 > show server.version
< 2019_07_30_h09:40:21 > hmb_remote_server version 1.10016.0.5356
< 2019_07_30_h09:40:21 > show fpm_ctrl.fw_info
< 2019_07_30_h09:40:21 > GIS-HMB Board - Firmware version is F003
< 2019_07_30_h09:40:23 > set diag.pd_watchdog_enable 0 0.1
< 2019_07_30_h09:40:23 > set diag.polling 7 200
< 2019_07_30_h09:42:49 > show print.force_all_zeros
< 2019_07_30_h09:42:49 > 0
< 2019_07_30_h09:43:05 > set pg.wh_wheel_corr 1 4827
< 2019_07_30_h09:43:05 > W&H - Wheel Correction Enabled
< 2019_07_30_h09:43:30 > <Detected-PD> Event-Number #1, Time = 500.092 s, Positition = 101.540000 mm (abs_pos = 20308)
< 2019_07_30_h09:43:37 > <Wheel-Correction> - Rotation Count = 1, Position Error = -2.000, Division-Ratio Correction = -0.00331500
< 2019_07_30_h09:43:37 > <Detected-PD> Event-Number #2, Time = 506.773 s, Positition = 198.080000 mm (abs_pos = 39616)
< 2019_07_30_h09:43:44 > <Wheel-Correction> - Rotation Count = 2, Position Error = 1.000, Division-Ratio Correction = -0.00000000
< 2019_07_30_h09:43:44 > <Detected-PD> Event-Number #3, Time = 513.464 s, Positition = 294.620000 mm (abs_pos = 58924)
< 2019_07_30_h09:43:46 > <Detected-PD> Event-Number #4, Time = 515.962 s, Positition = 391.160000 mm (abs_pos = 78232)
< 2019_07_30_h09:43:47 > <Wheel-Correction> - Rotation Count = 3, Position Error = 2.000, Division-Ratio Correction = 0.00248600
< 2019_07_30_h09:43:49 > <Wheel-Correction> - Rotation Count = 4, Position Error = -1.000, Division-Ratio Correction = -0.00082900
< 2019_07_30_h09:43:49 > <Detected-PD> Event-Number #5, Time = 518.668 s, Positition = 487.700000 mm (abs_pos = 97540)
< 2019_07_30_h09:43:51 > <Detected-PD> Event-Number #6, Time = 520.496 s, Positition = 584.240000 mm (abs_pos = 116848)
< 2019_07_30_h09:43:51 > <Wheel-Correction> - Rotation Count = 5, Position Error = 0.000, Division-Ratio Correction = -0.00000000
< 2019_07_30_h09:43:52 > <Detected-PD> Event-Number #7, Time = 522.121 s, Positition = 680.780000 mm (abs_pos = 136156)
< 2019_07_30_h09:43:53 > <Wheel-Correction> - Rotation Count = 6, Position Error = 0.000, Division-Ratio Correction = -0.00000000
< 2019_07_30_h09:43:54 > <Detected-PD> Event-Number #8, Time = 523.475 s, Positition = 777.320000 mm (abs_pos = 155464)
< 2019_07_30_h09:43:54 > <Wheel-Correction> - Rotation Count = 7, Position Error = 0.000, Division-Ratio Correction = -0.00000000
< 2019_07_30_h09:44:12 > <Detected-PD> Event-Number #9, Time = 542.085 s, Positition = 872.320000 mm (abs_pos = 174464)
< 2019_07_30_h09:44:14 > <Wheel-Correction> - Rotation Count = 8, Position Error = -1.000, Division-Ratio Correction = -0.51046200
< 2019_07_30_h09:44:15 > <Detected-PD> Event-Number #10, Time = 544.155 s, Positition = 967.320000 mm (abs_pos = 193464)
< 2019_07_30_h09:44:15 > <Wheel-Correction> - Rotation Count = 9, Position Error = -1.000, Division-Ratio Correction = -0.25688900
< 2019_07_30_h09:44:17 > <Wheel-Correction> - Rotation Count = 10, Position Error = 2.000, Division-Ratio Correction = -0.25274600
< 2019_07_30_h09:44:17 > <Detected-PD> Event-Number #11, Time = 546.342 s, Positition = 1062.320000 mm (abs_pos = 212464)
< 2019_07_30_h09:44:19 > <Detected-PD> Event-Number #12, Time = 548.990 s, Positition = 1157.320000 mm (abs_pos = 231464)
< 2019_07_30_h09:44:20 > <Wheel-Correction> - Rotation Count = 11, Position Error = -1.000, Division-Ratio Correction = -0.25606000
< 2019_07_30_h09:44:22 > <Detected-PD> Event-Number #13, Time = 551.806 s, Positition = 1252.320000 mm (abs_pos = 250464)
< 2019_07_30_h09:44:22 > <Wheel-Correction> - Rotation Count = 12, Position Error = 0.000, Division-Ratio Correction = -0.25523200
< 2019_07_30_h09:44:24 > <Detected-PD> Event-Number #14, Time = 553.494 s, Positition = 1347.320000 mm (abs_pos = 269464)
< 2019_07_30_h09:44:24 > <Wheel-Correction> - Rotation Count = 13, Position Error = 0.000, Division-Ratio Correction = -0.25523200
< 2019_07_30_h09:44:25 > <Wheel-Correction> - Rotation Count = 14, Position Error = 0.000, Division-Ratio Correction = -0.25523200
< 2019_07_30_h09:44:25 > <Detected-PD> Event-Number #15, Time = 554.990 s, Positition = 1442.320000 mm (abs_pos = 288464)
< 2019_07_30_h09:59:11 > set diag.polling 0 200
< 2019_07_30_h09:59:11 > set server.disconnect
< 2019_07_30_h09:59:11 > Closed connection to 192.168.79.139
< 2019_07_30_h09:59:11 > <Wheel-Correction> - Rotation Count = -1, Position Error = 0.000, Division-Ratio Correction = -1.00000000
< 2019_07_30_h09:59:43 > Closing EMB Console ...

View file

@ -0,0 +1,181 @@
##/////////////////////////////////////////////////////////////////////////////
## Title : wheel_correction_analysis
##/////////////////////////////////////////////////////////////////////////////
## File : wheel_correction_analysis.py
## Author : Gianmarco Girau
## Company : GIS
## Target : HMB Console
## Dependency : none
##/////////////////////////////////////////////////////////////////////////////
## Description: Analyze misalignment error from wheel corrections
##/////////////////////////////////////////////////////////////////////////////
## Last update: 2019-05-30
##/////////////////////////////////////////////////////////////////////////////
## Revisions :
## Date Version Author Description
## 2019-05-30 01.00.0a gmg Created
##/////////////////////////////////////////////////////////////////////////////
from bokeh.plotting import figure, output_file, show
from bokeh.layouts import gridplot
rotation_idx = []
pos_err = []
pitch_corr = []
pd_num = []
pd_time = []
pd_pos = []
log_file_name = './hmb_log2.txt'
data_file_name = './pitch_corr.csv'
pd_file_name = './pd_log.csv'
plot_file_name_1 = './pitch_corr_1.html'
plot_file_name_2 = './pitch_corr_2.html'
plot_file_name_3 = './delta_pd.html'
##/////////////////////////////////////////////////////////////////////////////
## Get data from the log file
##/////////////////////////////////////////////////////////////////////////////
f_log = open(log_file_name, 'r')
for line in f_log:
target = '<Wheel-Correction> - '
idx =line.find(target)
if idx != -1:
target = 'Rotation Count = '
idx = line.find(target)
clist = line[idx+len(target):].split(None)
rotation_idx.append(int(clist[0][0:-1]))
target = 'Position Error = '
idx = line.find(target)
clist = line[idx + len(target):].split(None)
pos_err.append(float(clist[0][0:-1]))
target = 'Division-Ratio Correction = '
idx = line.find(target)
clist = line[idx + len(target):].split(None)
pitch_corr.append(float(clist[0][0:-1]))
#print("Rotation Idx = {0:d}, Position-Error = {1:f}, Pixel-Pitch-Correction = {2:f}".format(rotation_idx[-1], pos_err[-1], pitch_corr[-1]))
f_log.closed
f_log = open(log_file_name, 'r')
for line in f_log:
target = '<Detected-PD>'
idx =line.find(target)
if idx != -1:
tmp = line[idx + len(target):].split('#')
clist = tmp[1].split(',')
pd_num.append(int(clist[0]))
#print('PD Event = {:d}'.format(pd_num[-1]))
target = 'Time = '
idx = line.find(target)
clist = line[idx + len(target):].split(None)
pd_time.append(float(clist[0][0:-1]))
target = 'abs_pos = '
idx = line.find(target)
clist = line[idx + len(target):].split(None)
pd_pos.append(float(clist[0][0:-1]))
f_log.closed
# Save data on a separate CSV file
f_data = open(data_file_name, 'w')
f_data.write("Rotation index, Position Error, Pixel-Pitch Correction" + '\n')
for idx in range(0,len(rotation_idx)):
f_data.write("{0:d}, {1:f}, {2:f}".format(rotation_idx[idx], pos_err[idx], pitch_corr[idx]) + '\n')
f_data.close
f_data = open(pd_file_name, 'w')
f_data.write("PD event, Time, Position" + '\n')
for idx in range(0,len(pd_num)):
f_data.write("{0:d}, {1:f}, {2:f}".format(pd_num[idx], pd_time[idx], pd_pos[idx]) + '\n')
f_data.close
##/////////////////////////////////////////////////////////////////////////////
## Plot-data
##/////////////////////////////////////////////////////////////////////////////
# output to static HTML file
output_file(plot_file_name_1)
plot_w = 500
plot_h = 500
toolset="pan,box_zoom,reset,save"
# create a new plot
s1 = figure(width=plot_w, plot_height=plot_h, title='Position Error', x_axis_label='Flexo Wheel Rotation', y_axis_label='Position Error [Encoder Steps]', tools=toolset)
s1.circle(rotation_idx, pos_err, size=5, color="navy", alpha=0.5)
s2 = figure(width=plot_w, height=plot_h, x_range=s1.x_range, y_range=s1.y_range, title='Pixel-Pitch Correction', x_axis_label='Flexo Wheel Rotation', y_axis_label='Pixel-Pitch Correction [Encoder Steps]', tools=toolset)
s2.triangle(rotation_idx, pitch_corr, size=10, color="olive", alpha=0.5)
#p = gridplot([[s1], [s2]], toolbar_location=None)
p = gridplot([[s1], [s2]])
# show the results
show(p)
# Create a second plot in um
# output to static HTML file
output_file(plot_file_name_2)
enc_res = 5
head_reas = 21.167
pos_err_um = [x*enc_res for x in pos_err]
pitch_corr_um = [x*enc_res for x in pitch_corr]
plot_w = 500
plot_h = 500
toolset="pan,box_zoom,reset,save"
# create a new plot
s1 = figure(width=plot_w, plot_height=plot_h, title='Position Error', x_axis_label='Flexo Wheel Rotation', y_axis_label='Position Error [um]', tools=toolset)
s1.circle(rotation_idx, pos_err_um, size=5, color="navy", alpha=0.5)
s2 = figure(width=plot_w, height=plot_h, x_range=s1.x_range, y_range=s1.y_range, title='Pixel-Pitch Correction', x_axis_label='Flexo Wheel Rotation', y_axis_label='Pixel-Pitch Correction [um]', tools=toolset)
s2.triangle(rotation_idx, pitch_corr_um, size=10, color="olive", alpha=0.5)
#p = gridplot([[s1], [s2]], toolbar_location=None)
p = gridplot([[s1], [s2]])
# show the results
show(p)
# output to static HTML file
output_file(plot_file_name_3)
plot_w = 500
plot_h = 500
toolset="pan,box_zoom,reset,save"
delta_pd = []
N = len(pd_num)
for idx in range(1,N):
delta_pd.append(pd_pos[idx] - pd_pos[idx-1])
# create a new plot
s1 = figure(width=plot_w, plot_height=plot_h, title='PD distance [encoder pulses]', x_axis_label='PD Event', y_axis_label='PD distance [encoder pulses]', tools=toolset)
s1.circle(pd_num[1:], delta_pd, size=5, color="navy", alpha=0.5)
#p = gridplot([[s1], [s2]], toolbar_location=None)
p = gridplot([[s1]])
# show the results
show(p)

View file

@ -0,0 +1,593 @@
-------------------------------------------------------------------------------
-- Title : pd_jitter_verify_tb
-- Project : EMB/SMB
-------------------------------------------------------------------------------
-- File : pd_jitter_verify_tb.vhd
-- Author : GMG
-- Company : Global Inkjet Systems
-- Created : 2018-09-11
-- Last update: 2020-04-15
-- SVN ID : Git
-- Standard : VHDL'2008
-------------------------------------------------------------------------------
-- Description:
-- Verify the PD jitter mechanism on the Pulse-Generator
-------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.math_real.all;
use work.log_pkg.all;
use work.avalon_verify_pkg.all;
use work.pulse_generator_4_pkg.all;
entity pd_jitter_verify_tb is
-- ..
end entity pd_jitter_verify_tb;
architecture behav of pd_jitter_verify_tb is
constant CLK_PERIOD : time := 10 ns;
-- Logging Verbosity Level
constant VERBOSITY_LEVEL : verb_level_t := VMEDIUM;
-----------------------------------------------------------------------------
-- TB Functions / Procedures
-----------------------------------------------------------------------------
procedure wait_latency(
signal clk : in std_logic;
cycles : in natural) is
begin
for i in 1 to cycles loop
wait until clk = '1' and clk'event;
end loop; -- i
end procedure wait_latency;
-----------------------------------------------------------------------------
-- Signal declarations
-----------------------------------------------------------------------------
signal reset_n : std_logic := '0';
signal clk : std_logic := '0';
signal init : std_logic;
signal pd_in : std_logic;
signal abs_position : std_logic_vector(31 downto 0);
signal dp_dir : std_logic;
signal fire_req : std_logic;
signal fire_req_vec : std_logic_vector(31 downto 0);
signal filtered_pd : std_logic;
signal ch_pd : std_logic;
signal ch_mask : std_logic;
signal raw_fire_req : std_logic;
signal avs_address : std_logic_vector(10 downto 0);
signal avs_write : std_logic;
signal avs_writedata : std_logic_vector(31 downto 0);
signal avs_read : std_logic;
signal avs_readdatavalid : std_logic;
signal avs_readdata : std_logic_vector(31 downto 0);
--
signal avs_m : mm_m_rec_t;
signal avs_s : mm_s_rec_t;
--
signal pd_in_cnt : integer;
signal pd_out_cnt : integer;
--
signal test_completed : boolean;
signal setup : boolean;
signal running : boolean;
signal error_flag : boolean;
signal passed : boolean;
signal failed : boolean;
begin -- architecture behav
clk <= not clk after 0.5*CLK_PERIOD;
-----------------------------------------------------------------------------
-- UUT
-----------------------------------------------------------------------------
iUUT: entity work.pulse_generator_4
generic map (
pulse_delay_equal_en => true)
port map (
clk => clk,
reset_n => reset_n,
init => init,
pd_in => pd_in,
abs_position => abs_position,
dp_dir => dp_dir,
fire_req_vec => fire_req_vec,
filtered_pd => filtered_pd,
ch_pd => ch_pd,
ch_mask => ch_mask,
raw_fire_req => raw_fire_req,
avs_address => avs_address,
avs_write => avs_write,
avs_writedata => avs_writedata,
avs_read => avs_read,
avs_readdata => avs_readdata);
fire_req <= fire_req_vec(0);
-----------------------------------------------------------------------------
-- Avalon interface
-----------------------------------------------------------------------------
clk_clk <= clk;
reset_reset_n <= reset_n;
avs_s.mm_readdata <= avs_readdata;
avs_s.mm_readdatavalid <= avs_readdatavalid;
avs_s.mm_waitrequest <= '0';
avs_s.use_readvalid <= true;
avs_address <= avs_m.mm_address(avs_address'range);
avs_write <= avs_m.mm_write;
avs_writedata <= avs_m.mm_writedata;
avs_read <= avs_m.mm_read;
pCNT_CH_PD : process(reset_n, clk)
begin
if(reset_n = '0') then
pd_out_cnt <= 0;
elsif(clk = '1' and clk'event) then
if(ch_pd = '1') then
pd_out_cnt <= pd_out_cnt + 1;
end if;
end if;
end process pCNT_CH_PD;
-----------------------------------------------------------------------------
-- Testbench Logic
-----------------------------------------------------------------------------
pTB_CTRL : process
alias dp_dir is <<signal iUUT.dp_dir_i : std_logic>>;
procedure issue_pd(valid_pd : boolean := true) is
begin
wait until clk = '1' and clk'event;
pd_in <= '1';
wait until clk = '1' and clk'event;
pd_in <= '0';
if(valid_pd = true) then
pd_in_cnt <= pd_in_cnt + 1;
end if;
end procedure issue_pd;
procedure check_pd is
begin
for i in 1 to 12 loop
wait until clk = '1' and clk'event;
end loop; -- i
if(pd_out_cnt /= pd_in_cnt) then
if(pd_out_cnt > pd_in_cnt) then
log("ERROR: Detected faulty Channel PD.", VLOW);
else
log("ERROR: Missing Channel PD.", VLOW);
end if;
error_flag <= true;
end if;
end procedure check_pd;
variable addr : std_logic_vector(31 downto 0) := (others => '0');
variable data : std_logic_vector(31 downto 0) := (others => '0');
begin
-- Set the verbosity level for logging
set_log_verbosity(VERBOSITY_LEVEL);
--set_log_verbosity(VHIGH);
-- initilialize the Avalon master-bus
mm_m_init(avs_m);
log_header("PD Jitter verification:", VLOW);
setup <= false;
running <= false;
passed <= false;
error_flag <= false;
init <= '0';
pd_in <= '0';
pd_in_cnt <= 0;
abs_position <= (others => '0');
-- Reset
reset_n <= '0';
wait for 100 ns;
wait until clk = '1' and clk'event;
reset_n <= '1';
wait for 200 ns;
-- enable the pulse generator
addr := std_logic_vector(resize(unsigned(CSR_PULSE_GEN_CONTROL_W_ADDR), 32));
data := X"0000_0001";
mm_32b_write(addr, data, avs_s, avs_m);
---------------------------------------------------------------------------
-- DP-DIR = '0'
---------------------------------------------------------------------------
log("DP-DIR = '0'", VLOW);
log_separator_line(VLOW);
dp_dir <= force '0';
wait for 200 ns;
wait until clk = '1' and clk'event;
init <= '1';
wait until clk = '1' and clk'event;
wait until clk = '1' and clk'event;
wait until clk = '1' and clk'event;
init <= '0';
wait for 200 ns;
wait until clk = '1' and clk'event;
---------------------------------------------------------------------------
-- DIR-0, Init Pos = 0
---------------------------------------------------------------------------
log("Issueing PD on ABS_POS = 0", VLOW);
for n in 0 to 9 loop
issue_pd;
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)+ 1);
end loop; -- n
log("Go back to ABS_POS = 0", VLOW);
for n in 0 to 9 loop
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)- 1);
end loop; -- n
log("Issueing again PD on ABS_POS = 0", VLOW);
for n in 0 to 9 loop
issue_pd(false);
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)+ 1);
end loop; -- n
for n in 0 to 9 loop
issue_pd;
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)+ 1);
end loop; -- n
wait for 1 us;
---------------------------------------------------------------------------
-- DIR-0, Init Pos = -10
---------------------------------------------------------------------------
log("Issueing PD DIR-0, on ABS_POS = -10", VLOW);
abs_position <= std_logic_vector(to_signed(-10,32));
wait_latency(clk, 3);
init <= '1';
wait_latency(clk, 2);
init <= '0';
wait_latency(clk, 10);
log("Issueing PD on ABS_POS = -10", VLOW);
for n in 0 to 9 loop
issue_pd;
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)+ 1);
end loop; -- n
log("Go back to ABS_POS = -10", VLOW);
for n in 0 to 9 loop
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)- 1);
end loop; -- n
log("Issueing again PD on ABS_POS = -10", VLOW);
for n in 0 to 9 loop
issue_pd(false);
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)+ 1);
end loop; -- n
for n in 0 to 9 loop
issue_pd;
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)+ 1);
end loop; -- n
wait for 1 us;
---------------------------------------------------------------------------
-- DIR-0, Mid-crossing
---------------------------------------------------------------------------
log_separator_line(VLOW);
log("DP-DIR = '0', Mid-Crossing", VLOW);
log_separator_line(VLOW);
abs_position <= X"7FFFFFF8";
wait_latency(clk, 3);
init <= '1';
wait_latency(clk, 2);
init <= '0';
wait_latency(clk, 10);
log("Issueing PD on ABS_POS = 0x7FFFFFF8", VLOW);
for n in 0 to 15 loop
issue_pd;
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)+ 1);
end loop; -- n
log("Go back to ABS_POS = 0x7FFFFFF8", VLOW);
for n in 0 to 15 loop
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)- 1);
end loop; -- n
log("Issueing again PD on ABS_POS = 0x7FFFFFF8", VLOW);
for n in 0 to 15 loop
issue_pd(false);
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)+ 1);
end loop; -- n
for n in 0 to 15 loop
issue_pd;
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)+ 1);
end loop; -- n
log("Performing a zero-crossing", VLOW);
wait_latency(clk, 10);
abs_position <= std_logic_vector(to_signed(-10,32));
wait_latency(clk, 10);
issue_pd;
for n in 0 to 19 loop
abs_position <= std_logic_vector(signed(abs_position)+ 1);
wait_latency(clk, 10);
end loop; -- n
issue_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)+ 1);
wait_latency(clk, 10);
abs_position <= X"7FFFFFF8";
log("Issueing a second set of PDs at ABS_POS = 0x7FFFFFF8", VLOW);
wait_latency(clk, 10);
for n in 0 to 15 loop
issue_pd;
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)+ 1);
end loop; -- n
wait for 1 us;
---------------------------------------------------------------------------
-- DP-DIR = '1'
---------------------------------------------------------------------------
log_separator_line(VLOW);
log("DP-DIR = '1'", VLOW);
log_separator_line(VLOW);
dp_dir <= force '1';
abs_position <= std_logic_vector(to_signed(0,32));
wait for 200 ns;
wait until clk = '1' and clk'event;
init <= '1';
wait until clk = '1' and clk'event;
wait until clk = '1' and clk'event;
wait until clk = '1' and clk'event;
init <= '0';
wait for 200 ns;
wait until clk = '1' and clk'event;
---------------------------------------------------------------------------
-- DIR-1, Init Pos = 0
---------------------------------------------------------------------------
log("Issueing PD on ABS_POS = 0", VLOW);
for n in 0 to 9 loop
issue_pd;
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)- 1);
end loop; -- n
log("Go back to ABS_POS = 0", VLOW);
for n in 0 to 9 loop
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)+ 1);
end loop; -- n
log("Issueing again PD on ABS_POS = 0", VLOW);
for n in 0 to 9 loop
issue_pd(false);
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)- 1);
end loop; -- n
for n in 0 to 9 loop
issue_pd;
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)- 1);
end loop; -- n
wait for 1 us;
---------------------------------------------------------------------------
-- DIR-1, Init Pos = +10
---------------------------------------------------------------------------
abs_position <= std_logic_vector(to_signed(+10,32));
wait_latency(clk, 3);
init <= '1';
wait_latency(clk, 2);
init <= '0';
wait_latency(clk, 10);
log("Issueing PD on ABS_POS = +10", VLOW);
for n in 0 to 9 loop
issue_pd;
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)- 1);
end loop; -- n
log("Go back to ABS_POS = +10", VLOW);
for n in 0 to 9 loop
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)+ 1);
end loop; -- n
log("Issueing again PD on ABS_POS = +10", VLOW);
for n in 0 to 9 loop
issue_pd(false);
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)- 1);
end loop; -- n
for n in 0 to 9 loop
issue_pd;
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)- 1);
end loop; -- n
wait for 1 us;
---------------------------------------------------------------------------
-- DIR-1, Mid-crossing
---------------------------------------------------------------------------
log_separator_line(VLOW);
log("DP-DIR = '1', Mid-Crossing", VLOW);
log_separator_line(VLOW);
abs_position <= X"80000008";
wait_latency(clk, 3);
init <= '1';
wait_latency(clk, 2);
init <= '0';
wait_latency(clk, 10);
log("Issueing PD on ABS_POS = 0x80000008", VLOW);
for n in 0 to 15 loop
issue_pd;
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)- 1);
end loop; -- n
log("Go back to ABS_POS = 0x80000008", VLOW);
for n in 0 to 15 loop
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)+ 1);
end loop; -- n
log("Issueing again PD on ABS_POS = 0x80000008", VLOW);
for n in 0 to 15 loop
issue_pd(false);
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)- 1);
end loop; -- n
for n in 0 to 15 loop
issue_pd;
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)- 1);
end loop; -- n
log("Performing a zero-crossing", VLOW);
wait_latency(clk, 10);
abs_position <= std_logic_vector(to_signed(+10,32));
wait_latency(clk, 10);
issue_pd;
for n in 0 to 19 loop
abs_position <= std_logic_vector(signed(abs_position)- 1);
wait_latency(clk, 10);
end loop; -- n
issue_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)- 1);
wait_latency(clk, 10);
abs_position <= X"80000008";
log("Issueing a second set of PDs at ABS_POS = 0x80000008", VLOW);
wait_latency(clk, 10);
for n in 0 to 15 loop
issue_pd;
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)- 1);
end loop; -- n
wait for 20 us;
running <= false;
passed <= true after 100 ns;
wait;
end process pTB_CTRL;
failed <= error_flag after 100 ns;
pREPORT_RESULT : process
begin
wait until failed = true or passed = true;
wait for 1 us;
log_separator_line(VLOW);
if(failed = true) then
log("FAILURE: test completed with errors.", VLOW);
elsif(passed = true) then
log("SUCCESS: test successfully completed.", VLOW);
end if;
log_separator_line(VLOW);
test_completed <= true;
end process pREPORT_RESULT;
end architecture behav;

View file

@ -0,0 +1,655 @@
-------------------------------------------------------------------------------
-- Title : simple_frac_div_tb
-- Project : EMB/SMB
-------------------------------------------------------------------------------
-- File : simple_frac_div_tb.vhd
-- Author : GMG
-- Company : Global Inkjet Systems
-- Created : 2017-12-06
-- Last update: 2019-12-02
-- SVN ID : Git
-- Standard : VHDL'2008
-------------------------------------------------------------------------------
-- Description:
-- Testbench for the simple_frac_div.vhd
-------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.math_real.all;
library OSVVM;
use OSVVM.RandomBasePkg.all;
use OSVVM.RandomPkg.all;
use work.log_pkg.all;
entity simple_frac_div_tb is
-- ..
end entity simple_frac_div_tb;
architecture behav of simple_frac_div_tb is
constant CLK_PERIOD : time := 10 ns;
-- Logging Verbosity Level
constant VERBOSITY_LEVEL : verb_level_t := VMEDIUM;
constant MAX_DIST : natural := 10000;
-- define the percentage of reverse steps, with respect to the intended
-- direction, while advancing the position:
-- 0 => no reverse movement at all
-- 20 => 20% of position increments are in the opposite dirtection
-- 49 => Essentially this is an oscillation around the centre position with a
-- tiny bias in the intended direction!
constant POS_RANDOM_PERC : natural range 0 to 49 := 0; -- define
constant INTRA_POS_LATENCY : natural := 5; -- number of clock cycles between position increments
-----------------------------------------------------------------------------
-- TB Functions / Procedures
-----------------------------------------------------------------------------
procedure wait_latency(
signal clk : in std_logic;
cycles : in natural) is
begin
for i in 1 to cycles loop
wait until clk = '1' and clk'event;
end loop; -- i
end procedure wait_latency;
-- convert the div_ratio to a fixed point integer with a 24 bits fractional part
function ratio_to_fixed_point (ratio : real) return std_logic_vector is
variable mantissa : real;
variable int_vec : std_logic_vector(33 downto 0) := (others => '0');
begin
-- Compute the ratio in two steps to avoid intermediate integer
-- representations exceeding 32 bits:
-- Compute first the integer part
int_vec(33 downto 24) := std_logic_vector(to_unsigned(integer(floor(ratio)), 10));
-- Compute the mantissa
mantissa := (ratio-floor(ratio))*real(2**24);
int_vec(23 downto 0) := std_logic_vector(to_unsigned(integer(mantissa), 24));
return int_vec;
end function ratio_to_fixed_point;
-- convert the sub-pixel offset to a fixed point integer with a 24 bits fractional part
function offset_to_fixed_point (off : real; ratio: real) return std_logic_vector is
variable norm_ratio : real;
variable mantissa : real;
variable int_vec : std_logic_vector(33 downto 0) := (others => '0');
begin
norm_ratio := off*ratio;
-- Compute the ratio in two steps to avoid intermediate integer
-- representations exceeding 32 bits:
-- Compute first the integer part
int_vec(33 downto 24) := std_logic_vector(to_unsigned(integer(floor(norm_ratio)), 10));
-- Compute the mantissa
mantissa := (norm_ratio-floor(norm_ratio))*real(2**24);
int_vec(23 downto 0) := std_logic_vector(to_unsigned(integer(mantissa), 24));
return int_vec;
end function offset_to_fixed_point;
function check_result(ratio : real; offset : real; delta_pos : integer; fire_cnt : integer; silent_mode : boolean := false) return boolean is
variable res : boolean;
variable exp_fire : integer;
begin
if(real(delta_pos) < ratio*offset) then
exp_fire := 0;
else
--exp_fire := integer(real(delta_pos)/ratio - offset+0.5);
exp_fire := integer((1.0 + real(delta_pos)/ratio - offset));
end if;
if(silent_mode = false) then
log("Check Result:",VMEDIUM);
log("ratio = " & to_string(ratio) & ", offset = " & to_string(offset) & ", delta_pos = " & to_string(delta_pos),VMEDIUM);
end if;
if(abs(exp_fire-fire_cnt) <= 1) then
res := true;
if(silent_mode = false) then
log("Check Result:",VMEDIUM);
log("ratio = " & to_string(ratio) & ", offset = " & to_string(offset) & ", delta_pos = " & to_string(delta_pos),VMEDIUM);
log("Expected Fire-Pulses = " & to_string(exp_fire) & ", detected = " & to_string(fire_cnt),VMEDIUM);
end if;
else
res := false;
log("Check Result:",VMEDIUM);
log("ratio = " & to_string(ratio) & ", offset = " & to_string(offset) & ", delta_pos = " & to_string(delta_pos),VMEDIUM);
log("ERROR: Expected Fire-Pulses = " & to_string(exp_fire) & ", detected = " & to_string(fire_cnt),VMEDIUM);
end if;
return res;
end function check_result;
-----------------------------------------------------------------------------
-- Signal declarations
-----------------------------------------------------------------------------
signal reset_n : std_logic := '0';
signal clk : std_logic := '0';
signal enable : std_logic;
signal upd_max_pos : std_logic;
signal upd_min_pos : std_logic;
signal abs_pos_max : std_logic_vector(31 downto 0);
signal abs_pos_min : std_logic_vector(31 downto 0);
signal dir : std_logic;
signal offset : std_logic_vector(33 downto 0);
signal ratio : std_logic_vector(33 downto 0);
signal abs_pos : std_logic_vector(31 downto 0);
signal fire : std_logic;
signal fire_cnt : std_logic_vector(31 downto 0);
--
signal div_ratio : real := 1.0;
signal pixel_offset : real := 0.0;
signal ideal_fire : real := 0.0;
signal firing_error : real := 0.0;
signal pos : integer := 0;
signal tot_fire_num : integer := 0;
--
signal test_completed : boolean;
signal configuring : boolean;
signal running : boolean;
signal passed : boolean;
signal failed : boolean;
begin -- architecture behav
clk <= not clk after 0.5*CLK_PERIOD;
-----------------------------------------------------------------------------
-- UUTs
-----------------------------------------------------------------------------
iUUT : entity work.simple_frac_div_4
port map (
clk => clk,
enable => enable,
dir => dir,
upd_max_pos => upd_max_pos,
upd_min_pos => upd_min_pos,
abs_pos_max => abs_pos_max,
abs_pos_min => abs_pos_min,
offset => offset,
ratio => ratio,
abs_pos => abs_pos,
fire => fire,
fire_cnt => fire_cnt);
ratio <= ratio_to_fixed_point(div_ratio);
offset <= offset_to_fixed_point(pixel_offset, div_ratio);
abs_pos <= std_logic_vector(to_signed(pos,32));
-----------------------------------------------------------------------------
-- Signal Monitor
-----------------------------------------------------------------------------
pMONITOR : process(clk)
alias ideal_fire_int is <<signal iUUT.ideal_fire : std_logic_vector(49 downto 0)>>;
alias firing_error_int is <<signal iUUT.firing_error : std_logic_vector(49 downto 0)>>;
begin
if(clk = '1' and clk'event) then
ideal_fire <= real(to_integer(unsigned(ideal_fire_int(49 downto 24)))) + (real(to_integer(unsigned(ideal_fire_int(23 downto 0)))) / real(2.0**24));
firing_error <= real(to_integer(unsigned(firing_error_int(49 downto 24)))) + (real(to_integer(unsigned(firing_error_int(23 downto 0)))) / real(2.0**24));
end if;
end process pMONITOR;
-----------------------------------------------------------------------------
-- Support Logic
-----------------------------------------------------------------------------
pSupport : process(clk)
begin
if(clk = '1' and clk'event) then
if(enable = '0') then
tot_fire_num <= 0;
elsif(fire = '1') then
tot_fire_num <= tot_fire_num +1;
end if;
end if;
end process pSupport;
-----------------------------------------------------------------------------
-- Testbench Logic
-----------------------------------------------------------------------------
pTB_CTRL : process
variable delta_pos : integer := 0;
variable init_pos : integer;
variable dir_m : integer;
variable tot_steps : integer;
variable result : boolean;
variable test_idx : natural;
variable rv : RandomPType;
procedure run_test is
variable steps : integer;
variable sel_dir : integer;
begin
log_header("Test-case " & to_string(test_idx), VMEDIUM);
wait_latency(clk, 1);
if dir = '0' then
dir_m := 1;
else
dir_m := -1;
end if;
init_pos := pos;
-- reset the absolute position memory
enable <= '0';
upd_max_pos <= '0';
upd_min_pos <= '0';
wait_latency(clk, 1);
upd_max_pos <= '1';
upd_min_pos <= '1';
wait_latency(clk, 1);
upd_max_pos <= '0';
upd_min_pos <= '0';
-- restart the divider
wait_latency(clk, 1);
enable <= '1';
wait_latency(clk, INTRA_POS_LATENCY);
-- run the steps
steps := 0;
loop_pos: while steps < tot_steps loop
wait_latency(clk, INTRA_POS_LATENCY);
/*
-- check the result and report
delta_pos := dir_m * (pos - init_pos);
result := check_result(div_ratio, pixel_offset, delta_pos, tot_fire_num, true);
exit loop_pos when result = false;
*/
sel_dir := rv.RandInt(1, 100);
if(sel_dir > POS_RANDOM_PERC) then
-- move in the intended direction
pos <= pos + dir_m;
steps := steps + 1;
else
-- move in the opposite direction
pos <= pos - dir_m;
steps := steps - 1;
end if;
end loop loop_pos;
-- wait the propagation of the latency
wait_latency(clk, INTRA_POS_LATENCY);
-- check the result and report
delta_pos := dir_m * (pos - init_pos);
if(result /= false) then
result := check_result(div_ratio, pixel_offset, delta_pos, tot_fire_num);
end if;
log("div_ratio = " & to_string(div_ratio), VMEDIUM);
end procedure run_test;
begin
-- Set the verbosity level for logging
set_log_verbosity(VERBOSITY_LEVEL);
--set_log_verbosity(VHIGH);
log_header("Fractional Divider verification:", VLOW);
test_completed <= false;
configuring <= false;
running <= false;
passed <= false;
failed <= false;
enable <= '0';
dir <= '1';
-- Reset
reset_n <= '0';
wait for 100 ns;
wait until clk = '1' and clk'event;
reset_n <= '1';
result := true;
test_idx := 0;
---------------------------------------------------------------------------
-- Test-00
---------------------------------------------------------------------------
if(result /= false) then
test_idx := test_idx+1;
div_ratio <= 4.000;
pixel_offset <= 0.0;
dir <= '0';
tot_steps := 100000;
run_test;
end if;
--wait for 5 us;
--test_completed <= true;
---------------------------------------------------------------------------
-- Test-01
---------------------------------------------------------------------------
if(result /= false) then
test_idx := test_idx+1;
div_ratio <= 4.000;
pixel_offset <= 0.25;
dir <= '0';
tot_steps := 100000;
run_test;
end if;
---------------------------------------------------------------------------
-- Test-02
---------------------------------------------------------------------------
if(result /= false) then
test_idx := test_idx+1;
div_ratio <= 4.000;
pixel_offset <= 0.5;
dir <= '0';
tot_steps := 100000;
run_test;
end if;
---------------------------------------------------------------------------
-- Test-03
---------------------------------------------------------------------------
if(result /= false) then
test_idx := test_idx+1;
div_ratio <= 4.000;
pixel_offset <= 0.75;
dir <= '0';
tot_steps := 100000;
run_test;
end if;
---------------------------------------------------------------------------
-- Test-04
---------------------------------------------------------------------------
if(result /= false) then
test_idx := test_idx+1;
div_ratio <= 4.000;
pixel_offset <= 1.0;
dir <= '0';
tot_steps := 100000;
run_test;
end if;
---------------------------------------------------------------------------
-- Test-05
---------------------------------------------------------------------------
if(result /= false) then
test_idx := test_idx+1;
div_ratio <= 1.001;
pixel_offset <= 0.0;
dir <= '0';
tot_steps := 10000;
run_test;
end if;
---------------------------------------------------------------------------
-- Test-06
---------------------------------------------------------------------------
if(result /= false) then
test_idx := test_idx+1;
div_ratio <= 1.002;
pixel_offset <= 0.9;
dir <= '1';
tot_steps := 10000;
run_test;
end if;
---------------------------------------------------------------------------
-- Test-07
---------------------------------------------------------------------------
if(result /= false) then
test_idx := test_idx+1;
div_ratio <= 1.333;
pixel_offset <= 1.5;
dir <= '0';
tot_steps := 10000;
run_test;
end if;
---------------------------------------------------------------------------
-- Test-08
---------------------------------------------------------------------------
if(result /= false) then
test_idx := test_idx+1;
div_ratio <= 4.008;
pixel_offset <= 0.25;
dir <= '0';
tot_steps := 10000;
run_test;
end if;
---------------------------------------------------------------------------
-- Test-09
---------------------------------------------------------------------------
if(result /= false) then
test_idx := test_idx+1;
div_ratio <= 4.000;
pixel_offset <= 0.0;
dir <= '0';
tot_steps := 10000;
run_test;
end if;
---------------------------------------------------------------------------
-- Test-10
---------------------------------------------------------------------------
if(result /= false) then
test_idx := test_idx+1;
div_ratio <= 4.000;
pixel_offset <= 0.25;
dir <= '0';
tot_steps := 10000;
run_test;
end if;
---------------------------------------------------------------------------
-- Test-11
---------------------------------------------------------------------------
if(result /= false) then
test_idx := test_idx+1;
div_ratio <= 4.000;
pixel_offset <= 0.5;
dir <= '0';
tot_steps := 10000;
run_test;
end if;
---------------------------------------------------------------------------
-- Test-12
---------------------------------------------------------------------------
if(result /= false) then
test_idx := test_idx+1;
div_ratio <= 4.000;
pixel_offset <= 0.75;
dir <= '0';
tot_steps := 10000;
run_test;
end if;
---------------------------------------------------------------------------
-- Test-13
---------------------------------------------------------------------------
if(result /= false) then
test_idx := test_idx+1;
div_ratio <= 4.000;
pixel_offset <= 1.0;
dir <= '0';
tot_steps := 10000;
run_test;
end if;
---------------------------------------------------------------------------
-- Test-14
---------------------------------------------------------------------------
if(result /= false) then
test_idx := test_idx+1;
div_ratio <= 4.000;
pixel_offset <= 0.12;
dir <= '0';
tot_steps := 10000;
run_test;
end if;
---------------------------------------------------------------------------
-- Test-15
---------------------------------------------------------------------------
if(result /= false) then
test_idx := test_idx+1;
div_ratio <= 4.000;
pixel_offset <= 0.13;
dir <= '0';
tot_steps := 10000;
run_test;
end if;
---------------------------------------------------------------------------
-- Test-16
---------------------------------------------------------------------------
if(result /= false) then
test_idx := test_idx+1;
div_ratio <= 126.0;
pixel_offset <= 0.99;
dir <= '0';
tot_steps := 10000;
run_test;
end if;
---------------------------------------------------------------------------
-- Test-17
---------------------------------------------------------------------------
if(result /= false) then
test_idx := test_idx+1;
div_ratio <= 126.0;
pixel_offset <= 0.0;
dir <= '0';
tot_steps := 10000;
run_test;
end if;
---------------------------------------------------------------------------
-- Test-18 - Very long test to check internal-reg-saturation
---------------------------------------------------------------------------
if(result /= false) then
test_idx := test_idx+1;
div_ratio <= 4.000;
pixel_offset <= 0.0;
dir <= '0';
tot_steps := 100000;
run_test;
end if;
---------------------------------------------------------------------------
-- Test-19 - Very long test to check internal-reg-saturation
---------------------------------------------------------------------------
if(result /= false) then
test_idx := test_idx+1;
div_ratio <= 1000.000;
pixel_offset <= 0.5;
dir <= '0';
tot_steps := 100000;
run_test;
end if;
---------------------------------------------------------------------------
-- Test-20 - Very long test to check internal-reg-saturation
---------------------------------------------------------------------------
if(result /= false) then
test_idx := test_idx+1;
div_ratio <= 999.9;
pixel_offset <= 0.5;
dir <= '0';
tot_steps := 100000;
run_test;
end if;
---------------------------------------------------------------------------
-- Test-21 - Very long test to check internal-reg-saturation
---------------------------------------------------------------------------
if(result /= false) then
test_idx := test_idx+1;
div_ratio <= 999.8;
pixel_offset <= 0.5;
dir <= '0';
tot_steps := 100000;
run_test;
end if;
---------------------------------------------------------------------------
-- Test-22 - Very long test to check internal-reg-saturation
---------------------------------------------------------------------------
if(result /= false) then
test_idx := test_idx+1;
div_ratio <= 1001.0;
pixel_offset <= 0.5;
dir <= '0';
tot_steps := 100000;
run_test;
end if;
---------------------------------------------------------------------------
-- Test-23 - Very long test to check internal-reg-saturation
---------------------------------------------------------------------------
if(result /= false) then
test_idx := test_idx+1;
div_ratio <= 1000.1;
pixel_offset <= 0.5;
dir <= '0';
tot_steps := 100000;
run_test;
end if;
---------------------------------------------------------------------------
-- Test-23 - Very long test to check internal-reg-saturation
---------------------------------------------------------------------------
if(result /= false) then
test_idx := test_idx+1;
div_ratio <= 1000.2;
pixel_offset <= 0.5;
dir <= '0';
tot_steps := 100000;
run_test;
end if;
---------------------------------------------------------------------------
-- Random Tests
---------------------------------------------------------------------------
for n in 1 to 20 loop
if(result /= false) then
test_idx := test_idx+1;
-- the div_ratio fractional part must be a multiple of 0.001
div_ratio <= 0.001*real(rv.RandInt(1000, 50000));
if((rv.RandInt(1,10) mod 2) = 0) then
dir <= '0';
else
dir <= '1';
end if;
tot_steps := rv.RandInt(5000, 20000);
run_test;
end if;
end loop; -- n
wait for 200 ns;
log_separator_line(VLOW);
if(result = false) then
failed <= true;
log("FAILURE: test completed with errors.", VLOW);
else
passed <= true;
log("SUCCESS: test successfully completed.", VLOW);
end if;
log_separator_line(VLOW);
test_completed <= true;
running <= false;
wait;
end process pTB_CTRL;
end architecture behav;

View file

@ -0,0 +1,307 @@
-------------------------------------------------------------------------------
-- Title : spitting_verify_tb
-- Project : Pulse-Generator
-------------------------------------------------------------------------------
-- File : spitting_verify_tb.vhd
-- Author : GMG
-- Company : Global Inkjet Systems
-- Created : 2018-09-11
-- Last update: 2019-05-22
-- SVN ID : Git
-- Standard : VHDL'2008
-------------------------------------------------------------------------------
-- Description:
-- Verify the spitting logic in pulse-generator
-------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.math_real.all;
use work.log_pkg.all;
use work.avalon_verify_pkg.all;
use work.pulse_generator_3_pkg.all;
entity spitting_verify_tb is
-- ..
end entity spitting_verify_tb;
architecture behav of spitting_verify_tb is
constant CLK_PERIOD : time := 10 ns;
-- Logging Verbosity Level
constant VERBOSITY_LEVEL : verb_level_t := VMEDIUM;
-----------------------------------------------------------------------------
-- TB Functions / Procedures
-----------------------------------------------------------------------------
procedure wait_latency(
signal clk : in std_logic;
cycles : in natural) is
begin
for i in 1 to cycles loop
wait until clk = '1' and clk'event;
end loop; -- i
end procedure wait_latency;
-----------------------------------------------------------------------------
-- Signal declarations
-----------------------------------------------------------------------------
signal reset_n : std_logic := '0';
signal clk : std_logic := '0';
signal init : std_logic;
signal pd_in : std_logic;
signal abs_position : std_logic_vector(31 downto 0);
signal dp_dir : std_logic;
signal pulse_out : std_logic;
signal filtered_pd : std_logic;
signal ch_pd : std_logic;
signal ch_mask : std_logic;
signal raw_pulse_out : std_logic;
signal avs_address : std_logic_vector(9 downto 0);
signal avs_write : std_logic;
signal avs_writedata : std_logic_vector(31 downto 0);
signal avs_read : std_logic;
signal avs_readdatavalid : std_logic;
signal avs_readdata : std_logic_vector(31 downto 0);
--
signal avs_m : mm_m_rec_t;
signal avs_s : mm_s_rec_t;
--
signal pd_in_cnt : integer;
signal pd_out_cnt : integer;
--
signal test_completed : boolean;
signal setup : boolean;
signal running : boolean;
signal error_flag : boolean;
signal passed : boolean;
signal failed : boolean;
begin -- architecture behav
clk <= not clk after 0.5*CLK_PERIOD;
-----------------------------------------------------------------------------
-- UUT
-----------------------------------------------------------------------------
iUUT: entity work.pulse_generator_3
generic map (
pulse_delay_equal_en => true,
out_pulse_condition => true)
port map (
clk => clk,
reset_n => reset_n,
init => init,
pd_in => pd_in,
abs_position => abs_position,
dp_dir => dp_dir,
pulse_out => pulse_out,
filtered_pd => filtered_pd,
ch_pd => ch_pd,
ch_mask => ch_mask,
raw_pulse_out => raw_pulse_out,
avs_address => avs_address,
avs_write => avs_write,
avs_writedata => avs_writedata,
avs_read => avs_read,
avs_readdatavalid => avs_readdatavalid,
avs_readdata => avs_readdata);
-----------------------------------------------------------------------------
-- Avalon interface
-----------------------------------------------------------------------------
clk_clk <= clk;
reset_reset_n <= reset_n;
avs_s.mm_readdata <= avs_readdata;
avs_s.mm_readdatavalid <= avs_readdatavalid;
avs_s.mm_waitrequest <= '0';
avs_s.use_readvalid <= true;
avs_address <= avs_m.mm_address(avs_address'range);
avs_write <= avs_m.mm_write;
avs_writedata <= avs_m.mm_writedata;
avs_read <= avs_m.mm_read;
pCNT_CH_PD : process(reset_n, clk)
begin
if(reset_n = '0') then
pd_out_cnt <= 0;
elsif(clk = '1' and clk'event) then
if(ch_pd = '1') then
pd_out_cnt <= pd_out_cnt + 1;
end if;
end if;
end process pCNT_CH_PD;
-----------------------------------------------------------------------------
-- Testbench Logic
-----------------------------------------------------------------------------
pTB_CTRL : process
alias dp_dir is <<signal iUUT.dp_dir_i : std_logic>>;
procedure issue_pd(valid_pd : boolean := true) is
begin
wait until clk = '1' and clk'event;
pd_in <= '1';
wait until clk = '1' and clk'event;
pd_in <= '0';
if(valid_pd = true) then
pd_in_cnt <= pd_in_cnt + 1;
end if;
end procedure issue_pd;
procedure check_pd is
begin
for i in 1 to 12 loop
wait until clk = '1' and clk'event;
end loop; -- i
if(pd_out_cnt /= pd_in_cnt) then
if(pd_out_cnt > pd_in_cnt) then
log("ERROR: Detected faulty Channel PD.", VLOW);
else
log("ERROR: Missing Channel PD.", VLOW);
end if;
error_flag <= true;
end if;
end procedure check_pd;
variable addr : std_logic_vector(31 downto 0) := (others => '0');
variable data : std_logic_vector(31 downto 0) := (others => '0');
begin
-- Set the verbosity level for logging
set_log_verbosity(VERBOSITY_LEVEL);
--set_log_verbosity(VHIGH);
-- initilialize the Avalon master-bus
mm_m_init(avs_m);
log_header("PD Jitter verification:", VLOW);
setup <= false;
running <= false;
passed <= false;
error_flag <= false;
init <= '0';
pd_in <= '0';
pd_in_cnt <= 0;
abs_position <= (others => '0');
-- Reset
reset_n <= '0';
wait for 100 ns;
wait until clk = '1' and clk'event;
reset_n <= '1';
wait for 200 ns;
-- enable the pulse generator
addr := std_logic_vector(resize(unsigned(PULSE_GEN_CTRL_REG), 32));
data := X"0000_0001";
mm_32b_write(addr, data, avs_s, avs_m);
---------------------------------------------------------------------------
-- DP-DIR = '0'
---------------------------------------------------------------------------
log("DP-DIR = '0'", VLOW);
log_separator_line(VLOW);
dp_dir <= force '0';
wait for 200 ns;
wait until clk = '1' and clk'event;
init <= '1';
wait until clk = '1' and clk'event;
wait until clk = '1' and clk'event;
wait until clk = '1' and clk'event;
init <= '0';
wait for 200 ns;
wait until clk = '1' and clk'event;
---------------------------------------------------------------------------
-- DIR-0, Init Pos = 0
---------------------------------------------------------------------------
log("Issueing PD on ABS_POS = 0", VLOW);
for n in 0 to 9 loop
issue_pd;
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)+ 1);
end loop; -- n
log("Go back to ABS_POS = 0", VLOW);
for n in 0 to 9 loop
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)- 1);
end loop; -- n
log("Issueing again PD on ABS_POS = 0", VLOW);
for n in 0 to 9 loop
issue_pd(false);
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)+ 1);
end loop; -- n
for n in 0 to 9 loop
issue_pd;
check_pd;
wait_latency(clk, 10);
abs_position <= std_logic_vector(signed(abs_position)+ 1);
end loop; -- n
wait for 1 us;
wait for 20 us;
running <= false;
passed <= true after 100 ns;
wait;
end process pTB_CTRL;
failed <= error_flag after 100 ns;
pREPORT_RESULT : process
begin
wait until failed = true or passed = true;
wait for 1 us;
log_separator_line(VLOW);
if(failed = true) then
log("FAILURE: test completed with errors.", VLOW);
elsif(passed = true) then
log("SUCCESS: test successfully completed.", VLOW);
end if;
log_separator_line(VLOW);
test_completed <= true;
end process pREPORT_RESULT;
end architecture behav;

View file

@ -0,0 +1,512 @@
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000009
0000000A
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000013
00000014
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
0000001D
0000001E
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000027
00000028
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000031
00000032
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
0000003C
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000064
00000014
00000064
00000064
00000064
00000064
00000064
00000064

View file

@ -0,0 +1,663 @@
-------------------------------------------------------------------------------
-- Title : tof_comp_tb
-- Project : Pulse-Generator
-------------------------------------------------------------------------------
-- File : tof_comp_tb.vhd
-- Author : GMG
-- Company : Global Inkjet Systems
-- Created : 2019-06-20
-- Last update: 2020-04-16
-- SVN ID : Git
-- Standard : VHDL'2008
-------------------------------------------------------------------------------
-- Description:
-- Verifies Time-of-Flight Compensation
-------------------------------------------------------------------------------
library std;
use std.textio.all;
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.std_logic_textio.all;
use ieee.math_real.all;
use work.log_pkg.all;
use work.avalon_verify_pkg.all;
use work.pulse_generator_4_pkg.all;
entity tof_comp_tb is
-- ..
end entity tof_comp_tb;
architecture behav of tof_comp_tb is
constant CLK_PERIOD : time := 10 ns;
-- Logging Verbosity Level
constant VERBOSITY_LEVEL : verb_level_t := VMEDIUM;
constant SIM_CYCLES : natural := 15;
-- DIV_RATIO: head-pitch/ encoder-global-resolution
constant DIV_RATIO : real := 1.0;
constant SAMPLING_PERIOD : natural := 1000; -- Use a sample period of 10 us
-- for the test
type cfg_data_t is array (natural range <>) of std_logic_vector(31 downto 0);
constant TOF_COMP_TABLE_LEN : natural := 512;
subtype tof_table_t is cfg_data_t(0 to TOF_COMP_TABLE_LEN-1);
constant tof_comp_file : string := "./../src/test/tof_comp/tof_table_1.cfg";
-----------------------------------------------------------------------------
-- Signal declarations
-----------------------------------------------------------------------------
signal reset_n : std_logic := '0';
signal clk : std_logic := '0';
signal init : std_logic;
signal pd_in : std_logic;
signal abs_position : std_logic_vector(31 downto 0);
signal dp_dir : std_logic;
signal fire_req : std_logic;
signal fire_req_vec : std_logic_vector(31 downto 0);
signal filtered_pd : std_logic;
signal ch_pd : std_logic;
signal ch_mask : std_logic;
signal raw_fire_req : std_logic;
signal avs_address : std_logic_vector(10 downto 0);
signal avs_write : std_logic;
signal avs_writedata : std_logic_vector(31 downto 0);
signal avs_read : std_logic;
signal avs_readdata : std_logic_vector(31 downto 0);
--
signal avs_m : mm_m_rec_t;
signal avs_s : mm_s_rec_t;
--
signal step_pos : std_logic;
signal step_neg : std_logic;
signal vel_meas : std_logic_vector(19 downto 0);
signal vel_sampling_per : std_logic_vector(19 downto 0);
--
signal end_of_stimuli : boolean;
signal test_completed : boolean;
signal setup : boolean;
signal running : boolean;
signal passed : boolean;
signal failed : boolean;
shared variable error_flag : boolean;
signal vel_meas_cnt : natural;
signal vel_upd_flag : std_logic;
--
signal fire_req_d : std_logic;
signal raw_fire_req_d : std_logic;
signal fire_cnt : integer;
signal raw_fire_cnt : integer;
-----------------------------------------------------------------------------
-- TB Functions / Procedures
-----------------------------------------------------------------------------
procedure wait_latency(
signal clk : in std_logic;
cycles : in natural) is
begin
for i in 1 to cycles loop
wait until clk = '1' and clk'event;
end loop; -- i
end procedure wait_latency;
procedure set_div_ratio(
div_ratio : real;
signal mm_s_rec : in mm_s_rec_t;
signal mm_m_rec : out mm_m_rec_t) is
variable addr : std_logic_vector(31 downto 0) := (others => '0');
variable data : std_logic_vector(31 downto 0) := (others => '0');
variable ratio_int : integer;
variable ratio_slv : std_logic_vector(33 downto 0);
begin
-- set the division ratio
ratio_int := integer(div_ratio*real(2**24));
ratio_slv := std_logic_vector(to_unsigned(ratio_int, 34));
-- Set the integer part of the div-ratio
data(31 downto 10) := (others => '0');
data( 9 downto 0) := ratio_slv(33 downto 24);
addr := std_logic_vector(resize(unsigned(CSR_DIVIDER_RATIO_INT_ADDR), 32));
mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
-- Set the fractional part of the div-ratio
data(31 downto 24) := (others => '0');
data(23 downto 0) := ratio_slv(23 downto 0);
addr := std_logic_vector(resize(unsigned(CSR_DIVIDER_RATIO_FRACTION_ADDR), 32));
mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
end procedure set_div_ratio;
procedure read_cfg_file(
fname : in string;
num_data : in natural;
read_data : out cfg_data_t) is
file f_id : text;
variable status : file_open_status;
variable InLine : line;
variable word : std_logic_vector(31 downto 0);
begin
file_open(status, f_id, fname, read_mode);
if(status /= open_ok) then
log("ERROR: Failed to open file " & fname & ".", VLOW);
error_flag := true;
else
READ_LOOP: for idx in 0 to num_data-1 loop
readline(f_id, InLine);
hread(InLine, word);
read_data(idx) := word;
end loop; -- READ_LOOP
file_close(f_id);
end if;
end procedure read_cfg_file;
procedure config_tof_comp_lut(
tof_table : in tof_table_t;
signal mm_s_rec : in mm_s_rec_t;
signal mm_m_rec : out mm_m_rec_t) is
variable addr : std_logic_vector(31 downto 0) := (others => '0');
variable data : std_logic_vector(31 downto 0) := (others => '0');
begin
for n in 0 to TOF_COMP_TABLE_LEN-1 loop
data := tof_table(n);
addr := std_logic_vector(resize(unsigned(CSR_TOF_COMP_LUT_ADDR)+n, 32));
mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
end loop; -- n
log("ToF Compensation LUT configured.", VMEDIUM);
end procedure config_tof_comp_lut;
procedure setup_tof_comp(
enc_speed_norm : natural;
vel_sampl_win : natural := SAMPLING_PERIOD;
signal mm_s_rec : in mm_s_rec_t;
signal mm_m_rec : out mm_m_rec_t) is
variable addr : std_logic_vector(31 downto 0) := (others => '0');
variable data : std_logic_vector(31 downto 0) := (others => '0');
begin
addr := std_logic_vector(resize(unsigned(CSR_ENC_SPEED_MEAS_WINDOW_ADDR), 32));
data := std_logic_vector(to_unsigned(vel_sampl_win, 32));
mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
addr := std_logic_vector(resize(unsigned(CSR_TOF_COMPENSATION_W_ADDR), 32));
data := x"0000" & std_logic_vector(to_unsigned(enc_speed_norm,16));
mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
end procedure setup_tof_comp;
procedure apply_pg_cfg(
div_ratio : real;
offset_dir0 : integer;
offset_dir1 : integer;
delay : integer;
dir : std_logic;
tof_enable : std_logic;
enc_speed_norm : natural;
signal mm_s_rec : in mm_s_rec_t;
signal mm_m_rec : out mm_m_rec_t) is
variable addr : std_logic_vector(31 downto 0) := (others => '0');
variable data : std_logic_vector(31 downto 0) := (others => '0');
variable ratio_int : integer;
variable ratio_slv : std_logic_vector(33 downto 0);
variable tof_table : tof_table_t;
begin
log_separator_line(VMEDIUM);
log("Configuring Pulse-Generator registers ...", VMEDIUM);
log_separator_line(VMEDIUM);
log("Div-Ratio = " & to_string(div_ratio), VMEDIUM);
-- Disable/Re-enable first the whole pulse_generator
addr := std_logic_vector(resize(unsigned(CSR_PULSE_GEN_CONTROL_W_ADDR), 32));
data := (others => '0');
mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
data := (0 => '1', 16 => '1', others => '0');
mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
-- Disable the Channel Controller sequencer
addr := std_logic_vector(resize(unsigned(CSR_CHANNEL_CONTROLLER_CONTROL_W_ADDR), 32));
data := (others => '0');
mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
-- Set the division ratio
set_div_ratio(div_ratio, mm_s_rec, mm_m_rec);
-- Disable/Enable the fractional divider
addr := std_logic_vector(resize(unsigned(CSR_FRACTIONAL_DIVIDER_CONTROL_ADDR), 32));
data := (others => '0');
mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
data := (0 => '1', others => '0');
mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
-- Configure the rest of the pulse_generator:
-- Configure the Channel Offset (Both DIR_0 and DIR_1):
-- DIR_0
addr := std_logic_vector(resize(unsigned(CSR_PD_OFFSET_DIR_0_ADDR),32));
data := std_logic_vector(to_unsigned(offset_dir0, 32));
mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
-- DIR_1
addr := std_logic_vector(resize(unsigned(CSR_PD_OFFSET_DIR_1_ADDR), 32));
data := std_logic_vector(to_unsigned(offset_dir1, 32));
mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
-- Configure the Channel Delay:
addr := std_logic_vector(resize(unsigned(CSR_CHANNEL_DELAY_ADDR), 32));
data := std_logic_vector(to_unsigned(delay, 32));
mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
-- Read the tof configuration file
read_cfg_file(tof_comp_file, TOF_COMP_TABLE_LEN, tof_table);
-- upload the table
config_tof_comp_lut(tof_table, mm_s_rec, mm_m_rec);
-- apply tof compensation
setup_tof_comp(enc_speed_norm, SAMPLING_PERIOD, mm_s_rec, mm_m_rec);
-- enable the pulse-generator: bypass_ch_ctrl = '1',
addr := std_logic_vector(resize(unsigned(CSR_PULSE_GEN_CONTROL_W_ADDR), 32));
data := (0 => '1', 1 => '1', 4 => dir, 12 => tof_enable, 16 => '1', others => '0');
mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
if(tof_enable = '0') then
log("ToF Compensation Disabled.", VMEDIUM);
else
log("ToF Compensation Enabled.", VMEDIUM);
end if;
if(dir = '0') then
log("Ch-Ctrl disabled, direction = DIR-0", VMEDIUM);
else
log("Ch-Ctrl disabled, direction = DIR-1", VMEDIUM);
end if;
log_separator_line(VMEDIUM);
end procedure apply_pg_cfg;
-----------------------------------------------------------------------------
-- End declarative part
-----------------------------------------------------------------------------
begin -- architecture behav
clk <= not clk after 0.5*CLK_PERIOD;
-----------------------------------------------------------------------------
-- UUT
-----------------------------------------------------------------------------
iUUT: entity work.pulse_generator_4
generic map (
PULSE_DELAY_EQUAL_EN => true,
TOF_COMP_EN => true)
port map (
clk => clk,
reset_n => reset_n,
init => init,
pd_in => pd_in,
abs_position => abs_position,
enc_vel => vel_meas,
enc_speed_meas_w => vel_sampling_per,
dp_dir => dp_dir,
fire_req_vec => fire_req_vec,
filtered_pd => filtered_pd,
ch_pd => ch_pd,
ch_mask => ch_mask,
raw_fire_req => raw_fire_req,
avs_address => avs_address,
avs_write => avs_write,
avs_writedata => avs_writedata,
avs_read => avs_read,
avs_readdata => avs_readdata);
fire_req <= fire_req_vec(0);
iVEL : entity work.simple_enc_vel_detect_6
port map (
clk => clk,
init => init,
step_pos => step_pos,
step_neg => step_neg,
sampling_period => vel_sampling_per,
vel_meas => vel_meas);
-----------------------------------------------------------------------------
-- Avalon interface
-----------------------------------------------------------------------------
clk_clk <= clk;
reset_reset_n <= reset_n;
avs_s.mm_readdata <= avs_readdata;
avs_s.mm_readdatavalid <= '1';
avs_s.mm_waitrequest <= '0';
avs_s.use_readvalid <= true;
avs_address <= avs_m.mm_address(avs_address'range);
avs_write <= avs_m.mm_write;
avs_writedata <= avs_m.mm_writedata;
avs_read <= avs_m.mm_read;
-----------------------------------------------------------------------------
-- Testbench Logic
-----------------------------------------------------------------------------
pVEL_MEAS_CNT : process(clk)
alias new_meas is <<signal iVEL.sampling_pulse : std_logic>>;
begin
if(clk = '1' and clk'event) then
vel_upd_flag <= new_meas;
if(init = '1') then
vel_meas_cnt <= 0;
elsif(new_meas = '1') then
vel_meas_cnt <= vel_meas_cnt + 1;
end if;
end if;
end process pVEL_MEAS_CNT;
pSTIMULI : process
-- increments the abs pos every period clock cycles, first the specified
-- number of positive steps, then negative steps, then repeat until the
-- timing window is finished
procedure gen_abs_pos(
pos_inc_num : in natural;
neg_inc_num : in natural;
period : in natural;
signal step_pos : out std_logic;
signal step_neg : out std_logic;
signal abs_position : out std_logic_vector(31 downto 0)) is
variable curr_vel_cnt : natural := vel_meas_cnt;
variable pos_cnt : natural;
variable neg_cnt : natural;
variable go_on : boolean;
begin
wait until clk = '1' and clk'event;
pos_cnt := 0;
neg_cnt := 0;
go_on := true;
while go_on = true loop
-- generate first positive steps
if(pos_cnt < pos_inc_num) then
abs_position <= std_logic_vector(signed(abs_position)+1);
step_pos <= '1';
pos_cnt := pos_cnt+1;
wait until clk = '1' and clk'event;
step_pos <= '0';
wait_latency(clk, period-1);
end if;
-- then generate negative steps
if(neg_cnt < neg_inc_num) then
abs_position <= std_logic_vector(signed(abs_position)-1);
step_neg <= '1';
neg_cnt := neg_cnt+1;
wait until clk = '1' and clk'event;
step_neg <= '0';
wait_latency(clk, period-1);
end if;
if(curr_vel_cnt /= vel_meas_cnt) then
go_on := false;
else
if(pos_cnt >= pos_inc_num and neg_cnt >= neg_inc_num)then
wait_latency(clk, period);
end if;
end if;
end loop;
end procedure gen_abs_pos;
begin
end_of_stimuli <= false;
--
pd_in <= '0';
abs_position <= (others => '0');
step_pos <= '0';
step_neg <= '0';
-- wait until init is deasserted
wait until falling_edge(init);
gen_abs_pos(
pos_inc_num => 50, neg_inc_num => 0, period => 10,
step_pos => step_pos, step_neg => step_neg, abs_position => abs_position);
gen_abs_pos(
pos_inc_num => 40, neg_inc_num => 0, period => 10,
step_pos => step_pos, step_neg => step_neg, abs_position => abs_position);
gen_abs_pos(
pos_inc_num => 30, neg_inc_num => 0, period => 10,
step_pos => step_pos, step_neg => step_neg, abs_position => abs_position);
gen_abs_pos(
pos_inc_num => 20, neg_inc_num => 0, period => 10,
step_pos => step_pos, step_neg => step_neg, abs_position => abs_position);
gen_abs_pos(
pos_inc_num => 10, neg_inc_num => 0, period => 10,
step_pos => step_pos, step_neg => step_neg, abs_position => abs_position);
gen_abs_pos(
pos_inc_num => 0, neg_inc_num => 10, period => 10,
step_pos => step_pos, step_neg => step_neg, abs_position => abs_position);
gen_abs_pos(
pos_inc_num => 0, neg_inc_num => 20, period => 10,
step_pos => step_pos, step_neg => step_neg, abs_position => abs_position);
gen_abs_pos(
pos_inc_num => 50, neg_inc_num => 5, period => 10,
step_pos => step_pos, step_neg => step_neg, abs_position => abs_position);
gen_abs_pos(
pos_inc_num => 50, neg_inc_num => 15, period => 10,
step_pos => step_pos, step_neg => step_neg, abs_position => abs_position);
gen_abs_pos(
pos_inc_num => 500, neg_inc_num => 0, period => 10,
step_pos => step_pos, step_neg => step_neg, abs_position => abs_position);
gen_abs_pos(
pos_inc_num => 150, neg_inc_num => 0, period => 6,
step_pos => step_pos, step_neg => step_neg, abs_position => abs_position);
gen_abs_pos(
pos_inc_num => 100, neg_inc_num => 0, period => 40,
step_pos => step_pos, step_neg => step_neg, abs_position => abs_position);
gen_abs_pos(
pos_inc_num => 100, neg_inc_num => 0, period => 40,
step_pos => step_pos, step_neg => step_neg, abs_position => abs_position);
wait for 200 us;
-- completed
end_of_stimuli <= true;
wait;
end process pSTIMULI;
-----------------------------------------------------------------------------
-- Check the output
-----------------------------------------------------------------------------
pOUT_CNT : process(clk)
begin
if(clk = '1' and clk'event) then
fire_req_d <= fire_req;
raw_fire_req_d <= raw_fire_req;
if(init = '1') then
fire_cnt <= 0;
elsif(fire_req = '1' and fire_req_d = '0') then
fire_cnt <= fire_cnt+1;
end if;
if(init = '1') then
raw_fire_cnt <= 0;
elsif(raw_fire_req = '1' and raw_fire_req_d = '0') then
raw_fire_cnt <= raw_fire_cnt+1;
end if;
end if;
end process pOUT_CNT;
-----------------------------------------------------------------------------
-- Testbench Main
-----------------------------------------------------------------------------
pTB_CTRL : process
variable addr : std_logic_vector(31 downto 0) := (others => '0');
variable data : std_logic_vector(31 downto 0) := (others => '0');
begin
-- Set the verbosity level for logging
set_log_verbosity(VERBOSITY_LEVEL);
--set_log_verbosity(VHIGH);
-- initilialize the Avalon master-bus
mm_m_init(avs_m);
log_header("Time-of-Flight Compensation verification:", VLOW);
setup <= false;
running <= false;
passed <= false;
error_flag := false;
init <= '0';
-- Reset
reset_n <= '0';
wait for 100 ns;
wait until clk = '1' and clk'event;
reset_n <= '1';
---------------------------------------------------------------------------
-- Pulse-Generator Configuration
---------------------------------------------------------------------------
wait for 200 ns;
apply_pg_cfg(
div_ratio => DIV_RATIO,
offset_dir0 => 0,
offset_dir1 => 0,
delay => 100,
dir => '0',
tof_enable => '1',
enc_speed_norm => 256,
mm_s_rec => avs_s, mm_m_rec => avs_m);
---------------------------------------------------------------------------
-- Movement Simulation
---------------------------------------------------------------------------
wait for 200 ns;
wait until clk = '1' and clk'event;
init <= '1';
wait until clk = '1' and clk'event;
wait until clk = '1' and clk'event;
wait until clk = '1' and clk'event;
init <= '0';
wait for 200 ns;
running <= true;
wait until clk = '1' and clk'event;
wait until (end_of_stimuli = true) or (vel_meas_cnt = SIM_CYCLES + 1);
running <= false;
if(fire_cnt /= raw_fire_cnt) then
log("Error: Fire-Cnt = " & to_string(fire_cnt) & ". Raw-Pulse-Cnt = " & to_string(raw_fire_cnt), VLOW);
error_flag := true;
else
log("Completed: Generated " & to_string(fire_cnt) & " fire-requests", VLOW);
end if;
--
passed <= true after 100 ns;
wait;
end process pTB_CTRL;
pFAILED : process
begin
wait for 10 ns;
if(error_flag = true) then
failed <= true after 100 ns;
end if;
end process pFAILED;
pREPORT_RESULT : process
begin
wait until failed = true or passed = true;
wait for 1 us;
log_separator_line(VLOW);
if(failed = true) then
log("FAILURE: test completed with errors.", VLOW);
elsif(passed = true) then
log("SUCCESS: test successfully completed.", VLOW);
end if;
log_separator_line(VLOW);
test_completed <= true;
end process pREPORT_RESULT;
end architecture behav;

View file

@ -0,0 +1,158 @@
%%/////////////////////////////////////////////////////////////////////////////
%% Title : wh_wheel_corr
%%/////////////////////////////////////////////////////////////////////////////
%% File : wh_wheel_corr.m
%% Author : Gianmarco Girau
%% Company : GIS
%% Target : GIS-HMB board
%% Dependency : none
%%/////////////////////////////////////////////////////////////////////////////
%% Description: Verify the stability of loop corrections for W&H
%%/////////////////////////////////////////////////////////////////////////////
%% Last update: 2019-06-07
%%/////////////////////////////////////////////////////////////////////////////
%% Revisions :
%% Date Version Author Description
%% 2016-09-16 01.00.0a gmg Created
%%/////////////////////////////////////////////////////////////////////////////
close all
clear all
clc
%head_pitch_um = 20.0
head_pitch_um = 4.23*5.0
encoder_res_um = 5.0
image_pixel_lenght = 100
div_ratio_nom = head_pitch_um/encoder_res_um
wheel_circum = image_pixel_lenght*div_ratio_nom
total_rotations = 100;
% Define a error vector for wheel rotations
wheel_error_v = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, ...
2, 2, 3, 3, 4, 4, 5, 5, 4, 4, ...
3, 3, 2, 2, 1, 1, 0, 0, -1, -1, ...
-2, -2, -3, -3, -4, -4, -5, -5, -4, -4, ...
-3, -3, -2, -2, -1, -1, 0, 0, 0, 0, ...
0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 1, 1, ...
1, 1, 0, 0, -1, -1, -1, -1, 0, 0, -40, 0, 0, +80];
N = total_rotations - length(wheel_error_v)
wheel_error_v = [wheel_error_v 40*ones(1,N)];
wheel_error_v = zeros(1,total_rotations);
%wheel_error_v(10) = 40
wheel_error_v(10:end) = 40;
%{
% Continuously changing
error_rel_max = 0.1
x = 0:total_rotations-1;
wheel_error_v = (0.1*wheel_circum)*sin(2*pi*x/total_rotations);
%}
%{
% Change and poause
error_rel_max = 0.1
x = 0:total_rotations-1;
%k = 5.0;
k = 10;
x = floor(x/k);
wheel_error_v = (0.1*wheel_circum)*sin(2*pi*x/(total_rotations/k));
%}
% Continuously changing
%{
error_rel_max = 0.1
x = 0:total_rotations-1;
wheel_error_v = (0.1*wheel_circum)*sin(2*pi*x/total_rotations);
%}
pd_pos(1) = 0;
tot_pixels(1) = 0;
end_image(1) = 0;
pos_error(1) = 0;
div_ratio(1) = div_ratio_nom;
for n = 1:total_rotations
delta_dist = wheel_circum + wheel_error_v(n);
pd_pos(n+1) = pd_pos(n)+ delta_dist;
tot_pixels(n+1) = tot_pixels(n)+ delta_dist/div_ratio(n);
end_image(n+1) = end_image(n)+div_ratio(n)*image_pixel_lenght;
pos_error(n+1) = pd_pos(n+1)-end_image(n+1);
% No Correction
%div_ratio(n+1) = div_ratio_nom;
% Basic Correction: FLL
%div_ratio(n+1) = div_ratio_nom+pos_error(n+1)/image_pixel_lenght;
% Correction Accumulation:
%div_ratio(n+1) = div_ratio(n)+pos_error(n+1)/image_pixel_lenght;
% PLL Correction:
delta_error = pos_error(n+1)-pos_error(n);
tot_error = pos_error(n+1);
% 1
%alpha = 1.0;
%beta = 0.05;
% 2
%alpha = 1.0;
%beta = 0.5;
% 3
alpha = 1.0;
beta = 1.0;
div_ratio(n+1) = div_ratio(n)+(alpha*delta_error+beta*tot_error)/image_pixel_lenght;
end
figure(1);
plot(wheel_error_v, 'r*')
grid on;
title('Wheel Errors')
%{
figure(2);
plot(pd_pos, 'b');
grid on;
title('PD position')
figure(3);
plot(tot_pixels, 'b');
grid on;
title('Total Pixels')
figure(4);
plot(end_image, 'b^');
grid on;
title('End Image')
%}
figure(5);
plot(div_ratio, 'k^');
grid on;
title('Division Ratio')
figure(6);
plot(pos_error, 'b^');
grid on;
title('Position Error')
pd_pos(end)
tot_pixels(end)
effective_ratio = pd_pos(end)/tot_pixels(end)