From c6116093eb3018f16d618ebdd183eec4e1218754 Mon Sep 17 00:00:00 2001 From: gianmarcogirau Date: Mon, 16 Dec 2019 15:46:20 +0000 Subject: [PATCH 01/15] CORE-73 - Initial commit of FPM-5: just renamed components from FPM-4 --- generic_ip/fire_pulse_manager/5/Readme.txt | 1 + .../5/build/fire_pulse_manager_5.qip | 65 ++ .../5/build/fire_pulse_manager_5_hw.tcl | 294 +++++++ .../fire_pulse_manager/5/doc/fpm_5.json | 55 ++ .../fire_pulse_manager/5/doc/fpm_ctrl_5.json | 310 ++++++++ .../fire_pulse_manager/5/doc/fpm_diags_5.json | 495 ++++++++++++ .../fire_pulse_manager/5/sim/sim_fpm.do | 113 +++ .../fire_pulse_manager/5/sim/wave_fpm.do | 403 ++++++++++ .../5/src/fire_pulse_5_pkg.vhd | 37 + .../5/src/fire_pulse_ctrl_5.vhd | 276 +++++++ .../5/src/fire_pulse_ext_5.vhd | 108 +++ .../5/src/fire_pulse_manager_5.vhd | 622 +++++++++++++++ .../5/src/simple_enc_vel_detect_5.vhd | 76 ++ .../5/src/smb_diagnostics_5.vhd | 702 +++++++++++++++++ .../5/src/test/fire_pulse_manager_5_tb.vhd | 719 ++++++++++++++++++ generic_ip/fire_pulse_manager/Readme.txt | 4 +- 16 files changed, 4279 insertions(+), 1 deletion(-) create mode 100644 generic_ip/fire_pulse_manager/5/Readme.txt create mode 100644 generic_ip/fire_pulse_manager/5/build/fire_pulse_manager_5.qip create mode 100644 generic_ip/fire_pulse_manager/5/build/fire_pulse_manager_5_hw.tcl create mode 100644 generic_ip/fire_pulse_manager/5/doc/fpm_5.json create mode 100644 generic_ip/fire_pulse_manager/5/doc/fpm_ctrl_5.json create mode 100644 generic_ip/fire_pulse_manager/5/doc/fpm_diags_5.json create mode 100644 generic_ip/fire_pulse_manager/5/sim/sim_fpm.do create mode 100644 generic_ip/fire_pulse_manager/5/sim/wave_fpm.do create mode 100644 generic_ip/fire_pulse_manager/5/src/fire_pulse_5_pkg.vhd create mode 100644 generic_ip/fire_pulse_manager/5/src/fire_pulse_ctrl_5.vhd create mode 100644 generic_ip/fire_pulse_manager/5/src/fire_pulse_ext_5.vhd create mode 100644 generic_ip/fire_pulse_manager/5/src/fire_pulse_manager_5.vhd create mode 100644 generic_ip/fire_pulse_manager/5/src/simple_enc_vel_detect_5.vhd create mode 100644 generic_ip/fire_pulse_manager/5/src/smb_diagnostics_5.vhd create mode 100644 generic_ip/fire_pulse_manager/5/src/test/fire_pulse_manager_5_tb.vhd diff --git a/generic_ip/fire_pulse_manager/5/Readme.txt b/generic_ip/fire_pulse_manager/5/Readme.txt new file mode 100644 index 0000000..63b3fad --- /dev/null +++ b/generic_ip/fire_pulse_manager/5/Readme.txt @@ -0,0 +1 @@ +FPM Major version 5: FPM with Programmable number of channels \ No newline at end of file diff --git a/generic_ip/fire_pulse_manager/5/build/fire_pulse_manager_5.qip b/generic_ip/fire_pulse_manager/5/build/fire_pulse_manager_5.qip new file mode 100644 index 0000000..5a5c06a --- /dev/null +++ b/generic_ip/fire_pulse_manager/5/build/fire_pulse_manager_5.qip @@ -0,0 +1,65 @@ +set_global_assignment -name IP_TOOL_NAME "fire_pulse_manager_5" +set_global_assignment -name IP_TOOL_VERSION "18.0" +set_global_assignment -name IP_GENERATED_DEVICE_FAMILY "{Cyclone V}" + +set COMMON_PATH ../../../common/0/src +set POF_PATH_0 ../../../pof_protocol/0/src +set POF_PATH_1 ../../../pof_protocol/1/src +set SEQUENCER_PATH ../../../generic_sequencer/15/src +set PULSE_GEN_PATH ../../../pulse_generator/2/src +set EMUL_PATH ../../../enc_pd_emul/1/src +set LOG_PATH ../../../event_logger/0/src +set SRC_PATH ../src + +# common +set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "$COMMON_PATH/sync_reset.vhd"] +set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "$COMMON_PATH/common_pkg.vhd"] +set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "$COMMON_PATH/sync_wire.vhd"] +set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "$COMMON_PATH/sync_wire_rEdge.vhd"] +set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "$COMMON_PATH/altera/sync_fifo.vhd"] +set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "$COMMON_PATH/queue_and_delay.vhd"] +set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "$COMMON_PATH/dpram_sclk.vhd"] + +# Generic Sequencer +set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "$SEQUENCER_PATH/altera/generic_seq_ram_15.vhd"] +set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "$SEQUENCER_PATH/generic_sequencer_15_pkg.vhd"] +set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "$SEQUENCER_PATH/generic_sequencer_15.vhd"] + +# Pulse Generator +set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "$PULSE_GEN_PATH/pulse_conditioning_2.vhd"] +set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "$PULSE_GEN_PATH/simple_frac_div_2.vhd"] +set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "$PULSE_GEN_PATH/pulse_generator_2_pkg.vhd"] +set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "$PULSE_GEN_PATH/pulse_generator_2.vhd"] + +# Emulator +set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "$EMUL_PATH/enc_pd_emul_1_pkg.vhd"] +set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "$EMUL_PATH/enc_pd_emul_1.vhd"] + +# Event Logger +set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "$LOG_PATH/event_logger_0_pkg.vhd"] +set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "$LOG_PATH/event_logger_0.vhd"] + +# POF-Rx +set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "$POF_PATH_0/pof_uart_rx_0.vhd"] +set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "$POF_PATH_0/pof_rx_0.vhd"] +set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "$POF_PATH_0/pof_uart_regen_0.vhd"] +set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "$POF_PATH_0/uart_tx_0.vhd"] +set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "$POF_PATH_0/pof_tx_0.vhd"] + +set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "$POF_PATH_1/pof_uart_rx_1.vhd"] +set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "$POF_PATH_1/pof_rx_1.vhd"] +set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "$POF_PATH_1/pof_uart_regen_1.vhd"] +set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "$POF_PATH_1/uart_tx_1.vhd"] +set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "$POF_PATH_1/pof_tx_1.vhd"] + +# Fire-Pulse-Manager +set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "$COMMON_PATH/cs_bus_itf.vhd"] +set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "$SRC_PATH/smb_diagnostics_5.vhd"] +set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "$SRC_PATH/simple_enc_vel_detect_5.vhd"] +set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "$SRC_PATH/fire_pulse_5_pkg.vhd"] +set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "$SRC_PATH/fire_pulse_ctrl_5.vhd"] +set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "$SRC_PATH/fire_pulse_ext_5.vhd"] +set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "$SRC_PATH/fire_pulse_manager_5.vhd"] + + + diff --git a/generic_ip/fire_pulse_manager/5/build/fire_pulse_manager_5_hw.tcl b/generic_ip/fire_pulse_manager/5/build/fire_pulse_manager_5_hw.tcl new file mode 100644 index 0000000..ff96520 --- /dev/null +++ b/generic_ip/fire_pulse_manager/5/build/fire_pulse_manager_5_hw.tcl @@ -0,0 +1,294 @@ +# TCL File Generated by Component Editor 16.0 +# Wed Oct 25 15:26:07 BST 2017 +# DO NOT MODIFY + + +# +# fire_pulse_manager_0 "fire_pulse_manager_5" v1.0 +# GMG 2017.10.25.15:26:07 +# Fire Pulse Manager +# + +# +# request TCL package from ACDS 16.0 +# +package require -exact qsys 16.0 + + +# +# module fire_pulse_manager_0 +# +set_module_property DESCRIPTION "Fire Pulse Manager" +set_module_property NAME fire_pulse_manager_5 +set_module_property VERSION 1.0 +set_module_property INTERNAL false +set_module_property OPAQUE_ADDRESS_MAP true +set_module_property GROUP "GIS Components" +set_module_property AUTHOR GMG +set_module_property DISPLAY_NAME fire_pulse_manager_5 +set_module_property INSTANTIATE_IN_SYSTEM_MODULE true +set_module_property EDITABLE true +set_module_property REPORT_TO_TALKBACK false +set_module_property ALLOW_GREYBOX_GENERATION false +set_module_property REPORT_HIERARCHY false + + +# +# file sets +# +add_fileset QUARTUS_SYNTH QUARTUS_SYNTH "" "" +set_fileset_property QUARTUS_SYNTH TOP_LEVEL fire_pulse_manager_5 +set_fileset_property QUARTUS_SYNTH ENABLE_RELATIVE_INCLUDE_PATHS false +set_fileset_property QUARTUS_SYNTH ENABLE_FILE_OVERWRITE_MODE false +#add_fileset_file pkg_functions.vhd VHDL PATH ../../../common/0/src/pkg_functions.vhd +add_fileset_file common_pkg.vhd VHDL PATH ../../../common/0/src/common_pkg.vhd +add_fileset_file sync_reset.vhd VHDL PATH ../../../common/0/src/sync_reset.vhd +add_fileset_file sync_wire.vhd VHDL PATH ../../../common/0/src/sync_wire.vhd +add_fileset_file sync_wire_rEdge.vhd VHDL PATH ../../../common/0/src/sync_wire_rEdge.vhd +add_fileset_file fifo_1024x32.vhd VHDL PATH ../../../common/0//src/altera/fifo_1024x32.vhd +add_fileset_file fifo_256x32.vhd VHDL PATH ../../../common/0/src/altera/fifo_256x32.vhd +add_fileset_file sync_fifo.vhd VHDL PATH ../../../common/0/src/altera/sync_fifo.vhd +add_fileset_file cs_bus_itf.vhd VHDL PATH ../../../common/0/src/cs_bus_itf.vhd +add_fileset_file dpram_sclk.vhd VHDL PATH ../../../common/0/src/dpram_sclk.vhd +add_fileset_file generic_seq_ram_15.vhd VHDL PATH ../../../generic_sequencer/15/src/altera/generic_seq_ram_15.vhd +add_fileset_file generic_sequencer_15_pkg.vhd VHDL PATH ../../../generic_sequencer/15/src/generic_sequencer_15_pkg.vhd +add_fileset_file generic_sequencer_15.vhd VHDL PATH ../../../generic_sequencer/15/src/generic_sequencer_15.vhd +add_fileset_file enc_pd_emul_1_pkg.vhd VHDL PATH ../../../enc_pd_emul/1/src/enc_pd_emul_1_pkg.vhd +add_fileset_file enc_pd_emul_1.vhd VHDL PATH ../../../enc_pd_emul/1/src/enc_pd_emul_1.vhd +add_fileset_file event_logger_0_pkg.vhd VHDL PATH ../../../event_logger/0/src/event_logger_0_pkg.vhd +add_fileset_file event_logger_0.vhd VHDL PATH ../../../event_logger/0/src/event_logger_0.vhd +add_fileset_file pulse_conditioning_2.vhd VHDL PATH ../../../pulse_generator/2/src/pulse_conditioning_2.vhd +add_fileset_file queue_and_delay.vhd VHDL PATH ../../../common/0/src/queue_and_delay.vhd +add_fileset_file simple_frac_div_2.vhd VHDL PATH ../../../pulse_generator/2/src/simple_frac_div_2.vhd +add_fileset_file pulse_generator_2_pkg.vhd VHDL PATH ../../../pulse_generator/2/src/pulse_generator_2_pkg.vhd +add_fileset_file pulse_generator_2.vhd VHDL PATH ../../../pulse_generator/2/src/pulse_generator_2.vhd +add_fileset_file pof_uart_rx_0.vhd VHDL PATH ../../../pof_protocol/0/src/pof_uart_rx_0.vhd +add_fileset_file pof_rx_0.vhd VHDL PATH ../../../pof_protocol/0/src/pof_rx_0.vhd +add_fileset_file pof_uart_regen_0.vhd VHDL PATH ../../../pof_protocol/0/src/pof_uart_regen_0.vhd +add_fileset_file pof_uart_rx_1.vhd VHDL PATH ../../../pof_protocol/1/src/pof_uart_rx_1.vhd +add_fileset_file pof_rx_1.vhd VHDL PATH ../../../pof_protocol/1/src/pof_rx_1.vhd +add_fileset_file pof_uart_regen_1.vhd VHDL PATH ../../../pof_protocol/1/src/pof_uart_regen_1.vhd +add_fileset_file smb_diagnostics_2.vhd VHDL PATH ../src/smb_diagnostics_2.vhd +add_fileset_file fire_pulse_5_pkg.vhd VHDL PATH ../src/fire_pulse_5_pkg.vhd +add_fileset_file simple_enc_vel_detect_5.vhd VHDL PATH ../src/simple_enc_vel_detect_5.vhd +add_fileset_file fire_pulse_ctrl_5.vhd VHDL PATH ../src/fire_pulse_ctrl_5.vhd +add_fileset_file fire_pulse_manager_5.vhd VHDL PATH ../src/fire_pulse_manager_5.vhd TOP_LEVEL_FILE + +add_fileset SIM_VHDL SIM_VHDL "" "" +set_fileset_property SIM_VHDL TOP_LEVEL fire_pulse_manager_5 +set_fileset_property SIM_VHDL ENABLE_RELATIVE_INCLUDE_PATHS false +set_fileset_property SIM_VHDL ENABLE_FILE_OVERWRITE_MODE false +add_fileset_file common_pkg.vhd VHDL PATH ../../../common/0/src/common_pkg.vhd +add_fileset_file sync_reset.vhd VHDL PATH ../../../common/0/src/sync_reset.vhd +add_fileset_file sync_wire.vhd VHDL PATH ../../../common/0/src/sync_wire.vhd +add_fileset_file sync_wire_rEdge.vhd VHDL PATH ../../../common/0/src/sync_wire_rEdge.vhd +add_fileset_file fifo_1024x32.vhd VHDL PATH ../../../common/0//src/altera/fifo_1024x32.vhd +add_fileset_file fifo_256x32.vhd VHDL PATH ../../../common/0/src/altera/fifo_256x32.vhd +add_fileset_file sync_fifo.vhd VHDL PATH ../../../common/0/src/altera/sync_fifo.vhd +add_fileset_file cs_bus_itf.vhd VHDL PATH ../../../common/0/src/cs_bus_itf.vhd +add_fileset_file dpram_sclk.vhd VHDL PATH ../../../common/0/src/dpram_sclk.vhd +add_fileset_file generic_seq_ram_15.vhd VHDL PATH ../../../generic_sequencer/15/src/altera/generic_seq_ram_15.vhd +add_fileset_file generic_sequencer_15_pkg.vhd VHDL PATH ../../../generic_sequencer/15/src/generic_sequencer_15_pkg.vhd +add_fileset_file generic_sequencer_15.vhd VHDL PATH ../../../generic_sequencer/15/src/generic_sequencer_15.vhd +add_fileset_file enc_pd_emul_1_pkg.vhd VHDL PATH ../../../enc_pd_emul/1/src/enc_pd_emul_1_pkg.vhd +add_fileset_file enc_pd_emul_1.vhd VHDL PATH ../../../enc_pd_emul/1/src/enc_pd_emul_1.vhd +add_fileset_file event_logger_0_pkg.vhd VHDL PATH ../../../event_logger/0/src/event_logger_0_pkg.vhd +add_fileset_file event_logger_0.vhd VHDL PATH ../../../event_logger/0/src/event_logger_0.vhd +add_fileset_file pulse_conditioning_2.vhd VHDL PATH ../../../pulse_generator/2/src/pulse_conditioning_2.vhd +add_fileset_file queue_and_delay.vhd VHDL PATH ../../../common/0/src/queue_and_delay.vhd +add_fileset_file simple_frac_div_2.vhd VHDL PATH ../../../pulse_generator/2/src/simple_frac_div_2.vhd +add_fileset_file pulse_generator_2_pkg.vhd VHDL PATH ../../../pulse_generator/2/src/pulse_generator_2_pkg.vhd +add_fileset_file pulse_generator_2.vhd VHDL PATH ../../../pulse_generator/2/src/pulse_generator_2.vhd +add_fileset_file pof_uart_rx_0.vhd VHDL PATH ../../../pof_protocol/0/src/pof_uart_rx_0.vhd +add_fileset_file pof_rx_0.vhd VHDL PATH ../../../pof_protocol/0/src/pof_rx_0.vhd +add_fileset_file pof_uart_regen_0.vhd VHDL PATH ../../../pof_protocol/0/src/pof_uart_regen_0.vhd +add_fileset_file pof_uart_rx_1.vhd VHDL PATH ../../../pof_protocol/1/src/pof_uart_rx_1.vhd +add_fileset_file pof_rx_1.vhd VHDL PATH ../../../pof_protocol/1/src/pof_rx_1.vhd +add_fileset_file pof_uart_regen_1.vhd VHDL PATH ../../../pof_protocol/1/src/pof_uart_regen_1.vhd +add_fileset_file smb_diagnostics_2.vhd VHDL PATH ../src/smb_diagnostics_2.vhd +add_fileset_file fire_pulse_5_pkg.vhd VHDL PATH ../src/fire_pulse_5_pkg.vhd +add_fileset_file simple_enc_vel_detect_5.vhd VHDL PATH ../src/simple_enc_vel_detect_5.vhd +add_fileset_file fire_pulse_ctrl_5.vhd VHDL PATH ../src/fire_pulse_ctrl_5.vhd +add_fileset_file fire_pulse_manager_5.vhd VHDL PATH ../src/fire_pulse_manager_5.vhd + + +# +# parameters +# + + +# +# display items +# + + +# +# connection point clock +# +add_interface clock clock end +set_interface_property clock clockRate 0 +set_interface_property clock ENABLED true +set_interface_property clock EXPORT_OF "" +set_interface_property clock PORT_NAME_MAP "" +set_interface_property clock CMSIS_SVD_VARIABLES "" +set_interface_property clock SVD_ADDRESS_GROUP "" + +add_interface_port clock clk clk Input 1 + + +# +# connection point reset +# +add_interface reset reset end +set_interface_property reset associatedClock clock +set_interface_property reset synchronousEdges DEASSERT +set_interface_property reset ENABLED true +set_interface_property reset EXPORT_OF "" +set_interface_property reset PORT_NAME_MAP "" +set_interface_property reset CMSIS_SVD_VARIABLES "" +set_interface_property reset SVD_ADDRESS_GROUP "" + +add_interface_port reset reset_n reset_n Input 1 + + +# +# connection point avs +# +add_interface avs avalon end +set_interface_property avs addressUnits WORDS +set_interface_property avs associatedClock clock +set_interface_property avs associatedReset reset +set_interface_property avs bitsPerSymbol 8 +set_interface_property avs burstOnBurstBoundariesOnly false +set_interface_property avs burstcountUnits WORDS +set_interface_property avs explicitAddressSpan 0 +set_interface_property avs holdTime 0 +set_interface_property avs linewrapBursts false +set_interface_property avs maximumPendingReadTransactions 0 +set_interface_property avs maximumPendingWriteTransactions 0 +set_interface_property avs readLatency 0 +set_interface_property avs readWaitTime 1 +set_interface_property avs setupTime 0 +set_interface_property avs timingUnits Cycles +set_interface_property avs writeWaitTime 0 +set_interface_property avs ENABLED true +set_interface_property avs EXPORT_OF "" +set_interface_property avs PORT_NAME_MAP "" +set_interface_property avs CMSIS_SVD_VARIABLES "" +set_interface_property avs SVD_ADDRESS_GROUP "" + +add_interface_port avs avs_address address Input 15 +add_interface_port avs avs_write write Input 1 +add_interface_port avs avs_writedata writedata Input 32 +add_interface_port avs avs_read read Input 1 +add_interface_port avs avs_readdata readdata Output 32 +add_interface_port avs avs_waitrequest waitrequest Output 1 +set_interface_assignment avs embeddedsw.configuration.isFlash 0 +set_interface_assignment avs embeddedsw.configuration.isMemoryDevice 0 +set_interface_assignment avs embeddedsw.configuration.isNonVolatileStorage 0 +set_interface_assignment avs embeddedsw.configuration.isPrintableDevice 0 + + +# +# connection point conduit_end +# +add_interface conduit_end conduit end +set_interface_property conduit_end associatedClock clock +set_interface_property conduit_end associatedReset reset +set_interface_property conduit_end ENABLED true +set_interface_property conduit_end EXPORT_OF "" +set_interface_property conduit_end PORT_NAME_MAP "" +set_interface_property conduit_end CMSIS_SVD_VARIABLES "" +set_interface_property conduit_end SVD_ADDRESS_GROUP "" + +add_interface_port conduit_end pof_rx pof_rx Input 1 +add_interface_port conduit_end pof_tx pof_tx Output 1 +add_interface_port conduit_end pof_iso_en pof_iso_en Output 1 +add_interface_port conduit_end fire_pulse fire_pulse Output 1 +add_interface_port conduit_end abs_pos_out abs_pos_out Output 32 +add_interface_port conduit_end print_start print_start Output 1 +add_interface_port conduit_end mon_pt mon_pt Output 4 + + +# +# connection point rx_clk +# +add_interface rx_clk clock end +set_interface_property rx_clk clockRate 0 +set_interface_property rx_clk ENABLED true +set_interface_property rx_clk EXPORT_OF "" +set_interface_property rx_clk PORT_NAME_MAP "" +set_interface_property rx_clk CMSIS_SVD_VARIABLES "" +set_interface_property rx_clk SVD_ADDRESS_GROUP "" + +add_interface_port rx_clk rx_clk clk Input 1 + + +# +# connection point irq_0 +# +add_interface irq_0 interrupt end +set_interface_property irq_0 associatedAddressablePoint "" +set_interface_property irq_0 associatedClock clock +set_interface_property irq_0 associatedReset reset +set_interface_property irq_0 bridgedReceiverOffset "" +set_interface_property irq_0 bridgesToReceiver "" +set_interface_property irq_0 ENABLED true +set_interface_property irq_0 EXPORT_OF "" +set_interface_property irq_0 PORT_NAME_MAP "" +set_interface_property irq_0 CMSIS_SVD_VARIABLES "" +set_interface_property irq_0 SVD_ADDRESS_GROUP "" + +add_interface_port irq_0 ins_fpm_irq_0 irq Output 1 + +# +# connection point irq_1 +# +add_interface irq_1 interrupt end +set_interface_property irq_1 associatedAddressablePoint "" +set_interface_property irq_1 associatedClock clock +set_interface_property irq_1 associatedReset reset +set_interface_property irq_1 bridgedReceiverOffset "" +set_interface_property irq_1 bridgesToReceiver "" +set_interface_property irq_1 ENABLED true +set_interface_property irq_1 EXPORT_OF "" +set_interface_property irq_1 PORT_NAME_MAP "" +set_interface_property irq_1 CMSIS_SVD_VARIABLES "" +set_interface_property irq_1 SVD_ADDRESS_GROUP "" + +add_interface_port irq_1 ins_fpm_irq_1 irq Output 1 + +# +# connection point irq_2 +# +add_interface irq_2 interrupt end +set_interface_property irq_2 associatedAddressablePoint "" +set_interface_property irq_2 associatedClock clock +set_interface_property irq_2 associatedReset reset +set_interface_property irq_2 bridgedReceiverOffset "" +set_interface_property irq_2 bridgesToReceiver "" +set_interface_property irq_2 ENABLED true +set_interface_property irq_2 EXPORT_OF "" +set_interface_property irq_2 PORT_NAME_MAP "" +set_interface_property irq_2 CMSIS_SVD_VARIABLES "" +set_interface_property irq_2 SVD_ADDRESS_GROUP "" + +add_interface_port irq_2 ins_fpm_irq_2 irq Output 1 + +# +# connection point irq_3 +# +add_interface irq_3 interrupt end +set_interface_property irq_3 associatedAddressablePoint "" +set_interface_property irq_3 associatedClock clock +set_interface_property irq_3 associatedReset reset +set_interface_property irq_3 bridgedReceiverOffset "" +set_interface_property irq_3 bridgesToReceiver "" +set_interface_property irq_3 ENABLED true +set_interface_property irq_3 EXPORT_OF "" +set_interface_property irq_3 PORT_NAME_MAP "" +set_interface_property irq_3 CMSIS_SVD_VARIABLES "" +set_interface_property irq_3 SVD_ADDRESS_GROUP "" + +add_interface_port irq_3 ins_fpm_irq_3 irq Output 1 + diff --git a/generic_ip/fire_pulse_manager/5/doc/fpm_5.json b/generic_ip/fire_pulse_manager/5/doc/fpm_5.json new file mode 100644 index 0000000..68b44dd --- /dev/null +++ b/generic_ip/fire_pulse_manager/5/doc/fpm_5.json @@ -0,0 +1,55 @@ +[{ + "ip_name" : "fpm_5", + "bus" : "csr", + "addr_hi_bit" : "14", + "addr_lo_bit" : "11", + "description" : "Fire-Pulse-Manager version 5", + "sub_blocks" : { + "fpm_ctrl_5" : { + "instance" : "", + "process" : "cpp, txt", + "offset" : "0x0000" + }, + "fpm_diags_5" : { + "instance" : "", + "process" : "cpp, txt", + "note" : "This block is instantiated only when generic ADD_SMB_DIAG is set to true", + "offset" : "0x0800" + }, + "event_logger_0" : { + "instance" : "", + "process" : "cpp, txt", + "note" : "This block is instantiated only when generic ADD_EVENT_LOGGER is set to true", + "offset" : "0x1000" + }, + "enc_pd_emul_1" : { + "instance" : "", + "process" : "cpp, txt", + "offset" : "0x1800" + }, + "pulse_generator_2:a" : { + "instance" : "0", + "process" : "cpp, txt", + "offset" : "0x2000" + }, + "pulse_generator_2:b" : { + "instance" : "1", + "process" : "cpp, txt", + "note" : "This block may not be instantiated depending on the value of generic CH_NUM specified in the FPM top-level", + "offset" : "0x2800" + }, + "pulse_generator_2:c" : { + "instance" : "2", + "process" : "cpp, txt", + "note" : "This block may not be instantiated depending on the value of generic CH_NUM specified in the FPM top-level", + "offset" : "0x3000" + }, + "pulse_generator_2:d" : { + "instance" : "3", + "process" : "cpp, txt", + "note" : "This block may not be instantiated depending on the value of generic CH_NUM specified in the FPM top-level", + "offset" : "0x3800" + } + } +} +] \ No newline at end of file diff --git a/generic_ip/fire_pulse_manager/5/doc/fpm_ctrl_5.json b/generic_ip/fire_pulse_manager/5/doc/fpm_ctrl_5.json new file mode 100644 index 0000000..27868c8 --- /dev/null +++ b/generic_ip/fire_pulse_manager/5/doc/fpm_ctrl_5.json @@ -0,0 +1,310 @@ +[{ + "ip_name": "fpm_ctrl_5", + "bus": "csr", + "description": "This block is the fire pulse manager control", + "registers": { + "ip_id" : { + "address" : "0", + "width" : "32", + "description" : "Unique ID for this IP block", + "fields": { + "ip_number" : { + "type" : "c", + "bit_len" : "8", + "reset" : "0x14", + "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" + } + } + }, + "Signal selection": { + "address": "2", + "width": "2", + "description": "Controls signal selection", + "fields": { + "fire_pulse_sel": { + "type": "w", + "bit_len": "1", + "reset": "0x0", + "description": "0 => Use External fire pulses, 1 => Use FPM fire pulses" + }, + "enc_pd_emul_en": { + "type": "w", + "bit_len": "1", + "reset": "0x0", + "description": "0 => Use POF RX, 1 => Use internal enc/PD emulator" + } + } + }, + "pof_receiver_control": { + "address": "3", + "width": "8", + "description": "Controls POF receiver", + "fields": { + "pof_rx_enable": { + "type": "w", + "bit_len": "1", + "reset": "0x0", + "description": "0 => Disable POF RX, 1 => Enable POF RX" + }, + "uart_regeneration_bypass": { + "type": "w", + "bit_len": "1", + "reset": "0x0", + "description": "0 => Use UART Regeneration, 1 => Bypass UART Regeneration" + }, + "clear_max": { + "type": "w", + "bit_len": "1", + "reset": "0x0", + "description": "0 => Disabled, 1 => Load the current value of Absolute Position as new maximum" + }, + "clear_min": { + "type": "w", + "bit_len": "1", + "reset": "0x0", + "description": "0 => Disabled, 1 => Load the current value of Absolute Position as new miniumum" + }, + "uart_rx_div": { + "type": "w", + "bit_len": "4", + "reset": "0x4", + "description": "Defines the number of 200 MHz clock cycles per UART data bit" + } + } + }, + "monitoring_point_selection": { + "address": "4", + "width": "16", + "description": "Selects monitoring points for external header", + "fields": { + "mp0": { + "type": "w", + "bit_len": "4", + "reset": "0x0", + "description": "Selects first monitoring point" + }, + "mp1": { + "type": "w", + "bit_len": "4", + "reset": "0x0", + "description": "Selects second monitoring point" + }, + "mp2": { + "type": "w", + "bit_len": "4", + "reset": "0x0", + "description": "Selects third monitoring point" + }, + "mp3": { + "type": "w", + "bit_len": "4", + "reset": "0x0", + "description": "Selects fourth monitoring point" + } + } + }, + "coarse_time_init": { + "type": "w", + "address": "5", + "reset": "0x00000000", + "width": "32", + "description": "Defines coarse time counter value" + }, + "fine_time_init": { + "address": "6", + "width": "29", + "description": "Fine time counter value/Load counter enable", + "fields": { + "fine_time_init": { + "type" :"w", + "bit_len": "28", + "reset": "0x0000000", + "description": "Defines fine time counter value" + }, + "time_load_en": { + "type" :"w", + "bit_len" : "1", + "reset": "0x0", + "description" : "Writting 1 loads the coarse and fine time counters" + } + } + }, + "fine_time_status": { + "type": "r", + "address": "7", + "reset": "0x0000000", + "width": "28", + "description": "Current fine time counter value" + }, + "coarse_time_status": { + "type": "r", + "address": "8", + "reset": "0x00000000", + "width": "32", + "description": "Current coarse time counter value" + }, + "pof_rx_status": { + "address": "9", + "width": "32", + "description": "Status of POF receiver", + "fields": { + "parity_bit_error_count": { + "type": "r", + "bit_len": "16", + "reset": "0x0000", + "description": "Counts number of parity errors" + }, + "skipped_position_error_count": { + "type": "r", + "bit_len": "16", + "reset": "0x0000", + "description": "Counts position skipped type errors" + } + } + }, + "pof_rx_control": { + "address": "10", + "width": "12", + "description": "POF receiver error control", + "fields": { + "error_rate_thres": { + "type" : "w", + "bit_len": "8", + "reset": "0x0A", + "description": "Defines RX error rate threshold" + }, + "rx_watchdog_en": { + "type": "w", + "bit_len": "1", + "reset": "0x1", + "description": "0 => Disable RX watchdog, 1 => Enable RX Watchdog" + }, + "rx_watchdog_clr": { + "type": "w", + "bit_len": "1", + "reset": "0x0", + "description": "0 => RX watchdog counter running, 1 => Clear RX watchdog counter" + }, + "rx_watchdog": { + "type": "r", + "bit_len": "1", + "reset": "0x0", + "description": "0 => RX watchdog not triggered, 1 => RX watchdog triggered" + }, + "rx_error_flag": { + "type": "r", + "bit_len": "1", + "reset": "0x0", + "description": "0 => Error rate below threshold, 1 => Error rate above threshold" + } + } + }, + "fpm_interrupt": { + "address": "11", + "width": "16", + "description": "Interrupt control", + "fields": { + "irq_en": { + "type": "w", + "bit_len": "1", + "reset": "0x0", + "description": "0 => Disable IRQ, 1 => Enable IRQ" + }, + "reserved1": { + "type": "rsv", + "bit_len": "3", + "description": "Reserved" + }, + "irq_clr": { + "type": "w", + "bit_len": "1", + "reset": "0x0", + "description": "0 => Don't clear pending IRQ, 1 => Clear pending IRQ" + }, + "reserved2": { + "type": "rsv", + "bit_len": "3", + "description": "Reserved" + }, + "irq_mask": { + "type": "w", + "bit_len": "1", + "reset": "0x0", + "description": "0 => IRQ not masked, 1 => IRQ masked" + }, + "reserved3": { + "type": "rsv", + "bit_len": "3", + "description": "Reserved" + }, + "irq_status": { + "type": "r", + "bit_len": "1", + "reset": "0x0", + "description": "0 => IRQ not active, 1 => IRQ active" + }, + "reserved4": { + "type": "rsv", + "bit_len": "3", + "description": "Reserved" + } + } + }, + "fpm_ext_ctrl": { + "address": "12", + "width": "32", + "description": "Controls regeneration of external fire pulses", + "fields": { + "ext_fp_det": { + "type": "w", + "bit_len": "16", + "reset": "0x0010", + "description": "Minimum width of external fire pulses" + }, + "ext_fp_gen": { + "type": "w", + "bit_len": "16", + "reset": "0x0020", + "description": "Width of regenerated external fire pulses" + } + } + } + } + }] \ No newline at end of file diff --git a/generic_ip/fire_pulse_manager/5/doc/fpm_diags_5.json b/generic_ip/fire_pulse_manager/5/doc/fpm_diags_5.json new file mode 100644 index 0000000..0ec64dd --- /dev/null +++ b/generic_ip/fire_pulse_manager/5/doc/fpm_diags_5.json @@ -0,0 +1,495 @@ +[{ + "ip_name": "fpm_diags_5", + "bus": "csr", + "description": "SMB diagnostics", + "registers": { + "init": { + "address": "0", + "width": "7", + "description": "Diagnostic reset", + "fields": { + "init": { + "type": "w", + "bit_len": "1", + "reset": "0x0", + "description": "initialize the full diagnostic block" + }, + "rst_counters": { + "type": "w", + "bit_len": "1", + "reset": "0x0", + "description": "reset only edge counters" + }, + "rst_measur": { + "type": "w", + "bit_len": "1", + "reset": "0x0", + "description": "reset only time-based velocity/acceleration measurement registers" + }, + "rst_dir": { + "type": "w", + "bit_len": "1", + "reset": "0x0", + "description": "reset only the logic for direction detection" + }, + "rst_enc_fifo": { + "type": "w", + "bit_len": "1", + "reset": "0x0", + "description": "reset only the encoder fifo" + }, + "rst_pos": { + "type": "w", + "bit_len": "1", + "reset": "0x0", + "description": "reset only the position detection register" + }, + "rst_pd_fifo": { + "type": "w", + "bit_len": "1", + "reset": "0x0", + "description": "reset only the PD fifo" + } + } + }, + "input_status": { + "address": "1", + "width": "17", + "description": "Instantaneous status of input signals", + "fields": { + "rs422_p1": { + "type": "r", + "bit_len": "1", + "reset": "0x00", + "description": "RS422 encoder phase-1" + }, + "rs422_p2": { + "type": "r", + "bit_len": "1", + "reset": "0x00", + "description": "RS422 encoder phase-2" + }, + "rs422_zp": { + "type": "r", + "bit_len": "1", + "reset": "0x00", + "description": "RS422 encoder zero-phase" + }, + "rs422_pd": { + "type": "r", + "bit_len": "1", + "reset": "0x00", + "description": "RS422 Product Detect" + }, + "ttl_p1": { + "type": "r", + "bit_len": "1", + "reset": "0x00", + "description": "TTL encoder phase-1" + }, + "ttl_p2": { + "type": "r", + "bit_len": "1", + "reset": "0x00", + "description": "TTL encoder phase-2" + }, + "ttl_zp": { + "type": "r", + "bit_len": "1", + "reset": "0x00", + "description": "TTL encoder zero-phase" + }, + "ttl_pd_pnp": { + "type": "r", + "bit_len": "1", + "reset": "0x00", + "description": "TTL (PNP) Product Detect" + }, + "ttl_pd_npn": { + "type": "r", + "bit_len": "1", + "reset": "0x00", + "description": "TTL (NPN) Product Detect" + }, + "filt_p1": { + "type": "r", + "bit_len": "1", + "reset": "0x00", + "description": "EMS filtered p1" + }, + "filt_p2": { + "type": "r", + "bit_len": "1", + "reset": "0x00", + "description": "EMS filtered p2" + }, + "filt_zp": { + "type": "r", + "bit_len": "1", + "reset": "0x00", + "description": "EMS filtered zp" + }, + "filt_pd": { + "type": "r", + "bit_len": "1", + "reset": "0x00", + "description": "EMS filtered pd" + }, + "enc_pulse": { + "type": "r", + "bit_len": "1", + "reset": "0x00", + "description": "enc_pulse (after jitter removal)" + }, + "pd_out": { + "type": "r", + "bit_len": "1", + "reset": "0x00", + "description": "PD output" + }, + "drop_watch": { + "type": "r", + "bit_len": "1", + "reset": "0x00", + "description": "drop watch)" + }, + "fire_req": { + "type": "r", + "bit_len": "1", + "reset": "0x00", + "description": "fire request" + } + } + }, + "phase1_counter": { + "type": "r", + "address": "2", + "reset": "0x0", + "width": "32", + "description": "Encoder Phase-1 (filtered) edge counter" + }, + "phase2_counter": { + "type": "r", + "address": "3", + "reset": "0x0", + "width": "32", + "description": "Encoder Phase-2 (filtered) edge counter" + }, + "zero_phase_counter": { + "type": "r", + "address": "4", + "reset": "0x0", + "width": "32", + "description": "Encoder Zero-Phase (filtered) edge counter" + }, + "pd_counter": { + "type": "r", + "address": "5", + "reset": "0x0", + "width": "32", + "description": "PD (filtered) edge counter" + }, + "enc_pulse_counter": { + "type": "r", + "address": "6", + "reset": "0x0", + "width": "32", + "description": "encoder pulse counter (after jitter removal)" + }, + "pd_output_counter": { + "type": "r", + "address": "7", + "reset": "0x0", + "width": "32", + "description": "PD output edge counter" + }, + "fire_request_counter": { + "type": "r", + "address": "8", + "reset": "0x0", + "width": "32", + "description": "Fire-Request counter" + }, + "aux_in_0_counter": { + "type": "r", + "address": "9", + "reset": "0x0", + "width": "32", + "description": "aux_in_0 counter" + }, + "aux_in_1_counter": { + "type": "r", + "address": "10", + "reset": "0x0", + "width": "32", + "description": "aux_in_1 counter" + }, + "aux_in_2_counter": { + "type": "r", + "address": "11", + "reset": "0x0", + "width": "32", + "description": "aux_in_2 counter" + }, + "delta_time_meas": { + "type": "r", + "address": "12", + "reset": "0x0", + "width": "32", + "description": "Delta-time measurement" + }, + "deltamin_time_meas": { + "type": "r", + "address": "13", + "reset": "0x0", + "width": "32", + "description": "Delta-time-min measurement" + }, + "deltamax_time_meas": { + "type": "r", + "address": "14", + "reset": "0x0", + "width": "32", + "description": "Delta-time-max measurement" + }, + "delta_time_prev_meas": { + "type": "r", + "address": "15", + "reset": "0x0", + "width": "32", + "description": "Previous delta-time measurement" + }, + "delta_time_meas_step": { + "type": "w", + "address": "16", + "reset": "0x0", + "width": "16", + "description": "Delta-time measurement step" + }, + "abs_pos": { + "type": "r", + "address": "17", + "reset": "0x0", + "width": "32", + "description": "Detected absolution position (DEPRECATED)" + }, + "dir_thres": { + "address": "18", + "width": "32", + "description": "Direction detection control", + "fields": { + "pos_dir_thres": { + "type": "w", + "bit_len": "16", + "reset": "0x007F", + "description": "threshold for positive direction detection" + }, + "neg_dir_thres": { + "type": "w", + "bit_len": "16", + "reset": "0xFF81", + "description": "threshold for negative direction detection" + } + } + }, + "dir_cnt": { + "address": "19", + "width": "32", + "description": "Direction status", + "fields": { + "dir_cnt": { + "type": "r", + "bit_len": "16", + "reset": "0x0", + "description": "direction count" + }, + "dir_change_cnt": { + "type": "r", + "bit_len": "16", + "reset": "0x0", + "description": "direction change count" + } + } + }, + "enc_sampling_period": { + "type": "w", + "address": "20", + "reset": "0x0", + "width": "28", + "description": "Encoder sampling period (encoder FIFO)" + }, + "enc_fifo_mng": { + "address": "21", + "width": "32", + "description": "encoder FIFO management", + "fields": { + "irq_gen_thres": { + "type": "w", + "bit_len": "10", + "reset": "0x0", + "description": "FIFO IRQ threshold" + }, + "reserved-0" : { + "type" : "rsv", + "bit_len" : "6", + "description" : "Reserved bits" + }, + "fifo_level": { + "type": "r", + "bit_len": "10", + "reset": "0x0", + "description": "fifo level" + }, + "reserved-1" : { + "type" : "rsv", + "bit_len" : "5", + "description" : "Reserved bits" + }, + "fifo_overflow": { + "type": "r", + "bit_len": "1", + "reset": "0x0", + "description": "fifo overflow flag" + } + } + }, + "enc_fifo_output": { + "type": "r", + "address": "22", + "reset": "0x0", + "width": "32", + "description": "Encoder FIFO output" + }, + "pd_fifo_mng": { + "address": "23", + "width": "32", + "description": "encoder FIFO management", + "fields": { + "irq_gen_thres": { + "type": "w", + "bit_len": "10", + "reset": "0x0", + "description": "FIFO IRQ threshold" + }, + "reserved-0" : { + "type" : "rsv", + "bit_len" : "5", + "description" : "Reserved bits" + }, + "pd_log_src": { + "type": "w", + "bit_len": "1", + "reset": "0x0", + "description": "PD log source: 0 => PD-FIFO associated to Filtered-PD input, 1 => PD-FIFO associated to PD-out input" + }, + "fifo_level": { + "type": "r", + "bit_len": "10", + "reset": "0x0", + "description": "fifo level" + }, + "reserved-1" : { + "type" : "rsv", + "bit_len" : "5", + "description" : "Reserved bits" + }, + "fifo_overflow": { + "type": "r", + "bit_len": "1", + "reset": "0x0", + "description": "fifo overflow flag" + } + } + }, + "pd_fifo_output": { + "type": "r", + "address": "24", + "reset": "0x0", + "width": "32", + "description": "PD FIFO output" + }, + "pd_watchdog_ctrl": { + "address": "25", + "width": "5", + "description": "PD watchdog control", + "fields": { + "watchdog_en": { + "type": "w", + "bit_len": "1", + "reset": "0x0", + "description": "PD watchdog enable" + }, + "watchdog_clr": { + "type": "w", + "bit_len": "1", + "reset": "0x0", + "description": "PD watchdog clear" + }, + "reserved" : { + "type" : "rsv", + "bit_len" : "2", + "description" : "Reserved bits" + }, + "watchdog_status": { + "type": "r", + "bit_len": "1", + "reset": "0x0", + "description": "watchdog status" + } + } + }, + "pd_watchdog_thres": { + "type": "w", + "address": "26", + "reset": "0x0", + "width": "32", + "description": "PD watchdog threshold" + }, + "irq_mng": { + "address": "27", + "width": "15", + "description": "Diagnostic block IRQ management", + "fields": { + "irq_en": { + "type": "w", + "bit_len": "3", + "reset": "0x0", + "description": "IRQ enable" + }, + "reserved-0" : { + "type" : "rsv", + "bit_len" : "1", + "description" : "Reserved bits" + }, + "irq_clr": { + "type": "w", + "bit_len": "3", + "reset": "0x0", + "description": "IRQ clear" + }, + "reserved-1" : { + "type" : "rsv", + "bit_len" : "1", + "description" : "Reserved bits" + }, + "irq_mask": { + "type": "w", + "bit_len": "3", + "reset": "0x0", + "description": "IRQ mask" + }, + "reserved-2" : { + "type" : "rsv", + "bit_len" : "1", + "description" : "Reserved bits" + }, + "irq_val": { + "type": "w", + "bit_len": "3", + "reset": "0x0", + "description": "IRQ value" + } + } + } + } +}] \ No newline at end of file diff --git a/generic_ip/fire_pulse_manager/5/sim/sim_fpm.do b/generic_ip/fire_pulse_manager/5/sim/sim_fpm.do new file mode 100644 index 0000000..0193c49 --- /dev/null +++ b/generic_ip/fire_pulse_manager/5/sim/sim_fpm.do @@ -0,0 +1,113 @@ +# Multi-channel FPM Simulation macro + +.main clear + +# Cleanup libraries +foreach lib [list work OSVVM] { + file delete -force -- $lib + vlib $lib +} + +# Path variables +set COMMON_PATH ../../../common/0/src +set POF_PATH_0 ../../../pof_protocol/0/src +set POF_PATH_1 ../../../pof_protocol/1/src +set SEQUENCER_PATH ../../../generic_sequencer/15/src +set PULSE_GEN_PATH ../../../pulse_generator/2/src +set EMUL_PATH ../../../enc_pd_emul/1/src +set LOG_PATH ../../../event_logger/0/src +set SRC_PATH ../src +set OSVVM_PATH ../../../common/0/src/test/OSVVM +set TB_PATH ../src/test + +set WORKLIB work + +vlib ./work +vmap work ./work + +# common +vcom -2008 -work $WORKLIB $COMMON_PATH/sync_reset.vhd +vcom -2008 -work $WORKLIB $COMMON_PATH/common_pkg.vhd +vcom -2008 -work $WORKLIB $COMMON_PATH/sync_wire.vhd +vcom -2008 -work $WORKLIB $COMMON_PATH/sync_wire_rEdge.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 + +# Generic Sequencer +vcom -2008 -work $WORKLIB $SEQUENCER_PATH/altera/generic_seq_ram_15.vhd +vcom -2008 -work $WORKLIB $SEQUENCER_PATH/generic_sequencer_15_pkg.vhd +vcom -2008 -work $WORKLIB $SEQUENCER_PATH/generic_sequencer_15.vhd + +# Pulse Generator +vcom -2008 -work $WORKLIB $PULSE_GEN_PATH/pulse_conditioning_2.vhd +vcom -2008 -work $WORKLIB $PULSE_GEN_PATH/simple_frac_div_2.vhd +vcom -2008 -work $WORKLIB $PULSE_GEN_PATH/pulse_generator_2_pkg.vhd +vcom -2008 -work $WORKLIB $PULSE_GEN_PATH/pulse_generator_2.vhd + +# Emulator +vcom -2008 -work $WORKLIB $EMUL_PATH/enc_pd_emul_1_pkg.vhd +vcom -2008 -work $WORKLIB $EMUL_PATH/enc_pd_emul_1.vhd + +# Event Logger +vcom -2008 -work $WORKLIB $LOG_PATH/event_logger_0_pkg.vhd +vcom -2008 -work $WORKLIB $LOG_PATH/event_logger_0.vhd + +# POF-Rx +vcom -2008 -work $WORKLIB $POF_PATH_0/pof_uart_rx_0.vhd +vcom -2008 -work $WORKLIB $POF_PATH_0/pof_rx_0.vhd +vcom -2008 -work $WORKLIB $POF_PATH_0/pof_uart_regen_0.vhd +vcom -2008 -work $WORKLIB $POF_PATH_0/uart_tx_0.vhd +vcom -2008 -work $WORKLIB $POF_PATH_0/pof_tx_0.vhd + +vcom -2008 -work $WORKLIB $POF_PATH_1/pof_uart_rx_1.vhd +vcom -2008 -work $WORKLIB $POF_PATH_1/pof_rx_1.vhd +vcom -2008 -work $WORKLIB $POF_PATH_1/pof_uart_regen_1.vhd +vcom -2008 -work $WORKLIB $POF_PATH_1/uart_tx_1.vhd +vcom -2008 -work $WORKLIB $POF_PATH_1/pof_tx_1.vhd + +# Fire-Pulse-Manager +vcom -2008 -work $WORKLIB $COMMON_PATH/cs_bus_itf.vhd +vcom -2008 -work $WORKLIB $SRC_PATH/smb_diagnostics_5.vhd +vcom -2008 -work $WORKLIB $SRC_PATH/simple_enc_vel_detect_5.vhd +vcom -2008 -work $WORKLIB $SRC_PATH/fire_pulse_5_pkg.vhd +vcom -2008 -work $WORKLIB $SRC_PATH/fire_pulse_ctrl_5.vhd +vcom -2008 -work $WORKLIB $SRC_PATH/fire_pulse_ext_5.vhd +vcom -2008 -work $WORKLIB $SRC_PATH/fire_pulse_manager_5.vhd + +# Compile the testbench support files: +# Compile OSVVM lib +vlib OSVVM +vcom -2008 -work OSVVM $OSVVM_PATH/RandomBasePkg.vhd +vcom -2008 -work OSVVM $OSVVM_PATH/SortListPkg_int.vhd +vcom -2008 -work OSVVM $OSVVM_PATH/RandomPkg.vhd + +# Compile the testbench support files: +vcom -2008 -work $WORKLIB $COMMON_PATH/test/common_test_pkg.vhd +vcom -2008 -work $WORKLIB $COMMON_PATH/test/log_pkg.vhd + +# Compile the VHDL packages that support bus protocols, memory mapped registers and functional procedures +vcom -2008 -work $WORKLIB $COMMON_PATH/test/avalon_verify_pkg.vhd + +# Testbench +vcom -2008 -work $WORKLIB $TB_PATH/fire_pulse_manager_5_tb.vhd + +# Load design +vsim -t ps work.fire_pulse_manager_5_tb + +# Add waves +#add wave -r sim:/fire_pulse_manager_1_tb/* +do wave_fpm.do + +# remove warnings from standard numeric/arithmetic packages (speed-up simulation) +set StdArithNoWarnings 1 +set NumericStdNoWarnings 1 + +when -label end_of_simulation {test_completed == true} {echo "Simulation Completed"; stop ;} +run -all + + + + + + diff --git a/generic_ip/fire_pulse_manager/5/sim/wave_fpm.do b/generic_ip/fire_pulse_manager/5/sim/wave_fpm.do new file mode 100644 index 0000000..ea34572 --- /dev/null +++ b/generic_ip/fire_pulse_manager/5/sim/wave_fpm.do @@ -0,0 +1,403 @@ +onerror {resume} +quietly WaveActivateNextPane {} 0 +add wave -noupdate -group TB /fire_pulse_manager_5_tb/ch_offset +add wave -noupdate -group TB /fire_pulse_manager_5_tb/reset_n +add wave -noupdate -group TB /fire_pulse_manager_5_tb/clk +add wave -noupdate -group TB /fire_pulse_manager_5_tb/rx_clk +add wave -noupdate -group TB /fire_pulse_manager_5_tb/pof_tx +add wave -noupdate -group TB /fire_pulse_manager_5_tb/pof_rx +add wave -noupdate -group TB -expand /fire_pulse_manager_5_tb/ch_pulse_out +add wave -noupdate -group TB /fire_pulse_manager_5_tb/avs_address +add wave -noupdate -group TB /fire_pulse_manager_5_tb/avs_write +add wave -noupdate -group TB /fire_pulse_manager_5_tb/avs_writedata +add wave -noupdate -group TB /fire_pulse_manager_5_tb/avs_read +add wave -noupdate -group TB /fire_pulse_manager_5_tb/avs_waitrequest +add wave -noupdate -group TB /fire_pulse_manager_5_tb/avs_readdata +add wave -noupdate -group TB /fire_pulse_manager_5_tb/init_tx +add wave -noupdate -group TB /fire_pulse_manager_5_tb/pd_in +add wave -noupdate -group TB /fire_pulse_manager_5_tb/pd_spy +add wave -noupdate -group TB /fire_pulse_manager_5_tb/inc_pos +add wave -noupdate -group TB /fire_pulse_manager_5_tb/dec_pos +add wave -noupdate -group TB -radix hexadecimal /fire_pulse_manager_5_tb/abs_position +add wave -noupdate -group TB /fire_pulse_manager_5_tb/abs_spy +add wave -noupdate -group TB /fire_pulse_manager_5_tb/tx_data +add wave -noupdate -group TB /fire_pulse_manager_5_tb/abs_position_d +add wave -noupdate -group TB /fire_pulse_manager_5_tb/dir_in +add wave -noupdate -group TB /fire_pulse_manager_5_tb/swathe_cnt +add wave -noupdate -group TB /fire_pulse_manager_5_tb/swathe_pos +add wave -noupdate -group TB /fire_pulse_manager_5_tb/end_of_swathe +add wave -noupdate -group TB /fire_pulse_manager_5_tb/test_completed +add wave -noupdate -group TB /fire_pulse_manager_5_tb/running +add wave -noupdate -group TB /fire_pulse_manager_5_tb/configuring +add wave -noupdate -group TB /fire_pulse_manager_5_tb/passed +add wave -noupdate -group TB /fire_pulse_manager_5_tb/failed +add wave -noupdate -group TB /fire_pulse_manager_5_tb/stimuli_completed +add wave -noupdate -group TB /fire_pulse_manager_5_tb/detected_error +add wave -noupdate -group TB /fire_pulse_manager_5_tb/registers_read +add wave -noupdate -group TB /fire_pulse_manager_5_tb/reprogram_offset +add wave -noupdate -group TB /fire_pulse_manager_5_tb/avs_m +add wave -noupdate -group TB /fire_pulse_manager_5_tb/avs_s +add wave -noupdate -group TB /fire_pulse_manager_5_tb/sel_slave_0 +add wave -noupdate -group TB /fire_pulse_manager_5_tb/sel_slave_1 +add wave -noupdate -group TB /fire_pulse_manager_5_tb/pd_cnt +add wave -noupdate -group TB /fire_pulse_manager_5_tb/fp_cnt +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/reset_n +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/clk +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/init +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/rx_clk +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/rx_data +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/init_out +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/pd_out +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/inc_pos +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/dec_pos +add wave -noupdate -group {POF RX} -radix decimal /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/abs_pos +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/enable +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/error_rate_thres +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/one_pps +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/max_error_flag +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/rx_watchdog +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/rx_watchdog_en +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/rx_watchdog_clr +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/parity_err_cnt +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/skip_pos_cnt +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/clear +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/symbol_ok +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/inc_pos_i +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/dec_pos_i +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/sync_gen +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/pd_gen +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/symbol_error +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/symbol_valid +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/symbol_valid_i +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/symbol_valid_d +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/toggle_sync +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/sync_confirmed +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/sync_toggle_test +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/sync +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/toggle_pd +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/pd_confirmed +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/pd_toggle_test +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/pd +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/valid_pos +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/upd_pos +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/corr_done +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/corr_sign +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/skip_pos +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/apply_corr +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/inc_pos_ii +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/dec_pos_ii +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/rx_error +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/rx_error_i +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/print_start_i +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/rx_symbol_val +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/clear_i +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/skip_pos_d +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/pos_recovery +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/max_error_flag_i +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/clk_cnt +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/dist +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/abs_dist +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/skip_cnt +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/next_pos_lsb +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/curr_pos_lsb +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/pos_corr +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/max_dist +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/rx_error_v +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/gray_pos +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/rx_symbol_val_v +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/symbol +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/symbol_i +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/rx_symbol +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/rx_wd_cnt +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/parity_err_cnt_i +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/skip_pos_cnt_i +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/error_rate_cnt +add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/error_rate +add wave -noupdate -group {POF RX} -radix decimal /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/abs_pos_i +add wave -noupdate -group UART_RX /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/iRX_SYMBOL/reset_n +add wave -noupdate -group UART_RX /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/iRX_SYMBOL/clk +add wave -noupdate -group UART_RX /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/iRX_SYMBOL/init +add wave -noupdate -group UART_RX /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/iRX_SYMBOL/data_out +add wave -noupdate -group UART_RX /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/iRX_SYMBOL/data_out_valid +add wave -noupdate -group UART_RX /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/iRX_SYMBOL/rx_error +add wave -noupdate -group UART_RX /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/iRX_SYMBOL/rx_data +add wave -noupdate -group UART_RX /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/iRX_SYMBOL/rx_data_i +add wave -noupdate -group UART_RX /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/iRX_SYMBOL/data +add wave -noupdate -group UART_RX /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/iRX_SYMBOL/bit_cnt_unary +add wave -noupdate -group UART_RX /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/iRX_SYMBOL/sample_cnt_unary +add wave -noupdate -group UART_RX /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/iRX_SYMBOL/receiving +add wave -noupdate -group UART_RX /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/iRX_SYMBOL/init_int +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/clk +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/reset_n +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/init +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/pd_in +add wave -noupdate -group CH-0 -radix hexadecimal /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/abs_position +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/enc_vel +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/enc_speed_meas_w +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/dp_dir +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/pulse_out +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/start_of_image +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/filtered_pd +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/ch_pd +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/ch_mask +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/raw_pulse_out +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/enc_pulse +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/avs_address +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/avs_write +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/avs_writedata +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/avs_read +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/avs_readdatavalid +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/avs_readdata +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/init_de +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/init_qd +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/enable +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/loc_pd +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/pd_queue_error +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/ch_ctrl_start_req +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/pd_pulse +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/filt_pd +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/filt_pd_d +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/ch_ctrl_write +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/ch_ctrl_read +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/ch_ctrl_busy +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/enable_i +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/ch_mask_i +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/bypass_ch_ctrl +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/bypass_delay_equal +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/div_pulse +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/gated_pulse +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/retimed_pulse +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/pulse_out_i +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/avs_write_i +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/avs_read_d +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/avs_read_i +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/de_queue_error +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/cnt_dir +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/dp_dir_i +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/ch_ctrl_start_req_i +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/set_first_pd +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/pulse_out_ii +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/loc_pulse +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/first_pulse +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/dp_dir_d +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/overdrive_rst +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/overdrv_event +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/pulse_scale_out +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/start_img_req +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/start_img_req_d +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/start_img +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/start_img_d +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/start_img_dd +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/fire_enable +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/img_completed +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/sw_ctrl_dp_dir +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/enable_out +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/ch_ctrl_start_req_d +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/add_img_size +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/add_img_size_d +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/abort_fire +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/ch_ctrl_csr_write +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/ch_ctrl_csr_read +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/frac_div_en_i +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/upd_max_pos +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/upd_min_pos +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/frac_div_en +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/gen_filt_pd +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/upd_max_pos_i +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/upd_min_pos_i +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/dir_change +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/first_pd +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/pd_in_d +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/filt_pd_i +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/abs_pos_lsb +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/ch_ctrl_start_req_ii +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/prevent_div_restart +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/rst_jitter +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/rst_diag_regs +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/fire_req +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/fire_req_d +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/fire_req_p +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/mid_cross +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/mid_crossed +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/zero_cross +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/close_to_zero +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/close_to_mid +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/bypass_pulse_cond +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/div_pulse_i +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/spitting_enable +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/spit_pulse +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/seq_bus_valid +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/spit_nco_msb +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/wh_apply_corr_en +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/wh_error_meas_avail +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/wh_corr_ready +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/wh_error_meas_started +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/init_wh +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/loc_pd_d +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/wh_meas_event +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/wh_img_end +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/first_img_started +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/tof_lut_wr_en +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/tof_comp_enable +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/tof_saturation +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/tof_sat_flag +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/wh_apply_corr_en_d +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/wh_corr_start +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/wh_skip_corr +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/wh_img_2nd_half +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/wh_img_2nd_half_d +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/selected_pulse +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/selected_pulse_d +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/clr_pd_queue +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/zero_gap_mode +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/start_image_flag +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/abs_pos_msb_old +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/ch_ctrl_csr_addr +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/ch_ctrl_trigger_in +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/wh_corr_ready_v +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/avs_addr +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/pulse_width +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/pulse_width_ext +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/init_v +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/ch_ctrl_start_addr +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/bpe_top +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/ch_ctrl_address +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/tof_lut_wr_addr +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/tof_lut_addr +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/avs_address_i +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/wh_rotat_cnt +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/overdrive_events +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/overdrive_thres +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/pulse_interval +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/wh_loop_filt_tot +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/wh_loop_filt_delta +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/ch_delay +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/ch_delay_i +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/enc_speed_norm_coeff +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/tof_lut_wr_data +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/tof_lut_wr_q +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/tof_lut_comp +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/tof_lut_comp_i +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/enc_speed_meas_w_i +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/enc_vel_i +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/img_size +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/pixel_cnt +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/ch_ctrl_vector_out +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/wh_skip_corr_thres +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/wh_img_pixel_cnt +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/wh_image_pixel_len +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/basic_pos_error_sat +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/norm_enc_vel +add wave -noupdate -group CH-0 -radix unsigned /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/ch_offset +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/avs_readdata_i +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/ch_ctrl_writedata +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/ch_ctrl_readdata +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/ch_ctrl_csr_writedata +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/ch_ctrl_csr_readdata +add wave -noupdate -group CH-0 -radix unsigned /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/ch_offset_dir0 +add wave -noupdate -group CH-0 -radix unsigned /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/ch_offset_dir1 +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/abs_pos_max +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/abs_pos_min +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/last_pd_pos +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/basic_pos_error +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/pd_in_cnt +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/fire_req_cnt +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/seq_bus_data +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/spit_nco +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/spit_nco_inc +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/start_pos +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/abs_pos_d +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/wh_pos_err_2_corr +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/wh_pos_err_max +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/wh_pos_err_min +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/wh_pos_err +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/wh_pos_err_curr +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/wh_pos_err_old +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/wh_pos_err_abs +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/wh_tot_err +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/wh_delta_err +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/div_offset +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/div_ratio +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/div_ratio_i +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/div_ratio_corr +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/div_ratio_corr_new +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/wh_loop_err_delta +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/wh_loop_err_tot +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/pos_error +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/wh_loop_err +add wave -noupdate -group CH-0 /fire_pulse_manager_5_tb/iDUT/pulse_generator_g(1)/iCH_PG/div_ratio_corr_ext +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/reset_n +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/clk +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/init +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/pd_in +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/inc_pos +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/dec_pos +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/abs_position +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/tx_data +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/avs_address +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/avs_write +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/avs_writedata +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/avs_read +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/avs_readdatavalid +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/avs_readdata +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/rd_event +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/wr_event +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/empty +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/full +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/tx_ready +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/rd_event_d +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/wr_event_i +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/symbol_valid +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/enable +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/toggle_sync +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/toggle_pd +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/add_keepalive +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/ovfl_err +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/init_d +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/init_gen +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/clear +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/pd_in_d +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/pd_gen +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/parity_bit +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/inject_error +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/inject_error_req +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/pd_event +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/pd_event_d +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/pd_event_dd +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/init_blocked +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/pd_event_ddd +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/delayed_pos +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/clr_fifo_lmax +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/delayed_pos_v +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/init_v +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/gray +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/bit_div +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/latched_pos +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/event_in_i +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/event_in +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/event_out +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/symbol +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/init_blk_cnt +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/keepalive_cnt +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/keepalive_period +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/init_blocked_period +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/fifo_level +add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/fifo_level_max +TreeUpdate [SetDefaultTree] +WaveRestoreCursors {{Cursor 1} {16135000 ps} 0} +quietly wave cursor active 1 +configure wave -namecolwidth 223 +configure wave -valuecolwidth 100 +configure wave -justifyvalue left +configure wave -signalnamewidth 1 +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} {193574912 ps} diff --git a/generic_ip/fire_pulse_manager/5/src/fire_pulse_5_pkg.vhd b/generic_ip/fire_pulse_manager/5/src/fire_pulse_5_pkg.vhd new file mode 100644 index 0000000..ac8d897 --- /dev/null +++ b/generic_ip/fire_pulse_manager/5/src/fire_pulse_5_pkg.vhd @@ -0,0 +1,37 @@ +------------------------------------------------------------------------------- +-- Title : fire_pulse_pkg +-- Project : HMB/EMB/SMB +------------------------------------------------------------------------------- +-- File : fire_pulse_pkg.vhd +-- Author : Gianmarco Girau +-- Company : Global Inkjet Systems +-- Created : 2017-09-08 +-- Last update: 2019-12-16 +-- SVN ID : Git +-- Standard : VHDL'08 +------------------------------------------------------------------------------- +-- Description: +-- Package for fire_pulse_manager block +------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +package fire_pulse_5_pkg is + + ----------------------------------------------------------------------------- + -- Inner block mapping + ----------------------------------------------------------------------------- + + constant blk_num : integer := 8; -- number of sub-blocks with dedicated + -- C&S registers + + constant fp_ctrl_id : natural := 0; -- Block ID for the Fire-Pulse-Mang Controller + constant diag_blk_id : natural := 1; -- Block ID for the Diagnostic Block + constant log_blk_id : natural := 2; -- Block ID for the Event Logger + constant int_enc_id : natural := 3; -- Block ID for the Internal Encoder Block + constant pg_ch_id : natural := 4; -- Block ID for Pulse-Generator + +end package fire_pulse_5_pkg; diff --git a/generic_ip/fire_pulse_manager/5/src/fire_pulse_ctrl_5.vhd b/generic_ip/fire_pulse_manager/5/src/fire_pulse_ctrl_5.vhd new file mode 100644 index 0000000..2d8e6dc --- /dev/null +++ b/generic_ip/fire_pulse_manager/5/src/fire_pulse_ctrl_5.vhd @@ -0,0 +1,276 @@ +------------------------------------------------------------------------------- +-- Title : fire_pulse_ctrl +-- Project : HMB/EMB/SMB +------------------------------------------------------------------------------- +-- File : fire_pulse_ctrl.vhd +-- Author : Gianmarco Girau +-- Company : Global Inkjet Systems +-- Created : 2017-09-06 +-- Last update: 2019-12-16 +-- SVN ID : Git +-- Standard : VHDL'08 +------------------------------------------------------------------------------- +-- Description: +-- Control service logic for the Fire-Controller-Manager +------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity fire_pulse_ctrl_5 is + port( + reset_n : in std_logic; + clk : in std_logic; + src_sel : out std_logic_vector(1 downto 0); + uart_regen_bypass : out std_logic; + upd_max_pos : out std_logic; + upd_min_pos : out std_logic; + enable_rx : out std_logic; + uart_bit_div : out std_logic_vector(3 downto 0); + error_rate_thres : out std_logic_vector(7 downto 0); + max_error_flag : in std_logic; + rx_watchdog : in std_logic; + rx_watchdog_en : out std_logic; + rx_watchdog_clr : out std_logic; + parity_err_cnt : in std_logic_vector(15 downto 0); + skip_pos_cnt : in std_logic_vector(15 downto 0); + mon_point_src : in std_logic_vector(15 downto 0); + mon_points : out std_logic_vector(3 downto 0); + coarse_time : out std_logic_vector(31 downto 0); + fine_time : out std_logic_vector(27 downto 0); + one_pps : out std_logic; + ext_fp_det : out std_logic_vector(15 downto 0); + ext_fp_gen : out std_logic_vector(15 downto 0); + -- Interrupt Senders + ins_fpm_irq_0 : out std_logic; + -- Avalon MM Interface + avs_address : in std_logic_vector(3 downto 0); + avs_write : in std_logic; + avs_writedata : in std_logic_vector(31 downto 0); + avs_read : in std_logic; + avs_readdatavalid : out std_logic; + avs_readdata : out std_logic_vector(31 downto 0)); +end entity fire_pulse_ctrl_5; + +architecture rtl of fire_pulse_ctrl_5 is + + ----------------------------------------------------------------------------- + -- Control & Status Registers Map + ----------------------------------------------------------------------------- + constant CSR_IP_ID : std_logic_vector(31 downto 0) := x"0000FF14"; + constant CSR_IP_VER : std_logic_vector(31 downto 0) := x"00000400"; + + constant CSR_IP_ID_REG : std_logic_vector(3 downto 0) := b"0000"; + constant CSR_IP_VER_REG : std_logic_vector(3 downto 0) := b"0001"; + constant SRC_SEL_REG : std_logic_vector(3 downto 0) := b"0010"; + constant POF_RX_CTRL : std_logic_vector(3 downto 0) := b"0011"; + constant MON_PT_CTRL_REG : std_logic_vector(3 downto 0) := b"0100"; + constant COARSE_TIME_INIT_REG : std_logic_vector(3 downto 0) := b"0101"; + constant FINE_TIME_INIT_REG : std_logic_vector(3 downto 0) := b"0110"; + constant FINE_TIME_REG : std_logic_vector(3 downto 0) := b"0111"; + constant COARSE_TIME_REG : std_logic_vector(3 downto 0) := b"1000"; + constant RX_ERROR_STATUS : std_logic_vector(3 downto 0) := b"1001"; + constant RX_ERROR_CSR : std_logic_vector(3 downto 0) := b"1010"; + constant IRQ_MNG_REG : std_logic_vector(3 downto 0) := b"1011"; + constant EXT_FP_CTRL_REG : std_logic_vector(3 downto 0) := b"1100"; + + ----------------------------------------------------------------------------- + -- Constants, Signals + ----------------------------------------------------------------------------- + + constant FINE_TIME_TC : integer := 100000000 - 1; -- clk must be 100MHz to + -- make it right + + signal enable_rx_i : std_logic; + signal fine_time_wrap, time_ld_en : std_logic; + signal rx_watchdog_en_i, rx_watchdog_clr_i : std_logic; + signal uart_regen_bypass_i : std_logic; + signal upd_min_pos_i, upd_max_pos_i : std_logic; + signal irq, irq_src, irq_src_d : std_logic_vector(0 downto 0); + signal irq_en, irq_mask, irq_val, irq_clr : std_logic_vector(0 downto 0); + signal src_sel_i : std_logic_vector(1 downto 0); + signal mp_sel0, mp_sel1, mp_sel2, mp_sel3 : std_logic_vector(3 downto 0); + signal bit_div : std_logic_vector(3 downto 0); + signal error_rate_thres_i : std_logic_vector(7 downto 0); + signal fine_time_init, fine_time_i : std_logic_vector(27 downto 0); + signal coarse_time_init, coarse_time_i : std_logic_vector(31 downto 0); + signal ext_fp_det_i, ext_fp_gen_i : std_logic_vector(15 downto 0); + +begin + + pCTRL_REGs : process(reset_n, clk) + begin -- process + if (reset_n = '0') then + fine_time_i <= (others => '0'); + coarse_time_i <= (others => '0'); + elsif (clk = '1' and clk'event) then + if (time_ld_en = '1') then + fine_time_i <= fine_time_init; + elsif (fine_time_wrap = '1') then + fine_time_i <= (others => '0'); + else + fine_time_i <= std_logic_vector(unsigned(fine_time_i) + 1); + end if; + if (time_ld_en = '1') then + coarse_time_i <= coarse_time_init; + elsif (fine_time_wrap = '1') then + coarse_time_i <= std_logic_vector(unsigned(coarse_time_i) + 1); + end if; + one_pps <= fine_time_wrap; + end if; + end process pCTRL_REGs; + + fine_time_wrap <= '1' when unsigned(fine_time_i) = FINE_TIME_TC else '0'; + + coarse_time <= coarse_time_i; + fine_time <= fine_time_i; + + -- MOnitoring Point selection + mon_points(0) <= mon_point_src(to_integer(unsigned(mp_sel0))); + mon_points(1) <= mon_point_src(to_integer(unsigned(mp_sel1))); + mon_points(2) <= mon_point_src(to_integer(unsigned(mp_sel2))); + mon_points(3) <= mon_point_src(to_integer(unsigned(mp_sel3))); + + ----------------------------------------------------------------------------- + -- IRQ generation and management + ----------------------------------------------------------------------------- + + pIRQ : process(reset_n, clk) + begin + if (reset_n = '0') then + ins_fpm_irq_0 <= '0'; + irq <= "0"; + irq_src_d <= "0"; + elsif (clk = '1' and clk'event) then + irq_src_d <= irq_src; + for n in 0 to irq'left loop + if (irq_clr(n) = '1') then + irq(n) <= '0'; + elsif (irq_en(n) = '1' and irq_src(n) = '1' and irq_src_d(n) = '0') then + irq(n) <= '1'; + end if; + end loop; -- n + ins_fpm_irq_0 <= irq_val(0); + end if; + end process pIRQ; + + irq_val <= irq and not irq_mask; + irq_src <= "1" when max_error_flag = '1' or rx_watchdog = '1' else "0"; + + ----------------------------------------------------------------------------- + -- C&S registers + ----------------------------------------------------------------------------- + + src_sel <= src_sel_i; + enable_rx <= enable_rx_i; + uart_regen_bypass <= uart_regen_bypass_i; + + uart_bit_div <= bit_div; + upd_max_pos <= upd_max_pos_i; + upd_min_pos <= upd_min_pos_i; + + error_rate_thres <= error_rate_thres_i; + rx_watchdog_en <= rx_watchdog_en_i; + rx_watchdog_clr <= rx_watchdog_clr_i; + + ext_fp_det <= ext_fp_det_i; + ext_fp_gen <= ext_fp_gen_i; + + pCTRL_STATUS : process(reset_n, clk) + begin + if (reset_n = '0') then + avs_readdatavalid <= '0'; + src_sel_i <= "00"; + enable_rx_i <= '0'; + uart_regen_bypass_i <= '0'; + upd_max_pos_i <= '0'; + upd_min_pos_i <= '0'; + bit_div <= "0100"; + error_rate_thres_i <= X"0A"; + rx_watchdog_en_i <= '1'; + rx_watchdog_clr_i <= '0'; + mp_sel0 <= X"0"; + mp_sel1 <= X"0"; + mp_sel2 <= X"0"; + mp_sel3 <= X"0"; + coarse_time_init <= (others => '0'); + fine_time_init <= (others => '0'); + time_ld_en <= '0'; + ext_fp_det_i <= X"0010"; + ext_fp_gen_i <= X"0020"; + elsif (clk = '1' and clk'event) then + -- CTRL registers + if (avs_write = '1') then + case avs_address is + when SRC_SEL_REG => + src_sel_i <= avs_writedata(1 downto 0); + when POF_RX_CTRL => + enable_rx_i <= avs_writedata(0); + uart_regen_bypass_i <= avs_writedata(1); + upd_max_pos_i <= avs_writedata(2); + upd_min_pos_i <= avs_writedata(3); + bit_div <= avs_writedata(7 downto 4); + when MON_PT_CTRL_REG => + mp_sel0 <= avs_writedata(3 downto 0); + mp_sel1 <= avs_writedata(7 downto 4); + mp_sel2 <= avs_writedata(11 downto 8); + mp_sel3 <= avs_writedata(15 downto 12); + when COARSE_TIME_INIT_REG => + coarse_time_init <= avs_writedata; + when FINE_TIME_INIT_REG => + time_ld_en <= avs_writedata(28); + fine_time_init <= avs_writedata(27 downto 0); + when RX_ERROR_CSR => + error_rate_thres_i <= avs_writedata(7 downto 0); + rx_watchdog_en_i <= avs_writedata(8); + rx_watchdog_clr_i <= avs_writedata(9); + when IRQ_MNG_REG => + irq_en <= avs_writedata(0 downto 0); + irq_clr <= avs_writedata(4 downto 4); + irq_mask <= avs_writedata(8 downto 8); + when EXT_FP_CTRL_REG => + ext_fp_det_i <= avs_writedata(15 downto 0); + ext_fp_gen_i <= avs_writedata(31 downto 16); + when others => null; + end case; + end if; + -- Read Ctrl & Status registers + avs_readdatavalid <= avs_read; + if (avs_read = '1') then + case avs_address is + when CSR_IP_ID_REG => + avs_readdata <= CSR_IP_ID; + when CSR_IP_VER_REG => + avs_readdata <= CSR_IP_VER; + when SRC_SEL_REG => + avs_readdata <= (0 => src_sel_i(0), 1 => src_sel_i(1), others => '0'); + when POF_RX_CTRL => + avs_readdata <= X"000000" & bit_div & upd_min_pos_i & upd_max_pos_i & uart_regen_bypass_i & enable_rx_i; + when MON_PT_CTRL_REG => + avs_readdata <= X"0000" & mp_sel3 & mp_sel2 & mp_sel1 & mp_sel0; + when COARSE_TIME_INIT_REG => + avs_readdata <= coarse_time_init; + when FINE_TIME_INIT_REG => + avs_readdata <= b"000" & time_ld_en & fine_time_init; + when RX_ERROR_STATUS => + avs_readdata <= skip_pos_cnt & parity_err_cnt; + when FINE_TIME_REG => + avs_readdata <= X"0" & fine_time_i; + when COARSE_TIME_REG => + avs_readdata <= coarse_time_i; + when RX_ERROR_CSR => + avs_readdata <= X"00000" & max_error_flag & rx_watchdog & rx_watchdog_clr_i & rx_watchdog_en_i & error_rate_thres_i; + when IRQ_MNG_REG => + avs_readdata <= X"0000" & "000" & irq_val & "000" & irq_mask & "000" & irq_clr & "000" & irq_en; + when EXT_FP_CTRL_REG => + avs_readdata <= ext_fp_gen_i & ext_fp_det_i; + when others => + avs_readdata <= X"BAD1BAD0"; + end case; + end if; + end if; + end process pCTRL_STATUS; + +end architecture rtl; diff --git a/generic_ip/fire_pulse_manager/5/src/fire_pulse_ext_5.vhd b/generic_ip/fire_pulse_manager/5/src/fire_pulse_ext_5.vhd new file mode 100644 index 0000000..ba724b8 --- /dev/null +++ b/generic_ip/fire_pulse_manager/5/src/fire_pulse_ext_5.vhd @@ -0,0 +1,108 @@ +------------------------------------------------------------------------------- +-- Title : fire_pulse_manager +-- Project : GMA +------------------------------------------------------------------------------- +-- File : fire_pulse_ext.vhd +-- Author : Christos Spirotis +-- Company : Global Inkjet Systems +-- Created : 2017-10-03 +-- Last update: 2019-12-16 +-- SVN ID : Git +-- Standard : VHDL'08 +------------------------------------------------------------------------------- +-- Description: +-- Detects external fire pulse and regenerates it +------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +library work; + +entity fire_pulse_ext_5 is + port( + reset_n : in std_logic; + clk : in std_logic; -- 100MHz + + ext_fp_det : in std_logic_vector(15 downto 0); + ext_fp_gen : in std_logic_vector(15 downto 0); + + ext_in : in std_logic; + ext_out : out std_logic + ); +end entity fire_pulse_ext_5; + +architecture rtl of fire_pulse_ext_5 is + +signal ext_in_cnt : unsigned(15 downto 0); +signal ext_out_cnt : unsigned(15 downto 0); +signal ext_in_det : std_logic_vector( 2 downto 0); +signal fp_gen : std_logic; + +begin + + -- Detect pulse + pulse_det : process (clk, reset_n) + begin + if (reset_n = '0') then + ext_in_cnt <= (others => '0'); + ext_in_det <= (others => '0'); + fp_gen <= '0'; + elsif rising_edge(clk) then + fp_gen <= '0'; + ext_in_det <= ext_in_det(1 downto 0) & ext_in; + + -- Detect rising edge while idle + if (ext_in_det(2 downto 1) = "01" and ext_in_cnt = 0) then + -- Start width counter + ext_in_cnt <= X"0001"; + -- Measure width while signal high + elsif ext_in_cnt /= 0 and ext_in_det(1) = '1' then + -- Counter++ + ext_in_cnt <= ext_in_cnt + 1; + -- If reached minimum width + if ext_in_cnt >= unsigned(ext_fp_det) then + -- Regenerate pulse + fp_gen <= '1'; + -- Reset width counter + ext_in_cnt <= (others => '0'); + end if; + -- If signal drops before detection + elsif ext_in_cnt /= 0 and ext_in_det(1) = '0' then + -- Reset width counter + ext_in_cnt <= (others => '0'); + end if; + end if; + end process pulse_det; + + -- Regenerate pulse + pulse_regen : process (clk, reset_n) + begin + if (reset_n = '0') then + ext_out_cnt <= (others => '0'); + ext_out <= '0'; + elsif rising_edge(clk) then + -- Look for pulse detected + if fp_gen = '1' and ext_out_cnt = 0 then + -- Start width counter + ext_out_cnt <= X"0001"; + -- Generate pulse + ext_out <= '1'; + -- If counting + elsif ext_out_cnt /= 0 then + -- Increment width + ext_out_cnt <= ext_out_cnt + 1; + -- If width reached programmed value + if ext_out_cnt >= unsigned(ext_fp_gen) then + -- Reset pulse + ext_out <= '0'; + -- Reset width counter + ext_out_cnt <= (others => '0'); + end if; + end if; + end if; + end process pulse_regen; + +end architecture rtl; diff --git a/generic_ip/fire_pulse_manager/5/src/fire_pulse_manager_5.vhd b/generic_ip/fire_pulse_manager/5/src/fire_pulse_manager_5.vhd new file mode 100644 index 0000000..44c4d72 --- /dev/null +++ b/generic_ip/fire_pulse_manager/5/src/fire_pulse_manager_5.vhd @@ -0,0 +1,622 @@ +------------------------------------------------------------------------------- +-- Title : fire_pulse_manager +-- Project : HMB/EMB/SMB +------------------------------------------------------------------------------- +-- File : fire_pulse_manager.vhd +-- Author : Gianmarco Girau +-- Company : Global Inkjet Systems +-- Created : 2017-09-06 +-- Last update: 2019-12-16 +-- SVN ID : Git +-- Standard : VHDL'08 +------------------------------------------------------------------------------- +-- Description: +-- Generates fire request from the EMS output data +------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +use work.fire_pulse_5_pkg.all; + +entity fire_pulse_manager_5 is + generic ( + CH_NUM : integer := 4; -- number of Pulse-Generator blocks + PD_QUEUE_SIZE : natural := 512; + ADD_SMB_DIAG : boolean := false; -- Instantiate SMB Diagnostic block + ADD_EVENT_LOGGER : boolean := false; -- Instantiate Event-Logger block + LOG_FIFO_SIZE : natural range 256 to 4096 := 1024; + POF_PROT_VER : natural range 0 to 1 := 0; -- POF-Protocol Versions: + -- 0 => Standard, 1 => Add Print-Start + PULSE_DELAY_EQUAL_EN : boolean := false; + TOF_COMP_EN : boolean := false; + PIXEL_PITCH_CORR_EN : boolean := false; + OUT_PULSE_CONDITION : boolean := true); + port( + reset_n : in std_logic; + clk : in std_logic; -- 100MHz + rx_clk : in std_logic; -- 300MHz (typical) + -- Datapath I/Os + pof_rx : in std_logic; + pof_tx : out std_logic; + pof_iso_en : out std_logic; + fire_pulse : out std_logic_vector(ch_num - 1 downto 0); + start_of_image : out std_logic_vector(ch_num - 1 downto 0); + abs_pos_out : out std_logic_vector(31 downto 0); + print_start : out std_logic; + mon_pt : out std_logic_vector(3 downto 0); -- Monitoring Points + -- on header J7 + -- Interrupt Senders + ins_fpm_irq_0 : out std_logic; + ins_fpm_irq_1 : out std_logic; -- @suppress "Unused port: ins_fpm_irq_1 is not used in work.fire_pulse_manager_5(rtl)" + ins_fpm_irq_2 : out std_logic; -- @suppress "Unused port: ins_fpm_irq_2 is not used in work.fire_pulse_manager_5(rtl)" + ins_fpm_irq_3 : out std_logic; -- @suppress "Unused port: ins_fpm_irq_3 is not used in work.fire_pulse_manager_5(rtl)" + -- Avalon MM (Slave) Interface + avs_address : in std_logic_vector(14 downto 0); + avs_write : in std_logic; + avs_writedata : in std_logic_vector(31 downto 0); + avs_read : in std_logic; + avs_waitrequest : out std_logic; + avs_readdata : out std_logic_vector(31 downto 0)); +end entity fire_pulse_manager_5; + +architecture rtl of fire_pulse_manager_5 is + + -- Period used for Time-of-Flight compensation velocity measurememnt + constant VEL_MEAS_PERIOD : natural := 10000; + + constant POF_UART_BIT_BIV : integer := 6; -- POF-Rx UART sampling clock vs + -- baudrate ratio + + type diag_cnt_en_t is array (0 to CH_NUM-1) of boolean; + constant DIAG_COUNTER_EN : diag_cnt_en_t := (0 => true, others => false); + + signal reset_n_i : std_logic; + -- + signal cs_addr : std_logic_vector(10 downto 0); + signal cs_write_en : std_logic_vector(blk_num - 1 downto 0); + signal cs_write_data : std_logic_vector(31 downto 0); + signal cs_read_en : std_logic_vector(blk_num - 1 downto 0); + signal cs_read_valid : std_logic_vector(blk_num - 1 downto 0); + signal cs_read_data : std_logic_vector(32 * blk_num - 1 downto 0); + -- + signal cs_ctrl_write_en : std_logic; + signal cs_ctrl_read_en : std_logic; + signal cs_ctrl_read_valid : std_logic; + signal cs_ctrl_read_data : std_logic_vector(31 downto 0); + -- + signal cs_pg_write_en : std_logic_vector(CH_NUM - 1 downto 0); + signal cs_pg_read_en : std_logic_vector(CH_NUM - 1 downto 0); + signal cs_pg_read_valid : std_logic_vector(CH_NUM - 1 downto 0); + signal cs_pg_read_data : std_logic_vector(32 * CH_NUM - 1 downto 0); + -- + signal cs_diag_write_en : std_logic; + signal cs_diag_read_en : std_logic; + signal cs_diag_read_valid : std_logic; + signal cs_diag_read_data : std_logic_vector(31 downto 0); + -- + signal cs_log_write_en : std_logic; + signal cs_log_read_en : std_logic; + signal cs_log_read_valid : std_logic; + signal cs_log_read_data : std_logic_vector(31 downto 0); + -- + signal cs_ie_write_en : std_logic; + signal cs_ie_read_en : std_logic; + signal cs_ie_read_valid : std_logic; + signal cs_ie_read_data : std_logic_vector(31 downto 0); + -- + signal enable_rx : std_logic; + signal uart_regen_bypass : std_logic; + signal max_error_flag : std_logic; + signal rx_watchdog : std_logic; + signal rx_watchdog_en : std_logic; + signal rx_watchdog_clr : std_logic; + signal print_start_i : std_logic; + signal error_rate_thres : std_logic_vector(7 downto 0); + signal parity_err_cnt : std_logic_vector(15 downto 0); + signal skip_pos_cnt : std_logic_vector(15 downto 0); + signal mon_point_src : std_logic_vector(15 downto 0); + signal fine_time : std_logic_vector(27 downto 0); + signal coarse_time : std_logic_vector(31 downto 0); + -- + signal init, remote_init : std_logic; + signal dp_dir : std_logic_vector(CH_NUM - 1 downto 0); + signal set_pos_ie : std_logic; + signal enc_pulse : std_logic_vector(CH_NUM - 1 downto 0); + signal pd_pulse : std_logic; + signal pd_pulse_ie : std_logic; + signal pd_pulse_pof : std_logic; + signal inc_pos : std_logic; + signal inc_pos_pof : std_logic; + signal inc_pos_ie : std_logic; + signal dec_pos : std_logic; + signal dec_pos_pof : std_logic; + signal dec_pos_ie : std_logic; + signal abs_pos : std_logic_vector(31 downto 0); + signal abs_pos_pof : std_logic_vector(31 downto 0); + signal abs_pos_ie : std_logic_vector(39 downto 0); + -- + signal ch_pd, ch_pulse_out : std_logic_vector(CH_NUM - 1 downto 0); + signal ch_raw_pulse, ch_mask : std_logic_vector(CH_NUM - 1 downto 0); + signal ch_start_of_image : std_logic_vector(CH_NUM - 1 downto 0); + signal start_of_image_i : std_logic_vector(CH_NUM - 1 downto 0); + signal fire_pulse_i : std_logic_vector(CH_NUM - 1 downto 0); + signal src_sel : std_logic_vector(1 downto 0); + -- + type vel_samp_per_vec_t is array (0 to CH_NUM-1) of std_logic_vector(19 downto 0); + signal vel_meas : std_logic_vector(19 downto 0); + signal vel_sampling_per : vel_samp_per_vec_t; + -- + signal one_pps : std_logic; + signal ext_fp_det : std_logic_vector(15 downto 0); + signal ext_fp_gen : std_logic_vector(15 downto 0); + signal pof_rx_regen : std_logic; + signal log_data_src : std_logic_vector(31 downto 0); + +begin + + ----------------------------------------------------------------------------- + -- Synchronize the input reset (h2f_reset) to the clock (from PLL) + ----------------------------------------------------------------------------- + + iSyncReset : entity work.sync_reset + port map( + async_rstN => reset_n, + clk => clk, + sync_rstN => reset_n_i); + + + ----------------------------------------------------------------------------- + -- C&S Register Interface Splitting + ----------------------------------------------------------------------------- + + iCS_BUS_ITF : entity work.cs_bus_ift + generic map( + blk_num => blk_num) + port map( + rstN => reset_n_i, + clk => clk, + avs_address => avs_address(14 downto 0), + avs_write => avs_write, + avs_writedata => avs_writedata, + avs_read => avs_read, + avs_waitrequest => avs_waitrequest, + avs_readdata => avs_readdata, + cs_addr => cs_addr, + cs_we => cs_write_en, + cs_wr_data => cs_write_data, + cs_re => cs_read_en, + cs_rv => cs_read_valid, + cs_rd_data => cs_read_data); + + cs_ctrl_write_en <= cs_write_en(fp_ctrl_id); + cs_diag_write_en <= cs_write_en(diag_blk_id); + cs_log_write_en <= cs_write_en(log_blk_id); + cs_ie_write_en <= cs_write_en(int_enc_id); + cs_pg_write_en_g : for i in 1 to CH_NUM generate + cs_pg_write_en(i - 1) <= cs_write_en(pg_ch_id + i - 1); + end generate; + + cs_ctrl_read_en <= cs_read_en(fp_ctrl_id); + cs_diag_read_en <= cs_read_en(diag_blk_id); + cs_log_read_en <= cs_read_en(log_blk_id); + cs_ie_read_en <= cs_read_en(int_enc_id); + cs_pg_read_en_g : for i in 1 to CH_NUM generate + cs_pg_read_en(i - 1) <= cs_read_en(pg_ch_id + i - 1); + end generate; + + cs_read_valid(fp_ctrl_id) <= cs_ctrl_read_valid; + cs_read_valid(diag_blk_id) <= cs_diag_read_valid; + cs_read_valid(log_blk_id) <= cs_log_read_valid; + cs_read_valid(int_enc_id) <= cs_ie_read_valid; + cs_read_valid_pg_g : for i in 1 to CH_NUM generate + cs_read_valid(pg_ch_id + i - 1) <= cs_pg_read_valid(i - 1); + end generate; + + cs_read_data(31 + 32 * fp_ctrl_id downto 32 * fp_ctrl_id) <= cs_ctrl_read_data; + cs_read_data(31 + 32 * diag_blk_id downto 32 * diag_blk_id) <= cs_diag_read_data; + cs_read_data(31 + 32 * log_blk_id downto 32 * log_blk_id) <= cs_log_read_data; + cs_read_data(31 + 32 * int_enc_id downto 32 * int_enc_id) <= cs_ie_read_data; + cs_read_data_pg_g : for i in 1 to CH_NUM generate + cs_read_data(31 + 32 * (pg_ch_id + i - 1) downto 32 * (pg_ch_id + i - 1)) <= cs_pg_read_data(31 + 32 * (i - 1) downto 32 * (i - 1)); + end generate; + + ----------------------------------------------------------------------------- + -- Fire-Pulse-Manager Controller + ----------------------------------------------------------------------------- + + iCTRL : entity work.fire_pulse_ctrl_5 + port map( + reset_n => reset_n_i, + clk => clk, + src_sel => src_sel, + uart_regen_bypass => uart_regen_bypass, + upd_max_pos => open, + upd_min_pos => open, + enable_rx => enable_rx, + uart_bit_div => open, + error_rate_thres => error_rate_thres, + max_error_flag => max_error_flag, + rx_watchdog => rx_watchdog, + rx_watchdog_en => rx_watchdog_en, + rx_watchdog_clr => rx_watchdog_clr, + parity_err_cnt => parity_err_cnt, + skip_pos_cnt => skip_pos_cnt, + mon_point_src => mon_point_src, + mon_points => mon_pt, + coarse_time => coarse_time, + fine_time => fine_time, + one_pps => one_pps, + ext_fp_det => ext_fp_det, + ext_fp_gen => ext_fp_gen, + ins_fpm_irq_0 => ins_fpm_irq_0, + avs_address => cs_addr(3 downto 0), + avs_write => cs_ctrl_write_en, + avs_writedata => cs_write_data, + avs_read => cs_ctrl_read_en, + avs_readdatavalid => cs_ctrl_read_valid, + avs_readdata => cs_ctrl_read_data); + + ins_fpm_irq_1 <= '0'; + ins_fpm_irq_2 <= '0'; + ins_fpm_irq_3 <= '0'; + + -- Output multiplexer + fire_pulse_i <= ch_pulse_out when src_sel(0) = '1' else (others => pof_rx_regen); + fire_pulse <= fire_pulse_i; + -- The start-of-image for zero-gap is available only when fire-request are + -- generated locally, through the pulse-generator + start_of_image_i <= ch_start_of_image when src_sel(0) = '1' else (others => '0'); + start_of_image <= start_of_image_i; + + pd_pulse <= pd_pulse_pof when src_sel(1) = '0' else pd_pulse_ie; + abs_pos <= abs_pos_pof when src_sel(1) = '0' else abs_pos_ie(31 downto 0); + inc_pos <= inc_pos_pof when src_sel(1) = '0' else inc_pos_ie; + dec_pos <= dec_pos_pof when src_sel(1) = '0' else dec_pos_ie; + + pBUF_ABS_POS : process(clk) + begin + if(clk = '1' and clk'event) then + abs_pos_out <= abs_pos; + end if; + end process pBUF_ABS_POS; + + pINIT_GEN : process(clk) + begin + if(clk = '1' and clk'Event) then + if(src_sel(1) = '0') then + init <= not enable_rx or remote_init; + else + init <= set_pos_ie; + end if; + end if; + end process pINIT_GEN; + + mon_point_src(0) <= init; + mon_point_src(1) <= dp_dir(0); + mon_point_src(2) <= pd_pulse; + mon_point_src(3) <= enc_pulse(0); + mon_point_src(4) <= ch_pd(0); + mon_point_src(5) <= ch_pulse_out(0); + mon_point_src(6) <= ch_raw_pulse(0); + mon_point_src(7) <= ch_mask(0); + mon_point_src(8) <= pof_rx; + mon_point_src(9) <= fire_pulse_i(0); + mon_point_src(10) <= start_of_image_i(0); + mon_point_src(11) <= inc_pos; + mon_point_src(12) <= dec_pos; + mon_point_src(13) <= print_start_i; + -- + mon_point_src(15 downto 14) <= (others => '0'); + + pof_iso_en <= enable_rx; + + ----------------------------------------------------------------------------- + -- Encoder Speed Detection + ----------------------------------------------------------------------------- + + gENC_VEL: if TOF_COMP_EN = true generate + + -- Used for Time-of-Flight Compensation + iVEL : entity work.simple_enc_vel_detect_5 + port map ( + clk => clk, + init => init, + step_pos => inc_pos, + step_neg => dec_pos, + sampling_period => vel_sampling_per(0), + vel_meas => vel_meas); + + else generate + + vel_meas <= (others => '0'); + + end generate gENC_VEL; + + ----------------------------------------------------------------------------- + -- Pulse Generator + ----------------------------------------------------------------------------- + + pulse_generator_g : for i in 1 to CH_NUM generate + iCH_PG : entity work.pulse_generator_2 + generic map( + PD_QUEUE_SIZE => PD_QUEUE_SIZE, + PULSE_DELAY_EQUAL_EN => PULSE_DELAY_EQUAL_EN, + OUT_PULSE_CONDITION => OUT_PULSE_CONDITION, + OVERDRIVE_CHECK => false, + BIDIR_CH_OFFSET_EN => false, + DIAG_COUNTERS => DIAG_COUNTER_EN(i-1), + TOF_COMP_EN => TOF_COMP_EN, + PIXEL_PITCH_CORR_EN => PIXEL_PITCH_CORR_EN) + port map( + clk => clk, + reset_n => reset_n_i, + init => init, + pd_in => pd_pulse, + abs_position => abs_pos, + enc_vel => vel_meas, + enc_speed_meas_w => vel_sampling_per(i - 1), + dp_dir => dp_dir(i - 1), + pulse_out => ch_pulse_out(i - 1), + start_of_image => ch_start_of_image(i - 1), + ch_pd => ch_pd(i - 1), + ch_mask => ch_mask(i - 1), + raw_pulse_out => ch_raw_pulse(i - 1), + enc_pulse => enc_pulse(i -1), + avs_address => cs_addr(10 downto 0), + avs_write => cs_pg_write_en(i - 1), + avs_writedata => cs_write_data, + avs_read => cs_pg_read_en(i - 1), + avs_readdatavalid => cs_pg_read_valid(i - 1), + avs_readdata => cs_pg_read_data(31 + 32 * (i - 1) downto 32 * (i - 1))); + end generate; + + ----------------------------------------------------------------------------- + -- POF Interface + ----------------------------------------------------------------------------- + + gPOF: if POF_PROT_VER = 0 generate + + -- POF Receiver + iPOF_RX : entity work.pof_rx_0 + generic map( + GEN_BIT_DIV => POF_UART_BIT_BIV) + port map( + reset_n => reset_n_i, + clk => clk, + init => '0', + rx_clk => rx_clk, + rx_data => pof_rx, + init_out => remote_init, + pd_out => pd_pulse_pof, + inc_pos => inc_pos_pof, + dec_pos => dec_pos_pof, + abs_pos => abs_pos_pof, + enable => enable_rx, + error_rate_thres => error_rate_thres, + one_pps => one_pps, + max_error_flag => max_error_flag, + rx_watchdog => rx_watchdog, + rx_watchdog_en => rx_watchdog_en, + rx_watchdog_clr => rx_watchdog_clr, + parity_err_cnt => parity_err_cnt, + skip_pos_cnt => skip_pos_cnt); + + -- UART signal regeneration + iUART_REGEN : entity work.pof_uart_regen_0 + generic map( + GEN_BIT_DIV => POF_UART_BIT_BIV, + data_width => 8) + port map( + reset_n => reset_n, + clk => rx_clk, + enable => enable_rx, + bypass_en => uart_regen_bypass, + uart_rx => pof_rx, + uart_tx => pof_tx); + + print_start <= print_start_i; + + print_start_i <= '0'; + + elsif POF_PROT_VER = 1 generate + + -- POF Receiver + iPOF_RX : entity work.pof_rx_1 + generic map( + GEN_BIT_DIV => POF_UART_BIT_BIV) + port map( + reset_n => reset_n_i, + clk => clk, + init => '0', + rx_clk => rx_clk, + rx_data => pof_rx, + init_out => remote_init, + pd_out => pd_pulse_pof, + print_start => print_start_i, + inc_pos => inc_pos_pof, + dec_pos => dec_pos_pof, + abs_pos => abs_pos_pof, + enable => enable_rx, + error_rate_thres => error_rate_thres, + one_pps => one_pps, + max_error_flag => max_error_flag, + rx_watchdog => rx_watchdog, + rx_watchdog_en => rx_watchdog_en, + rx_watchdog_clr => rx_watchdog_clr, + parity_err_cnt => parity_err_cnt, + skip_pos_cnt => skip_pos_cnt); + + print_start <= print_start_i; + + -- UART signal regeneration + iUART_REGEN : entity work.pof_uart_regen_1 + generic map( + GEN_BIT_DIV => POF_UART_BIT_BIV, + data_width => 9) + port map( + reset_n => reset_n, + clk => rx_clk, + enable => enable_rx, + bypass_en => uart_regen_bypass, + uart_rx => pof_rx, + uart_tx => pof_tx); + + end generate gPOF; + + ----------------------------------------------------------------------------- + -- Diagnostic block + ----------------------------------------------------------------------------- + + gDIAG: if ADD_SMB_DIAG = false generate + + pDIAG_RD : process(clk) + begin + if(clk = '1' and clk'event) then + cs_diag_read_valid <= cs_diag_read_en; + end if; + end process pDIAG_RD; + + cs_diag_read_data <= X"DEAD_BEEF"; + + elsif ADD_SMB_DIAG = true generate + + iDiagnostic : entity work.smb_diagnostics_5 + port map( + clk => clk, + reset_n => reset_n_i, + ext_diag_rst => init, + rs422_phase0 => '0', + rs422_phase1 => '0', + rs422_zero_ph => '0', + rs422_prod_det => '0', + ttl_phase0 => '0', + ttl_phase1 => '0', + ttl_zero_ph => '0', + ttl_prod_det => '0', + ttl_prod_det_npn => '0', + filt_phase0 => '0', + filt_phase1 => '0', + filt_zero_ph => '0', + filt_prod_det => pd_pulse, + enc_out => enc_pulse(0), + pd_out => ch_pd(0), + pos_step => inc_pos, + neg_step => dec_pos, + drop_watch => '0', + fire_req => fire_pulse_i(0), + fine_time => fine_time, + coarse_time => coarse_time, + abs_position => open, + ins_diag_irq_0 => ins_fpm_irq_1, + ins_diag_irq_1 => ins_fpm_irq_2, + ins_diag_irq_2 => ins_fpm_irq_3, + avs_address => cs_addr(5 downto 0), + avs_write => cs_diag_write_en, + avs_writedata => cs_write_data, + avs_read => cs_diag_read_en, + avs_readdatavalid => cs_diag_read_valid, + avs_readdata => cs_diag_read_data); + + end generate gDIAG; + + ----------------------------------------------------------------------------- + -- Event Logger + ----------------------------------------------------------------------------- + + gEL: if ADD_EVENT_LOGGER = false generate + + pLOGGER_RD : process(clk) + begin + if(clk = '1' and clk'event) then + cs_log_read_valid <= cs_log_read_en; + end if; + end process pLOGGER_RD; + + cs_log_read_data <= X"DEAD_BEEF"; + + elsif ADD_EVENT_LOGGER = true generate + + event_logger_0_1: entity work.event_logger_0 + generic map ( + FIFO_SIZE => LOG_FIFO_SIZE) + port map ( + rstN => reset_n_i, + clk => clk, + data_src => log_data_src, + fine_time => fine_time, + abs_position => abs_pos, + ins_irq => open, + avs_address => cs_addr(3 downto 0), + avs_write => cs_log_write_en, + avs_writedata => cs_write_data, + avs_read => cs_log_read_en, + avs_readdatavalid => cs_log_read_valid, + avs_readdata => cs_log_read_data); + + log_data_src(0) <= init; + log_data_src(1) <= dp_dir(0); + log_data_src(2) <= pd_pulse; + log_data_src(3) <= enc_pulse(0); + log_data_src(4) <= ch_pd(0); + log_data_src(5) <= ch_pulse_out(0); + log_data_src(6) <= ch_raw_pulse(0); + log_data_src(7) <= ch_mask(0); + log_data_src(8) <= pof_rx; + log_data_src(9) <= fire_pulse_i(0); + log_data_src(10) <= start_of_image_i(0); + log_data_src(11) <= inc_pos; + log_data_src(12) <= dec_pos; + log_data_src(13) <= print_start_i; + -- + log_data_src(31 downto 14) <= (others => '0'); + + end generate gEL; + + ----------------------------------------------------------------------------- + -- Ext fire pulse regen + ----------------------------------------------------------------------------- + + fire_pulse_ext_i : entity work.fire_pulse_ext_5 + port map( + reset_n => reset_n_i, + clk => clk, + + ext_fp_det => ext_fp_det, + ext_fp_gen => ext_fp_gen, + + ext_in => pof_rx, + ext_out => pof_rx_regen); + + ----------------------------------------------------------------------------- + -- Internal encoder generator + ----------------------------------------------------------------------------- + + iEMUL : entity work.enc_pd_emul_1 + generic map( + SEQ_ENABLE => false) + port map( + clk => clk, + reset_n => reset_n_i, + ttl_pd => open, + ttl_enc_p1 => open, + ttl_enc_p2 => open, + ttl_enc_zp => open, + rs422_pd => pd_pulse_ie, + rs422_enc_p1 => open, + rs422_enc_p2 => open, + rs422_enc_zp => open, + abs_pos_out => abs_pos_ie, + set_pos_out => set_pos_ie, + inc_pos_out => inc_pos_ie, + dec_pos_out => dec_pos_ie, + avs_address => cs_addr(9 downto 0), + avs_write => cs_ie_write_en, + avs_writedata => cs_write_data, + avs_read => cs_ie_read_en, + avs_readdatavalid => cs_ie_read_valid, + avs_readdata => cs_ie_read_data); + +end architecture rtl; diff --git a/generic_ip/fire_pulse_manager/5/src/simple_enc_vel_detect_5.vhd b/generic_ip/fire_pulse_manager/5/src/simple_enc_vel_detect_5.vhd new file mode 100644 index 0000000..5443216 --- /dev/null +++ b/generic_ip/fire_pulse_manager/5/src/simple_enc_vel_detect_5.vhd @@ -0,0 +1,76 @@ +------------------------------------------------------------------------------- +-- Title : simple encoder velocity detection +-- Project : project independent +------------------------------------------------------------------------------- +-- File : simple_enc_vel_detect_5.vhd +-- Author : Gianmarco Girau +-- Company : Global Inkjet Systems +-- Created : 2019-06-18 +-- Last update: 2019-12-16 +-- SVN ID : Git +-- Standard : VHDL'2008 +------------------------------------------------------------------------------- +-- Description: +-- This block detects encoder velocity by measuring the balance of encoder +-- positive and negative steps over consecutive sampling periods. +-- The sampling period is supposed to be less than 2 ms +------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 + + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity simple_enc_vel_detect_5 is + port ( + clk : in std_logic; -- Must be 100 MHz + init : in std_logic; + step_pos : in std_logic; + step_neg : in std_logic; + sampling_period : in std_logic_vector(19 downto 0); + vel_meas : out std_logic_vector(19 downto 0)); +end simple_enc_vel_detect_5; + +architecture RTL of simple_enc_vel_detect_5 is + + signal init_i, sampling_pulse : std_logic; + + signal sampling_per_cnt : std_logic_vector(19 downto 0); + signal vel_meas_i : std_logic_vector(19 downto 0); + signal vel_meas_sat_pos : std_logic_vector(19 downto 0); + signal vel_meas_sat_neg : std_logic_vector(19 downto 0); + +begin -- RTL + + pVEL_DETECT : process(clk) + begin + if(clk = '1' and clk'event) then + init_i <= init; + if(init_i = '1' or sampling_pulse = '1') then + sampling_per_cnt <= (others => '0'); + else + sampling_per_cnt <= std_logic_vector(unsigned(sampling_per_cnt)+1); + end if; + if(init_i = '1' or sampling_pulse = '1') then + vel_meas_i <= (others => '0'); + elsif(step_pos = '1' and signed(vel_meas_i) < signed(vel_meas_sat_pos)) then + vel_meas_i <= std_logic_vector(signed(vel_meas_i)+1); + elsif(step_neg = '1' and signed(vel_meas_i) > signed(vel_meas_sat_neg)) then + vel_meas_i <= std_logic_vector(signed(vel_meas_i)-1); + end if; + if(init_i = '1') then + vel_meas <= (others => '0'); + elsif(sampling_pulse = '1') then + vel_meas <= vel_meas_i; + end if; + end if; + end process pVEL_DETECT; + + sampling_pulse <= '1' when unsigned(sampling_per_cnt) = unsigned(sampling_period)-1 else '0'; + + -- define positive and negative saturation thresholds + vel_meas_sat_pos <= (vel_meas_i'left => '0', others => '1'); + vel_meas_sat_neg <= (vel_meas_i'left => '1', others => '0'); + +end RTL; diff --git a/generic_ip/fire_pulse_manager/5/src/smb_diagnostics_5.vhd b/generic_ip/fire_pulse_manager/5/src/smb_diagnostics_5.vhd new file mode 100644 index 0000000..7d51919 --- /dev/null +++ b/generic_ip/fire_pulse_manager/5/src/smb_diagnostics_5.vhd @@ -0,0 +1,702 @@ +------------------------------------------------------------------------------- +-- Title : smb diagnostic block +-- Project : SMB +------------------------------------------------------------------------------- +-- File : smb_diagnostics_5.vhd +-- Author : Gianmarco Girau +-- Company : Global Inkjet Systems +-- Created : 2016-08-02 +-- Last update: 2019-12-16 +-- SVN ID : Git +-- Standard : VHDL'2008 +------------------------------------------------------------------------------- +-- Description: This block includes all the SMB diagnostic functionalities +-- except the event logger. +------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity smb_diagnostics_5 is + port ( + clk : in std_logic; + reset_n : in std_logic := '1'; + -- External sync reset (via daisy-chain) + ext_diag_rst : in std_logic; + -- diagnostic inputs + rs422_phase0 : in std_logic; + rs422_phase1 : in std_logic; + rs422_zero_ph : in std_logic; + rs422_prod_det : in std_logic; + ttl_phase0 : in std_logic; + ttl_phase1 : in std_logic; + ttl_zero_ph : in std_logic; + ttl_prod_det : in std_logic; + ttl_prod_det_npn : in std_logic; + filt_phase0 : in std_logic; + filt_phase1 : in std_logic; + filt_zero_ph : in std_logic; + filt_prod_det : in std_logic; + enc_out : in std_logic; + pd_out : in std_logic; + pos_step : in std_logic; + neg_step : in std_logic; + drop_watch : in std_logic; + fire_req : in std_logic; + -- local timer + fine_time : in std_logic_vector(27 downto 0); + coarse_time : in std_logic_vector(31 downto 0); + -- Absolute Position + abs_position : out std_logic_vector(31 downto 0); + -- Interrupt Senders + ins_diag_irq_0 : out std_logic; + ins_diag_irq_1 : out std_logic; + ins_diag_irq_2 : out std_logic; + -- Avalon MM Interface + avs_address : in std_logic_vector( 5 downto 0); + avs_write : in std_logic; + avs_writedata : in std_logic_vector(31 downto 0); + avs_read : in std_logic; + avs_readdatavalid : out std_logic; + avs_readdata : out std_logic_vector(31 downto 0)); +end entity smb_diagnostics_5; + +architecture rtl of smb_diagnostics_5 is + + constant ADDR_WIDTH : integer := avs_address'length; + + constant DIAG_INIT_REG : std_logic_vector(5 downto 0) := b"000000"; + constant DIAG_IN_STATUS_REG : std_logic_vector(5 downto 0) := b"000001"; + constant PHASE0_CNT_REG : std_logic_vector(5 downto 0) := b"000010"; + constant PHASE1_CNT_REG : std_logic_vector(5 downto 0) := b"000011"; + constant ZERO_PH_CNT_REG : std_logic_vector(5 downto 0) := b"000100"; + constant PD_CNT_REG : std_logic_vector(5 downto 0) := b"000101"; + constant ENC_OUT_CNT_REG : std_logic_vector(5 downto 0) := b"000110"; + constant PD_OUT_CNT_REG : std_logic_vector(5 downto 0) := b"000111"; + constant FIRE_REQ_CNT_REG : std_logic_vector(5 downto 0) := b"001000"; + constant UNUSED_REG_0 : std_logic_vector(5 downto 0) := b"001001"; + constant UNUSED_REG_1 : std_logic_vector(5 downto 0) := b"001010"; + constant UNUSED_REG_2 : std_logic_vector(5 downto 0) := b"001011"; + constant ENC_D_TIME_REG : std_logic_vector(5 downto 0) := b"001100"; + constant ENC_DMIN_TIME_REG : std_logic_vector(5 downto 0) := b"001101"; + constant ENC_DMAX_TIME_REG : std_logic_vector(5 downto 0) := b"001110"; + constant ENC_D_TIME_PREV_REG : std_logic_vector(5 downto 0) := b"001111"; + constant ENC_D_TIME_MEAS_STEP : std_logic_vector(5 downto 0) := b"010000"; + constant POSITION_CNT_REG : std_logic_vector(5 downto 0) := b"010001"; + constant DIR_COUNT_THRES_REG : std_logic_vector(5 downto 0) := b"010010"; + constant DIR_COUNT_REG : std_logic_vector(5 downto 0) := b"010011"; + constant ENC_SAMPL_PER_REG : std_logic_vector(5 downto 0) := b"010100"; + constant ENC_FIFO_CS_REG : std_logic_vector(5 downto 0) := b"010101"; + constant ENC_FIFO_OUT_REG : std_logic_vector(5 downto 0) := b"010110"; + constant PD_FIFO_CS_REG : std_logic_vector(5 downto 0) := b"010111"; + constant PD_FIFO_OUT_REG : std_logic_vector(5 downto 0) := b"011000"; + constant PD_WATCH_DOG_CTRL : std_logic_vector(5 downto 0) := b"011001"; + constant PD_WATCH_DOG_THRES : std_logic_vector(5 downto 0) := b"011010"; + constant IRQ_MNG_REG : std_logic_vector(5 downto 0) := b"011011"; + + -- signals + type fsm_status_t is (idle, wait_ph1_ris, wait_ph0_ris); + signal fsm_status_curr,fsm_status_next : fsm_status_t; + -- + signal filt_phase0_d, filt_phase1_d, filt_zero_ph_d, filt_prod_det_d : std_logic; + signal enc_out_d, pd_out_d, filt_phase0_p, filt_phase1_p, init_i : std_logic; + signal filt_zero_ph_p, filt_prod_det_p, enc_out_p, pd_out_p : std_logic; + signal init, rst_counters_i, rst_counters, rst_measur_i, rst_measur : std_logic; + signal rst_dir, rst_dir_i, enable_diff_measur, meas_enc_p : std_logic; + signal ph0_rising, ph0_falling, ph1_rising, ph1_falling : std_logic; + signal set_dir_forward, set_dir_backward, dir_pos_sat, dir_neg_sat : std_logic; + signal direction, direction_d, direction_change : std_logic; + signal sampling_time, fifo_rd_en, fifo_wr_en, fifo_full, fifo_error : std_logic; + signal rst_fifo_i, rst_fifo, rst_pos, rst_pos_i, avs_read_i : std_logic; + signal pd_fifo_error, pd_fifo_wr_en, pd_fifo_rd_en, pd_fifo_full : std_logic; + signal pd_p, pd_log_src, pd_fifo_alarm, enc_fifo_alarm : std_logic; + signal clr_pd_pos, pd_wd_en, pd_wd_alarm, rst_pd_fifo, rst_pd_fifo_i : std_logic; + signal fire_req_d, fire_req_p : std_logic; + -- + signal enable_diff_measur_cnt : std_logic_vector( 1 downto 0); + signal irq_en, irq_clr, irq_src, irq_src_d : std_logic_vector( 2 downto 0); + signal irq, irq_val, irq_mask, pd_data_sel : std_logic_vector( 2 downto 0); + signal meas_enc_pulse : std_logic_vector( 3 downto 0); + signal pd_fifo_usedw, pd_fifo_thres : std_logic_vector( 7 downto 0); + signal fifo_thres, fifo_usedw : std_logic_vector( 9 downto 0); + signal dir_cnt, dir_change_cnt : std_logic_vector(15 downto 0); + signal pos_dir_thres, neg_dir_thres : std_logic_vector(15 downto 0); + signal meas_pulse_cnt, meas_step : std_logic_vector(15 downto 0); + signal input_status : std_logic_vector(16 downto 0); + signal sampling_period, sampling_time_cnt : std_logic_vector(27 downto 0); + signal fine_time_l : std_logic_vector(27 downto 0); + signal filt_phase0_cnt, filt_phase1_cnt : std_logic_vector(31 downto 0); + signal filt_zero_ph_cnt, filt_prod_det_cnt : std_logic_vector(31 downto 0); + signal enc_out_cnt, pd_out_cnt : std_logic_vector(31 downto 0); + signal enc_delta_time, enc_delta_time_prev : std_logic_vector(31 downto 0); + signal enc_delta_time_cnt : std_logic_vector(31 downto 0); + signal enc_delta_time_min, enc_delta_time_max : std_logic_vector(31 downto 0); + signal fifo_d, fifo_q, pos_cnt : std_logic_vector(31 downto 0); + signal pd_fifo_d, pd_fifo_q : std_logic_vector(31 downto 0); + signal pd_pos, coarse_time_l, pd_wd_thres : std_logic_vector(31 downto 0); + signal pd_delta_pos, pd_delta_pos_abs : std_logic_vector(31 downto 0); + signal fire_req_cnt : std_logic_vector(31 downto 0); + + +begin + + pInit : process(clk) + begin + if(clk = '1' and clk'event) then + init <= init_i or ext_diag_rst; + end if; + end process pInit; + + ----------------------------------------------------------------------------- + -- Input Status + ----------------------------------------------------------------------------- + + pInputStatus : process(clk) + begin + if(clk = '1' and clk'event) then + input_status( 0) <= rs422_phase0; + input_status( 1) <= rs422_phase1; + input_status( 2) <= rs422_zero_ph; + input_status( 3) <= rs422_prod_det; + input_status( 4) <= ttl_phase0; + input_status( 5) <= ttl_phase1; + input_status( 6) <= ttl_zero_ph; + input_status( 7) <= ttl_prod_det; + input_status( 8) <= ttl_prod_det_npn; + input_status( 9) <= filt_phase0; + input_status(10) <= filt_phase1; + input_status(11) <= filt_zero_ph; + input_status(12) <= filt_prod_det; + input_status(13) <= enc_out; + input_status(14) <= pd_out; + input_status(15) <= drop_watch; + input_status(16) <= fire_req; + end if; + end process pInputStatus; + + ----------------------------------------------------------------------------- + -- Edge detection and counting + ----------------------------------------------------------------------------- + + pEdgeDetect_Cnt : process(clk) + begin + if(clk = '1' and clk'event) then + filt_phase0_d <= filt_phase0; + filt_phase1_d <= filt_phase1; + filt_zero_ph_d <= filt_zero_ph; + filt_prod_det_d <= filt_prod_det; + enc_out_d <= enc_out; + pd_out_d <= pd_out; + fire_req_d <= fire_req; + if(rst_counters = '1') then + filt_phase0_cnt <= (others => '0'); + elsif(filt_phase0_p = '1') then + filt_phase0_cnt <= std_logic_vector(unsigned(filt_phase0_cnt)+1); + end if; + if(rst_counters = '1') then + filt_phase1_cnt <= (others => '0'); + elsif(filt_phase1_p = '1') then + filt_phase1_cnt <= std_logic_vector(unsigned(filt_phase1_cnt)+1); + end if; + if(rst_counters = '1') then + filt_zero_ph_cnt <= (others => '0'); + elsif(filt_zero_ph_p = '1') then + filt_zero_ph_cnt <= std_logic_vector(unsigned(filt_zero_ph_cnt)+1); + end if; + if(rst_counters = '1') then + filt_prod_det_cnt <= (others => '0'); + elsif(filt_prod_det_p = '1') then + filt_prod_det_cnt <= std_logic_vector(unsigned(filt_prod_det_cnt)+1); + end if; + if(rst_counters = '1') then + enc_out_cnt <= (others => '0'); + elsif(enc_out_p = '1') then + enc_out_cnt <= std_logic_vector(unsigned(enc_out_cnt)+1); + end if; + if(rst_counters = '1') then + pd_out_cnt <= (others => '0'); + elsif(pd_out_p = '1') then + pd_out_cnt <= std_logic_vector(unsigned(pd_out_cnt)+1); + end if; + if(rst_counters = '1') then + fire_req_cnt <= (others => '0'); + elsif(fire_req_p = '1') then + fire_req_cnt <= std_logic_vector(unsigned(fire_req_cnt)+1); + end if; + end if; + end process pEdgeDetect_Cnt; + + filt_phase0_p <= filt_phase0 and not filt_phase0_d; + filt_phase1_p <= filt_phase1 and not filt_phase1_d; + filt_zero_ph_p <= filt_zero_ph and not filt_zero_ph_d; + filt_prod_det_p <= filt_prod_det and not filt_prod_det_d; + enc_out_p <= enc_out and not enc_out_d; + pd_out_p <= pd_out and not pd_out_d; + fire_req_p <= fire_req and not fire_req_d; + + rst_counters <= rst_counters_i or init; + + ----------------------------------------------------------------------------- + -- Speed and acceleration measurements + ----------------------------------------------------------------------------- + + pMeasure : process(clk) + begin + if(clk = '1' and clk'event) then + if(rst_measur = '1' or meas_enc_p = '1') then + meas_pulse_cnt <= (others => '0'); + elsif(enc_out_d = '1') then + meas_pulse_cnt <= std_logic_vector(unsigned(meas_pulse_cnt)+1); + end if; + if(rst_measur = '1') then + meas_enc_pulse <= (others => '0'); + else + meas_enc_pulse <= meas_enc_pulse(meas_enc_pulse'high-1 downto 0) & meas_enc_p; + end if; + if(rst_measur = '1' or meas_enc_pulse(0) = '1') then + enc_delta_time_cnt <= (others => '0'); + else + enc_delta_time_cnt <= std_logic_vector(unsigned(enc_delta_time_cnt)+1); + end if; + if(rst_measur = '1') then + enc_delta_time <= (others => '0'); + enc_delta_time_prev <= (others => '0'); + elsif(meas_enc_pulse(0) = '1') then + enc_delta_time <= enc_delta_time_cnt; + enc_delta_time_prev <= enc_delta_time; + end if; + if(rst_measur = '1' or rst_counters = '1') then + enable_diff_measur_cnt <= (others => '0'); + elsif(meas_enc_p = '1') then + enable_diff_measur_cnt <= std_logic_vector(unsigned(enable_diff_measur_cnt)+1); + end if; + if(rst_measur = '1' or rst_counters = '1') then + enable_diff_measur <= '0'; + elsif(enable_diff_measur_cnt = "11") then + enable_diff_measur <= '1'; + end if; + if(enable_diff_measur = '0') then + enc_delta_time_min <= (others => '1'); + elsif(meas_enc_pulse(2) = '1' and unsigned(enc_delta_time) < unsigned(enc_delta_time_min)) then + enc_delta_time_min <= enc_delta_time; + end if; + if(enable_diff_measur = '0') then + enc_delta_time_max <= (others => '0'); + elsif(meas_enc_pulse(2) = '1' and unsigned(enc_delta_time) > unsigned(enc_delta_time_max)) then + enc_delta_time_max <= enc_delta_time; + end if; + end if; + end process pMeasure; + + meas_enc_p <= '1' when enc_out_p = '1' and unsigned(meas_pulse_cnt) = unsigned(meas_step) else '0'; + + rst_measur <= rst_measur_i or init; + + ----------------------------------------------------------------------------- + -- Direction detection & Position Tracking + ----------------------------------------------------------------------------- + + -- Direction is detected by checking the order of rising and falling edged + -- between phase-0 and phase-1. + -- Forward direction => Phase-0 is anticipated w.r.t. Phase-1 + -- Backward direction => Phase-0 is delayed w.r.t. Phase-1 + + ph0_rising <= filt_phase0_p; + ph0_falling <= not filt_phase0 and filt_phase0_d; + ph1_rising <= filt_phase1_p; + ph1_falling <= not filt_phase1 and filt_phase1_d; + + rst_dir <= rst_dir_i or init; + + -- Use a FSM to detect the sequence of events: + -- FSM Status Register + pFSM_SR : process(clk) + begin + if(clk = '1' and clk'event) then + if(rst_dir = '1') then + fsm_status_curr <= idle; + else + fsm_status_curr <= fsm_status_next; + end if; + end if; + end process pFSM_SR; + + -- FSM Combinational Logic + pFSM_CL : process(fsm_status_curr, ph0_rising, ph0_falling, ph1_rising, ph1_falling) + begin + -- default assignments + set_dir_forward <= '0'; + set_dir_backward <= '0'; + -- + fsm_status_next <= fsm_status_curr; + + case fsm_status_curr is + when idle => + if(ph0_rising = '1') then + fsm_status_next <= wait_ph1_ris; + elsif(ph1_rising = '1') then + fsm_status_next <= wait_ph0_ris; + end if; + + when wait_ph1_ris => + if(ph1_rising = '1') then + set_dir_forward <= '1'; + fsm_status_next <= idle; + elsif(ph0_falling = '1') then + fsm_status_next <= idle; + end if; + + when wait_ph0_ris => + if(ph0_rising = '1') then + set_dir_backward <= '1'; + fsm_status_next <= idle; + elsif(ph1_falling = '1') then + fsm_status_next <= idle; + end if; + + when others => null; + end case; + end process pFSM_CL; + + pDirRegs : process(clk) + begin + if(clk = '1' and clk'event) then + if(rst_dir = '1') then + dir_cnt <= (others => '0'); + elsif(set_dir_forward = '1' and dir_pos_sat = '0') then + dir_cnt <= std_logic_vector(signed(dir_cnt)+1); + elsif(set_dir_backward = '1' and dir_neg_sat = '0') then + dir_cnt <= std_logic_vector(signed(dir_cnt)-1); + end if; + direction_d <= direction; + if(rst_dir = '1') then + dir_change_cnt <= (others => '0'); + elsif(direction_change = '1') then + dir_change_cnt <= std_logic_vector(unsigned(dir_change_cnt)+1); + end if; + end if; + end process pDirRegs; + + direction <= dir_cnt(dir_cnt'high); + direction_change <= direction xor direction_d; + + -- Positive/Negative saturation for the direction counter + dir_pos_sat <= '1' when signed(dir_cnt) > signed(pos_dir_thres) else '0'; + dir_neg_sat <= '1' when signed(dir_cnt) < signed(neg_dir_thres) else '0'; + + -- Position Tracking + pPOS_TRACK : process(clk) + begin + if(clk = '1' and clk'event) then + if(rst_pos = '1') then + pos_cnt <= (others => '0'); + elsif(pos_step = '1') then + pos_cnt <= std_logic_vector(signed(pos_cnt)+1); + elsif(neg_step = '1') then + pos_cnt <= std_logic_vector(signed(pos_cnt)-1); + end if; + abs_position <= pos_cnt; + end if; + end process pPOS_TRACK; + + rst_pos <= init or rst_pos_i; + + ----------------------------------------------------------------------------- + -- PD logging + ----------------------------------------------------------------------------- + + pPD_log : process(clk) + begin + if(clk = '1' and clk'event) then + if(init = '1') then + pd_fifo_error <= '0'; + elsif(pd_fifo_wr_en = '1' and pd_fifo_full = '1') then + pd_fifo_error <= '1'; + end if; + if(init = '0' and pd_p = '1') then + pd_data_sel <= "001"; + else + pd_data_sel <= pd_data_sel(1 downto 0) & '0'; + end if; + if(init = '1') then + fine_time_l <= (others => '0'); + coarse_time_l <= (others => '0'); + pd_pos <= (others => '0'); + elsif(pd_p = '1') then + fine_time_l <= fine_time; + coarse_time_l <= coarse_time; + pd_pos <= pos_cnt; + end if; + end if; + end process pPD_log; + + pd_p <= pd_out_p when pd_log_src = '1' else filt_prod_det_p; + + iPD_log_fifo : entity work.sync_fifo + generic map( + FIFO_WIDTH => 32, + FIFO_DEPTH => 256) + port map ( + clock => clk, + data => pd_fifo_d, + rdreq => pd_fifo_rd_en, + sclr => rst_pd_fifo, + wrreq => pd_fifo_wr_en, + empty => open, + full => pd_fifo_full, + q => pd_fifo_q, + usedw => pd_fifo_usedw); + + pd_fifo_rd_en <= '1' when avs_read = '1' and avs_address = PD_FIFO_OUT_REG else '0'; + + pd_fifo_alarm <= '1' when unsigned(pd_fifo_usedw) >= unsigned(pd_fifo_thres) else '0'; + + -- FIFO write logic + pd_fifo_wr_en <= pd_data_sel(2) or pd_data_sel(1) or pd_data_sel(0); + + -- select the input for the pd fifo + with pd_data_sel select + pd_fifo_d <= + X"0" & fine_time_l when "001", + coarse_time_l when "010", + pd_pos when others; + + rst_pd_fifo <= rst_pd_fifo_i or init; + + -- PD Positional Watch-Dog + pPD_WatchDog : process(clk) + begin + if(clk = '1') then + if(init = '1' or clr_pd_pos = '1' or filt_prod_det_p = '1') then + pd_delta_pos <= (others => '0'); + elsif(pos_step = '1') then + pd_delta_pos <= std_logic_vector(signed(pd_delta_pos)+1); + elsif(neg_step = '1') then + pd_delta_pos <= std_logic_vector(signed(pd_delta_pos)-1); + end if; + -- compare the absolute value of the delta position against the + -- threshold. Use the 1's complement to save some logic. + if(pd_wd_en = '1' and unsigned(pd_delta_pos_abs) > unsigned(pd_wd_thres)) then + pd_wd_alarm <= '1'; + else + pd_wd_alarm <= '0'; + end if; + end if; + end process pPD_WatchDog; + + pd_delta_pos_abs <= '0' & pd_delta_pos(30 downto 0) when pd_delta_pos(31) = '0' else '0' & not pd_delta_pos(30 downto 0); + + ----------------------------------------------------------------------------- + -- Encoder pulse count buffering (ACTUALLY NOW IS POSITION COUNT SAMPLING!!!) + ----------------------------------------------------------------------------- + + -- The encoder pulse count is periodically sampled. The samples are stored in + -- a dedicated FIFO and they can be used to generate a speed/acceleration + -- profile. => CHANGED: JUST using the position count, because it is more + -- it is independent of the encoder directionality settings + + pEncPulseSample : process(clk) + begin + if(clk = '1' and clk'event) then + if(rst_fifo = '1' or sampling_time = '1') then + sampling_time_cnt <= (others => '0'); + else + sampling_time_cnt <= std_logic_vector(unsigned(sampling_time_cnt)+1); + end if; + if(rst_fifo = '1') then + fifo_error <= '0'; + elsif(fifo_wr_en = '1' and fifo_full = '1') then + fifo_error <= '1'; + end if; + fifo_wr_en <= sampling_time; + --fifo_d <= enc_out_cnt; + fifo_d <= pos_cnt; + end if; + end process pEncPulseSample; + + sampling_time <= '1' when unsigned(sampling_time_cnt) = unsigned(sampling_period) else '0'; + + iEncPulseFifo : entity work.sync_fifo + generic map( + FIFO_WIDTH => 32, + FIFO_DEPTH => 1024) + port map ( + clock => clk, + data => fifo_d, + rdreq => fifo_rd_en, + sclr => rst_fifo, + wrreq => fifo_wr_en, + empty => open, + full => fifo_full, + q => fifo_q, + usedw => fifo_usedw); + + fifo_rd_en <= '1' when avs_read = '1' and avs_address = ENC_FIFO_OUT_REG else '0'; + + enc_fifo_alarm <= '1' when unsigned(fifo_usedw) >= unsigned(fifo_thres) else '0'; + + rst_fifo <= init or rst_fifo_i or rst_counters_i; + + ----------------------------------------------------------------------------- + -- IRQ generation and management + ----------------------------------------------------------------------------- + + pIRQ : process(reset_n, clk) + begin + if(reset_n = '0') then + ins_diag_irq_0 <= '0'; + ins_diag_irq_1 <= '0'; + ins_diag_irq_2 <= '0'; + irq <= "000"; + irq_src_d <= "000"; + elsif(clk = '1' and clk'event) then + irq_src_d <= irq_src; + for n in 0 to 2 loop + if(irq_clr(n) = '1') then + irq(n) <= '0'; + elsif(irq_en(n) = '1' and irq_src(n) = '1' and irq_src_d(n) = '0') then + irq(n) <= '1'; + end if; + end loop; -- n + ins_diag_irq_0 <= irq_val(0); + ins_diag_irq_1 <= irq_val(1); + ins_diag_irq_2 <= irq_val(2); + end if; + end process pIRQ; + + irq_val <= irq and not irq_mask; + irq_src <= pd_wd_alarm & pd_fifo_alarm & enc_fifo_alarm; + + ----------------------------------------------------------------------------- + -- C&S registers (Avalon-MM I/F) + ----------------------------------------------------------------------------- + + pCTRL_STATUS : process(reset_n, clk) + begin + if(reset_n = '0') then + avs_read_i <= '0'; + avs_readdatavalid <= '0'; + avs_readdata <= (others => '0'); + -- + init_i <= '0'; + rst_counters_i <= '0'; + rst_measur_i <= '0'; + rst_dir_i <= '0'; + rst_fifo_i <= '0'; + rst_pos_i <= '0'; + rst_pd_fifo_i <= '0'; + pd_log_src <= '0'; + pd_wd_en <= '0'; + clr_pd_pos <= '0'; + irq_en <= "000"; + irq_clr <= "000"; + irq_mask <= "000"; + meas_step <= (0 => '1', others => '0'); + sampling_period <= (others => '0'); + pos_dir_thres <= X"007F"; -- +127 + neg_dir_thres <= X"FF81"; -- -127 + elsif(clk = '1' and clk'event) then + -- CTRL registers + if(avs_write = '1') then + case avs_address is + when DIAG_INIT_REG => + init_i <= avs_writedata( 0); + rst_counters_i <= avs_writedata( 1); + rst_measur_i <= avs_writedata( 2); + rst_dir_i <= avs_writedata( 3); + rst_fifo_i <= avs_writedata( 4); + rst_pos_i <= avs_writedata( 5); + rst_pd_fifo_i <= avs_writedata( 6); + when ENC_D_TIME_MEAS_STEP => + meas_step <= avs_writedata(meas_step'range); + when DIR_COUNT_THRES_REG => + pos_dir_thres <= avs_writedata(15 downto 0); + neg_dir_thres <= avs_writedata(31 downto 16); + when ENC_SAMPL_PER_REG => + sampling_period <= avs_writedata(sampling_period'range); + when ENC_FIFO_CS_REG => + fifo_thres <= avs_writedata(fifo_thres'range); + when PD_FIFO_CS_REG => + pd_fifo_thres <= avs_writedata(pd_fifo_thres'range); + pd_log_src <= avs_writedata(15); + when PD_WATCH_DOG_CTRL => + pd_wd_en <= avs_writedata( 0); + clr_pd_pos <= avs_writedata( 1); + when PD_WATCH_DOG_THRES => + pd_wd_thres <= avs_writedata; + when IRQ_MNG_REG => + irq_en <= avs_writedata( 2 downto 0); + irq_clr <= avs_writedata( 6 downto 4); + irq_mask <= avs_writedata(10 downto 8); + when others => null; + end case; + end if; + + -- Read Ctrl & Status registers + avs_read_i <= avs_read; + -- Read valid is delayed of an additional clock cycle to take into + -- account for the FIFO latency + avs_readdatavalid <= avs_read_i; + if(avs_read_i = '1') then + case avs_address is + when DIAG_INIT_REG => + avs_readdata <= X"000000" & b"0" & rst_pd_fifo_i & rst_pos_i & rst_fifo_i & rst_dir_i & rst_measur_i & rst_counters_i & init_i; + when DIAG_IN_STATUS_REG => + avs_readdata(input_status'range) <= input_status; + avs_readdata(31 downto input_status'length) <= (others => '0'); + when PHASE0_CNT_REG => + avs_readdata <= filt_phase0_cnt; + when PHASE1_CNT_REG => + avs_readdata <= filt_phase1_cnt; + when ZERO_PH_CNT_REG => + avs_readdata <= filt_zero_ph_cnt; + when PD_CNT_REG => + avs_readdata <= filt_prod_det_cnt; + when ENC_OUT_CNT_REG => + avs_readdata <= enc_out_cnt; + when PD_OUT_CNT_REG => + avs_readdata <= pd_out_cnt; + when FIRE_REQ_CNT_REG => + avs_readdata <= fire_req_cnt; + when ENC_D_TIME_REG => + avs_readdata <= enc_delta_time; + when ENC_DMIN_TIME_REG => + avs_readdata <= enc_delta_time_min; + when ENC_DMAX_TIME_REG => + avs_readdata <= enc_delta_time_max; + when ENC_D_TIME_PREV_REG => + avs_readdata <= enc_delta_time_prev; + when ENC_D_TIME_MEAS_STEP => + avs_readdata <= X"0000" & meas_step; + when POSITION_CNT_REG => + avs_readdata <= pos_cnt; + when DIR_COUNT_THRES_REG => + avs_readdata <= neg_dir_thres & pos_dir_thres; + when DIR_COUNT_REG => + avs_readdata <= dir_change_cnt & dir_cnt; + when ENC_SAMPL_PER_REG => + avs_readdata <= X"0" & sampling_period; + when ENC_FIFO_CS_REG => + avs_readdata <= fifo_error & b"00000" & fifo_usedw & b"000000" & fifo_thres; + when ENC_FIFO_OUT_REG => + avs_readdata <= fifo_q; + when PD_FIFO_CS_REG => + avs_readdata <= pd_fifo_error & b"0000000" & pd_fifo_usedw & pd_log_src & b"0000000" & pd_fifo_thres; + when PD_FIFO_OUT_REG => + avs_readdata <= pd_fifo_q; + when PD_WATCH_DOG_CTRL => + avs_readdata <= (0 => pd_wd_en, 1 => clr_pd_pos, 4 => pd_wd_alarm, others => '0'); + when PD_WATCH_DOG_THRES => + avs_readdata <= pd_wd_thres; + when IRQ_MNG_REG => + avs_readdata <= X"0000" & '0' & irq_val & '0' & irq_mask & '0' & irq_clr & '0' & irq_en; + when others => + avs_readdata <= X"BAD1BAD0"; + end case; + end if; + end if; + end process pCTRL_STATUS; + +end architecture rtl; diff --git a/generic_ip/fire_pulse_manager/5/src/test/fire_pulse_manager_5_tb.vhd b/generic_ip/fire_pulse_manager/5/src/test/fire_pulse_manager_5_tb.vhd new file mode 100644 index 0000000..1d1226f --- /dev/null +++ b/generic_ip/fire_pulse_manager/5/src/test/fire_pulse_manager_5_tb.vhd @@ -0,0 +1,719 @@ +------------------------------------------------------------------------------- +-- Title : fire_pulse_manager_tb +-- Project : fire_pulse_manager +------------------------------------------------------------------------------- +-- File : fire_pulse_manager_tb.vhd +-- Author : Christos Spirotis +-- Company : Global Inkjet Systems +-- Created : 2018-08-10 +-- Last update: 2019-12-16 +-- SVN ID : Git +-- Standard : VHDL'08 +------------------------------------------------------------------------------- +-- Description: +-- Testbench for fire pulse manager block +------------------------------------------------------------------------------- + +library modelsim_lib; +use modelsim_lib.util.all; +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; +use ieee.math_real.all; +use std.textio.all; +library work; +use work.fire_pulse_5_pkg.all; +use work.log_pkg.all; +use work.avalon_verify_pkg.all; +use work.pulse_generator_2_pkg.all; +use work.enc_pd_emul_1_pkg.CSR_ENC_NCO_INC_ADDR; +use work.enc_pd_emul_1_pkg.CSR_ENC_CTRL_ADDR; +use work.enc_pd_emul_1_pkg.CSR_PD_CTRL_ADDR; +use work.enc_pd_emul_1_pkg.CSR_OUT_ENABLE_ADDR; +use work.enc_pd_emul_1_pkg.CSR_PULSE_NUM_ADDR; + +library osvvm; +use osvvm.RandomPkg.all; + +entity fire_pulse_manager_5_tb is +end fire_pulse_manager_5_tb; + +architecture behav of fire_pulse_manager_5_tb is + + constant CH_NUM : integer := 4; + constant DEV_NUM : integer := 2; + + + constant CLK_PERIOD : time := 10.0 ns; + constant CLK_FREQ : real := 100.0e6; + + -- TODO Try different receive oversampling ratios - 300MHz is in the real system + constant RX_CLK_PERIOD : time := CLK_PERIOD / 3; -- clock period for used by the + -- UART-Rx on the POF + + constant POF_DELAY : time := 30 ns; -- Total delay from POF-Tx input to POF-Rx output + + constant NUM_ITERATIONS : natural := 5; + constant SWATHE_LEN : integer := 600; + constant START_DIR : std_logic := '0'; + constant TIME_INT : time := 5000 ns; + constant VERBOSITY_LEVEL : verb_level_t := VMEDIUM; + + type ch_offset_t is array (0 to CH_NUM - 1) of integer; + signal ch_offset : ch_offset_t := (100, 308, 316, 324); + + type avs_read_bus_t is array (0 to DEV_NUM - 1) of std_logic_vector(31 downto 0); + + signal reset_n : std_logic := '0'; + signal clk : std_logic := '0'; + signal rx_clk : std_logic := '0'; + signal pof_tx, pof_rx : std_logic; + signal ch_pulse_out : std_logic_vector(3 downto 0); + signal avs_address : std_logic_vector(14 downto 0); + signal avs_write : std_logic_vector(DEV_NUM - 1 downto 0); + signal avs_writedata : std_logic_vector(31 downto 0); + signal avs_read : std_logic_vector(DEV_NUM - 1 downto 0); + signal avs_waitrequest : std_logic_vector(DEV_NUM - 1 downto 0); + signal avs_readdata : avs_read_bus_t; + -- + signal init_tx : std_logic; + signal pd_in : std_logic; + signal pd_spy : std_logic; + signal inc_pos : std_logic; + signal dec_pos : std_logic; + signal abs_position : std_logic_vector(31 downto 0); + signal abs_spy : std_logic_vector(31 downto 0); + signal tx_data : std_logic; + signal pof_tx_avs_rv : std_logic; + signal pof_tx_avs_we_d : std_logic; + -- + signal abs_position_d : std_logic_vector(31 downto 0); + signal dir_in : std_logic; + signal swathe_cnt : integer; + signal swathe_pos : integer; + signal end_of_swathe : std_logic; + signal test_completed : boolean; + signal running : boolean; + signal configuring : boolean; + signal passed : boolean; + signal failed : boolean; + signal stimuli_completed : boolean; + signal detected_error : boolean := false; + signal registers_read : boolean := false; + signal reprogram_offset : boolean := false; + + -- + signal avs_m : mm_m_rec_t; + signal avs_s : mm_s_rec_t; + signal sel_slave_0 : std_logic; + signal sel_slave_1 : std_logic; + -- + type pd_cnt_t is array (0 to CH_NUM - 1) of integer; + signal pd_cnt : pd_cnt_t; + type fp_cnt_t is array (0 to CH_NUM - 1) of integer; + signal fp_cnt : fp_cnt_t; + + -- generate the NCO increment corresponding to a given output frequency + function freq2NCO_inc( + f_out : real; f_clk : real) return std_logic_vector is + variable nco_inc : std_logic_vector(31 downto 0); + + begin + nco_inc := std_logic_vector(to_unsigned(integer((f_out / f_clk) * (2.0**32)), 32)); + return nco_inc; + + end function freq2NCO_inc; + +begin -- behav + + clk_pr : process + begin + clk <= '0'; + wait for 0.5 * CLK_PERIOD; + clk <= '1'; + wait for 0.5 * CLK_PERIOD; + end process clk_pr; + + rx_clk_pr : process + begin + rx_clk <= '0'; + wait for 0.5 * RX_CLK_PERIOD; + rx_clk <= '1'; + wait for 0.5 * RX_CLK_PERIOD; + end process rx_clk_pr; + + ----------------------------------------------------------------------------- + -- DUTs : Fire Pulse Manager + ----------------------------------------------------------------------------- + + iDUT : entity work.fire_pulse_manager_5 + generic map( + CH_NUM => CH_NUM) + port map( + reset_n => reset_n, + clk => clk, + rx_clk => rx_clk, + pof_rx => pof_rx, + pof_tx => pof_tx, + fire_pulse => ch_pulse_out, + mon_pt => open, + ins_fpm_irq_0 => open, + ins_fpm_irq_1 => open, + ins_fpm_irq_2 => open, + ins_fpm_irq_3 => open, + avs_address => avs_address, + avs_write => avs_write(0), + avs_writedata => avs_writedata, + avs_read => avs_read(0), + avs_waitrequest => avs_waitrequest(0), + avs_readdata => avs_readdata(0) + ); + + pof_rx <= transport tx_data after POF_DELAY; + + ----------------------------------------------------------------------------- + -- POF Tx + ----------------------------------------------------------------------------- + + iPOF_TX : entity work.pof_tx_0 + port map( + reset_n => reset_n, + clk => clk, + init => init_tx, + pd_in => pd_in, + inc_pos => inc_pos, + dec_pos => dec_pos, + abs_position => abs_position, + tx_data => tx_data, + avs_address => avs_address(2 downto 0), + avs_write => avs_write(1), + avs_writedata => avs_writedata, + avs_read => avs_read(1), + avs_readdatavalid => pof_tx_avs_rv, + avs_readdata => avs_readdata(1)); + + -- Generate a dummy waitrequest for the POF-tx + pPOF_TX_DUMMY_WR : process(clk) + begin + if(clk = '1' and clk'event) then + pof_tx_avs_we_d <= avs_write(1); + end if; + end process pPOF_TX_DUMMY_WR; + + avs_waitrequest(1) <= '0' when pof_tx_avs_we_d = '1' or pof_tx_avs_rv = '1' else '0'; + + ----------------------------------------------------------------------------- + -- Stimuli Generation + ----------------------------------------------------------------------------- + + pSTIMULI_REGs : process(clk) + begin + if (clk = '1' and clk'event) then + abs_position_d <= abs_position; + end if; + end process pSTIMULI_REGs; + + inc_pos <= '1' when signed(abs_position) = signed(abs_position_d) + 1 else '0'; + dec_pos <= '1' when signed(abs_position) = signed(abs_position_d) - 1 else '0'; + + pSTIMULI : process + variable end_of_stimuli : boolean; + variable rv : RandomPType; + + begin + + -- initialization + init_tx <= '0'; + dir_in <= START_DIR; + pd_in <= '0'; + abs_position <= (others => '0'); + swathe_pos <= 0; + -- + swathe_cnt <= 0; + stimuli_completed <= false; + end_of_swathe <= '0'; + + -- generating the stimulus + wait until running = true; + wait for 200 ns; + -- Send a Init/Sync pulse + wait until clk = '1' and clk'event; + init_tx <= '1'; + wait until clk = '1' and clk'event; + init_tx <= '0'; + wait for 500 ns; + -- + -- generate the forward swathe + end_of_stimuli := false; + while end_of_stimuli = false loop + swathe_pos <= 0; + + for i in 0 to CH_NUM - 1 loop + ch_offset(i) <= rv.RandInt(0, 379); + end loop; + reprogram_offset <= true; + wait until configuring = true; + reprogram_offset <= false; + wait until configuring = false; + + wait until clk = '1' and clk'event; + + while swathe_pos /= SWATHE_LEN loop + wait until clk = '1' and clk'event; + --generate a position increment + swathe_pos <= swathe_pos + 1; + if (dir_in = '0') then + abs_position <= std_logic_vector(signed(abs_position) + 1); + else + abs_position <= std_logic_vector(signed(abs_position) - 1); + end if; + -- + if (swathe_pos = 16) then + -- generate a PD increment: the PD might be either concurren or not + -- to the position increment + wait for 0.5 * CLK_PERIOD; + pd_in <= '1'; + wait for 100 ns; + wait until clk = '1' and clk'event; + pd_in <= '0'; + end if; + wait for TIME_INT; + end loop; -- swathe_pos /= SWATHE_LEN + + wait for 25 us; + end_of_swathe <= '1'; + wait until clk = '1' and clk'event; + end_of_swathe <= '0'; + -- reverse direction + if (dir_in /= START_DIR) then + if (swathe_cnt = NUM_ITERATIONS - 1) then + end_of_stimuli := true; + else + swathe_cnt <= swathe_cnt + 1; + end if; + end if; + if (end_of_stimuli = false) then + wait until clk = '1' and clk'event; + dir_in <= not dir_in; + -- Wait some time to make sure the change of direction is transmitted. + -- Note: if the position starts changing before the receiver was able to + -- confirm the change of direction, then some encoder pulses may not be + -- generated + wait for 1 us; + wait until clk = '1' and clk'event; + end if; + end loop; -- end_of_stimuli = false + + stimuli_completed <= true; + wait; + + end process pSTIMULI; + + ----------------------------------------------------------------------------- + -- Testbench Control + ----------------------------------------------------------------------------- + + pTB_CTRL : process + type fp_arrived_t is array (0 to CH_NUM - 1) of boolean; + variable fp_arrived : fp_arrived_t; + type fp_arrived_time_t is array (0 to CH_NUM - 1) of integer; + variable fp_arrived_time : fp_arrived_time_t; + variable fp_arrived_agg : integer; + variable pd_arrived_time : integer; + + begin + -- init_signal_spy("/iDUT/abs_pos","abs_spy",0); + -- init_signal_spy("/iDUT/pd_pulse","pd_spy",0); + init_signal_spy("abs_position", "abs_spy", 0); + init_signal_spy("pd_in", "pd_spy", 0); + + -- Set the verbosity level for logging + set_log_verbosity(VERBOSITY_LEVEL); + set_log_verbosity(VHIGH); + + log_header("Multi-channel FPM verification:", VLOW); + + test_completed <= false; + running <= false; + passed <= false; + failed <= false; + + -- Reset + reset_n <= '0'; + wait for 100 ns; + wait until clk = '1' and clk'event; + reset_n <= '1'; + + if (configuring /= true) then + wait until configuring = true; + end if; + wait until configuring = false; + running <= true; + log("Running test ... ", VLOW, true); + + while stimuli_completed = false loop + wait until ((pd_spy = '1' and pd_spy'event) or stimuli_completed); + + if (stimuli_completed) then + exit; + end if; + + pd_arrived_time := to_integer(signed(abs_spy)); + for i in 0 to CH_NUM - 1 loop + fp_arrived(i) := false; + fp_arrived_time(i) := 0; + end loop; + log("Product detect fired @ " & integer'image(pd_arrived_time) & " ... ", VLOW, true); + fp_arrived_agg := 0; + while fp_arrived_agg < CH_NUM loop + fp_arrived_agg := 0; + for i in 0 to CH_NUM - 1 loop + if fp_arrived(i) = true then + fp_arrived_agg := fp_arrived_agg + 1; + end if; + end loop; + + wait until (unsigned(ch_pulse_out) /= 0 or stimuli_completed); + if (stimuli_completed) then + exit; + end if; + + for i in 0 to CH_NUM - 1 loop + if ch_pulse_out(i) = '1' and fp_arrived(i) = false then + fp_arrived(i) := true; + fp_arrived_time(i) := to_integer(signed(abs_spy)); + log("Channel CH" & integer'image(i) & " Fire pulse logged @ " & integer'image(fp_arrived_time(i)) & " ... ", VLOW, true); + if (abs (pd_arrived_time - fp_arrived_time(i)) /= ch_offset(i)) then + log("Channel CH" & integer'image(i) & " OFFSET INCORRECT !!! ", VLOW, true); + detected_error <= true; + end if; + end if; + end loop; + end loop; + end loop; + + if (stimuli_completed = true) then + -- wait enough time to make sure that a max length package can be propagated + wait for 20 us; + end if; + + if (registers_read = false) then + wait until registers_read = true; + end if; + + -- Report PD and FP counter from pulse generator + for i in 0 to CH_NUM - 1 loop + log("Channel CH" & integer'image(i) & " PDin counter value : " & integer'image(pd_cnt(i)) & " ... ", VLOW, true); + log("Channel CH" & integer'image(i) & " FPout counter value : " & integer'image(fp_cnt(i)) & " ... ", VLOW, true); + if (i = 0 and (pd_cnt(i) /= (NUM_ITERATIONS) * 2)) or + (i /= 0 and pd_cnt(i) /= 0) then -- fire_pulse_manager now has no registers beyond channel 0 + log("Channel CH" & integer'image(i) & " PD_cnt counter value Incorrect: ", VLOW, true); + detected_error <= true; + end if; + if (i = 0 and (fp_cnt(i) /= (NUM_ITERATIONS) * 2 * 100)) or + (i /= 0 and fp_cnt(i) /= 0) then + log("Channel CH" & integer'image(i) & " FP_cnt counter value Incorrect: ", VLOW, true); + detected_error <= true; + end if; + end loop; + + wait until clk = '1' and clk'event; + + if (detected_error = true) 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; + + pUUT_CTRL : process + 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 + sel_slave_0 <= '0'; + sel_slave_1 <= '0'; + configuring <= true; + + -- initilialize the Avalon master-bus + mm_m_init(avs_m, use_waitrequest => true); + + if (reset_n = '0') then + wait until reset_n = '1'; + wait for 100 ns; + wait until clk = '1' and clk'event; + end if; + + log("Configuring POFTX ... ", VLOW, true); + sel_slave_1 <= '1'; + -- Config netfork_tx control registers: + -- enable the block + addr := std_logic_vector(to_unsigned(0, 32)); + data := X"0000_0021"; + mm_32b_write(addr, data, avs_s, avs_m); + + sel_slave_1 <= '0'; + sel_slave_0 <= '1'; + wait until clk = '1' and clk'event; + + log("Configuring EMUL ... ", VLOW, true); + -- Configure Encoder NCO freq + addr := std_logic_vector(to_unsigned(6144 + to_integer(unsigned(CSR_ENC_NCO_INC_ADDR)), 32)); + data := freq2NCO_inc(200.0e3, CLK_FREQ); + -- Write the data to the register + mm_32b_write(addr, data, avs_s, avs_m); + -- Enable outputs + addr := std_logic_vector(to_unsigned(6144 + to_integer(unsigned(CSR_OUT_ENABLE_ADDR)), 32)); + data := X"000000FF"; + -- Write the data to the register + mm_32b_write(addr, data, avs_s, avs_m); + + log("Configuring FPM ... ", VLOW, true); + -- Config fire_pulse_manager control registers: + -- Enable the POF-Rx + addr := std_logic_vector(to_unsigned(3, 32)); + data := X"0000_8061"; -- set bit_div to 6 to match the 50MBd TX signal to the 300MHz RX_CLK + -- Write the data to the register + mm_32b_write(addr, data, avs_s, avs_m); + -- Select pulse generator + addr := std_logic_vector(to_unsigned(2, 32)); + data := X"0000_0001"; + -- Write the data to the register + mm_32b_write(addr, data, avs_s, avs_m); + -- Config external fire pulses + addr := std_logic_vector(to_unsigned(12, 32)); + data := X"0008_0004"; + -- Write the data to the register + mm_32b_write(addr, data, avs_s, avs_m); + + config_pg_l : for i in 0 to CH_NUM - 1 loop + -- Disable/Re-enable first the whole pulse_generator + addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(PULSE_GEN_CTRL_REG)), 32)); + data := (others => '0'); + mm_32b_write(addr, data, avs_s, avs_m); + data := (0 => '1', 16 => '1', others => '0'); + mm_32b_write(addr, data, avs_s, avs_m); + -- Disable/Re-enable the Channel Controller sequencer + addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(CH_CTRL_CTRL_REG)), 32)); + data := (others => '0'); + mm_32b_write(addr, data, avs_s, avs_m); + addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(CH_CTRL_CTRL_REG)), 32)); + data := (0 => '1', others => '0'); + mm_32b_write(addr, data, avs_s, avs_m); + -- set the sub-pixel offset + data := std_logic_vector(to_unsigned(0, 32)); + addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SP_OFFSET_INT)), 32)); + mm_32b_write(addr, data, avs_s, avs_m); + data := std_logic_vector(to_unsigned(0, 32)); + addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SP_OFFSET_FRAC)), 32)); + mm_32b_write(addr, data, avs_s, avs_m); + -- set the division ratio + ratio_int := integer(2.0 * 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(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(DIV_RATIO_INT)), 32)); + mm_32b_write(addr, data, avs_s, avs_m); + -- 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(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(DIV_RATIO_FRAC)), 32)); + mm_32b_write(addr, data, avs_s, avs_m); + -- Disable/Enable the fractional divider + addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(FRAC_DIV_CTRL_REG)), 32)); + data := (others => '0'); + mm_32b_write(addr, data, avs_s, avs_m); + data := (0 => '1', others => '0'); + mm_32b_write(addr, data, avs_s, avs_m); + -- Configure the Channel Offset (Both DIR_0 and DIR_1): + -- DIR_0 + addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(CH_OFFSET_D0_REG)), 32)); + data := std_logic_vector(to_unsigned(ch_offset(i), 32)); + mm_32b_write(addr, data, avs_s, avs_m); + -- DIR_1 + addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(CH_OFFSET_D1_REG)), 32)); + data := std_logic_vector(to_unsigned(ch_offset(i), 32)); + mm_32b_write(addr, data, avs_s, avs_m); + -- Configure the Channel Delay + addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(CH_DELAY_REG)), 32)); + data := std_logic_vector(to_unsigned(0, 32)); + mm_32b_write(addr, data, avs_s, avs_m); + + -- Fill Sequencer RAM with simple swathe DIR-0 + -- 0x00, 0x30000000 – Reset the vector output value + addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET)), 32)); + data := X"30000000"; + mm_32b_write(addr, data, avs_s, avs_m); + -- 0x01, 0x10000001 – Trigger Mask (PD trigger enabled) + addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET) + 1), 32)); + data := X"10000001"; + mm_32b_write(addr, data, avs_s, avs_m); + -- 0x02, 0x20000001 – Wait for a single PD event + addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET) + 2), 32)); + data := X"20000001"; + mm_32b_write(addr, data, avs_s, avs_m); + -- 0x03, 0x30006404 – Issue a request for starting the generation of 100 fire pulses (DIR-0) + addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET) + 3), 32)); + data := X"30006404"; + mm_32b_write(addr, data, avs_s, avs_m); + -- 0x04, 0x30006400 – De-assert the request bit (start_image_req) + addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET) + 4), 32)); + data := X"30006400"; + mm_32b_write(addr, data, avs_s, avs_m); + -- 0x05, 0x80000258 – Wait till POS END + addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET) + 5), 32)); + data := X"80000258"; + mm_32b_write(addr, data, avs_s, avs_m); + -- 0x06, 0xC0000000 – Jump to DIR-1 + addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET) + 6), 32)); + data := X"C0000010"; + mm_32b_write(addr, data, avs_s, avs_m); + + -- Fill Sequencer RAM with simple swathe DIR-1 + -- 0x10, 0x30000000 – Reset the vector output value + addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET) + 16), 32)); + data := X"30000001"; + mm_32b_write(addr, data, avs_s, avs_m); + -- 0x11, 0x10000001 – Trigger Mask (PD trigger enabled) + addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET) + 17), 32)); + data := X"10000001"; + mm_32b_write(addr, data, avs_s, avs_m); + -- 0x12, 0x20000001 – Wait for a single PD event + addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET) + 18), 32)); + data := X"20000001"; + mm_32b_write(addr, data, avs_s, avs_m); + -- 0x13, 0x30006405 – Issue a request for starting the generation of 100 fire pulses (DIR-1) + addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET) + 19), 32)); + data := X"30006405"; + mm_32b_write(addr, data, avs_s, avs_m); + -- 0x14, 0x30006401 – De-assert the request bit (start_image_req) + addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET) + 20), 32)); + data := X"30006401"; + mm_32b_write(addr, data, avs_s, avs_m); + -- 0x15, 0x80000000 – Wait till POS START + addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET) + 21), 32)); + data := X"80000000"; + mm_32b_write(addr, data, avs_s, avs_m); + -- 0x16, 0xC0000000 – Jump to DIR-0 + addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET) + 22), 32)); + data := X"C0000000"; + mm_32b_write(addr, data, avs_s, avs_m); + + -- Start Sequencer + addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_CSR_OFFSET) + 3), 32)); + data := (0 => '1', others => '0'); + mm_32b_write(addr, data, avs_s, avs_m); + end loop config_pg_l; + + -- Init the encoder NCO - Preset Abs-Pos + addr := std_logic_vector(to_unsigned(6144 + to_integer(unsigned(CSR_ENC_CTRL_ADDR)), 32)); + data := 32X"B"; + -- Write the data to the register + mm_32b_write(addr, data, avs_s, avs_m); + + log("Configuration completed.", VLOW, true); + configuring <= false; + + while stimuli_completed = false loop + wait until reprogram_offset = true or stimuli_completed = true; + if (stimuli_completed) then + exit; + end if; + + configuring <= true; + log("Reprogramming offset ... ", VLOW, true); + config_of_l : for i in 0 to CH_NUM - 1 loop + -- Configure the Channel Offset (Both DIR_0 and DIR_1): + -- DIR_0 + addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(CH_OFFSET_D0_REG)), 32)); + data := std_logic_vector(to_unsigned(ch_offset(i), 32)); + mm_32b_write(addr, data, avs_s, avs_m); + -- DIR_1 + addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(CH_OFFSET_D1_REG)), 32)); + data := std_logic_vector(to_unsigned(ch_offset(i), 32)); + mm_32b_write(addr, data, avs_s, avs_m); + end loop; + configuring <= false; + -- issue PD + addr := std_logic_vector(to_unsigned(6144 + to_integer(unsigned(CSR_PD_CTRL_ADDR)), 32)); + data := 32X"3"; + -- Write the data to the register + mm_32b_write(addr, data, avs_s, avs_m); + if dir_in = '0' then + log("Running 600 steps in DIR-0 ...", VLOW); + addr := std_logic_vector(to_unsigned(6144 + to_integer(unsigned(CSR_PULSE_NUM_ADDR)), 32)); + data := 32X"258"; + -- Write the data to the register + mm_32b_write(addr, data, avs_s, avs_m); + addr := std_logic_vector(to_unsigned(6144 + to_integer(unsigned(CSR_ENC_CTRL_ADDR)), 32)); + data := 32X"11"; + -- Write the data to the register + mm_32b_write(addr, data, avs_s, avs_m); + addr := std_logic_vector(to_unsigned(6144 + to_integer(unsigned(CSR_ENC_CTRL_ADDR)), 32)); + data := 32X"31"; + -- Write the data to the register + mm_32b_write(addr, data, avs_s, avs_m); + else + log("Running 600 steps in DIR-1 ...", VLOW); + addr := std_logic_vector(to_unsigned(6144 + to_integer(unsigned(CSR_PULSE_NUM_ADDR)), 32)); + data := 32X"258"; + -- Write the data to the register + mm_32b_write(addr, data, avs_s, avs_m); + addr := std_logic_vector(to_unsigned(6144 + to_integer(unsigned(CSR_ENC_CTRL_ADDR)), 32)); + data := 32X"15"; + -- Write the data to the register + mm_32b_write(addr, data, avs_s, avs_m); + addr := std_logic_vector(to_unsigned(6144 + to_integer(unsigned(CSR_ENC_CTRL_ADDR)), 32)); + data := 32X"35"; + -- Write the data to the register + mm_32b_write(addr, data, avs_s, avs_m); + end if; + end loop; + + -- Read PD and FP counter from pulse generator + for i in 0 to CH_NUM - 1 loop + addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(PD_IN_CNT_REG)), 32)); + mm_32b_read(addr, data, avs_s, avs_m); + pd_cnt(i) <= to_integer(unsigned(data)); + addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(FIRE_REQ_CNT_REG)), 32)); + mm_32b_read(addr, data, avs_s, avs_m); + fp_cnt(i) <= to_integer(unsigned(data)); + end loop; + + registers_read <= true; + + wait; + end process pUUT_CTRL; + + clk_clk <= clk; + reset_reset_n <= reset_n; + + avs_s.mm_readdata <= avs_readdata(0) when sel_slave_0 = '1' else + avs_readdata(1) when sel_slave_1 = '1' else (others => '0'); + + avs_s.mm_readdatavalid <= '0'; + + avs_s.mm_waitrequest <= avs_waitrequest(0) when sel_slave_0 = '1' else + avs_waitrequest(1) when sel_slave_1 = '1' else '0'; + + avs_s.use_readvalid <= false; + + avs_address <= avs_m.mm_address(avs_address'range); + avs_write(0) <= avs_m.mm_write and sel_slave_0; + avs_write(1) <= avs_m.mm_write and sel_slave_1; + avs_writedata <= avs_m.mm_writedata; + avs_read(0) <= avs_m.mm_read and sel_slave_0; + avs_read(1) <= avs_m.mm_read and sel_slave_1; + +end behav; + diff --git a/generic_ip/fire_pulse_manager/Readme.txt b/generic_ip/fire_pulse_manager/Readme.txt index 7f64a4c..a65bf78 100644 --- a/generic_ip/fire_pulse_manager/Readme.txt +++ b/generic_ip/fire_pulse_manager/Readme.txt @@ -10,4 +10,6 @@ Fire-Pulse-Manager major versions: - 4: Programmable Channel: different features can be programmed through VHDL generic: Number of channels, instantion of Diagnostic block, event logger, POF Protocol type, - additional logic for usage TOF Compensation, Pixel-Pitch correction \ No newline at end of file + additional logic for usage TOF Compensation, Pixel-Pitch correction + +- 5 FPM-5 fully replaces FPM-4. It Includes support for SEB-EPD => EMS block instantiated at place of POF-Rx block, based on the value of a VHDL generic. \ No newline at end of file From 813cc0e205cbb17755b277f7efc75498ed369dbb Mon Sep 17 00:00:00 2001 From: gianmarcogirau Date: Tue, 17 Dec 2019 09:16:43 +0000 Subject: [PATCH 02/15] CORE-73 - Added dp_dir output. All output are now buffered --- .../5/build/fire_pulse_manager_5_hw.tcl | 1 + .../5/src/fire_pulse_manager_5.vhd | 19 +++++++++---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/generic_ip/fire_pulse_manager/5/build/fire_pulse_manager_5_hw.tcl b/generic_ip/fire_pulse_manager/5/build/fire_pulse_manager_5_hw.tcl index ff96520..ead71c5 100644 --- a/generic_ip/fire_pulse_manager/5/build/fire_pulse_manager_5_hw.tcl +++ b/generic_ip/fire_pulse_manager/5/build/fire_pulse_manager_5_hw.tcl @@ -207,6 +207,7 @@ add_interface_port conduit_end pof_iso_en pof_iso_en Output 1 add_interface_port conduit_end fire_pulse fire_pulse Output 1 add_interface_port conduit_end abs_pos_out abs_pos_out Output 32 add_interface_port conduit_end print_start print_start Output 1 +add_interface_port conduit_end dp_dir_out dp_dir_out Output 1 add_interface_port conduit_end mon_pt mon_pt Output 4 diff --git a/generic_ip/fire_pulse_manager/5/src/fire_pulse_manager_5.vhd b/generic_ip/fire_pulse_manager/5/src/fire_pulse_manager_5.vhd index 44c4d72..014ddb6 100644 --- a/generic_ip/fire_pulse_manager/5/src/fire_pulse_manager_5.vhd +++ b/generic_ip/fire_pulse_manager/5/src/fire_pulse_manager_5.vhd @@ -6,7 +6,7 @@ -- Author : Gianmarco Girau -- Company : Global Inkjet Systems -- Created : 2017-09-06 --- Last update: 2019-12-16 +-- Last update: 2019-12-17 -- SVN ID : Git -- Standard : VHDL'08 ------------------------------------------------------------------------------- @@ -44,6 +44,7 @@ entity fire_pulse_manager_5 is pof_iso_en : out std_logic; fire_pulse : out std_logic_vector(ch_num - 1 downto 0); start_of_image : out std_logic_vector(ch_num - 1 downto 0); + dp_dir_out : out std_logic_vector(ch_num - 1 downto 0); abs_pos_out : out std_logic_vector(31 downto 0); print_start : out std_logic; mon_pt : out std_logic_vector(3 downto 0); -- Monitoring Points @@ -265,23 +266,25 @@ begin -- Output multiplexer fire_pulse_i <= ch_pulse_out when src_sel(0) = '1' else (others => pof_rx_regen); - fire_pulse <= fire_pulse_i; -- The start-of-image for zero-gap is available only when fire-request are -- generated locally, through the pulse-generator start_of_image_i <= ch_start_of_image when src_sel(0) = '1' else (others => '0'); - start_of_image <= start_of_image_i; pd_pulse <= pd_pulse_pof when src_sel(1) = '0' else pd_pulse_ie; abs_pos <= abs_pos_pof when src_sel(1) = '0' else abs_pos_ie(31 downto 0); inc_pos <= inc_pos_pof when src_sel(1) = '0' else inc_pos_ie; dec_pos <= dec_pos_pof when src_sel(1) = '0' else dec_pos_ie; - pBUF_ABS_POS : process(clk) + pBUF_OUT : process(clk) begin if(clk = '1' and clk'event) then - abs_pos_out <= abs_pos; + abs_pos_out <= abs_pos; + dp_dir_out <= dp_dir; + fire_pulse <= fire_pulse_i; + start_of_image <= start_of_image_i; + print_start <= print_start_i; end if; - end process pBUF_ABS_POS; + end process pBUF_OUT; pINIT_GEN : process(clk) begin @@ -417,8 +420,6 @@ begin uart_rx => pof_rx, uart_tx => pof_tx); - print_start <= print_start_i; - print_start_i <= '0'; elsif POF_PROT_VER = 1 generate @@ -449,8 +450,6 @@ begin parity_err_cnt => parity_err_cnt, skip_pos_cnt => skip_pos_cnt); - print_start <= print_start_i; - -- UART signal regeneration iUART_REGEN : entity work.pof_uart_regen_1 generic map( From 59c64ba466e79615919e2dd81959b80bfc28b335 Mon Sep 17 00:00:00 2001 From: gianmarcogirau Date: Tue, 17 Dec 2019 10:55:00 +0000 Subject: [PATCH 03/15] CORE-73 - Imported EMS block from the SMB repository --- generic_ip/ems/0/doc/ems_0.json | 370 ++++++ generic_ip/ems/0/sim/sim_ems.do | 75 ++ generic_ip/ems/0/sim/wave_ems.do | 380 ++++++ generic_ip/ems/0/src/ems_0.vhd | 589 +++++++++ generic_ip/ems/0/src/ems_0_pkg.vhd | 41 + generic_ip/ems/0/src/test/ems_0_tb.vhd | 1689 ++++++++++++++++++++++++ 6 files changed, 3144 insertions(+) create mode 100644 generic_ip/ems/0/doc/ems_0.json create mode 100644 generic_ip/ems/0/sim/sim_ems.do create mode 100644 generic_ip/ems/0/sim/wave_ems.do create mode 100644 generic_ip/ems/0/src/ems_0.vhd create mode 100644 generic_ip/ems/0/src/ems_0_pkg.vhd create mode 100644 generic_ip/ems/0/src/test/ems_0_tb.vhd diff --git a/generic_ip/ems/0/doc/ems_0.json b/generic_ip/ems/0/doc/ems_0.json new file mode 100644 index 0000000..2e4b900 --- /dev/null +++ b/generic_ip/ems/0/doc/ems_0.json @@ -0,0 +1,370 @@ +[{ + "ip_name": "ems_0", + "bus": "csr", + "description": "Encoder Management System", + "registers": { + "ip_id" : { + "address" : "0", + "width" : "32", + "description" : "Unique ID for this IP block", + "fields": { + "ip_number" : { + "type" : "c", + "bit_len" : "8", + "reset" : "0x1F", + "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" : "0x01", + "description" : "Minor number" + }, + "major_number" : { + "type" : "c", + "bit_len" : "8", + "reset" : "0x00", + "description" : "Major number" + + }, + "reserved" : { + "type" : "rsv", + "bit_len" : "16", + "description" : "Reserved bits" + } + } + }, + "ems_enable" : { + "address" : "0", + "width" : "4", + "description" : "EMS Enable", + "fields": { + "init" : { + "type" : "w", + "bit_len" : "1", + "reset" : "0x0", + "description" : "EMS init" + }, + "ems_enable" : { + "type" : "w", + "bit_len" : "1", + "reset" : "0x0", + "description" : "EMS enable" + }, + "enc_enable" : { + "type" : "w", + "bit_len" : "1", + "reset" : "0x0", + "description" : "Encoder enable" + }, + "pd_enable" : { + "type" : "w", + "bit_len" : "1", + "reset" : "0x0", + "description" : "PD enable" + } + } + }, + "ems_config" : { + "address" : "1", + "width" : "13", + "description" : "EMS configuration", + "fields": { + "enc_sel" : { + "type" : "w", + "bit_len" : "2", + "reset" : "0x0", + "description" : "Encoder source selection" + }, + "pd_sel" : { + "type" : "w", + "bit_len" : "3", + "reset" : "0x0", + "description" : "PD source selection" + }, + "enc_ph1_en" : { + "type" : "w", + "bit_len" : "1", + "reset" : "0x0", + "description" : "Encoder phase-1 enable" + }, + "enc_ph2_en" : { + "type" : "w", + "bit_len" : "1", + "reset" : "0x0", + "description" : "Encoder phase-2 enable" + }, + "enc_rising_en" : { + "type" : "w", + "bit_len" : "1", + "reset" : "0x0", + "description" : "Enables encoder events on rising edges" + }, + "enc_falling_en" : { + "type" : "w", + "bit_len" : "1", + "reset" : "0x0", + "description" : "Enables encoder events on falling edges" + }, + "pd_rising_en" : { + "type" : "w", + "bit_len" : "1", + "reset" : "0x0", + "description" : "Enables PD events on rising edges" + }, + "pd_falling_en" : { + "type" : "w", + "bit_len" : "1", + "reset" : "0x0", + "description" : "Enables PD events on falling edges" + }, + "set_abs_pos" : { + "type" : "w0", + "bit_len" : "1", + "reset" : "0x0", + "description" : "Preset the value of the absolute position" + }, + "switch_pos_neg_inc" : { + "type" : "w", + "bit_len" : "1", + "reset" : "0x0", + "description" : "When enabled, positive and negative increments of the absolute position are switched, achieving the same effect of switching encoder phase-1 and phase-2. " + } + } + }, + "pd_hyst" : { + "address" : "2", + "width" : "17", + "description" : "PD hysteresis control", + "fields": { + "pd_hyst_val" : { + "type" : "w", + "bit_len" : "16", + "reset" : "0x20", + "description" : "Enable rising-edge events on source 0" + }, + "clr_pd_hyst" : { + "type" : "w", + "bit_len" : "1", + "reset" : "0x0", + "description" : "clears the PD hysteresis filter" + } + } + }, + "sw_ctrl": { + "address": "3", + "width": "6", + "description": "software controls", + "fields": { + "sw_pd": { + "type": "w0", + "bit_len": "1", + "reset": "0x0", + "description": "Generates a SW PD event" + }, + "kickstart_pd" : { + "type": "w0", + "bit_len": "1", + "reset": "0x0", + "description": "Generates a kickstart PD event" + }, + "reserved" : { + "type" : "rsv", + "bit_len" : "2", + "description" : "Reserved bits" + }, + "sw_pos_step": { + "type": "w0", + "bit_len": "1", + "reset": "0x0", + "description": "single SW increment for the absolute position" + }, + "sw_neg_step": { + "type": "w0", + "bit_len": "1", + "reset": "0x0", + "description": "single SW decrement for the absolute position" + } + } + }, + "enc_divide": { + "type": "w", + "address": "4", + "reset": "0x0", + "width": "4", + "description": "division factor for the encoder increments/decrements" + }, + "abs_pos_init": { + "type": "w", + "address": "5", + "reset": "0x0", + "width": "32", + "subtype": "signed", + "description": "value fetched into the absolute-position when the preset ctrl bit is asserted" + }, + "abs_pos_val": { + "type": "r", + "address": "6", + "reset": "0x0", + "width": "32", + "subtype": "signed", + "description": "Current value of the absolute-position (With/Without Encoder Multiplier)" + }, + "pd_counters": { + "address": "7", + "width": "32", + "description": "PD counters", + "fields": { + "total_pd_cnt": { + "type": "r", + "bit_len": "16", + "reset": "0x0", + "description": "Total number of PD events" + }, + "hw_pd_cnt": { + "type": "r", + "bit_len": "16", + "reset": "0x0", + "description": "Number of hardware PD events" + } + } + }, + "filter_cfg": { + "address": "8", + "width": "20", + "description": "input filters configuration", + "fields": { + "filter_order": { + "type": "w", + "bit_len": "5", + "reset": "0x0", + "description": "filter order" + }, + "Reserved-0" : { + "type" : "rsv", + "bit_len" : "3", + "description" : "Reserved bits" + }, + "filter_hyst": { + "type": "w", + "bit_len": "5", + "reset": "0x0", + "description": "filter hysteresis" + }, + "Reserved-1" : { + "type" : "rsv", + "bit_len" : "3", + "description" : "Reserved bits" + }, + "ld_filt_cfg_pd": { + "type": "w0", + "bit_len": "1", + "reset": "0x0", + "description": "applies the specified configuration to the PD filter" + }, + "ld_filt_cfg_p1": { + "type": "w0", + "bit_len": "1", + "reset": "0x0", + "description": "applies the specified configuration to the Encoder-Phase-1 filter" + }, + "ld_filt_cfg_p2": { + "type": "w0", + "bit_len": "1", + "reset": "0x0", + "description": "applies the specified configuration to the Encoder-Phase-2 filter" + }, + "ld_filt_cfg_zp": { + "type": "w0", + "bit_len": "1", + "reset": "0x0", + "description": "applies the specified configuration to the Encoder-Zero-Phase filter" + } + } + }, + "enc_mult_cfg": { + "address": "9", + "width": "15", + "description": "Encoder Multiplier Configuration", + "fields": { + "use_multiplier": { + "type": "w", + "bit_len": "1", + "reset": "0x0", + "description": "Use Encoder Multiplier" + }, + "Reserved-1" : { + "type" : "rsv", + "bit_len" : "3", + "description" : "Reserved bits" + }, + "mult_sel": { + "type": "w", + "bit_len": "3", + "reset": "0x0", + "description": "Encoder Multiplication selection {0-7}: log2(Mult-Value), 0 => Mult=1, 1 => Mult=2, 7 => Mult=128" + }, + "Reserved-2" : { + "type" : "rsv", + "bit_len" : "1", + "description" : "Reserved bits" + }, + "vel_avg_steps": { + "type": "w", + "bit_len": "7", + "reset": "0x8", + "description": "Number of consecutive encoder steps used for generating the average velocity (must be an even number, max is 64)" + } + } + }, + "delta_t_init": { + "type": "w", + "address": "10", + "reset": "0x19", + "width": "28", + "description": "Set this constant to 25 for Encoder Mult values less or equal than 8, otherwise set to 2*Mult-Value" + }, + "vel_timeout": { + "type": "w", + "address": "11", + "reset": "0x1388", + "width": "28", + "description": "Velocity estimation time-out period" + }, + "abs_pos_in_stat": { + "type": "r", + "address": "12", + "reset": "0x0", + "width": "32", + "subtype": "signed", + "description": "Debug - Current value of the Absolute Position, without Encoder Multiplier" + }, + "abs_pos_vel_stat": { + "type": "r", + "address": "13", + "reset": "0x0", + "width": "32", + "subtype": "signed", + "description": "Debug - Current value of the Absolute Position, after the encoder velocity estimation block" + } + } +}] \ No newline at end of file diff --git a/generic_ip/ems/0/sim/sim_ems.do b/generic_ip/ems/0/sim/sim_ems.do new file mode 100644 index 0000000..7355b1d --- /dev/null +++ b/generic_ip/ems/0/sim/sim_ems.do @@ -0,0 +1,75 @@ +# Simulation macro + +# Cleanup libraries +foreach lib [list work OSVVM] { + file delete -force -- $lib + vlib $lib +} + +#.main clear + +set COMMON_PATH ../../../common/0/src +set ENC_MULT ../../../encoder_multiply/0/src +set EMS_SRC ../src +set GEN_SEQ ../../../generic_sequencer/15/src +set EMUL ../../../enc_pd_emul/1/src +set OSVVM_PATH $COMMON_PATH/test/OSVVM + +set WORKLIB work + +vlib ./work +vmap work ./work + +# Compile the UUT +vcom -2008 -work $WORKLIB $COMMON_PATH/common_pkg.vhd +vcom -2008 -work $WORKLIB $COMMON_PATH/digital_lpf.vhd +vcom -2008 -work $WORKLIB $COMMON_PATH/dpram_sclk.vhd +vcom -2008 -work $WORKLIB $ENC_MULT/lut_divider_0.vhd +vcom -2008 -work $WORKLIB $ENC_MULT/encoder_speed_detect_0.vhd +vcom -2008 -work $WORKLIB $ENC_MULT/encoder_multiply_0.vhd +vcom -2008 -work $WORKLIB $EMS_SRC/ems_0_pkg.vhd +vcom -2008 -work $WORKLIB $EMS_SRC/ems_0.vhd + + +# 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 support files +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 + +# Add the encoder/PD emulator +vcom -2008 -work $WORKLIB $GEN_SEQ/altera/generic_seq_ram_15.vhd +vcom -2008 -work $WORKLIB $GEN_SEQ/generic_sequencer_15_pkg.vhd +vcom -2008 -work $WORKLIB $GEN_SEQ/generic_sequencer_15.vhd +vcom -2008 -work $WORKLIB $EMUL/enc_pd_emul_1_pkg.vhd +vcom -2008 -work $WORKLIB $EMUL/enc_pd_emul_1.vhd + +# Compile the testbench +vcom -2008 -work $WORKLIB ./../src/test/ems_0_tb.vhd + +vsim -t ps work.ems_0_tb + + +#add wave /ems_0_tb/* +#add wave /ems_0_tb/iEMS/* +#add wave /ems_0_tb/iEMUL/* + +# remove warnings from standard numeric/arithmetic packages (speed-up simulation) +set StdArithNoWarnings 1 +set NumericStdNoWarnings 1 + +do wave_ems.do + +when -label end_of_simulation {test_completed == true} {echo "Simulation Completed"; stop ;} +run -all + +#run 200 us; \ No newline at end of file diff --git a/generic_ip/ems/0/sim/wave_ems.do b/generic_ip/ems/0/sim/wave_ems.do new file mode 100644 index 0000000..22ff36f --- /dev/null +++ b/generic_ip/ems/0/sim/wave_ems.do @@ -0,0 +1,380 @@ +onerror {resume} +quietly WaveActivateNextPane {} 0 +add wave -noupdate ems_0_tb/reset_n +add wave -noupdate ems_0_tb/clk +add wave -noupdate ems_0_tb/mask_npn +add wave -noupdate ems_0_tb/mask_pnp +add wave -noupdate ems_0_tb/ttl_pd +add wave -noupdate ems_0_tb/ttl_pd_npn +add wave -noupdate ems_0_tb/ttl_pd_pnp +add wave -noupdate ems_0_tb/ttl_enc_p1 +add wave -noupdate ems_0_tb/ttl_enc_p2 +add wave -noupdate ems_0_tb/ttl_enc_zp +add wave -noupdate ems_0_tb/rs422_pd +add wave -noupdate ems_0_tb/rs422_enc_p1 +add wave -noupdate ems_0_tb/rs422_enc_p2 +add wave -noupdate ems_0_tb/rs422_enc_zp +add wave -noupdate ems_0_tb/pd_out +add wave -noupdate ems_0_tb/set_pos +add wave -noupdate ems_0_tb/inc_pos +add wave -noupdate ems_0_tb/dec_pos +add wave -noupdate ems_0_tb/filt_p1 +add wave -noupdate ems_0_tb/filt_p2 +add wave -noupdate ems_0_tb/filt_zp +add wave -noupdate ems_0_tb/filt_pd +add wave -noupdate -radix decimal ems_0_tb/abs_position +add wave -noupdate -radix decimal ems_0_tb/avs_address +add wave -noupdate ems_0_tb/avs_write +add wave -noupdate -radix hexadecimal ems_0_tb/avs_writedata +add wave -noupdate ems_0_tb/avs_read +add wave -noupdate ems_0_tb/avs_readdatavalid +add wave -noupdate -radix hexadecimal ems_0_tb/avs_readdata +add wave -noupdate ems_0_tb/ems_address +add wave -noupdate ems_0_tb/ems_write +add wave -noupdate -radix hexadecimal ems_0_tb/ems_writedata +add wave -noupdate ems_0_tb/ems_read +add wave -noupdate ems_0_tb/ems_readdatavalid +add wave -noupdate -radix hexadecimal ems_0_tb/ems_readdata +add wave -noupdate ems_0_tb/init +add wave -noupdate ems_0_tb/setup +add wave -noupdate ems_0_tb/running +add wave -noupdate ems_0_tb/passed +add wave -noupdate ems_0_tb/failed +add wave -noupdate ems_0_tb/test_timeout +add wave -noupdate ems_0_tb/test_completed +add wave -noupdate ems_0_tb/error_flag +add wave -noupdate ems_0_tb/avs_mm_s_rec +add wave -noupdate ems_0_tb/avs_mm_m_rec +add wave -noupdate ems_0_tb/ems_mm_s_rec +add wave -noupdate ems_0_tb/ems_mm_m_rec +add wave -noupdate -divider EMS +add wave -noupdate ems_0_tb/iEMS/clk +add wave -noupdate ems_0_tb/iEMS/reset_n +add wave -noupdate ems_0_tb/iEMS/init +add wave -noupdate ems_0_tb/iEMS/avs_address +add wave -noupdate ems_0_tb/iEMS/avs_write +add wave -noupdate -radix hexadecimal ems_0_tb/iEMS/avs_writedata +add wave -noupdate ems_0_tb/iEMS/avs_read +add wave -noupdate ems_0_tb/iEMS/avs_readdatavalid +add wave -noupdate ems_0_tb/iEMS/avs_readdata +add wave -noupdate ems_0_tb/iEMS/rs422_pd +add wave -noupdate ems_0_tb/iEMS/rs422_p1 +add wave -noupdate ems_0_tb/iEMS/rs422_p2 +add wave -noupdate ems_0_tb/iEMS/rs422_zp +add wave -noupdate ems_0_tb/iEMS/ttl_pd +add wave -noupdate ems_0_tb/iEMS/ttl_pd_npn +add wave -noupdate ems_0_tb/iEMS/ttl_p1 +add wave -noupdate ems_0_tb/iEMS/ttl_p2 +add wave -noupdate ems_0_tb/iEMS/ttl_zp +add wave -noupdate -radix decimal ems_0_tb/iEMS/abs_position +add wave -noupdate ems_0_tb/iEMS/pd_out +add wave -noupdate ems_0_tb/iEMS/set_pos +add wave -noupdate ems_0_tb/iEMS/inc_pos +add wave -noupdate ems_0_tb/iEMS/dec_pos +add wave -noupdate ems_0_tb/iEMS/filt_p1 +add wave -noupdate ems_0_tb/iEMS/filt_p2 +add wave -noupdate ems_0_tb/iEMS/filt_zp +add wave -noupdate ems_0_tb/iEMS/filt_pd +add wave -noupdate ems_0_tb/iEMS/init_i +add wave -noupdate ems_0_tb/iEMS/ttl_pd_i +add wave -noupdate ems_0_tb/iEMS/sel_ttl_npn +add wave -noupdate ems_0_tb/iEMS/pd_mux +add wave -noupdate ems_0_tb/iEMS/p1_mux +add wave -noupdate ems_0_tb/iEMS/p2_mux +add wave -noupdate ems_0_tb/iEMS/zp_mux +add wave -noupdate ems_0_tb/iEMS/ems_init +add wave -noupdate ems_0_tb/iEMS/pd_i +add wave -noupdate ems_0_tb/iEMS/pd_re +add wave -noupdate ems_0_tb/iEMS/pd_fe +add wave -noupdate ems_0_tb/iEMS/p1_i +add wave -noupdate ems_0_tb/iEMS/p1_re +add wave -noupdate ems_0_tb/iEMS/p1_fe +add wave -noupdate ems_0_tb/iEMS/p2_i +add wave -noupdate ems_0_tb/iEMS/p2_re +add wave -noupdate ems_0_tb/iEMS/p2_fe +add wave -noupdate ems_0_tb/iEMS/zp_i +add wave -noupdate ems_0_tb/iEMS/p1_re_i +add wave -noupdate ems_0_tb/iEMS/p1_fe_i +add wave -noupdate ems_0_tb/iEMS/p2_re_i +add wave -noupdate ems_0_tb/iEMS/p2_fe_i +add wave -noupdate ems_0_tb/iEMS/enc_ph1_en +add wave -noupdate ems_0_tb/iEMS/enc_ph2_en +add wave -noupdate ems_0_tb/iEMS/enc_rising_en +add wave -noupdate ems_0_tb/iEMS/enc_falling_en +add wave -noupdate ems_0_tb/iEMS/step_pos_i +add wave -noupdate ems_0_tb/iEMS/step_neg_i +add wave -noupdate ems_0_tb/iEMS/step_pos +add wave -noupdate ems_0_tb/iEMS/step_neg +add wave -noupdate ems_0_tb/iEMS/set_pos_i +add wave -noupdate ems_0_tb/iEMS/set_abs_pos +add wave -noupdate ems_0_tb/iEMS/wrap_pos +add wave -noupdate ems_0_tb/iEMS/wrap_neg +add wave -noupdate ems_0_tb/iEMS/inc_pos_i +add wave -noupdate ems_0_tb/iEMS/dec_pos_i +add wave -noupdate ems_0_tb/iEMS/step_pos_ii +add wave -noupdate ems_0_tb/iEMS/step_neg_ii +add wave -noupdate ems_0_tb/iEMS/wrap_pos_i +add wave -noupdate ems_0_tb/iEMS/wrap_neg_i +add wave -noupdate ems_0_tb/iEMS/use_multiplier +add wave -noupdate ems_0_tb/iEMS/m_step_pos +add wave -noupdate ems_0_tb/iEMS/m_step_neg +add wave -noupdate ems_0_tb/iEMS/step_pos_retimed +add wave -noupdate ems_0_tb/iEMS/step_neg_retimed +add wave -noupdate ems_0_tb/iEMS/init_mult +add wave -noupdate ems_0_tb/iEMS/enable_mult +add wave -noupdate ems_0_tb/iEMS/mult_sel +add wave -noupdate ems_0_tb/iEMS/avg_steps +add wave -noupdate ems_0_tb/iEMS/delta_init +add wave -noupdate ems_0_tb/iEMS/time_out +add wave -noupdate ems_0_tb/iEMS/delta_t +add wave -noupdate ems_0_tb/iEMS/ems_enable +add wave -noupdate ems_0_tb/iEMS/pd_hyst_filt +add wave -noupdate ems_0_tb/iEMS/set_pd_hyst_filt +add wave -noupdate ems_0_tb/iEMS/pd_event +add wave -noupdate ems_0_tb/iEMS/clr_pd_hyst_filt +add wave -noupdate ems_0_tb/iEMS/sw_pos_step +add wave -noupdate ems_0_tb/iEMS/sw_neg_step +add wave -noupdate ems_0_tb/iEMS/pd_rising_en +add wave -noupdate ems_0_tb/iEMS/pd_falling_en +add wave -noupdate ems_0_tb/iEMS/sw_pd +add wave -noupdate ems_0_tb/iEMS/pd +add wave -noupdate ems_0_tb/iEMS/kickstart_pd +add wave -noupdate ems_0_tb/iEMS/enc_sel +add wave -noupdate ems_0_tb/iEMS/pd_sel +add wave -noupdate -radix unsigned ems_0_tb/iEMS/enc_cnt +add wave -noupdate ems_0_tb/iEMS/enc_divide +add wave -noupdate ems_0_tb/iEMS/pd_hyst_val +add wave -noupdate ems_0_tb/iEMS/pd_hyst_pos_cnt +add wave -noupdate ems_0_tb/iEMS/pd_hyst_neg_cnt +add wave -noupdate ems_0_tb/iEMS/hw_pd_cnt +add wave -noupdate ems_0_tb/iEMS/total_pd_cnt +add wave -noupdate ems_0_tb/iEMS/abs_pos_i +add wave -noupdate ems_0_tb/iEMS/abs_pos_init +add wave -noupdate ems_0_tb/iEMS/iP1_FILT/clk +add wave -noupdate ems_0_tb/iEMS/iP1_FILT/reset_n +add wave -noupdate ems_0_tb/iEMS/iP1_FILT/ld_cfg +add wave -noupdate ems_0_tb/iEMS/iP1_FILT/filt_order +add wave -noupdate ems_0_tb/iEMS/iP1_FILT/hyst +add wave -noupdate ems_0_tb/iEMS/iP1_FILT/filt_in +add wave -noupdate ems_0_tb/iEMS/iP1_FILT/filt_out +add wave -noupdate ems_0_tb/iEMS/iP1_FILT/rEdge +add wave -noupdate ems_0_tb/iEMS/iP1_FILT/fEdge +add wave -noupdate ems_0_tb/iEMS/iP1_FILT/sig_ii +add wave -noupdate ems_0_tb/iEMS/iP1_FILT/sig_i +add wave -noupdate ems_0_tb/iEMS/iP1_FILT/sig +add wave -noupdate -radix unsigned ems_0_tb/iEMS/iP1_FILT/filt_order_i +add wave -noupdate -radix unsigned ems_0_tb/iEMS/iP1_FILT/cnt_ones +add wave -noupdate ems_0_tb/iEMS/iP1_FILT/hyst_i +add wave -noupdate ems_0_tb/iEMS/iP1_FILT/delay_line +add wave -noupdate -divider EMUL +add wave -noupdate ems_0_tb/iEMUL/clk +add wave -noupdate ems_0_tb/iEMUL/reset_n +add wave -noupdate ems_0_tb/iEMUL/ttl_pd +add wave -noupdate ems_0_tb/iEMUL/ttl_enc_p1 +add wave -noupdate ems_0_tb/iEMUL/ttl_enc_p2 +add wave -noupdate ems_0_tb/iEMUL/ttl_enc_zp +add wave -noupdate ems_0_tb/iEMUL/rs422_pd +add wave -noupdate ems_0_tb/iEMUL/rs422_enc_p1 +add wave -noupdate ems_0_tb/iEMUL/rs422_enc_p2 +add wave -noupdate ems_0_tb/iEMUL/rs422_enc_zp +add wave -noupdate -radix decimal ems_0_tb/iEMUL/abs_pos_out +add wave -noupdate ems_0_tb/iEMUL/set_pos_out +add wave -noupdate ems_0_tb/iEMUL/inc_pos_out +add wave -noupdate ems_0_tb/iEMUL/dec_pos_out +add wave -noupdate ems_0_tb/iEMUL/avs_address +add wave -noupdate ems_0_tb/iEMUL/avs_write +add wave -noupdate ems_0_tb/iEMUL/avs_writedata +add wave -noupdate ems_0_tb/iEMUL/avs_read +add wave -noupdate ems_0_tb/iEMUL/avs_readdatavalid +add wave -noupdate ems_0_tb/iEMUL/avs_readdata +add wave -noupdate ems_0_tb/iEMUL/enc_init +add wave -noupdate ems_0_tb/iEMUL/nco_inc_en +add wave -noupdate ems_0_tb/iEMUL/enc_dir +add wave -noupdate ems_0_tb/iEMUL/enc_p1 +add wave -noupdate ems_0_tb/iEMUL/enc_p2 +add wave -noupdate ems_0_tb/iEMUL/enc_p1_d +add wave -noupdate ems_0_tb/iEMUL/enc_p2_d +add wave -noupdate ems_0_tb/iEMUL/pulse_cnt_inc +add wave -noupdate ems_0_tb/iEMUL/pulse_cnt_inc_d +add wave -noupdate ems_0_tb/iEMUL/max_pulses_start +add wave -noupdate ems_0_tb/iEMUL/avs_read_d +add wave -noupdate ems_0_tb/iEMUL/max_pulses_en +add wave -noupdate ems_0_tb/iEMUL/pulse_cnt_start +add wave -noupdate ems_0_tb/iEMUL/pulse_cnt_stop +add wave -noupdate ems_0_tb/iEMUL/max_pulses_done +add wave -noupdate ems_0_tb/iEMUL/zero_phase +add wave -noupdate ems_0_tb/iEMUL/pulse_cnt_running +add wave -noupdate ems_0_tb/iEMUL/ttl_pd_en +add wave -noupdate ems_0_tb/iEMUL/ttl_enc_p1_en +add wave -noupdate ems_0_tb/iEMUL/ttl_enc_p2_en +add wave -noupdate ems_0_tb/iEMUL/ttl_enc_zp_en +add wave -noupdate ems_0_tb/iEMUL/rs422_pd_en +add wave -noupdate ems_0_tb/iEMUL/enc_zp +add wave -noupdate ems_0_tb/iEMUL/ttl_pd_fh +add wave -noupdate ems_0_tb/iEMUL/ttl_enc_p1_fh +add wave -noupdate ems_0_tb/iEMUL/ttl_enc_p2_fh +add wave -noupdate ems_0_tb/iEMUL/ttl_enc_zp_fh +add wave -noupdate ems_0_tb/iEMUL/rs422_pd_fh +add wave -noupdate ems_0_tb/iEMUL/rs422_enc_p1_fh +add wave -noupdate ems_0_tb/iEMUL/rs422_enc_p2_fh +add wave -noupdate ems_0_tb/iEMUL/rs422_enc_zp_fh +add wave -noupdate ems_0_tb/iEMUL/rs422_enc_p1_en +add wave -noupdate ems_0_tb/iEMUL/rs422_enc_p2_en +add wave -noupdate ems_0_tb/iEMUL/rs422_enc_zp_en +add wave -noupdate ems_0_tb/iEMUL/enc_emul_en +add wave -noupdate ems_0_tb/iEMUL/inc_pos +add wave -noupdate ems_0_tb/iEMUL/dec_pos +add wave -noupdate ems_0_tb/iEMUL/set_abs_pos +add wave -noupdate ems_0_tb/iEMUL/avs_write_i +add wave -noupdate ems_0_tb/iEMUL/seq_ram_write +add wave -noupdate ems_0_tb/iEMUL/seq_csr_write +add wave -noupdate ems_0_tb/iEMUL/avs_read_i +add wave -noupdate ems_0_tb/iEMUL/seq_ram_read +add wave -noupdate ems_0_tb/iEMUL/seq_csr_read +add wave -noupdate ems_0_tb/iEMUL/seq_start_req +add wave -noupdate ems_0_tb/iEMUL/seq_busy +add wave -noupdate ems_0_tb/iEMUL/ext_trigger +add wave -noupdate ems_0_tb/iEMUL/us_pulse +add wave -noupdate ems_0_tb/iEMUL/ms_pulse +add wave -noupdate ems_0_tb/iEMUL/sec_pulse +add wave -noupdate ems_0_tb/iEMUL/pd +add wave -noupdate ems_0_tb/iEMUL/pd_d +add wave -noupdate ems_0_tb/iEMUL/pd_pulse +add wave -noupdate ems_0_tb/iEMUL/clr_pd_cnt +add wave -noupdate ems_0_tb/iEMUL/pd_gen +add wave -noupdate ems_0_tb/iEMUL/pd_seq +add wave -noupdate ems_0_tb/iEMUL/pd_emul_en +add wave -noupdate ems_0_tb/iEMUL/pd_i +add wave -noupdate ems_0_tb/iEMUL/max_pulses_start_i +add wave -noupdate ems_0_tb/iEMUL/seq_pulses_start +add wave -noupdate ems_0_tb/iEMUL/enc_dir_i +add wave -noupdate ems_0_tb/iEMUL/pulse_dir +add wave -noupdate ems_0_tb/iEMUL/seq_vec_out +add wave -noupdate ems_0_tb/iEMUL/seq_csr_addr +add wave -noupdate ems_0_tb/iEMUL/clk_cnt +add wave -noupdate ems_0_tb/iEMUL/seq_trigger_in +add wave -noupdate ems_0_tb/iEMUL/seq_ram_addr +add wave -noupdate ems_0_tb/iEMUL/seq_start_addr +add wave -noupdate ems_0_tb/iEMUL/avs_addr_i +add wave -noupdate ems_0_tb/iEMUL/us_cnt +add wave -noupdate ems_0_tb/iEMUL/ms_cnt +add wave -noupdate ems_0_tb/iEMUL/zero_phase_ppr +add wave -noupdate ems_0_tb/iEMUL/zero_phase_cnt +add wave -noupdate ems_0_tb/iEMUL/pd_pulse_width +add wave -noupdate ems_0_tb/iEMUL/pd_pulse_cnt +add wave -noupdate ems_0_tb/iEMUL/pd_cnt +add wave -noupdate ems_0_tb/iEMUL/enc_nco_1 +add wave -noupdate ems_0_tb/iEMUL/enc_nco_2 +add wave -noupdate ems_0_tb/iEMUL/nco_inc +add wave -noupdate ems_0_tb/iEMUL/avs_readdata_i +add wave -noupdate -radix unsigned ems_0_tb/iEMUL/seq_pulses +add wave -noupdate ems_0_tb/iEMUL/seq_ram_writedata +add wave -noupdate ems_0_tb/iEMUL/seq_csr_writedata +add wave -noupdate ems_0_tb/iEMUL/seq_ram_readdata +add wave -noupdate ems_0_tb/iEMUL/seq_csr_readdata +add wave -noupdate ems_0_tb/iEMUL/max_pulses +add wave -noupdate ems_0_tb/iEMUL/max_pulses_i +add wave -noupdate ems_0_tb/iEMUL/pulse_cnt +add wave -noupdate ems_0_tb/iEMUL/abs_pos +add wave -noupdate ems_0_tb/iEMUL/abs_pos_init +add wave -noupdate -divider {Encoder Multiply} +add wave -noupdate ems_0_tb/iEMS/iMULT/reset_n +add wave -noupdate ems_0_tb/iEMS/iMULT/clk +add wave -noupdate ems_0_tb/iEMS/iMULT/init +add wave -noupdate ems_0_tb/iEMS/iMULT/enable +add wave -noupdate ems_0_tb/iEMS/iMULT/mult_sel +add wave -noupdate ems_0_tb/iEMS/iMULT/delta_t +add wave -noupdate ems_0_tb/iEMS/iMULT/step_pos_in +add wave -noupdate ems_0_tb/iEMS/iMULT/step_neg_in +add wave -noupdate ems_0_tb/iEMS/iMULT/step_pos_out +add wave -noupdate ems_0_tb/iEMS/iMULT/step_neg_out +add wave -noupdate ems_0_tb/iEMS/iMULT/init_d +add wave -noupdate ems_0_tb/iEMS/iMULT/step_pos +add wave -noupdate ems_0_tb/iEMS/iMULT/step_neg +add wave -noupdate ems_0_tb/iEMS/iMULT/m_step_pos +add wave -noupdate ems_0_tb/iEMS/iMULT/m_step_neg +add wave -noupdate ems_0_tb/iEMS/iMULT/sign +add wave -noupdate ems_0_tb/iEMS/iMULT/sign_i +add wave -noupdate ems_0_tb/iEMS/iMULT/time_cnt_tc +add wave -noupdate ems_0_tb/iEMS/iMULT/norm_pos +add wave -noupdate ems_0_tb/iEMS/iMULT/norm_neg +add wave -noupdate ems_0_tb/iEMS/iMULT/kickoff +add wave -noupdate ems_0_tb/iEMS/iMULT/pending_kickoff +add wave -noupdate ems_0_tb/iEMS/iMULT/realign_pos +add wave -noupdate ems_0_tb/iEMS/iMULT/realign_neg +add wave -noupdate ems_0_tb/iEMS/iMULT/realign_pos_d +add wave -noupdate ems_0_tb/iEMS/iMULT/realign_neg_d +add wave -noupdate ems_0_tb/iEMS/iMULT/realign_pos_i +add wave -noupdate ems_0_tb/iEMS/iMULT/realign_neg_i +add wave -noupdate ems_0_tb/iEMS/iMULT/delay_vect +add wave -noupdate ems_0_tb/iEMS/iMULT/pulse_cnt +add wave -noupdate ems_0_tb/iEMS/iMULT/m_pulse_cnt +add wave -noupdate ems_0_tb/iEMS/iMULT/m_norm_value +add wave -noupdate ems_0_tb/iEMS/iMULT/delta_m +add wave -noupdate ems_0_tb/iEMS/iMULT/time_cnt +add wave -noupdate ems_0_tb/iEMS/iMULT/m_delta_t +add wave -noupdate ems_0_tb/iEMS/iMULT/delta_t_i +add wave -noupdate -divider {Velocity Estimation} +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/reset_n +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/clk +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/init +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/enable +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/avg_steps +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/delta_init +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/time_out +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/step_pos +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/step_neg +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/delta_t +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/step_pos_out +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/step_neg_out +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/time_out_flag +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/step_type +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/step_pos_i +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/step_neg_i +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/inc_last +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/inc_first +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/avg_transient_on +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/init_i +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/time_out_flag_i +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/new_step +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/inc_step_balance +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/dec_step_balance +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/inc_step_cnt +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/write_last +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/first_step +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/time_out_flag_d +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/last_step_type +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/enforce_delta_min +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/data_valid +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/step_cnt +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/step_bal_m1 +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/step_balance +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/first_addr +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/last_addr +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/loc_time +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/time_out_cnt +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/time_diff +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/time_diff_i +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/delta_t_i +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/new_tag +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/tag_last_i +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/tag_first +add wave -noupdate ems_0_tb/iEMS/iVEL_MEAS/tag_last +TreeUpdate [SetDefaultTree] +WaveRestoreCursors {{Cursor 1} {2822645000 ps} 0} +quietly wave cursor active 1 +configure wave -namecolwidth 301 +configure wave -valuecolwidth 116 +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 {2324291448 ps} {3321458552 ps} diff --git a/generic_ip/ems/0/src/ems_0.vhd b/generic_ip/ems/0/src/ems_0.vhd new file mode 100644 index 0000000..70f630b --- /dev/null +++ b/generic_ip/ems/0/src/ems_0.vhd @@ -0,0 +1,589 @@ +------------------------------------------------------------------------------- +-- Title : ems +-- Project : SMB +------------------------------------------------------------------------------- +-- File : ems.vhd +-- Author : Gianmarco Girau +-- Company : Global Inkjet Systems +-- Created : 2018-05-24 +-- Last update: 2019-12-17 +-- SVN ID : Git +-- Standard : VHDL 2008 +------------------------------------------------------------------------------- +-- Description: +-- EMS: Encoder (and Product Detect) Management System. +-- This version of the EMS is completely different from the one +-- implemented on the PMB, and natively uses the concept of absolute +-- position. +------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +library work; +use work.ems_0_pkg.all; + +entity ems_0 is + generic( + GEN_PRINT_START : boolean := false); + port ( + clk : in std_logic; + reset_n : in std_logic := '1'; + init : in std_logic; + -- Avalon-MM I/F + avs_address : in std_logic_vector( 3 downto 0); + avs_write : in std_logic; + avs_writedata : in std_logic_vector(31 downto 0); + avs_read : in std_logic; + avs_readdatavalid : out std_logic; + avs_readdata : out std_logic_vector(31 downto 0); + -- EMS inputs + rs422_pd : in std_logic; + rs422_p1 : in std_logic; + rs422_p2 : in std_logic; + rs422_zp : in std_logic; + ttl_pd : in std_logic; + ttl_pd_npn : in std_logic; + ttl_p1 : in std_logic; + ttl_p2 : in std_logic; + ttl_zp : in std_logic; + -- + abs_position : out std_logic_vector(31 downto 0); + pd_out : out std_logic; + print_start : out std_logic := '1'; + -- diagnostics + set_pos : out std_logic; -- to the diagnostic block + inc_pos : out std_logic; -- to the diagnostic block + dec_pos : out std_logic; -- to the diagnostic block + filt_p1 : out std_logic; + filt_p2 : out std_logic; + filt_zp : out std_logic; + filt_pd : out std_logic); + +end entity ems_0; + +architecture rtl of ems_0 is + + constant CSR_IP_ID : std_logic_vector(31 downto 0) := x"0000FF1F"; + constant CSR_IP_VER : std_logic_vector(31 downto 0) := x"00000001"; + + constant DEFAULT_FILT_ORDER : positive := 14; + constant DEFAULT_FILT_HYST : positive := 2; + + signal init_i, ttl_pd_i, sel_ttl_npn, pd_mux : std_logic; + signal p1_mux, p2_mux, zp_mux, ems_init : std_logic; + signal pd_i, pd_re, pd_fe, p1_i, p1_re, p1_fe : std_logic; + signal p2_i, p2_re, p2_fe, zp_i, p1_re_i : std_logic; + signal p1_fe_i, p2_re_i, p2_fe_i, enc_ph1_en : std_logic; + signal enc_ph2_en, enc_rising_en, enc_falling_en : std_logic; + signal step_pos_i, step_neg_i, step_pos, step_neg : std_logic; + signal set_pos_i, set_abs_pos, wrap_pos, wrap_neg : std_logic; + signal inc_pos_i, dec_pos_i, ems_enable : std_logic; + signal pd_hyst_filt, set_pd_hyst_filt, pd_event : std_logic; + signal clr_pd_hyst_filt, sw_pos_step, sw_neg_step : std_logic; + signal pd_rising_en, pd_falling_en, sw_pd : std_logic; + signal pd, kickstart_pd, sw_clr_pd_hyst_filt : std_logic; + signal ld_filt_cfg_pd, ld_filt_cfg_zp : std_logic; + signal ld_filt_cfg_p1, ld_filt_cfg_p2 : std_logic; + signal switch_pos_neg_inc, step_pos_ii, step_neg_ii : std_logic; + signal enc_enable, enc_enable_i : std_logic; + signal pd_enable, pd_enable_i : std_logic; + signal wrap_pos_i, wrap_neg_i, use_multiplier : std_logic; + signal m_step_pos, m_step_neg : std_logic; + signal step_pos_retimed, step_neg_retimed : std_logic; + signal init_mult, enable_mult : std_logic; + -- + signal enc_sel : std_logic_vector( 1 downto 0); + signal pd_sel, mult_sel, pd_delay_line : std_logic_vector( 2 downto 0); + signal enc_cnt, enc_divide : std_logic_vector( 3 downto 0); + signal filt_order, filt_hyst : std_logic_vector( 4 downto 0); + signal avg_steps : std_logic_vector( 6 downto 0); + signal pd_hyst_val : std_logic_vector(15 downto 0); + signal pd_hyst_pos_cnt, pd_hyst_neg_cnt : std_logic_vector(15 downto 0); + signal hw_pd_cnt, total_pd_cnt : std_logic_vector(15 downto 0); + signal delta_init, time_out : std_logic_vector(27 downto 0); + signal abs_pos_i, abs_pos_init : std_logic_vector(31 downto 0); + signal abs_pos_in, abs_pos_vel : std_logic_vector(31 downto 0); + signal delta_t : std_logic_vector(39 downto 0); + + +begin + + pINIT : process(clk) + begin + if(clk = '1' and clk'event) then + init_i <= init or ems_init; + end if; + end process pINIT; + + ----------------------------------------------------------------------------- + -- Input selection and conditioning + ----------------------------------------------------------------------------- + + -- NOTE: on the SMB none of the TTL input are inverted + ttl_pd_i <= ttl_pd when sel_ttl_npn = '0' else ttl_pd_npn; + + -- Input multiplexers + pd_mux <= rs422_pd when pd_sel(0) = '0' else ttl_pd_i; + p1_mux <= rs422_p1 when enc_sel(0) = '0' else ttl_p1; + p2_mux <= rs422_p2 when enc_sel(0) = '0' else ttl_p2; + zp_mux <= rs422_zp when enc_sel(0) = '0' else ttl_zp; + + -- Filters + iPD_FILT: entity work.digital_lpf + generic map ( + MAX_ORDER => 32, + DEFAULT_ORDER => DEFAULT_FILT_ORDER, + DEFAULT_HYST => DEFAULT_FILT_HYST) + port map ( + clk => clk, + reset_n => reset_n, + ld_cfg => ld_filt_cfg_pd, + filt_order => filt_order, + hyst => filt_hyst, + filt_in => pd_mux, + filt_out => pd_i, + rEdge => pd_re, + fEdge => pd_fe); + + iP1_FILT: entity work.digital_lpf + generic map ( + MAX_ORDER => 32, + DEFAULT_ORDER => DEFAULT_FILT_ORDER, + DEFAULT_HYST => DEFAULT_FILT_HYST) + port map ( + clk => clk, + reset_n => reset_n, + ld_cfg => ld_filt_cfg_p1, + filt_order => filt_order, + hyst => filt_hyst, + filt_in => p1_mux, + filt_out => p1_i, + rEdge => p1_re, + fEdge => p1_fe); + + iP2_FILT: entity work.digital_lpf + generic map ( + MAX_ORDER => 32, + DEFAULT_ORDER => DEFAULT_FILT_ORDER, + DEFAULT_HYST => DEFAULT_FILT_HYST) + port map ( + clk => clk, + reset_n => reset_n, + ld_cfg => ld_filt_cfg_p2, + filt_order => filt_order, + hyst => filt_hyst, + filt_in => p2_mux, + filt_out => p2_i, + rEdge => p2_re, + fEdge => p2_fe); + + iZP_FILT: entity work.digital_lpf + generic map ( + MAX_ORDER => 32, + DEFAULT_ORDER => DEFAULT_FILT_ORDER, + DEFAULT_HYST => DEFAULT_FILT_HYST) + port map ( + clk => clk, + reset_n => reset_n, + ld_cfg => ld_filt_cfg_zp, + filt_order => filt_order, + hyst => filt_hyst, + filt_in => zp_mux, + filt_out => zp_i); + + -- Buffer the filtered signals + pFiltOut_Buf : process(clk) + begin + if(clk = '1' and clk'event) then + filt_pd <= pd_i; + filt_p1 <= p1_i; + filt_p2 <= p2_i; + filt_zp <= zp_i; + end if; + end process pFiltOut_Buf; + + -- W&H Print-Start digital filter + gPS: if GEN_PRINT_START = true generate + + iPS_FILT: entity work.digital_lpf + generic map ( + MAX_ORDER => 32, + DEFAULT_ORDER => DEFAULT_FILT_ORDER, + DEFAULT_HYST => DEFAULT_FILT_HYST) + port map ( + clk => clk, + reset_n => reset_n, + ld_cfg => ld_filt_cfg_pd, + filt_order => filt_order, + hyst => filt_hyst, + filt_in => ttl_pd_npn, + filt_out => print_start, + rEdge => open, + fEdge => open); + + end generate gPS; + + ----------------------------------------------------------------------------- + -- Encoder Detection + ----------------------------------------------------------------------------- + + p1_re_i <= p1_re and enc_ph1_en and enc_rising_en; + p1_fe_i <= p1_fe and enc_ph1_en and enc_falling_en; + p2_re_i <= p2_re and enc_ph2_en and enc_rising_en; + p2_fe_i <= p2_fe and enc_ph2_en and enc_falling_en; + + pENC_DET: process(all) + variable det_array : std_logic_vector(3 downto 0); + begin + det_array := p1_re_i & p1_fe_i & p2_re_i & p2_fe_i; + step_pos_i <= '0'; + step_neg_i <= '0'; + case det_array is + when b"1000" => -- phase-1 rising edge + if enc_ph2_en = '0' or p2_i = '0' then + step_pos_i <= '1'; + else + step_neg_i <= '1'; + end if; + when b"0100" => -- phase-1 falling edge + if enc_ph2_en = '0' or p2_i = '1' then + step_pos_i <= '1'; + else + step_neg_i <= '1'; + end if; + when b"0010" => -- phase-2 rising edge + if enc_ph1_en = '0' or p1_i = '1' then + step_pos_i <= '1'; + else + step_neg_i <= '1'; + end if; + when b"0001" => -- phase-2 falling edge + if enc_ph1_en = '0' or p1_i = '0' then + step_pos_i <= '1'; + else + step_neg_i <= '1'; + end if; + when others => + null; + end case; + end process pENC_DET; + + -- NOTE: ~The encoder jitter and the dual-phase directionality management are + -- performed in the pulse generator block. + + pENC_REGs : process(clk) + begin + if(clk = '1' and clk'event) then + -- Encoder division: to be used ONLY when the maximum encoder rate + -- exceeds the transmission bandwidth over the POF (~4Mbps) + if(set_pos_i = '1' or wrap_pos = '1') then + enc_cnt <= (others => '0'); + elsif(wrap_neg = '1') then + enc_cnt <= enc_divide; + elsif(step_pos = '1') then + enc_cnt <= std_logic_vector(unsigned(enc_cnt)+1); + elsif(step_neg = '1') then + enc_cnt <= std_logic_vector(unsigned(enc_cnt)-1); + end if; + -- latch wrap_pos and wrap_neg to prevent a long combinational path + inc_pos_i <= wrap_pos; + dec_pos_i <= wrap_neg; + if(set_pos_i = '1') then + abs_pos_i <= abs_pos_init; + elsif(inc_pos_i = '1') then + abs_pos_i <= std_logic_vector(signed(abs_pos_i)+1); + elsif(dec_pos_i = '1') then + abs_pos_i <= std_logic_vector(signed(abs_pos_i)-1); + end if; + if(set_pos_i = '1') then + abs_pos_in <= abs_pos_init; + elsif(step_pos = '1') then + abs_pos_in <= std_logic_vector(signed(abs_pos_in)+1); + elsif(step_neg = '1') then + abs_pos_in <= std_logic_vector(signed(abs_pos_in)-1); + end if; + if(set_pos_i = '1') then + abs_pos_vel <= abs_pos_init; + elsif(step_pos_retimed = '1') then + abs_pos_vel <= std_logic_vector(signed(abs_pos_vel)+1); + elsif(step_neg_retimed = '1') then + abs_pos_vel <= std_logic_vector(signed(abs_pos_vel)-1); + end if; + set_pos <= set_pos_i; + inc_pos <= inc_pos_i; + dec_pos <= dec_pos_i; + init_mult <= set_pos_i; + enable_mult <= enc_enable_i; + end if; + end process pENC_REGs; + + enc_enable_i <= enc_enable and ems_enable; + + set_pos_i <= init_i or set_abs_pos; + + step_pos_ii <= enc_enable_i and ((step_pos_i and not enc_sel(1)) or (sw_pos_step and enc_sel(1))); + step_neg_ii <= enc_enable_i and ((step_neg_i and not enc_sel(1)) or (sw_neg_step and enc_sel(1))); + + step_pos <= step_pos_ii when switch_pos_neg_inc = '0' else step_neg_ii; + step_neg <= step_neg_ii when switch_pos_neg_inc = '0' else step_pos_ii; + + wrap_pos_i <= '1' when step_pos = '1' and unsigned(enc_cnt) = unsigned(enc_divide) else '0'; + wrap_neg_i <= '1' when step_neg = '1' and unsigned(enc_cnt) = 0 else '0'; + + wrap_pos <= wrap_pos_i when use_multiplier = '0' else m_step_pos; + wrap_neg <= wrap_neg_i when use_multiplier = '0' else m_step_neg; + + abs_position <= abs_pos_i; + + + ----------------------------------------------------------------------------- + -- Product Detect management + ----------------------------------------------------------------------------- + + pPD_MNG : process(clk) + begin + if(clk = '1' and clk'event) then + if(init_i = '1' or clr_pd_hyst_filt = '1' or sw_clr_pd_hyst_filt = '1') then + pd_hyst_filt <= '0'; + elsif(set_pd_hyst_filt = '1') then + pd_hyst_filt <= '1'; + end if; + if(set_pd_hyst_filt = '1') then + pd_hyst_pos_cnt <= pd_hyst_val; + elsif(step_pos = '1') then + pd_hyst_pos_cnt <= std_logic_vector(unsigned(pd_hyst_pos_cnt)-1); + end if; + if(set_pd_hyst_filt = '1') then + pd_hyst_neg_cnt <= pd_hyst_val; + elsif(step_neg = '1') then + pd_hyst_neg_cnt <= std_logic_vector(unsigned(pd_hyst_neg_cnt)-1); + end if; + pd <= kickstart_pd or (not pd_hyst_filt and pd_enable_i and (pd_event or sw_pd)); + if(init_i = '1') then + pd_delay_line <= (others => '0'); + else + pd_delay_line <= pd_delay_line(pd_delay_line'left-1 downto 0) & pd; + end if; + if(init_i = '1') then + hw_pd_cnt <= (others => '0'); + elsif(pd_event = '1' and pd_hyst_filt = '0' and pd_enable_i = '1') then + hw_pd_cnt <= std_logic_vector(unsigned(hw_pd_cnt)+1); + end if; + if(init_i = '1') then + total_pd_cnt <= (others => '0'); + elsif((pd_event = '1' or sw_pd = '1') and pd_hyst_filt = '0' and pd_enable_i = '1') then + total_pd_cnt <= std_logic_vector(unsigned(total_pd_cnt)+1); + end if; + end if; + end process pPD_MNG; + + pd_enable_i <= pd_enable and ems_enable; + + -- hardware pd event: + pd_event <= not pd_sel(1) and ((pd_re and pd_rising_en) or (pd_fe and pd_falling_en)); + + -- Note: the hysteresis mechanism is not triggered in case of a kickstart-pd + -- (a PD event added when ems_enable = '0' and used for initial + -- synchronization only) + set_pd_hyst_filt <= '1' when pd_enable_i = '1' and (pd_event = '1' or sw_pd = '1') else '0'; + + clr_pd_hyst_filt <= '1' when pd_hyst_filt = '1' and (pd_enable_i = '0' or unsigned(pd_hyst_pos_cnt) = 0 or unsigned(pd_hyst_neg_cnt) = 0) else '0'; + + -- when the multiplier is enabled, compensate for the latency in the absolute + -- position introduced by the multiplier + pd_out <= pd when enable_mult = '0' else pd_delay_line(pd_delay_line'left); + + ----------------------------------------------------------------------------- + -- Velocity Estimation & Encoder Multiplication + ----------------------------------------------------------------------------- + + -- Encoder Multiplier + iMULT : entity work.encoder_multiply_0 + port map ( + reset_n => reset_n, + clk => clk, + init => init_mult, + enable => enable_mult, + mult_sel => mult_sel, + delta_t => delta_t, + step_pos_in => step_pos_retimed, + step_neg_in => step_neg_retimed, + step_pos_out => m_step_pos, + step_neg_out => m_step_neg); + + -- Average Velocity Estimation + iVEL_MEAS: entity work.encoder_speed_detect_0 + port map ( + reset_n => reset_n, + clk => clk, + init => init_mult, + enable => enable_mult, + avg_steps => avg_steps, + delta_init => delta_init, + time_out => time_out, + step_pos => step_pos, + step_neg => step_neg, + delta_t => delta_t, + step_pos_out => step_pos_retimed, + step_neg_out => step_neg_retimed, + time_out_flag => open); + + + ----------------------------------------------------------------------------- + -- C&S registers (Avalon-MM I/F) + ----------------------------------------------------------------------------- + + sel_ttl_npn <= pd_sel(2); + + pCTRL_STATUS : process(reset_n, clk) + begin + if(reset_n = '0') then + avs_readdatavalid <= '0'; + avs_readdata <= (others => '0'); + -- + ems_init <= '0'; + ems_enable <= '0'; + enc_enable <= '0'; + pd_enable <= '0'; + enc_sel <= "00"; + pd_sel <= "000"; + enc_ph1_en <= '0'; + enc_ph2_en <= '0'; + enc_rising_en <= '0'; + enc_falling_en <= '0'; + pd_rising_en <= '0'; + pd_falling_en <= '0'; + switch_pos_neg_inc <= '0'; + pd_hyst_val <= X"0020"; + enc_divide <= (others => '0'); + abs_pos_init <= (others => '0'); + use_multiplier <= '0'; + mult_sel <= (others => '0'); + avg_steps <= std_logic_vector(to_unsigned(8, avg_steps'length)); + time_out <= std_logic_vector(to_unsigned(5000, time_out'length)); + delta_init <= std_logic_vector(to_unsigned(25, delta_init'length)); + elsif(clk = '1' and clk'event) then + -- default assignments/self-clearing + set_abs_pos <= '0'; + sw_pd <= '0'; + kickstart_pd <= '0'; + sw_pos_step <= '0'; + sw_neg_step <= '0'; + sw_clr_pd_hyst_filt <= '0'; + ld_filt_cfg_pd <= '0'; + ld_filt_cfg_p1 <= '0'; + ld_filt_cfg_p2 <= '0'; + ld_filt_cfg_zp <= '0'; + -- CTRL registers + if(avs_write = '1') then + case avs_address is + when CSR_EMS_ENABLE_ADDR => + ems_init <= avs_writedata(0); + ems_enable <= avs_writedata(1); + enc_enable <= avs_writedata(2); + pd_enable <= avs_writedata(3); + when CSR_EMS_CONFIG_ADDR => + enc_sel <= avs_writedata( 1 downto 0); + pd_sel <= avs_writedata( 4 downto 2); + enc_ph1_en <= avs_writedata( 5); + enc_ph2_en <= avs_writedata( 6); + enc_rising_en <= avs_writedata( 7); + enc_falling_en <= avs_writedata( 8); + pd_rising_en <= avs_writedata( 9); + pd_falling_en <= avs_writedata(10); + set_abs_pos <= avs_writedata(11); + switch_pos_neg_inc <= avs_writedata(12); + when CSR_PD_HYST_ADDR => + sw_clr_pd_hyst_filt <= avs_writedata(16); + pd_hyst_val <= avs_writedata(15 downto 0); + when CSR_SW_CTRL_ADDR => + sw_pd <= avs_writedata(0); + kickstart_pd <= avs_writedata(1); + sw_pos_step <= avs_writedata(4); + sw_neg_step <= avs_writedata(5); + when CSR_ENC_DIVIDE => + enc_divide <= avs_writedata( 3 downto 0); + when CSR_ABS_POS_PRESET_ADDR => + abs_pos_init <= avs_writedata; + when CSR_FILT_CFG_ADDR => + filt_order <= avs_writedata( 4 downto 0); + filt_hyst <= avs_writedata(12 downto 8); + ld_filt_cfg_pd <= avs_writedata(16); + ld_filt_cfg_p1 <= avs_writedata(17); + ld_filt_cfg_p2 <= avs_writedata(18); + ld_filt_cfg_zp <= avs_writedata(19); + when CSR_MULT_CFG_ADDR => + use_multiplier <= avs_writedata(0); + mult_sel <= avs_writedata( 6 downto 4); + avg_steps <= avs_writedata(14 downto 8); + when CSR_DELTA_T_INIT_ADDR => + delta_init <= avs_writedata(27 downto 0); + when CSR_VEL_TIMEOUT_ADDR => + time_out <= avs_writedata(27 downto 0); + when others => null; + end case; + end if; + + -- Read Ctrl & Status registers + avs_readdatavalid <= avs_read; + if(avs_read = '1') then + case avs_address is + when CSR_IP_ID_ADDR => + avs_readdata <= CSR_IP_ID; + when CSR_IP_VER_ADDR => + avs_readdata <= CSR_IP_VER; + when CSR_EMS_ENABLE_ADDR => + avs_readdata <= (0 => ems_init, 1 => ems_enable, 2 => enc_enable, 3 => pd_enable, others => '0'); + when CSR_EMS_CONFIG_ADDR => + avs_readdata <= (0 => enc_sel(0), + 1 => enc_sel(1), + 2 => pd_sel(0), + 3 => pd_sel(1), + 4 => pd_sel(2), + 5 => enc_ph1_en, + 6 => enc_ph2_en, + 7 => enc_rising_en, + 8 => enc_falling_en, + 9 => pd_rising_en, + 10 => pd_falling_en, + 11 => set_abs_pos, + 12 => switch_pos_neg_inc, others => '0'); + when CSR_PD_HYST_ADDR => + avs_readdata <= X"0000" & pd_hyst_val; + when CSR_SW_CTRL_ADDR => + avs_readdata <= (0 => sw_pd, + 1 => kickstart_pd, + 4 => sw_pos_step, + 5 => sw_neg_step, others => '0'); + when CSR_ENC_DIVIDE => + avs_readdata <= X"0000000" & enc_divide; + when CSR_ABS_POS_PRESET_ADDR => + avs_readdata <= abs_pos_init; + when CSR_ABS_POS_STAT_ADDR => + avs_readdata <= abs_pos_i; + when CSR_PD_CNT_ADDR => + avs_readdata <= hw_pd_cnt & total_pd_cnt; + when CSR_FILT_CFG_ADDR => + avs_readdata <= X"0000" & "000" & filt_hyst & "000" &filt_order; + when CSR_MULT_CFG_ADDR => + avs_readdata <= 17x"0" & avg_steps & "0" & mult_sel & "000" & use_multiplier; + when CSR_DELTA_T_INIT_ADDR => + avs_readdata <= X"0" & delta_init; + when CSR_VEL_TIMEOUT_ADDR => + avs_readdata <= X"0" & time_out; + when CSR_ABS_POS_IN_ADDR => + avs_readdata <= abs_pos_in; + when CSR_ABS_POS_VEL_ADDR => + avs_readdata <= abs_pos_vel; + when others => + avs_readdata <= X"BAD1BAD0"; + end case; + end if; + end if; + end process pCTRL_STATUS; + +end architecture rtl; + diff --git a/generic_ip/ems/0/src/ems_0_pkg.vhd b/generic_ip/ems/0/src/ems_0_pkg.vhd new file mode 100644 index 0000000..99c267e --- /dev/null +++ b/generic_ip/ems/0/src/ems_0_pkg.vhd @@ -0,0 +1,41 @@ +------------------------------------------------------------------------------- +-- Title : ems_0_pkg +-- Project : SMB +------------------------------------------------------------------------------- +-- File : ems_0_pkg.vhd +-- Author : GMG +-- Company : Global Inkjet Systems +-- Created : 2018-05-24 +-- Last update: 2019-12-17 +-- SVN ID : Git +-- Standard : VHDL'2008 +------------------------------------------------------------------------------- +-- Description: +-- Package defining common constants for the ems block +------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +package ems_0_pkg is + + constant CSR_IP_ID_ADDR : std_logic_vector(3 downto 0) := 4x"0"; + constant CSR_IP_VER_ADDR : std_logic_vector(3 downto 0) := 4x"1"; + constant CSR_EMS_ENABLE_ADDR : std_logic_vector(3 downto 0) := 4x"2"; + constant CSR_EMS_CONFIG_ADDR : std_logic_vector(3 downto 0) := 4x"3"; + constant CSR_PD_HYST_ADDR : std_logic_vector(3 downto 0) := 4x"4"; + constant CSR_SW_CTRL_ADDR : std_logic_vector(3 downto 0) := 4x"5"; + constant CSR_ENC_DIVIDE : std_logic_vector(3 downto 0) := 4x"6"; + constant CSR_ABS_POS_PRESET_ADDR : std_logic_vector(3 downto 0) := 4x"7"; + constant CSR_ABS_POS_STAT_ADDR : std_logic_vector(3 downto 0) := 4x"8"; + constant CSR_PD_CNT_ADDR : std_logic_vector(3 downto 0) := 4x"9"; + constant CSR_FILT_CFG_ADDR : std_logic_vector(3 downto 0) := 4x"A"; + constant CSR_MULT_CFG_ADDR : std_logic_vector(3 downto 0) := 4x"B"; + constant CSR_DELTA_T_INIT_ADDR : std_logic_vector(3 downto 0) := 4x"C"; + constant CSR_VEL_TIMEOUT_ADDR : std_logic_vector(3 downto 0) := 4x"D"; + constant CSR_ABS_POS_IN_ADDR : std_logic_vector(3 downto 0) := 4x"E"; + constant CSR_ABS_POS_VEL_ADDR : std_logic_vector(3 downto 0) := 4x"F"; + +end package ems_0_pkg; diff --git a/generic_ip/ems/0/src/test/ems_0_tb.vhd b/generic_ip/ems/0/src/test/ems_0_tb.vhd new file mode 100644 index 0000000..4ba3cc6 --- /dev/null +++ b/generic_ip/ems/0/src/test/ems_0_tb.vhd @@ -0,0 +1,1689 @@ +------------------------------------------------------------------------------- +-- Title : ems_0_tb +-- Project : SMB +------------------------------------------------------------------------------- +-- File : ems_0_tb.vhd +-- Author : GMG +-- Company : Global Inkjet Systems +-- Created : 2018-06-12 +-- Last update: 2019-12-17 +-- SVN ID : Git +-- Standard : VHDL'2008 +------------------------------------------------------------------------------- +-- Description: +-- Testbench for the EMS block +------------------------------------------------------------------------------- + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; +use ieee.math_real.all; + +library work; +use work.log_pkg.all; +use work.avalon_verify_pkg.all; +use work.enc_pd_emul_1_pkg.all; +use work.ems_0_pkg.all; + +entity ems_0_tb is + -- .. +end entity ems_0_tb; + +architecture behav of ems_0_tb is + + constant CLK_PERIOD : time := 10 ns; + + constant CLK_FREQ : real := 100.0e6; -- target clock frequency + + -- Logging Verbosity Level + constant VERBOSITY_LEVEL : verb_level_t := VMEDIUM; + + constant MAX_SIM_TIME : time := 4.0 ms; -- Maximum simulation time + + signal reset_n : std_logic := '0'; + signal clk : std_logic := '0'; + signal ttl_pd : std_logic; + signal ttl_pd_npn : std_logic; + signal ttl_enc_p1 : std_logic; + signal ttl_enc_p2 : std_logic; + signal ttl_enc_zp : std_logic; + signal rs422_pd : std_logic; + signal rs422_enc_p1 : std_logic; + signal rs422_enc_p2 : std_logic; + signal rs422_enc_zp : std_logic; + -- + signal pd_out : std_logic; + signal set_pos : std_logic; + signal inc_pos : std_logic; + signal dec_pos : std_logic; + signal filt_p1 : std_logic; + signal filt_p2 : std_logic; + signal filt_zp : std_logic; + signal filt_pd : std_logic; + signal abs_position : std_logic_vector(31 downto 0); + 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 ems_address : std_logic_vector( 3 downto 0); + signal ems_write : std_logic; + signal ems_writedata : std_logic_vector(31 downto 0); + signal ems_read : std_logic; + signal ems_readdatavalid : std_logic; + signal ems_readdata : std_logic_vector(31 downto 0); + -- + signal init : std_logic; + signal emul_set_pos : std_logic; + signal emul_inc_pos : std_logic; + signal emul_dec_pos : std_logic; + signal emul_pos : std_logic_vector(39 downto 0); + -- + signal mask_npn : std_logic; + signal mask_pnp : std_logic; + signal ttl_pd_pnp : std_logic; + + -- TB specific signals + signal setup : boolean; + signal running : boolean; + signal passed : boolean := false; + signal failed : boolean := false; + signal test_timeout : boolean := false; + signal test_completed : boolean := false; + + signal error_flag : boolean; + + signal avs_mm_s_rec : mm_s_rec_t; + signal avs_mm_m_rec : mm_m_rec_t; + signal ems_mm_s_rec : mm_s_rec_t; + signal ems_mm_m_rec : mm_m_rec_t; + + ----------------------------------------------------------------------------- + -- Subprograms + ----------------------------------------------------------------------------- + + procedure wait_clk_cycles(cycles : in natural) is + begin + for n in 0 to cycles-1 loop + wait until clk = '1' and clk'event; + end loop; -- n + end procedure wait_clk_cycles; + + -- generate the NCO increment corresponding to a given output frequency + function freq2NCO_inc( + f_out : real; f_clk : real) return std_logic_vector is + variable nco_inc : std_logic_vector(31 downto 0); + + begin + nco_inc := std_logic_vector(to_unsigned(integer((f_out/f_clk)*(2.0**32)),32)); + return nco_inc; + + end function freq2NCO_inc; + +begin -- architecture behav + + clk <= not clk after 0.5*CLK_PERIOD; + + clk_clk <= clk; + + reset_reset_n <= reset_n; + + ----------------------------------------------------------------------------- + -- EMS (UUT) + ----------------------------------------------------------------------------- + + iEMS: entity work.ems_0 + port map ( + clk => clk, + reset_n => reset_n, + init => init, + avs_address => ems_address, + avs_write => ems_write, + avs_writedata => ems_writedata, + avs_read => ems_read, + avs_readdatavalid => ems_readdatavalid, + avs_readdata => ems_readdata, + rs422_pd => rs422_pd, + rs422_p1 => rs422_enc_p1, + rs422_p2 => rs422_enc_p2, + rs422_zp => rs422_enc_zp, + ttl_pd => ttl_pd_pnp, + ttl_pd_npn => ttl_pd_npn, + ttl_p1 => ttl_enc_p1, + ttl_p2 => ttl_enc_p2, + ttl_zp => ttl_enc_zp, + abs_position => abs_position, + pd_out => pd_out, + set_pos => set_pos, + inc_pos => inc_pos, + dec_pos => dec_pos, + filt_p1 => filt_p1, + filt_p2 => filt_p2, + filt_zp => filt_zp, + filt_pd => filt_pd); + + ttl_pd_npn <= ttl_pd and not mask_npn; + ttl_pd_pnp <= ttl_pd and not mask_pnp; + + mask_pnp <= not mask_npn; + + ----------------------------------------------------------------------------- + -- Encoder/PD emulator (Stimuli Generator) + ----------------------------------------------------------------------------- + + iEMUL : entity work.enc_pd_emul_1 + port map ( + clk => clk, + reset_n => reset_n, + ttl_pd => ttl_pd, + ttl_enc_p1 => ttl_enc_p1, + ttl_enc_p2 => ttl_enc_p2, + ttl_enc_zp => ttl_enc_zp, + rs422_pd => rs422_pd, + rs422_enc_p1 => rs422_enc_p1, + rs422_enc_p2 => rs422_enc_p2, + rs422_enc_zp => rs422_enc_zp, + abs_pos_out => emul_pos, + set_pos_out => emul_set_pos, + inc_pos_out => emul_inc_pos, + dec_pos_out => emul_dec_pos, + 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 Buses BFM mapping + ----------------------------------------------------------------------------- + + -- Encoder/PD Emulator + avs_mm_s_rec.mm_readdata <= avs_readdata; + avs_mm_s_rec.mm_readdatavalid <= avs_readdatavalid; + avs_mm_s_rec.use_readvalid <= true; + + avs_write <= avs_mm_m_rec.mm_write; + avs_writedata <= avs_mm_m_rec.mm_writedata; + avs_address <= avs_mm_m_rec.mm_address(avs_address'range); + avs_read <= avs_mm_m_rec.mm_read; + + -- EMS + ems_mm_s_rec.mm_readdata <= ems_readdata; + ems_mm_s_rec.mm_readdatavalid <= ems_readdatavalid; + ems_mm_s_rec.use_readvalid <= true; + + ems_write <= ems_mm_m_rec.mm_write; + ems_writedata <= ems_mm_m_rec.mm_writedata; + ems_address <= ems_mm_m_rec.mm_address(ems_address'range); + ems_read <= ems_mm_m_rec.mm_read; + + ----------------------------------------------------------------------------- + -- Testbench Logic + ----------------------------------------------------------------------------- + + pTEST_PROC : process + + procedure csr_read(addr : in std_logic_vector; data : out std_logic_vector(31 downto 0)) is + begin + mm_32b_read(std_logic_vector(resize(unsigned(addr),32)), data, avs_mm_s_rec, avs_mm_m_rec); + end procedure csr_read; + + procedure csr_write(addr : in std_logic_vector; data : in std_logic_vector(31 downto 0)) is + begin + mm_32b_write(std_logic_vector(resize(unsigned(addr),32)), data, avs_mm_s_rec, avs_mm_m_rec); + end procedure csr_write; + + procedure check_pos(exp_pos : in std_logic_vector(39 downto 0)) is + variable curr_pos : std_logic_vector(39 downto 0); + variable data : std_logic_vector(31 downto 0); + begin + csr_read(CSR_POS_STAT_LSB_ADDR, data); + curr_pos(31 downto 0) := data; + csr_read(CSR_POS_STAT_MSB_ADDR, data); + curr_pos(39 downto 32) := data(7 downto 0); + + if(curr_pos /= exp_pos) then + log("ERROR: detected abs_pos = " & to_string(to_integer(signed(curr_pos))) & ", expected = " & to_string(to_integer(signed(exp_pos))) & ".", VLOW); + error_flag <= true; + end if; + + end procedure check_pos; + + procedure wait_pulses(timeout : in time := 0 ns) is + variable t0 : time; + variable done : boolean := false; + variable data : std_logic_vector(31 downto 0); + + begin + t0 := now; + wait for 50 ns; + while done = false loop + -- check the done pulse + csr_read(CSR_ENC_CTRL_ADDR, data); + if(data(6) = '1') then + done := true; + elsif(timeout > 0 ns and now-t0 >= timeout) then + done := true; + log("ERROR: wait_pulses timeout.", VLOW); + error_flag <= true; + else + wait for 100 ns; + end if; + end loop; + end procedure wait_pulses; + + procedure seq_ram_wr(addr : in std_logic_vector; data : in std_logic_vector(31 downto 0)) is + begin + csr_write(std_logic_vector(unsigned(SEQ_RAM_OFFSET)+unsigned(addr)), data); + end procedure seq_ram_wr; + + -- Config the sequencer with various test procedures + procedure config_seq is + variable data : std_logic_vector(31 downto 0); + begin + -- create full swathe: first direction 0, then direction 1 + seq_ram_wr(10x"000", X"30000000"); -- VEC_SET, All zero + seq_ram_wr(10x"001", X"100000FF"); -- TRIG_MASK, all enabled + seq_ram_wr(10x"002", X"27000001"); -- TRIG_WAIT, (pulse_cnt_running = 0) + seq_ram_wr(10x"003", X"31000001"); -- VEC_SET, Issue a PD pulse, set the + -- enc_dir to 0 + seq_ram_wr(10x"004", X"60000001"); -- BUS_BURST, 1 data + seq_ram_wr(10x"005", X"00000032"); -- seq_pulses = 50 + seq_ram_wr(10x"006", X"26000001"); -- TRIG_WAIT, (pulse_cnt_running = 1) + seq_ram_wr(10x"007", X"25000001"); -- TRIG_WAIT, (max_pulses_done = 1) + seq_ram_wr(10x"008", X"21000005"); -- TRIG_WAIT, (5 us) + seq_ram_wr(10x"009", X"31000001"); -- VEC_SET, Issue a PD pulse + seq_ram_wr(10x"00A", X"30000002"); -- VEC_SET, set enc_dir to 1 + seq_ram_wr(10x"00B", X"60000001"); -- BUS_BURST, 1 data + seq_ram_wr(10x"00C", X"0000002F"); -- seq_pulses = 50-3 + seq_ram_wr(10x"00D", X"26000001"); -- TRIG_WAIT, (pulse_cnt_running = 1) + seq_ram_wr(10x"00E", X"25000001"); -- TRIG_WAIT, (max_pulses_done = 1) + seq_ram_wr(10x"00F", X"60000001"); -- BUS_BURST, 1 data + seq_ram_wr(10x"010", X"00000002"); -- seq_pulses = 2 + seq_ram_wr(10x"011", X"26000001"); -- TRIG_WAIT, (pulse_cnt_running = 1) + seq_ram_wr(10x"012", X"25000001"); -- TRIG_WAIT, (max_pulses_done = 1) + seq_ram_wr(10x"013", X"60000001"); -- BUS_BURST, 1 data + seq_ram_wr(10x"014", X"00000001"); -- seq_pulses = 1 + seq_ram_wr(10x"015", X"26000001"); -- TRIG_WAIT, (pulse_cnt_running = 1) + seq_ram_wr(10x"016", X"25000001"); -- TRIG_WAIT, (max_pulses_done = 1) + seq_ram_wr(10x"017", X"31000001"); -- VEC_SET, Issue a PD pulse + seq_ram_wr(10x"018", X"2000000A"); -- TRIG_WAIT, (100 ns) + seq_ram_wr(10x"019", X"F0000000"); -- END + + -- create full swathe: first direction 1, then direction 0 + seq_ram_wr(10x"020", X"30000000"); -- VEC_SET, All zero + seq_ram_wr(10x"021", X"100000FF"); -- TRIG_MASK, all enabled + seq_ram_wr(10x"022", X"27000001"); -- TRIG_WAIT, (pulse_cnt_running = 0) + seq_ram_wr(10x"023", X"31000001"); -- VEC_SET, Issue a PD pulse + seq_ram_wr(10x"024", X"30000002"); -- VEC_SET, set enc_dir to 1 + seq_ram_wr(10x"025", X"60000001"); -- BUS_BURST, 1 data + seq_ram_wr(10x"026", X"00000032"); -- seq_pulses = 50 + seq_ram_wr(10x"027", X"26000001"); -- TRIG_WAIT, (pulse_cnt_running = 1) + seq_ram_wr(10x"028", X"25000001"); -- TRIG_WAIT, (max_pulses_done = 1) + seq_ram_wr(10x"029", X"21000005"); -- TRIG_WAIT, (5 us) + seq_ram_wr(10x"02A", X"31000001"); -- VEC_SET, Issue a PD pulse, enc_dir = 0 + seq_ram_wr(10x"02B", X"60000001"); -- BUS_BURST, 1 data + seq_ram_wr(10x"02C", X"0000002F"); -- seq_pulses = 50-3 + seq_ram_wr(10x"02D", X"26000001"); -- TRIG_WAIT, (pulse_cnt_running = 1) + seq_ram_wr(10x"02E", X"25000001"); -- TRIG_WAIT, (max_pulses_done = 1) + seq_ram_wr(10x"02F", X"60000001"); -- BUS_BURST, 1 data + seq_ram_wr(10x"030", X"00000002"); -- seq_pulses = 2 + seq_ram_wr(10x"031", X"26000001"); -- TRIG_WAIT, (pulse_cnt_running = 1) + seq_ram_wr(10x"032", X"25000001"); -- TRIG_WAIT, (max_pulses_done = 1) + seq_ram_wr(10x"033", X"60000001"); -- BUS_BURST, 1 data + seq_ram_wr(10x"034", X"00000001"); -- seq_pulses = 1 + seq_ram_wr(10x"035", X"26000001"); -- TRIG_WAIT, (pulse_cnt_running = 1) + seq_ram_wr(10x"036", X"25000001"); -- TRIG_WAIT, (max_pulses_done = 1) + seq_ram_wr(10x"037", X"31000001"); -- VEC_SET, Issue a PD pulse + seq_ram_wr(10x"038", X"2000000A"); -- TRIG_WAIT, (100 ns) + seq_ram_wr(10x"039", X"F0000000"); -- END + + log("Sequencer RAM configured.", VLOW); + + end procedure config_seq; + + -- start the sequencer at a given offset + procedure start_seq_proc(offset : in std_logic_vector) is + variable data : std_logic_vector(31 downto 0) := (others => '0'); + begin + data(0) := '1'; -- start-request bit + data(24 downto 16) := offset; -- start-address + csr_write(CSR_SEQ_CTRL_ADDR, data); + + end procedure start_seq_proc; + + -- wait until the sequencer is not busy + procedure wait_seq_avail(timeout : in time := 0 ns) is + variable t0 : time; + variable done : boolean := false; + variable data : std_logic_vector(31 downto 0) := (others => '0'); + begin + t0 := now; + wait for 50 ns; + while done = false loop + -- check the done pulse + csr_read(CSR_SEQ_CTRL_ADDR, data); + if(data(2) = '0') then + done := true; + elsif(timeout > 0 ns and now-t0 >= timeout) then + done := true; + log("ERROR: wait_seq_avail timeout.", VLOW); + error_flag <= true; + else + wait for 100 ns; + end if; + end loop; + end procedure wait_seq_avail; + + procedure ems_read(addr : in std_logic_vector; data : out std_logic_vector(31 downto 0)) is + begin + mm_32b_read(std_logic_vector(resize(unsigned(addr),32)), data, ems_mm_s_rec, ems_mm_m_rec); + end procedure ems_read; + + procedure ems_write(addr : in std_logic_vector; data : in std_logic_vector(31 downto 0)) is + begin + mm_32b_write(std_logic_vector(resize(unsigned(addr),32)), data, ems_mm_s_rec, ems_mm_m_rec); + end procedure ems_write; + + variable data : std_logic_vector(31 downto 0); + + begin + + --------------------------------------------------------------------------- + -- Initialize & Configure + --------------------------------------------------------------------------- + + reset_n <= '0'; + + init <= '0'; + + mask_npn <= '1'; + + mm_m_init(avs_mm_m_rec); + mm_m_init(ems_mm_m_rec); + setup <= false; + + running <= false; + error_flag <= false; + + --Set the verbosity level for logging + set_log_verbosity(VERBOSITY_LEVEL); + -- + wait for 100 ns; + reset_n <= '1'; + + -- Nothing really to do here + setup <= true; + + --------------------------------------------------------------------------- + -- Running + --------------------------------------------------------------------------- + + running <= true; + log_separator_line(VLOW); + log("EMS verification:", VLOW); + log_separator_line(VLOW); + + + -- Enable the Emulator: + -- Enable outputs + csr_write(CSR_OUT_ENABLE_ADDR, X"000000FF"); + + -- Configure Encoder NCO freq + csr_write(CSR_ENC_NCO_INC_ADDR, freq2NCO_inc(200.0e3, CLK_FREQ)); + + -- Init the encoder NCO - Preset Abs-Pos, Free running mode disabled + csr_write(CSR_ENC_CTRL_ADDR, 32X"19"); + + -- Enable the PD generation + -- Init the encoder NCO - Preset Abs-Pos, Free running mode disabled + csr_write(CSR_PD_CTRL_ADDR, 32X"1"); + + config_seq; + -- enable the sequencer + csr_write(std_logic_vector(unsigned(SEQ_CSR_OFFSET)+3), 32x"1"); + log("Sequencer Enabled.", VLOW); + + wait for 50 us; + + --/* + + --------------------------------------------------------------------------- + -- EMS Configuration: + -- Encoder: RS422, Dual-Phase, R/F Edge + -- PD: RS422, Rising Edge only + --------------------------------------------------------------------------- + + log_separator_line(VLOW); + log("EMS Configuration:", VLOW); + log("Encoder: RS422, Dual-Phase, R/F edges", VLOW); + log("PD: RS422, Rising edge", VLOW); + + -- Disable TTL outputs on the emulator + csr_write(CSR_OUT_ENABLE_ADDR, X"000000F0"); + + -- EMS software init + ems_write(CSR_EMS_ENABLE_ADDR, 32x"1"); + + -- disable the EMS during the configuration + ems_write(CSR_EMS_ENABLE_ADDR, 32x"0"); + + -- apply EMS config + ems_write(CSR_EMS_CONFIG_ADDR, 32x"3E0"); + + -- enable the EMS + ems_write(CSR_EMS_ENABLE_ADDR, 32x"E"); + + -- Start the swathe + log("Start swathe #1: DIR-0 first, then DIR-1", VMEDIUM); + start_seq_proc(9x"000"); + + -- wait for the product detect at the beginning of the swathe + wait until pd_out = '1'; + if(signed(abs_position) /= 0) then + log("ERROR: Detected PD at position " & to_string(to_integer(signed(abs_position))) & ".", VLOW); + error_flag <= true; + else + log("Detected PD at position 0, forward swathe", VMEDIUM); + end if; + + wait until signed(abs_position) = 50; + log("Detected end of the forward swathe", VMEDIUM); + + -- wait for the product detect at the beginning of the swathe + wait until pd_out = '1'; + if(signed(abs_position) /= 50) then + log("ERROR: Detected PD at position " & to_string(to_integer(signed(abs_position))) & ".", VLOW); + error_flag <= true; + else + log("Detected PD at position 50, forward swathe", VMEDIUM); + end if; + + wait until signed(abs_position) = 0; + log("Detected end of the bacward swathe", VMEDIUM); + + wait for 20 us; + wait_clk_cycles(5); + + -- Manually clear the PD hysteresis filter + ems_write(CSR_PD_HYST_ADDR, 32x"10020"); + + -- Start the swathe + log("Start swathe #2: DIR-1 first, then DIR-2", VMEDIUM); + start_seq_proc(9x"020"); + + -- wait for the product detect at the beginning of the swathe + wait until pd_out = '1'; + if(signed(abs_position) /= 0) then + log("ERROR: Detected PD at position " & to_string(to_integer(signed(abs_position))) & ".", VLOW); + error_flag <= true; + else + log("Detected PD at position 0, forward swathe", VMEDIUM); + end if; + + wait until signed(abs_position) = -50; + log("Detected end of the forward swathe", VMEDIUM); + + -- wait for the product detect at the beginning of the swathe + wait until pd_out = '1'; + if(signed(abs_position) /= -50) then + log("ERROR: Detected PD at position " & to_string(to_integer(signed(abs_position))) & ".", VLOW); + error_flag <= true; + else + log("Detected PD at position -50, forward swathe", VMEDIUM); + end if; + + wait until signed(abs_position) = 0; + log("Detected end of the bacward swathe", VMEDIUM); + + wait for 20 us; + + --------------------------------------------------------------------------- + -- EMS Configuration: + -- Encoder: TTL, Dual-Phase, R/F Edge + -- PD: TTL, Rising Edge only + --------------------------------------------------------------------------- + + log_separator_line(VLOW); + log("EMS Configuration:", VLOW); + log("Encoder: TTL, Dual-Phase, R/F edges", VLOW); + log("PD: TTL, Rising edge", VLOW); + + -- Disable RS422 outputs on the emulator + csr_write(CSR_OUT_ENABLE_ADDR, X"0000000F"); + + -- Manually clear the PD hysteresis filter + ems_write(CSR_PD_HYST_ADDR, 32x"10020"); + + -- EMS software init + ems_write(CSR_EMS_ENABLE_ADDR, 32x"1"); + + -- disable the EMS during the configuration + ems_write(CSR_EMS_ENABLE_ADDR, 32x"0"); + + -- apply EMS config + ems_write(CSR_EMS_CONFIG_ADDR, 32x"3E5"); + + -- enable the EMS + ems_write(CSR_EMS_ENABLE_ADDR, 32x"E"); + + -- Start the swathe + log("Start swathe #1: DIR-0 first, then DIR-1", VMEDIUM); + start_seq_proc(9x"000"); + + -- wait for the product detect at the beginning of the swathe + wait until pd_out = '1'; + if(signed(abs_position) /= 0) then + log("ERROR: Detected PD at position " & to_string(to_integer(signed(abs_position))) & ".", VLOW); + error_flag <= true; + else + log("Detected PD at position 0, forward swathe", VMEDIUM); + end if; + + wait until signed(abs_position) = 50; + log("Detected end of the forward swathe", VMEDIUM); + + -- wait for the product detect at the beginning of the swathe + wait until pd_out = '1'; + if(signed(abs_position) /= 50) then + log("ERROR: Detected PD at position " & to_string(to_integer(signed(abs_position))) & ".", VLOW); + error_flag <= true; + else + log("Detected PD at position 50, forward swathe", VMEDIUM); + end if; + + wait until signed(abs_position) = 0; + log("Detected end of the bacward swathe", VMEDIUM); + + wait for 20 us; + wait_clk_cycles(5); + + -- Manually clear the PD hysteresis filter + ems_write(CSR_PD_HYST_ADDR, 32x"10020"); + + -- Start the swathe + log("Start swathe #2: DIR-1 first, then DIR-2", VMEDIUM); + start_seq_proc(9x"020"); + + -- wait for the product detect at the beginning of the swathe + wait until pd_out = '1'; + if(signed(abs_position) /= 0) then + log("ERROR: Detected PD at position " & to_string(to_integer(signed(abs_position))) & ".", VLOW); + error_flag <= true; + else + log("Detected PD at position 0, forward swathe", VMEDIUM); + end if; + + wait until signed(abs_position) = -50; + log("Detected end of the forward swathe", VMEDIUM); + + -- wait for the product detect at the beginning of the swathe + wait until pd_out = '1'; + if(signed(abs_position) /= -50) then + log("ERROR: Detected PD at position " & to_string(to_integer(signed(abs_position))) & ".", VLOW); + error_flag <= true; + else + log("Detected PD at position -50, forward swathe", VMEDIUM); + end if; + + wait until signed(abs_position) = 0; + log("Detected end of the bacward swathe", VMEDIUM); + + wait for 20 us; + + --------------------------------------------------------------------------- + -- EMS Configuration: + -- Encoder: RS422, Dual-Phase, R/F Edge + -- PD: TTL, Rising Edge only + --------------------------------------------------------------------------- + + log_separator_line(VLOW); + log("EMS Configuration:", VLOW); + log("Encoder: RS422, Dual-Phase, R/F edges", VLOW); + log("PD: TTL, Rising edge", VLOW); + + -- Disable the unused outputs on the emulator + csr_write(CSR_OUT_ENABLE_ADDR, X"000000E1"); + + -- Manually clear the PD hysteresis filter + ems_write(CSR_PD_HYST_ADDR, 32x"10020"); + + -- EMS software init + ems_write(CSR_EMS_ENABLE_ADDR, 32x"1"); + + -- disable the EMS during the configuration + ems_write(CSR_EMS_ENABLE_ADDR, 32x"0"); + + -- apply EMS config + ems_write(CSR_EMS_CONFIG_ADDR, 32x"3E4"); + + -- enable the EMS + ems_write(CSR_EMS_ENABLE_ADDR, 32x"E"); + + -- Start the swathe + log("Start swathe #1: DIR-0 first, then DIR-1", VMEDIUM); + start_seq_proc(9x"000"); + + -- wait for the product detect at the beginning of the swathe + wait until pd_out = '1'; + if(signed(abs_position) /= 0) then + log("ERROR: Detected PD at position " & to_string(to_integer(signed(abs_position))) & ".", VLOW); + error_flag <= true; + else + log("Detected PD at position 0, forward swathe", VMEDIUM); + end if; + + wait until signed(abs_position) = 50; + log("Detected end of the forward swathe", VMEDIUM); + + -- wait for the product detect at the beginning of the swathe + wait until pd_out = '1'; + if(signed(abs_position) /= 50) then + log("ERROR: Detected PD at position " & to_string(to_integer(signed(abs_position))) & ".", VLOW); + error_flag <= true; + else + log("Detected PD at position 50, forward swathe", VMEDIUM); + end if; + + wait until signed(abs_position) = 0; + log("Detected end of the bacward swathe", VMEDIUM); + + wait for 20 us; + wait_clk_cycles(5); + + -- Manually clear the PD hysteresis filter + ems_write(CSR_PD_HYST_ADDR, 32x"10020"); + + -- Start the swathe + log("Start swathe #2: DIR-1 first, then DIR-2", VMEDIUM); + start_seq_proc(9x"020"); + + -- wait for the product detect at the beginning of the swathe + wait until pd_out = '1'; + if(signed(abs_position) /= 0) then + log("ERROR: Detected PD at position " & to_string(to_integer(signed(abs_position))) & ".", VLOW); + error_flag <= true; + else + log("Detected PD at position 0, forward swathe", VMEDIUM); + end if; + + wait until signed(abs_position) = -50; + log("Detected end of the forward swathe", VMEDIUM); + + -- wait for the product detect at the beginning of the swathe + wait until pd_out = '1'; + if(signed(abs_position) /= -50) then + log("ERROR: Detected PD at position " & to_string(to_integer(signed(abs_position))) & ".", VLOW); + error_flag <= true; + else + log("Detected PD at position -50, forward swathe", VMEDIUM); + end if; + + wait until signed(abs_position) = 0; + log("Detected end of the bacward swathe", VMEDIUM); + + wait for 20 us; + + --------------------------------------------------------------------------- + -- EMS Configuration: + -- Encoder: RS422, Dual-Phase, R/F Edge + -- PD: TTL (NPN), Rising Edge only + --------------------------------------------------------------------------- + + log_separator_line(VLOW); + log("EMS Configuration:", VLOW); + log("Encoder: RS422, Dual-Phase, R/F edges", VLOW); + log("PD: TTL (NPN), Rising edge", VLOW); + + -- Disable the unused outputs on the emulator + csr_write(CSR_OUT_ENABLE_ADDR, X"000000E1"); + + -- Manually clear the PD hysteresis filter + ems_write(CSR_PD_HYST_ADDR, 32x"10020"); + + -- EMS software init + ems_write(CSR_EMS_ENABLE_ADDR, 32x"1"); + + -- disable the EMS during the configuration + ems_write(CSR_EMS_ENABLE_ADDR, 32x"0"); + + -- apply EMS config + ems_write(CSR_EMS_CONFIG_ADDR, 32x"3F4"); + + -- enable the EMS + ems_write(CSR_EMS_ENABLE_ADDR, 32x"E"); + + mask_npn <= '0'; + + -- Start the swathe + log("Start swathe #1: DIR-0 first, then DIR-1", VMEDIUM); + start_seq_proc(9x"000"); + + -- wait for the product detect at the beginning of the swathe + wait until pd_out = '1'; + if(signed(abs_position) /= 0) then + log("ERROR: Detected PD at position " & to_string(to_integer(signed(abs_position))) & ".", VLOW); + error_flag <= true; + else + log("Detected PD at position 0, forward swathe", VMEDIUM); + end if; + + wait until signed(abs_position) = 50; + log("Detected end of the forward swathe", VMEDIUM); + + -- wait for the product detect at the beginning of the swathe + wait until pd_out = '1'; + if(signed(abs_position) /= 50) then + log("ERROR: Detected PD at position " & to_string(to_integer(signed(abs_position))) & ".", VLOW); + error_flag <= true; + else + log("Detected PD at position 50, forward swathe", VMEDIUM); + end if; + + wait until signed(abs_position) = 0; + log("Detected end of the bacward swathe", VMEDIUM); + + wait for 20 us; + wait_clk_cycles(5); + + -- Manually clear the PD hysteresis filter + ems_write(CSR_PD_HYST_ADDR, 32x"10020"); + + -- Start the swathe + log("Start swathe #2: DIR-1 first, then DIR-2", VMEDIUM); + start_seq_proc(9x"020"); + + -- wait for the product detect at the beginning of the swathe + wait until pd_out = '1'; + if(signed(abs_position) /= 0) then + log("ERROR: Detected PD at position " & to_string(to_integer(signed(abs_position))) & ".", VLOW); + error_flag <= true; + else + log("Detected PD at position 0, forward swathe", VMEDIUM); + end if; + + wait until signed(abs_position) = -50; + log("Detected end of the forward swathe", VMEDIUM); + + -- wait for the product detect at the beginning of the swathe + wait until pd_out = '1'; + if(signed(abs_position) /= -50) then + log("ERROR: Detected PD at position " & to_string(to_integer(signed(abs_position))) & ".", VLOW); + error_flag <= true; + else + log("Detected PD at position -50, forward swathe", VMEDIUM); + end if; + + wait until signed(abs_position) = 0; + log("Detected end of the bacward swathe", VMEDIUM); + + mask_npn <= '1'; + + wait for 20 us; + + --------------------------------------------------------------------------- + -- EMS Configuration: + -- Encoder: RS422, Single-Phase (Phase-1), R/F Edge + -- PD: RS422, Rising Edge only + --------------------------------------------------------------------------- + + log_separator_line(VLOW); + log("EMS Configuration:", VLOW); + log("Encoder: RS422, Single-Phase (Ph-1), R/F edges", VLOW); + log("PD: RS422, Rising edge", VLOW); + + -- Disable TTL outputs on the emulator + csr_write(CSR_OUT_ENABLE_ADDR, X"000000B0"); + + -- Manually clear the PD hysteresis filter (hysteresis set to 16 because + -- the swathe is shorter) + ems_write(CSR_PD_HYST_ADDR, 32x"10010"); + + -- EMS software init + ems_write(CSR_EMS_ENABLE_ADDR, 32x"1"); + + -- disable the EMS during the configuration + ems_write(CSR_EMS_ENABLE_ADDR, 32x"0"); + + -- apply EMS config + ems_write(CSR_EMS_CONFIG_ADDR, 32x"3A0"); + + -- enable the EMS + ems_write(CSR_EMS_ENABLE_ADDR, 32x"E"); + + -- Start the swathe + log("Start swathe #1: DIR-0 first, then DIR-1", VMEDIUM); + start_seq_proc(9x"000"); + + -- wait for the product detect at the beginning of the swathe + wait until pd_out = '1'; + if(signed(abs_position) /= 0) then + log("ERROR: Detected PD at position " & to_string(to_integer(signed(abs_position))) & ".", VLOW); + error_flag <= true; + else + log("Detected PD at position 0, forward swathe", VMEDIUM); + end if; + + -- In single-phase mode only the absolute position between the EMS and the + -- emulator differ + wait until signed(abs_position) = 25; + log("Detected end of the forward swathe", VMEDIUM); + + -- wait for the product detect at the beginning of the swathe + wait until pd_out = '1'; + if(signed(abs_position) /= 25) then + log("ERROR: Detected PD at position " & to_string(to_integer(signed(abs_position))) & ".", VLOW); + error_flag <= true; + else + log("Detected PD at position 25, forward swathe", VMEDIUM); + end if; + + wait until signed(abs_position) = 50; + log("Detected end of the bacward swathe", VMEDIUM); + + wait for 20 us; + wait_clk_cycles(5); + + -- Manually clear the PD hysteresis filter + ems_write(CSR_PD_HYST_ADDR, 32x"10010"); + + -- Start the swathe + log("Start swathe #2: DIR-1 first, then DIR-2", VMEDIUM); + start_seq_proc(9x"020"); + + -- wait for the product detect at the beginning of the swathe + wait until pd_out = '1'; + if(signed(abs_position) /= 50) then + log("ERROR: Detected PD at position " & to_string(to_integer(signed(abs_position))) & ".", VLOW); + error_flag <= true; + else + log("Detected PD at position 50, forward swathe", VMEDIUM); + end if; + + -- The position keeps increasing because the EMS in working in single phase + -- mode + wait until signed(abs_position) = 75; + log("Detected end of the forward swathe", VMEDIUM); + + -- wait for the product detect at the beginning of the swathe + wait until pd_out = '1'; + if(signed(abs_position) /= 75) then + log("ERROR: Detected PD at position " & to_string(to_integer(signed(abs_position))) & ".", VLOW); + error_flag <= true; + else + log("Detected PD at position 75, forward swathe", VMEDIUM); + end if; + + wait until signed(abs_position) = 100; + log("Detected end of the bacward swathe", VMEDIUM); + + wait for 20 us; + + --------------------------------------------------------------------------- + -- EMS Configuration: + -- Encoder: RS422, Single-Phase (Phase-2), R/F Edge + -- PD: RS422, Rising Edge only + --------------------------------------------------------------------------- + + log_separator_line(VLOW); + log("EMS Configuration:", VLOW); + log("Encoder: RS422, Single-Phase (Ph-2), R/F edges", VLOW); + log("PD: RS422, Rising edge", VLOW); + + -- Disable TTL outputs on the emulator + csr_write(CSR_OUT_ENABLE_ADDR, X"000000D0"); + + -- Manually clear the PD hysteresis filter (hysteresis set to 16 because + -- the swathe is shorter) + ems_write(CSR_PD_HYST_ADDR, 32x"10010"); + + -- set the initial value of the abosule position to -50 + ems_write(CSR_ABS_POS_PRESET_ADDR, x"FFFFFFCE"); + log("EMS position set to -50", VMEDIUM); + + -- EMS software init + ems_write(CSR_EMS_ENABLE_ADDR, 32x"1"); + + -- disable the EMS during the configuration + ems_write(CSR_EMS_ENABLE_ADDR, 32x"0"); + + -- preset the absolute position + ems_write(CSR_EMS_CONFIG_ADDR, 32x"800"); + + -- apply EMS config + ems_write(CSR_EMS_CONFIG_ADDR, 32x"3C0"); + + -- enable the EMS + ems_write(CSR_EMS_ENABLE_ADDR, 32x"E"); + + -- Start the swathe + log("Start swathe #1: DIR-0 first, then DIR-1", VMEDIUM); + start_seq_proc(9x"000"); + + -- wait for the product detect at the beginning of the swathe + wait until pd_out = '1'; + if(signed(abs_position) /= -50) then + log("ERROR: Detected PD at position " & to_string(to_integer(signed(abs_position))) & ".", VLOW); + error_flag <= true; + else + log("Detected PD at position -50, forward swathe", VMEDIUM); + end if; + + -- In single-phase mode only the absolute position between the EMS and the + -- emulator differ + wait until signed(abs_position) = -25; + log("Detected end of the forward swathe", VMEDIUM); + + -- wait for the product detect at the beginning of the swathe + wait until pd_out = '1'; + if(signed(abs_position) /= -25) then + log("ERROR: Detected PD at position " & to_string(to_integer(signed(abs_position))) & ".", VLOW); + error_flag <= true; + else + log("Detected PD at position -25, forward swathe", VMEDIUM); + end if; + + wait until signed(abs_position) = 0; + log("Detected end of the bacward swathe", VMEDIUM); + + wait for 20 us; + wait_clk_cycles(5); + + -- Manually clear the PD hysteresis filter + ems_write(CSR_PD_HYST_ADDR, 32x"10010"); + + -- Start the swathe + log("Start swathe #2: DIR-1 first, then DIR-2", VMEDIUM); + start_seq_proc(9x"020"); + + -- wait for the product detect at the beginning of the swathe + wait until pd_out = '1'; + if(signed(abs_position) /= 0) then + log("ERROR: Detected PD at position " & to_string(to_integer(signed(abs_position))) & ".", VLOW); + error_flag <= true; + else + log("Detected PD at position 0, forward swathe", VMEDIUM); + end if; + + -- The position keeps increasing because the EMS in working in single phase + -- mode + wait until signed(abs_position) = 25; + log("Detected end of the forward swathe", VMEDIUM); + + -- wait for the product detect at the beginning of the swathe + wait until pd_out = '1'; + if(signed(abs_position) /= 25) then + log("ERROR: Detected PD at position " & to_string(to_integer(signed(abs_position))) & ".", VLOW); + error_flag <= true; + else + log("Detected PD at position 25, forward swathe", VMEDIUM); + end if; + + wait until signed(abs_position) = 50; + log("Detected end of the bacward swathe", VMEDIUM); + + wait for 20 us; + + --------------------------------------------------------------------------- + -- EMS Configuration: + -- Encoder: RS422, Single-Phase (Phase-1), Single-Edge (Rising) + -- PD: RS422, Rising Edge only + --------------------------------------------------------------------------- + + log_separator_line(VLOW); + log("EMS Configuration:", VLOW); + log("Encoder: RS422, Single-Phase (Ph-1), Single-Edge (Rising)", VLOW); + log("PD: RS422, Rising edge", VLOW); + + -- Disable TTL outputs on the emulator + csr_write(CSR_OUT_ENABLE_ADDR, X"000000B0"); + + -- Manually clear the PD hysteresis filter (hysteresis set to 8 because + -- the swathe is shorter) + ems_write(CSR_PD_HYST_ADDR, 32x"10008"); + + -- set the initial value of the abosule position to 100 + ems_write(CSR_ABS_POS_PRESET_ADDR, 32x"64"); + log("EMS position set to 100", VMEDIUM); + + -- EMS software init + ems_write(CSR_EMS_ENABLE_ADDR, 32x"1"); + + -- disable the EMS during the configuration + ems_write(CSR_EMS_ENABLE_ADDR, 32x"0"); + + -- preset the absolute position + ems_write(CSR_EMS_CONFIG_ADDR, 32x"800"); + + -- apply EMS config + ems_write(CSR_EMS_CONFIG_ADDR, 32x"2A0"); + + -- enable the EMS + ems_write(CSR_EMS_ENABLE_ADDR, 32x"E"); + + -- Start the swathe + log("Start swathe #1: DIR-0 first, then DIR-1", VMEDIUM); + start_seq_proc(9x"000"); + + -- wait for the product detect at the beginning of the swathe + wait until pd_out = '1'; + if(signed(abs_position) /= 100) then + log("ERROR: Detected PD at position " & to_string(to_integer(signed(abs_position))) & ".", VLOW); + error_flag <= true; + else + log("Detected PD at position 100, forward swathe", VMEDIUM); + end if; + + -- In single-phase mode only the absolute position between the EMS and the + -- emulator differ + wait until signed(abs_position) = 113; + log("Detected end of the forward swathe", VMEDIUM); + + -- wait for the product detect at the beginning of the swathe + wait until pd_out = '1'; + if(signed(abs_position) /= 113) then + log("ERROR: Detected PD at position " & to_string(to_integer(signed(abs_position))) & ".", VLOW); + error_flag <= true; + else + log("Detected PD at position 113, forward swathe", VMEDIUM); + end if; + + wait until signed(abs_position) = 125; + log("Detected end of the bacward swathe", VMEDIUM); + + wait for 20 us; + wait_clk_cycles(5); + + -- Manually clear the PD hysteresis filter + ems_write(CSR_PD_HYST_ADDR, 32x"10008"); + + -- Start the swathe + log("Start swathe #2: DIR-1 first, then DIR-2", VMEDIUM); + start_seq_proc(9x"020"); + + -- wait for the product detect at the beginning of the swathe + wait until pd_out = '1'; + if(signed(abs_position) /= 125) then + log("ERROR: Detected PD at position " & to_string(to_integer(signed(abs_position))) & ".", VLOW); + error_flag <= true; + else + log("Detected PD at position 125, forward swathe", VMEDIUM); + end if; + + -- The position keeps increasing because the EMS in working in single phase + -- mode + wait until signed(abs_position) = 138; + log("Detected end of the forward swathe", VMEDIUM); + + -- wait for the product detect at the beginning of the swathe + wait until pd_out = '1'; + if(signed(abs_position) /= 138) then + log("ERROR: Detected PD at position " & to_string(to_integer(signed(abs_position))) & ".", VLOW); + error_flag <= true; + else + log("Detected PD at position 138, forward swathe", VMEDIUM); + end if; + + wait until signed(abs_position) = 150; + log("Detected end of the bacward swathe", VMEDIUM); + + wait for 20 us; + + --------------------------------------------------------------------------- + -- EMS Configuration: + -- Encoder: RS422, Single-Phase (Phase-1), Single-Edge (Falling) + -- PD: RS422, Rising Edge only + --------------------------------------------------------------------------- + + log_separator_line(VLOW); + log("EMS Configuration:", VLOW); + log("Encoder: RS422, Single-Phase (Ph-1), Single-Edge (Falling)", VLOW); + log("PD: RS422, Rising edge", VLOW); + + -- Disable TTL outputs on the emulator + csr_write(CSR_OUT_ENABLE_ADDR, X"000000B0"); + + -- Manually clear the PD hysteresis filter (hysteresis set to 8 because + -- the swathe is shorter) + ems_write(CSR_PD_HYST_ADDR, 32x"10008"); + + -- set the initial value of the abosule position to 100 + ems_write(CSR_ABS_POS_PRESET_ADDR, 32x"64"); + log("EMS position set to 100", VMEDIUM); + + -- EMS software init + ems_write(CSR_EMS_ENABLE_ADDR, 32x"1"); + + -- disable the EMS during the configuration + ems_write(CSR_EMS_ENABLE_ADDR, 32x"0"); + + -- preset the absolute position + ems_write(CSR_EMS_CONFIG_ADDR, 32x"800"); + + -- apply EMS config + ems_write(CSR_EMS_CONFIG_ADDR, 32x"320"); + + -- enable the EMS + ems_write(CSR_EMS_ENABLE_ADDR, 32x"E"); + + -- Start the swathe + log("Start swathe #1: DIR-0 first, then DIR-1", VMEDIUM); + start_seq_proc(9x"000"); + + -- wait for the product detect at the beginning of the swathe + wait until pd_out = '1'; + if(signed(abs_position) /= 100) then + log("ERROR: Detected PD at position " & to_string(to_integer(signed(abs_position))) & ".", VLOW); + error_flag <= true; + else + log("Detected PD at position 100, forward swathe", VMEDIUM); + end if; + + -- In single-phase mode only the absolute position between the EMS and the + -- emulator differ + wait until signed(abs_position) = 112; + log("Detected end of the forward swathe", VMEDIUM); + + -- wait for the product detect at the beginning of the swathe + wait until pd_out = '1'; + if(signed(abs_position) /= 112) then + log("ERROR: Detected PD at position " & to_string(to_integer(signed(abs_position))) & ".", VLOW); + error_flag <= true; + else + log("Detected PD at position 112, forward swathe", VMEDIUM); + end if; + + wait until signed(abs_position) = 125; + log("Detected end of the bacward swathe", VMEDIUM); + + wait for 20 us; + wait_clk_cycles(5); + + -- Manually clear the PD hysteresis filter + ems_write(CSR_PD_HYST_ADDR, 32x"10008"); + + -- Start the swathe + log("Start swathe #2: DIR-1 first, then DIR-2", VMEDIUM); + start_seq_proc(9x"020"); + + -- wait for the product detect at the beginning of the swathe + wait until pd_out = '1'; + if(signed(abs_position) /= 125) then + log("ERROR: Detected PD at position " & to_string(to_integer(signed(abs_position))) & ".", VLOW); + error_flag <= true; + else + log("Detected PD at position 125, forward swathe", VMEDIUM); + end if; + + -- The position keeps increasing because the EMS in working in single phase + -- mode + wait until signed(abs_position) = 137; + log("Detected end of the forward swathe", VMEDIUM); + + -- wait for the product detect at the beginning of the swathe + wait until pd_out = '1'; + if(signed(abs_position) /= 137) then + log("ERROR: Detected PD at position " & to_string(to_integer(signed(abs_position))) & ".", VLOW); + error_flag <= true; + else + log("Detected PD at position 137, forward swathe", VMEDIUM); + end if; + + wait until signed(abs_position) = 150; + log("Detected end of the bacward swathe", VMEDIUM); + + wait for 20 us; + + --------------------------------------------------------------------------- + -- Test the remaining features, SW PD, Kickstart, SW steps .... + --------------------------------------------------------------------------- + + log_separator_line(VLOW); + log("Miscellaneous checks:", VLOW); + log_separator_line(VLOW); + + -- Check the PD on the falling edge + + -- Enable RS422 outputs on the emulator + csr_write(CSR_OUT_ENABLE_ADDR, X"000000F0"); + + -- EMS software init + ems_write(CSR_EMS_ENABLE_ADDR, 32x"1"); + + -- disable the EMS during the configuration + ems_write(CSR_EMS_ENABLE_ADDR, 32x"0"); + + -- apply EMS config: + -- Enc RS422 + SW steps, Dual-~Phase, R/F edges + -- PD RS422, Falling edge + ems_write(CSR_EMS_CONFIG_ADDR, 32x"5E2"); + + -- enable the EMS + ems_write(CSR_EMS_ENABLE_ADDR, 32x"E"); + + log("Checking detection of PD on the falling edge", VMEDIUM); + + -- issue a PD from the emulator: + csr_write(CSR_PD_CTRL_ADDR, 32X"3"); + + wait until filt_pd = '1' and filt_pd'event; + -- Check that the PD count is still 0 + ems_read(work.ems_0_pkg.CSR_PD_CNT_ADDR, data); + if(unsigned(data(31 downto 16)) /= 0) then + log("ERROR: Detected unexpected PD before the falling edge.", VLOW); + error_flag <= true; + end if; + -- wait for the falling edge + wait until filt_pd = '0' and filt_pd'event; + wait_clk_cycles(4); + -- check the PD count + ems_read(work.ems_0_pkg.CSR_PD_CNT_ADDR, data); + if(unsigned(data(31 downto 16)) /= 1) then + log("ERROR: PD count must be 1 after the PD falling edge.", VLOW); + error_flag <= true; + else + log("Detected PD on the falling edge.", VMEDIUM); + end if; + + -- Verify that sw-steps are processed also when the RS422 input is selected + for n in 0 to 9 loop + ems_write(CSR_SW_CTRL_ADDR, 32x"10"); + wait_clk_cycles(10); + end loop; -- n + if(signed(abs_position) /= 110) then + log("ERROR: Failed to capture sw_pos_step in RS422 mode.", VLOW); + error_flag <= true; + end if; + for n in 0 to 19 loop + ems_write(CSR_SW_CTRL_ADDR, 32x"20"); + wait_clk_cycles(10); + end loop; -- n + if(signed(abs_position) /= 90) then + log("ERROR: Failed to capture sw_neg_step in RS422 mode.", VLOW); + error_flag <= true; + else + log("Completed SW step check.", VMEDIUM); + end if; + + -- issue a kickstart + ems_write(CSR_SW_CTRL_ADDR, 32x"2"); + log("Issued kickstart PD.", VMEDIUM); + wait until pd_out = '1'; + log("Detected kickstart PD.", VMEDIUM); + -- check that the PD count has not changed + wait_clk_cycles(5); + ems_read(work.ems_0_pkg.CSR_PD_CNT_ADDR, data); + if(unsigned(data(15 downto 0)) /= 1) then + log("ERROR: Detected unexpected increment of the PD counter.", VLOW); + error_flag <= true; + end if; + + -- Now disable the EMS and check that kickstart still works + ems_write(CSR_EMS_ENABLE_ADDR, 32x"0"); + -- issue a kickstart + ems_write(CSR_SW_CTRL_ADDR, 32x"2"); + log("Issued kickstart PD (EMS disabled).", VMEDIUM); + wait until pd_out = '1'; + log("Detected kickstart PD.", VMEDIUM); + -- check that the PD count has not changed + wait_clk_cycles(5); + ems_read(work.ems_0_pkg.CSR_PD_CNT_ADDR, data); + if(unsigned(data(15 downto 0)) /= 1) then + log("ERROR: Detected unexpected increment of the PD counter.", VLOW); + error_flag <= true; + end if; + + -- restore the EMS enable + ems_write(CSR_EMS_ENABLE_ADDR, 32x"E"); + + -- Issue a SW PD, verify that the previous kickstart have not triggered the + -- hysteresis filter, but a SW PD will + ems_write(CSR_SW_CTRL_ADDR, 32x"1"); + log("Issued SW PD.", VMEDIUM); + wait until pd_out = '1'; + log("Detected SW PD.", VMEDIUM); + -- check that the PD count has changed + wait_clk_cycles(5); + ems_read(work.ems_0_pkg.CSR_PD_CNT_ADDR, data); + if(unsigned(data(15 downto 0)) /= 2) then + log("ERROR: Detected wrong value on the PD counter.", VLOW); + error_flag <= true; + end if; + wait_clk_cycles(5); + + -- Now issue another PD, make sure it gets filtered because of the hysteresis + ems_write(CSR_SW_CTRL_ADDR, 32x"1"); + log("Issued SW PD (to be filtered by hysteresis).", VMEDIUM); + wait_clk_cycles(10); + if(unsigned(data(15 downto 0)) /= 2) then + log("ERROR: Detected wrong value on the PD counter.", VLOW); + error_flag <= true; + end if; + wait_clk_cycles(5); + + -- Clear the hysteresis filter, check that the next PD is taken + ems_write(CSR_PD_HYST_ADDR, 32x"1000A"); + + ems_write(CSR_SW_CTRL_ADDR, 32x"1"); + log("Issued SW PD.", VMEDIUM); + wait until pd_out = '1'; + log("Detected SW PD.", VMEDIUM); + + log("Completed.", VLOW); + + wait_clk_cycles(10); + + wait for 50 us; + + --------------------------------------------------------------------------- + -- Test the input filters + --------------------------------------------------------------------------- + + log_separator_line(VLOW); + log("Filters Checks:", VLOW); + log_separator_line(VLOW); + + log("Manually force the RS422 inputs:", VLOW); + + -- Check filtering of active high pulses + log("Filter active high pulses:", VLOW); + for n in 2 to 10 loop + + ems_write(CSR_FILT_CFG_ADDR, X"000F01" & std_logic_vector(to_unsigned(n,8))); + log("EMS Filter order set to " & to_string(n) & ":", VLOW); + wait_clk_cycles(20); + + for m in 1 to 5 loop + rs422_pd <= force '1'; + rs422_enc_p1 <= force '1'; + rs422_enc_p2 <= force '1'; + rs422_enc_zp <= force '1'; + wait_clk_cycles(m); + rs422_pd <= force '0'; + rs422_enc_p1 <= force '0'; + rs422_enc_p2 <= force '0'; + rs422_enc_zp <= force '0'; + wait_clk_cycles(10); + end loop; -- m + wait_clk_cycles(20); + end loop; -- n + + -- Check filtering of active low pulses + log("Filter active low pulses:", VLOW); + rs422_pd <= force '1'; + rs422_enc_p1 <= force '1'; + rs422_enc_p2 <= force '1'; + rs422_enc_zp <= force '1'; + wait_clk_cycles(50); + for n in 2 to 10 loop + + ems_write(CSR_FILT_CFG_ADDR, X"000F01" & std_logic_vector(to_unsigned(n,8))); + log("EMS Filter order set to " & to_string(n) & ":", VLOW); + wait_clk_cycles(20); + + for m in 1 to 5 loop + rs422_pd <= force '0'; + rs422_enc_p1 <= force '0'; + rs422_enc_p2 <= force '0'; + rs422_enc_zp <= force '0'; + wait_clk_cycles(m); + rs422_pd <= force '1'; + rs422_enc_p1 <= force '1'; + rs422_enc_p2 <= force '1'; + rs422_enc_zp <= force '1'; + wait_clk_cycles(10); + end loop; -- m + wait_clk_cycles(20); + end loop; -- n + + rs422_pd <= release; + rs422_enc_p1 <= release; + rs422_enc_p2 <= release; + rs422_enc_zp <= release; + + log("Completed.", VLOW); + + --*/ + + wait for 20 us; + + --------------------------------------------------------------------------- + -- EMS Configuration: + -- Multiplier ON : M = 1 + -- Encoder: RS422, Dual-Phase, R/F Edge + -- PD: RS422, Rising Edge only + --------------------------------------------------------------------------- + + log_separator_line(VLOW); + log("EMS Configuration:", VLOW); + log("Multiplier: ON, M = 1", VLOW); + log("Encoder: RS422, Dual-Phase, R/F edges", VLOW); + log("PD: RS422, Rising edge", VLOW); + + -- Disable TTL outputs on the emulator + csr_write(CSR_OUT_ENABLE_ADDR, X"000000F0"); + + -- EMS software init + ems_write(CSR_EMS_ENABLE_ADDR, 32x"1"); + + -- disable the EMS during the configuration + ems_write(CSR_EMS_ENABLE_ADDR, 32x"0"); + + -- set the initial position to 100 + ems_write(CSR_ABS_POS_PRESET_ADDR, 32x"64"); + + -- apply EMS config + ems_write(CSR_EMS_CONFIG_ADDR, 32x"BE0"); + + -- configure the multiplier (Enabled, M = 1, AVG_STEPS = 8) + ems_write(CSR_MULT_CFG_ADDR, 32x"0800"); + ems_write(CSR_MULT_CFG_ADDR, 32x"0801"); + + -- enable the EMS + ems_write(CSR_EMS_ENABLE_ADDR, 32x"E"); + + -- Start the swathe + log("Start swathe #1: DIR-0 first, then DIR-1", VMEDIUM); + start_seq_proc(9x"000"); + + -- wait for the product detect at the beginning of the swathe + wait until pd_out = '1'; + if(signed(abs_position) /= 100) then + log("ERROR: Detected PD at position " & to_string(to_integer(signed(abs_position))) & ".", VLOW); + error_flag <= true; + else + log("Detected PD at position 0, forward swathe", VMEDIUM); + end if; + + wait until signed(abs_position) = 150; + log("Detected end of the forward swathe", VMEDIUM); + + -- wait for the product detect at the beginning of the swathe + wait until pd_out = '1'; + if(signed(abs_position) /= 150) then + log("ERROR: Detected PD at position " & to_string(to_integer(signed(abs_position))) & ".", VLOW); + error_flag <= true; + else + log("Detected PD at position 50, forward swathe", VMEDIUM); + end if; + + wait until signed(abs_position) = 100; + log("Detected end of the bacward swathe", VMEDIUM); + + wait for 20 us; + wait_clk_cycles(5); + + -- Manually clear the PD hysteresis filter + ems_write(CSR_PD_HYST_ADDR, 32x"10020"); + + -- Start the swathe + log("Start swathe #2: DIR-1 first, then DIR-2", VMEDIUM); + start_seq_proc(9x"020"); + + -- wait for the product detect at the beginning of the swathe + wait until pd_out = '1'; + if(signed(abs_position) /= 100) then + log("ERROR: Detected PD at position " & to_string(to_integer(signed(abs_position))) & ".", VLOW); + error_flag <= true; + else + log("Detected PD at position 0, forward swathe", VMEDIUM); + end if; + + wait until signed(abs_position) = 50; + log("Detected end of the forward swathe", VMEDIUM); + + -- wait for the product detect at the beginning of the swathe + wait until pd_out = '1'; + if(signed(abs_position) /= 50) then + log("ERROR: Detected PD at position " & to_string(to_integer(signed(abs_position))) & ".", VLOW); + error_flag <= true; + else + log("Detected PD at position 50, forward swathe", VMEDIUM); + end if; + + wait until signed(abs_position) = 100; + log("Detected end of the bacward swathe", VMEDIUM); + + wait for 20 us; + + --------------------------------------------------------------------------- + -- EMS Configuration: + -- Multiplier ON : M = 4 + -- Encoder: RS422, Dual-Phase, R/F Edge + -- PD: RS422, Rising Edge only + --------------------------------------------------------------------------- + + log_separator_line(VLOW); + log("EMS Configuration:", VLOW); + log("Multiplier: ON, M = 4", VLOW); + log("Encoder: RS422, Dual-Phase, R/F edges", VLOW); + log("PD: RS422, Rising edge", VLOW); + + -- Disable TTL outputs on the emulator + csr_write(CSR_OUT_ENABLE_ADDR, X"000000F0"); + + -- EMS software init + ems_write(CSR_EMS_ENABLE_ADDR, 32x"1"); + + -- disable the EMS during the configuration + ems_write(CSR_EMS_ENABLE_ADDR, 32x"0"); + + -- set the initial position to 100 + ems_write(CSR_ABS_POS_PRESET_ADDR, 32x"64"); + + -- apply EMS config + ems_write(CSR_EMS_CONFIG_ADDR, 32x"BE0"); + + -- configure the multiplier (Enabled, M = 4, AVG_STEPS = 8) + ems_write(CSR_MULT_CFG_ADDR, 32x"0820"); + ems_write(CSR_MULT_CFG_ADDR, 32x"0821"); + + -- enable the EMS + ems_write(CSR_EMS_ENABLE_ADDR, 32x"E"); + + -- Start the swathe + log("Start swathe #1: DIR-0 first, then DIR-1", VMEDIUM); + start_seq_proc(9x"000"); + + -- wait for the product detect at the beginning of the swathe + wait until pd_out = '1'; + if(signed(abs_position) /= 100) then + log("ERROR: Detected PD at position " & to_string(to_integer(signed(abs_position))) & ".", VLOW); + error_flag <= true; + else + log("Detected PD at position 100, forward swathe", VMEDIUM); + end if; + + wait until signed(abs_position) = 300; + log("Detected end of the forward swathe", VMEDIUM); + + -- wait for the product detect at the beginning of the swathe + wait until pd_out = '1'; + if(signed(abs_position) /= 300) then + log("ERROR: Detected PD at position " & to_string(to_integer(signed(abs_position))) & ".", VLOW); + error_flag <= true; + else + log("Detected PD at position 300, forward swathe", VMEDIUM); + end if; + + wait until signed(abs_position) = 100; + log("Detected end of the bacward swathe", VMEDIUM); + + -- make sure that you wait enough time to have a time-out in the velocity estimation + wait for 60 us; + wait_clk_cycles(5); + + -- Manually clear the PD hysteresis filter + ems_write(CSR_PD_HYST_ADDR, 32x"10020"); + + -- Start the swathe + log("Start swathe #2: DIR-1 first, then DIR-2", VMEDIUM); + start_seq_proc(9x"020"); + + -- wait for the product detect at the beginning of the swathe + wait until pd_out = '1'; + if(signed(abs_position) /= 100) then + log("ERROR: Detected PD at position " & to_string(to_integer(signed(abs_position))) & ".", VLOW); + error_flag <= true; + else + log("Detected PD at position 100, forward swathe", VMEDIUM); + end if; + + wait until signed(abs_position) = -100; + log("Detected end of the forward swathe", VMEDIUM); + + -- wait for the product detect at the beginning of the swathe + wait until pd_out = '1'; + if(signed(abs_position) /= -100) then + log("ERROR: Detected PD at position " & to_string(to_integer(signed(abs_position))) & ".", VLOW); + error_flag <= true; + else + log("Detected PD at position -100, forward swathe", VMEDIUM); + end if; + + wait until signed(abs_position) = 100; + log("Detected end of the bacward swathe", VMEDIUM); + + wait for 20 us; + + --------------------------------------------------------------------------- + -- End + --------------------------------------------------------------------------- + + passed <= true after 100 ns; + wait; + + end process pTEST_PROC; + + failed <= error_flag after 100 ns; + + CHECK_SIM_TIMEOUT: process + begin -- process CHECK_SIM_TIMEOUT + while now < MAX_SIM_TIME loop + wait for 100 us; + end loop; + test_timeout <= true; + wait; + end process CHECK_SIM_TIMEOUT; + + pREPORT_RESULT : process + begin + wait until failed = true or passed = true or test_timeout = 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); + elsif(test_timeout = true) then + log("FAILURE: test achieved max-sim-time without reaching ", VLOW); + log(" failed/passed condition.", VLOW); + end if; + log_separator_line(VLOW); + test_completed <= true; + end process pREPORT_RESULT; + + +end architecture behav; From 2860b68e3cb8752bcfdbdb8828d76e64245303be Mon Sep 17 00:00:00 2001 From: gianmarcogirau Date: Tue, 17 Dec 2019 13:46:29 +0000 Subject: [PATCH 04/15] CORE-73 - Imported Drop-Watch Generator from the SMB repository --- .../0/doc/drop_watch_gen_0.json | 166 +++++++++ generic_ip/drop_watch_gen/0/sim/com_dw.do | 28 ++ .../drop_watch_gen/0/src/drop_watch_gen_0.vhd | 320 ++++++++++++++++++ .../0/src/drop_watch_gen_0_pkg.vhd | 31 ++ generic_ip/ems/0/doc/ems_0.json | 28 +- 5 files changed, 559 insertions(+), 14 deletions(-) create mode 100644 generic_ip/drop_watch_gen/0/doc/drop_watch_gen_0.json create mode 100644 generic_ip/drop_watch_gen/0/sim/com_dw.do create mode 100644 generic_ip/drop_watch_gen/0/src/drop_watch_gen_0.vhd create mode 100644 generic_ip/drop_watch_gen/0/src/drop_watch_gen_0_pkg.vhd diff --git a/generic_ip/drop_watch_gen/0/doc/drop_watch_gen_0.json b/generic_ip/drop_watch_gen/0/doc/drop_watch_gen_0.json new file mode 100644 index 0000000..95c7af5 --- /dev/null +++ b/generic_ip/drop_watch_gen/0/doc/drop_watch_gen_0.json @@ -0,0 +1,166 @@ +[{ + "ip_name": "drop_watch_gen_0", + "bus": "csr", + "description": "Drop-Watch Generator", + "registers": { + "ip_id" : { + "address" : "0", + "width" : "32", + "description" : "Unique ID for this IP block", + "fields": { + "ip_number" : { + "type" : "c", + "bit_len" : "8", + "reset" : "0x20", + "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" : "0x01", + "description" : "Minor number" + }, + "major_number" : { + "type" : "c", + "bit_len" : "8", + "reset" : "0x00", + "description" : "Major number" + + }, + "reserved" : { + "type" : "rsv", + "bit_len" : "16", + "description" : "Reserved bits" + } + } + }, + "dw_csr" : { + "address" : "2", + "width" : "26", + "description" : "Drop-Watch Control and Status", + "fields": { + "dw_en" : { + "type" : "w", + "bit_len" : "1", + "reset" : "0x0", + "description" : "Drop-Watch enable" + }, + "dw_polarity" : { + "type" : "w", + "bit_len" : "1", + "reset" : "0x0", + "description" : "Drop-Watch polarity" + }, + "input_polarity" : { + "type" : "w", + "bit_len" : "1", + "reset" : "0x0", + "description" : "input polarity" + }, + "Reserved-0" : { + "type" : "rsv", + "bit_len" : "2", + "description" : "Reserved bits" + }, + "seq_start_req" : { + "type" : "w", + "bit_len" : "1", + "reset" : "0x0", + "description" : "sequencer start request" + }, + "seq_busy" : { + "type" : "r", + "bit_len" : "1", + "reset" : "0x0", + "description" : "sequencer busy" + }, + "Reserved-1" : { + "type" : "rsv", + "bit_len" : "1", + "description" : "Reserved bit" + }, + "seq_start_addr" : { + "type" : "w", + "bit_len" : "8", + "reset" : "0x0", + "description" : "sequencer start address" + }, + "Reserved-2" : { + "type" : "rsv", + "bit_len" : "8", + "description" : "Reserved bits" + }, + "dw_sw_drive_en" : { + "type" : "w", + "bit_len" : "1", + "reset" : "0x0", + "description" : "Enable the Drop-Watch output to be driven through a control register (dw_sw_value), bypassing the sequencer and the queue&delay blocks" + }, + "dw_sw_value" : { + "type" : "w", + "bit_len" : "1", + "reset" : "0x0", + "description" : "Specifies the value of the Drop-Watch output, when dw_sw_drive_en is asserted" + } + } + }, + "dw_delay" : { + "address" : "3", + "type" : "w", + "width" : "32", + "reset" : "0x0", + "description" : "Drop-Watch delay" + }, + "dw_pulse_width" : { + "address" : "4", + "type" : "w", + "width" : "24", + "reset" : "0x03E8", + "description" : "Drop-Watch pulse-width" + }, + "dw_cnt": { + "address": "5", + "width": "18", + "description": "Drop-Watch count", + "fields": { + "dw_cnt": { + "type": "r", + "bit_len": "16", + "reset": "0x0", + "description": "Drop-Watch events count" + }, + "rst_dw_cnt": { + "type": "w", + "bit_len": "1", + "reset": "0x0", + "description": "Reset the drop-watch count" + }, + "queue_ovfl_error": { + "type": "r", + "bit_len": "1", + "reset": "0x0", + "description": "Drop-watch queue overflow error" + } + } + } + } +}] \ No newline at end of file diff --git a/generic_ip/drop_watch_gen/0/sim/com_dw.do b/generic_ip/drop_watch_gen/0/sim/com_dw.do new file mode 100644 index 0000000..41c7526 --- /dev/null +++ b/generic_ip/drop_watch_gen/0/sim/com_dw.do @@ -0,0 +1,28 @@ +# Simulation macro + +# Cleanup libraries +foreach lib [list work] { + file delete -force -- $lib + vlib $lib +} + +#.main clear + +set COMMON_PATH ../../../common/0/src +set GEN_SEQ ../../../generic_sequencer/15/src +set DW_SRC ../src + +set WORKLIB work + +vlib ./work +vmap work ./work + +# Compile the UUT +vcom -2008 -work $WORKLIB $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 $GEN_SEQ/altera/generic_seq_ram_15.vhd +vcom -2008 -work $WORKLIB $GEN_SEQ/generic_sequencer_15_pkg.vhd +vcom -2008 -work $WORKLIB $GEN_SEQ/generic_sequencer_15.vhd +vcom -2008 -work $WORKLIB $DW_SRC/drop_watch_gen_0_pkg.vhd +vcom -2008 -work $WORKLIB $DW_SRC/drop_watch_gen_0.vhd \ No newline at end of file diff --git a/generic_ip/drop_watch_gen/0/src/drop_watch_gen_0.vhd b/generic_ip/drop_watch_gen/0/src/drop_watch_gen_0.vhd new file mode 100644 index 0000000..3a72486 --- /dev/null +++ b/generic_ip/drop_watch_gen/0/src/drop_watch_gen_0.vhd @@ -0,0 +1,320 @@ +------------------------------------------------------------------------------- +-- Title : drop_watch_gen_0 +-- Project : Generic-IPs +------------------------------------------------------------------------------- +-- File : drop_watch_gen_0.vhd +-- Author : Gianmarco Girau +-- Company : Global Inkjet Systems +-- Created : 2016-05-29 +-- Last update: 2019-12-17 +-- SVN ID : Git +-- Standard : VHDL'93 +------------------------------------------------------------------------------- +-- Description: +-- Simple Drop-Watch generator, supporting queueing of multiple events, +-- programmable delay and pulse width, multiple source selection and +-- programmable polarity reversal (active high/low selection) +------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +library work; +use work.drop_watch_gen_0_pkg.all; + +entity drop_watch_gen_0 is + port( + reset_n : in std_logic; + clk : in std_logic; + input_src : in std_logic_vector( 3 downto 0); + drop_watch : out std_logic; + -- Avalon MM + avs_address : in std_logic_vector( 9 downto 0); + avs_write : in std_logic; + avs_writedata : in std_logic_vector(31 downto 0); + avs_read : in std_logic; + avs_readdatavalid : out std_logic; + avs_readdata : out std_logic_vector(31 downto 0)); +end drop_watch_gen_0; + +architecture RTL of drop_watch_gen_0 is + + constant CSR_IP_ID : std_logic_vector(31 downto 0) := x"0000FF20"; + constant CSR_IP_VER : std_logic_vector(31 downto 0) := x"00000001"; + + signal dw_src, dw_src_d, pulse_gen, pulse_cnt_tc : std_logic; + signal dw_gen_en, queue_overflow_err, drop_watch_i : std_logic; + signal dw_polarity, init_qd, dw_i, pulse_gen_d : std_logic; + signal input_polarity, seq_start_req : std_logic; + signal seq_csr_write, seq_csr_read : std_logic; + signal seq_busy, seq_read, seq_write, avs_write_i : std_logic; + signal avs_read_i, avs_read_d, rst_drop_cnt : std_logic; + signal bus_valid, pulse_1us, pulse_1ms : std_logic; + signal dw_sw_drive_en, dw_sw_value : std_logic; + -- + signal vector_out : std_logic_vector( 0 downto 0); + signal input_src_d, input_src_i : std_logic_vector( 3 downto 0); + signal seq_csr_addr : std_logic_vector( 3 downto 0); + signal avs_addr : std_logic_vector( 2 downto 0); + signal seq_start_addr : std_logic_vector( 7 downto 0); + signal trigger_in : std_logic_vector( 7 downto 0); + signal seq_address : std_logic_vector( 7 downto 0); + signal avs_address_i : std_logic_vector( 9 downto 0); + signal us_cnt, ms_cnt : std_logic_vector( 9 downto 0); + signal drop_cnt : std_logic_vector(15 downto 0); + signal pulse_width, pulse_cnt : std_logic_vector(23 downto 0); + signal seq_csr_writedata, seq_csr_readdata : std_logic_vector(31 downto 0); + signal dw_delay, seq_writedata, seq_readdata : std_logic_vector(31 downto 0); + signal avs_readdata_i : std_logic_vector(31 downto 0); + +begin -- RTL + + ----------------------------------------------------------------------------- + -- Drop-Watch Sequencer + ----------------------------------------------------------------------------- + + iCH_SEQ : entity work.generic_sequencer_15 + generic map ( + TRIGGER_WIDTH => 8, + VECTOR_WIDTH => 1, + BUS_WIDTH => 1, + POS_WIDTH => 1, + SEQ_DEPTH => 256, + ADD_VEC_PIPE => false, + VECT_RAMP_EN => false, + BUS_BURST_EN => false, + POS_BUS_EN => false, + ALU_EN => false) + port map ( + clk => clk, + reset_n => reset_n, + avs_csr_address => seq_csr_addr, + avs_csr_write => seq_csr_write, + avs_csr_writedata => seq_csr_writedata, + avs_csr_read => seq_csr_read, + avs_csr_readdata => seq_csr_readdata, + avs_seq_address => seq_address, + avs_seq_write => seq_write, + avs_seq_writedata => seq_writedata, + avs_seq_read => seq_read, + avs_seq_readdata => seq_readdata, + start_req => seq_start_req, + start_addr => seq_start_addr, + trigger_in => trigger_in, + pos_in => (others => '0'), + busy => seq_busy, + vector_out => vector_out, + bus_data => open, + bus_valid => open, + bus_ack => '0'); + + -- make sure all the input signals are asserted for a single clock cycle + pIN_SRC_CON : process(clk) + begin + if(clk = '1' and clk'event) then + input_src_d <= input_src; + end if; + end process pIN_SRC_CON; + + input_src_i <= (input_src and not input_src_d) when input_polarity = '1' else (not input_src and input_src_d); + + trigger_in <= '0' & pulse_1ms & pulse_1us & '1' & input_src_i; + + -- Generate a 1 us and a 1 ms pulse signal to be used for triggering events + -- in the drop-watch sequencer + pGEN_TIME_PULSES : process(reset_n, clk) + begin + if(reset_n = '0') then + us_cnt <= (others => '0'); + ms_cnt <= (others => '0'); + elsif(clk = '1' and clk'event) then + if(pulse_1us = '1') then + us_cnt <= (others => '0'); + else + us_cnt <= std_logic_vector(unsigned(us_cnt)+1); + end if; + if(pulse_1ms = '1') then + ms_cnt <= (others => '0'); + else + ms_cnt <= std_logic_vector(unsigned(ms_cnt)+1); + end if; + end if; + end process pGEN_TIME_PULSES; + + pulse_1us <= '1' when unsigned(us_cnt) = 99 else '0'; + pulse_1ms <= '1' when unsigned(ms_cnt) = 999 else '0'; + + ----------------------------------------------------------------------------- + -- Drop-watch generation logic + ----------------------------------------------------------------------------- + + pGenDW_Event : process(reset_n, clk) + begin + if(reset_n = '0') then + dw_src <= '0'; + dw_src_d <= '0'; + dw_i <= '0'; + pulse_gen_d <= '0'; + drop_watch <= '1'; + pulse_cnt <= (others => '0'); + drop_cnt <= (others => '0'); + elsif(clk = '1' and clk'event) then + -- source selection + dw_src <= dw_gen_en and vector_out(0); + dw_src_d <= dw_src; + pulse_gen_d <= pulse_gen; + if(dw_gen_en = '0' or pulse_cnt_tc = '1') then + dw_i <= '0'; + elsif(pulse_gen_d = '1') then + dw_i <= '1'; + end if; + if(dw_sw_drive_en = '0') then + if(dw_polarity = '1') then + drop_watch <= drop_watch_i; + else + drop_watch <= not drop_watch_i; + end if; + else + drop_watch <= dw_sw_value; + end if; + if(pulse_gen = '1') then + pulse_cnt <= (others => '0'); + else + pulse_cnt <= std_logic_vector(unsigned(pulse_cnt)+1); + end if; + if(dw_gen_en = '0' or rst_drop_cnt = '1') then + drop_cnt <= (others => '0'); + elsif(pulse_gen = '1') then + drop_cnt <= std_logic_vector(unsigned(drop_cnt)+1); + end if; + end if; + end process pGenDW_Event; + + pulse_gen <= dw_src and not dw_src_d; + pulse_cnt_tc <= '1' when unsigned(pulse_cnt) = unsigned(pulse_width) else '0'; + + -- Queue and delay drop watch requests + iQD: entity work.queue_and_delay + generic map ( + use_ext_time => false, + queue_size => 2048) + port map ( + rstN => reset_n, + clk => clk, + init => init_qd, + cnt_dir => '0', + delay => dw_delay, + ext_time => (others => '0'), + wave_in => dw_i, + wave_out => drop_watch_i, + ovf_error => queue_overflow_err); + + init_qd <= not dw_gen_en; + + ----------------------------------------------------------------------------- + -- C&S registers (Avalon-MM I/F) + ----------------------------------------------------------------------------- + + -- Memory partitioning: + -- Relative addresses between 0 and 511 => DW Gen C&S regs + -- Relative addresses between 32 and 63 => Sequencer Ctrl&Status + -- Relative addresses between 512 and 1023 => Sequencer instruction buffers + + avs_write_i <= '1' when avs_write = '1' and avs_address(9 downto 3) = 7x"0" else '0'; + seq_csr_write <= '1' when avs_write = '1' and avs_address(9 downto 3) = 7x"4" else '0'; + seq_write <= '1' when avs_write = '1' and avs_address(9) = '1' else '0'; + -- + avs_read_i <= '1' when avs_read = '1' and avs_address(9 downto 3) = 7x"0" else '0'; + seq_csr_read <= '1' when avs_read = '1' and avs_address(9 downto 3) = 7x"4" else '0'; + seq_read <= '1' when avs_read = '1' and avs_address(9) = '1' else '0'; + -- + avs_addr <= avs_address(2 downto 0); + seq_address <= avs_address(seq_address'range); + seq_csr_addr <= avs_address(seq_csr_addr'range); + -- + seq_writedata <= avs_writedata; + seq_csr_writedata <= avs_writedata; + + pCTRL_STATUS : process(reset_n, clk) + begin + if(reset_n = '0') then + avs_read_d <= '0'; + avs_readdatavalid <= '0'; + avs_readdata_i <= (others => '0'); + -- + dw_gen_en <= '0'; + dw_polarity <= '0'; + input_polarity <= '0'; + seq_start_req <= '0'; + rst_drop_cnt <= '0'; + dw_sw_drive_en <= '0'; + dw_sw_value <= '0'; + seq_start_addr <= (others => '0'); + dw_delay <= (others => '0'); + pulse_width <= X"0003E8"; + elsif(clk = '1' and clk'event) then + -- CTRL registers + if(avs_write_i = '1') then + case avs_addr is + when CSR_DW_CSR => + dw_gen_en <= avs_writedata(0); + dw_polarity <= avs_writedata(1); -- 0 => active low, 1 => + -- active high + input_polarity <= avs_writedata(2); + seq_start_req <= avs_writedata(5); + seq_start_addr <= avs_writedata(seq_start_addr'high+8 downto 8); + dw_sw_drive_en <= avs_writedata(24); + dw_sw_value <= avs_writedata(25); + when CSR_DW_DELAY => + dw_delay <= avs_writedata; + when CSR_DW_PULSE_WIDTH => + pulse_width <= avs_writedata(pulse_width'range); + when CSR_DW_CNT => + rst_drop_cnt <= avs_writedata(16); + when others => null; + end case; + end if; + + -- Read Ctrl & Status registers + avs_read_d <= avs_read; + avs_readdatavalid <= avs_read_d; + if(avs_read_i = '1') then + case avs_addr is + when CSR_IP_ID_ADDR => + avs_readdata_i <= CSR_IP_ID; + when CSR_IP_VER_ADDR => + avs_readdata_i <= CSR_IP_VER; + when CSR_DW_CSR => + avs_readdata_i(15 downto 0) <= seq_start_addr & '0' & seq_busy & seq_start_req & "00" & input_polarity & dw_polarity & dw_gen_en; + avs_readdata_i(31 downto 16) <= 14x"0" & dw_sw_value & dw_sw_drive_en; + when CSR_DW_DELAY => + avs_readdata_i <= dw_delay; + when CSR_DW_PULSE_WIDTH => + avs_readdata_i <= X"00" & pulse_width; + when CSR_DW_CNT => + avs_readdata_i(31 downto 16) <= (16 => rst_drop_cnt, 17 => queue_overflow_err, others => '0'); + avs_readdata_i(15 downto 0) <= drop_cnt; + when others => + avs_readdata_i <= X"BAD1BAD0"; + end case; + end if; + if(avs_read = '1') then + avs_address_i <= avs_address; + end if; + -- output multiplexer + case? avs_address_i(9 downto 5) is + when "00000" => + avs_readdata <= avs_readdata_i; + when "00001" => + avs_readdata <= seq_csr_readdata; + when "1----" => + avs_readdata <= seq_readdata; + when others => + avs_readdata <= X"BAD1BAD0"; + end case?; + end if; + end process pCTRL_STATUS; + +end RTL; diff --git a/generic_ip/drop_watch_gen/0/src/drop_watch_gen_0_pkg.vhd b/generic_ip/drop_watch_gen/0/src/drop_watch_gen_0_pkg.vhd new file mode 100644 index 0000000..a1bcffc --- /dev/null +++ b/generic_ip/drop_watch_gen/0/src/drop_watch_gen_0_pkg.vhd @@ -0,0 +1,31 @@ +------------------------------------------------------------------------------- +-- Title : drop_watch_gen_0_pkg +-- Project : Generic-IPs +------------------------------------------------------------------------------- +-- File : drop_watch_gen_0_pkg.vhd +-- Author : GMG +-- Company : Global Inkjet Systems +-- Created : 2018-05-24 +-- Last update: 2019-12-17 +-- SVN ID : Git +-- Standard : VHDL'2008 +------------------------------------------------------------------------------- +-- Description: +-- Package defining common constants for the drop-watch generator +------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +package drop_watch_gen_0_pkg is + + constant CSR_IP_ID_ADDR : std_logic_vector(2 downto 0) := 3x"0"; + constant CSR_IP_VER_ADDR : std_logic_vector(2 downto 0) := 3x"1"; + constant CSR_DW_CSR : std_logic_vector(2 downto 0) := 3x"2"; + constant CSR_DW_DELAY : std_logic_vector(2 downto 0) := 3x"3"; + constant CSR_DW_PULSE_WIDTH : std_logic_vector(2 downto 0) := 3x"4"; + constant CSR_DW_CNT : std_logic_vector(2 downto 0) := 3x"5"; + +end package drop_watch_gen_0_pkg; diff --git a/generic_ip/ems/0/doc/ems_0.json b/generic_ip/ems/0/doc/ems_0.json index 2e4b900..fec47d5 100644 --- a/generic_ip/ems/0/doc/ems_0.json +++ b/generic_ip/ems/0/doc/ems_0.json @@ -54,7 +54,7 @@ } }, "ems_enable" : { - "address" : "0", + "address" : "2", "width" : "4", "description" : "EMS Enable", "fields": { @@ -85,7 +85,7 @@ } }, "ems_config" : { - "address" : "1", + "address" : "3", "width" : "13", "description" : "EMS configuration", "fields": { @@ -152,7 +152,7 @@ } }, "pd_hyst" : { - "address" : "2", + "address" : "4", "width" : "17", "description" : "PD hysteresis control", "fields": { @@ -171,7 +171,7 @@ } }, "sw_ctrl": { - "address": "3", + "address": "5", "width": "6", "description": "software controls", "fields": { @@ -208,14 +208,14 @@ }, "enc_divide": { "type": "w", - "address": "4", + "address": "6", "reset": "0x0", "width": "4", "description": "division factor for the encoder increments/decrements" }, "abs_pos_init": { "type": "w", - "address": "5", + "address": "7", "reset": "0x0", "width": "32", "subtype": "signed", @@ -223,14 +223,14 @@ }, "abs_pos_val": { "type": "r", - "address": "6", + "address": "8", "reset": "0x0", "width": "32", "subtype": "signed", "description": "Current value of the absolute-position (With/Without Encoder Multiplier)" }, "pd_counters": { - "address": "7", + "address": "9", "width": "32", "description": "PD counters", "fields": { @@ -249,7 +249,7 @@ } }, "filter_cfg": { - "address": "8", + "address": "10", "width": "20", "description": "input filters configuration", "fields": { @@ -302,7 +302,7 @@ } }, "enc_mult_cfg": { - "address": "9", + "address": "11", "width": "15", "description": "Encoder Multiplier Configuration", "fields": { @@ -338,21 +338,21 @@ }, "delta_t_init": { "type": "w", - "address": "10", + "address": "12", "reset": "0x19", "width": "28", "description": "Set this constant to 25 for Encoder Mult values less or equal than 8, otherwise set to 2*Mult-Value" }, "vel_timeout": { "type": "w", - "address": "11", + "address": "13", "reset": "0x1388", "width": "28", "description": "Velocity estimation time-out period" }, "abs_pos_in_stat": { "type": "r", - "address": "12", + "address": "14", "reset": "0x0", "width": "32", "subtype": "signed", @@ -360,7 +360,7 @@ }, "abs_pos_vel_stat": { "type": "r", - "address": "13", + "address": "15", "reset": "0x0", "width": "32", "subtype": "signed", From 464a8ea1cb06b98952a69446dee08b07c5686c6a Mon Sep 17 00:00:00 2001 From: gianmarcogirau Date: Wed, 18 Dec 2019 16:44:36 +0000 Subject: [PATCH 05/15] CORE-73 - FPM-5 modifications completed. Working on the modified testbench --- .../fire_pulse_manager/5/doc/fpm_ctrl_5.json | 16 +- .../fire_pulse_manager/5/sim/sim_fpm.do | 11 + .../5/src/fire_pulse_5_pkg.vhd | 10 +- .../5/src/fire_pulse_ctrl_5.vhd | 89 ++++--- .../5/src/fire_pulse_ctrl_5_pkg.vhd | 40 +++ .../5/src/fire_pulse_manager_5.vhd | 234 +++++++++++++++++- .../5/src/test/fire_pulse_manager_5_tb.vhd | 132 +++++++--- 7 files changed, 451 insertions(+), 81 deletions(-) create mode 100644 generic_ip/fire_pulse_manager/5/src/fire_pulse_ctrl_5_pkg.vhd diff --git a/generic_ip/fire_pulse_manager/5/doc/fpm_ctrl_5.json b/generic_ip/fire_pulse_manager/5/doc/fpm_ctrl_5.json index 27868c8..c610ad5 100644 --- a/generic_ip/fire_pulse_manager/5/doc/fpm_ctrl_5.json +++ b/generic_ip/fire_pulse_manager/5/doc/fpm_ctrl_5.json @@ -42,7 +42,7 @@ "major_number" : { "type" : "c", "bit_len" : "8", - "reset" : "0x04", + "reset" : "0x05", "description" : "Major number" }, @@ -55,7 +55,7 @@ }, "Signal selection": { "address": "2", - "width": "2", + "width": "4", "description": "Controls signal selection", "fields": { "fire_pulse_sel": { @@ -69,6 +69,18 @@ "bit_len": "1", "reset": "0x0", "description": "0 => Use POF RX, 1 => Use internal enc/PD emulator" + }, + "seb_epd_en": { + "type": "w", + "bit_len": "1", + "reset": "0x0", + "description": "1 => Enable SEB-EPD interface, 0 => Use POF based interface" + }, + "seb_epd_linkout_sel": { + "type": "w", + "bit_len": "1", + "reset": "0x0", + "description": "0 => SEB_EPD_LINK_OUT is driven by the POF-Tx output, 0 => SEB_EPD_LINK_OUT is driven by the Drop-Watch output" } } }, diff --git a/generic_ip/fire_pulse_manager/5/sim/sim_fpm.do b/generic_ip/fire_pulse_manager/5/sim/sim_fpm.do index 0193c49..980d57f 100644 --- a/generic_ip/fire_pulse_manager/5/sim/sim_fpm.do +++ b/generic_ip/fire_pulse_manager/5/sim/sim_fpm.do @@ -15,6 +15,8 @@ set POF_PATH_1 ../../../pof_protocol/1/src set SEQUENCER_PATH ../../../generic_sequencer/15/src set PULSE_GEN_PATH ../../../pulse_generator/2/src set EMUL_PATH ../../../enc_pd_emul/1/src +set EMS_PATH ../../../ems/0/src +set ENC_MULT_PATH ../../../encoder_multiply/0/src set LOG_PATH ../../../event_logger/0/src set SRC_PATH ../src set OSVVM_PATH ../../../common/0/src/test/OSVVM @@ -33,6 +35,7 @@ vcom -2008 -work $WORKLIB $COMMON_PATH/sync_wire_rEdge.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/digital_lpf.vhd # Generic Sequencer vcom -2008 -work $WORKLIB $SEQUENCER_PATH/altera/generic_seq_ram_15.vhd @@ -49,6 +52,13 @@ vcom -2008 -work $WORKLIB $PULSE_GEN_PATH/pulse_generator_2.vhd vcom -2008 -work $WORKLIB $EMUL_PATH/enc_pd_emul_1_pkg.vhd vcom -2008 -work $WORKLIB $EMUL_PATH/enc_pd_emul_1.vhd +# EMS +vcom -2008 -work $WORKLIB $EMS_PATH/ems_0_pkg.vhd +vcom -2008 -work $WORKLIB $ENC_MULT_PATH/lut_divider_0.vhd +vcom -2008 -work $WORKLIB $ENC_MULT_PATH/encoder_speed_detect_0.vhd +vcom -2008 -work $WORKLIB $ENC_MULT_PATH/encoder_multiply_0.vhd +vcom -2008 -work $WORKLIB $EMS_PATH/ems_0.vhd + # Event Logger vcom -2008 -work $WORKLIB $LOG_PATH/event_logger_0_pkg.vhd vcom -2008 -work $WORKLIB $LOG_PATH/event_logger_0.vhd @@ -71,6 +81,7 @@ vcom -2008 -work $WORKLIB $COMMON_PATH/cs_bus_itf.vhd vcom -2008 -work $WORKLIB $SRC_PATH/smb_diagnostics_5.vhd vcom -2008 -work $WORKLIB $SRC_PATH/simple_enc_vel_detect_5.vhd vcom -2008 -work $WORKLIB $SRC_PATH/fire_pulse_5_pkg.vhd +vcom -2008 -work $WORKLIB $SRC_PATH/fire_pulse_ctrl_5_pkg.vhd vcom -2008 -work $WORKLIB $SRC_PATH/fire_pulse_ctrl_5.vhd vcom -2008 -work $WORKLIB $SRC_PATH/fire_pulse_ext_5.vhd vcom -2008 -work $WORKLIB $SRC_PATH/fire_pulse_manager_5.vhd diff --git a/generic_ip/fire_pulse_manager/5/src/fire_pulse_5_pkg.vhd b/generic_ip/fire_pulse_manager/5/src/fire_pulse_5_pkg.vhd index ac8d897..ae43edb 100644 --- a/generic_ip/fire_pulse_manager/5/src/fire_pulse_5_pkg.vhd +++ b/generic_ip/fire_pulse_manager/5/src/fire_pulse_5_pkg.vhd @@ -6,7 +6,7 @@ -- Author : Gianmarco Girau -- Company : Global Inkjet Systems -- Created : 2017-09-08 --- Last update: 2019-12-16 +-- Last update: 2019-12-18 -- SVN ID : Git -- Standard : VHDL'08 ------------------------------------------------------------------------------- @@ -25,13 +25,17 @@ package fire_pulse_5_pkg is -- Inner block mapping ----------------------------------------------------------------------------- - constant blk_num : integer := 8; -- number of sub-blocks with dedicated + constant blk_size : integer := 2048; + + constant blk_num : integer := 10; -- number of sub-blocks with dedicated -- C&S registers constant fp_ctrl_id : natural := 0; -- Block ID for the Fire-Pulse-Mang Controller constant diag_blk_id : natural := 1; -- Block ID for the Diagnostic Block constant log_blk_id : natural := 2; -- Block ID for the Event Logger constant int_enc_id : natural := 3; -- Block ID for the Internal Encoder Block - constant pg_ch_id : natural := 4; -- Block ID for Pulse-Generator + constant ems_blk_id : natural := 4; -- Block ID for the EMS block + constant pof_blk_id : natural := 5; -- Block ID for the POF output interface + constant pg_ch_id : natural := 6; -- Block ID for Pulse-Generator end package fire_pulse_5_pkg; diff --git a/generic_ip/fire_pulse_manager/5/src/fire_pulse_ctrl_5.vhd b/generic_ip/fire_pulse_manager/5/src/fire_pulse_ctrl_5.vhd index 2d8e6dc..f3474cb 100644 --- a/generic_ip/fire_pulse_manager/5/src/fire_pulse_ctrl_5.vhd +++ b/generic_ip/fire_pulse_manager/5/src/fire_pulse_ctrl_5.vhd @@ -6,7 +6,7 @@ -- Author : Gianmarco Girau -- Company : Global Inkjet Systems -- Created : 2017-09-06 --- Last update: 2019-12-16 +-- Last update: 2019-12-18 -- SVN ID : Git -- Standard : VHDL'08 ------------------------------------------------------------------------------- @@ -19,11 +19,14 @@ library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; +library work; +use work.fire_pulse_ctrl_5_pkg.all; + entity fire_pulse_ctrl_5 is port( reset_n : in std_logic; clk : in std_logic; - src_sel : out std_logic_vector(1 downto 0); + src_sel : out std_logic_vector(3 downto 0); uart_regen_bypass : out std_logic; upd_max_pos : out std_logic; upd_min_pos : out std_logic; @@ -43,6 +46,8 @@ entity fire_pulse_ctrl_5 is one_pps : out std_logic; ext_fp_det : out std_logic_vector(15 downto 0); ext_fp_gen : out std_logic_vector(15 downto 0); + dw_src : out std_logic_vector( 3 downto 0); + dw_pulse_width : out std_logic_vector(15 downto 0); -- Interrupt Senders ins_fpm_irq_0 : out std_logic; -- Avalon MM Interface @@ -60,21 +65,7 @@ architecture rtl of fire_pulse_ctrl_5 is -- Control & Status Registers Map ----------------------------------------------------------------------------- constant CSR_IP_ID : std_logic_vector(31 downto 0) := x"0000FF14"; - constant CSR_IP_VER : std_logic_vector(31 downto 0) := x"00000400"; - - constant CSR_IP_ID_REG : std_logic_vector(3 downto 0) := b"0000"; - constant CSR_IP_VER_REG : std_logic_vector(3 downto 0) := b"0001"; - constant SRC_SEL_REG : std_logic_vector(3 downto 0) := b"0010"; - constant POF_RX_CTRL : std_logic_vector(3 downto 0) := b"0011"; - constant MON_PT_CTRL_REG : std_logic_vector(3 downto 0) := b"0100"; - constant COARSE_TIME_INIT_REG : std_logic_vector(3 downto 0) := b"0101"; - constant FINE_TIME_INIT_REG : std_logic_vector(3 downto 0) := b"0110"; - constant FINE_TIME_REG : std_logic_vector(3 downto 0) := b"0111"; - constant COARSE_TIME_REG : std_logic_vector(3 downto 0) := b"1000"; - constant RX_ERROR_STATUS : std_logic_vector(3 downto 0) := b"1001"; - constant RX_ERROR_CSR : std_logic_vector(3 downto 0) := b"1010"; - constant IRQ_MNG_REG : std_logic_vector(3 downto 0) := b"1011"; - constant EXT_FP_CTRL_REG : std_logic_vector(3 downto 0) := b"1100"; + constant CSR_IP_VER : std_logic_vector(31 downto 0) := x"00000500"; ----------------------------------------------------------------------------- -- Constants, Signals @@ -88,24 +79,48 @@ architecture rtl of fire_pulse_ctrl_5 is signal rx_watchdog_en_i, rx_watchdog_clr_i : std_logic; signal uart_regen_bypass_i : std_logic; signal upd_min_pos_i, upd_max_pos_i : std_logic; - signal irq, irq_src, irq_src_d : std_logic_vector(0 downto 0); - signal irq_en, irq_mask, irq_val, irq_clr : std_logic_vector(0 downto 0); - signal src_sel_i : std_logic_vector(1 downto 0); - signal mp_sel0, mp_sel1, mp_sel2, mp_sel3 : std_logic_vector(3 downto 0); - signal bit_div : std_logic_vector(3 downto 0); - signal error_rate_thres_i : std_logic_vector(7 downto 0); + signal fpm_init_i, fpm_init_d : std_logic; + signal fpm_init_start, fpm_init_done : std_logic; + signal fpm_init_done_flag, fpm_init_pulse : std_logic; + signal irq, irq_src, irq_src_d : std_logic_vector( 0 downto 0); + signal irq_en, irq_mask, irq_val, irq_clr : std_logic_vector( 0 downto 0); + signal src_sel_i, dw_src_i : std_logic_vector( 3 downto 0); + signal mp_sel0, mp_sel1, mp_sel2, mp_sel3 : std_logic_vector( 3 downto 0); + signal bit_div : std_logic_vector( 3 downto 0); + signal error_rate_thres_i, init_cnt : std_logic_vector( 7 downto 0); + signal ext_fp_det_i, ext_fp_gen_i : std_logic_vector(15 downto 0); + signal dw_pulse_width_i : std_logic_vector(15 downto 0); signal fine_time_init, fine_time_i : std_logic_vector(27 downto 0); signal coarse_time_init, coarse_time_i : std_logic_vector(31 downto 0); - signal ext_fp_det_i, ext_fp_gen_i : std_logic_vector(15 downto 0); begin pCTRL_REGs : process(reset_n, clk) begin -- process if (reset_n = '0') then - fine_time_i <= (others => '0'); - coarse_time_i <= (others => '0'); + fpm_init_i <= '0'; + fpm_init_d <= '0'; + fpm_init_done_flag <= '0'; + init_cnt <= (others => '0'); + fine_time_i <= (others => '0'); + coarse_time_i <= (others => '0'); elsif (clk = '1' and clk'event) then + fpm_init_d <= fpm_init_start; + if(fpm_init_start = '1' and fpm_init_d = '0') then + fpm_init_done_flag <= '0'; + elsif(fpm_init_done = '1') then + fpm_init_done_flag <= '1'; + end if; + if(fpm_init_pulse = '1') then + fpm_init_i <= '1'; + elsif(fpm_init_done = '1') then + fpm_init_i <= '0'; + end if; + if(fpm_init_pulse = '1') then + init_cnt <= (others => '0'); + elsif(fpm_init_i = '1') then + init_cnt <= std_logic_vector(unsigned(init_cnt)+1); + end if; if (time_ld_en = '1') then fine_time_i <= fine_time_init; elsif (fine_time_wrap = '1') then @@ -122,11 +137,17 @@ begin end if; end process pCTRL_REGs; + fpm_init_pulse <= fpm_init_start and fpm_init_d; + fpm_init_done <= '1' when unsigned(init_cnt) = 50 else '0'; + fine_time_wrap <= '1' when unsigned(fine_time_i) = FINE_TIME_TC else '0'; coarse_time <= coarse_time_i; fine_time <= fine_time_i; + dw_src <= dw_src_i; + dw_pulse_width <= dw_pulse_width_i; + -- MOnitoring Point selection mon_points(0) <= mon_point_src(to_integer(unsigned(mp_sel0))); mon_points(1) <= mon_point_src(to_integer(unsigned(mp_sel1))); @@ -182,7 +203,8 @@ begin begin if (reset_n = '0') then avs_readdatavalid <= '0'; - src_sel_i <= "00"; + fpm_init_start <= '0'; + src_sel_i <= "0000"; enable_rx_i <= '0'; uart_regen_bypass_i <= '0'; upd_max_pos_i <= '0'; @@ -204,8 +226,10 @@ begin -- CTRL registers if (avs_write = '1') then case avs_address is + when FPM_INIT_REG => + fpm_init_start <= avs_writedata(0); when SRC_SEL_REG => - src_sel_i <= avs_writedata(1 downto 0); + src_sel_i <= avs_writedata(3 downto 0); when POF_RX_CTRL => enable_rx_i <= avs_writedata(0); uart_regen_bypass_i <= avs_writedata(1); @@ -233,6 +257,9 @@ begin when EXT_FP_CTRL_REG => ext_fp_det_i <= avs_writedata(15 downto 0); ext_fp_gen_i <= avs_writedata(31 downto 16); + when DW_CFG_REG => + dw_src_i <= avs_writedata( 3 downto 0); + dw_pulse_width_i <= avs_writedata(15 downto 0); when others => null; end case; end if; @@ -244,8 +271,10 @@ begin avs_readdata <= CSR_IP_ID; when CSR_IP_VER_REG => avs_readdata <= CSR_IP_VER; + when FPM_INIT_REG => + avs_readdata <= (0 => fpm_init_start, 1 => fpm_init_done_flag, others => '0'); when SRC_SEL_REG => - avs_readdata <= (0 => src_sel_i(0), 1 => src_sel_i(1), others => '0'); + avs_readdata <= 28x"0" & src_sel_i; when POF_RX_CTRL => avs_readdata <= X"000000" & bit_div & upd_min_pos_i & upd_max_pos_i & uart_regen_bypass_i & enable_rx_i; when MON_PT_CTRL_REG => @@ -266,6 +295,8 @@ begin avs_readdata <= X"0000" & "000" & irq_val & "000" & irq_mask & "000" & irq_clr & "000" & irq_en; when EXT_FP_CTRL_REG => avs_readdata <= ext_fp_gen_i & ext_fp_det_i; + when DW_CFG_REG => + avs_readdata <= dw_pulse_width_i & X"000" & dw_src_i; when others => avs_readdata <= X"BAD1BAD0"; end case; diff --git a/generic_ip/fire_pulse_manager/5/src/fire_pulse_ctrl_5_pkg.vhd b/generic_ip/fire_pulse_manager/5/src/fire_pulse_ctrl_5_pkg.vhd new file mode 100644 index 0000000..3c1c2b2 --- /dev/null +++ b/generic_ip/fire_pulse_manager/5/src/fire_pulse_ctrl_5_pkg.vhd @@ -0,0 +1,40 @@ +------------------------------------------------------------------------------- +-- Title : fire_pulse_ctrl_5_pkg +-- Project : FPM +------------------------------------------------------------------------------- +-- File : fire_pulse_ctrl_5_pkg.vhd +-- Author : GMG +-- Company : Global Inkjet Systems +-- Created : 2018-05-24 +-- Last update: 2019-12-18 +-- SVN ID : Git +-- Standard : VHDL'2008 +------------------------------------------------------------------------------- +-- Description: +-- Package defining common constants for fire_pulse_ctrl_5 +------------------------------------------------------------------------------- +-- altera vhdl_input_version vhdl_2008 + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +package fire_pulse_ctrl_5_pkg is + + constant CSR_IP_ID_REG : std_logic_vector(3 downto 0) := X"0"; + constant CSR_IP_VER_REG : std_logic_vector(3 downto 0) := X"1"; + constant FPM_INIT_REG : std_logic_vector(3 downto 0) := X"2"; + constant SRC_SEL_REG : std_logic_vector(3 downto 0) := X"3"; + constant POF_RX_CTRL : std_logic_vector(3 downto 0) := X"4"; + constant MON_PT_CTRL_REG : std_logic_vector(3 downto 0) := X"5"; + constant COARSE_TIME_INIT_REG : std_logic_vector(3 downto 0) := X"6"; + constant FINE_TIME_INIT_REG : std_logic_vector(3 downto 0) := X"7"; + constant FINE_TIME_REG : std_logic_vector(3 downto 0) := X"8"; + constant COARSE_TIME_REG : std_logic_vector(3 downto 0) := X"9"; + constant RX_ERROR_STATUS : std_logic_vector(3 downto 0) := X"A"; + constant RX_ERROR_CSR : std_logic_vector(3 downto 0) := X"B"; + constant IRQ_MNG_REG : std_logic_vector(3 downto 0) := X"C"; + constant EXT_FP_CTRL_REG : std_logic_vector(3 downto 0) := X"D"; + constant DW_CFG_REG : std_logic_vector(3 downto 0) := X"E"; + +end package fire_pulse_ctrl_5_pkg; diff --git a/generic_ip/fire_pulse_manager/5/src/fire_pulse_manager_5.vhd b/generic_ip/fire_pulse_manager/5/src/fire_pulse_manager_5.vhd index 014ddb6..e7d44da 100644 --- a/generic_ip/fire_pulse_manager/5/src/fire_pulse_manager_5.vhd +++ b/generic_ip/fire_pulse_manager/5/src/fire_pulse_manager_5.vhd @@ -6,7 +6,7 @@ -- Author : Gianmarco Girau -- Company : Global Inkjet Systems -- Created : 2017-09-06 --- Last update: 2019-12-17 +-- Last update: 2019-12-18 -- SVN ID : Git -- Standard : VHDL'08 ------------------------------------------------------------------------------- @@ -19,11 +19,14 @@ library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; +library work; +use work.common_pkg.all; use work.fire_pulse_5_pkg.all; entity fire_pulse_manager_5 is generic ( - CH_NUM : integer := 4; -- number of Pulse-Generator blocks + SEB_EPD_MODE : boolean := false; -- Support SEB-EPD + CH_NUM : integer := 4; -- number of Pulse-Generator blocks PD_QUEUE_SIZE : natural := 512; ADD_SMB_DIAG : boolean := false; -- Instantiate SMB Diagnostic block ADD_EVENT_LOGGER : boolean := false; -- Instantiate Event-Logger block @@ -33,6 +36,7 @@ entity fire_pulse_manager_5 is PULSE_DELAY_EQUAL_EN : boolean := false; TOF_COMP_EN : boolean := false; PIXEL_PITCH_CORR_EN : boolean := false; + DW_GEN_EN : boolean := false; OUT_PULSE_CONDITION : boolean := true); port( reset_n : in std_logic; @@ -42,6 +46,10 @@ entity fire_pulse_manager_5 is pof_rx : in std_logic; pof_tx : out std_logic; pof_iso_en : out std_logic; + seb_epd_enc_p1 : in std_logic; + seb_epd_enc_p2 : in std_logic; + seb_epd_pd : in std_logic; + seb_epd_link_out : out std_logic; fire_pulse : out std_logic_vector(ch_num - 1 downto 0); start_of_image : out std_logic_vector(ch_num - 1 downto 0); dp_dir_out : out std_logic_vector(ch_num - 1 downto 0); @@ -108,6 +116,16 @@ architecture rtl of fire_pulse_manager_5 is signal cs_ie_read_valid : std_logic; signal cs_ie_read_data : std_logic_vector(31 downto 0); -- + signal cs_ems_write_en : std_logic; + signal cs_ems_read_en : std_logic; + signal cs_ems_read_valid : std_logic; + signal cs_ems_read_data : std_logic_vector(31 downto 0); + -- + signal cs_pof_write_en : std_logic; + signal cs_pof_read_en : std_logic; + signal cs_pof_read_valid : std_logic; + signal cs_pof_read_data : std_logic_vector(31 downto 0); + -- signal enable_rx : std_logic; signal uart_regen_bypass : std_logic; signal max_error_flag : std_logic; @@ -115,10 +133,12 @@ architecture rtl of fire_pulse_manager_5 is signal rx_watchdog_en : std_logic; signal rx_watchdog_clr : std_logic; signal print_start_i : std_logic; - signal error_rate_thres : std_logic_vector(7 downto 0); + signal dw_src : std_logic_vector( 3 downto 0); + signal error_rate_thres : std_logic_vector( 7 downto 0); signal parity_err_cnt : std_logic_vector(15 downto 0); signal skip_pos_cnt : std_logic_vector(15 downto 0); signal mon_point_src : std_logic_vector(15 downto 0); + signal dw_pulse_width : std_logic_vector(15 downto 0); signal fine_time : std_logic_vector(27 downto 0); signal coarse_time : std_logic_vector(31 downto 0); -- @@ -129,22 +149,40 @@ architecture rtl of fire_pulse_manager_5 is signal pd_pulse : std_logic; signal pd_pulse_ie : std_logic; signal pd_pulse_pof : std_logic; + signal pd_ems : std_logic; + -- signal inc_pos : std_logic; signal inc_pos_pof : std_logic; signal inc_pos_ie : std_logic; + signal inc_pos_ems : std_logic; signal dec_pos : std_logic; signal dec_pos_pof : std_logic; signal dec_pos_ie : std_logic; + signal dec_pos_ems : std_logic; signal abs_pos : std_logic_vector(31 downto 0); signal abs_pos_pof : std_logic_vector(31 downto 0); + signal abs_pos_ems : std_logic_vector(31 downto 0); signal abs_pos_ie : std_logic_vector(39 downto 0); -- + signal pd_pulse_mux : std_logic; + signal enc_p1_mux : std_logic; + signal enc_p2_mux : std_logic; + signal enc_p1_ie : std_logic; + signal enc_p2_ie : std_logic; + -- + signal pof_tx_data : std_logic; + signal dw_pulse : std_logic; + signal dw_pulse_i : std_logic; + signal rst_dw_pulse : std_logic; + signal set_dw_pulse : std_logic; + signal dw_pulse_cnt : std_logic_vector(15 downto 0); + -- signal ch_pd, ch_pulse_out : std_logic_vector(CH_NUM - 1 downto 0); signal ch_raw_pulse, ch_mask : std_logic_vector(CH_NUM - 1 downto 0); signal ch_start_of_image : std_logic_vector(CH_NUM - 1 downto 0); signal start_of_image_i : std_logic_vector(CH_NUM - 1 downto 0); signal fire_pulse_i : std_logic_vector(CH_NUM - 1 downto 0); - signal src_sel : std_logic_vector(1 downto 0); + signal src_sel : std_logic_vector(3 downto 0); -- type vel_samp_per_vec_t is array (0 to CH_NUM-1) of std_logic_vector(19 downto 0); signal vel_meas : std_logic_vector(19 downto 0); @@ -154,7 +192,7 @@ architecture rtl of fire_pulse_manager_5 is signal ext_fp_det : std_logic_vector(15 downto 0); signal ext_fp_gen : std_logic_vector(15 downto 0); signal pof_rx_regen : std_logic; - signal log_data_src : std_logic_vector(31 downto 0); + signal log_data_src : std_logic_vector(31 downto 0); begin @@ -196,6 +234,8 @@ begin cs_diag_write_en <= cs_write_en(diag_blk_id); cs_log_write_en <= cs_write_en(log_blk_id); cs_ie_write_en <= cs_write_en(int_enc_id); + cs_ems_write_en <= cs_write_en(ems_blk_id); + cs_pof_write_en <= cs_write_en(pof_blk_id); cs_pg_write_en_g : for i in 1 to CH_NUM generate cs_pg_write_en(i - 1) <= cs_write_en(pg_ch_id + i - 1); end generate; @@ -204,6 +244,8 @@ begin cs_diag_read_en <= cs_read_en(diag_blk_id); cs_log_read_en <= cs_read_en(log_blk_id); cs_ie_read_en <= cs_read_en(int_enc_id); + cs_ems_read_en <= cs_read_en(ems_blk_id); + cs_pof_read_en <= cs_read_en(pof_blk_id); cs_pg_read_en_g : for i in 1 to CH_NUM generate cs_pg_read_en(i - 1) <= cs_read_en(pg_ch_id + i - 1); end generate; @@ -212,6 +254,8 @@ begin cs_read_valid(diag_blk_id) <= cs_diag_read_valid; cs_read_valid(log_blk_id) <= cs_log_read_valid; cs_read_valid(int_enc_id) <= cs_ie_read_valid; + cs_read_valid(ems_blk_id) <= cs_ems_read_valid; + cs_read_valid(pof_blk_id) <= cs_pof_read_valid; cs_read_valid_pg_g : for i in 1 to CH_NUM generate cs_read_valid(pg_ch_id + i - 1) <= cs_pg_read_valid(i - 1); end generate; @@ -220,6 +264,8 @@ begin cs_read_data(31 + 32 * diag_blk_id downto 32 * diag_blk_id) <= cs_diag_read_data; cs_read_data(31 + 32 * log_blk_id downto 32 * log_blk_id) <= cs_log_read_data; cs_read_data(31 + 32 * int_enc_id downto 32 * int_enc_id) <= cs_ie_read_data; + cs_read_data(31 + 32 * ems_blk_id downto 32 * ems_blk_id) <= cs_ems_read_data; + cs_read_data(31 + 32 * pof_blk_id downto 32 * pof_blk_id) <= cs_pof_read_data; cs_read_data_pg_g : for i in 1 to CH_NUM generate cs_read_data(31 + 32 * (pg_ch_id + i - 1) downto 32 * (pg_ch_id + i - 1)) <= cs_pg_read_data(31 + 32 * (i - 1) downto 32 * (i - 1)); end generate; @@ -252,6 +298,8 @@ begin one_pps => one_pps, ext_fp_det => ext_fp_det, ext_fp_gen => ext_fp_gen, + dw_src => dw_src, + dw_pulse_width => dw_pulse_width, ins_fpm_irq_0 => ins_fpm_irq_0, avs_address => cs_addr(3 downto 0), avs_write => cs_ctrl_write_en, @@ -264,16 +312,52 @@ begin ins_fpm_irq_2 <= '0'; ins_fpm_irq_3 <= '0'; + + ----------------------------------------------------------------------------- + -- I/Os selection + ----------------------------------------------------------------------------- + -- Output multiplexer fire_pulse_i <= ch_pulse_out when src_sel(0) = '1' else (others => pof_rx_regen); -- The start-of-image for zero-gap is available only when fire-request are -- generated locally, through the pulse-generator start_of_image_i <= ch_start_of_image when src_sel(0) = '1' else (others => '0'); - pd_pulse <= pd_pulse_pof when src_sel(1) = '0' else pd_pulse_ie; - abs_pos <= abs_pos_pof when src_sel(1) = '0' else abs_pos_ie(31 downto 0); - inc_pos <= inc_pos_pof when src_sel(1) = '0' else inc_pos_ie; - dec_pos <= dec_pos_pof when src_sel(1) = '0' else dec_pos_ie; + pENC_PD_SRC_SEL : process(clk) + begin + if(clk = '1' and clk'event) then + -- Abs-Pos and PD source selection + if(src_sel(2) = '1') then + -- Use SEB-EPD inputs + pd_pulse <= pd_ems; + abs_pos <= abs_pos_ems; + inc_pos <= inc_pos_ems; + dec_pos <= dec_pos_ems; + else + if(src_sel(1) = '0') then + pd_pulse <= pd_pulse_pof; + abs_pos <= abs_pos_pof; + inc_pos <= inc_pos_pof; + dec_pos <= dec_pos_pof; + else + pd_pulse <= pd_pulse_ie; + abs_pos <= abs_pos_ie(31 downto 0); + inc_pos <= inc_pos_ie; + dec_pos <= dec_pos_ie; + end if; + end if; + end if; + end process pENC_PD_SRC_SEL; + + gSEB_EPD_LINKOUT : if SEB_EPD_MODE = true generate + + seb_epd_link_out <= pof_tx_data when src_sel(3) = '0' else dw_pulse; + + else generate + + seb_epd_link_out <= '0'; + + end generate gSEB_EPD_LINKOUT; pBUF_OUT : process(clk) begin @@ -377,7 +461,7 @@ begin end generate; ----------------------------------------------------------------------------- - -- POF Interface + -- POF Rx Interface ----------------------------------------------------------------------------- gPOF: if POF_PROT_VER = 0 generate @@ -465,6 +549,105 @@ begin end generate gPOF; + ----------------------------------------------------------------------------- + -- EMS + ----------------------------------------------------------------------------- + + gEMS : if SEB_EPD_MODE = true generate + + iEMS : entity work.ems_0 + generic map( + GEN_PRINT_START => false) + port map ( + clk => clk, + reset_n => reset_n_i, + init => init, + avs_address => cs_addr(3 downto 0), + avs_write => cs_ems_write_en, + avs_writedata => cs_write_data, + avs_read => cs_ems_read_en, + avs_readdatavalid => cs_ems_read_valid, + avs_readdata => cs_ems_read_data, + rs422_pd => pd_pulse_mux, + rs422_p1 => enc_p1_mux, + rs422_p2 => enc_p2_mux, + rs422_zp => '0', + ttl_pd => '0', + ttl_pd_npn => '0', + ttl_p1 => '0', + ttl_p2 => '0', + ttl_zp => '0', + abs_position => abs_pos_ems, + pd_out => pd_ems, + print_start => open, + set_pos => open, + inc_pos => inc_pos_ems, + dec_pos => dec_pos_ems, + filt_p1 => open, + filt_p2 => open, + filt_zp => open, + filt_pd => open); + + pd_pulse_mux <= seb_epd_pd when src_sel(1) = '0' else pd_pulse_ie; + enc_p1_mux <= seb_epd_enc_p1 when src_sel(1) = '0' else enc_p1_ie; + enc_p2_mux <= seb_epd_enc_p2 when src_sel(1) = '0' else enc_p2_ie; + + else generate + + pEMS_RD : process(clk) + begin + if(clk = '1' and clk'event) then + cs_ems_read_valid <= cs_ems_read_en; + end if; + end process pEMS_RD; + + cs_ems_read_data <= X"DEAD_BEEF"; + + abs_pos_ems <= (others => '0'); + pd_ems <= '0'; + inc_pos_ems <= '0'; + dec_pos_ems <= '0'; + + end generate gEMS; + + ----------------------------------------------------------------------------- + -- POF-Tx + ----------------------------------------------------------------------------- + + gPOF_TX : if SEB_EPD_MODE = true generate + -- Default POF-Protocol + iPOF_TX: entity work.pof_tx_0 + port map ( + reset_n => reset_n_i, + clk => clk, + init => init, + pd_in => pd_ems, + inc_pos => inc_pos_ems, + dec_pos => dec_pos_ems, + abs_position => abs_pos_ems, + tx_data => pof_tx_data, + avs_address => cs_addr(2 downto 0), + avs_write => cs_pof_write_en, + avs_writedata => cs_write_data, + avs_read => cs_pof_read_en, + avs_readdatavalid => cs_pof_read_valid, + avs_readdata => cs_pof_read_data); + + else generate + + pPOF_TX_RD : process(clk) + begin + if(clk = '1' and clk'event) then + cs_pof_read_valid <= cs_pof_read_en; + end if; + end process pPOF_TX_RD; + + cs_pof_read_data <= X"DEAD_BEEF"; + + pof_tx_data <= '0'; + + end generate gPOF_TX; + ----------------------------------------------------------------------------- -- Diagnostic block ----------------------------------------------------------------------------- @@ -589,6 +772,33 @@ begin ext_in => pof_rx, ext_out => pof_rx_regen); + ----------------------------------------------------------------------------- + -- Drop-Watch Pulse generation + ----------------------------------------------------------------------------- + + dw_pulse <= '0'; + + pGEN_DW: process(clk) + begin + if(clk = '1' and clk'event) then + if(rst_dw_pulse = '1') then + dw_pulse_i <= '0'; + elsif(set_dw_pulse = '1') then + dw_pulse_i <= '1'; + end if; + if(rst_dw_pulse = '1') then + dw_pulse_cnt <= (0 => '1', others => '0'); + elsif(dw_pulse_i = '1') then + dw_pulse_cnt <= std_logic_vector(unsigned(dw_pulse_cnt) + 1); + end if; + end if; + end process pGEN_DW; + + rst_dw_pulse <= '1' when init = '1' or unsigned(dw_pulse_cnt) = unsigned(dw_pulse_width) else '0'; + set_dw_pulse <= '1' when fire_pulse_i(to_integer(unsigned(dw_src(log2(CH_NUM)-1 downto 0)))) = '1' else '0'; + + dw_pulse <= dw_pulse_i; + ----------------------------------------------------------------------------- -- Internal encoder generator ----------------------------------------------------------------------------- @@ -604,8 +814,8 @@ begin ttl_enc_p2 => open, ttl_enc_zp => open, rs422_pd => pd_pulse_ie, - rs422_enc_p1 => open, - rs422_enc_p2 => open, + rs422_enc_p1 => enc_p1_ie, + rs422_enc_p2 => enc_p2_ie, rs422_enc_zp => open, abs_pos_out => abs_pos_ie, set_pos_out => set_pos_ie, diff --git a/generic_ip/fire_pulse_manager/5/src/test/fire_pulse_manager_5_tb.vhd b/generic_ip/fire_pulse_manager/5/src/test/fire_pulse_manager_5_tb.vhd index 1d1226f..6f3df34 100644 --- a/generic_ip/fire_pulse_manager/5/src/test/fire_pulse_manager_5_tb.vhd +++ b/generic_ip/fire_pulse_manager/5/src/test/fire_pulse_manager_5_tb.vhd @@ -6,7 +6,7 @@ -- Author : Christos Spirotis -- Company : Global Inkjet Systems -- Created : 2018-08-10 --- Last update: 2019-12-16 +-- Last update: 2019-12-18 -- SVN ID : Git -- Standard : VHDL'08 ------------------------------------------------------------------------------- @@ -23,14 +23,11 @@ use ieee.math_real.all; use std.textio.all; library work; use work.fire_pulse_5_pkg.all; +use work.fire_pulse_ctrl_5_pkg.all; use work.log_pkg.all; use work.avalon_verify_pkg.all; use work.pulse_generator_2_pkg.all; -use work.enc_pd_emul_1_pkg.CSR_ENC_NCO_INC_ADDR; -use work.enc_pd_emul_1_pkg.CSR_ENC_CTRL_ADDR; -use work.enc_pd_emul_1_pkg.CSR_PD_CTRL_ADDR; -use work.enc_pd_emul_1_pkg.CSR_OUT_ENABLE_ADDR; -use work.enc_pd_emul_1_pkg.CSR_PULSE_NUM_ADDR; +use work.enc_pd_emul_1_pkg.all; library osvvm; use osvvm.RandomPkg.all; @@ -47,7 +44,6 @@ architecture behav of fire_pulse_manager_5_tb is constant CLK_PERIOD : time := 10.0 ns; constant CLK_FREQ : real := 100.0e6; - -- TODO Try different receive oversampling ratios - 300MHz is in the real system constant RX_CLK_PERIOD : time := CLK_PERIOD / 3; -- clock period for used by the -- UART-Rx on the POF @@ -86,6 +82,10 @@ architecture behav of fire_pulse_manager_5_tb is signal tx_data : std_logic; signal pof_tx_avs_rv : std_logic; signal pof_tx_avs_we_d : std_logic; + signal seb_epd_enc_p1 : std_logic; + signal seb_epd_enc_p2 : std_logic; + signal seb_epd_pd : std_logic; + signal seb_epd_link_out : std_logic; -- signal abs_position_d : std_logic_vector(31 downto 0); signal dir_in : std_logic; @@ -112,6 +112,7 @@ architecture behav of fire_pulse_manager_5_tb is signal pd_cnt : pd_cnt_t; type fp_cnt_t is array (0 to CH_NUM - 1) of integer; signal fp_cnt : fp_cnt_t; + type pg_offset_t is array (0 to CH_NUM - 1) of integer; -- generate the NCO increment corresponding to a given output frequency function freq2NCO_inc( @@ -155,6 +156,10 @@ begin -- behav rx_clk => rx_clk, pof_rx => pof_rx, pof_tx => pof_tx, + seb_epd_enc_p1 => seb_epd_enc_p1, + seb_epd_enc_p2 => seb_epd_enc_p2, + seb_epd_pd => seb_epd_pd, + seb_epd_link_out => seb_epd_link_out, fire_pulse => ch_pulse_out, mon_pt => open, ins_fpm_irq_0 => open, @@ -172,7 +177,34 @@ begin -- behav pof_rx <= transport tx_data after POF_DELAY; ----------------------------------------------------------------------------- - -- POF Tx + -- Encoder/PD emulator (Stimuli Generator) + ----------------------------------------------------------------------------- + + iEMUL : entity work.enc_pd_emul_1 + port map ( + clk => clk, + reset_n => reset_n, + ttl_pd => ttl_pd, + ttl_enc_p1 => ttl_p1, + ttl_enc_p2 => ttl_p2, + ttl_enc_zp => ttl_zp, + rs422_pd => rs422_pd, + rs422_enc_p1 => rs422_p1, + rs422_enc_p2 => rs422_p2, + rs422_enc_zp => rs422_zp, + abs_pos_out => emul_pos, + set_pos_out => emul_set_pos, + inc_pos_out => emul_inc_pos, + dec_pos_out => emul_dec_pos, + avs_address => emul_address, + avs_write => emul_write, + avs_writedata => emul_writedata, + avs_read => emul_read, + avs_readdatavalid => emul_readdatavalid, + avs_readdata => emul_readdata); + + ----------------------------------------------------------------------------- + -- POF Tx (Stimuli Generator) ----------------------------------------------------------------------------- iPOF_TX : entity work.pof_tx_0 @@ -206,6 +238,8 @@ begin -- behav -- Stimuli Generation ----------------------------------------------------------------------------- + /* + pSTIMULI_REGs : process(clk) begin if (clk = '1' and clk'event) then @@ -216,6 +250,10 @@ begin -- behav inc_pos <= '1' when signed(abs_position) = signed(abs_position_d) + 1 else '0'; dec_pos <= '1' when signed(abs_position) = signed(abs_position_d) - 1 else '0'; + seb_epd_pd <= '0'; + seb_epd_enc_p1 <= '0'; + seb_epd_enc_p2 <= '0'; + pSTIMULI : process variable end_of_stimuli : boolean; variable rv : RandomPType; @@ -309,6 +347,10 @@ begin -- behav end process pSTIMULI; + */ + + + ----------------------------------------------------------------------------- -- Testbench Control ----------------------------------------------------------------------------- @@ -438,15 +480,19 @@ begin -- behav variable data : std_logic_vector(31 downto 0) := (others => '0'); variable ratio_int : integer; variable ratio_slv : std_logic_vector(33 downto 0); + variable pg_off : pg_offset_t; + variable pg_ram_off : pg_offset_t; begin sel_slave_0 <= '0'; sel_slave_1 <= '0'; configuring <= true; - -- initilialize the Avalon master-bus + -- Initialize avalon mm interfaces mm_m_init(avs_m, use_waitrequest => true); + mm_m_init(emul_mm_m, use_readvalid => true); + if (reset_n = '0') then wait until reset_n = '1'; wait for 100 ns; @@ -495,26 +541,32 @@ begin -- behav -- Write the data to the register mm_32b_write(addr, data, avs_s, avs_m); + -- precompute the channel memory offsets: + for i in 0 to CH_NUM - 1 loop + pg_off(i) := (work.fire_pulse_5_pkg.pg_ch_id + i)*work.fire_pulse_5_pkg.blk_size; + pg_ram_off(i) := pg_off(i) + to_integer(unsigned(work.pulse_generator_2_pkg.SEQ_RAM_OFFSET)); + end loop; -- i + config_pg_l : for i in 0 to CH_NUM - 1 loop -- Disable/Re-enable first the whole pulse_generator - addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(PULSE_GEN_CTRL_REG)), 32)); + addr := std_logic_vector(to_unsigned(pg_off(i) + to_integer(unsigned(work.pulse_generator_2_pkg.PULSE_GEN_CTRL_REG)), 32)); data := (others => '0'); mm_32b_write(addr, data, avs_s, avs_m); data := (0 => '1', 16 => '1', others => '0'); mm_32b_write(addr, data, avs_s, avs_m); -- Disable/Re-enable the Channel Controller sequencer - addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(CH_CTRL_CTRL_REG)), 32)); + addr := std_logic_vector(to_unsigned(pg_off(i) + to_integer(unsigned(work.pulse_generator_2_pkg.CH_CTRL_CTRL_REG)), 32)); data := (others => '0'); mm_32b_write(addr, data, avs_s, avs_m); - addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(CH_CTRL_CTRL_REG)), 32)); + addr := std_logic_vector(to_unsigned(pg_off(i) + to_integer(unsigned(work.pulse_generator_2_pkg.CH_CTRL_CTRL_REG)), 32)); data := (0 => '1', others => '0'); mm_32b_write(addr, data, avs_s, avs_m); -- set the sub-pixel offset data := std_logic_vector(to_unsigned(0, 32)); - addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SP_OFFSET_INT)), 32)); + addr := std_logic_vector(to_unsigned(pg_off(i) + to_integer(unsigned(work.pulse_generator_2_pkg.SP_OFFSET_INT)), 32)); mm_32b_write(addr, data, avs_s, avs_m); data := std_logic_vector(to_unsigned(0, 32)); - addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SP_OFFSET_FRAC)), 32)); + addr := std_logic_vector(to_unsigned(pg_off(i) + to_integer(unsigned(work.pulse_generator_2_pkg.SP_OFFSET_FRAC)), 32)); mm_32b_write(addr, data, avs_s, avs_m); -- set the division ratio ratio_int := integer(2.0 * real(2**24)); @@ -522,95 +574,95 @@ begin -- behav -- 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(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(DIV_RATIO_INT)), 32)); + addr := std_logic_vector(to_unsigned(pg_off(i) + to_integer(unsigned(work.pulse_generator_2_pkg.DIV_RATIO_INT)), 32)); mm_32b_write(addr, data, avs_s, avs_m); -- 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(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(DIV_RATIO_FRAC)), 32)); + addr := std_logic_vector(to_unsigned(pg_off(i) + to_integer(unsigned(work.pulse_generator_2_pkg.DIV_RATIO_FRAC)), 32)); mm_32b_write(addr, data, avs_s, avs_m); -- Disable/Enable the fractional divider - addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(FRAC_DIV_CTRL_REG)), 32)); + addr := std_logic_vector(to_unsigned(pg_off(i) + to_integer(unsigned(work.pulse_generator_2_pkg.FRAC_DIV_CTRL_REG)), 32)); data := (others => '0'); mm_32b_write(addr, data, avs_s, avs_m); data := (0 => '1', others => '0'); mm_32b_write(addr, data, avs_s, avs_m); -- Configure the Channel Offset (Both DIR_0 and DIR_1): -- DIR_0 - addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(CH_OFFSET_D0_REG)), 32)); + addr := std_logic_vector(to_unsigned(pg_off(i) + to_integer(unsigned(work.pulse_generator_2_pkg.CH_OFFSET_D0_REG)), 32)); data := std_logic_vector(to_unsigned(ch_offset(i), 32)); mm_32b_write(addr, data, avs_s, avs_m); -- DIR_1 - addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(CH_OFFSET_D1_REG)), 32)); + addr := std_logic_vector(to_unsigned(pg_off(i) + to_integer(unsigned(work.pulse_generator_2_pkg.CH_OFFSET_D1_REG)), 32)); data := std_logic_vector(to_unsigned(ch_offset(i), 32)); mm_32b_write(addr, data, avs_s, avs_m); -- Configure the Channel Delay - addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(CH_DELAY_REG)), 32)); + addr := std_logic_vector(to_unsigned(pg_off(i) + to_integer(unsigned(work.pulse_generator_2_pkg.CH_DELAY_REG)), 32)); data := std_logic_vector(to_unsigned(0, 32)); mm_32b_write(addr, data, avs_s, avs_m); -- Fill Sequencer RAM with simple swathe DIR-0 -- 0x00, 0x30000000 – Reset the vector output value - addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET)), 32)); + addr := std_logic_vector(to_unsigned(pg_ram_off(i), 32)); data := X"30000000"; mm_32b_write(addr, data, avs_s, avs_m); -- 0x01, 0x10000001 – Trigger Mask (PD trigger enabled) - addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET) + 1), 32)); + addr := std_logic_vector(to_unsigned(pg_ram_off(i) + 1, 32)); data := X"10000001"; mm_32b_write(addr, data, avs_s, avs_m); -- 0x02, 0x20000001 – Wait for a single PD event - addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET) + 2), 32)); + addr := std_logic_vector(to_unsigned(pg_ram_off(i) + 2, 32)); data := X"20000001"; mm_32b_write(addr, data, avs_s, avs_m); -- 0x03, 0x30006404 – Issue a request for starting the generation of 100 fire pulses (DIR-0) - addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET) + 3), 32)); + addr := std_logic_vector(to_unsigned(pg_ram_off(i) + 3, 32)); data := X"30006404"; mm_32b_write(addr, data, avs_s, avs_m); -- 0x04, 0x30006400 – De-assert the request bit (start_image_req) - addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET) + 4), 32)); + addr := std_logic_vector(to_unsigned(pg_ram_off(i) + 4, 32)); data := X"30006400"; mm_32b_write(addr, data, avs_s, avs_m); -- 0x05, 0x80000258 – Wait till POS END - addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET) + 5), 32)); + addr := std_logic_vector(to_unsigned(pg_ram_off(i) + 5, 32)); data := X"80000258"; mm_32b_write(addr, data, avs_s, avs_m); -- 0x06, 0xC0000000 – Jump to DIR-1 - addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET) + 6), 32)); + addr := std_logic_vector(to_unsigned(pg_ram_off(i) + 6, 32)); data := X"C0000010"; mm_32b_write(addr, data, avs_s, avs_m); -- Fill Sequencer RAM with simple swathe DIR-1 -- 0x10, 0x30000000 – Reset the vector output value - addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET) + 16), 32)); + addr := std_logic_vector(to_unsigned(pg_ram_off(i) + 16, 32)); data := X"30000001"; mm_32b_write(addr, data, avs_s, avs_m); -- 0x11, 0x10000001 – Trigger Mask (PD trigger enabled) - addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET) + 17), 32)); + addr := std_logic_vector(to_unsigned(pg_ram_off(i) + 17, 32)); data := X"10000001"; mm_32b_write(addr, data, avs_s, avs_m); -- 0x12, 0x20000001 – Wait for a single PD event - addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET) + 18), 32)); + addr := std_logic_vector(to_unsigned(pg_ram_off(i) + 18, 32)); data := X"20000001"; mm_32b_write(addr, data, avs_s, avs_m); -- 0x13, 0x30006405 – Issue a request for starting the generation of 100 fire pulses (DIR-1) - addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET) + 19), 32)); + addr := std_logic_vector(to_unsigned(pg_ram_off(i) + 19, 32)); data := X"30006405"; mm_32b_write(addr, data, avs_s, avs_m); -- 0x14, 0x30006401 – De-assert the request bit (start_image_req) - addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET) + 20), 32)); + addr := std_logic_vector(to_unsigned(pg_ram_off(i) + 20, 32)); data := X"30006401"; mm_32b_write(addr, data, avs_s, avs_m); -- 0x15, 0x80000000 – Wait till POS START - addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET) + 21), 32)); + addr := std_logic_vector(to_unsigned(pg_ram_off(i) + 21, 32)); data := X"80000000"; mm_32b_write(addr, data, avs_s, avs_m); -- 0x16, 0xC0000000 – Jump to DIR-0 - addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_RAM_OFFSET) + 22), 32)); + addr := std_logic_vector(to_unsigned(pg_ram_off(i) + 22, 32)); data := X"C0000000"; mm_32b_write(addr, data, avs_s, avs_m); -- Start Sequencer - addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(SEQ_CSR_OFFSET) + 3), 32)); + addr := std_logic_vector(to_unsigned(pg_off(i) + to_integer(unsigned(work.pulse_generator_2_pkg.SEQ_CSR_OFFSET) + 3), 32)); data := (0 => '1', others => '0'); mm_32b_write(addr, data, avs_s, avs_m); end loop config_pg_l; @@ -715,5 +767,15 @@ begin -- behav avs_read(0) <= avs_m.mm_read and sel_slave_0; avs_read(1) <= avs_m.mm_read and sel_slave_1; + -- Emulator Avalon bus maapings + emul_mm_s.mm_readdata <= emul_readdata; + emul_mm_s.mm_readdatavalid <= emul_readdatavalid; + emul_mm_s.mm_waitrequest <= '0'; + + emul_address <= emul_mm_m.mm_address(emul_address'range); + emul_writedata <= emul_mm_m.mm_writedata; + emul_write <= emul_mm_m.mm_write; + emul_read <= emul_mm_m.mm_read; + end behav; From aa92da23b7a838503f4b4274e1c7f7cb577e31e0 Mon Sep 17 00:00:00 2001 From: gianmarcogirau Date: Mon, 6 Jan 2020 14:42:31 +0000 Subject: [PATCH 06/15] CORE-73 - The testbench now supports the legacy functionality --- .../common/0/src/test/avalon_verify_pkg_2.vhd | 703 +++++++++++++++++ .../fire_pulse_manager/5/sim/sim_fpm.do | 5 +- .../fire_pulse_manager/5/sim/wave_fpm.do | 209 ++++- .../5/src/fire_pulse_5_pkg.vhd | 22 +- .../5/src/fire_pulse_ctrl_5.vhd | 19 +- .../5/src/fire_pulse_manager_5.vhd | 71 +- .../5/src/test/fire_pulse_manager_5_tb.vhd | 508 ++++-------- .../src/test/fire_pulse_manager_5_tb_pkg.vhd | 743 ++++++++++++++++++ 8 files changed, 1870 insertions(+), 410 deletions(-) create mode 100644 generic_ip/common/0/src/test/avalon_verify_pkg_2.vhd create mode 100644 generic_ip/fire_pulse_manager/5/src/test/fire_pulse_manager_5_tb_pkg.vhd diff --git a/generic_ip/common/0/src/test/avalon_verify_pkg_2.vhd b/generic_ip/common/0/src/test/avalon_verify_pkg_2.vhd new file mode 100644 index 0000000..aa85786 --- /dev/null +++ b/generic_ip/common/0/src/test/avalon_verify_pkg_2.vhd @@ -0,0 +1,703 @@ +-- avalon_verify_pkg_2 vs avalon_verify_pkg: +-- in avalon_verify_pkg_2 the read_latency and the usage of the wait_request +-- can be individually selected to for every avalon master/slave couple. +-- Note: the full package needs to be revised + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; +use ieee.std_logic_textio.all; +use std.textio.all; + +library OSVVM ; +use OSVVM.RandomBasePkg.all ; +use OSVVM.RandomPkg.all ; + +package avalon_verify_pkg_2 is + + shared variable RV : RandomPType; + + ----------------------------------------------------------------------------- + -- Bus duty cycle control + ----------------------------------------------------------------------------- + + signal int_mmBusPunctureAllowed : boolean := false; + signal int_mmBusPunctureMax : integer := 3; + + signal int_stmBusPunctureAllowed : boolean := false; + signal int_stmBusPunctureMin : integer := 3; + signal int_stmBusPunctureMax : integer := 3; + + ----------------------------------------------------------------------------- + -- Clock and reset section + ----------------------------------------------------------------------------- + + signal clk_clk : std_logic := '0'; + signal reset_reset_n : std_logic := '0'; + + ----------------------------------------------------------------------------- + -- Avalon MM section + ----------------------------------------------------------------------------- + + type data_128b_vec_t is array (0 to 1023) of std_logic_vector(127 downto 0); + + type data_96b_vec_t is array (0 to 1023) of std_logic_vector( 95 downto 0); + + type data_64b_vec_t is array (0 to 1023) of std_logic_vector( 63 downto 0); + + type data_32b_vec_t is array (0 to 1023) of std_logic_vector( 31 downto 0); + + type data_16b_vec_t is array (0 to 1023) of std_logic_vector( 15 downto 0); + + type data_8b_vec_t is array (0 to 1023) of std_logic_vector( 7 downto 0); + + signal base_addr : std_logic_vector(31 downto 0) := (others => '0'); + + type mm_m_rec_t is + record + mm_burstcount : std_logic_vector(31 downto 0) ; + mm_burst : std_logic ; + mm_writedata : std_logic_vector(31 downto 0) ; + mm_address : std_logic_vector(31 downto 0) ; + mm_write : std_logic ; + mm_read : std_logic ; + mm_byteenable : std_logic_vector(3 downto 0) ; + mm_debugaccess : std_logic ; + use_waitrequest : boolean; + use_readvalid : boolean; + read_latency : natural; + end record; + + type mm_s_rec_t is + record + mm_waitrequest : std_logic; + mm_readdata : std_logic_vector(31 downto 0); + mm_readdatavalid : std_logic; + end record; + + type mm_128b_m_rec_t is + record + mm_burstcount : std_logic_vector( 31 downto 0); + mm_burst : std_logic ; + mm_writedata : std_logic_vector(127 downto 0); + mm_address : std_logic_vector( 31 downto 0); + mm_write : std_logic ; + mm_read : std_logic ; + mm_byteenable : std_logic_vector( 15 downto 0); + mm_debugaccess : std_logic ; + use_waitrequest : boolean; + use_readvalid : boolean; + read_latency : natural; + end record; + + type mm_128b_s_rec_t is + record + mm_waitrequest : std_logic; + mm_readdata : std_logic_vector(127 downto 0); + mm_readdatavalid : std_logic; + end record; + + procedure mm_m_init( signal mm_m_rec : out mm_m_rec_t; read_latency : natural := 0; use_readvalid : boolean := false; use_waitrequest : boolean := false); + procedure mm_s_init( signal mm_s_rec : out mm_s_rec_t); + + procedure mm_128b_m_init( signal mm_m_rec : out mm_128b_m_rec_t ); + procedure mm_128b_s_init( signal mm_s_rec : out mm_128b_s_rec_t ); + + procedure mm_128b_burst( addr : in std_logic_vector(31 downto 0); + size : in integer; + data : in data_128b_vec_t; + signal mm_s_rec : in mm_128b_s_rec_t; + signal mm_m_rec : out mm_128b_m_rec_t); + + procedure mm_32b_burst( addr : in std_logic_vector(31 downto 0); + size : in integer; + data : in data_32b_vec_t; + signal mm_s_rec : in mm_s_rec_t; + signal mm_m_rec : out mm_m_rec_t); + + procedure mm_32b_write( addr : in std_logic_vector(31 downto 0); + data : in std_logic_vector(31 downto 0); + signal mm_s_rec : in mm_s_rec_t; + signal mm_m_rec : out mm_m_rec_t); + + procedure mm_16b_write( addr : in std_logic_vector(31 downto 0); + data : in std_logic_vector(15 downto 0); + signal mm_s_rec : in mm_s_rec_t; + signal mm_m_rec : out mm_m_rec_t); + + procedure mm_8b_write( addr : in std_logic_vector(31 downto 0); + data : in std_logic_vector( 7 downto 0); + signal mm_s_rec : in mm_s_rec_t; + signal mm_m_rec : out mm_m_rec_t); + + procedure mm_32b_read( addr : in std_logic_vector(31 downto 0); + data : out std_logic_vector(31 downto 0); + signal mm_s_rec : in mm_s_rec_t; + signal mm_m_rec : out mm_m_rec_t); + + procedure mm_16b_read( addr : in std_logic_vector(31 downto 0); + data : out std_logic_vector(15 downto 0); + signal mm_s_rec : in mm_s_rec_t; + signal mm_m_rec : out mm_m_rec_t); + + procedure mm_8b_read( addr : in std_logic_vector(31 downto 0); + data : out std_logic_vector( 7 downto 0); + signal mm_s_rec : in mm_s_rec_t; + signal mm_m_rec : out mm_m_rec_t); + + ----------------------------------------------------------------------------- + -- Avalon Stream section + ----------------------------------------------------------------------------- + + type stm_m_rec_t is + record + stm_channel : std_logic_vector( 7 downto 0); + stm_data : std_logic_vector(31 downto 0); + stm_valid : std_logic; + stm_sop : std_logic; + stm_eop : std_logic; + end record; + + type stm_s_rec_t is + record + stm_ready : std_logic; + stm_error : std_logic_vector( 7 downto 0); + end record; + + procedure stm_m_init( signal stm_m_rec : out stm_m_rec_t ); + procedure stm_s_init( signal stm_s_rec : out stm_s_rec_t ); + + procedure stm_puncture; + + procedure stm_32b_write( len : in integer; + channel : in integer; + data_vec : in data_32b_vec_t; + signal stm_s_rec : in stm_s_rec_t; + signal stm_m_rec : out stm_m_rec_t); + + procedure stm_16b_write( len : in integer; + channel : in integer; + data_vec : in data_16b_vec_t; + signal stm_s_rec : in stm_s_rec_t; + signal stm_m_rec : out stm_m_rec_t); + + procedure stm_8b_write( len : in integer; + channel : in integer; + data_vec : in data_8b_vec_t; + signal stm_s_rec : in stm_s_rec_t; + signal stm_m_rec : out stm_m_rec_t); + + procedure stm_8b_read( signal stm_m_rec : in stm_m_rec_t; + signal stm_s_rec : out stm_s_rec_t; + data_vec : out data_8b_vec_t; + channel : out integer; + len : out integer); + + ----------------------------------------------------------------------------- + -- LVDS section + ----------------------------------------------------------------------------- + + type lvds_m_rec_t is + record + lvds_1_rx_data : std_logic_vector(9 downto 0); + lvds_1_rx_nlock : std_logic; + lvds_1_rx_clk : std_logic; + lvds_2_rx_data : std_logic_vector(9 downto 0); + lvds_2_rx_nlock : std_logic; + lvds_2_rx_clk : std_logic; + end record; + + type lvds_s_rec_t is + record + lvds_refclk : std_logic; + lvds_1_rx_npwrdn : std_logic; + lvds_1_rx_en : std_logic; + lvds_2_rx_npwrdn : std_logic; + lvds_2_rx_en : std_logic; + end record; + + procedure lvds_m_init( signal lvds_m_rec : out lvds_m_rec_t ); + procedure lvds_s_init( signal lvds_s_rec : out lvds_s_rec_t ); + procedure lvds_write( len : in integer; + data_vec : in data_8b_vec_t; + signal lvds_s_rec : in lvds_s_rec_t; + signal lvds_m_rec : out lvds_m_rec_t); + + +end avalon_verify_pkg_2; + +package body avalon_verify_pkg_2 is + + ----------------------------------------------------------------------------- + -- Avalon MM section + ----------------------------------------------------------------------------- + + procedure mm_128b_m_init( signal mm_m_rec : out mm_128b_m_rec_t ) is + begin + mm_m_rec.mm_address <= (others => '0'); + mm_m_rec.mm_byteenable <= (others => '0'); + mm_m_rec.mm_writedata <= (others => '0'); + mm_m_rec.mm_write <= '0'; + mm_m_rec.mm_read <= '0'; + mm_m_rec.mm_byteenable <= (others => '0'); + mm_m_rec.mm_debugaccess <= '0'; + mm_m_rec.mm_burstcount <= (others => '0'); + end mm_128b_m_init; + + procedure mm_128b_s_init( signal mm_s_rec : out mm_128b_s_rec_t ) is + begin + --mm_s_rec.mm_waitrequest <= '0'; + --mm_s_rec.mm_readdata <= (others => '0'); + --mm_s_rec.mm_readdatavalid <= '0'; + end mm_128b_s_init; + + procedure mm_m_init( signal mm_m_rec : out mm_m_rec_t; read_latency : natural := 0; use_readvalid : boolean := false; use_waitrequest : boolean := false) is + begin + mm_m_rec.mm_address <= (others => '0'); + mm_m_rec.mm_byteenable <= (others => '0'); + mm_m_rec.mm_writedata <= (others => '0'); + mm_m_rec.mm_write <= '0'; + mm_m_rec.mm_read <= '0'; + mm_m_rec.mm_byteenable <= (others => '0'); + mm_m_rec.mm_debugaccess <= '0'; + mm_m_rec.mm_burstcount <= (others => '0'); + mm_m_rec.use_waitrequest <= use_waitrequest; + mm_m_rec.use_readvalid <= use_readvalid; + mm_m_rec.read_latency <= read_latency; + end mm_m_init; + + procedure mm_s_init( signal mm_s_rec : out mm_s_rec_t) is + begin + mm_s_rec.mm_waitrequest <= '0'; + mm_s_rec.mm_readdata <= (others => '0'); + mm_s_rec.mm_readdatavalid <= '0'; + end mm_s_init; + + procedure mm_128b_burst( addr : in std_logic_vector(31 downto 0); + size : in integer; + data : in data_128b_vec_t; + signal mm_s_rec : in mm_128b_s_rec_t; + signal mm_m_rec : out mm_128b_m_rec_t) is + begin + wait until rising_edge(clk_clk); + if(mm_m_rec.use_waitrequest = true and mm_s_rec.mm_waitrequest = '1') then + wait until falling_edge(mm_s_rec.mm_waitrequest); + end if; + for i in 0 to size-1 loop + if i = 0 then + mm_m_rec.mm_address <= addr or base_addr; + mm_m_rec.mm_byteenable <= x"1111"; + mm_m_rec.mm_writedata <= data(i); + mm_m_rec.mm_write <= '1'; + mm_m_rec.mm_burst <= '1'; + mm_m_rec.mm_burstcount <= std_logic_vector(to_unsigned(size,32)); + wait until rising_edge(clk_clk); + mm_m_rec.mm_byteenable <= x"0000"; + mm_m_rec.mm_write <= '0'; + mm_m_rec.mm_burst <= '0'; + else + mm_m_rec.mm_address <= addr or base_addr; + mm_m_rec.mm_byteenable <= x"1111"; + mm_m_rec.mm_writedata <= data(i); + mm_m_rec.mm_write <= '1'; + wait until rising_edge(clk_clk); + mm_m_rec.mm_byteenable <= x"0000"; + mm_m_rec.mm_write <= '0'; + end if; + end loop; -- i + wait until rising_edge(clk_clk); + end mm_128b_burst; + + procedure mm_32b_burst( addr : in std_logic_vector(31 downto 0); + size : in integer; + data : in data_32b_vec_t; + signal mm_s_rec : in mm_s_rec_t; + signal mm_m_rec : out mm_m_rec_t) is + begin + wait until rising_edge(clk_clk); + if(mm_m_rec.use_waitrequest = true and mm_s_rec.mm_waitrequest = '1') then + wait until falling_edge(mm_s_rec.mm_waitrequest); + end if; + for i in 0 to size-1 loop + if i = 0 then + mm_m_rec.mm_address <= addr or base_addr; + mm_m_rec.mm_byteenable <= "1111"; + mm_m_rec.mm_writedata <= data(i); + mm_m_rec.mm_write <= '1'; + mm_m_rec.mm_burst <= '1'; + mm_m_rec.mm_burstcount <= std_logic_vector(to_unsigned(size,32)); + wait until rising_edge(clk_clk); + mm_m_rec.mm_byteenable <= "0000"; + mm_m_rec.mm_write <= '0'; + mm_m_rec.mm_burst <= '0'; + else + mm_m_rec.mm_address <= addr or base_addr; + mm_m_rec.mm_byteenable <= "1111"; + mm_m_rec.mm_writedata <= data(i); + mm_m_rec.mm_write <= '1'; + wait until rising_edge(clk_clk); + mm_m_rec.mm_byteenable <= "0000"; + mm_m_rec.mm_write <= '0'; + end if; + end loop; -- i + wait until rising_edge(clk_clk); + end mm_32b_burst; + + procedure mm_32b_write( addr : in std_logic_vector(31 downto 0); + data : in std_logic_vector(31 downto 0); + signal mm_s_rec : in mm_s_rec_t; + signal mm_m_rec : out mm_m_rec_t) is + begin + wait until rising_edge(clk_clk); + mm_m_rec.mm_address <= addr or base_addr; + mm_m_rec.mm_byteenable <= "1111"; + mm_m_rec.mm_writedata <= data; + mm_m_rec.mm_write <= '1'; + wait until falling_edge(clk_clk); + if(mm_m_rec.use_waitrequest = true and mm_s_rec.mm_waitrequest = '1') then + wait until falling_edge(mm_s_rec.mm_waitrequest); + end if; + wait until rising_edge(clk_clk); + mm_m_rec.mm_byteenable <= "0000"; + mm_m_rec.mm_write <= '0'; + end mm_32b_write; + + procedure mm_16b_write( addr : in std_logic_vector(31 downto 0); + data : in std_logic_vector(15 downto 0); + signal mm_s_rec : in mm_s_rec_t; + signal mm_m_rec : out mm_m_rec_t) is + variable my_addr : std_logic_vector(31 downto 0) := (others=>'0'); + begin + my_addr := addr; + if addr(1) = '1' then + my_addr := std_logic_vector(unsigned(my_addr)+2); + end if; + wait until rising_edge(clk_clk); + if(mm_m_rec.use_waitrequest = true and mm_s_rec.mm_waitrequest = '1') then + wait until falling_edge(mm_s_rec.mm_waitrequest); + end if; + mm_m_rec.mm_address <= addr or base_addr; + mm_m_rec.mm_writedata <= data & data; + if addr(1) = '0' then + mm_m_rec.mm_byteenable <= "0011"; + else + mm_m_rec.mm_byteenable <= "1100"; + end if; + mm_m_rec.mm_write <= '1'; + wait until rising_edge(clk_clk); + mm_m_rec.mm_byteenable <= "0000"; + mm_m_rec.mm_write <= '0'; + wait until rising_edge(clk_clk); + end mm_16b_write; + + procedure mm_8b_write( addr : in std_logic_vector(31 downto 0); + data : in std_logic_vector( 7 downto 0); + signal mm_s_rec : in mm_s_rec_t; + signal mm_m_rec : out mm_m_rec_t) is + begin + wait until rising_edge(clk_clk); + if(mm_m_rec.use_waitrequest = true and mm_s_rec.mm_waitrequest = '1') then + wait until falling_edge(mm_s_rec.mm_waitrequest); + end if; + mm_m_rec.mm_address <= addr or base_addr; + mm_m_rec.mm_writedata <= data & data & data & data; + if addr(1 downto 0) = "00" then + mm_m_rec.mm_byteenable <= "0001"; + elsif addr(1 downto 0) = "01" then + mm_m_rec.mm_byteenable <= "0010"; + elsif addr(1 downto 0) = "10" then + mm_m_rec.mm_byteenable <= "0100"; + else + mm_m_rec.mm_byteenable <= "1000"; + end if; + mm_m_rec.mm_write <= '1'; + wait until rising_edge(clk_clk); + mm_m_rec.mm_byteenable <= "0000"; + mm_m_rec.mm_write <= '0'; + wait until rising_edge(clk_clk); + end mm_8b_write; + + procedure mm_32b_read( addr : in std_logic_vector(31 downto 0); + data : out std_logic_vector(31 downto 0); + signal mm_s_rec : in mm_s_rec_t; + signal mm_m_rec : out mm_m_rec_t) is + begin + wait until rising_edge(clk_clk); + mm_m_rec.mm_address <= addr or base_addr; + mm_m_rec.mm_read <= '1'; + wait until falling_edge(clk_clk); + if(mm_m_rec.use_waitrequest = true and mm_s_rec.mm_waitrequest = '1') then + wait until falling_edge(mm_s_rec.mm_waitrequest); + end if; + wait until rising_edge(clk_clk); + mm_m_rec.mm_read <= '0'; + if(mm_m_rec.use_waitrequest = false) then + for n in 1 to mm_m_rec.read_latency loop + wait until rising_edge(clk_clk); + end loop; -- n + end if; + if(mm_m_rec.use_readvalid = true) then + if(mm_s_rec.mm_readdatavalid = '0') then + wait until mm_s_rec.mm_readdatavalid = '1'; + end if; + end if; + wait until falling_edge(clk_clk); + data := mm_s_rec.mm_readdata; + end mm_32b_read; + + procedure mm_16b_read( addr : in std_logic_vector(31 downto 0); + data : out std_logic_vector(15 downto 0); + signal mm_s_rec : in mm_s_rec_t; + signal mm_m_rec : out mm_m_rec_t) is + begin + wait until rising_edge(clk_clk); + if(mm_m_rec.use_waitrequest = true and mm_s_rec.mm_waitrequest = '1') then + wait until falling_edge(mm_s_rec.mm_waitrequest); + end if; + mm_m_rec.mm_address <= addr or base_addr; + mm_m_rec.mm_read <= '1'; + wait until rising_edge(clk_clk); + mm_m_rec.mm_read <= '0'; + wait until rising_edge(mm_s_rec.mm_readdatavalid); + data := mm_s_rec.mm_readdata(15 downto 0); + end mm_16b_read; + + procedure mm_8b_read( addr : in std_logic_vector(31 downto 0); + data : out std_logic_vector( 7 downto 0); + signal mm_s_rec : in mm_s_rec_t; + signal mm_m_rec : out mm_m_rec_t) is + begin + wait until rising_edge(clk_clk); + if(mm_m_rec.use_waitrequest = true and mm_s_rec.mm_waitrequest = '1') then + wait until falling_edge(mm_s_rec.mm_waitrequest); + end if; + mm_m_rec.mm_address <= addr or base_addr; + mm_m_rec.mm_read <= '1'; + wait until rising_edge(clk_clk); + mm_m_rec.mm_read <= '0'; + wait until rising_edge(mm_s_rec.mm_readdatavalid); + data := mm_s_rec.mm_readdata( 7 downto 0); + end mm_8b_read; + + ----------------------------------------------------------------------------- + -- Avalon Stream section + ----------------------------------------------------------------------------- + + procedure stm_m_init( signal stm_m_rec : out stm_m_rec_t ) is + begin + stm_m_rec.stm_channel <= (others => '0'); + stm_m_rec.stm_data <= (others => '0'); + stm_m_rec.stm_valid <= '0'; + stm_m_rec.stm_sop <= '0'; + stm_m_rec.stm_eop <= '0'; + end stm_m_init; + + procedure stm_s_init( signal stm_s_rec : out stm_s_rec_t ) is + begin + stm_s_rec.stm_ready <= '0'; + stm_s_rec.stm_error <= (others => '0'); + end stm_s_init; + + procedure stm_puncture is + variable loop_max : integer; + begin + loop_max := RV.RandInt(int_stmBusPunctureMin,int_stmBusPunctureMax); + if loop_max > 0 then + for i in 1 to loop_max loop + wait until rising_edge(clk_clk); + end loop; -- i + end if; + end stm_puncture; + + procedure stm_32b_write( len : in integer; + channel : in integer; + data_vec : in data_32b_vec_t; + signal stm_s_rec : in stm_s_rec_t; + signal stm_m_rec : out stm_m_rec_t) is + variable loop_max : integer; + begin + wait until rising_edge(clk_clk); + if stm_s_rec.stm_ready = '0' then + wait until rising_edge(stm_s_rec.stm_ready); + end if; + wait until rising_edge(clk_clk); + for i in 1 to len loop + stm_m_rec.stm_channel <= std_logic_vector(to_unsigned(channel, 8)); + stm_m_rec.stm_data <= data_vec(i-1); + stm_m_rec.stm_valid <= '1'; + stm_m_rec.stm_sop <= '0'; + stm_m_rec.stm_eop <= '0'; + if i = 1 then + stm_m_rec.stm_sop <= '1'; + end if; + if i = len then + stm_m_rec.stm_eop <= '1'; + end if; + wait until rising_edge(clk_clk); + stm_m_rec.stm_valid <= '0'; + stm_m_rec.stm_sop <= '0'; + stm_m_rec.stm_eop <= '0'; + + stm_puncture; + end loop; -- i + stm_m_rec.stm_sop <= '0'; + stm_m_rec.stm_eop <= '0'; + stm_m_rec.stm_valid <= '0'; + end stm_32b_write; + + procedure stm_16b_write( len : in integer; + channel : in integer; + data_vec : in data_16b_vec_t; + signal stm_s_rec : in stm_s_rec_t; + signal stm_m_rec : out stm_m_rec_t) is + variable loop_max : integer; + begin + wait until rising_edge(clk_clk); + if stm_s_rec.stm_ready = '0' then + wait until rising_edge(stm_s_rec.stm_ready); + end if; + wait until rising_edge(clk_clk); + for i in 1 to len loop + stm_m_rec.stm_channel <= std_logic_vector(to_unsigned(channel, 8)); + stm_m_rec.stm_data <= x"0000" & data_vec(i-1); + stm_m_rec.stm_valid <= '1'; + stm_m_rec.stm_sop <= '0'; + stm_m_rec.stm_eop <= '0'; + if i = 1 then + stm_m_rec.stm_sop <= '1'; + end if; + if i = len then + stm_m_rec.stm_eop <= '1'; + end if; + wait until rising_edge(clk_clk); + stm_m_rec.stm_valid <= '0'; + stm_m_rec.stm_sop <= '0'; + stm_m_rec.stm_eop <= '0'; + + stm_puncture; + + end loop; -- i + stm_m_rec.stm_sop <= '0'; + stm_m_rec.stm_eop <= '0'; + stm_m_rec.stm_valid <= '0'; + end stm_16b_write; + + procedure stm_8b_write( len : in integer; + channel : in integer; + data_vec : in data_8b_vec_t; + signal stm_s_rec : in stm_s_rec_t; + signal stm_m_rec : out stm_m_rec_t) is + variable loop_max : integer; + begin + wait until rising_edge(clk_clk); + if stm_s_rec.stm_ready = '0' then + wait until rising_edge(stm_s_rec.stm_ready); + end if; + wait until rising_edge(clk_clk); + for i in 1 to len loop + stm_m_rec.stm_channel <= std_logic_vector(to_unsigned(channel, 8)); + stm_m_rec.stm_data <= x"000000" & data_vec(i-1); + stm_m_rec.stm_valid <= '1'; + stm_m_rec.stm_sop <= '0'; + stm_m_rec.stm_eop <= '0'; + if i = 1 then + stm_m_rec.stm_sop <= '1'; + end if; + if i = len then + stm_m_rec.stm_eop <= '1'; + end if; + wait until rising_edge(clk_clk); + stm_m_rec.stm_valid <= '0'; + stm_m_rec.stm_sop <= '0'; + stm_m_rec.stm_eop <= '0'; + + stm_puncture; + + end loop; -- i + stm_m_rec.stm_sop <= '0'; + stm_m_rec.stm_eop <= '0'; + stm_m_rec.stm_valid <= '0'; + end stm_8b_write; + + procedure stm_8b_read( signal stm_m_rec : in stm_m_rec_t; + signal stm_s_rec : out stm_s_rec_t; + data_vec : out data_8b_vec_t; + channel : out integer; + len : out integer) is + variable tmp_len : integer := 0; + begin + wait until rising_edge(clk_clk); + if stm_m_rec.stm_sop = '0' then + wait until rising_edge(stm_m_rec.stm_sop); + end if; + channel := to_integer(unsigned(stm_m_rec.stm_data)); + while stm_m_rec.stm_eop = '0' loop + tmp_len := tmp_len + 1; + wait until rising_edge(clk_clk); + if stm_m_rec.stm_valid = '1' then + data_vec(tmp_len-1) := stm_m_rec.stm_data(7 downto 0); + end if; + end loop; + len := tmp_len; + end stm_8b_read; + + ----------------------------------------------------------------------------- + -- LVDS section + ----------------------------------------------------------------------------- + + procedure lvds_m_init( signal lvds_m_rec : out lvds_m_rec_t ) is + begin + lvds_m_rec.lvds_1_rx_data <= (others => '0'); + lvds_m_rec.lvds_1_rx_nlock <= '0'; + lvds_m_rec.lvds_1_rx_clk <= '0'; + lvds_m_rec.lvds_2_rx_data <= (others => '0'); + lvds_m_rec.lvds_2_rx_nlock <= '0'; + lvds_m_rec.lvds_2_rx_clk <= '0'; + end lvds_m_init; + + procedure lvds_s_init( signal lvds_s_rec : out lvds_s_rec_t ) is + begin + lvds_s_rec.lvds_refclk <= '0'; + lvds_s_rec.lvds_1_rx_npwrdn <= '0'; + lvds_s_rec.lvds_1_rx_en <= '0'; + lvds_s_rec.lvds_2_rx_npwrdn <= '0'; + lvds_s_rec.lvds_2_rx_en <= '0'; + end lvds_s_init; + + procedure lvds_write( len : in integer; + data_vec : in data_8b_vec_t; + signal lvds_s_rec : in lvds_s_rec_t; + signal lvds_m_rec : out lvds_m_rec_t) is + variable tog : std_logic := '1'; + variable lvds_crc : std_logic_vector(7 downto 0) := x"00"; + variable lvds_tmp : std_logic_vector(7 downto 0) := x"00"; + constant STX : std_logic_vector(7 downto 0) := x"02"; + constant ETX : std_logic_vector(7 downto 0) := x"03"; + begin + wait until rising_edge(lvds_s_rec.lvds_refclk); + lvds_m_rec.lvds_1_rx_data <= '1' & '0' & STX; + wait until rising_edge(lvds_s_rec.lvds_refclk); + lvds_m_rec.lvds_1_rx_data <= '0' & '0' & std_logic_vector(to_unsigned(len / 256,8)); + wait until rising_edge(lvds_s_rec.lvds_refclk); + lvds_m_rec.lvds_1_rx_data <= '1' & '0' & std_logic_vector(to_unsigned(len mod 256,8)); + wait until rising_edge(lvds_s_rec.lvds_refclk); + for i in 0 to len-1 loop + tog := not tog; + lvds_crc := lvds_crc xor data_vec(i); + lvds_m_rec.lvds_1_rx_data <= tog & '0' & data_vec(i); + wait until rising_edge(lvds_s_rec.lvds_refclk); + end loop; -- i + tog := not tog; + lvds_m_rec.lvds_1_rx_data <= tog & '0' & lvds_crc; + wait until rising_edge(lvds_s_rec.lvds_refclk); + tog := not tog; + lvds_m_rec.lvds_1_rx_data <= tog & '0' & ETX; + wait until rising_edge(lvds_s_rec.lvds_refclk); + if tog = '1' then + lvds_m_rec.lvds_1_rx_data <= (others => '0'); + wait until rising_edge(lvds_s_rec.lvds_refclk); + end if; + end lvds_write; + + +end avalon_verify_pkg_2; diff --git a/generic_ip/fire_pulse_manager/5/sim/sim_fpm.do b/generic_ip/fire_pulse_manager/5/sim/sim_fpm.do index 980d57f..bdeb8ec 100644 --- a/generic_ip/fire_pulse_manager/5/sim/sim_fpm.do +++ b/generic_ip/fire_pulse_manager/5/sim/sim_fpm.do @@ -98,7 +98,10 @@ vcom -2008 -work $WORKLIB $COMMON_PATH/test/common_test_pkg.vhd vcom -2008 -work $WORKLIB $COMMON_PATH/test/log_pkg.vhd # Compile the VHDL packages that support bus protocols, memory mapped registers and functional procedures -vcom -2008 -work $WORKLIB $COMMON_PATH/test/avalon_verify_pkg.vhd +vcom -2008 -work $WORKLIB $COMMON_PATH/test/avalon_verify_pkg_2.vhd + +# Testbench support package +vcom -2008 -work $WORKLIB $TB_PATH/fire_pulse_manager_5_tb_pkg.vhd # Testbench vcom -2008 -work $WORKLIB $TB_PATH/fire_pulse_manager_5_tb.vhd diff --git a/generic_ip/fire_pulse_manager/5/sim/wave_fpm.do b/generic_ip/fire_pulse_manager/5/sim/wave_fpm.do index ea34572..bb7d5d7 100644 --- a/generic_ip/fire_pulse_manager/5/sim/wave_fpm.do +++ b/generic_ip/fire_pulse_manager/5/sim/wave_fpm.do @@ -1,6 +1,6 @@ onerror {resume} quietly WaveActivateNextPane {} 0 -add wave -noupdate -group TB /fire_pulse_manager_5_tb/ch_offset +add wave -noupdate -group TB -expand /fire_pulse_manager_5_tb/ch_offset add wave -noupdate -group TB /fire_pulse_manager_5_tb/reset_n add wave -noupdate -group TB /fire_pulse_manager_5_tb/clk add wave -noupdate -group TB /fire_pulse_manager_5_tb/rx_clk @@ -14,17 +14,18 @@ add wave -noupdate -group TB /fire_pulse_manager_5_tb/avs_read add wave -noupdate -group TB /fire_pulse_manager_5_tb/avs_waitrequest add wave -noupdate -group TB /fire_pulse_manager_5_tb/avs_readdata add wave -noupdate -group TB /fire_pulse_manager_5_tb/init_tx -add wave -noupdate -group TB /fire_pulse_manager_5_tb/pd_in -add wave -noupdate -group TB /fire_pulse_manager_5_tb/pd_spy add wave -noupdate -group TB /fire_pulse_manager_5_tb/inc_pos add wave -noupdate -group TB /fire_pulse_manager_5_tb/dec_pos -add wave -noupdate -group TB -radix hexadecimal /fire_pulse_manager_5_tb/abs_position -add wave -noupdate -group TB /fire_pulse_manager_5_tb/abs_spy +add wave -noupdate -group TB -radix unsigned /fire_pulse_manager_5_tb/abs_position add wave -noupdate -group TB /fire_pulse_manager_5_tb/tx_data -add wave -noupdate -group TB /fire_pulse_manager_5_tb/abs_position_d -add wave -noupdate -group TB /fire_pulse_manager_5_tb/dir_in add wave -noupdate -group TB /fire_pulse_manager_5_tb/swathe_cnt -add wave -noupdate -group TB /fire_pulse_manager_5_tb/swathe_pos +add wave -noupdate -group TB /fire_pulse_manager_5_tb/enc_p1 +add wave -noupdate -group TB /fire_pulse_manager_5_tb/enc_p2 +add wave -noupdate -group TB /fire_pulse_manager_5_tb/pd +add wave -noupdate -group TB /fire_pulse_manager_5_tb/seb_epd_enc_p1 +add wave -noupdate -group TB /fire_pulse_manager_5_tb/seb_epd_enc_p2 +add wave -noupdate -group TB /fire_pulse_manager_5_tb/seb_epd_pd +add wave -noupdate -group TB /fire_pulse_manager_5_tb/seb_epd_link_out add wave -noupdate -group TB /fire_pulse_manager_5_tb/end_of_swathe add wave -noupdate -group TB /fire_pulse_manager_5_tb/test_completed add wave -noupdate -group TB /fire_pulse_manager_5_tb/running @@ -41,6 +42,129 @@ add wave -noupdate -group TB /fire_pulse_manager_5_tb/sel_slave_0 add wave -noupdate -group TB /fire_pulse_manager_5_tb/sel_slave_1 add wave -noupdate -group TB /fire_pulse_manager_5_tb/pd_cnt add wave -noupdate -group TB /fire_pulse_manager_5_tb/fp_cnt +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/reset_n +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/clk +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/rx_clk +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/pof_rx +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/pof_tx +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/pof_iso_en +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/seb_epd_enc_p1 +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/seb_epd_enc_p2 +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/seb_epd_pd +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/seb_epd_link_out +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/fire_pulse +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/start_of_image +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/dp_dir_out +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/abs_pos_out +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/print_start +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/mon_pt +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/ins_fpm_irq_0 +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/ins_fpm_irq_1 +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/ins_fpm_irq_2 +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/ins_fpm_irq_3 +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/avs_address +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/avs_write +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/avs_writedata +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/avs_read +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/avs_waitrequest +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/avs_readdata +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/reset_n_i +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/cs_addr +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/cs_write_en +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/cs_write_data +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/cs_read_en +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/cs_read_valid +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/cs_read_data +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/cs_ctrl_write_en +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/cs_ctrl_read_en +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/cs_ctrl_read_valid +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/cs_ctrl_read_data +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/cs_pg_write_en +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/cs_pg_read_en +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/cs_pg_read_valid +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/cs_pg_read_data +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/cs_diag_write_en +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/cs_diag_read_en +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/cs_diag_read_valid +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/cs_diag_read_data +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/cs_log_write_en +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/cs_log_read_en +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/cs_log_read_valid +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/cs_log_read_data +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/cs_ie_write_en +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/cs_ie_read_en +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/cs_ie_read_valid +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/cs_ie_read_data +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/cs_ems_write_en +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/cs_ems_read_en +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/cs_ems_read_valid +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/cs_ems_read_data +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/cs_pof_write_en +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/cs_pof_read_en +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/cs_pof_read_valid +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/cs_pof_read_data +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/enable_rx +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/uart_regen_bypass +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/max_error_flag +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/rx_watchdog +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/rx_watchdog_en +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/rx_watchdog_clr +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/print_start_i +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/dw_src +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/error_rate_thres +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/parity_err_cnt +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/skip_pos_cnt +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/mon_point_src +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/dw_pulse_width +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/fine_time +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/coarse_time +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/init +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/remote_init +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/dp_dir +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/set_pos_ie +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/enc_pulse +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/pd_pulse +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/pd_pulse_ie +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/pd_pulse_pof +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/pd_ems +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/inc_pos +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/inc_pos_pof +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/inc_pos_ie +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/inc_pos_ems +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/dec_pos +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/dec_pos_pof +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/dec_pos_ie +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/dec_pos_ems +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/abs_pos +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/abs_pos_pof +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/abs_pos_ems +add wave -noupdate -group {FPM top} -radix decimal /fire_pulse_manager_5_tb/iDUT/abs_pos_ie +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/pd_pulse_mux +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/enc_p1_mux +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/enc_p2_mux +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/enc_p1_ie +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/enc_p2_ie +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/pof_tx_data +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/dw_pulse +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/dw_pulse_i +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/rst_dw_pulse +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/set_dw_pulse +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/dw_pulse_cnt +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/ch_pd +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/ch_pulse_out +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/ch_raw_pulse +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/ch_mask +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/ch_start_of_image +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/start_of_image_i +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/fire_pulse_i +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/src_sel +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/vel_meas +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/vel_sampling_per +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/one_pps +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/ext_fp_det +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/ext_fp_gen +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/pof_rx_regen +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/log_data_src add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/reset_n add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/clk add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/init @@ -383,8 +507,73 @@ add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/keepalive_peri add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/init_blocked_period add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/fifo_level add wave -noupdate -group POF_Tx /fire_pulse_manager_5_tb/iPOF_TX/fifo_level_max +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/reset_n +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/clk +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/src_sel +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/uart_regen_bypass +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/enable_rx +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/error_rate_thres +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/max_error_flag +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/rx_watchdog +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/rx_watchdog_en +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/rx_watchdog_clr +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/parity_err_cnt +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/skip_pos_cnt +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/mon_point_src +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/mon_points +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/coarse_time +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/fine_time +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/one_pps +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/ext_fp_det +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/ext_fp_gen +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/dw_src +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/dw_pulse_width +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/ins_fpm_irq_0 +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/avs_address +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/avs_write +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/avs_writedata +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/avs_read +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/avs_readdatavalid +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/avs_readdata +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/enable_rx_i +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/fine_time_wrap +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/time_ld_en +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/rx_watchdog_en_i +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/rx_watchdog_clr_i +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/uart_regen_bypass_i +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/upd_min_pos_i +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/upd_max_pos_i +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/fpm_init_i +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/fpm_init_d +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/fpm_init_start +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/fpm_init_done +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/fpm_init_done_flag +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/fpm_init_pulse +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/irq +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/irq_src +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/irq_src_d +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/irq_en +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/irq_mask +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/irq_val +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/irq_clr +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/src_sel_i +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/dw_src_i +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/mp_sel0 +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/mp_sel1 +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/mp_sel2 +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/mp_sel3 +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/bit_div +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/error_rate_thres_i +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/init_cnt +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/ext_fp_det_i +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/ext_fp_gen_i +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/dw_pulse_width_i +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/fine_time_init +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/fine_time_i +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/coarse_time_init +add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/coarse_time_i TreeUpdate [SetDefaultTree] -WaveRestoreCursors {{Cursor 1} {16135000 ps} 0} +WaveRestoreCursors {{Cursor 1} {8565000 ps} 0} quietly wave cursor active 1 configure wave -namecolwidth 223 configure wave -valuecolwidth 100 @@ -400,4 +589,4 @@ configure wave -griddelta 40 configure wave -timeline 0 configure wave -timelineunits ps update -WaveRestoreZoom {0 ps} {193574912 ps} +WaveRestoreZoom {200417556 ps} {249051708 ps} diff --git a/generic_ip/fire_pulse_manager/5/src/fire_pulse_5_pkg.vhd b/generic_ip/fire_pulse_manager/5/src/fire_pulse_5_pkg.vhd index ae43edb..6f1b89b 100644 --- a/generic_ip/fire_pulse_manager/5/src/fire_pulse_5_pkg.vhd +++ b/generic_ip/fire_pulse_manager/5/src/fire_pulse_5_pkg.vhd @@ -6,7 +6,7 @@ -- Author : Gianmarco Girau -- Company : Global Inkjet Systems -- Created : 2017-09-08 --- Last update: 2019-12-18 +-- Last update: 2020-01-03 -- SVN ID : Git -- Standard : VHDL'08 ------------------------------------------------------------------------------- @@ -25,17 +25,17 @@ package fire_pulse_5_pkg is -- Inner block mapping ----------------------------------------------------------------------------- - constant blk_size : integer := 2048; + constant BLK_SIZE : integer := 2048; - constant blk_num : integer := 10; -- number of sub-blocks with dedicated - -- C&S registers + constant BLK_NUM : integer := 10; -- number of sub-blocks with dedicated + -- C&S registers - constant fp_ctrl_id : natural := 0; -- Block ID for the Fire-Pulse-Mang Controller - constant diag_blk_id : natural := 1; -- Block ID for the Diagnostic Block - constant log_blk_id : natural := 2; -- Block ID for the Event Logger - constant int_enc_id : natural := 3; -- Block ID for the Internal Encoder Block - constant ems_blk_id : natural := 4; -- Block ID for the EMS block - constant pof_blk_id : natural := 5; -- Block ID for the POF output interface - constant pg_ch_id : natural := 6; -- Block ID for Pulse-Generator + constant FP_CTRL_ID : natural := 0; -- Block ID for the Fire-Pulse-Mang Controller + constant DIAG_BLK_ID : natural := 1; -- Block ID for the Diagnostic Block + constant LOG_BLK_ID : natural := 2; -- Block ID for the Event Logger + constant INT_ENC_ID : natural := 3; -- Block ID for the Internal Encoder Block + constant EMS_BLK_ID : natural := 4; -- Block ID for the EMS block + constant POF_BLK_ID : natural := 5; -- Block ID for the POF output interface + constant PG_CH_ID : natural := 6; -- Block ID for Pulse-Generator end package fire_pulse_5_pkg; diff --git a/generic_ip/fire_pulse_manager/5/src/fire_pulse_ctrl_5.vhd b/generic_ip/fire_pulse_manager/5/src/fire_pulse_ctrl_5.vhd index f3474cb..d89cb71 100644 --- a/generic_ip/fire_pulse_manager/5/src/fire_pulse_ctrl_5.vhd +++ b/generic_ip/fire_pulse_manager/5/src/fire_pulse_ctrl_5.vhd @@ -6,7 +6,7 @@ -- Author : Gianmarco Girau -- Company : Global Inkjet Systems -- Created : 2017-09-06 --- Last update: 2019-12-18 +-- Last update: 2020-01-02 -- SVN ID : Git -- Standard : VHDL'08 ------------------------------------------------------------------------------- @@ -28,10 +28,7 @@ entity fire_pulse_ctrl_5 is clk : in std_logic; src_sel : out std_logic_vector(3 downto 0); uart_regen_bypass : out std_logic; - upd_max_pos : out std_logic; - upd_min_pos : out std_logic; enable_rx : out std_logic; - uart_bit_div : out std_logic_vector(3 downto 0); error_rate_thres : out std_logic_vector(7 downto 0); max_error_flag : in std_logic; rx_watchdog : in std_logic; @@ -188,10 +185,6 @@ begin enable_rx <= enable_rx_i; uart_regen_bypass <= uart_regen_bypass_i; - uart_bit_div <= bit_div; - upd_max_pos <= upd_max_pos_i; - upd_min_pos <= upd_min_pos_i; - error_rate_thres <= error_rate_thres_i; rx_watchdog_en <= rx_watchdog_en_i; rx_watchdog_clr <= rx_watchdog_clr_i; @@ -207,9 +200,6 @@ begin src_sel_i <= "0000"; enable_rx_i <= '0'; uart_regen_bypass_i <= '0'; - upd_max_pos_i <= '0'; - upd_min_pos_i <= '0'; - bit_div <= "0100"; error_rate_thres_i <= X"0A"; rx_watchdog_en_i <= '1'; rx_watchdog_clr_i <= '0'; @@ -222,6 +212,8 @@ begin time_ld_en <= '0'; ext_fp_det_i <= X"0010"; ext_fp_gen_i <= X"0020"; + dw_src_i <= (others => '0'); + dw_pulse_width_i <= X"000A"; elsif (clk = '1' and clk'event) then -- CTRL registers if (avs_write = '1') then @@ -233,9 +225,6 @@ begin when POF_RX_CTRL => enable_rx_i <= avs_writedata(0); uart_regen_bypass_i <= avs_writedata(1); - upd_max_pos_i <= avs_writedata(2); - upd_min_pos_i <= avs_writedata(3); - bit_div <= avs_writedata(7 downto 4); when MON_PT_CTRL_REG => mp_sel0 <= avs_writedata(3 downto 0); mp_sel1 <= avs_writedata(7 downto 4); @@ -276,7 +265,7 @@ begin when SRC_SEL_REG => avs_readdata <= 28x"0" & src_sel_i; when POF_RX_CTRL => - avs_readdata <= X"000000" & bit_div & upd_min_pos_i & upd_max_pos_i & uart_regen_bypass_i & enable_rx_i; + avs_readdata <= (0 => enable_rx_i, 1 => uart_regen_bypass_i, others => '0'); when MON_PT_CTRL_REG => avs_readdata <= X"0000" & mp_sel3 & mp_sel2 & mp_sel1 & mp_sel0; when COARSE_TIME_INIT_REG => diff --git a/generic_ip/fire_pulse_manager/5/src/fire_pulse_manager_5.vhd b/generic_ip/fire_pulse_manager/5/src/fire_pulse_manager_5.vhd index e7d44da..6962afe 100644 --- a/generic_ip/fire_pulse_manager/5/src/fire_pulse_manager_5.vhd +++ b/generic_ip/fire_pulse_manager/5/src/fire_pulse_manager_5.vhd @@ -6,7 +6,7 @@ -- Author : Gianmarco Girau -- Company : Global Inkjet Systems -- Created : 2017-09-06 --- Last update: 2019-12-18 +-- Last update: 2020-01-03 -- SVN ID : Git -- Standard : VHDL'08 ------------------------------------------------------------------------------- @@ -85,11 +85,11 @@ architecture rtl of fire_pulse_manager_5 is signal reset_n_i : std_logic; -- signal cs_addr : std_logic_vector(10 downto 0); - signal cs_write_en : std_logic_vector(blk_num - 1 downto 0); + signal cs_write_en : std_logic_vector(BLK_NUM - 1 downto 0); signal cs_write_data : std_logic_vector(31 downto 0); - signal cs_read_en : std_logic_vector(blk_num - 1 downto 0); - signal cs_read_valid : std_logic_vector(blk_num - 1 downto 0); - signal cs_read_data : std_logic_vector(32 * blk_num - 1 downto 0); + signal cs_read_en : std_logic_vector(BLK_NUM - 1 downto 0); + signal cs_read_valid : std_logic_vector(BLK_NUM - 1 downto 0); + signal cs_read_data : std_logic_vector(32 * BLK_NUM - 1 downto 0); -- signal cs_ctrl_write_en : std_logic; signal cs_ctrl_read_en : std_logic; @@ -213,7 +213,7 @@ begin iCS_BUS_ITF : entity work.cs_bus_ift generic map( - blk_num => blk_num) + BLK_NUM => BLK_NUM) port map( rstN => reset_n_i, clk => clk, @@ -230,44 +230,44 @@ begin cs_rv => cs_read_valid, cs_rd_data => cs_read_data); - cs_ctrl_write_en <= cs_write_en(fp_ctrl_id); - cs_diag_write_en <= cs_write_en(diag_blk_id); - cs_log_write_en <= cs_write_en(log_blk_id); - cs_ie_write_en <= cs_write_en(int_enc_id); - cs_ems_write_en <= cs_write_en(ems_blk_id); - cs_pof_write_en <= cs_write_en(pof_blk_id); + cs_ctrl_write_en <= cs_write_en(FP_CTRL_ID); + cs_diag_write_en <= cs_write_en(DIAG_BLK_ID); + cs_log_write_en <= cs_write_en(LOG_BLK_ID); + cs_ie_write_en <= cs_write_en(INT_ENC_ID); + cs_ems_write_en <= cs_write_en(EMS_BLK_ID); + cs_pof_write_en <= cs_write_en(POF_BLK_ID); cs_pg_write_en_g : for i in 1 to CH_NUM generate - cs_pg_write_en(i - 1) <= cs_write_en(pg_ch_id + i - 1); + cs_pg_write_en(i - 1) <= cs_write_en(PG_CH_ID + i - 1); end generate; - cs_ctrl_read_en <= cs_read_en(fp_ctrl_id); - cs_diag_read_en <= cs_read_en(diag_blk_id); - cs_log_read_en <= cs_read_en(log_blk_id); - cs_ie_read_en <= cs_read_en(int_enc_id); - cs_ems_read_en <= cs_read_en(ems_blk_id); - cs_pof_read_en <= cs_read_en(pof_blk_id); + cs_ctrl_read_en <= cs_read_en(FP_CTRL_ID); + cs_diag_read_en <= cs_read_en(DIAG_BLK_ID); + cs_log_read_en <= cs_read_en(LOG_BLK_ID); + cs_ie_read_en <= cs_read_en(INT_ENC_ID); + cs_ems_read_en <= cs_read_en(EMS_BLK_ID); + cs_pof_read_en <= cs_read_en(POF_BLK_ID); cs_pg_read_en_g : for i in 1 to CH_NUM generate - cs_pg_read_en(i - 1) <= cs_read_en(pg_ch_id + i - 1); + cs_pg_read_en(i - 1) <= cs_read_en(PG_CH_ID + i - 1); end generate; - cs_read_valid(fp_ctrl_id) <= cs_ctrl_read_valid; - cs_read_valid(diag_blk_id) <= cs_diag_read_valid; - cs_read_valid(log_blk_id) <= cs_log_read_valid; - cs_read_valid(int_enc_id) <= cs_ie_read_valid; - cs_read_valid(ems_blk_id) <= cs_ems_read_valid; - cs_read_valid(pof_blk_id) <= cs_pof_read_valid; + cs_read_valid(FP_CTRL_ID) <= cs_ctrl_read_valid; + cs_read_valid(DIAG_BLK_ID) <= cs_diag_read_valid; + cs_read_valid(LOG_BLK_ID) <= cs_log_read_valid; + cs_read_valid(INT_ENC_ID) <= cs_ie_read_valid; + cs_read_valid(EMS_BLK_ID) <= cs_ems_read_valid; + cs_read_valid(POF_BLK_ID) <= cs_pof_read_valid; cs_read_valid_pg_g : for i in 1 to CH_NUM generate - cs_read_valid(pg_ch_id + i - 1) <= cs_pg_read_valid(i - 1); + cs_read_valid(PG_CH_ID + i - 1) <= cs_pg_read_valid(i - 1); end generate; - cs_read_data(31 + 32 * fp_ctrl_id downto 32 * fp_ctrl_id) <= cs_ctrl_read_data; - cs_read_data(31 + 32 * diag_blk_id downto 32 * diag_blk_id) <= cs_diag_read_data; - cs_read_data(31 + 32 * log_blk_id downto 32 * log_blk_id) <= cs_log_read_data; - cs_read_data(31 + 32 * int_enc_id downto 32 * int_enc_id) <= cs_ie_read_data; - cs_read_data(31 + 32 * ems_blk_id downto 32 * ems_blk_id) <= cs_ems_read_data; - cs_read_data(31 + 32 * pof_blk_id downto 32 * pof_blk_id) <= cs_pof_read_data; + cs_read_data(31 + 32 * FP_CTRL_ID downto 32 * FP_CTRL_ID) <= cs_ctrl_read_data; + cs_read_data(31 + 32 * DIAG_BLK_ID downto 32 * DIAG_BLK_ID) <= cs_diag_read_data; + cs_read_data(31 + 32 * LOG_BLK_ID downto 32 * LOG_BLK_ID) <= cs_log_read_data; + cs_read_data(31 + 32 * INT_ENC_ID downto 32 * INT_ENC_ID) <= cs_ie_read_data; + cs_read_data(31 + 32 * EMS_BLK_ID downto 32 * EMS_BLK_ID) <= cs_ems_read_data; + cs_read_data(31 + 32 * POF_BLK_ID downto 32 * POF_BLK_ID) <= cs_pof_read_data; cs_read_data_pg_g : for i in 1 to CH_NUM generate - cs_read_data(31 + 32 * (pg_ch_id + i - 1) downto 32 * (pg_ch_id + i - 1)) <= cs_pg_read_data(31 + 32 * (i - 1) downto 32 * (i - 1)); + cs_read_data(31 + 32 * (PG_CH_ID + i - 1) downto 32 * (PG_CH_ID + i - 1)) <= cs_pg_read_data(31 + 32 * (i - 1) downto 32 * (i - 1)); end generate; ----------------------------------------------------------------------------- @@ -280,10 +280,7 @@ begin clk => clk, src_sel => src_sel, uart_regen_bypass => uart_regen_bypass, - upd_max_pos => open, - upd_min_pos => open, enable_rx => enable_rx, - uart_bit_div => open, error_rate_thres => error_rate_thres, max_error_flag => max_error_flag, rx_watchdog => rx_watchdog, diff --git a/generic_ip/fire_pulse_manager/5/src/test/fire_pulse_manager_5_tb.vhd b/generic_ip/fire_pulse_manager/5/src/test/fire_pulse_manager_5_tb.vhd index 6f3df34..41a403a 100644 --- a/generic_ip/fire_pulse_manager/5/src/test/fire_pulse_manager_5_tb.vhd +++ b/generic_ip/fire_pulse_manager/5/src/test/fire_pulse_manager_5_tb.vhd @@ -6,7 +6,7 @@ -- Author : Christos Spirotis -- Company : Global Inkjet Systems -- Created : 2018-08-10 --- Last update: 2019-12-18 +-- Last update: 2020-01-06 -- SVN ID : Git -- Standard : VHDL'08 ------------------------------------------------------------------------------- @@ -14,20 +14,21 @@ -- Testbench for fire pulse manager block ------------------------------------------------------------------------------- -library modelsim_lib; -use modelsim_lib.util.all; library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; use ieee.math_real.all; + use std.textio.all; + library work; use work.fire_pulse_5_pkg.all; use work.fire_pulse_ctrl_5_pkg.all; use work.log_pkg.all; -use work.avalon_verify_pkg.all; +use work.avalon_verify_pkg_2.all; use work.pulse_generator_2_pkg.all; use work.enc_pd_emul_1_pkg.all; +use work.fire_pulse_manager_5_tb_pkg.all; library osvvm; use osvvm.RandomPkg.all; @@ -39,24 +40,27 @@ architecture behav of fire_pulse_manager_5_tb is constant CH_NUM : integer := 4; constant DEV_NUM : integer := 2; - - - constant CLK_PERIOD : time := 10.0 ns; - constant CLK_FREQ : real := 100.0e6; constant RX_CLK_PERIOD : time := CLK_PERIOD / 3; -- clock period for used by the -- UART-Rx on the POF constant POF_DELAY : time := 30 ns; -- Total delay from POF-Tx input to POF-Rx output + constant ENC_PPR : natural := 10000; + constant ENC_FREQ : enc_freq_t := 1.0e6; + + constant PD_PULSE_W : pd_pulse_width_t := 0.5; + constant PD_PERIOD : pd_period_t := 2.0; + constant NUM_ITERATIONS : natural := 5; constant SWATHE_LEN : integer := 600; - constant START_DIR : std_logic := '0'; - constant TIME_INT : time := 5000 ns; + constant IMAGE_SIZE : integer := 100; + constant START_DIR : enc_dir_t := DIR_0; + constant VERBOSITY_LEVEL : verb_level_t := VMEDIUM; type ch_offset_t is array (0 to CH_NUM - 1) of integer; - signal ch_offset : ch_offset_t := (100, 308, 316, 324); + signal ch_offset : ch_offset_t := (others => 0); type avs_read_bus_t is array (0 to DEV_NUM - 1) of std_logic_vector(31 downto 0); @@ -64,7 +68,7 @@ architecture behav of fire_pulse_manager_5_tb is signal clk : std_logic := '0'; signal rx_clk : std_logic := '0'; signal pof_tx, pof_rx : std_logic; - signal ch_pulse_out : std_logic_vector(3 downto 0); + signal ch_pulse_out : std_logic_vector(CH_NUM-1 downto 0); signal avs_address : std_logic_vector(14 downto 0); signal avs_write : std_logic_vector(DEV_NUM - 1 downto 0); signal avs_writedata : std_logic_vector(31 downto 0); @@ -73,22 +77,31 @@ architecture behav of fire_pulse_manager_5_tb is signal avs_readdata : avs_read_bus_t; -- signal init_tx : std_logic; - signal pd_in : std_logic; - signal pd_spy : std_logic; signal inc_pos : std_logic; signal dec_pos : std_logic; signal abs_position : std_logic_vector(31 downto 0); - signal abs_spy : std_logic_vector(31 downto 0); signal tx_data : std_logic; signal pof_tx_avs_rv : std_logic; signal pof_tx_avs_we_d : std_logic; + signal enc_p1 : std_logic; + signal enc_p2 : std_logic; + signal pd : std_logic; signal seb_epd_enc_p1 : std_logic; signal seb_epd_enc_p2 : std_logic; signal seb_epd_pd : std_logic; signal seb_epd_link_out : std_logic; -- - signal abs_position_d : std_logic_vector(31 downto 0); - signal dir_in : std_logic; + signal emul_address : std_logic_vector( 9 downto 0); + signal emul_write : std_logic; + signal emul_writedata : std_logic_vector(31 downto 0); + signal emul_read : std_logic; + signal emul_readdatavalid : std_logic; + signal emul_readdata : std_logic_vector(31 downto 0); + signal emul_inc_pos : std_logic; + signal emul_dec_pos : std_logic; + signal emul_pos : std_logic_vector(39 downto 0); + -- + signal enc_dir : enc_dir_t; signal swathe_cnt : integer; signal swathe_pos : integer; signal end_of_swathe : std_logic; @@ -101,29 +114,20 @@ architecture behav of fire_pulse_manager_5_tb is signal detected_error : boolean := false; signal registers_read : boolean := false; signal reprogram_offset : boolean := false; - -- signal avs_m : mm_m_rec_t; signal avs_s : mm_s_rec_t; signal sel_slave_0 : std_logic; signal sel_slave_1 : std_logic; + signal emul_s : mm_s_rec_t; + signal emul_m : mm_m_rec_t; -- type pd_cnt_t is array (0 to CH_NUM - 1) of integer; signal pd_cnt : pd_cnt_t; type fp_cnt_t is array (0 to CH_NUM - 1) of integer; - signal fp_cnt : fp_cnt_t; - type pg_offset_t is array (0 to CH_NUM - 1) of integer; - - -- generate the NCO increment corresponding to a given output frequency - function freq2NCO_inc( - f_out : real; f_clk : real) return std_logic_vector is - variable nco_inc : std_logic_vector(31 downto 0); - - begin - nco_inc := std_logic_vector(to_unsigned(integer((f_out / f_clk) * (2.0**32)), 32)); - return nco_inc; - - end function freq2NCO_inc; + signal fp_cnt : fp_cnt_t; + signal loc_fp_cnt : fp_cnt_t; + signal ch_pulse_out_d : std_logic_vector(CH_NUM-1 downto 0); begin -- behav @@ -171,8 +175,7 @@ begin -- behav avs_writedata => avs_writedata, avs_read => avs_read(0), avs_waitrequest => avs_waitrequest(0), - avs_readdata => avs_readdata(0) - ); + avs_readdata => avs_readdata(0)); pof_rx <= transport tx_data after POF_DELAY; @@ -180,22 +183,29 @@ begin -- behav -- Encoder/PD emulator (Stimuli Generator) ----------------------------------------------------------------------------- + -- The Emulator provides the Encoder and PD stimuli to the FPM: + -- When using the SEB-POF, the encoder stimuli is given by the absolute position. + -- A POF-Transmitter block (below) encodes the Absolute position and PD + -- events according to the POF-Protocol format. + -- When using the SEB-EPD, the encoder phase-1/2 outputs of the emulator are + -- directly fed as inputs to the FPM + iEMUL : entity work.enc_pd_emul_1 port map ( clk => clk, reset_n => reset_n, - ttl_pd => ttl_pd, - ttl_enc_p1 => ttl_p1, - ttl_enc_p2 => ttl_p2, - ttl_enc_zp => ttl_zp, - rs422_pd => rs422_pd, - rs422_enc_p1 => rs422_p1, - rs422_enc_p2 => rs422_p2, - rs422_enc_zp => rs422_zp, + ttl_pd => open, + ttl_enc_p1 => open, + ttl_enc_p2 => open, + ttl_enc_zp => open, + rs422_pd => pd, + rs422_enc_p1 => enc_p1, + rs422_enc_p2 => enc_p2, + rs422_enc_zp => open, abs_pos_out => emul_pos, - set_pos_out => emul_set_pos, - inc_pos_out => emul_inc_pos, - dec_pos_out => emul_dec_pos, + set_pos_out => open, + inc_pos_out => inc_pos, + dec_pos_out => dec_pos, avs_address => emul_address, avs_write => emul_write, avs_writedata => emul_writedata, @@ -203,6 +213,12 @@ begin -- behav avs_readdatavalid => emul_readdatavalid, avs_readdata => emul_readdata); + abs_position <= emul_pos(31 downto 0); + + seb_epd_pd <= pd; + seb_epd_enc_p1 <= enc_p1; + seb_epd_enc_p2 <= enc_p2; + ----------------------------------------------------------------------------- -- POF Tx (Stimuli Generator) ----------------------------------------------------------------------------- @@ -212,7 +228,7 @@ begin -- behav reset_n => reset_n, clk => clk, init => init_tx, - pd_in => pd_in, + pd_in => pd, inc_pos => inc_pos, dec_pos => dec_pos, abs_position => abs_position, @@ -238,56 +254,50 @@ begin -- behav -- Stimuli Generation ----------------------------------------------------------------------------- - /* - - pSTIMULI_REGs : process(clk) - begin - if (clk = '1' and clk'event) then - abs_position_d <= abs_position; - end if; - end process pSTIMULI_REGs; - - inc_pos <= '1' when signed(abs_position) = signed(abs_position_d) + 1 else '0'; - dec_pos <= '1' when signed(abs_position) = signed(abs_position_d) - 1 else '0'; - - seb_epd_pd <= '0'; - seb_epd_enc_p1 <= '0'; - seb_epd_enc_p2 <= '0'; - pSTIMULI : process - variable end_of_stimuli : boolean; - variable rv : RandomPType; + variable end_of_stimuli : boolean; + variable swathe_completed : boolean; + variable pd_pos : integer; + variable rv : RandomPType; begin -- initialization init_tx <= '0'; - dir_in <= START_DIR; - pd_in <= '0'; - abs_position <= (others => '0'); + enc_dir <= START_DIR; swathe_pos <= 0; -- swathe_cnt <= 0; stimuli_completed <= false; end_of_swathe <= '0'; + -- + mm_m_init(emul_m, use_readvalid => true); -- generating the stimulus - wait until running = true; + if(running /= true) then + wait until running = true; + end if; wait for 200 ns; - -- Send a Init/Sync pulse + + -- Set the initial absolute-position for the encoder emulator + set_enc_abs_pos(40x"0", emul_s, emul_m); + + -- Send a Init/Sync pulse to the POF-Tx wait until clk = '1' and clk'event; init_tx <= '1'; wait until clk = '1' and clk'event; init_tx <= '0'; wait for 500 ns; + -- -- generate the forward swathe end_of_stimuli := false; while end_of_stimuli = false loop - swathe_pos <= 0; + --swathe_pos <= 0; for i in 0 to CH_NUM - 1 loop - ch_offset(i) <= rv.RandInt(0, 379); + ch_offset(i) <= rv.RandInt(0, 199); + --ch_offset(i) <= 50; end loop; reprogram_offset <= true; wait until configuring = true; @@ -295,35 +305,36 @@ begin -- behav wait until configuring = false; wait until clk = '1' and clk'event; - - while swathe_pos /= SWATHE_LEN loop - wait until clk = '1' and clk'event; - --generate a position increment - swathe_pos <= swathe_pos + 1; - if (dir_in = '0') then - abs_position <= std_logic_vector(signed(abs_position) + 1); - else - abs_position <= std_logic_vector(signed(abs_position) - 1); - end if; - -- - if (swathe_pos = 16) then - -- generate a PD increment: the PD might be either concurren or not - -- to the position increment - wait for 0.5 * CLK_PERIOD; - pd_in <= '1'; - wait for 100 ns; - wait until clk = '1' and clk'event; - pd_in <= '0'; - end if; - wait for TIME_INT; - end loop; -- swathe_pos /= SWATHE_LEN + + -- start running the encoder + run_enc_pulses(ENC_FREQ, enc_dir, true, SWATHE_LEN, ENC_PPR, emul_s, emul_m); + if(enc_dir = DIR_0) then + log("Running Swathe " & to_string(swathe_cnt + 1) & ", DIR-0.", VMEDIUM); + else + log("Running Swathe " & to_string(swathe_cnt + 1) & ", DIR-1.", VMEDIUM); + end if; + + -- issue a PD to start firing + pd_pos := rv.RandInt(0, 49); + --pd_pos := 10; + for k in 1 to pd_pos loop + wait until abs_position'event; + end loop; -- k + run_pd_pulses(PD_PULSE_W, PD_PERIOD, true, emul_s, emul_m); + + swathe_completed := false; + while swathe_completed = false loop + wait for 500 ns; + -- Check whether the encoder generation has completed + check_max_pulses_done(swathe_completed, emul_s, emul_m); + end loop; wait for 25 us; end_of_swathe <= '1'; wait until clk = '1' and clk'event; end_of_swathe <= '0'; -- reverse direction - if (dir_in /= START_DIR) then + if (enc_dir /= START_DIR) then if (swathe_cnt = NUM_ITERATIONS - 1) then end_of_stimuli := true; else @@ -332,7 +343,11 @@ begin -- behav end if; if (end_of_stimuli = false) then wait until clk = '1' and clk'event; - dir_in <= not dir_in; + if(enc_dir = DIR_0) then + enc_dir <= DIR_1; + else + enc_dir <= DIR_0; + end if; -- Wait some time to make sure the change of direction is transmitted. -- Note: if the position starts changing before the receiver was able to -- confirm the change of direction, then some encoder pulses may not be @@ -347,31 +362,40 @@ begin -- behav end process pSTIMULI; - */ - - - ----------------------------------------------------------------------------- -- Testbench Control ----------------------------------------------------------------------------- + pOUT_CHECK_REGs : process(reset_n, clk) + begin + if(reset_n = '0') then + ch_pulse_out_d <= (others => '0'); + loc_fp_cnt <= (others => 0); + elsif(clk = '1' and clk'event) then + ch_pulse_out_d <= ch_pulse_out; + for n in 0 to CH_NUM-1 loop + if(ch_pulse_out(n) = '1' and ch_pulse_out_d(n) = '0') then + loc_fp_cnt(n) <= loc_fp_cnt(n) + 1; + end if; + end loop; -- n + end if; + end process pOUT_CHECK_REGs; + pTB_CTRL : process type fp_arrived_t is array (0 to CH_NUM - 1) of boolean; variable fp_arrived : fp_arrived_t; - type fp_arrived_time_t is array (0 to CH_NUM - 1) of integer; - variable fp_arrived_time : fp_arrived_time_t; - variable fp_arrived_agg : integer; - variable pd_arrived_time : integer; + type fp_arrived_pos_t is array (0 to CH_NUM - 1) of integer; + variable fp_arrived_pos : fp_arrived_pos_t; + variable fp_arrived_agg : integer; + variable pd_arrived_pos : integer; + alias pd_spy is <>; + alias abs_spy is <>; begin - -- init_signal_spy("/iDUT/abs_pos","abs_spy",0); - -- init_signal_spy("/iDUT/pd_pulse","pd_spy",0); - init_signal_spy("abs_position", "abs_spy", 0); - init_signal_spy("pd_in", "pd_spy", 0); -- Set the verbosity level for logging set_log_verbosity(VERBOSITY_LEVEL); - set_log_verbosity(VHIGH); + --set_log_verbosity(VHIGH); log_header("Multi-channel FPM verification:", VLOW); @@ -391,7 +415,9 @@ begin -- behav end if; wait until configuring = false; running <= true; - log("Running test ... ", VLOW, true); + log_separator_line(VLOW); + log("Configuration completed. Running test ... ", VLOW, true); + log_separator_line(VLOW); while stimuli_completed = false loop wait until ((pd_spy = '1' and pd_spy'event) or stimuli_completed); @@ -400,12 +426,12 @@ begin -- behav exit; end if; - pd_arrived_time := to_integer(signed(abs_spy)); + pd_arrived_pos := to_integer(signed(abs_spy)); for i in 0 to CH_NUM - 1 loop fp_arrived(i) := false; - fp_arrived_time(i) := 0; + fp_arrived_pos(i) := 0; end loop; - log("Product detect fired @ " & integer'image(pd_arrived_time) & " ... ", VLOW, true); + log("Product detect fired @ " & integer'image(pd_arrived_pos) & " ... ", VLOW, true); fp_arrived_agg := 0; while fp_arrived_agg < CH_NUM loop fp_arrived_agg := 0; @@ -423,10 +449,10 @@ begin -- behav for i in 0 to CH_NUM - 1 loop if ch_pulse_out(i) = '1' and fp_arrived(i) = false then fp_arrived(i) := true; - fp_arrived_time(i) := to_integer(signed(abs_spy)); - log("Channel CH" & integer'image(i) & " Fire pulse logged @ " & integer'image(fp_arrived_time(i)) & " ... ", VLOW, true); - if (abs (pd_arrived_time - fp_arrived_time(i)) /= ch_offset(i)) then - log("Channel CH" & integer'image(i) & " OFFSET INCORRECT !!! ", VLOW, true); + fp_arrived_pos(i) := to_integer(signed(abs_spy)); + log("Channel CH" & integer'image(i) & " Fire pulse logged @ " & integer'image(fp_arrived_pos(i)) & " ... ", VLOW, true); + if (abs (pd_arrived_pos - fp_arrived_pos(i)) /= ch_offset(i)) then + log("ERROR on Channel CH" & integer'image(i) & ": First Fire-Pulse detected at position " & to_string(fp_arrived_pos(i)) & ", expected position is " & to_string((pd_arrived_pos+ch_offset(i))), VLOW, true); detected_error <= true; end if; end if; @@ -445,15 +471,15 @@ begin -- behav -- Report PD and FP counter from pulse generator for i in 0 to CH_NUM - 1 loop - log("Channel CH" & integer'image(i) & " PDin counter value : " & integer'image(pd_cnt(i)) & " ... ", VLOW, true); - log("Channel CH" & integer'image(i) & " FPout counter value : " & integer'image(fp_cnt(i)) & " ... ", VLOW, true); + log("Channel CH" & integer'image(i) & " PD-in counter value : " & integer'image(pd_cnt(i)) & " ... ", VLOW, true); + log("Channel CH" & integer'image(i) & " FP-out counter value : " & integer'image(fp_cnt(i)) & " ... ", VLOW, true); + log("Channel CH" & integer'image(i) & " Detected Fire-Pulses : " & integer'image(loc_fp_cnt(i)) & " ... ", VLOW, true); if (i = 0 and (pd_cnt(i) /= (NUM_ITERATIONS) * 2)) or (i /= 0 and pd_cnt(i) /= 0) then -- fire_pulse_manager now has no registers beyond channel 0 log("Channel CH" & integer'image(i) & " PD_cnt counter value Incorrect: ", VLOW, true); detected_error <= true; end if; - if (i = 0 and (fp_cnt(i) /= (NUM_ITERATIONS) * 2 * 100)) or - (i /= 0 and fp_cnt(i) /= 0) then + if((loc_fp_cnt(i) /= (NUM_ITERATIONS) * 2 * 100) or (i = 0 and (fp_cnt(i) /= (NUM_ITERATIONS) * 2 * 100)) or (i /= 0 and fp_cnt(i) /= 0)) then log("Channel CH" & integer'image(i) & " FP_cnt counter value Incorrect: ", VLOW, true); detected_error <= true; end if; @@ -478,10 +504,6 @@ begin -- behav pUUT_CTRL : process 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 pg_off : pg_offset_t; - variable pg_ram_off : pg_offset_t; begin sel_slave_0 <= '0'; @@ -491,8 +513,6 @@ begin -- behav -- Initialize avalon mm interfaces mm_m_init(avs_m, use_waitrequest => true); - mm_m_init(emul_mm_m, use_readvalid => true); - if (reset_n = '0') then wait until reset_n = '1'; wait for 100 ns; @@ -511,168 +531,16 @@ begin -- behav sel_slave_0 <= '1'; wait until clk = '1' and clk'event; - log("Configuring EMUL ... ", VLOW, true); - -- Configure Encoder NCO freq - addr := std_logic_vector(to_unsigned(6144 + to_integer(unsigned(CSR_ENC_NCO_INC_ADDR)), 32)); - data := freq2NCO_inc(200.0e3, CLK_FREQ); - -- Write the data to the register - mm_32b_write(addr, data, avs_s, avs_m); - -- Enable outputs - addr := std_logic_vector(to_unsigned(6144 + to_integer(unsigned(CSR_OUT_ENABLE_ADDR)), 32)); - data := X"000000FF"; - -- Write the data to the register - mm_32b_write(addr, data, avs_s, avs_m); - log("Configuring FPM ... ", VLOW, true); - -- Config fire_pulse_manager control registers: - -- Enable the POF-Rx - addr := std_logic_vector(to_unsigned(3, 32)); - data := X"0000_8061"; -- set bit_div to 6 to match the 50MBd TX signal to the 300MHz RX_CLK - -- Write the data to the register - mm_32b_write(addr, data, avs_s, avs_m); - -- Select pulse generator - addr := std_logic_vector(to_unsigned(2, 32)); - data := X"0000_0001"; - -- Write the data to the register - mm_32b_write(addr, data, avs_s, avs_m); - -- Config external fire pulses - addr := std_logic_vector(to_unsigned(12, 32)); - data := X"0008_0004"; - -- Write the data to the register - mm_32b_write(addr, data, avs_s, avs_m); - - -- precompute the channel memory offsets: - for i in 0 to CH_NUM - 1 loop - pg_off(i) := (work.fire_pulse_5_pkg.pg_ch_id + i)*work.fire_pulse_5_pkg.blk_size; - pg_ram_off(i) := pg_off(i) + to_integer(unsigned(work.pulse_generator_2_pkg.SEQ_RAM_OFFSET)); - end loop; -- i + + fpm_ctrl_config(avs_s, avs_m); config_pg_l : for i in 0 to CH_NUM - 1 loop - -- Disable/Re-enable first the whole pulse_generator - addr := std_logic_vector(to_unsigned(pg_off(i) + to_integer(unsigned(work.pulse_generator_2_pkg.PULSE_GEN_CTRL_REG)), 32)); - data := (others => '0'); - mm_32b_write(addr, data, avs_s, avs_m); - data := (0 => '1', 16 => '1', others => '0'); - mm_32b_write(addr, data, avs_s, avs_m); - -- Disable/Re-enable the Channel Controller sequencer - addr := std_logic_vector(to_unsigned(pg_off(i) + to_integer(unsigned(work.pulse_generator_2_pkg.CH_CTRL_CTRL_REG)), 32)); - data := (others => '0'); - mm_32b_write(addr, data, avs_s, avs_m); - addr := std_logic_vector(to_unsigned(pg_off(i) + to_integer(unsigned(work.pulse_generator_2_pkg.CH_CTRL_CTRL_REG)), 32)); - data := (0 => '1', others => '0'); - mm_32b_write(addr, data, avs_s, avs_m); - -- set the sub-pixel offset - data := std_logic_vector(to_unsigned(0, 32)); - addr := std_logic_vector(to_unsigned(pg_off(i) + to_integer(unsigned(work.pulse_generator_2_pkg.SP_OFFSET_INT)), 32)); - mm_32b_write(addr, data, avs_s, avs_m); - data := std_logic_vector(to_unsigned(0, 32)); - addr := std_logic_vector(to_unsigned(pg_off(i) + to_integer(unsigned(work.pulse_generator_2_pkg.SP_OFFSET_FRAC)), 32)); - mm_32b_write(addr, data, avs_s, avs_m); - -- set the division ratio - ratio_int := integer(2.0 * 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(to_unsigned(pg_off(i) + to_integer(unsigned(work.pulse_generator_2_pkg.DIV_RATIO_INT)), 32)); - mm_32b_write(addr, data, avs_s, avs_m); - -- 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(to_unsigned(pg_off(i) + to_integer(unsigned(work.pulse_generator_2_pkg.DIV_RATIO_FRAC)), 32)); - mm_32b_write(addr, data, avs_s, avs_m); - -- Disable/Enable the fractional divider - addr := std_logic_vector(to_unsigned(pg_off(i) + to_integer(unsigned(work.pulse_generator_2_pkg.FRAC_DIV_CTRL_REG)), 32)); - data := (others => '0'); - mm_32b_write(addr, data, avs_s, avs_m); - data := (0 => '1', others => '0'); - mm_32b_write(addr, data, avs_s, avs_m); - -- Configure the Channel Offset (Both DIR_0 and DIR_1): - -- DIR_0 - addr := std_logic_vector(to_unsigned(pg_off(i) + to_integer(unsigned(work.pulse_generator_2_pkg.CH_OFFSET_D0_REG)), 32)); - data := std_logic_vector(to_unsigned(ch_offset(i), 32)); - mm_32b_write(addr, data, avs_s, avs_m); - -- DIR_1 - addr := std_logic_vector(to_unsigned(pg_off(i) + to_integer(unsigned(work.pulse_generator_2_pkg.CH_OFFSET_D1_REG)), 32)); - data := std_logic_vector(to_unsigned(ch_offset(i), 32)); - mm_32b_write(addr, data, avs_s, avs_m); - -- Configure the Channel Delay - addr := std_logic_vector(to_unsigned(pg_off(i) + to_integer(unsigned(work.pulse_generator_2_pkg.CH_DELAY_REG)), 32)); - data := std_logic_vector(to_unsigned(0, 32)); - mm_32b_write(addr, data, avs_s, avs_m); - -- Fill Sequencer RAM with simple swathe DIR-0 - -- 0x00, 0x30000000 – Reset the vector output value - addr := std_logic_vector(to_unsigned(pg_ram_off(i), 32)); - data := X"30000000"; - mm_32b_write(addr, data, avs_s, avs_m); - -- 0x01, 0x10000001 – Trigger Mask (PD trigger enabled) - addr := std_logic_vector(to_unsigned(pg_ram_off(i) + 1, 32)); - data := X"10000001"; - mm_32b_write(addr, data, avs_s, avs_m); - -- 0x02, 0x20000001 – Wait for a single PD event - addr := std_logic_vector(to_unsigned(pg_ram_off(i) + 2, 32)); - data := X"20000001"; - mm_32b_write(addr, data, avs_s, avs_m); - -- 0x03, 0x30006404 – Issue a request for starting the generation of 100 fire pulses (DIR-0) - addr := std_logic_vector(to_unsigned(pg_ram_off(i) + 3, 32)); - data := X"30006404"; - mm_32b_write(addr, data, avs_s, avs_m); - -- 0x04, 0x30006400 – De-assert the request bit (start_image_req) - addr := std_logic_vector(to_unsigned(pg_ram_off(i) + 4, 32)); - data := X"30006400"; - mm_32b_write(addr, data, avs_s, avs_m); - -- 0x05, 0x80000258 – Wait till POS END - addr := std_logic_vector(to_unsigned(pg_ram_off(i) + 5, 32)); - data := X"80000258"; - mm_32b_write(addr, data, avs_s, avs_m); - -- 0x06, 0xC0000000 – Jump to DIR-1 - addr := std_logic_vector(to_unsigned(pg_ram_off(i) + 6, 32)); - data := X"C0000010"; - mm_32b_write(addr, data, avs_s, avs_m); + pulse_gen_config(i, ch_offset(i), IMAGE_SIZE, avs_s, avs_m); - -- Fill Sequencer RAM with simple swathe DIR-1 - -- 0x10, 0x30000000 – Reset the vector output value - addr := std_logic_vector(to_unsigned(pg_ram_off(i) + 16, 32)); - data := X"30000001"; - mm_32b_write(addr, data, avs_s, avs_m); - -- 0x11, 0x10000001 – Trigger Mask (PD trigger enabled) - addr := std_logic_vector(to_unsigned(pg_ram_off(i) + 17, 32)); - data := X"10000001"; - mm_32b_write(addr, data, avs_s, avs_m); - -- 0x12, 0x20000001 – Wait for a single PD event - addr := std_logic_vector(to_unsigned(pg_ram_off(i) + 18, 32)); - data := X"20000001"; - mm_32b_write(addr, data, avs_s, avs_m); - -- 0x13, 0x30006405 – Issue a request for starting the generation of 100 fire pulses (DIR-1) - addr := std_logic_vector(to_unsigned(pg_ram_off(i) + 19, 32)); - data := X"30006405"; - mm_32b_write(addr, data, avs_s, avs_m); - -- 0x14, 0x30006401 – De-assert the request bit (start_image_req) - addr := std_logic_vector(to_unsigned(pg_ram_off(i) + 20, 32)); - data := X"30006401"; - mm_32b_write(addr, data, avs_s, avs_m); - -- 0x15, 0x80000000 – Wait till POS START - addr := std_logic_vector(to_unsigned(pg_ram_off(i) + 21, 32)); - data := X"80000000"; - mm_32b_write(addr, data, avs_s, avs_m); - -- 0x16, 0xC0000000 – Jump to DIR-0 - addr := std_logic_vector(to_unsigned(pg_ram_off(i) + 22, 32)); - data := X"C0000000"; - mm_32b_write(addr, data, avs_s, avs_m); - - -- Start Sequencer - addr := std_logic_vector(to_unsigned(pg_off(i) + to_integer(unsigned(work.pulse_generator_2_pkg.SEQ_CSR_OFFSET) + 3), 32)); - data := (0 => '1', others => '0'); - mm_32b_write(addr, data, avs_s, avs_m); end loop config_pg_l; - -- Init the encoder NCO - Preset Abs-Pos - addr := std_logic_vector(to_unsigned(6144 + to_integer(unsigned(CSR_ENC_CTRL_ADDR)), 32)); - data := 32X"B"; - -- Write the data to the register - mm_32b_write(addr, data, avs_s, avs_m); - log("Configuration completed.", VLOW, true); configuring <= false; @@ -682,64 +550,34 @@ begin -- behav exit; end if; + log("Reading counters ... ", VLOW, true); + -- Read PD and FP counter from pulse generator + for i in 0 to CH_NUM - 1 loop + fpm_reg_read(PG_CH_ID+i, work.pulse_generator_2_pkg.PD_IN_CNT_REG, data, avs_s, avs_m); + pd_cnt(i) <= to_integer(unsigned(data)); + fpm_reg_read(PG_CH_ID+i, work.pulse_generator_2_pkg.FIRE_REQ_CNT_REG, data, avs_s, avs_m); + fp_cnt(i) <= to_integer(unsigned(data)); + wait until clk = '1' and clk'event; + log("CH-" & to_string(i) & ": pd_in_cnt = " & to_string(pd_cnt(i)) & ", fire_req_cnt = " & to_string(fp_cnt(i)) & ", detected fire-req-cnt = " & to_string(loc_fp_cnt(i)), VMEDIUM); + end loop; + configuring <= true; log("Reprogramming offset ... ", VLOW, true); config_of_l : for i in 0 to CH_NUM - 1 loop - -- Configure the Channel Offset (Both DIR_0 and DIR_1): - -- DIR_0 - addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(CH_OFFSET_D0_REG)), 32)); - data := std_logic_vector(to_unsigned(ch_offset(i), 32)); - mm_32b_write(addr, data, avs_s, avs_m); - -- DIR_1 - addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(CH_OFFSET_D1_REG)), 32)); - data := std_logic_vector(to_unsigned(ch_offset(i), 32)); - mm_32b_write(addr, data, avs_s, avs_m); + ch_offset_config(i, ch_offset(i), avs_s, avs_m); end loop; configuring <= false; - -- issue PD - addr := std_logic_vector(to_unsigned(6144 + to_integer(unsigned(CSR_PD_CTRL_ADDR)), 32)); - data := 32X"3"; - -- Write the data to the register - mm_32b_write(addr, data, avs_s, avs_m); - if dir_in = '0' then - log("Running 600 steps in DIR-0 ...", VLOW); - addr := std_logic_vector(to_unsigned(6144 + to_integer(unsigned(CSR_PULSE_NUM_ADDR)), 32)); - data := 32X"258"; - -- Write the data to the register - mm_32b_write(addr, data, avs_s, avs_m); - addr := std_logic_vector(to_unsigned(6144 + to_integer(unsigned(CSR_ENC_CTRL_ADDR)), 32)); - data := 32X"11"; - -- Write the data to the register - mm_32b_write(addr, data, avs_s, avs_m); - addr := std_logic_vector(to_unsigned(6144 + to_integer(unsigned(CSR_ENC_CTRL_ADDR)), 32)); - data := 32X"31"; - -- Write the data to the register - mm_32b_write(addr, data, avs_s, avs_m); - else - log("Running 600 steps in DIR-1 ...", VLOW); - addr := std_logic_vector(to_unsigned(6144 + to_integer(unsigned(CSR_PULSE_NUM_ADDR)), 32)); - data := 32X"258"; - -- Write the data to the register - mm_32b_write(addr, data, avs_s, avs_m); - addr := std_logic_vector(to_unsigned(6144 + to_integer(unsigned(CSR_ENC_CTRL_ADDR)), 32)); - data := 32X"15"; - -- Write the data to the register - mm_32b_write(addr, data, avs_s, avs_m); - addr := std_logic_vector(to_unsigned(6144 + to_integer(unsigned(CSR_ENC_CTRL_ADDR)), 32)); - data := 32X"35"; - -- Write the data to the register - mm_32b_write(addr, data, avs_s, avs_m); - end if; end loop; + log("Reading counters ... ", VLOW, true); -- Read PD and FP counter from pulse generator for i in 0 to CH_NUM - 1 loop - addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(PD_IN_CNT_REG)), 32)); - mm_32b_read(addr, data, avs_s, avs_m); + fpm_reg_read(PG_CH_ID+i, work.pulse_generator_2_pkg.PD_IN_CNT_REG, data, avs_s, avs_m); pd_cnt(i) <= to_integer(unsigned(data)); - addr := std_logic_vector(to_unsigned(8192 + (2048 * i) + to_integer(unsigned(FIRE_REQ_CNT_REG)), 32)); - mm_32b_read(addr, data, avs_s, avs_m); + fpm_reg_read(PG_CH_ID+i, work.pulse_generator_2_pkg.FIRE_REQ_CNT_REG, data, avs_s, avs_m); fp_cnt(i) <= to_integer(unsigned(data)); + wait until clk = '1' and clk'event; + log("CH-" & to_string(i) & ": pd_in_cnt = " & to_string(pd_cnt(i)) & ", fire_req_cnt = " & to_string(fp_cnt(i)), VMEDIUM); end loop; registers_read <= true; @@ -758,8 +596,6 @@ begin -- behav avs_s.mm_waitrequest <= avs_waitrequest(0) when sel_slave_0 = '1' else avs_waitrequest(1) when sel_slave_1 = '1' else '0'; - avs_s.use_readvalid <= false; - avs_address <= avs_m.mm_address(avs_address'range); avs_write(0) <= avs_m.mm_write and sel_slave_0; avs_write(1) <= avs_m.mm_write and sel_slave_1; @@ -768,14 +604,14 @@ begin -- behav avs_read(1) <= avs_m.mm_read and sel_slave_1; -- Emulator Avalon bus maapings - emul_mm_s.mm_readdata <= emul_readdata; - emul_mm_s.mm_readdatavalid <= emul_readdatavalid; - emul_mm_s.mm_waitrequest <= '0'; + emul_s.mm_readdata <= emul_readdata; + emul_s.mm_readdatavalid <= emul_readdatavalid; + emul_s.mm_waitrequest <= '0'; - emul_address <= emul_mm_m.mm_address(emul_address'range); - emul_writedata <= emul_mm_m.mm_writedata; - emul_write <= emul_mm_m.mm_write; - emul_read <= emul_mm_m.mm_read; + emul_address <= emul_m.mm_address(emul_address'range); + emul_writedata <= emul_m.mm_writedata; + emul_write <= emul_m.mm_write; + emul_read <= emul_m.mm_read; end behav; diff --git a/generic_ip/fire_pulse_manager/5/src/test/fire_pulse_manager_5_tb_pkg.vhd b/generic_ip/fire_pulse_manager/5/src/test/fire_pulse_manager_5_tb_pkg.vhd new file mode 100644 index 0000000..72b6a56 --- /dev/null +++ b/generic_ip/fire_pulse_manager/5/src/test/fire_pulse_manager_5_tb_pkg.vhd @@ -0,0 +1,743 @@ +------------------------------------------------------------------------------- +-- Title : fire_pulse_manager_5_tb_pkg +-- Project : SMB +------------------------------------------------------------------------------- +-- File : fire_pulse_manager_5_tb_pkg.vhd +-- Author : Gianmarco Girau +-- Company : Global Inkjet Systems +-- Created : 2020-01-02 +-- Last update: 2020-01-06 +-- SVN ID : Git +-- Standard : VHDL'2008 +------------------------------------------------------------------------------- +-- Description: +-- Support package for the FPM testbench +------------------------------------------------------------------------------- + +--library std; +--use std.textio.all; + +library ieee; +use ieee.std_logic_1164.all; +use ieee.std_logic_textio.all; +use ieee.numeric_std.all; +use ieee.math_real.all; + +library work; +use work.fire_pulse_5_pkg.all; +use work.enc_pd_emul_1_pkg.all; +use work.fire_pulse_ctrl_5_pkg.all; + +library OSVVM ; +use OSVVM.RandomBasePkg.all ; +use OSVVM.RandomPkg.all; + +library work; +use work.log_pkg.all; +use work.avalon_verify_pkg_2.all; +use work.enc_pd_emul_1_pkg.all; + +package fire_pulse_manager_5_tb_pkg is + + constant CLK_PERIOD : time := 10.0 ns; + constant CLK_FREQ : real := 100.0e6; + + constant ENC_NCO_WIDTH : positive := 32; + + -- Logging Verbosity Level + constant VERBOSITY_LEVEL : verb_level_t := VMEDIUM; + + ----------------------------------------------------------------------------- + -- FPM Configuration + ----------------------------------------------------------------------------- + + -- fpm_reg_write with addr defined as std_logic_vector + procedure fpm_reg_write( + blk_id : in natural range 0 to BLK_NUM-1; + addr : in std_logic_vector; + data : in std_logic_vector(31 downto 0); + signal mm_s : in mm_s_rec_t; + signal mm_m : out mm_m_rec_t); + + -- fpm_reg_write with addr defined as integer + procedure fpm_reg_write( + blk_id : in natural range 0 to BLK_NUM-1; + addr : in integer; + data : in std_logic_vector(31 downto 0); + signal mm_s : in mm_s_rec_t; + signal mm_m : out mm_m_rec_t); + + -- fpm_reg_read with addr defined as std_logic_vector + procedure fpm_reg_read( + blk_id : in natural range 0 to BLK_NUM-1; + addr : in std_logic_vector; + data : out std_logic_vector(31 downto 0); + signal mm_s : in mm_s_rec_t; + signal mm_m : out mm_m_rec_t); + + -- fpm_reg_read with addr defined as integer + procedure fpm_reg_read( + blk_id : in natural range 0 to BLK_NUM-1; + addr : in integer; + data : out std_logic_vector(31 downto 0); + signal mm_s : in mm_s_rec_t; + signal mm_m : out mm_m_rec_t); + + procedure fpm_ctrl_config( + signal mm_s : in mm_s_rec_t; + signal mm_m : out mm_m_rec_t); + + procedure ch_offset_config( + ch_id : in natural; + ch_offset : in natural; + signal mm_s : in mm_s_rec_t; + signal mm_m : out mm_m_rec_t); + + procedure ch_ctrl_config( + ch_id : in natural; + pixel_num : in natural; + signal mm_s : in mm_s_rec_t; + signal mm_m : out mm_m_rec_t); + + procedure pulse_gen_config( + ch_id : in natural; + ch_offset : in natural; + pixel_num : in natural; + signal mm_s : in mm_s_rec_t; + signal mm_m : out mm_m_rec_t); + + ----------------------------------------------------------------------------- + -- ENC/PD Emulator Configuration + ----------------------------------------------------------------------------- + + type enc_phase_t is (SINGLE_PHASE, DUAL_PHASE); + type enc_edge_t is (RISING, FALLING, RISING_AND_FALLING); + type pd_edge_t is (RISING, FALLING, RISING_AND_FALLING); + subtype enc_freq_t is real range 0.0e3 to 10.0e6; + subtype pd_pulse_width_t is real range 0.0 to 1000.0; -- PD period in us + --subtype pd_period_t is real range 50.0 to 1.0e6; -- PD period in us + subtype pd_period_t is real range 0.5 to 1.0e6; -- PD period in us + + type enc_dir_t is (DIR_0, DIR_1); + + type emul_cfg_t is record + + enc_res : real; + enc_ppr : integer; + enc_phase : enc_phase_t; + enc_edge : enc_edge_t; + enc_dir : enc_dir_t; + pd_edge : pd_edge_t; + enc_freq : enc_freq_t; + pd_pulse_w : pd_pulse_width_t; + pd_period : pd_period_t; + enc_pulses : integer; + + end record emul_cfg_t; + + -- set abs-pos + procedure set_enc_abs_pos( + abs_pos : in std_logic_vector(39 downto 0); + signal mm_s_rec : in mm_s_rec_t; + signal mm_m_rec : out mm_m_rec_t); + + -- The ENC/PD emulator configuration is derived from the EMS + procedure apply_enc_pd_emul_cfg( + cfg : in emul_cfg_t; + init : in boolean := true; + run_pulses_mode : in boolean := false; + signal mm_s_rec : in mm_s_rec_t; + signal mm_m_rec : out mm_m_rec_t); + + -- Stop the ENC/PD emulator + procedure stop_enc_pd_emul( + signal mm_s_rec : in mm_s_rec_t; + signal mm_m_rec : out mm_m_rec_t); + + procedure check_max_pulses_done( + done : out boolean; + signal mm_s_rec : in mm_s_rec_t; + signal mm_m_rec : out mm_m_rec_t); + + -- Run a fix number of encoder pulses + procedure run_enc_pulses( + enc_freq : in enc_freq_t; + direction : in enc_dir_t; + double_ph_mode : in boolean := true; + num_pulses : in integer; + enc_ppr : in integer; + signal mm_s_rec : in mm_s_rec_t; + signal mm_m_rec : out mm_m_rec_t); + + -- Run PD pulses: either single pulse or periodic mode + procedure run_pd_pulses( + pulse_width : in pd_pulse_width_t; + pd_period : in pd_period_t; + single_pulse_mode : in boolean := false; + signal mm_s_rec : in mm_s_rec_t; + signal mm_m_rec : out mm_m_rec_t); + + ----------------------------------------------------------------------------- + -- Support functions + ----------------------------------------------------------------------------- + + -- generate the NCO increment corresponding to a given output frequency + function freq2NCO_inc( + f_out : real; f_clk : real) return std_logic_vector; + +end fire_pulse_manager_5_tb_pkg; + +package body fire_pulse_manager_5_tb_pkg is + + ----------------------------------------------------------------------------- + -- FPM Configuration + ----------------------------------------------------------------------------- + + -- fpm_reg_write with addr defined as std_logic_vector + procedure fpm_reg_write( + blk_id : in natural range 0 to BLK_NUM-1; + addr : in std_logic_vector; + data : in std_logic_vector(31 downto 0); + signal mm_s : in mm_s_rec_t; + signal mm_m : out mm_m_rec_t) is + + variable address : std_logic_vector(31 downto 0); + + begin + + address := std_logic_vector(to_unsigned(blk_id*BLK_SIZE+to_integer(unsigned(addr)),32)); + mm_32b_write(address, data, mm_s, mm_m); + + end procedure fpm_reg_write; + + -- fpm_reg_write with addr defined as integer + procedure fpm_reg_write( + blk_id : in natural range 0 to BLK_NUM-1; + addr : in integer; + data : in std_logic_vector(31 downto 0); + signal mm_s : in mm_s_rec_t; + signal mm_m : out mm_m_rec_t) is + + variable address : std_logic_vector(31 downto 0); + + begin + + address := std_logic_vector(to_unsigned((blk_id*BLK_SIZE)+addr,32)); + mm_32b_write(address, data, mm_s, mm_m); + + end procedure fpm_reg_write; + + -- fpm_reg_read with addr defined as std_logic_vector + procedure fpm_reg_read( + blk_id : in natural range 0 to BLK_NUM-1; + addr : in std_logic_vector; + data : out std_logic_vector(31 downto 0); + signal mm_s : in mm_s_rec_t; + signal mm_m : out mm_m_rec_t) is + + variable address : std_logic_vector(31 downto 0); + + begin + + address := std_logic_vector(to_unsigned(blk_id*BLK_SIZE+to_integer(unsigned(addr)),32)); + mm_32b_read(address, data, mm_s, mm_m); + + end procedure fpm_reg_read; + + -- fpm_reg_read with addr defined as std_logic_vector + procedure fpm_reg_read( + blk_id : in natural range 0 to BLK_NUM-1; + addr : in integer; + data : out std_logic_vector(31 downto 0); + signal mm_s : in mm_s_rec_t; + signal mm_m : out mm_m_rec_t) is + + variable address : std_logic_vector(31 downto 0); + + begin + + address := std_logic_vector(to_unsigned((blk_id*BLK_SIZE)+addr,32)); + mm_32b_read(address, data, mm_s, mm_m); + + end procedure fpm_reg_read; + + procedure fpm_ctrl_config( + signal mm_s : in mm_s_rec_t; + signal mm_m : out mm_m_rec_t) is + + variable data : std_logic_vector(31 downto 0); + + begin + + log("Configuring FPM Controller ... ", VMEDIUM, true); + -- Enable the POF-Rx + data := X"0000_0001"; + fpm_reg_write(FP_CTRL_ID, POF_RX_CTRL, data, mm_s, mm_m); + + -- Select the input source + data := X"0000_0001"; + fpm_reg_write(FP_CTRL_ID, SRC_SEL_REG, data, mm_s, mm_m); + + -- Config external fire pulses + data := X"0008_0004"; + -- Write the data to the register + fpm_reg_write(FP_CTRL_ID, EXT_FP_CTRL_REG, data, mm_s, mm_m); + + end procedure fpm_ctrl_config; + + procedure ch_offset_config( + ch_id : in natural; + ch_offset : in natural; + signal mm_s : in mm_s_rec_t; + signal mm_m : out mm_m_rec_t) is + + variable data : std_logic_vector(31 downto 0); + + begin + + -- Disable/Re-enable first the whole pulse_generator + data := std_logic_vector(to_unsigned(ch_offset, 32)); + fpm_reg_write(PG_CH_ID+ch_id, work.pulse_generator_2_pkg.CH_OFFSET_D0_REG, data, mm_s, mm_m); + fpm_reg_write(PG_CH_ID+ch_id, work.pulse_generator_2_pkg.CH_OFFSET_D1_REG, data, mm_s, mm_m); + + log("CH-" & to_string(ch_id) & ": PD offset configured to " & to_string(ch_offset) & ".", VMEDIUM); + + end procedure ch_offset_config; + + procedure ch_ctrl_config( + ch_id : in natural; + pixel_num : in natural; + signal mm_s : in mm_s_rec_t; + signal mm_m : out mm_m_rec_t) is + + variable data : std_logic_vector(31 downto 0); + variable ram_idx : natural; + variable ram_offset : natural; + + begin + + ram_offset := to_integer(unsigned(work.pulse_generator_2_pkg.SEQ_RAM_OFFSET)); + ram_idx := 0; + + -- Issue first an image on DIR-0, then on DIR-1 + -- Reset the vector output value + data := X"30000000"; + fpm_reg_write(PG_CH_ID+ch_id, ram_offset+ram_idx, data, mm_s, mm_m); + ram_idx := ram_idx + 1; + -- Enable Trigger Mask (All the triggers) + data := X"1000000F"; + fpm_reg_write(PG_CH_ID+ch_id, ram_offset+ram_idx, data, mm_s, mm_m); + ram_idx := ram_idx + 1; + -- Wait for a single PD event + data := X"20000001"; + fpm_reg_write(PG_CH_ID+ch_id, ram_offset+ram_idx, data, mm_s, mm_m); + ram_idx := ram_idx + 1; + -- Issue a request to generate 'pixel_num' fire requests + data := X"30" & std_logic_vector(to_unsigned(pixel_num,16)) & X"24"; + fpm_reg_write(PG_CH_ID+ch_id, ram_offset+ram_idx, data, mm_s, mm_m); + ram_idx := ram_idx + 1; + data := X"30" & std_logic_vector(to_unsigned(pixel_num,16)) & X"00"; + fpm_reg_write(PG_CH_ID+ch_id, ram_offset+ram_idx, data, mm_s, mm_m); + ram_idx := ram_idx + 1; + -- wait until the end of the image + data := X"23000001"; + fpm_reg_write(PG_CH_ID+ch_id, ram_offset+ram_idx, data, mm_s, mm_m); + ram_idx := ram_idx + 1; + -- Switch to DIR-1 + data := X"30000001"; + fpm_reg_write(PG_CH_ID+ch_id, ram_offset+ram_idx, data, mm_s, mm_m); + ram_idx := ram_idx + 1; + -- Wait for a single PD event + data := X"20000001"; + fpm_reg_write(PG_CH_ID+ch_id, ram_offset+ram_idx, data, mm_s, mm_m); + ram_idx := ram_idx + 1; + -- Issue a request to generate 'pixel_num' fire requests + data := X"30" & std_logic_vector(to_unsigned(pixel_num,16)) & X"25"; + fpm_reg_write(PG_CH_ID+ch_id, ram_offset+ram_idx, data, mm_s, mm_m); + ram_idx := ram_idx + 1; + data := X"30" & std_logic_vector(to_unsigned(pixel_num,16)) & X"01"; + fpm_reg_write(PG_CH_ID+ch_id, ram_offset+ram_idx, data, mm_s, mm_m); + ram_idx := ram_idx + 1; + -- wait until the end of the image + data := X"23000001"; + fpm_reg_write(PG_CH_ID+ch_id, ram_offset+ram_idx, data, mm_s, mm_m); + ram_idx := ram_idx + 1; + -- Jump to DIR-0 + data := X"C0000000"; + fpm_reg_write(PG_CH_ID+ch_id, ram_offset+ram_idx, data, mm_s, mm_m); + ram_idx := ram_idx + 1; + + end procedure ch_ctrl_config; + + procedure pulse_gen_config( + ch_id : in natural; + ch_offset : in natural; + pixel_num : in natural; + signal mm_s : in mm_s_rec_t; + signal mm_m : out mm_m_rec_t) is + + variable data : std_logic_vector(31 downto 0); + variable ratio_int : integer; + variable ratio_slv : std_logic_vector(33 downto 0); + + begin + + log("Configuring Channel " & to_string(ch_id) & " ... ", VMEDIUM, true); + + -- Disable/Re-enable first the whole pulse_generator + data := (others => '0'); + fpm_reg_write(PG_CH_ID+ch_id, work.pulse_generator_2_pkg.PULSE_GEN_CTRL_REG, data, mm_s, mm_m); + data := (0 => '1', 16 => '1', others => '0'); + fpm_reg_write(PG_CH_ID+ch_id, work.pulse_generator_2_pkg.PULSE_GEN_CTRL_REG, data, mm_s, mm_m); + + -- Disable/Re-enable the Channel Controller sequencer + data := (others => '0'); + fpm_reg_write(PG_CH_ID+ch_id, work.pulse_generator_2_pkg.CH_CTRL_CTRL_REG, data, mm_s, mm_m); + data := (0 => '1', others => '0'); + fpm_reg_write(PG_CH_ID+ch_id, work.pulse_generator_2_pkg.CH_CTRL_CTRL_REG, data, mm_s, mm_m); + -- set the sub-pixel offset + data := std_logic_vector(to_unsigned(0, 32)); + fpm_reg_write(PG_CH_ID+ch_id, work.pulse_generator_2_pkg.SP_OFFSET_INT, data, mm_s, mm_m); + data := std_logic_vector(to_unsigned(0, 32)); + fpm_reg_write(PG_CH_ID+ch_id, work.pulse_generator_2_pkg.SP_OFFSET_FRAC, data, mm_s, mm_m); + -- set the division ratio + ratio_int := integer(2.0 * 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); + fpm_reg_write(PG_CH_ID+ch_id, work.pulse_generator_2_pkg.DIV_RATIO_INT, data, mm_s, mm_m); + data(31 downto 24) := (others => '0'); + data(23 downto 0) := ratio_slv(23 downto 0); + fpm_reg_write(PG_CH_ID+ch_id, work.pulse_generator_2_pkg.DIV_RATIO_FRAC, data, mm_s, mm_m); + -- Disable/Enable the fractional divider + data := (others => '0'); + fpm_reg_write(PG_CH_ID+ch_id, work.pulse_generator_2_pkg.FRAC_DIV_CTRL_REG, data, mm_s, mm_m); + data := (0 => '1', others => '0'); + fpm_reg_write(PG_CH_ID+ch_id, work.pulse_generator_2_pkg.FRAC_DIV_CTRL_REG, data, mm_s, mm_m); + + -- configure the channel offset + ch_offset_config(ch_id, ch_offset, mm_s, mm_m); + + -- Configure the sequencer RAM + ch_ctrl_config(ch_id, pixel_num, mm_s, mm_m); + + -- Restart the sequencer + data := (others => '0'); + fpm_reg_write(PG_CH_ID+ch_id, to_integer(unsigned(work.pulse_generator_2_pkg.SEQ_CSR_OFFSET)) + 3, data, mm_s, mm_m); + data := (0 => '1', others => '0'); + fpm_reg_write(PG_CH_ID+ch_id, to_integer(unsigned(work.pulse_generator_2_pkg.SEQ_CSR_OFFSET)) + 3, data, mm_s, mm_m); + + end procedure pulse_gen_config; + + ----------------------------------------------------------------------------- + -- ENC/PD Emulator Configuration + ----------------------------------------------------------------------------- + + procedure set_enc_abs_pos( + abs_pos : in std_logic_vector(39 downto 0); + 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 + + -- set the value for MSBs + addr:= std_logic_vector(resize(unsigned(CSR_POS_INIT_MSB_ADDR), 32)); + mm_32b_write(addr, 24x"0" & abs_pos(39 downto 32), mm_s_rec, mm_m_rec); + -- set the value for LSBs + addr:= std_logic_vector(resize(unsigned(CSR_POS_INIT_LSB_ADDR), 32)); + mm_32b_write(addr, abs_pos(31 downto 0), mm_s_rec, mm_m_rec); + -- read back the encoder configuration, then apply the set_abs_pos control + -- bit + addr:= std_logic_vector(resize(unsigned(CSR_ENC_CTRL_ADDR), 32)); + mm_32b_read(addr, data, mm_s_rec, mm_m_rec); + data(3) := '1'; + mm_32b_write(addr, data, mm_s_rec, mm_m_rec); + + log("Encoder/PD emulator abs-pos preset to " & to_string(to_integer(signed(abs_pos))) & ".", VMEDIUM); + + + end procedure set_enc_abs_pos; + + procedure apply_enc_pd_emul_cfg( + cfg : in emul_cfg_t; + init : in boolean := true; + run_pulses_mode : in boolean := false; + 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 data_check : std_logic_vector(31 downto 0) := (others => '0'); + -- + variable pd_low_period : real := 0.0; -- PD low period (ns) + variable pd_high_period : real := 0.0; -- PD high period (ns) + + begin + + -- Set the NCO inc: output freq + addr:= std_logic_vector(resize(unsigned(CSR_ENC_NCO_INC_ADDR), 32)); + data := freq2NCO_inc(real(cfg.enc_freq), CLK_FREQ); + mm_32b_write(addr, data, mm_s_rec, mm_m_rec); + + -- set the max pulses register + addr := std_logic_vector(resize(unsigned(CSR_PULSE_NUM_ADDR), 32)); + data := std_logic_vector(to_unsigned(cfg.enc_pulses, 32)); + mm_32b_write(addr, data, mm_s_rec, mm_m_rec); + + -- set the zero-phase ppr number + addr := std_logic_vector(resize(unsigned(CSR_ZP_PPR_ADDR), 32)); + data := std_logic_vector(to_unsigned(cfg.enc_ppr, 32)); + mm_32b_write(addr, data, mm_s_rec, mm_m_rec); + + /* + pd_high_period := cfg.pd_pulse_w*(1000.0/CLK_PERIOD); + pd_low_period := real(cfg.pd_period)*(1000.0/CLK_PERIOD)-pd_high_period; + + addr(blk_addr_width-1 downto 0) := std_logic_vector(to_unsigned(8, blk_addr_width)); + data := std_logic_vector(to_unsigned(integer(pd_high_period-1.0),32)); + mm_32b_write(addr, data, mm_s_rec, mm_m_rec); + + addr(blk_addr_width-1 downto 0) := std_logic_vector(to_unsigned(7, blk_addr_width)); + data := std_logic_vector(to_unsigned(integer(pd_low_period-1.0),32)); + mm_32b_write(addr, data, mm_s_rec, mm_m_rec); + + -- Enable PD emulation (first de-assert, then assert) + addr(blk_addr_width-1 downto 0) := std_logic_vector(to_unsigned(6, blk_addr_width)); + 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); + */ + + -- Enable only the necessary outputs: + if(cfg.enc_phase = DUAL_PHASE ) then + data := 32x"FF"; + else + data := 32x"BB"; + end if; + addr := std_logic_vector(resize(unsigned(CSR_OUT_ENABLE_ADDR), 32)); + mm_32b_write(addr, data, mm_s_rec, mm_m_rec); + + addr := std_logic_vector(resize(unsigned(CSR_ENC_CTRL_ADDR), 32)); + if(init = true) then + mm_32b_write(addr, 32x"2", mm_s_rec, mm_m_rec); + end if; + + data := (others => '0'); + if(run_pulses_mode = true) then + data(4) := '1'; + end if; + if(cfg.enc_dir = DIR_0) then + data(2) := '0'; + else + data(2) := '1'; + end if; + + -- enable the encoder + data(0) := '1'; + mm_32b_write(addr, data, mm_s_rec, mm_m_rec); + + log("Encoder/PD emulator enabled.", VMEDIUM); + + end procedure apply_enc_pd_emul_cfg; + + -- Stop the ENC/PD emulator + procedure stop_enc_pd_emul( + 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 + + -- Disable PD emulation + addr := std_logic_vector(resize(unsigned(CSR_PD_CTRL_ADDR), 32)); + mm_32b_read(addr, data, mm_s_rec, mm_m_rec); + data(0) := '0'; + mm_32b_write(addr, data, mm_s_rec, mm_m_rec); + + -- Disable Enc emulation + addr := std_logic_vector(resize(unsigned(CSR_ENC_CTRL_ADDR), 32)); + mm_32b_read(addr, data, mm_s_rec, mm_m_rec); + data(0) := '0'; + mm_32b_write(addr, data, mm_s_rec, mm_m_rec); + + end procedure stop_enc_pd_emul; + + -- Check whether the generation of a fixed number of encoder pulses has completed + procedure check_max_pulses_done( + done : out boolean; + 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_CTRL_ADDR), 32)); + mm_32b_read(addr, data, mm_s_rec, mm_m_rec); + + if(data(6) = '1') then + done := true; + else + done := false; + end if; + + end procedure check_max_pulses_done; + + -- Run a fix number of encoder pulses + procedure run_enc_pulses( + enc_freq : in enc_freq_t; + direction : in enc_dir_t; + double_ph_mode : in boolean := true; + num_pulses : in integer; + enc_ppr : in 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 data_check : std_logic_vector(31 downto 0) := (others => '0'); + + begin + + -- Set the NCO inc: output freq + addr := std_logic_vector(resize(unsigned(CSR_ENC_NCO_INC_ADDR), 32)); + data := freq2NCO_inc(real(enc_freq), CLK_FREQ); + mm_32b_write(addr, data, mm_s_rec, mm_m_rec); + + -- set the max pulses register + addr := std_logic_vector(resize(unsigned(CSR_PULSE_NUM_ADDR), 32)); + data := std_logic_vector(to_unsigned(num_pulses, 32)); + mm_32b_write(addr, data, mm_s_rec, mm_m_rec); + + -- set the zero-phase ppr number + addr := std_logic_vector(resize(unsigned(CSR_ZP_PPR_ADDR), 32)); + data := std_logic_vector(to_unsigned(enc_ppr, 32)); + mm_32b_write(addr, data, mm_s_rec, mm_m_rec); + + -- Enable only the necessary outputs: + if(double_ph_mode = true) then + data := 32x"FF"; + else + data := 32x"BB"; + end if; + addr := std_logic_vector(resize(unsigned(CSR_OUT_ENABLE_ADDR), 32)); + mm_32b_write(addr, data, mm_s_rec, mm_m_rec); + + addr := std_logic_vector(resize(unsigned(CSR_ENC_CTRL_ADDR), 32)); + data := (4 => '1', 5 => '1', others => '0'); + if(direction = DIR_0) then + data(2) := '0'; + else + data(2) := '1'; + end if; + + -- enable the encoder + data(0) := '1'; + mm_32b_write(addr, data, mm_s_rec, mm_m_rec); + + --log("Running encoder pulses ... ", VMEDIUM); + + end procedure run_enc_pulses; + + -- Run PD pulses: either single pulse or periodic mode + procedure run_pd_pulses( + pulse_width : in pd_pulse_width_t; + pd_period : in pd_period_t; + single_pulse_mode : in boolean := false; + 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 data_check : std_logic_vector(31 downto 0) := (others => '0'); + variable tmp_val : integer; + variable idx : integer; + variable loop_idx : integer; + + begin + + -- set the pulse width + addr := std_logic_vector(resize(unsigned(CSR_PD_PULSE_W_ADDR), 32)); + data := std_logic_vector(to_unsigned(integer(pulse_width*100.0),32)); + mm_32b_write(addr, data, mm_s_rec, mm_m_rec); + + -- No need to use the sequerncer for a single pulse + if(single_pulse_mode = true) then + addr := std_logic_vector(resize(unsigned(CSR_PD_CTRL_ADDR), 32)); + mm_32b_write(addr, 32x"3", mm_s_rec, mm_m_rec); + log("Issued single PD pulse. ", VMEDIUM); + return; + end if; + + -- Use the sequencer to generate periodic pulses (here the periodicity is + -- in time): First program the sequencer RAM with instructions to generate + -- pulses with the specified periodicity, then enable the sequencer, + -- finally trigger the start of the procedure: + + -- Write in the Emulator sequencer a simple procedure to issue PD pulses + addr := std_logic_vector(resize(unsigned(SEQ_RAM_OFFSET)+0, 32)); + mm_32b_write(addr, X"100000FF", mm_s_rec, mm_m_rec); -- Enable triggers + addr := std_logic_vector(resize(unsigned(SEQ_RAM_OFFSET)+1, 32)); + mm_32b_write(addr, X"30000000", mm_s_rec, mm_m_rec); -- All the outputs to zero + idx := 2; + loop_idx := idx; + if(pd_period >= 1.0) then + -- add a first trigger-wait instruction for 1-us pulses + addr := std_logic_vector(resize(unsigned(SEQ_RAM_OFFSET)+idx, 32)); + tmp_val := integer(pd_period); + data := X"21000" & std_logic_vector(to_unsigned(tmp_val, 12)); + mm_32b_write(addr, data, mm_s_rec, mm_m_rec); -- trig_wait (us pulses) + idx := idx + 1; + end if; + -- add a second trigger on single clock cycle events + addr := std_logic_vector(resize(unsigned(SEQ_RAM_OFFSET)+idx, 32)); + tmp_val := integer((pd_period-floor(pd_period))*100.0); + data := X"20000" & std_logic_vector(to_unsigned(tmp_val, 12)); + mm_32b_write(addr, data, mm_s_rec, mm_m_rec); -- trig_wait (clk pulses) + idx := idx + 1; + -- issue the PD pulse + addr := std_logic_vector(resize(unsigned(SEQ_RAM_OFFSET)+idx, 32)); + mm_32b_write(addr, X"31000001", mm_s_rec, mm_m_rec); -- All the outputs to zero + idx := idx + 1; + -- Jump to the beginning of the loop + addr := std_logic_vector(resize(unsigned(SEQ_RAM_OFFSET)+idx, 32)); + mm_32b_write(addr, X"31000001", mm_s_rec, mm_m_rec); -- All the outputs to zero + + -- Enable the sequencer + addr := std_logic_vector(resize(unsigned(SEQ_RAM_OFFSET)+idx, 32)); + mm_32b_write(addr, 32x"1", mm_s_rec, mm_m_rec); -- All the outputs to zero + + -- issue a start-request to the sequencer + addr := std_logic_vector(resize(unsigned(CSR_SEQ_CTRL_ADDR), 32)); + data(0) := '1'; -- start-request bit + data(24 downto 16) := 9x"0"; -- EAM sequence start-address + mm_32b_write(addr, 32x"1", mm_s_rec, mm_m_rec); + + log("Running PD pulses ... ", VMEDIUM); + + end procedure run_pd_pulses; + + ----------------------------------------------------------------------------- + -- Support functions + ----------------------------------------------------------------------------- + + -- generate the NCO increment corresponding to a given output frequency + function freq2NCO_inc( + f_out : real; f_clk : real) return std_logic_vector is + variable nco_inc : std_logic_vector(ENC_NCO_WIDTH-1 downto 0); + + begin + nco_inc := std_logic_vector(to_unsigned(integer((f_out/f_clk)*(2.0**ENC_NCO_WIDTH)),ENC_NCO_WIDTH)); + return nco_inc; + + end function freq2NCO_inc; + +end fire_pulse_manager_5_tb_pkg; From 469a94e87da66db00134c765eab3a7497bdba0c6 Mon Sep 17 00:00:00 2001 From: gianmarcogirau Date: Tue, 7 Jan 2020 14:19:17 +0000 Subject: [PATCH 07/15] CORE-73 - Testbench now covers SEB-EPD mode --- .../fire_pulse_manager/5/sim/wave_fpm.do | 122 +++++++++++++++++- .../5/src/test/fire_pulse_manager_5_tb.vhd | 105 +++++++++++---- .../src/test/fire_pulse_manager_5_tb_pkg.vhd | 85 ++++++++---- 3 files changed, 264 insertions(+), 48 deletions(-) diff --git a/generic_ip/fire_pulse_manager/5/sim/wave_fpm.do b/generic_ip/fire_pulse_manager/5/sim/wave_fpm.do index bb7d5d7..98b52ba 100644 --- a/generic_ip/fire_pulse_manager/5/sim/wave_fpm.do +++ b/generic_ip/fire_pulse_manager/5/sim/wave_fpm.do @@ -33,7 +33,7 @@ add wave -noupdate -group TB /fire_pulse_manager_5_tb/configuring add wave -noupdate -group TB /fire_pulse_manager_5_tb/passed add wave -noupdate -group TB /fire_pulse_manager_5_tb/failed add wave -noupdate -group TB /fire_pulse_manager_5_tb/stimuli_completed -add wave -noupdate -group TB /fire_pulse_manager_5_tb/detected_error +add wave -noupdate -group TB /fire_pulse_manager_5_tb/error_flag add wave -noupdate -group TB /fire_pulse_manager_5_tb/registers_read add wave -noupdate -group TB /fire_pulse_manager_5_tb/reprogram_offset add wave -noupdate -group TB /fire_pulse_manager_5_tb/avs_m @@ -572,6 +572,124 @@ add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/fine_ti add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/fine_time_i add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/coarse_time_init add wave -noupdate -group {FPM Ctrl} /fire_pulse_manager_5_tb/iDUT/iCTRL/coarse_time_i +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/clk +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/reset_n +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/init +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/avs_address +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/avs_write +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/avs_writedata +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/avs_read +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/avs_readdatavalid +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/avs_readdata +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/rs422_pd +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/rs422_p1 +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/rs422_p2 +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/rs422_zp +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/ttl_pd +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/ttl_pd_npn +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/ttl_p1 +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/ttl_p2 +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/ttl_zp +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/abs_position +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/pd_out +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/print_start +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/set_pos +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/inc_pos +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/dec_pos +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/filt_p1 +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/filt_p2 +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/filt_zp +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/filt_pd +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/init_i +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/ttl_pd_i +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/sel_ttl_npn +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/pd_mux +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/p1_mux +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/p2_mux +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/zp_mux +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/ems_init +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/pd_i +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/pd_re +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/pd_fe +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/p1_i +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/p1_re +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/p1_fe +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/p2_i +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/p2_re +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/p2_fe +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/zp_i +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/p1_re_i +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/p1_fe_i +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/p2_re_i +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/p2_fe_i +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/enc_ph1_en +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/enc_ph2_en +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/enc_rising_en +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/enc_falling_en +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/step_pos_i +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/step_neg_i +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/step_pos +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/step_neg +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/set_pos_i +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/set_abs_pos +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/wrap_pos +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/wrap_neg +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/inc_pos_i +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/dec_pos_i +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/ems_enable +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/pd_hyst_filt +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/set_pd_hyst_filt +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/pd_event +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/clr_pd_hyst_filt +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/sw_pos_step +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/sw_neg_step +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/pd_rising_en +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/pd_falling_en +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/sw_pd +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/pd +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/kickstart_pd +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/sw_clr_pd_hyst_filt +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/ld_filt_cfg_pd +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/ld_filt_cfg_zp +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/ld_filt_cfg_p1 +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/ld_filt_cfg_p2 +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/switch_pos_neg_inc +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/step_pos_ii +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/step_neg_ii +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/enc_enable +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/enc_enable_i +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/pd_enable +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/pd_enable_i +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/wrap_pos_i +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/wrap_neg_i +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/use_multiplier +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/m_step_pos +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/m_step_neg +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/step_pos_retimed +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/step_neg_retimed +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/init_mult +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/enable_mult +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/enc_sel +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/pd_sel +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/mult_sel +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/pd_delay_line +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/enc_cnt +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/enc_divide +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/filt_order +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/filt_hyst +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/avg_steps +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/pd_hyst_val +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/pd_hyst_pos_cnt +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/pd_hyst_neg_cnt +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/hw_pd_cnt +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/total_pd_cnt +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/delta_init +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/time_out +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/abs_pos_i +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/abs_pos_init +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/abs_pos_in +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/abs_pos_vel +add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/delta_t TreeUpdate [SetDefaultTree] WaveRestoreCursors {{Cursor 1} {8565000 ps} 0} quietly wave cursor active 1 @@ -589,4 +707,4 @@ configure wave -griddelta 40 configure wave -timeline 0 configure wave -timelineunits ps update -WaveRestoreZoom {200417556 ps} {249051708 ps} +WaveRestoreZoom {709687556 ps} {758321708 ps} diff --git a/generic_ip/fire_pulse_manager/5/src/test/fire_pulse_manager_5_tb.vhd b/generic_ip/fire_pulse_manager/5/src/test/fire_pulse_manager_5_tb.vhd index 41a403a..f09b239 100644 --- a/generic_ip/fire_pulse_manager/5/src/test/fire_pulse_manager_5_tb.vhd +++ b/generic_ip/fire_pulse_manager/5/src/test/fire_pulse_manager_5_tb.vhd @@ -6,7 +6,7 @@ -- Author : Christos Spirotis -- Company : Global Inkjet Systems -- Created : 2018-08-10 --- Last update: 2020-01-06 +-- Last update: 2020-01-07 -- SVN ID : Git -- Standard : VHDL'08 ------------------------------------------------------------------------------- @@ -103,6 +103,7 @@ architecture behav of fire_pulse_manager_5_tb is -- signal enc_dir : enc_dir_t; signal swathe_cnt : integer; + signal half_swathe_cnt : integer; signal swathe_pos : integer; signal end_of_swathe : std_logic; signal test_completed : boolean; @@ -111,7 +112,9 @@ architecture behav of fire_pulse_manager_5_tb is signal passed : boolean; signal failed : boolean; signal stimuli_completed : boolean; - signal detected_error : boolean := false; + -- + shared variable error_flag : boolean; + signal registers_read : boolean := false; signal reprogram_offset : boolean := false; -- @@ -128,6 +131,9 @@ architecture behav of fire_pulse_manager_5_tb is signal fp_cnt : fp_cnt_t; signal loc_fp_cnt : fp_cnt_t; signal ch_pulse_out_d : std_logic_vector(CH_NUM-1 downto 0); + -- + signal input_mode : fpm_input_type_t; + begin -- behav @@ -153,7 +159,8 @@ begin -- behav iDUT : entity work.fire_pulse_manager_5 generic map( - CH_NUM => CH_NUM) + SEB_EPD_MODE => true, + CH_NUM => CH_NUM) port map( reset_n => reset_n, clk => clk, @@ -268,6 +275,7 @@ begin -- behav swathe_pos <= 0; -- swathe_cnt <= 0; + half_swathe_cnt <= 0; stimuli_completed <= false; end_of_swathe <= '0'; -- @@ -330,12 +338,16 @@ begin -- behav end loop; wait for 25 us; + half_swathe_cnt <= half_swathe_cnt + 1; + wait until clk = '1' and clk'event; end_of_swathe <= '1'; wait until clk = '1' and clk'event; end_of_swathe <= '0'; -- reverse direction if (enc_dir /= START_DIR) then - if (swathe_cnt = NUM_ITERATIONS - 1) then + -- The number of iterations is doubled, to take into account POF and + -- EPD input types + if (swathe_cnt = 2*NUM_ITERATIONS - 1) then end_of_stimuli := true; else swathe_cnt <= swathe_cnt + 1; @@ -378,6 +390,15 @@ begin -- behav loc_fp_cnt(n) <= loc_fp_cnt(n) + 1; end if; end loop; -- n + -- Check the number of generated fire-requests at the end of the swathe + if(end_of_swathe = '1') then + for n in 0 to CH_NUM-1 loop + if(loc_fp_cnt(n) /= half_swathe_cnt*IMAGE_SIZE) then + log("ERROR on Channel CH" & integer'image(n) & ": Expected Fire-Requests = " & to_string(half_swathe_cnt*IMAGE_SIZE) & ", detected Fire-Requests = " & to_string(loc_fp_cnt(n)), VLOW, true); + error_flag := true; + end if; + end loop; -- n + end if; end if; end process pOUT_CHECK_REGs; @@ -399,10 +420,10 @@ begin -- behav log_header("Multi-channel FPM verification:", VLOW); - test_completed <= false; running <= false; passed <= false; - failed <= false; + + error_flag := false; -- Reset reset_n <= '0'; @@ -415,9 +436,6 @@ begin -- behav end if; wait until configuring = false; running <= true; - log_separator_line(VLOW); - log("Configuration completed. Running test ... ", VLOW, true); - log_separator_line(VLOW); while stimuli_completed = false loop wait until ((pd_spy = '1' and pd_spy'event) or stimuli_completed); @@ -453,7 +471,7 @@ begin -- behav log("Channel CH" & integer'image(i) & " Fire pulse logged @ " & integer'image(fp_arrived_pos(i)) & " ... ", VLOW, true); if (abs (pd_arrived_pos - fp_arrived_pos(i)) /= ch_offset(i)) then log("ERROR on Channel CH" & integer'image(i) & ": First Fire-Pulse detected at position " & to_string(fp_arrived_pos(i)) & ", expected position is " & to_string((pd_arrived_pos+ch_offset(i))), VLOW, true); - detected_error <= true; + error_flag := true; end if; end if; end loop; @@ -474,32 +492,49 @@ begin -- behav log("Channel CH" & integer'image(i) & " PD-in counter value : " & integer'image(pd_cnt(i)) & " ... ", VLOW, true); log("Channel CH" & integer'image(i) & " FP-out counter value : " & integer'image(fp_cnt(i)) & " ... ", VLOW, true); log("Channel CH" & integer'image(i) & " Detected Fire-Pulses : " & integer'image(loc_fp_cnt(i)) & " ... ", VLOW, true); - if (i = 0 and (pd_cnt(i) /= (NUM_ITERATIONS) * 2)) or + if (i = 0 and (pd_cnt(i) /= (NUM_ITERATIONS) * 2 * 2)) or (i /= 0 and pd_cnt(i) /= 0) then -- fire_pulse_manager now has no registers beyond channel 0 log("Channel CH" & integer'image(i) & " PD_cnt counter value Incorrect: ", VLOW, true); - detected_error <= true; + error_flag := true; end if; - if((loc_fp_cnt(i) /= (NUM_ITERATIONS) * 2 * 100) or (i = 0 and (fp_cnt(i) /= (NUM_ITERATIONS) * 2 * 100)) or (i /= 0 and fp_cnt(i) /= 0)) then + if((loc_fp_cnt(i) /= (NUM_ITERATIONS) * 2 * 2 * IMAGE_SIZE) or (i = 0 and (fp_cnt(i) /= (NUM_ITERATIONS) * 2 * 2 * IMAGE_SIZE)) or (i /= 0 and fp_cnt(i) /= 0)) then log("Channel CH" & integer'image(i) & " FP_cnt counter value Incorrect: ", VLOW, true); - detected_error <= true; + error_flag := true; end if; end loop; wait until clk = '1' and clk'event; - if (detected_error = true) then - failed <= true; + running <= false; + passed <= true after 100 ns; + wait; + + end process pTB_CTRL; + + pFAILED : process + begin + failed <= false; + while true loop + wait for 1 us; + if(error_flag = true) then + failed <= true; + end if; + end loop; + 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); - else - passed <= true; + elsif(passed = true) then log("SUCCESS: test successfully completed.", VLOW); end if; log_separator_line(VLOW); test_completed <= true; - running <= false; - wait; - - end process pTB_CTRL; + end process pREPORT_RESULT; pUUT_CTRL : process variable addr : std_logic_vector(31 downto 0) := (others => '0'); @@ -508,7 +543,9 @@ begin -- behav begin sel_slave_0 <= '0'; sel_slave_1 <= '0'; - configuring <= true; + configuring <= true; + + input_mode <= POF_INPUT; -- Initialize avalon mm interfaces mm_m_init(avs_m, use_waitrequest => true); @@ -517,7 +554,7 @@ begin -- behav wait until reset_n = '1'; wait for 100 ns; wait until clk = '1' and clk'event; - end if; + end if; log("Configuring POFTX ... ", VLOW, true); sel_slave_1 <= '1'; @@ -535,6 +572,8 @@ begin -- behav fpm_ctrl_config(avs_s, avs_m); + fpm_ems_config(avs_s, avs_m); + config_pg_l : for i in 0 to CH_NUM - 1 loop pulse_gen_config(i, ch_offset(i), IMAGE_SIZE, avs_s, avs_m); @@ -544,6 +583,12 @@ begin -- behav log("Configuration completed.", VLOW, true); configuring <= false; + log_separator_line(VLOW); + log("POF input mode verification", VLOW, true); + log_separator_line(VLOW); + + fpm_input_config(input_mode, avs_s, avs_m); + while stimuli_completed = false loop wait until reprogram_offset = true or stimuli_completed = true; if (stimuli_completed) then @@ -562,6 +607,18 @@ begin -- behav end loop; configuring <= true; + + -- Reprogram the input to EPD and repeat the same number of iterations + if (swathe_cnt = NUM_ITERATIONS) then + log_separator_line(VLOW); + log("EPD input mode verification", VLOW, true); + log_separator_line(VLOW); + + input_mode <= EPD_INPUT; + wait until clk = '1' and clk'event; + fpm_input_config(input_mode, avs_s, avs_m); + end if; + log("Reprogramming offset ... ", VLOW, true); config_of_l : for i in 0 to CH_NUM - 1 loop ch_offset_config(i, ch_offset(i), avs_s, avs_m); diff --git a/generic_ip/fire_pulse_manager/5/src/test/fire_pulse_manager_5_tb_pkg.vhd b/generic_ip/fire_pulse_manager/5/src/test/fire_pulse_manager_5_tb_pkg.vhd index 72b6a56..8113ba2 100644 --- a/generic_ip/fire_pulse_manager/5/src/test/fire_pulse_manager_5_tb_pkg.vhd +++ b/generic_ip/fire_pulse_manager/5/src/test/fire_pulse_manager_5_tb_pkg.vhd @@ -6,7 +6,7 @@ -- Author : Gianmarco Girau -- Company : Global Inkjet Systems -- Created : 2020-01-02 --- Last update: 2020-01-06 +-- Last update: 2020-01-07 -- SVN ID : Git -- Standard : VHDL'2008 ------------------------------------------------------------------------------- @@ -25,7 +25,7 @@ use ieee.math_real.all; library work; use work.fire_pulse_5_pkg.all; -use work.enc_pd_emul_1_pkg.all; +use work.ems_0_pkg.all; use work.fire_pulse_ctrl_5_pkg.all; library OSVVM ; @@ -47,6 +47,8 @@ package fire_pulse_manager_5_tb_pkg is -- Logging Verbosity Level constant VERBOSITY_LEVEL : verb_level_t := VMEDIUM; + type fpm_input_type_t is (POF_INPUT, EPD_INPUT, INTERNAL); + ----------------------------------------------------------------------------- -- FPM Configuration ----------------------------------------------------------------------------- @@ -106,6 +108,15 @@ package fire_pulse_manager_5_tb_pkg is signal mm_s : in mm_s_rec_t; signal mm_m : out mm_m_rec_t); + procedure fpm_input_config( + input_type : in fpm_input_type_t; + signal mm_s : in mm_s_rec_t; + signal mm_m : out mm_m_rec_t); + + procedure fpm_ems_config( + signal mm_s : in mm_s_rec_t; + signal mm_m : out mm_m_rec_t); + ----------------------------------------------------------------------------- -- ENC/PD Emulator Configuration ----------------------------------------------------------------------------- @@ -430,6 +441,56 @@ package body fire_pulse_manager_5_tb_pkg is end procedure pulse_gen_config; + procedure fpm_input_config( + input_type : in fpm_input_type_t; + signal mm_s : in mm_s_rec_t; + signal mm_m : out mm_m_rec_t) is + + variable data : std_logic_vector(31 downto 0); + + begin + + if(input_type = POF_INPUT) then + + data := X"0000_0001"; + fpm_reg_write(FP_CTRL_ID, SRC_SEL_REG, data, mm_s, mm_m); + log("FPM input set to POF. ", VLOW, true); + + elsif(input_type = EPD_INPUT) then + + data := X"0000_0005"; + fpm_reg_write(FP_CTRL_ID, SRC_SEL_REG, data, mm_s, mm_m); + log("FPM input set to EPD. ", VLOW, true); + + end if; + + end procedure fpm_input_config; + + + procedure fpm_ems_config( + signal mm_s : in mm_s_rec_t; + signal mm_m : out mm_m_rec_t) is + + variable data : std_logic_vector(31 downto 0); + + begin + + log("Configuring EMS ... ", VMEDIUM, true); + + -- EMS software init + fpm_reg_write(EMS_BLK_ID, work.ems_0_pkg.CSR_EMS_ENABLE_ADDR, 32x"1", mm_s, mm_m); + + -- disable the EMS during the configuration + fpm_reg_write(EMS_BLK_ID, work.ems_0_pkg.CSR_EMS_ENABLE_ADDR, 32x"0", mm_s, mm_m); + + -- apply EMS config + fpm_reg_write(EMS_BLK_ID, work.ems_0_pkg.CSR_EMS_CONFIG_ADDR, 32x"3E0", mm_s, mm_m); + + -- enable the EMS + fpm_reg_write(EMS_BLK_ID, work.ems_0_pkg.CSR_EMS_ENABLE_ADDR, 32x"E", mm_s, mm_m); + + end procedure fpm_ems_config; + ----------------------------------------------------------------------------- -- ENC/PD Emulator Configuration ----------------------------------------------------------------------------- @@ -493,26 +554,6 @@ package body fire_pulse_manager_5_tb_pkg is data := std_logic_vector(to_unsigned(cfg.enc_ppr, 32)); mm_32b_write(addr, data, mm_s_rec, mm_m_rec); - /* - pd_high_period := cfg.pd_pulse_w*(1000.0/CLK_PERIOD); - pd_low_period := real(cfg.pd_period)*(1000.0/CLK_PERIOD)-pd_high_period; - - addr(blk_addr_width-1 downto 0) := std_logic_vector(to_unsigned(8, blk_addr_width)); - data := std_logic_vector(to_unsigned(integer(pd_high_period-1.0),32)); - mm_32b_write(addr, data, mm_s_rec, mm_m_rec); - - addr(blk_addr_width-1 downto 0) := std_logic_vector(to_unsigned(7, blk_addr_width)); - data := std_logic_vector(to_unsigned(integer(pd_low_period-1.0),32)); - mm_32b_write(addr, data, mm_s_rec, mm_m_rec); - - -- Enable PD emulation (first de-assert, then assert) - addr(blk_addr_width-1 downto 0) := std_logic_vector(to_unsigned(6, blk_addr_width)); - 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); - */ - -- Enable only the necessary outputs: if(cfg.enc_phase = DUAL_PHASE ) then data := 32x"FF"; From 6987b27ff72e76ea864165dc9d249a566a8e6e68 Mon Sep 17 00:00:00 2001 From: gianmarcogirau Date: Wed, 8 Jan 2020 09:29:21 +0000 Subject: [PATCH 08/15] CORE-73 - added separate script to compile the FPM --- .../fire_pulse_manager/5/sim/com_fpm.do | 101 ++++++++++++++++++ .../fire_pulse_manager/5/sim/sim_fpm.do | 69 +----------- 2 files changed, 102 insertions(+), 68 deletions(-) create mode 100644 generic_ip/fire_pulse_manager/5/sim/com_fpm.do diff --git a/generic_ip/fire_pulse_manager/5/sim/com_fpm.do b/generic_ip/fire_pulse_manager/5/sim/com_fpm.do new file mode 100644 index 0000000..1db2616 --- /dev/null +++ b/generic_ip/fire_pulse_manager/5/sim/com_fpm.do @@ -0,0 +1,101 @@ +# Multi-channel FPM compilation macro: +# To prevent cleaning the existing work library at the beginning run the command with "--nocleanup" option: +# do com_fpm.do --nocleanup + +set DO_CLEANUP 1 + +if { $argc >= 1 } { + set PARAM $1 + if { $PARAM == "--nocleanup" } { + set DO_CLEANUP 0 + } +} + +if { $DO_CLEANUP == 1 } { + .main clear + + # Cleanup libraries + foreach lib [list work ] { + file delete -force -- $lib + vlib $lib + } +} + +# Path variables +set COMMON_PATH ../../../common/0/src +set POF_PATH_0 ../../../pof_protocol/0/src +set POF_PATH_1 ../../../pof_protocol/1/src +set SEQUENCER_PATH ../../../generic_sequencer/15/src +set PULSE_GEN_PATH ../../../pulse_generator/2/src +set EMUL_PATH ../../../enc_pd_emul/1/src +set EMS_PATH ../../../ems/0/src +set ENC_MULT_PATH ../../../encoder_multiply/0/src +set LOG_PATH ../../../event_logger/0/src +set SRC_PATH ../src +set OSVVM_PATH ../../../common/0/src/test/OSVVM +set TB_PATH ../src/test + +set WORKLIB work + +vlib ./work +vmap work ./work + +# common +vcom -2008 -work $WORKLIB $COMMON_PATH/sync_reset.vhd +vcom -2008 -work $WORKLIB $COMMON_PATH/common_pkg.vhd +vcom -2008 -work $WORKLIB $COMMON_PATH/sync_wire.vhd +vcom -2008 -work $WORKLIB $COMMON_PATH/sync_wire_rEdge.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/digital_lpf.vhd + +# Generic Sequencer +vcom -2008 -work $WORKLIB $SEQUENCER_PATH/altera/generic_seq_ram_15.vhd +vcom -2008 -work $WORKLIB $SEQUENCER_PATH/generic_sequencer_15_pkg.vhd +vcom -2008 -work $WORKLIB $SEQUENCER_PATH/generic_sequencer_15.vhd + +# Pulse Generator +vcom -2008 -work $WORKLIB $PULSE_GEN_PATH/pulse_conditioning_2.vhd +vcom -2008 -work $WORKLIB $PULSE_GEN_PATH/simple_frac_div_2.vhd +vcom -2008 -work $WORKLIB $PULSE_GEN_PATH/pulse_generator_2_pkg.vhd +vcom -2008 -work $WORKLIB $PULSE_GEN_PATH/pulse_generator_2.vhd + +# Emulator +vcom -2008 -work $WORKLIB $EMUL_PATH/enc_pd_emul_1_pkg.vhd +vcom -2008 -work $WORKLIB $EMUL_PATH/enc_pd_emul_1.vhd + +# EMS +vcom -2008 -work $WORKLIB $EMS_PATH/ems_0_pkg.vhd +vcom -2008 -work $WORKLIB $ENC_MULT_PATH/lut_divider_0.vhd +vcom -2008 -work $WORKLIB $ENC_MULT_PATH/encoder_speed_detect_0.vhd +vcom -2008 -work $WORKLIB $ENC_MULT_PATH/encoder_multiply_0.vhd +vcom -2008 -work $WORKLIB $EMS_PATH/ems_0.vhd + +# Event Logger +vcom -2008 -work $WORKLIB $LOG_PATH/event_logger_0_pkg.vhd +vcom -2008 -work $WORKLIB $LOG_PATH/event_logger_0.vhd + +# POF-Rx +vcom -2008 -work $WORKLIB $POF_PATH_0/pof_uart_rx_0.vhd +vcom -2008 -work $WORKLIB $POF_PATH_0/pof_rx_0.vhd +vcom -2008 -work $WORKLIB $POF_PATH_0/pof_uart_regen_0.vhd +vcom -2008 -work $WORKLIB $POF_PATH_0/uart_tx_0.vhd +vcom -2008 -work $WORKLIB $POF_PATH_0/pof_tx_0.vhd + +vcom -2008 -work $WORKLIB $POF_PATH_1/pof_uart_rx_1.vhd +vcom -2008 -work $WORKLIB $POF_PATH_1/pof_rx_1.vhd +vcom -2008 -work $WORKLIB $POF_PATH_1/pof_uart_regen_1.vhd +vcom -2008 -work $WORKLIB $POF_PATH_1/uart_tx_1.vhd +vcom -2008 -work $WORKLIB $POF_PATH_1/pof_tx_1.vhd + +# Fire-Pulse-Manager +vcom -2008 -work $WORKLIB $COMMON_PATH/cs_bus_itf.vhd +vcom -2008 -work $WORKLIB $SRC_PATH/smb_diagnostics_5.vhd +vcom -2008 -work $WORKLIB $SRC_PATH/simple_enc_vel_detect_5.vhd +vcom -2008 -work $WORKLIB $SRC_PATH/fire_pulse_5_pkg.vhd +vcom -2008 -work $WORKLIB $SRC_PATH/fire_pulse_ctrl_5_pkg.vhd +vcom -2008 -work $WORKLIB $SRC_PATH/fire_pulse_ctrl_5.vhd +vcom -2008 -work $WORKLIB $SRC_PATH/fire_pulse_ext_5.vhd +vcom -2008 -work $WORKLIB $SRC_PATH/fire_pulse_manager_5.vhd + diff --git a/generic_ip/fire_pulse_manager/5/sim/sim_fpm.do b/generic_ip/fire_pulse_manager/5/sim/sim_fpm.do index bdeb8ec..3b8633e 100644 --- a/generic_ip/fire_pulse_manager/5/sim/sim_fpm.do +++ b/generic_ip/fire_pulse_manager/5/sim/sim_fpm.do @@ -9,16 +9,6 @@ foreach lib [list work OSVVM] { } # Path variables -set COMMON_PATH ../../../common/0/src -set POF_PATH_0 ../../../pof_protocol/0/src -set POF_PATH_1 ../../../pof_protocol/1/src -set SEQUENCER_PATH ../../../generic_sequencer/15/src -set PULSE_GEN_PATH ../../../pulse_generator/2/src -set EMUL_PATH ../../../enc_pd_emul/1/src -set EMS_PATH ../../../ems/0/src -set ENC_MULT_PATH ../../../encoder_multiply/0/src -set LOG_PATH ../../../event_logger/0/src -set SRC_PATH ../src set OSVVM_PATH ../../../common/0/src/test/OSVVM set TB_PATH ../src/test @@ -27,64 +17,7 @@ set WORKLIB work vlib ./work vmap work ./work -# common -vcom -2008 -work $WORKLIB $COMMON_PATH/sync_reset.vhd -vcom -2008 -work $WORKLIB $COMMON_PATH/common_pkg.vhd -vcom -2008 -work $WORKLIB $COMMON_PATH/sync_wire.vhd -vcom -2008 -work $WORKLIB $COMMON_PATH/sync_wire_rEdge.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/digital_lpf.vhd - -# Generic Sequencer -vcom -2008 -work $WORKLIB $SEQUENCER_PATH/altera/generic_seq_ram_15.vhd -vcom -2008 -work $WORKLIB $SEQUENCER_PATH/generic_sequencer_15_pkg.vhd -vcom -2008 -work $WORKLIB $SEQUENCER_PATH/generic_sequencer_15.vhd - -# Pulse Generator -vcom -2008 -work $WORKLIB $PULSE_GEN_PATH/pulse_conditioning_2.vhd -vcom -2008 -work $WORKLIB $PULSE_GEN_PATH/simple_frac_div_2.vhd -vcom -2008 -work $WORKLIB $PULSE_GEN_PATH/pulse_generator_2_pkg.vhd -vcom -2008 -work $WORKLIB $PULSE_GEN_PATH/pulse_generator_2.vhd - -# Emulator -vcom -2008 -work $WORKLIB $EMUL_PATH/enc_pd_emul_1_pkg.vhd -vcom -2008 -work $WORKLIB $EMUL_PATH/enc_pd_emul_1.vhd - -# EMS -vcom -2008 -work $WORKLIB $EMS_PATH/ems_0_pkg.vhd -vcom -2008 -work $WORKLIB $ENC_MULT_PATH/lut_divider_0.vhd -vcom -2008 -work $WORKLIB $ENC_MULT_PATH/encoder_speed_detect_0.vhd -vcom -2008 -work $WORKLIB $ENC_MULT_PATH/encoder_multiply_0.vhd -vcom -2008 -work $WORKLIB $EMS_PATH/ems_0.vhd - -# Event Logger -vcom -2008 -work $WORKLIB $LOG_PATH/event_logger_0_pkg.vhd -vcom -2008 -work $WORKLIB $LOG_PATH/event_logger_0.vhd - -# POF-Rx -vcom -2008 -work $WORKLIB $POF_PATH_0/pof_uart_rx_0.vhd -vcom -2008 -work $WORKLIB $POF_PATH_0/pof_rx_0.vhd -vcom -2008 -work $WORKLIB $POF_PATH_0/pof_uart_regen_0.vhd -vcom -2008 -work $WORKLIB $POF_PATH_0/uart_tx_0.vhd -vcom -2008 -work $WORKLIB $POF_PATH_0/pof_tx_0.vhd - -vcom -2008 -work $WORKLIB $POF_PATH_1/pof_uart_rx_1.vhd -vcom -2008 -work $WORKLIB $POF_PATH_1/pof_rx_1.vhd -vcom -2008 -work $WORKLIB $POF_PATH_1/pof_uart_regen_1.vhd -vcom -2008 -work $WORKLIB $POF_PATH_1/uart_tx_1.vhd -vcom -2008 -work $WORKLIB $POF_PATH_1/pof_tx_1.vhd - -# Fire-Pulse-Manager -vcom -2008 -work $WORKLIB $COMMON_PATH/cs_bus_itf.vhd -vcom -2008 -work $WORKLIB $SRC_PATH/smb_diagnostics_5.vhd -vcom -2008 -work $WORKLIB $SRC_PATH/simple_enc_vel_detect_5.vhd -vcom -2008 -work $WORKLIB $SRC_PATH/fire_pulse_5_pkg.vhd -vcom -2008 -work $WORKLIB $SRC_PATH/fire_pulse_ctrl_5_pkg.vhd -vcom -2008 -work $WORKLIB $SRC_PATH/fire_pulse_ctrl_5.vhd -vcom -2008 -work $WORKLIB $SRC_PATH/fire_pulse_ext_5.vhd -vcom -2008 -work $WORKLIB $SRC_PATH/fire_pulse_manager_5.vhd +do com_fpm.do --nocleanup # Compile the testbench support files: # Compile OSVVM lib From 9c7ca507ed603e83c659b2569626927cb0f6a483 Mon Sep 17 00:00:00 2001 From: gianmarcogirau Date: Thu, 9 Jan 2020 11:46:34 +0000 Subject: [PATCH 09/15] CORE-73 - Updates JSON files. Added an output to the FPM to multiplex TIMING_TX/RX pins in the SOM, in SEB-EPD mode --- .../fire_pulse_manager/5/doc/fpm_5.json | 18 +++-- .../fire_pulse_manager/5/doc/fpm_ctrl_5.json | 65 +++++++++++++++---- .../fire_pulse_manager/5/sim/wave_fpm.do | 2 - .../5/src/fire_pulse_manager_5.vhd | 28 +++++--- .../5/src/test/fire_pulse_manager_5_tb.vhd | 4 +- 5 files changed, 88 insertions(+), 29 deletions(-) diff --git a/generic_ip/fire_pulse_manager/5/doc/fpm_5.json b/generic_ip/fire_pulse_manager/5/doc/fpm_5.json index 68b44dd..dbdd65b 100644 --- a/generic_ip/fire_pulse_manager/5/doc/fpm_5.json +++ b/generic_ip/fire_pulse_manager/5/doc/fpm_5.json @@ -26,29 +26,39 @@ "instance" : "", "process" : "cpp, txt", "offset" : "0x1800" + }, + "ems_0" : { + "instance" : "", + "process" : "cpp, txt", + "offset" : "0x2000" + }, + "pof_tx_0" : { + "instance" : "", + "process" : "cpp, txt", + "offset" : "0x2800" }, "pulse_generator_2:a" : { "instance" : "0", "process" : "cpp, txt", - "offset" : "0x2000" + "offset" : "0x3000" }, "pulse_generator_2:b" : { "instance" : "1", "process" : "cpp, txt", "note" : "This block may not be instantiated depending on the value of generic CH_NUM specified in the FPM top-level", - "offset" : "0x2800" + "offset" : "0x3800" }, "pulse_generator_2:c" : { "instance" : "2", "process" : "cpp, txt", "note" : "This block may not be instantiated depending on the value of generic CH_NUM specified in the FPM top-level", - "offset" : "0x3000" + "offset" : "0x4000" }, "pulse_generator_2:d" : { "instance" : "3", "process" : "cpp, txt", "note" : "This block may not be instantiated depending on the value of generic CH_NUM specified in the FPM top-level", - "offset" : "0x3800" + "offset" : "0x4800" } } } diff --git a/generic_ip/fire_pulse_manager/5/doc/fpm_ctrl_5.json b/generic_ip/fire_pulse_manager/5/doc/fpm_ctrl_5.json index c610ad5..d42a3fc 100644 --- a/generic_ip/fire_pulse_manager/5/doc/fpm_ctrl_5.json +++ b/generic_ip/fire_pulse_manager/5/doc/fpm_ctrl_5.json @@ -53,8 +53,27 @@ } } }, - "Signal selection": { + "fpm_init": { "address": "2", + "width": "2", + "description": "Controls signal selection", + "fields": { + "fpm_init_start" : { + "type" : "w", + "bit_len" : "1", + "reset" : "0", + "description" : "Start the fpm_init procedure" + }, + "fpm_init_done" : { + "type" : "r", + "bit_len" : "1", + "reset" : "0", + "description" : "fpm_init completed flag" + } + } + }, + "Signal selection": { + "address": "3", "width": "4", "description": "Controls signal selection", "fields": { @@ -85,7 +104,7 @@ } }, "pof_receiver_control": { - "address": "3", + "address": "4", "width": "8", "description": "Controls POF receiver", "fields": { @@ -122,7 +141,7 @@ } }, "monitoring_point_selection": { - "address": "4", + "address": "5", "width": "16", "description": "Selects monitoring points for external header", "fields": { @@ -154,13 +173,13 @@ }, "coarse_time_init": { "type": "w", - "address": "5", + "address": "6", "reset": "0x00000000", "width": "32", "description": "Defines coarse time counter value" }, "fine_time_init": { - "address": "6", + "address": "7", "width": "29", "description": "Fine time counter value/Load counter enable", "fields": { @@ -180,20 +199,20 @@ }, "fine_time_status": { "type": "r", - "address": "7", + "address": "8", "reset": "0x0000000", "width": "28", "description": "Current fine time counter value" }, "coarse_time_status": { "type": "r", - "address": "8", + "address": "9", "reset": "0x00000000", "width": "32", "description": "Current coarse time counter value" }, "pof_rx_status": { - "address": "9", + "address": "10", "width": "32", "description": "Status of POF receiver", "fields": { @@ -212,7 +231,7 @@ } }, "pof_rx_control": { - "address": "10", + "address": "11", "width": "12", "description": "POF receiver error control", "fields": { @@ -249,7 +268,7 @@ } }, "fpm_interrupt": { - "address": "11", + "address": "12", "width": "16", "description": "Interrupt control", "fields": { @@ -300,7 +319,7 @@ } }, "fpm_ext_ctrl": { - "address": "12", + "address": "13", "width": "32", "description": "Controls regeneration of external fire pulses", "fields": { @@ -317,6 +336,30 @@ "description": "Width of regenerated external fire pulses" } } + }, + "drop_watch_config": { + "address": "14", + "width": "32", + "description": "Drop-Watch configuration", + "fields": { + "dw_src": { + "type": "w", + "bit_len": "4", + "reset": "0x0", + "description": "Select the source channel for the drop-watch" + }, + "reserved": { + "type": "rsv", + "bit_len": "12", + "description": "Reserved" + }, + "dw_pulse_width": { + "type": "w", + "bit_len": "16", + "reset": "0x000A", + "description": "Drop-Watch pulse width, expressed as clock cycles @100MHz" + } + } } } }] \ No newline at end of file diff --git a/generic_ip/fire_pulse_manager/5/sim/wave_fpm.do b/generic_ip/fire_pulse_manager/5/sim/wave_fpm.do index 98b52ba..c1089b9 100644 --- a/generic_ip/fire_pulse_manager/5/sim/wave_fpm.do +++ b/generic_ip/fire_pulse_manager/5/sim/wave_fpm.do @@ -25,7 +25,6 @@ add wave -noupdate -group TB /fire_pulse_manager_5_tb/pd add wave -noupdate -group TB /fire_pulse_manager_5_tb/seb_epd_enc_p1 add wave -noupdate -group TB /fire_pulse_manager_5_tb/seb_epd_enc_p2 add wave -noupdate -group TB /fire_pulse_manager_5_tb/seb_epd_pd -add wave -noupdate -group TB /fire_pulse_manager_5_tb/seb_epd_link_out add wave -noupdate -group TB /fire_pulse_manager_5_tb/end_of_swathe add wave -noupdate -group TB /fire_pulse_manager_5_tb/test_completed add wave -noupdate -group TB /fire_pulse_manager_5_tb/running @@ -51,7 +50,6 @@ add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/pof_iso_en add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/seb_epd_enc_p1 add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/seb_epd_enc_p2 add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/seb_epd_pd -add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/seb_epd_link_out add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/fire_pulse add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/start_of_image add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/dp_dir_out diff --git a/generic_ip/fire_pulse_manager/5/src/fire_pulse_manager_5.vhd b/generic_ip/fire_pulse_manager/5/src/fire_pulse_manager_5.vhd index 6962afe..c738902 100644 --- a/generic_ip/fire_pulse_manager/5/src/fire_pulse_manager_5.vhd +++ b/generic_ip/fire_pulse_manager/5/src/fire_pulse_manager_5.vhd @@ -6,7 +6,7 @@ -- Author : Gianmarco Girau -- Company : Global Inkjet Systems -- Created : 2017-09-06 --- Last update: 2020-01-03 +-- Last update: 2020-01-08 -- SVN ID : Git -- Standard : VHDL'08 ------------------------------------------------------------------------------- @@ -46,10 +46,10 @@ entity fire_pulse_manager_5 is pof_rx : in std_logic; pof_tx : out std_logic; pof_iso_en : out std_logic; + seb_epd_mode_en : out std_logic; seb_epd_enc_p1 : in std_logic; seb_epd_enc_p2 : in std_logic; seb_epd_pd : in std_logic; - seb_epd_link_out : out std_logic; fire_pulse : out std_logic_vector(ch_num - 1 downto 0); start_of_image : out std_logic_vector(ch_num - 1 downto 0); dp_dir_out : out std_logic_vector(ch_num - 1 downto 0); @@ -170,6 +170,7 @@ architecture rtl of fire_pulse_manager_5 is signal enc_p1_ie : std_logic; signal enc_p2_ie : std_logic; -- + signal pof_tx_regen : std_logic; signal pof_tx_data : std_logic; signal dw_pulse : std_logic; signal dw_pulse_i : std_logic; @@ -346,15 +347,26 @@ begin end if; end process pENC_PD_SRC_SEL; - gSEB_EPD_LINKOUT : if SEB_EPD_MODE = true generate + gPOF_TX_OUT : if SEB_EPD_MODE = true generate - seb_epd_link_out <= pof_tx_data when src_sel(3) = '0' else dw_pulse; + pof_tx <= pof_tx_regen when src_sel(2) = '0' else + pof_tx_data when src_sel(3) = '0' else + dw_pulse; + + pBUF_SEB_EPD_MODE : process(clk) + begin + if(clk = '1' and clk'event) then + seb_epd_mode_en <= src_sel(2); + end if; + end process pBUF_SEB_EPD_MODE; else generate - seb_epd_link_out <= '0'; + pof_tx <= pof_tx_regen; + + seb_epd_mode_en <= '0'; - end generate gSEB_EPD_LINKOUT; + end generate gPOF_TX_OUT; pBUF_OUT : process(clk) begin @@ -499,7 +511,7 @@ begin enable => enable_rx, bypass_en => uart_regen_bypass, uart_rx => pof_rx, - uart_tx => pof_tx); + uart_tx => pof_tx_regen); print_start_i <= '0'; @@ -773,8 +785,6 @@ begin -- Drop-Watch Pulse generation ----------------------------------------------------------------------------- - dw_pulse <= '0'; - pGEN_DW: process(clk) begin if(clk = '1' and clk'event) then diff --git a/generic_ip/fire_pulse_manager/5/src/test/fire_pulse_manager_5_tb.vhd b/generic_ip/fire_pulse_manager/5/src/test/fire_pulse_manager_5_tb.vhd index f09b239..18c2aa9 100644 --- a/generic_ip/fire_pulse_manager/5/src/test/fire_pulse_manager_5_tb.vhd +++ b/generic_ip/fire_pulse_manager/5/src/test/fire_pulse_manager_5_tb.vhd @@ -6,7 +6,7 @@ -- Author : Christos Spirotis -- Company : Global Inkjet Systems -- Created : 2018-08-10 --- Last update: 2020-01-07 +-- Last update: 2020-01-08 -- SVN ID : Git -- Standard : VHDL'08 ------------------------------------------------------------------------------- @@ -89,7 +89,6 @@ architecture behav of fire_pulse_manager_5_tb is signal seb_epd_enc_p1 : std_logic; signal seb_epd_enc_p2 : std_logic; signal seb_epd_pd : std_logic; - signal seb_epd_link_out : std_logic; -- signal emul_address : std_logic_vector( 9 downto 0); signal emul_write : std_logic; @@ -170,7 +169,6 @@ begin -- behav seb_epd_enc_p1 => seb_epd_enc_p1, seb_epd_enc_p2 => seb_epd_enc_p2, seb_epd_pd => seb_epd_pd, - seb_epd_link_out => seb_epd_link_out, fire_pulse => ch_pulse_out, mon_pt => open, ins_fpm_irq_0 => open, From 508a14c15958529140ca04cb6906b4e7d8fda28c Mon Sep 17 00:00:00 2001 From: gianmarcogirau Date: Tue, 14 Jan 2020 11:22:54 +0000 Subject: [PATCH 10/15] CORE-73 - Minor changes to FPM-5 --- .../5/src/fire_pulse_ctrl_5.vhd | 5 ++- .../5/src/fire_pulse_manager_5.vhd | 32 +++++++++++-------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/generic_ip/fire_pulse_manager/5/src/fire_pulse_ctrl_5.vhd b/generic_ip/fire_pulse_manager/5/src/fire_pulse_ctrl_5.vhd index d89cb71..1107ac4 100644 --- a/generic_ip/fire_pulse_manager/5/src/fire_pulse_ctrl_5.vhd +++ b/generic_ip/fire_pulse_manager/5/src/fire_pulse_ctrl_5.vhd @@ -6,7 +6,7 @@ -- Author : Gianmarco Girau -- Company : Global Inkjet Systems -- Created : 2017-09-06 --- Last update: 2020-01-02 +-- Last update: 2020-01-13 -- SVN ID : Git -- Standard : VHDL'08 ------------------------------------------------------------------------------- @@ -26,6 +26,7 @@ entity fire_pulse_ctrl_5 is port( reset_n : in std_logic; clk : in std_logic; + fpm_init : out std_logic; src_sel : out std_logic_vector(3 downto 0); uart_regen_bypass : out std_logic; enable_rx : out std_logic; @@ -137,6 +138,8 @@ begin fpm_init_pulse <= fpm_init_start and fpm_init_d; fpm_init_done <= '1' when unsigned(init_cnt) = 50 else '0'; + fpm_init <= fpm_init_i; + fine_time_wrap <= '1' when unsigned(fine_time_i) = FINE_TIME_TC else '0'; coarse_time <= coarse_time_i; diff --git a/generic_ip/fire_pulse_manager/5/src/fire_pulse_manager_5.vhd b/generic_ip/fire_pulse_manager/5/src/fire_pulse_manager_5.vhd index c738902..06e2e91 100644 --- a/generic_ip/fire_pulse_manager/5/src/fire_pulse_manager_5.vhd +++ b/generic_ip/fire_pulse_manager/5/src/fire_pulse_manager_5.vhd @@ -6,7 +6,7 @@ -- Author : Gianmarco Girau -- Company : Global Inkjet Systems -- Created : 2017-09-06 --- Last update: 2020-01-08 +-- Last update: 2020-01-14 -- SVN ID : Git -- Standard : VHDL'08 ------------------------------------------------------------------------------- @@ -169,6 +169,8 @@ architecture rtl of fire_pulse_manager_5 is signal enc_p2_mux : std_logic; signal enc_p1_ie : std_logic; signal enc_p2_ie : std_logic; + signal ems_filt_p1 : std_logic; + signal ems_filt_p2 : std_logic; -- signal pof_tx_regen : std_logic; signal pof_tx_data : std_logic; @@ -184,6 +186,7 @@ architecture rtl of fire_pulse_manager_5 is signal start_of_image_i : std_logic_vector(CH_NUM - 1 downto 0); signal fire_pulse_i : std_logic_vector(CH_NUM - 1 downto 0); signal src_sel : std_logic_vector(3 downto 0); + signal fpm_init : std_logic; -- type vel_samp_per_vec_t is array (0 to CH_NUM-1) of std_logic_vector(19 downto 0); signal vel_meas : std_logic_vector(19 downto 0); @@ -279,6 +282,7 @@ begin port map( reset_n => reset_n_i, clk => clk, + fpm_init => fpm_init, src_sel => src_sel, uart_regen_bypass => uart_regen_bypass, enable_rx => enable_rx, @@ -306,10 +310,6 @@ begin avs_readdatavalid => cs_ctrl_read_valid, avs_readdata => cs_ctrl_read_data); - ins_fpm_irq_1 <= '0'; - ins_fpm_irq_2 <= '0'; - ins_fpm_irq_3 <= '0'; - ----------------------------------------------------------------------------- -- I/Os selection @@ -383,9 +383,9 @@ begin begin if(clk = '1' and clk'Event) then if(src_sel(1) = '0') then - init <= not enable_rx or remote_init; + init <= fpm_init or (not enable_rx) or remote_init; else - init <= set_pos_ie; + init <= fpm_init or set_pos_ie; end if; end if; end process pINIT_GEN; @@ -592,8 +592,8 @@ begin set_pos => open, inc_pos => inc_pos_ems, dec_pos => dec_pos_ems, - filt_p1 => open, - filt_p2 => open, + filt_p1 => ems_filt_p1, + filt_p2 => ems_filt_p2, filt_zp => open, filt_pd => open); @@ -672,6 +672,10 @@ begin cs_diag_read_data <= X"DEAD_BEEF"; + ins_fpm_irq_1 <= '0'; + ins_fpm_irq_2 <= '0'; + ins_fpm_irq_3 <= '0'; + elsif ADD_SMB_DIAG = true generate iDiagnostic : entity work.smb_diagnostics_5 @@ -679,17 +683,17 @@ begin clk => clk, reset_n => reset_n_i, ext_diag_rst => init, - rs422_phase0 => '0', - rs422_phase1 => '0', + rs422_phase0 => seb_epd_enc_p1, + rs422_phase1 => seb_epd_enc_p2, rs422_zero_ph => '0', - rs422_prod_det => '0', + rs422_prod_det => seb_epd_pd, ttl_phase0 => '0', ttl_phase1 => '0', ttl_zero_ph => '0', ttl_prod_det => '0', ttl_prod_det_npn => '0', - filt_phase0 => '0', - filt_phase1 => '0', + filt_phase0 => ems_filt_p1, + filt_phase1 => ems_filt_p2, filt_zero_ph => '0', filt_prod_det => pd_pulse, enc_out => enc_pulse(0), From 073dcadd3a8d99b2e6365ef3f2f5a729fdb9b1a0 Mon Sep 17 00:00:00 2001 From: gianmarcogirau Date: Fri, 17 Jan 2020 10:05:42 +0000 Subject: [PATCH 11/15] CORE-73 - Verified Drop-Watch functionality, integrated LEDs generation block from the SMB --- .../fire_pulse_manager/5/doc/fpm_ctrl_5.json | 79 ++++ .../fire_pulse_manager/5/doc/fpm_diags_5.json | 2 +- .../fire_pulse_manager/5/sim/com_fpm.do | 1 + .../fire_pulse_manager/5/sim/wave_fpm.do | 20 +- .../5/src/fire_pulse_ctrl_5.vhd | 9 +- .../5/src/fire_pulse_ctrl_5_pkg.vhd | 3 +- .../5/src/fire_pulse_manager_5.vhd | 82 +++- .../5/src/seb_epd_led_gen_5.vhd | 390 ++++++++++++++++++ .../5/src/test/fire_pulse_manager_5_tb.vhd | 33 +- .../src/test/fire_pulse_manager_5_tb_pkg.vhd | 49 ++- 10 files changed, 651 insertions(+), 17 deletions(-) create mode 100644 generic_ip/fire_pulse_manager/5/src/seb_epd_led_gen_5.vhd diff --git a/generic_ip/fire_pulse_manager/5/doc/fpm_ctrl_5.json b/generic_ip/fire_pulse_manager/5/doc/fpm_ctrl_5.json index d42a3fc..ab2cafe 100644 --- a/generic_ip/fire_pulse_manager/5/doc/fpm_ctrl_5.json +++ b/generic_ip/fire_pulse_manager/5/doc/fpm_ctrl_5.json @@ -360,6 +360,85 @@ "description": "Drop-Watch pulse width, expressed as clock cycles @100MHz" } } + }, + "seb_epd_led_status": { + "address": "15", + "width": "12", + "description": "SEB-EPD LED status", + "fields": { + "led_pd_g": { + "type": "r", + "bit_len": "1", + "reset": "0x0", + "description": "LED PD Green" + }, + "led_pd_y": { + "type": "r", + "bit_len": "1", + "reset": "0x0", + "description": "LED PD Yellow" + }, + "led_pd_r": { + "type": "r", + "bit_len": "1", + "reset": "0x0", + "description": "LED PD Red" + }, + "led_enc_p1_g": { + "type": "r", + "bit_len": "1", + "reset": "0x0", + "description": "LED Encoder-Phase-1 Green" + }, + "led_enc_p1_y": { + "type": "r", + "bit_len": "1", + "reset": "0x0", + "description": "LED Encoder-Phase-1 Yellow" + }, + "led_enc_p1_r": { + "type": "r", + "bit_len": "1", + "reset": "0x0", + "description": "LED Encoder-Phase-1 Red" + }, + "led_enc_p2_g": { + "type": "r", + "bit_len": "1", + "reset": "0x0", + "description": "LED Encoder-Phase-2 Green" + }, + "led_enc_p2_y": { + "type": "r", + "bit_len": "1", + "reset": "0x0", + "description": "LED Encoder-Phase-2 Yellow" + }, + "led_enc_p2_r": { + "type": "r", + "bit_len": "1", + "reset": "0x0", + "description": "LED Encoder-Phase-2 Red" + }, + "led_pof_in_g": { + "type": "r", + "bit_len": "1", + "reset": "0x0", + "description": "LED POF-In Green" + }, + "led_pof_in_y": { + "type": "r", + "bit_len": "1", + "reset": "0x0", + "description": "LED POF-In Yellow" + }, + "led_pof_in_r": { + "type": "r", + "bit_len": "1", + "reset": "0x0", + "description": "LED POF-In Red" + } + } } } }] \ No newline at end of file diff --git a/generic_ip/fire_pulse_manager/5/doc/fpm_diags_5.json b/generic_ip/fire_pulse_manager/5/doc/fpm_diags_5.json index 0ec64dd..bb9da79 100644 --- a/generic_ip/fire_pulse_manager/5/doc/fpm_diags_5.json +++ b/generic_ip/fire_pulse_manager/5/doc/fpm_diags_5.json @@ -380,7 +380,7 @@ "type": "w", "bit_len": "1", "reset": "0x0", - "description": "PD log source: 0 => PD-FIFO associated to Filtered-PD input, 1 => PD-FIFO associated to PD-out input" + "description": "PD log source: 0 => PD-FIFO associated to PD pulse at the input of the Pulse-Generator, 1 => PD-FIFO associated to output of the PD Queue on the first channel" }, "fifo_level": { "type": "r", diff --git a/generic_ip/fire_pulse_manager/5/sim/com_fpm.do b/generic_ip/fire_pulse_manager/5/sim/com_fpm.do index 1db2616..a2bf9ed 100644 --- a/generic_ip/fire_pulse_manager/5/sim/com_fpm.do +++ b/generic_ip/fire_pulse_manager/5/sim/com_fpm.do @@ -97,5 +97,6 @@ vcom -2008 -work $WORKLIB $SRC_PATH/fire_pulse_5_pkg.vhd vcom -2008 -work $WORKLIB $SRC_PATH/fire_pulse_ctrl_5_pkg.vhd vcom -2008 -work $WORKLIB $SRC_PATH/fire_pulse_ctrl_5.vhd vcom -2008 -work $WORKLIB $SRC_PATH/fire_pulse_ext_5.vhd +vcom -2008 -work $WORKLIB $SRC_PATH/seb_epd_led_gen_5.vhd vcom -2008 -work $WORKLIB $SRC_PATH/fire_pulse_manager_5.vhd diff --git a/generic_ip/fire_pulse_manager/5/sim/wave_fpm.do b/generic_ip/fire_pulse_manager/5/sim/wave_fpm.do index c1089b9..a61228b 100644 --- a/generic_ip/fire_pulse_manager/5/sim/wave_fpm.do +++ b/generic_ip/fire_pulse_manager/5/sim/wave_fpm.do @@ -41,6 +41,9 @@ add wave -noupdate -group TB /fire_pulse_manager_5_tb/sel_slave_0 add wave -noupdate -group TB /fire_pulse_manager_5_tb/sel_slave_1 add wave -noupdate -group TB /fire_pulse_manager_5_tb/pd_cnt add wave -noupdate -group TB /fire_pulse_manager_5_tb/fp_cnt +add wave -noupdate -group TB /fire_pulse_manager_5_tb/run_dw +add wave -noupdate -group TB /fire_pulse_manager_5_tb/dw +add wave -noupdate -group TB /fire_pulse_manager_5_tb/dw_cnt add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/reset_n add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/clk add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/rx_clk @@ -163,6 +166,19 @@ add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/ext_fp_det add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/ext_fp_gen add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/pof_rx_regen add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/log_data_src +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/led_pd_g +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/led_pd_y +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/led_pd_r +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/led_enc_p1_g +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/led_enc_p1_y +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/led_enc_p1_r +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/led_enc_p2_g +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/led_enc_p2_y +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/led_enc_p2_r +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/led_pof_g +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/led_pof_y +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/led_pof_r +add wave -noupdate -group {FPM top} /fire_pulse_manager_5_tb/iDUT/led_status add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/reset_n add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/clk add wave -noupdate -group {POF RX} /fire_pulse_manager_5_tb/iDUT/gPOF/iPOF_RX/init @@ -689,7 +705,7 @@ add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/abs_pos_in add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/abs_pos_vel add wave -noupdate -group EMS /fire_pulse_manager_5_tb/iDUT/gEMS/iEMS/delta_t TreeUpdate [SetDefaultTree] -WaveRestoreCursors {{Cursor 1} {8565000 ps} 0} +WaveRestoreCursors {{Cursor 1} {2100245000 ps} 0} quietly wave cursor active 1 configure wave -namecolwidth 223 configure wave -valuecolwidth 100 @@ -705,4 +721,4 @@ configure wave -griddelta 40 configure wave -timeline 0 configure wave -timelineunits ps update -WaveRestoreZoom {709687556 ps} {758321708 ps} +WaveRestoreZoom {404659377 ps} {453293529 ps} diff --git a/generic_ip/fire_pulse_manager/5/src/fire_pulse_ctrl_5.vhd b/generic_ip/fire_pulse_manager/5/src/fire_pulse_ctrl_5.vhd index 1107ac4..7a1b075 100644 --- a/generic_ip/fire_pulse_manager/5/src/fire_pulse_ctrl_5.vhd +++ b/generic_ip/fire_pulse_manager/5/src/fire_pulse_ctrl_5.vhd @@ -6,7 +6,7 @@ -- Author : Gianmarco Girau -- Company : Global Inkjet Systems -- Created : 2017-09-06 --- Last update: 2020-01-13 +-- Last update: 2020-01-16 -- SVN ID : Git -- Standard : VHDL'08 ------------------------------------------------------------------------------- @@ -46,6 +46,7 @@ entity fire_pulse_ctrl_5 is ext_fp_gen : out std_logic_vector(15 downto 0); dw_src : out std_logic_vector( 3 downto 0); dw_pulse_width : out std_logic_vector(15 downto 0); + led_status : in std_logic_vector(11 downto 0); -- Interrupt Senders ins_fpm_irq_0 : out std_logic; -- Avalon MM Interface @@ -250,8 +251,8 @@ begin ext_fp_det_i <= avs_writedata(15 downto 0); ext_fp_gen_i <= avs_writedata(31 downto 16); when DW_CFG_REG => - dw_src_i <= avs_writedata( 3 downto 0); - dw_pulse_width_i <= avs_writedata(15 downto 0); + dw_src_i <= avs_writedata( 3 downto 0); + dw_pulse_width_i <= avs_writedata(31 downto 16); when others => null; end case; end if; @@ -289,6 +290,8 @@ begin avs_readdata <= ext_fp_gen_i & ext_fp_det_i; when DW_CFG_REG => avs_readdata <= dw_pulse_width_i & X"000" & dw_src_i; + when LED_STATUS_REG => + avs_readdata <= 20x"0" & led_status; when others => avs_readdata <= X"BAD1BAD0"; end case; diff --git a/generic_ip/fire_pulse_manager/5/src/fire_pulse_ctrl_5_pkg.vhd b/generic_ip/fire_pulse_manager/5/src/fire_pulse_ctrl_5_pkg.vhd index 3c1c2b2..839f1c1 100644 --- a/generic_ip/fire_pulse_manager/5/src/fire_pulse_ctrl_5_pkg.vhd +++ b/generic_ip/fire_pulse_manager/5/src/fire_pulse_ctrl_5_pkg.vhd @@ -6,7 +6,7 @@ -- Author : GMG -- Company : Global Inkjet Systems -- Created : 2018-05-24 --- Last update: 2019-12-18 +-- Last update: 2020-01-16 -- SVN ID : Git -- Standard : VHDL'2008 ------------------------------------------------------------------------------- @@ -36,5 +36,6 @@ package fire_pulse_ctrl_5_pkg is constant IRQ_MNG_REG : std_logic_vector(3 downto 0) := X"C"; constant EXT_FP_CTRL_REG : std_logic_vector(3 downto 0) := X"D"; constant DW_CFG_REG : std_logic_vector(3 downto 0) := X"E"; + constant LED_STATUS_REG : std_logic_vector(3 downto 0) := X"F"; end package fire_pulse_ctrl_5_pkg; diff --git a/generic_ip/fire_pulse_manager/5/src/fire_pulse_manager_5.vhd b/generic_ip/fire_pulse_manager/5/src/fire_pulse_manager_5.vhd index 06e2e91..73e0550 100644 --- a/generic_ip/fire_pulse_manager/5/src/fire_pulse_manager_5.vhd +++ b/generic_ip/fire_pulse_manager/5/src/fire_pulse_manager_5.vhd @@ -6,7 +6,7 @@ -- Author : Gianmarco Girau -- Company : Global Inkjet Systems -- Created : 2017-09-06 --- Last update: 2020-01-14 +-- Last update: 2020-01-16 -- SVN ID : Git -- Standard : VHDL'08 ------------------------------------------------------------------------------- @@ -169,6 +169,7 @@ architecture rtl of fire_pulse_manager_5 is signal enc_p2_mux : std_logic; signal enc_p1_ie : std_logic; signal enc_p2_ie : std_logic; + signal ems_filt_pd : std_logic; signal ems_filt_p1 : std_logic; signal ems_filt_p2 : std_logic; -- @@ -178,6 +179,8 @@ architecture rtl of fire_pulse_manager_5 is signal dw_pulse_i : std_logic; signal rst_dw_pulse : std_logic; signal set_dw_pulse : std_logic; + signal dw_trigger : std_logic; + signal dw_trigger_d : std_logic; signal dw_pulse_cnt : std_logic_vector(15 downto 0); -- signal ch_pd, ch_pulse_out : std_logic_vector(CH_NUM - 1 downto 0); @@ -197,6 +200,20 @@ architecture rtl of fire_pulse_manager_5 is signal ext_fp_gen : std_logic_vector(15 downto 0); signal pof_rx_regen : std_logic; signal log_data_src : std_logic_vector(31 downto 0); + -- + signal led_pd_g : std_logic; + signal led_pd_y : std_logic; + signal led_pd_r : std_logic; + signal led_enc_p1_g : std_logic; + signal led_enc_p1_y : std_logic; + signal led_enc_p1_r : std_logic; + signal led_enc_p2_g : std_logic; + signal led_enc_p2_y : std_logic; + signal led_enc_p2_r : std_logic; + signal led_pof_g : std_logic; + signal led_pof_y : std_logic; + signal led_pof_r : std_logic; + signal led_status : std_logic_vector(11 downto 0); begin @@ -302,6 +319,7 @@ begin ext_fp_gen => ext_fp_gen, dw_src => dw_src, dw_pulse_width => dw_pulse_width, + led_status => led_status, ins_fpm_irq_0 => ins_fpm_irq_0, avs_address => cs_addr(3 downto 0), avs_write => cs_ctrl_write_en, @@ -383,7 +401,7 @@ begin begin if(clk = '1' and clk'Event) then if(src_sel(1) = '0') then - init <= fpm_init or (not enable_rx) or remote_init; + init <= fpm_init or (not src_sel(2) and (not enable_rx or remote_init)); else init <= fpm_init or set_pos_ie; end if; @@ -595,7 +613,7 @@ begin filt_p1 => ems_filt_p1, filt_p2 => ems_filt_p2, filt_zp => open, - filt_pd => open); + filt_pd => ems_filt_pd); pd_pulse_mux <= seb_epd_pd when src_sel(1) = '0' else pd_pulse_ie; enc_p1_mux <= seb_epd_enc_p1 when src_sel(1) = '0' else enc_p1_ie; @@ -657,6 +675,57 @@ begin end generate gPOF_TX; + ----------------------------------------------------------------------------- + -- SEB-EPD LEDs + ----------------------------------------------------------------------------- + + iLED_GEN: entity work.seb_epd_led_gen_5 + port map ( + reset_n => reset_n, + clk => clk, + init => init, + ld_pd_max_t => '0', + ld_pd_end_g_t => '0', + ld_enc_max_t => '0', + ld_enc_end_g_t => '0', + ld_pof_g_t => '0', + timing_value => (others => '0'), + host_pwr_is_up => '1', + p_good => '1', + p_in_good => '1', + p_host_good => '1', + pg_iso_5v => '1', + pg_iso_12v => '1', + rs422_pd => ems_filt_pd, + rs422_p1 => ems_filt_p1, + rs422_p2 => ems_filt_p2, + ttl_pd => '0', + ttl_pd_npn => '0', + ttl_p1 => '0', + ttl_p2 => '0', + pof_out => pof_rx, + smb_ok => '1', + led_pwr_g => open, + led_pwr_y => open, + led_pwr_r => open, + led_pd_g => led_pd_g, + led_pd_y => led_pd_y, + led_pd_r => led_pd_r, + led_enc_p1_g => led_enc_p1_g, + led_enc_p1_y => led_enc_p1_y, + led_enc_p1_r => led_enc_p1_r, + led_enc_p2_g => led_enc_p2_g, + led_enc_p2_y => led_enc_p2_y, + led_enc_p2_r => led_enc_p2_r, + led_pof_g => led_pof_g, + led_pof_y => led_pof_y, + led_pof_r => led_pof_r); + + led_status( 2 downto 0) <= led_pd_r & led_pd_y & led_pd_g; + led_status( 5 downto 3) <= led_enc_p1_r & led_enc_p1_y & led_enc_p1_g; + led_status( 8 downto 6) <= led_enc_p2_r & led_enc_p2_y & led_enc_p2_g; + led_status(11 downto 9) <= led_pof_r & led_pof_y & led_pof_g; + ----------------------------------------------------------------------------- -- Diagnostic block ----------------------------------------------------------------------------- @@ -701,7 +770,7 @@ begin pos_step => inc_pos, neg_step => dec_pos, drop_watch => '0', - fire_req => fire_pulse_i(0), + fire_req => ch_pulse_out(0), fine_time => fine_time, coarse_time => coarse_time, abs_position => open, @@ -792,6 +861,7 @@ begin pGEN_DW: process(clk) begin if(clk = '1' and clk'event) then + dw_trigger_d <= dw_trigger; if(rst_dw_pulse = '1') then dw_pulse_i <= '0'; elsif(set_dw_pulse = '1') then @@ -805,8 +875,10 @@ begin end if; end process pGEN_DW; + dw_trigger <= ch_pulse_out(to_integer(unsigned(dw_src(log2(CH_NUM)-1 downto 0)))); + rst_dw_pulse <= '1' when init = '1' or unsigned(dw_pulse_cnt) = unsigned(dw_pulse_width) else '0'; - set_dw_pulse <= '1' when fire_pulse_i(to_integer(unsigned(dw_src(log2(CH_NUM)-1 downto 0)))) = '1' else '0'; + set_dw_pulse <= dw_trigger and not dw_trigger_d; dw_pulse <= dw_pulse_i; diff --git a/generic_ip/fire_pulse_manager/5/src/seb_epd_led_gen_5.vhd b/generic_ip/fire_pulse_manager/5/src/seb_epd_led_gen_5.vhd new file mode 100644 index 0000000..5c6d888 --- /dev/null +++ b/generic_ip/fire_pulse_manager/5/src/seb_epd_led_gen_5.vhd @@ -0,0 +1,390 @@ +------------------------------------------------------------------------------- +-- Title : seb_epd_led_gen_5 +-- Project : SMB +------------------------------------------------------------------------------- +-- File : seb_epd_led_gen_5.vhd +-- Author : Gianmarco Girau +-- Company : Global Inkjet Systems +-- Created : 2018-08-06 +-- Last update: 2020-01-16 +-- SVN ID : Git +-- Standard : VHDL'08 +------------------------------------------------------------------------------- +-- Description: +-- Generate signals for driving the SMB LEDs. +-- Note: those signals can still be overwritten by software through the +-- SMB-Ctrl block. +------------------------------------------------------------------------------- + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity seb_epd_led_gen_5 is + port( + reset_n : in std_logic; + clk : in std_logic; + -- config + init : in std_logic; + ld_pd_max_t : in std_logic; + ld_pd_end_g_t : in std_logic; + ld_enc_max_t : in std_logic; + ld_enc_end_g_t : in std_logic; + ld_pof_g_t : in std_logic; + timing_value : in std_logic_vector(31 downto 0); + -- input status signals + host_pwr_is_up : in std_logic; + p_good : in std_logic; + p_in_good : in std_logic; + p_host_good : in std_logic; + pg_iso_5v : in std_logic; + pg_iso_12v : in std_logic; + rs422_pd : in std_logic; + rs422_p1 : in std_logic; + rs422_p2 : in std_logic; + ttl_pd : in std_logic; + ttl_pd_npn : in std_logic; + ttl_p1 : in std_logic; + ttl_p2 : in std_logic; + pof_out : in std_logic; + smb_ok : in std_logic; + -- LEDs outputs values + led_pwr_g : out std_logic; + led_pwr_y : out std_logic; + led_pwr_r : out std_logic; + led_pd_g : out std_logic; + led_pd_y : out std_logic; + led_pd_r : out std_logic; + led_enc_p1_g : out std_logic; + led_enc_p1_y : out std_logic; + led_enc_p1_r : out std_logic; + led_enc_p2_g : out std_logic; + led_enc_p2_y : out std_logic; + led_enc_p2_r : out std_logic; + led_pof_g : out std_logic; + led_pof_y : out std_logic; + led_pof_r : out std_logic); +end entity seb_epd_led_gen_5; + +architecture rtl of seb_epd_led_gen_5 is + + signal power_good, rs422_pd_i, ttl_pd_i, ttl_npn_pd_i : std_logic; + signal rs422_pd_d, ttl_pd_d, ttl_npn_pd_d : std_logic; + signal pd_cnt_zero_flag, rst_pd_green, pd_red, pd_green : std_logic; + signal rs422_p1_i, rs422_p2_i, ttl_p1_i, ttl_p2_i : std_logic; + signal rs422_p1_d, rs422_p2_d, ttl_p1_d, ttl_p2_d : std_logic; + signal rs422_p1_event, rs422_p2_event, p1_cnt_zero_flag : std_logic; + signal ttl_p1_event, ttl_p2_event, p2_cnt_zero_flag : std_logic; + signal rst_p1_green, rst_p2_green, p1_red, p2_red : std_logic; + signal p1_green, p2_green, pof_green, pof_out_d : std_logic; + signal pof_event, pof_cnt_zero_flag, pd_multiple_event : std_logic; + signal smb_ok_d, alert_cnt_zero_flag : std_logic; + signal pd_active, p1_active, p2_active : std_logic; + -- + signal p1_event, p2_event : std_logic_vector( 1 downto 0); + signal p1_prev_event, p2_prev_event : std_logic_vector( 1 downto 0); + signal pd_event, pd_previous_event : std_logic_vector( 2 downto 0); + signal alert_led : std_logic_vector( 3 downto 0); + signal pd_max_period, pd_end_green_t, pd_cnt : std_logic_vector(29 downto 0); + signal enc_max_period, enc_end_green_t : std_logic_vector(29 downto 0); + signal pof_green_t : std_logic_vector(29 downto 0); + signal p1_cnt, p2_cnt, pof_cnt, alert_cnt : std_logic_vector(29 downto 0); + +begin + + ----------------------------------------------------------------------------- + -- Power LED + ----------------------------------------------------------------------------- + + power_good <= '0' when p_good = '0' or p_in_good = '0' or p_host_good = '0' or pg_iso_12v = '0' or pg_iso_5v = '0' else '1'; + + led_pwr_r <= '1' when power_good = '0' and host_pwr_is_up = '1' else '0'; + + led_pwr_y <= '1' when host_pwr_is_up = '0' else '0'; + + led_pwr_g <= '1' when power_good = '1' and host_pwr_is_up = '1' else '0'; + + ----------------------------------------------------------------------------- + -- PD LEDs + ----------------------------------------------------------------------------- + + -- synchronize to the local clock and generate a pulse on the rising edge + iRS422_PD_SYNC: entity work.sync_wire + generic map (rst_val => '0', sync_stages => 3) + port map (rstN => reset_n, clk => clk, async_in => rs422_pd, sync_out => rs422_pd_i); + + iTTL_PNP_PD_SYNC: entity work.sync_wire + generic map (rst_val => '0', sync_stages => 3) + port map (rstN => reset_n, clk => clk, async_in => ttl_pd, sync_out => ttl_pd_i); + + iTTL_NPN_PD_SYNC: entity work.sync_wire + generic map (rst_val => '0', sync_stages => 3) + port map (rstN => reset_n, clk => clk, async_in => ttl_pd_npn, sync_out => ttl_npn_pd_i); + + pd_event <= (ttl_npn_pd_i xor ttl_npn_pd_d) & (ttl_pd_i xor ttl_pd_d) & (rs422_pd_i xor rs422_pd_d); + + pPD_LEDs : process(reset_n, clk) is + begin -- process + if(reset_n = '0') then + rs422_pd_d <= '0'; + ttl_pd_d <= '0'; + ttl_npn_pd_d <= '0'; + pd_previous_event <= "000"; + pd_max_period <= std_logic_vector(to_unsigned(100000000-1, 30)); + pd_end_green_t <= std_logic_vector(to_unsigned( 50000000-1, 30)); + pd_cnt <= (others => '0'); + pd_previous_event <= "000"; + pd_red <= '0'; + pd_green <= '0'; + led_pd_r <= '0'; + led_pd_y <= '0'; + led_pd_g <= '0'; + pd_active <= '0'; + elsif(clk = '1' and clk'event) then + rs422_pd_d <= rs422_pd_i; + ttl_pd_d <= ttl_pd_i; + ttl_npn_pd_d <= ttl_npn_pd_i; + if(ld_pd_max_t = '1') then + pd_max_period <= timing_value(pd_max_period'range); + end if; + if(ld_pd_end_g_t = '1') then + pd_end_green_t <= timing_value(pd_end_green_t'range); + end if; + if(init = '1' or (pd_cnt_zero_flag = '1' and pd_event = "000")) then + pd_previous_event <= "000"; + elsif(pd_event /= "000") then + pd_previous_event <= pd_event; + end if; + if(init = '1') then + pd_cnt <= (others => '0'); + elsif(pd_event /= "000" and pd_red = '0') then + pd_cnt <= pd_max_period; + elsif(pd_cnt_zero_flag = '0') then + pd_cnt <= std_logic_vector(unsigned(pd_cnt)-1); + end if; + if(init = '1' or (pd_cnt_zero_flag = '1' and pd_event = "000")) then + pd_red <= '0'; + elsif((pd_event /= "000" and pd_previous_event /= "000" and pd_event /= pd_previous_event) or pd_multiple_event = '1') then + pd_red <= '1'; + end if; + if(pd_red = '1' or rst_pd_green = '1' or init = '1') then + pd_green <= '0'; + elsif(pd_event = "001" or pd_event = "010" or pd_event = "100") then + pd_green <= '1'; + end if; + led_pd_r <= smb_ok and power_good and pd_red; + led_pd_y <= (smb_ok and power_good and pd_cnt_zero_flag and pd_active) or alert_led(0); + led_pd_g <= smb_ok and power_good and pd_green; + if(pd_event(0) = '1' or pd_event(1) = '1' or pd_event(2) = '1') then + pd_active <= '1'; + end if; + end if; + end process pPD_LEDs; + + pd_cnt_zero_flag <= '1' when unsigned(pd_cnt) = 0 else '0'; + + rst_pd_green <= '1' when unsigned(pd_cnt) = unsigned(pd_end_green_t) else '0'; + + pd_multiple_event <= '1' when pd_event = "011" or pd_event = "101" or pd_event = "110" or pd_event = "111" else '0'; + + ----------------------------------------------------------------------------- + -- Encoder LEDs + ----------------------------------------------------------------------------- + + -- synchronize the signals to the local clock domain + iRS422_P1_SYNC: entity work.sync_wire + generic map (rst_val => '0', sync_stages => 3) + port map (rstN => reset_n, clk => clk, async_in => rs422_p1, sync_out => rs422_p1_i); + + iRS422_P2_SYNC: entity work.sync_wire + generic map (rst_val => '0', sync_stages => 3) + port map (rstN => reset_n, clk => clk, async_in => rs422_p2, sync_out => rs422_p2_i); + + iTTL_P1_SYNC: entity work.sync_wire + generic map (rst_val => '0', sync_stages => 3) + port map (rstN => reset_n, clk => clk, async_in => ttl_p1, sync_out => ttl_p1_i); + + iTTL_P2_SYNC: entity work.sync_wire + generic map (rst_val => '0', sync_stages => 3) + port map (rstN => reset_n, clk => clk, async_in => ttl_p2, sync_out => ttl_p2_i); + + pENC_LEDs : process(reset_n, clk) + begin + if(reset_n = '0') then + enc_max_period <= std_logic_vector(to_unsigned(100000000-1, 30)); + enc_end_green_t <= std_logic_vector(to_unsigned( 50000000-1, 30)); + p1_cnt <= (others => '0'); + p2_cnt <= (others => '0'); + p1_red <= '0'; + p1_green <= '0'; + p2_red <= '0'; + p2_green <= '0'; + p1_prev_event <= "00"; + p2_prev_event <= "00"; + p1_active <= '0'; + p2_active <= '0'; + elsif(clk = '1' and clk'event) then + if(ld_enc_max_t = '1') then + enc_max_period <= timing_value(enc_max_period'range); + end if; + if(ld_enc_end_g_t = '1') then + enc_end_green_t <= timing_value(enc_end_green_t'range); + end if; + if(init = '1' or (p1_cnt_zero_flag = '1' and p1_event = "00")) then + p1_prev_event <= "00"; + elsif(p1_event(0) = '1' or p1_event(1) = '1') then + p1_prev_event <= p1_event; + end if; + if(init = '1' or (p2_cnt_zero_flag = '1' and p2_event = "00")) then + p2_prev_event <= "00"; + elsif(p2_event(0) = '1' or p2_event(1) = '1') then + p2_prev_event <= p2_event; + end if; + if(init = '1') then + p1_cnt <= (others => '0'); + elsif((p1_event(0) = '1' or p1_event(1) = '1') and p1_red = '0') then + p1_cnt <= enc_max_period; + elsif(p1_cnt_zero_flag = '0') then + p1_cnt <= std_logic_vector(unsigned(p1_cnt)-1); + end if; + if(init = '1') then + p2_cnt <= (others => '0'); + elsif((p2_event(0) = '1' or p2_event(1) = '1') and p2_red = '0') then + p2_cnt <= enc_max_period; + elsif(p2_cnt_zero_flag = '0') then + p2_cnt <= std_logic_vector(unsigned(p2_cnt)-1); + end if; + if(init = '1' or (p1_cnt_zero_flag = '1' and p1_event = "00")) then + p1_red <= '0'; + elsif((p1_event(0) = '1' and ((p2_event(0) ='1' or p2_event(1) = '1') or p1_event(1) = '1' or p1_prev_event(1) = '1' or p2_prev_event(1) = '1')) or (p1_event(1) = '1' and (p1_event(0) = '1' or p1_prev_event(0) = '1' or p2_prev_event(0) = '1'))) then + p1_red <= '1'; + end if; + if(init = '1' or (p2_cnt_zero_flag = '1' and p2_event = "00")) then + p2_red <= '0'; + elsif((p2_event(0) = '1' and ((p1_event(0) ='1' or p1_event(1) = '1') or p2_event(1) = '1' or p2_prev_event(1) = '1' or p1_prev_event(1) = '1')) or (p2_event(1) = '1' and (p2_event(0) = '1' or p2_prev_event(0) = '1' or p1_prev_event(0) = '1'))) then + p2_red <= '1'; + end if; + if(p1_red = '1' or rst_p1_green = '1' or init = '1') then + p1_green <= '0'; + elsif(p1_event = "01" or p1_event = "10") then + p1_green <= '1'; + end if; + if(p2_red = '1' or rst_p2_green = '1' or init = '1') then + p2_green <= '0'; + elsif(p2_event = "01" or p2_event = "10") then + p2_green <= '1'; + end if; + if(p1_event(0) = '1' or p1_event(1) = '1') then + p1_active <= '1'; + end if; + if(p2_event(0) = '1' or p2_event(1) = '1') then + p2_active <= '1'; + end if; + end if; + end process pENC_LEDs; + + pENC_LEDs_NR : process(clk) + begin + if(clk = '1' and clk'event) then + rs422_p1_d <= rs422_p1_i; + rs422_p2_d <= rs422_p2_i; + ttl_p1_d <= ttl_p1_i; + ttl_p2_d <= ttl_p2_i; + p1_event <= ttl_p1_event & rs422_p1_event; + p2_event <= ttl_p2_event & rs422_p2_event; + led_enc_p1_r <= smb_ok and power_good and p1_red; + led_enc_p1_y <= (smb_ok and power_good and p1_cnt_zero_flag and not p1_red and p1_active) or alert_led(1); + led_enc_p1_g <= smb_ok and power_good and p1_green and not p1_red; + led_enc_p2_r <= smb_ok and power_good and p2_red; + led_enc_p2_y <= (smb_ok and power_good and p2_cnt_zero_flag and not p2_red and p2_active) or alert_led(2); + led_enc_p2_g <= smb_ok and power_good and p2_green and not p2_red; + end if; + end process pENC_LEDs_NR; + + rs422_p1_event <= rs422_p1_i xor rs422_p1_d; + rs422_p2_event <= rs422_p2_i xor rs422_p2_d; + ttl_p1_event <= ttl_p1_i xor ttl_p1_d; + ttl_p2_event <= ttl_p2_i xor ttl_p2_d; + + p1_cnt_zero_flag <= '1' when unsigned(p1_cnt) = 0 else '0'; + p2_cnt_zero_flag <= '1' when unsigned(p2_cnt) = 0 else '0'; + + rst_p1_green <= '1' when unsigned(p1_cnt) = unsigned(enc_end_green_t) else '0'; + rst_p2_green <= '1' when unsigned(p2_cnt) = unsigned(enc_end_green_t) else '0'; + + ----------------------------------------------------------------------------- + -- POF LEDs + ----------------------------------------------------------------------------- + + pPOF_LED : process(reset_n, clk) + begin + if(reset_n = '0') then + pof_green_t <= std_logic_vector(to_unsigned( 50000000-1, 30)); + pof_cnt <= (others => '0'); + pof_out_d <= '0'; + pof_green <= '0'; + led_pof_g <= '0'; + elsif(clk = '1' and clk'event) then + if(ld_pof_g_t = '1') then + pof_green_t <= timing_value(pof_green_t'range); + end if; + pof_out_d <= pof_out; + if(init = '1') then + pof_cnt <= (others => '0'); + elsif(pof_event = '1') then + pof_cnt <= pof_green_t; + elsif(pof_cnt_zero_flag = '0') then + pof_cnt <= std_logic_vector(unsigned(pof_cnt)-1); + end if; + if(init = '1' or (pof_cnt_zero_flag = '1' and pof_event = '0')) then + pof_green <= '0'; + elsif(pof_event = '1') then + pof_green <= '1'; + end if; + led_pof_g <= smb_ok and power_good and pof_green; + end if; + end process pPOF_LED; + + -- create event only on the rising edge + pof_event <= pof_out and not pof_out_d; + + pof_cnt_zero_flag <= '1' when unsigned(pof_cnt) = 0 else '0'; + + led_pof_y <= alert_led(3); + led_pof_r <= '0'; + + + ----------------------------------------------------------------------------- + -- Emergency Flashing + ----------------------------------------------------------------------------- + + -- when the smb_ctrl watchdog is triggered (smb_ok deasserted), all the LEDs, + -- apart from the power LED, needs to start flashing + + pEMERGENCY_FLASH : process(clk) + begin + if(clk = '1' and clk'event) then + smb_ok_d <= smb_ok; + if(smb_ok = '1') then + alert_led <= "0000"; + elsif(smb_ok = '0' and smb_ok_d = '1') then + alert_cnt <= std_logic_vector(to_unsigned( 50000000-1, 30)); + else + if(alert_cnt_zero_flag = '1') then + if(alert_led = "1111") then + alert_led <= "0000"; + else + alert_led <= alert_led(2 downto 0) & '1'; + end if; + alert_cnt <= std_logic_vector(to_unsigned( 50000000-1, 30)); + else + alert_cnt <= std_logic_vector(unsigned(alert_cnt)-1); + end if; + end if; + end if; + end process pEMERGENCY_FLASH; + + alert_cnt_zero_flag <= '1' when unsigned(alert_cnt) = 0 else '0'; + + +end architecture rtl; diff --git a/generic_ip/fire_pulse_manager/5/src/test/fire_pulse_manager_5_tb.vhd b/generic_ip/fire_pulse_manager/5/src/test/fire_pulse_manager_5_tb.vhd index 18c2aa9..baefd3d 100644 --- a/generic_ip/fire_pulse_manager/5/src/test/fire_pulse_manager_5_tb.vhd +++ b/generic_ip/fire_pulse_manager/5/src/test/fire_pulse_manager_5_tb.vhd @@ -6,7 +6,7 @@ -- Author : Christos Spirotis -- Company : Global Inkjet Systems -- Created : 2018-08-10 --- Last update: 2020-01-08 +-- Last update: 2020-01-16 -- SVN ID : Git -- Standard : VHDL'08 ------------------------------------------------------------------------------- @@ -56,6 +56,10 @@ architecture behav of fire_pulse_manager_5_tb is constant SWATHE_LEN : integer := 600; constant IMAGE_SIZE : integer := 100; constant START_DIR : enc_dir_t := DIR_0; + + -- when DRIVE_DROP_WATCH is true, FPM output pof_tx is driven with the + -- drop-watch signal + constant DRIVE_DROP_WATCH : boolean := true; constant VERBOSITY_LEVEL : verb_level_t := VMEDIUM; @@ -131,6 +135,11 @@ architecture behav of fire_pulse_manager_5_tb is signal loc_fp_cnt : fp_cnt_t; signal ch_pulse_out_d : std_logic_vector(CH_NUM-1 downto 0); -- + signal run_dw : std_logic; + signal dw : std_logic; + signal dw_d : std_logic; + signal dw_cnt : natural; + -- signal input_mode : fpm_input_type_t; @@ -376,11 +385,15 @@ begin -- behav -- Testbench Control ----------------------------------------------------------------------------- + dw <= pof_tx when run_dw = '1' else '0'; + pOUT_CHECK_REGs : process(reset_n, clk) begin if(reset_n = '0') then ch_pulse_out_d <= (others => '0'); loc_fp_cnt <= (others => 0); + dw_d <= '0'; + dw_cnt <= 0; elsif(clk = '1' and clk'event) then ch_pulse_out_d <= ch_pulse_out; for n in 0 to CH_NUM-1 loop @@ -397,6 +410,12 @@ begin -- behav end if; end loop; -- n end if; + dw_d <= dw; + if(run_dw = '0') then + dw_cnt <= 0; + elsif(dw = '1' and dw_d = '0') then + dw_cnt <= dw_cnt + 1; + end if; end if; end process pOUT_CHECK_REGs; @@ -545,6 +564,8 @@ begin -- behav input_mode <= POF_INPUT; + run_dw <= '0'; + -- Initialize avalon mm interfaces mm_m_init(avs_m, use_waitrequest => true); @@ -587,6 +608,10 @@ begin -- behav fpm_input_config(input_mode, avs_s, avs_m); + if(DRIVE_DROP_WATCH = true) then + drop_watch_config('1', "0001", 15, avs_s, avs_m); + end if; + while stimuli_completed = false loop wait until reprogram_offset = true or stimuli_completed = true; if (stimuli_completed) then @@ -615,6 +640,12 @@ begin -- behav input_mode <= EPD_INPUT; wait until clk = '1' and clk'event; fpm_input_config(input_mode, avs_s, avs_m); + + if(DRIVE_DROP_WATCH = true) then + drop_watch_config('1', "0001", 15, avs_s, avs_m); + end if; + + run_dw <= '1'; end if; log("Reprogramming offset ... ", VLOW, true); diff --git a/generic_ip/fire_pulse_manager/5/src/test/fire_pulse_manager_5_tb_pkg.vhd b/generic_ip/fire_pulse_manager/5/src/test/fire_pulse_manager_5_tb_pkg.vhd index 8113ba2..9e33064 100644 --- a/generic_ip/fire_pulse_manager/5/src/test/fire_pulse_manager_5_tb_pkg.vhd +++ b/generic_ip/fire_pulse_manager/5/src/test/fire_pulse_manager_5_tb_pkg.vhd @@ -6,7 +6,7 @@ -- Author : Gianmarco Girau -- Company : Global Inkjet Systems -- Created : 2020-01-02 --- Last update: 2020-01-07 +-- Last update: 2020-01-16 -- SVN ID : Git -- Standard : VHDL'2008 ------------------------------------------------------------------------------- @@ -117,6 +117,13 @@ package fire_pulse_manager_5_tb_pkg is signal mm_s : in mm_s_rec_t; signal mm_m : out mm_m_rec_t); + procedure drop_watch_config( + enable : in std_logic; + src : in std_logic_vector(3 downto 0); + pulse_witdth : in natural; + signal mm_s : in mm_s_rec_t; + signal mm_m : out mm_m_rec_t); + ----------------------------------------------------------------------------- -- ENC/PD Emulator Configuration ----------------------------------------------------------------------------- @@ -284,9 +291,11 @@ package body fire_pulse_manager_5_tb_pkg is -- Enable the POF-Rx data := X"0000_0001"; fpm_reg_write(FP_CTRL_ID, POF_RX_CTRL, data, mm_s, mm_m); + + fpm_reg_read(FP_CTRL_ID, SRC_SEL_REG, data, mm_s, mm_m); -- Select the input source - data := X"0000_0001"; + data(2 downto 0) := b"001"; fpm_reg_write(FP_CTRL_ID, SRC_SEL_REG, data, mm_s, mm_m); -- Config external fire pulses @@ -450,15 +459,19 @@ package body fire_pulse_manager_5_tb_pkg is begin + + if(input_type = POF_INPUT) then - data := X"0000_0001"; + fpm_reg_read(FP_CTRL_ID, SRC_SEL_REG, data, mm_s, mm_m); + + data(2 downto 0) := b"001"; fpm_reg_write(FP_CTRL_ID, SRC_SEL_REG, data, mm_s, mm_m); log("FPM input set to POF. ", VLOW, true); elsif(input_type = EPD_INPUT) then - data := X"0000_0005"; + data(2 downto 0) := b"101"; fpm_reg_write(FP_CTRL_ID, SRC_SEL_REG, data, mm_s, mm_m); log("FPM input set to EPD. ", VLOW, true); @@ -491,6 +504,34 @@ package body fire_pulse_manager_5_tb_pkg is end procedure fpm_ems_config; + procedure drop_watch_config( + enable : in std_logic; + src : in std_logic_vector(3 downto 0); + pulse_witdth : in natural; + signal mm_s : in mm_s_rec_t; + signal mm_m : out mm_m_rec_t) is + + variable data : std_logic_vector(31 downto 0); + + begin + + -- configure the drop-watch + data := std_logic_vector(to_unsigned(pulse_witdth, 16)) & X"000" & src; + fpm_reg_write(FP_CTRL_ID, work.fire_pulse_ctrl_5_pkg.DW_CFG_REG, data, mm_s, mm_m); + + -- Enable/disable the drop-watch + fpm_reg_read(FP_CTRL_ID, work.fire_pulse_ctrl_5_pkg.SRC_SEL_REG, data, mm_s, mm_m); + data(3) := enable; + fpm_reg_write(FP_CTRL_ID, work.fire_pulse_ctrl_5_pkg.SRC_SEL_REG, data, mm_s, mm_m); + + if(enable = '1') then + log("Drop-Watch output enable on channel " & to_string(to_integer(unsigned(src))) & ".", VMEDIUM, true); + else + log("Drop-Watch output disabled.", VMEDIUM, true); + end if; + + end procedure drop_watch_config; + ----------------------------------------------------------------------------- -- ENC/PD Emulator Configuration ----------------------------------------------------------------------------- From 491d84fc17fe2ea03efd1618fd4c6aeaa31afd7f Mon Sep 17 00:00:00 2001 From: gianmarcogirau Date: Mon, 20 Jan 2020 16:44:16 +0000 Subject: [PATCH 12/15] CORE-73 CORE-80 - Restructured the logic for SEB-EPD LEDs --- generic_ip/ems/0/doc/ems_0.json | 2 +- .../encoder_multiply/0/src/lut_divider_0.vhd | 37 +- .../fire_pulse_manager/5/doc/fpm_ctrl_5.json | 83 ++- .../fire_pulse_manager/5/sim/sim_led.do | 49 ++ .../fire_pulse_manager/5/sim/wave_led.do | 105 +++ .../5/src/fire_pulse_ctrl_5.vhd | 8 +- .../5/src/fire_pulse_ctrl_5_pkg.vhd | 35 +- .../5/src/fire_pulse_manager_5.vhd | 50 +- .../5/src/seb_epd_led_gen_5.vhd | 326 ++++----- .../fire_pulse_manager/5/src/test/led_tb.vhd | 633 ++++++++++++++++++ 10 files changed, 1027 insertions(+), 301 deletions(-) create mode 100644 generic_ip/fire_pulse_manager/5/sim/sim_led.do create mode 100644 generic_ip/fire_pulse_manager/5/sim/wave_led.do create mode 100644 generic_ip/fire_pulse_manager/5/src/test/led_tb.vhd diff --git a/generic_ip/ems/0/doc/ems_0.json b/generic_ip/ems/0/doc/ems_0.json index fec47d5..952bf39 100644 --- a/generic_ip/ems/0/doc/ems_0.json +++ b/generic_ip/ems/0/doc/ems_0.json @@ -99,7 +99,7 @@ "type" : "w", "bit_len" : "3", "reset" : "0x0", - "description" : "PD source selection" + "description" : "PD source selection: Bit-0: 0 => RS422, 1 => Single-Ended. Bit-1: 1 => Exclude Harware PDs. Bit-2: 0 => In single-ended mode use PNP, 1 => In single-ended mode use NPN" }, "enc_ph1_en" : { "type" : "w", diff --git a/generic_ip/encoder_multiply/0/src/lut_divider_0.vhd b/generic_ip/encoder_multiply/0/src/lut_divider_0.vhd index 59cb22b..dd19d35 100644 --- a/generic_ip/encoder_multiply/0/src/lut_divider_0.vhd +++ b/generic_ip/encoder_multiply/0/src/lut_divider_0.vhd @@ -6,7 +6,7 @@ -- Author : Gianmarco Girau -- Company : Global Inkjet Systems -- Created : 2019-04-17 --- Last update: 2019-04-17 +-- Last update: 2020-01-17 -- SVN ID : Git -- Standard : VHDL'2008 ------------------------------------------------------------------------------- @@ -72,41 +72,6 @@ architecture rtl of lut_divider_0 is X"011A7B96", X"01194538", X"01181181", X"0116E068", X"0115B1E5", X"011485F0", X"01135C81", X"0112358E", X"01111111", X"010FEF01", X"010ECF56", X"010DB20A", X"010C9714", X"010B7E6E", X"010A6810", X"010953F3", X"01084210", X"01073260", X"010624DD", X"0105197F", X"01041041", X"0103091B", X"01020408", X"01010101"); -/* - X"FFFFFFFF", X"7FFFFFFF", X"55555555", X"3FFFFFFF", X"33333333", X"2AAAAAAA", X"24924924", X"1FFFFFFF", - X"1C71C71C", X"19999999", X"1745D174", X"15555555", X"13B13B13", X"12492492", X"11111111", X"0FFFFFFF", - X"0F0F0F0F", X"0E38E38E", X"0D79435E", X"0CCCCCCC", X"0C30C30C", X"0BA2E8BA", X"0B21642C", X"0AAAAAAA", - X"0A3D70A3", X"09D89D89", X"097B425E", X"09249249", X"08D3DCB0", X"08888888", X"08421084", X"07FFFFFF", - X"07C1F07C", X"07878787", X"07507507", X"071C71C7", X"06EB3E45", X"06BCA1AF", X"06906906", X"06666666", - X"063E7063", X"06186186", X"05F417D0", X"05D1745D", X"05B05B05", X"0590B216", X"0572620A", X"05555555", - X"05397829", X"051EB851", X"05050505", X"04EC4EC4", X"04D4873E", X"04BDA12F", X"04A7904A", X"04924924", - X"047DC11F", X"0469EE58", X"0456C797", X"04444444", X"04325C53", X"04210842", X"04104104", X"03FFFFFF", - X"03F03F03", X"03E0F83E", X"03D22635", X"03C3C3C3", X"03B5CC0E", X"03A83A83", X"039B0AD1", X"038E38E3", - X"0381C0E0", X"03759F22", X"0369D036", X"035E50D7", X"03531DEC", X"03483483", X"033D91D2", X"03333333", - X"0329161F", X"031F3831", X"03159721", X"030C30C3", X"03030303", X"02FA0BE8", X"02F14990", X"02E8BA2E", - X"02E05C0B", X"02D82D82", X"02D02D02", X"02C8590B", X"02C0B02C", X"02B93105", X"02B1DA46", X"02AAAAAA", - X"02A3A0FD", X"029CBC14", X"0295FAD4", X"028F5C28", X"0288DF0C", X"02828282", X"027C4597", X"02762762", - X"02702702", X"026A439F", X"02647C69", X"025ED097", X"02593F69", X"0253C825", X"024E6A17", X"02492492", - X"0243F6F0", X"023EE08F", X"0239E0D5", X"0234F72C", X"02302302", X"022B63CB", X"0226B902", X"02222222", - X"021D9EAD", X"02192E29", X"0214D021", X"02108421", X"020C49BA", X"02082082", X"02040810", X"01FFFFFF", - X"01FC07F0", X"01F81F81", X"01F44659", X"01F07C1F", X"01ECC07B", X"01E9131A", X"01E573AC", X"01E1E1E1", - X"01DE5D6E", X"01DAE607", X"01D77B65", X"01D41D41", X"01D0CB58", X"01CD8568", X"01CA4B30", X"01C71C71", - X"01C3F8F0", X"01C0E070", X"01BDD2B8", X"01BACF91", X"01B7D6C3", X"01B4E81B", X"01B20364", X"01AF286B", - X"01AC5701", X"01A98EF6", X"01A6D01A", X"01A41A41", X"01A16D3F", X"019EC8E9", X"019C2D14", X"01999999", - X"01970E4F", X"01948B0F", X"01920FB4", X"018F9C18", X"018D3018", X"018ACB90", X"01886E5F", X"01861861", - X"0183C977", X"01818181", X"017F405F", X"017D05F4", X"017AD220", X"0178A4C8", X"01767DCE", X"01745D17", - X"01724287", X"01702E05", X"016E1F76", X"016C16C1", X"016A13CD", X"01681681", X"01661EC6", X"01642C85", - X"01623FA7", X"01605816", X"015E75BB", X"015C9882", X"015AC056", X"0158ED23", X"01571ED3", X"01555555", - X"01539094", X"0151D07E", X"01501501", X"014E5E0A", X"014CAB88", X"014AFD6A", X"0149539E", X"0147AE14", - X"01460CBC", X"01446F86", X"0142D662", X"01414141", X"013FB013", X"013E22CB", X"013C995A", X"013B13B1", - X"013991C2", X"01381381", X"013698DF", X"013521CF", X"0133AE45", X"01323E34", X"0130D190", X"012F684B", - X"012E025C", X"012C9FB4", X"012B404A", X"0129E412", X"01288B01", X"0127350B", X"0125E227", X"01249249", - X"01234567", X"0121FB78", X"0120B470", X"011F7047", X"011E2EF3", X"011CF06A", X"011BB4A4", X"011A7B96", - X"01194538", X"01181181", X"0116E068", X"0115B1E5", X"011485F0", X"01135C81", X"0112358E", X"01111111", - X"010FEF01", X"010ECF56", X"010DB20A", X"010C9714", X"010B7E6E", X"010A6810", X"010953F3", X"01084210", - X"01073260", X"010624DD", X"0105197F", X"01041041", X"0103091B", X"01020408", X"01010101", X"00FFFFFF"); -*/ - signal addr : std_logic_vector( 7 downto 0); signal lut_q : std_logic_vector(31 downto 0); diff --git a/generic_ip/fire_pulse_manager/5/doc/fpm_ctrl_5.json b/generic_ip/fire_pulse_manager/5/doc/fpm_ctrl_5.json index ab2cafe..64c2b00 100644 --- a/generic_ip/fire_pulse_manager/5/doc/fpm_ctrl_5.json +++ b/generic_ip/fire_pulse_manager/5/doc/fpm_ctrl_5.json @@ -53,8 +53,63 @@ } } }, - "fpm_init": { + "fpm_config": { "address": "2", + "width": "11", + "description": "Configuration values for the FPM", + "fields": { + "ch_num" : { + "type" : "r", + "bit_len" : "4", + "reset" : "0", + "description" : "Number of channels" + }, + "seb_epd_logic_present" : { + "type" : "r", + "bit_len" : "1", + "reset" : "0", + "description" : "0 => SEB-EPD logic not present, 1 => SEB-EPD logic present" + }, + "smb_diagnostic_present" : { + "type" : "r", + "bit_len" : "1", + "reset" : "0", + "description" : "0 => SMB diagnostic block not present, 1 => SMB diagnostic block present" + }, + "event_logger_present" : { + "type" : "r", + "bit_len" : "1", + "reset" : "0", + "description" : "0 => Event Logger block not present, 1 => Event Logger block present" + }, + "pof_protocol_version" : { + "type" : "r", + "bit_len" : "1", + "reset" : "0", + "description" : "0 => Support POF protocol version 0, 1 => Support POF protocol version 1" + }, + "delay_equalization_enable" : { + "type" : "r", + "bit_len" : "1", + "reset" : "0", + "description" : "0 => No support for delay equalization, 1 => Support for delay equalization" + }, + "tof_comp_enable" : { + "type" : "r", + "bit_len" : "1", + "reset" : "0", + "description" : "0 => No support for Time-of-Flight compensation, 1 => Support for Time-of-Flight compensation" + }, + "pixel_pitch_corr_enable" : { + "type" : "r", + "bit_len" : "1", + "reset" : "0", + "description" : "0 => No support for pixel-pitch correction, 1 => Support for pixel-pitch correction" + } + } + }, + "fpm_init": { + "address": "3", "width": "2", "description": "Controls signal selection", "fields": { @@ -73,7 +128,7 @@ } }, "Signal selection": { - "address": "3", + "address": "4", "width": "4", "description": "Controls signal selection", "fields": { @@ -104,7 +159,7 @@ } }, "pof_receiver_control": { - "address": "4", + "address": "5", "width": "8", "description": "Controls POF receiver", "fields": { @@ -141,7 +196,7 @@ } }, "monitoring_point_selection": { - "address": "5", + "address": "6", "width": "16", "description": "Selects monitoring points for external header", "fields": { @@ -173,13 +228,13 @@ }, "coarse_time_init": { "type": "w", - "address": "6", + "address": "7", "reset": "0x00000000", "width": "32", "description": "Defines coarse time counter value" }, "fine_time_init": { - "address": "7", + "address": "8", "width": "29", "description": "Fine time counter value/Load counter enable", "fields": { @@ -199,20 +254,20 @@ }, "fine_time_status": { "type": "r", - "address": "8", + "address": "9", "reset": "0x0000000", "width": "28", "description": "Current fine time counter value" }, "coarse_time_status": { "type": "r", - "address": "9", + "address": "10", "reset": "0x00000000", "width": "32", "description": "Current coarse time counter value" }, "pof_rx_status": { - "address": "10", + "address": "11", "width": "32", "description": "Status of POF receiver", "fields": { @@ -231,7 +286,7 @@ } }, "pof_rx_control": { - "address": "11", + "address": "12", "width": "12", "description": "POF receiver error control", "fields": { @@ -268,7 +323,7 @@ } }, "fpm_interrupt": { - "address": "12", + "address": "13", "width": "16", "description": "Interrupt control", "fields": { @@ -319,7 +374,7 @@ } }, "fpm_ext_ctrl": { - "address": "13", + "address": "14", "width": "32", "description": "Controls regeneration of external fire pulses", "fields": { @@ -338,7 +393,7 @@ } }, "drop_watch_config": { - "address": "14", + "address": "15", "width": "32", "description": "Drop-Watch configuration", "fields": { @@ -362,7 +417,7 @@ } }, "seb_epd_led_status": { - "address": "15", + "address": "16", "width": "12", "description": "SEB-EPD LED status", "fields": { diff --git a/generic_ip/fire_pulse_manager/5/sim/sim_led.do b/generic_ip/fire_pulse_manager/5/sim/sim_led.do new file mode 100644 index 0000000..09edd97 --- /dev/null +++ b/generic_ip/fire_pulse_manager/5/sim/sim_led.do @@ -0,0 +1,49 @@ +# Simulation macro + +#.main clear + +set OSVVM_PATH ../../../common/0/src/test/OSVVM +set COMMON_PATH ../../../common/0/src + +set WORKLIB work + +vlib ./work +vmap work ./work + +# Compile the UUT +vcom -2008 -work $WORKLIB ../src/seb_epd_led_gen_5.vhd + +# 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 support files +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 + +# Compile the testbench +vcom -2008 -work $WORKLIB ./../src/test/led_tb.vhd + +vsim -t ps work.led_tb + + +#add wave /led_tb/* +#add wave /led_tb/iUUT/* + +# remove warnings from standard numeric/arithmetic packages (speed-up simulation) +set StdArithNoWarnings 1 +set NumericStdNoWarnings 1 + +do wave_led.do + +when -label end_of_simulation {test_completed == true} {echo "Simulation Completed"; stop ;} +run -all + +#run 200 us; \ No newline at end of file diff --git a/generic_ip/fire_pulse_manager/5/sim/wave_led.do b/generic_ip/fire_pulse_manager/5/sim/wave_led.do new file mode 100644 index 0000000..5becfdc --- /dev/null +++ b/generic_ip/fire_pulse_manager/5/sim/wave_led.do @@ -0,0 +1,105 @@ +onerror {resume} +quietly WaveActivateNextPane {} 0 +add wave -noupdate /led_tb/reset_n +add wave -noupdate /led_tb/clk +add wave -noupdate /led_tb/init +add wave -noupdate /led_tb/pd +add wave -noupdate /led_tb/enc_p1 +add wave -noupdate /led_tb/enc_p2 +add wave -noupdate /led_tb/pof +add wave -noupdate /led_tb/all_ok +add wave -noupdate /led_tb/led_pd_g +add wave -noupdate /led_tb/led_pd_y +add wave -noupdate /led_tb/led_pd_r +add wave -noupdate /led_tb/led_enc_p1_g +add wave -noupdate /led_tb/led_enc_p1_y +add wave -noupdate /led_tb/led_enc_p1_r +add wave -noupdate /led_tb/led_enc_p2_g +add wave -noupdate /led_tb/led_enc_p2_y +add wave -noupdate /led_tb/led_enc_p2_r +add wave -noupdate /led_tb/led_pof_g +add wave -noupdate /led_tb/led_pof_y +add wave -noupdate /led_tb/led_pof_r +add wave -noupdate /led_tb/setup +add wave -noupdate /led_tb/running +add wave -noupdate /led_tb/passed +add wave -noupdate /led_tb/failed +add wave -noupdate /led_tb/test_timeout +add wave -noupdate /led_tb/test_completed +add wave -noupdate /led_tb/error_flag +add wave -noupdate /led_tb/iUUT/reset_n +add wave -noupdate /led_tb/iUUT/clk +add wave -noupdate /led_tb/iUUT/init +add wave -noupdate /led_tb/iUUT/pd +add wave -noupdate /led_tb/iUUT/enc_p1 +add wave -noupdate /led_tb/iUUT/enc_p2 +add wave -noupdate /led_tb/iUUT/pof +add wave -noupdate /led_tb/iUUT/all_ok +add wave -noupdate /led_tb/iUUT/led_pd_g +add wave -noupdate /led_tb/iUUT/led_pd_y +add wave -noupdate /led_tb/iUUT/led_pd_r +add wave -noupdate /led_tb/iUUT/led_enc_p1_g +add wave -noupdate /led_tb/iUUT/led_enc_p1_y +add wave -noupdate /led_tb/iUUT/led_enc_p1_r +add wave -noupdate /led_tb/iUUT/led_enc_p2_g +add wave -noupdate /led_tb/iUUT/led_enc_p2_y +add wave -noupdate /led_tb/iUUT/led_enc_p2_r +add wave -noupdate /led_tb/iUUT/led_pof_g +add wave -noupdate /led_tb/iUUT/led_pof_y +add wave -noupdate /led_tb/iUUT/led_pof_r +add wave -noupdate /led_tb/iUUT/pd_d +add wave -noupdate /led_tb/iUUT/enc_p1_d +add wave -noupdate /led_tb/iUUT/enc_p2_d +add wave -noupdate /led_tb/iUUT/one_ms_pulse +add wave -noupdate /led_tb/iUUT/pd_event +add wave -noupdate /led_tb/iUUT/p1_prev_event +add wave -noupdate /led_tb/iUUT/p2_prev_event +add wave -noupdate /led_tb/iUUT/pd_cnt_zero_flag +add wave -noupdate /led_tb/iUUT/rst_pd_green +add wave -noupdate /led_tb/iUUT/pd_red +add wave -noupdate /led_tb/iUUT/pd_green +add wave -noupdate /led_tb/iUUT/p1_event +add wave -noupdate /led_tb/iUUT/p2_event +add wave -noupdate /led_tb/iUUT/p1_cnt_zero_flag +add wave -noupdate /led_tb/iUUT/p2_cnt_zero_flag +add wave -noupdate /led_tb/iUUT/rst_p1_green +add wave -noupdate /led_tb/iUUT/rst_p2_green +add wave -noupdate /led_tb/iUUT/p1_red +add wave -noupdate /led_tb/iUUT/p2_red +add wave -noupdate /led_tb/iUUT/p1_green +add wave -noupdate /led_tb/iUUT/p2_green +add wave -noupdate /led_tb/iUUT/pof_green +add wave -noupdate /led_tb/iUUT/rst_pof_green +add wave -noupdate /led_tb/iUUT/pof_d +add wave -noupdate /led_tb/iUUT/pof_event +add wave -noupdate /led_tb/iUUT/pof_cnt_zero_flag +add wave -noupdate /led_tb/iUUT/all_ok_d +add wave -noupdate /led_tb/iUUT/alert_cnt_zero_flag +add wave -noupdate /led_tb/iUUT/pd_active +add wave -noupdate /led_tb/iUUT/p1_active +add wave -noupdate /led_tb/iUUT/p2_active +add wave -noupdate /led_tb/iUUT/alert_led +add wave -noupdate -radix unsigned /led_tb/iUUT/pd_cnt +add wave -noupdate -radix unsigned /led_tb/iUUT/p1_cnt +add wave -noupdate -radix unsigned /led_tb/iUUT/p2_cnt +add wave -noupdate -radix unsigned /led_tb/iUUT/pof_cnt +add wave -noupdate -radix unsigned /led_tb/iUUT/alert_cnt +add wave -noupdate -radix unsigned /led_tb/iUUT/one_ms_cnt +TreeUpdate [SetDefaultTree] +WaveRestoreCursors {{Cursor 1} {510235000 ps} 0} +quietly wave cursor active 1 +configure wave -namecolwidth 238 +configure wave -valuecolwidth 137 +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} {16252698624 ps} diff --git a/generic_ip/fire_pulse_manager/5/src/fire_pulse_ctrl_5.vhd b/generic_ip/fire_pulse_manager/5/src/fire_pulse_ctrl_5.vhd index 7a1b075..6f138f1 100644 --- a/generic_ip/fire_pulse_manager/5/src/fire_pulse_ctrl_5.vhd +++ b/generic_ip/fire_pulse_manager/5/src/fire_pulse_ctrl_5.vhd @@ -6,7 +6,7 @@ -- Author : Gianmarco Girau -- Company : Global Inkjet Systems -- Created : 2017-09-06 --- Last update: 2020-01-16 +-- Last update: 2020-01-17 -- SVN ID : Git -- Standard : VHDL'08 ------------------------------------------------------------------------------- @@ -26,6 +26,7 @@ entity fire_pulse_ctrl_5 is port( reset_n : in std_logic; clk : in std_logic; + fpm_config : in std_logic_vector(10 downto 0); fpm_init : out std_logic; src_sel : out std_logic_vector(3 downto 0); uart_regen_bypass : out std_logic; @@ -50,7 +51,7 @@ entity fire_pulse_ctrl_5 is -- Interrupt Senders ins_fpm_irq_0 : out std_logic; -- Avalon MM Interface - avs_address : in std_logic_vector(3 downto 0); + avs_address : in std_logic_vector(4 downto 0); avs_write : in std_logic; avs_writedata : in std_logic_vector(31 downto 0); avs_read : in std_logic; @@ -264,6 +265,9 @@ begin avs_readdata <= CSR_IP_ID; when CSR_IP_VER_REG => avs_readdata <= CSR_IP_VER; + when FPM_CONFIG_REG => + avs_readdata(fpm_config'range) <= fpm_config; + avs_readdata(31 downto fpm_config'length) <= (others => '0'); when FPM_INIT_REG => avs_readdata <= (0 => fpm_init_start, 1 => fpm_init_done_flag, others => '0'); when SRC_SEL_REG => diff --git a/generic_ip/fire_pulse_manager/5/src/fire_pulse_ctrl_5_pkg.vhd b/generic_ip/fire_pulse_manager/5/src/fire_pulse_ctrl_5_pkg.vhd index 839f1c1..e71acf8 100644 --- a/generic_ip/fire_pulse_manager/5/src/fire_pulse_ctrl_5_pkg.vhd +++ b/generic_ip/fire_pulse_manager/5/src/fire_pulse_ctrl_5_pkg.vhd @@ -6,7 +6,7 @@ -- Author : GMG -- Company : Global Inkjet Systems -- Created : 2018-05-24 --- Last update: 2020-01-16 +-- Last update: 2020-01-17 -- SVN ID : Git -- Standard : VHDL'2008 ------------------------------------------------------------------------------- @@ -21,21 +21,22 @@ use ieee.numeric_std.all; package fire_pulse_ctrl_5_pkg is - constant CSR_IP_ID_REG : std_logic_vector(3 downto 0) := X"0"; - constant CSR_IP_VER_REG : std_logic_vector(3 downto 0) := X"1"; - constant FPM_INIT_REG : std_logic_vector(3 downto 0) := X"2"; - constant SRC_SEL_REG : std_logic_vector(3 downto 0) := X"3"; - constant POF_RX_CTRL : std_logic_vector(3 downto 0) := X"4"; - constant MON_PT_CTRL_REG : std_logic_vector(3 downto 0) := X"5"; - constant COARSE_TIME_INIT_REG : std_logic_vector(3 downto 0) := X"6"; - constant FINE_TIME_INIT_REG : std_logic_vector(3 downto 0) := X"7"; - constant FINE_TIME_REG : std_logic_vector(3 downto 0) := X"8"; - constant COARSE_TIME_REG : std_logic_vector(3 downto 0) := X"9"; - constant RX_ERROR_STATUS : std_logic_vector(3 downto 0) := X"A"; - constant RX_ERROR_CSR : std_logic_vector(3 downto 0) := X"B"; - constant IRQ_MNG_REG : std_logic_vector(3 downto 0) := X"C"; - constant EXT_FP_CTRL_REG : std_logic_vector(3 downto 0) := X"D"; - constant DW_CFG_REG : std_logic_vector(3 downto 0) := X"E"; - constant LED_STATUS_REG : std_logic_vector(3 downto 0) := X"F"; + constant CSR_IP_ID_REG : std_logic_vector(4 downto 0) := 5x"00"; + constant CSR_IP_VER_REG : std_logic_vector(4 downto 0) := 5x"01"; + constant FPM_CONFIG_REG : std_logic_vector(4 downto 0) := 5x"02"; + constant FPM_INIT_REG : std_logic_vector(4 downto 0) := 5x"03"; + constant SRC_SEL_REG : std_logic_vector(4 downto 0) := 5x"04"; + constant POF_RX_CTRL : std_logic_vector(4 downto 0) := 5x"05"; + constant MON_PT_CTRL_REG : std_logic_vector(4 downto 0) := 5x"06"; + constant COARSE_TIME_INIT_REG : std_logic_vector(4 downto 0) := 5x"07"; + constant FINE_TIME_INIT_REG : std_logic_vector(4 downto 0) := 5x"08"; + constant FINE_TIME_REG : std_logic_vector(4 downto 0) := 5x"09"; + constant COARSE_TIME_REG : std_logic_vector(4 downto 0) := 5x"0A"; + constant RX_ERROR_STATUS : std_logic_vector(4 downto 0) := 5x"0B"; + constant RX_ERROR_CSR : std_logic_vector(4 downto 0) := 5x"0C"; + constant IRQ_MNG_REG : std_logic_vector(4 downto 0) := 5x"0D"; + constant EXT_FP_CTRL_REG : std_logic_vector(4 downto 0) := 5x"0E"; + constant DW_CFG_REG : std_logic_vector(4 downto 0) := 5x"0F"; + constant LED_STATUS_REG : std_logic_vector(4 downto 0) := 5x"10"; end package fire_pulse_ctrl_5_pkg; diff --git a/generic_ip/fire_pulse_manager/5/src/fire_pulse_manager_5.vhd b/generic_ip/fire_pulse_manager/5/src/fire_pulse_manager_5.vhd index 73e0550..1343c04 100644 --- a/generic_ip/fire_pulse_manager/5/src/fire_pulse_manager_5.vhd +++ b/generic_ip/fire_pulse_manager/5/src/fire_pulse_manager_5.vhd @@ -6,7 +6,7 @@ -- Author : Gianmarco Girau -- Company : Global Inkjet Systems -- Created : 2017-09-06 --- Last update: 2020-01-16 +-- Last update: 2020-01-17 -- SVN ID : Git -- Standard : VHDL'08 ------------------------------------------------------------------------------- @@ -26,7 +26,7 @@ use work.fire_pulse_5_pkg.all; entity fire_pulse_manager_5 is generic ( SEB_EPD_MODE : boolean := false; -- Support SEB-EPD - CH_NUM : integer := 4; -- number of Pulse-Generator blocks + CH_NUM : integer range 1 to 15 := 4; -- number of Pulse-Generator blocks PD_QUEUE_SIZE : natural := 512; ADD_SMB_DIAG : boolean := false; -- Instantiate SMB Diagnostic block ADD_EVENT_LOGGER : boolean := false; -- Instantiate Event-Logger block @@ -36,7 +36,6 @@ entity fire_pulse_manager_5 is PULSE_DELAY_EQUAL_EN : boolean := false; TOF_COMP_EN : boolean := false; PIXEL_PITCH_CORR_EN : boolean := false; - DW_GEN_EN : boolean := false; OUT_PULSE_CONDITION : boolean := true); port( reset_n : in std_logic; @@ -214,6 +213,8 @@ architecture rtl of fire_pulse_manager_5 is signal led_pof_y : std_logic; signal led_pof_r : std_logic; signal led_status : std_logic_vector(11 downto 0); + -- + signal fpm_generic_status : std_logic_vector(10 downto 0); begin @@ -299,6 +300,7 @@ begin port map( reset_n => reset_n_i, clk => clk, + fpm_config => fpm_generic_status, fpm_init => fpm_init, src_sel => src_sel, uart_regen_bypass => uart_regen_bypass, @@ -321,13 +323,24 @@ begin dw_pulse_width => dw_pulse_width, led_status => led_status, ins_fpm_irq_0 => ins_fpm_irq_0, - avs_address => cs_addr(3 downto 0), + avs_address => cs_addr(4 downto 0), avs_write => cs_ctrl_write_en, avs_writedata => cs_write_data, avs_read => cs_ctrl_read_en, avs_readdatavalid => cs_ctrl_read_valid, avs_readdata => cs_ctrl_read_data); + fpm_generic_status( 3 downto 0) <= std_logic_vector(to_unsigned(CH_NUM, 4)); + fpm_generic_status(4) <= '1' when SEB_EPD_MODE = true else '0'; + fpm_generic_status(5) <= '1' when ADD_SMB_DIAG = true else '0'; + fpm_generic_status(6) <= '1' when ADD_EVENT_LOGGER = true else '0'; + fpm_generic_status(7) <= '1' when POF_PROT_VER = 1 else '0'; + fpm_generic_status(8) <= '1' when PULSE_DELAY_EQUAL_EN = true else '0'; + fpm_generic_status(9) <= '1' when TOF_COMP_EN = true else '0'; + fpm_generic_status(10) <= '1' when PIXEL_PITCH_CORR_EN = true else '0'; + + + ----------------------------------------------------------------------------- -- I/Os selection @@ -684,30 +697,11 @@ begin reset_n => reset_n, clk => clk, init => init, - ld_pd_max_t => '0', - ld_pd_end_g_t => '0', - ld_enc_max_t => '0', - ld_enc_end_g_t => '0', - ld_pof_g_t => '0', - timing_value => (others => '0'), - host_pwr_is_up => '1', - p_good => '1', - p_in_good => '1', - p_host_good => '1', - pg_iso_5v => '1', - pg_iso_12v => '1', - rs422_pd => ems_filt_pd, - rs422_p1 => ems_filt_p1, - rs422_p2 => ems_filt_p2, - ttl_pd => '0', - ttl_pd_npn => '0', - ttl_p1 => '0', - ttl_p2 => '0', - pof_out => pof_rx, - smb_ok => '1', - led_pwr_g => open, - led_pwr_y => open, - led_pwr_r => open, + pd => ems_filt_pd, + enc_p1 => ems_filt_p1, + enc_p2 => ems_filt_p2, + pof => pof_rx, + all_ok => '1', led_pd_g => led_pd_g, led_pd_y => led_pd_y, led_pd_r => led_pd_r, diff --git a/generic_ip/fire_pulse_manager/5/src/seb_epd_led_gen_5.vhd b/generic_ip/fire_pulse_manager/5/src/seb_epd_led_gen_5.vhd index 5c6d888..2be8d6c 100644 --- a/generic_ip/fire_pulse_manager/5/src/seb_epd_led_gen_5.vhd +++ b/generic_ip/fire_pulse_manager/5/src/seb_epd_led_gen_5.vhd @@ -6,7 +6,7 @@ -- Author : Gianmarco Girau -- Company : Global Inkjet Systems -- Created : 2018-08-06 --- Last update: 2020-01-16 +-- Last update: 2020-01-20 -- SVN ID : Git -- Standard : VHDL'08 ------------------------------------------------------------------------------- @@ -21,37 +21,21 @@ use ieee.std_logic_1164.all; use ieee.numeric_std.all; entity seb_epd_led_gen_5 is + generic( + MAX_PERIOD_MS : natural := 1000; + GREEN_PERIOD_MS : natural := 200); port( reset_n : in std_logic; clk : in std_logic; -- config init : in std_logic; - ld_pd_max_t : in std_logic; - ld_pd_end_g_t : in std_logic; - ld_enc_max_t : in std_logic; - ld_enc_end_g_t : in std_logic; - ld_pof_g_t : in std_logic; - timing_value : in std_logic_vector(31 downto 0); -- input status signals - host_pwr_is_up : in std_logic; - p_good : in std_logic; - p_in_good : in std_logic; - p_host_good : in std_logic; - pg_iso_5v : in std_logic; - pg_iso_12v : in std_logic; - rs422_pd : in std_logic; - rs422_p1 : in std_logic; - rs422_p2 : in std_logic; - ttl_pd : in std_logic; - ttl_pd_npn : in std_logic; - ttl_p1 : in std_logic; - ttl_p2 : in std_logic; - pof_out : in std_logic; - smb_ok : in std_logic; + pd : in std_logic; + enc_p1 : in std_logic; + enc_p2 : in std_logic; + pof : in std_logic; + all_ok : in std_logic; -- LEDs outputs values - led_pwr_g : out std_logic; - led_pwr_y : out std_logic; - led_pwr_r : out std_logic; led_pd_g : out std_logic; led_pd_y : out std_logic; led_pd_r : out std_logic; @@ -68,114 +52,75 @@ end entity seb_epd_led_gen_5; architecture rtl of seb_epd_led_gen_5 is - signal power_good, rs422_pd_i, ttl_pd_i, ttl_npn_pd_i : std_logic; - signal rs422_pd_d, ttl_pd_d, ttl_npn_pd_d : std_logic; + constant END_GREEN_PERIOD_MS : natural := MAX_PERIOD_MS - GREEN_PERIOD_MS; + + signal pd_d, enc_p1_d, enc_p2_d, one_ms_pulse : std_logic; + signal p1_prev_event, p2_prev_event : std_logic; signal pd_cnt_zero_flag, rst_pd_green, pd_red, pd_green : std_logic; - signal rs422_p1_i, rs422_p2_i, ttl_p1_i, ttl_p2_i : std_logic; - signal rs422_p1_d, rs422_p2_d, ttl_p1_d, ttl_p2_d : std_logic; - signal rs422_p1_event, rs422_p2_event, p1_cnt_zero_flag : std_logic; - signal ttl_p1_event, ttl_p2_event, p2_cnt_zero_flag : std_logic; + signal p1_event, p2_event, p1_cnt_zero_flag : std_logic; + signal p2_cnt_zero_flag, pd_event, rst_pof_green : std_logic; signal rst_p1_green, rst_p2_green, p1_red, p2_red : std_logic; - signal p1_green, p2_green, pof_green, pof_out_d : std_logic; - signal pof_event, pof_cnt_zero_flag, pd_multiple_event : std_logic; - signal smb_ok_d, alert_cnt_zero_flag : std_logic; + signal p1_green, p2_green, pof_green, pof_d : std_logic; + signal pof_event, pof_cnt_zero_flag, pof_active : std_logic; + signal all_ok_d, alert_cnt_zero_flag : std_logic; signal pd_active, p1_active, p2_active : std_logic; -- - signal p1_event, p2_event : std_logic_vector( 1 downto 0); - signal p1_prev_event, p2_prev_event : std_logic_vector( 1 downto 0); - signal pd_event, pd_previous_event : std_logic_vector( 2 downto 0); signal alert_led : std_logic_vector( 3 downto 0); - signal pd_max_period, pd_end_green_t, pd_cnt : std_logic_vector(29 downto 0); - signal enc_max_period, enc_end_green_t : std_logic_vector(29 downto 0); - signal pof_green_t : std_logic_vector(29 downto 0); - signal p1_cnt, p2_cnt, pof_cnt, alert_cnt : std_logic_vector(29 downto 0); + signal pd_cnt, pof_cnt : std_logic_vector( 9 downto 0); + signal p1_cnt, p2_cnt, alert_cnt : std_logic_vector( 9 downto 0); + signal one_ms_cnt : std_logic_vector(16 downto 0); begin - ----------------------------------------------------------------------------- - -- Power LED - ----------------------------------------------------------------------------- - - power_good <= '0' when p_good = '0' or p_in_good = '0' or p_host_good = '0' or pg_iso_12v = '0' or pg_iso_5v = '0' else '1'; - - led_pwr_r <= '1' when power_good = '0' and host_pwr_is_up = '1' else '0'; - - led_pwr_y <= '1' when host_pwr_is_up = '0' else '0'; - - led_pwr_g <= '1' when power_good = '1' and host_pwr_is_up = '1' else '0'; + pGEN_1MS_PULSE : process(reset_n, clk) + begin + if(reset_n = '0') then + one_ms_pulse <= '0'; + one_ms_cnt <= (others => '0'); + elsif(clk = '1' and clk'event) then + if(unsigned(one_ms_cnt) = 100000-1) then + one_ms_pulse <= '1'; + one_ms_cnt <= (others => '0'); + else + one_ms_pulse <= '0'; + one_ms_cnt <= std_logic_vector(unsigned(one_ms_cnt)+1); + end if; + end if; + end process pGEN_1MS_PULSE; ----------------------------------------------------------------------------- -- PD LEDs ----------------------------------------------------------------------------- - -- synchronize to the local clock and generate a pulse on the rising edge - iRS422_PD_SYNC: entity work.sync_wire - generic map (rst_val => '0', sync_stages => 3) - port map (rstN => reset_n, clk => clk, async_in => rs422_pd, sync_out => rs422_pd_i); - - iTTL_PNP_PD_SYNC: entity work.sync_wire - generic map (rst_val => '0', sync_stages => 3) - port map (rstN => reset_n, clk => clk, async_in => ttl_pd, sync_out => ttl_pd_i); - - iTTL_NPN_PD_SYNC: entity work.sync_wire - generic map (rst_val => '0', sync_stages => 3) - port map (rstN => reset_n, clk => clk, async_in => ttl_pd_npn, sync_out => ttl_npn_pd_i); - - pd_event <= (ttl_npn_pd_i xor ttl_npn_pd_d) & (ttl_pd_i xor ttl_pd_d) & (rs422_pd_i xor rs422_pd_d); - pPD_LEDs : process(reset_n, clk) is begin -- process if(reset_n = '0') then - rs422_pd_d <= '0'; - ttl_pd_d <= '0'; - ttl_npn_pd_d <= '0'; - pd_previous_event <= "000"; - pd_max_period <= std_logic_vector(to_unsigned(100000000-1, 30)); - pd_end_green_t <= std_logic_vector(to_unsigned( 50000000-1, 30)); + pd_d <= '0'; + pd_event <= '0'; pd_cnt <= (others => '0'); - pd_previous_event <= "000"; - pd_red <= '0'; pd_green <= '0'; - led_pd_r <= '0'; led_pd_y <= '0'; led_pd_g <= '0'; pd_active <= '0'; elsif(clk = '1' and clk'event) then - rs422_pd_d <= rs422_pd_i; - ttl_pd_d <= ttl_pd_i; - ttl_npn_pd_d <= ttl_npn_pd_i; - if(ld_pd_max_t = '1') then - pd_max_period <= timing_value(pd_max_period'range); - end if; - if(ld_pd_end_g_t = '1') then - pd_end_green_t <= timing_value(pd_end_green_t'range); - end if; - if(init = '1' or (pd_cnt_zero_flag = '1' and pd_event = "000")) then - pd_previous_event <= "000"; - elsif(pd_event /= "000") then - pd_previous_event <= pd_event; - end if; + pd_d <= pd; + pd_event <= pd xor pd_d; if(init = '1') then pd_cnt <= (others => '0'); - elsif(pd_event /= "000" and pd_red = '0') then - pd_cnt <= pd_max_period; - elsif(pd_cnt_zero_flag = '0') then + elsif(pd_event = '1') then + pd_cnt <= std_logic_vector(to_unsigned(MAX_PERIOD_MS, pd_cnt'length)); + elsif(pd_cnt_zero_flag = '0' and one_ms_pulse = '1') then pd_cnt <= std_logic_vector(unsigned(pd_cnt)-1); end if; - if(init = '1' or (pd_cnt_zero_flag = '1' and pd_event = "000")) then - pd_red <= '0'; - elsif((pd_event /= "000" and pd_previous_event /= "000" and pd_event /= pd_previous_event) or pd_multiple_event = '1') then - pd_red <= '1'; - end if; - if(pd_red = '1' or rst_pd_green = '1' or init = '1') then - pd_green <= '0'; - elsif(pd_event = "001" or pd_event = "010" or pd_event = "100") then + if(pd_event = '1') then pd_green <= '1'; + elsif(rst_pd_green = '1' or init = '1') then + pd_green <= '0'; end if; - led_pd_r <= smb_ok and power_good and pd_red; - led_pd_y <= (smb_ok and power_good and pd_cnt_zero_flag and pd_active) or alert_led(0); - led_pd_g <= smb_ok and power_good and pd_green; - if(pd_event(0) = '1' or pd_event(1) = '1' or pd_event(2) = '1') then + led_pd_r <= all_ok and pd_red; + led_pd_y <= (all_ok and pd_cnt_zero_flag and pd_active) or alert_led(0); + led_pd_g <= all_ok and pd_green; + if(pd_event = '1') then pd_active <= '1'; end if; end if; @@ -183,101 +128,77 @@ begin pd_cnt_zero_flag <= '1' when unsigned(pd_cnt) = 0 else '0'; - rst_pd_green <= '1' when unsigned(pd_cnt) = unsigned(pd_end_green_t) else '0'; + rst_pd_green <= '1' when one_ms_pulse = '1' and unsigned(pd_cnt) = END_GREEN_PERIOD_MS else '0'; - pd_multiple_event <= '1' when pd_event = "011" or pd_event = "101" or pd_event = "110" or pd_event = "111" else '0'; + -- PD red LED is never activated because there is only one PD source + pd_red <= '0'; ----------------------------------------------------------------------------- -- Encoder LEDs ----------------------------------------------------------------------------- - -- synchronize the signals to the local clock domain - iRS422_P1_SYNC: entity work.sync_wire - generic map (rst_val => '0', sync_stages => 3) - port map (rstN => reset_n, clk => clk, async_in => rs422_p1, sync_out => rs422_p1_i); - - iRS422_P2_SYNC: entity work.sync_wire - generic map (rst_val => '0', sync_stages => 3) - port map (rstN => reset_n, clk => clk, async_in => rs422_p2, sync_out => rs422_p2_i); - - iTTL_P1_SYNC: entity work.sync_wire - generic map (rst_val => '0', sync_stages => 3) - port map (rstN => reset_n, clk => clk, async_in => ttl_p1, sync_out => ttl_p1_i); - - iTTL_P2_SYNC: entity work.sync_wire - generic map (rst_val => '0', sync_stages => 3) - port map (rstN => reset_n, clk => clk, async_in => ttl_p2, sync_out => ttl_p2_i); - pENC_LEDs : process(reset_n, clk) begin if(reset_n = '0') then - enc_max_period <= std_logic_vector(to_unsigned(100000000-1, 30)); - enc_end_green_t <= std_logic_vector(to_unsigned( 50000000-1, 30)); - p1_cnt <= (others => '0'); - p2_cnt <= (others => '0'); - p1_red <= '0'; - p1_green <= '0'; - p2_red <= '0'; - p2_green <= '0'; - p1_prev_event <= "00"; - p2_prev_event <= "00"; + p1_cnt <= (others => '0'); + p2_cnt <= (others => '0'); + p1_red <= '0'; + p1_green <= '0'; + p2_red <= '0'; + p2_green <= '0'; + p1_prev_event <= '0'; + p2_prev_event <= '0'; p1_active <= '0'; p2_active <= '0'; elsif(clk = '1' and clk'event) then - if(ld_enc_max_t = '1') then - enc_max_period <= timing_value(enc_max_period'range); - end if; - if(ld_enc_end_g_t = '1') then - enc_end_green_t <= timing_value(enc_end_green_t'range); - end if; - if(init = '1' or (p1_cnt_zero_flag = '1' and p1_event = "00")) then - p1_prev_event <= "00"; - elsif(p1_event(0) = '1' or p1_event(1) = '1') then + if(init = '1' or (p1_cnt_zero_flag = '1' and p1_event = '0')) then + p1_prev_event <= '0'; + elsif(p1_event = '1') then p1_prev_event <= p1_event; end if; - if(init = '1' or (p2_cnt_zero_flag = '1' and p2_event = "00")) then - p2_prev_event <= "00"; - elsif(p2_event(0) = '1' or p2_event(1) = '1') then + if(init = '1' or (p2_cnt_zero_flag = '1' and p2_event = '0')) then + p2_prev_event <= '0'; + elsif(p2_event = '1') then p2_prev_event <= p2_event; end if; if(init = '1') then p1_cnt <= (others => '0'); - elsif((p1_event(0) = '1' or p1_event(1) = '1') and p1_red = '0') then - p1_cnt <= enc_max_period; - elsif(p1_cnt_zero_flag = '0') then + elsif(p1_event = '1' and p1_red = '0') then + p1_cnt <= std_logic_vector(to_unsigned(MAX_PERIOD_MS-1, p1_cnt'length)); + elsif(p1_cnt_zero_flag = '0' and one_ms_pulse = '1') then p1_cnt <= std_logic_vector(unsigned(p1_cnt)-1); end if; if(init = '1') then p2_cnt <= (others => '0'); - elsif((p2_event(0) = '1' or p2_event(1) = '1') and p2_red = '0') then - p2_cnt <= enc_max_period; - elsif(p2_cnt_zero_flag = '0') then + elsif(p2_event = '1' and p2_red = '0') then + p2_cnt <= std_logic_vector(to_unsigned(MAX_PERIOD_MS-1, p2_cnt'length)); + elsif(p2_cnt_zero_flag = '0' and one_ms_pulse = '1') then p2_cnt <= std_logic_vector(unsigned(p2_cnt)-1); end if; - if(init = '1' or (p1_cnt_zero_flag = '1' and p1_event = "00")) then + if(init = '1' or (p1_cnt_zero_flag = '1' and p1_event = '0')) then p1_red <= '0'; - elsif((p1_event(0) = '1' and ((p2_event(0) ='1' or p2_event(1) = '1') or p1_event(1) = '1' or p1_prev_event(1) = '1' or p2_prev_event(1) = '1')) or (p1_event(1) = '1' and (p1_event(0) = '1' or p1_prev_event(0) = '1' or p2_prev_event(0) = '1'))) then + elsif(p1_event = '1' and p2_event ='1') then p1_red <= '1'; end if; - if(init = '1' or (p2_cnt_zero_flag = '1' and p2_event = "00")) then + if(init = '1' or (p2_cnt_zero_flag = '1' and p2_event = '0')) then p2_red <= '0'; - elsif((p2_event(0) = '1' and ((p1_event(0) ='1' or p1_event(1) = '1') or p2_event(1) = '1' or p2_prev_event(1) = '1' or p1_prev_event(1) = '1')) or (p2_event(1) = '1' and (p2_event(0) = '1' or p2_prev_event(0) = '1' or p1_prev_event(0) = '1'))) then + elsif(p2_event = '1' and p1_event ='1') then p2_red <= '1'; end if; if(p1_red = '1' or rst_p1_green = '1' or init = '1') then p1_green <= '0'; - elsif(p1_event = "01" or p1_event = "10") then + elsif(p1_event = '1') then p1_green <= '1'; end if; if(p2_red = '1' or rst_p2_green = '1' or init = '1') then p2_green <= '0'; - elsif(p2_event = "01" or p2_event = "10") then + elsif(p2_event = '1') then p2_green <= '1'; end if; - if(p1_event(0) = '1' or p1_event(1) = '1') then + if(p1_event = '1') then p1_active <= '1'; end if; - if(p2_event(0) = '1' or p2_event(1) = '1') then + if(p2_event = '1') then p2_active <= '1'; end if; end if; @@ -286,31 +207,24 @@ begin pENC_LEDs_NR : process(clk) begin if(clk = '1' and clk'event) then - rs422_p1_d <= rs422_p1_i; - rs422_p2_d <= rs422_p2_i; - ttl_p1_d <= ttl_p1_i; - ttl_p2_d <= ttl_p2_i; - p1_event <= ttl_p1_event & rs422_p1_event; - p2_event <= ttl_p2_event & rs422_p2_event; - led_enc_p1_r <= smb_ok and power_good and p1_red; - led_enc_p1_y <= (smb_ok and power_good and p1_cnt_zero_flag and not p1_red and p1_active) or alert_led(1); - led_enc_p1_g <= smb_ok and power_good and p1_green and not p1_red; - led_enc_p2_r <= smb_ok and power_good and p2_red; - led_enc_p2_y <= (smb_ok and power_good and p2_cnt_zero_flag and not p2_red and p2_active) or alert_led(2); - led_enc_p2_g <= smb_ok and power_good and p2_green and not p2_red; + enc_p1_d <= enc_p1; + enc_p2_d <= enc_p2; + p1_event <= enc_p1 xor enc_p1_d; + p2_event <= enc_p2 xor enc_p2_d; + led_enc_p1_r <= all_ok and p1_red; + led_enc_p1_y <= (all_ok and p1_cnt_zero_flag and not p1_red and p1_active) or alert_led(1); + led_enc_p1_g <= all_ok and p1_green and not p1_red; + led_enc_p2_r <= all_ok and p2_red; + led_enc_p2_y <= (all_ok and p2_cnt_zero_flag and not p2_red and p2_active) or alert_led(2); + led_enc_p2_g <= all_ok and p2_green and not p2_red; end if; end process pENC_LEDs_NR; - rs422_p1_event <= rs422_p1_i xor rs422_p1_d; - rs422_p2_event <= rs422_p2_i xor rs422_p2_d; - ttl_p1_event <= ttl_p1_i xor ttl_p1_d; - ttl_p2_event <= ttl_p2_i xor ttl_p2_d; - p1_cnt_zero_flag <= '1' when unsigned(p1_cnt) = 0 else '0'; p2_cnt_zero_flag <= '1' when unsigned(p2_cnt) = 0 else '0'; - rst_p1_green <= '1' when unsigned(p1_cnt) = unsigned(enc_end_green_t) else '0'; - rst_p2_green <= '1' when unsigned(p2_cnt) = unsigned(enc_end_green_t) else '0'; + rst_p1_green <= '1' when unsigned(p1_cnt) = END_GREEN_PERIOD_MS-1 and one_ms_pulse = '1' else '0'; + rst_p2_green <= '1' when unsigned(p2_cnt) = END_GREEN_PERIOD_MS-1 and one_ms_pulse = '1' else '0'; ----------------------------------------------------------------------------- -- POF LEDs @@ -319,38 +233,40 @@ begin pPOF_LED : process(reset_n, clk) begin if(reset_n = '0') then - pof_green_t <= std_logic_vector(to_unsigned( 50000000-1, 30)); pof_cnt <= (others => '0'); - pof_out_d <= '0'; + pof_d <= '0'; pof_green <= '0'; led_pof_g <= '0'; + led_pof_y <= '0'; + pof_event <= '0'; + pof_active <= '0'; elsif(clk = '1' and clk'event) then - if(ld_pof_g_t = '1') then - pof_green_t <= timing_value(pof_green_t'range); - end if; - pof_out_d <= pof_out; + pof_d <= pof; + pof_event <= pof and not pof_d; if(init = '1') then pof_cnt <= (others => '0'); elsif(pof_event = '1') then - pof_cnt <= pof_green_t; - elsif(pof_cnt_zero_flag = '0') then + pof_cnt <= std_logic_vector(to_unsigned(MAX_PERIOD_MS, pof_cnt'length)); + elsif(pof_cnt_zero_flag = '0' and one_ms_pulse = '1') then pof_cnt <= std_logic_vector(unsigned(pof_cnt)-1); end if; - if(init = '1' or (pof_cnt_zero_flag = '1' and pof_event = '0')) then + if(init = '1' or (rst_pof_green = '1' and pof_event = '0')) then pof_green <= '0'; elsif(pof_event = '1') then pof_green <= '1'; end if; - led_pof_g <= smb_ok and power_good and pof_green; + led_pof_g <= all_ok and pof_green; + led_pof_y <= (all_ok and pof_cnt_zero_flag and pof_active) or alert_led(3); + if(pof_event = '1') then + pof_active <= '1'; + end if; end if; end process pPOF_LED; - -- create event only on the rising edge - pof_event <= pof_out and not pof_out_d; - pof_cnt_zero_flag <= '1' when unsigned(pof_cnt) = 0 else '0'; - led_pof_y <= alert_led(3); + rst_pof_green <= '1' when one_ms_pulse = '1' and unsigned(pof_cnt) = END_GREEN_PERIOD_MS else '0'; + led_pof_r <= '0'; @@ -358,17 +274,21 @@ begin -- Emergency Flashing ----------------------------------------------------------------------------- - -- when the smb_ctrl watchdog is triggered (smb_ok deasserted), all the LEDs, - -- apart from the power LED, needs to start flashing + -- when the smb_ctrl watchdog is triggered (all_ok deasserted), all the LEDs + -- need to start flashing - pEMERGENCY_FLASH : process(clk) + pEMERGENCY_FLASH : process(reset_n, clk) begin - if(clk = '1' and clk'event) then - smb_ok_d <= smb_ok; - if(smb_ok = '1') then + if(reset_n = '0') then + all_ok_d <= '0'; + alert_led <= "0000"; + alert_cnt <= std_logic_vector(to_unsigned(END_GREEN_PERIOD_MS-1, alert_cnt'length)); + elsif(clk = '1' and clk'event) then + all_ok_d <= all_ok; + if(all_ok = '1') then alert_led <= "0000"; - elsif(smb_ok = '0' and smb_ok_d = '1') then - alert_cnt <= std_logic_vector(to_unsigned( 50000000-1, 30)); + elsif(all_ok = '0' and all_ok_d = '1') then + alert_cnt <= std_logic_vector(to_unsigned(END_GREEN_PERIOD_MS-1, alert_cnt'length)); else if(alert_cnt_zero_flag = '1') then if(alert_led = "1111") then @@ -376,8 +296,8 @@ begin else alert_led <= alert_led(2 downto 0) & '1'; end if; - alert_cnt <= std_logic_vector(to_unsigned( 50000000-1, 30)); - else + alert_cnt <= std_logic_vector(to_unsigned(END_GREEN_PERIOD_MS-1, alert_cnt'length)); + elsif(one_ms_pulse = '1') then alert_cnt <= std_logic_vector(unsigned(alert_cnt)-1); end if; end if; diff --git a/generic_ip/fire_pulse_manager/5/src/test/led_tb.vhd b/generic_ip/fire_pulse_manager/5/src/test/led_tb.vhd new file mode 100644 index 0000000..0c3c543 --- /dev/null +++ b/generic_ip/fire_pulse_manager/5/src/test/led_tb.vhd @@ -0,0 +1,633 @@ +------------------------------------------------------------------------------- +-- Title : led_tb +-- Project : FPM +------------------------------------------------------------------------------- +-- File : led_tb.vhd +-- Author : GMG +-- Company : Global Inkjet Systems +-- Created : 2018-06-12 +-- Last update: 2020-01-20 +-- SVN ID : Git +-- Standard : VHDL'2008 +------------------------------------------------------------------------------- +-- Description: +-- Testbench for the FPM LED generator +------------------------------------------------------------------------------- + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +library work; +use work.log_pkg.all; + +entity led_tb is + -- .. +end entity led_tb; + +architecture behav of led_tb is + + constant CLK_PERIOD : time := 10 ns; + + constant CLK_FREQ : real := 100.0e6; -- target clock frequency + + -- Logging Verbosity Level + constant VERBOSITY_LEVEL : verb_level_t := VMEDIUM; + + constant MAX_SIM_TIME : time := 50.0 ms; -- Maximum simulation time + + constant MAX_PERIOD_MS : natural := 5; + constant GREEN_PERIOD_MS : natural := 2; + + constant RUN_ENC_TEST : boolean := true; + constant RUN_PD_TEST : boolean := true; + constant RUN_POF_TEST : boolean := true; + + + signal reset_n : std_logic := '0'; + signal clk : std_logic := '0'; + -- + signal init : std_logic; + signal pd : std_logic; + signal enc_p1 : std_logic; + signal enc_p2 : std_logic; + signal pof : std_logic; + signal all_ok : std_logic; + signal led_pd_g : std_logic; + signal led_pd_y : std_logic; + signal led_pd_r : std_logic; + signal led_enc_p1_g : std_logic; + signal led_enc_p1_y : std_logic; + signal led_enc_p1_r : std_logic; + signal led_enc_p2_g : std_logic; + signal led_enc_p2_y : std_logic; + signal led_enc_p2_r : std_logic; + signal led_pof_g : std_logic; + signal led_pof_y : std_logic; + signal led_pof_r : std_logic; + + -- TB specific signals + signal setup : boolean; + signal running : boolean; + signal passed : boolean := false; + signal failed : boolean := false; + signal test_timeout : boolean := false; + signal test_completed : boolean := false; + + signal error_flag : boolean; + +begin -- architecture behav + + clk <= not clk after 0.5*CLK_PERIOD; + + ----------------------------------------------------------------------------- + -- LED Generator (UUT) + ----------------------------------------------------------------------------- + + iUUT: entity work.seb_epd_led_gen_5 + generic map ( + MAX_PERIOD_MS => MAX_PERIOD_MS, + GREEN_PERIOD_MS => GREEN_PERIOD_MS) + port map ( + reset_n => reset_n, + clk => clk, + init => init, + pd => pd, + enc_p1 => enc_p1, + enc_p2 => enc_p2, + pof => pof, + all_ok => all_ok, + led_pd_g => led_pd_g, + led_pd_y => led_pd_y, + led_pd_r => led_pd_r, + led_enc_p1_g => led_enc_p1_g, + led_enc_p1_y => led_enc_p1_y, + led_enc_p1_r => led_enc_p1_r, + led_enc_p2_g => led_enc_p2_g, + led_enc_p2_y => led_enc_p2_y, + led_enc_p2_r => led_enc_p2_r, + led_pof_g => led_pof_g, + led_pof_y => led_pof_y, + led_pof_r => led_pof_r); + + + ----------------------------------------------------------------------------- + -- Testbench Logic + ----------------------------------------------------------------------------- + + pTEST_PROC : process + + begin + + --------------------------------------------------------------------------- + -- Initialize & Configure + --------------------------------------------------------------------------- + + reset_n <= '0'; + + init <= '0'; + + setup <= false; + + running <= false; + error_flag <= false; + + --Set the verbosity level for logging + set_log_verbosity(VERBOSITY_LEVEL); + + pd <= '0'; + enc_p1 <= '0'; + enc_p2 <= '0'; + pof <= '0'; + all_ok <= '0'; + + wait for 100 ns; + reset_n <= '1'; + + wait for 100 ns; + wait until clk = '1' and clk'event; + all_ok <= '1'; + + -- Nothing really to do here + setup <= true; + + --------------------------------------------------------------------------- + -- Running + --------------------------------------------------------------------------- + + running <= true; + log_separator_line(VLOW); + log("FPM (SEB-EPD) LEDs verification:", VLOW); + log_separator_line(VLOW); + + wait for 0.5 ms; + + --------------------------------------------------------------------------- + -- POF LED + --------------------------------------------------------------------------- + + if(RUN_POF_TEST = true) then + + log_separator_line(VLOW); + log("Testing POF LED:", VLOW); + wait for 5 us; + + if(led_pof_r /= '0') then + log("ERROR: POF Red LED must be LOW.", VLOW); + error_flag <= true; + end if; + if(led_pof_y /= '0') then + log("ERROR: POF Yellow LED must be LOW.", VLOW); + error_flag <= true; + end if; + if(led_pof_g /= '0') then + log("ERROR: POF Green LED must be LOW.", VLOW); + error_flag <= true; + end if; + + wait for 5 us; + wait until clk = '1' and clk'event; + pof <= not pof; + wait until clk = '1' and clk'event; + pof <= not pof; + + wait for 100 ns; + if(led_pof_g /= '1') then + log("ERROR: POF Green LED must be HIGH.", VLOW); + error_flag <= true; + end if; + if(led_pof_y /= '0') then + log("ERROR: POF Yellow LED must be LOW.", VLOW); + error_flag <= true; + end if; + + wait for 3 ms; + if(led_pof_g /= '0') then + log("ERROR: POF Green LED must be LOW.", VLOW); + error_flag <= true; + end if; + if(led_pof_y /= '0') then + log("ERROR: POF Yellow LED must be LOW.", VLOW); + error_flag <= true; + end if; + + wait for 3 ms; + if(led_pof_g /= '0') then + log("ERROR: POF Green LED must be LOW.", VLOW); + error_flag <= true; + end if; + if(led_pof_y /= '1') then + log("ERROR: POF Yellow LED must be HIGH.", VLOW); + error_flag <= true; + end if; + + wait for 5 us; + wait until clk = '1' and clk'event; + pof <= not pof; + wait until clk = '1' and clk'event; + pof <= not pof; + + wait for 100 ns; + if(led_pof_g /= '1') then + log("ERROR: POF Green LED must be HIGH.", VLOW); + error_flag <= true; + end if; + if(led_pof_y /= '0') then + log("ERROR: POF Yellow LED must be LOW.", VLOW); + error_flag <= true; + end if; + + for n in 0 to 8 loop + wait for 10 us; + wait until clk = '1' and clk'event; + pof <= not pof; + wait until clk = '1' and clk'event; + pof <= not pof; + end loop; -- n + + wait for 100 ns; + if(led_pof_g /= '1') then + log("ERROR: POF Green LED must be HIGH.", VLOW); + error_flag <= true; + end if; + if(led_pof_y /= '0') then + log("ERROR: POF Yellow LED must be LOW.", VLOW); + error_flag <= true; + end if; + + wait for 3 ms; + if(led_pof_g /= '0') then + log("ERROR: POF Green LED must be LOW.", VLOW); + error_flag <= true; + end if; + if(led_pof_y /= '0') then + log("ERROR: POF Yellow LED must be LOW.", VLOW); + error_flag <= true; + end if; + + wait for 3 ms; + if(led_pof_g /= '0') then + log("ERROR: POF Green LED must be LOW.", VLOW); + error_flag <= true; + end if; + if(led_pof_y /= '1') then + log("ERROR: POF Yellow LED must be HIGH.", VLOW); + error_flag <= true; + end if; + + wait for 50 ns; + if(error_flag = false) then + log("POF LEDs are OK.", VLOW); + end if; + + wait for 0.5 ms; + + end if; -- RUN_POF_TEST + + --------------------------------------------------------------------------- + -- PD LEDs + --------------------------------------------------------------------------- + + if(RUN_PD_TEST = true) then + + log_separator_line(VLOW); + log("Testing PD LEDs:", VLOW); + + pd <= '1'; + + wait for 100 ns; + if(led_pd_g /= '1') then + log("ERROR: PD Green LED must be HIGH.", VLOW); + error_flag <= true; + end if; + if(led_pd_y /= '0') then + log("ERROR: PD Yellow LED must be LOW.", VLOW); + error_flag <= true; + end if; + + wait for 1 us; + pd <= '0'; + wait for 1 us; + + wait for 3 ms; + if(led_pd_g /= '0') then + log("ERROR: PD Green LED must be LOW.", VLOW); + error_flag <= true; + end if; + if(led_pd_y /= '0') then + log("ERROR: PD Yellow LED must be LOW.", VLOW); + error_flag <= true; + end if; + + wait for 3 ms; + if(led_pd_g /= '0') then + log("ERROR: PD Green LED must be LOW.", VLOW); + error_flag <= true; + end if; + if(led_pd_y /= '1') then + log("ERROR: PD Yellow LED must be HIGH.", VLOW); + error_flag <= true; + end if; + + wait for 1.5 ms; + + pd <= '1'; + wait for 1 us; + pd <= '0'; + wait for 10 us; + pd <= '1'; + wait for 1 us; + pd <= '0'; + wait for 10 us; + pd <= '1'; + wait for 1 us; + pd <= '0'; + wait for 10 us; + pd <= '1'; + wait for 1 us; + pd <= '0'; + + if(led_pd_g /= '1') then + log("ERROR: PD Green LED must be HIGH.", VLOW); + error_flag <= true; + end if; + if(led_pd_y /= '0') then + log("ERROR: PD Yellow LED must be LOW.", VLOW); + error_flag <= true; + end if; + + wait for 3.0 ms; + + if(led_pd_g /= '0') then + log("ERROR: PD Green LED must be LOW.", VLOW); + error_flag <= true; + end if; + if(led_pd_y /= '0') then + log("ERROR: PD Yellow LED must be LOW.", VLOW); + error_flag <= true; + end if; + + wait for 3 ms; + if(led_pd_g /= '0') then + log("ERROR: PD Green LED must be LOW.", VLOW); + error_flag <= true; + end if; + if(led_pd_y /= '1') then + log("ERROR: PD Yellow LED must be HIGH.", VLOW); + error_flag <= true; + end if; + + wait for 50 ns; + if(error_flag = false) then + log("PD LEDs are OK.", VLOW); + end if; + + wait for 0.5 ms; + + end if; -- RUN_PD_TEST + + --------------------------------------------------------------------------- + -- Encoder LEDs + --------------------------------------------------------------------------- + + if(RUN_ENC_TEST = true) then + + log_separator_line(VLOW); + log("Testing Encoder LEDs:", VLOW); + wait for 5 us; + + if(led_enc_p1_y /= '0') then + log("ERROR: P1 Yellow LED must be LOW.", VLOW); + error_flag <= true; + end if; + + if(led_enc_p2_y /= '0') then + log("ERROR: P2 Yellow LED must be LOW.", VLOW); + error_flag <= true; + end if; + + if(led_enc_p1_g /= '0') then + log("ERROR: P1 Green LED must be LOW.", VLOW); + error_flag <= true; + end if; + + if(led_enc_p2_g /= '0') then + log("ERROR: P2 Green LED must be LOW.", VLOW); + error_flag <= true; + end if; + + if(led_enc_p1_r /= '0') then + log("ERROR: P1 Red LED must be LOW.", VLOW); + error_flag <= true; + end if; + + if(led_enc_p2_r /= '0') then + log("ERROR: P2 Red LED must be LOW.", VLOW); + error_flag <= true; + end if; + + wait for 1 us; + + enc_p1 <= '1'; + wait for 10 us; + enc_p2 <= '1'; + wait for 100 ns; + + if(led_enc_p1_g /= '1') then + log("ERROR: P1 Green LED must be HIGH.", VLOW); + error_flag <= true; + end if; + if(led_enc_p2_g /= '1') then + log("ERROR: P2 Green LED must be HIGH.", VLOW); + error_flag <= true; + end if; + if(led_enc_p1_y /= '0') then + log("ERROR: P1 Yellow LED must be LOW.", VLOW); + error_flag <= true; + end if; + if(led_enc_p2_y /= '0') then + log("ERROR: P2 Yellow LED must be LOW.", VLOW); + error_flag <= true; + end if; + + wait for 3 ms; + if(led_enc_p1_g /= '0') then + log("ERROR: P1 Green LED must be LOW.", VLOW); + error_flag <= true; + end if; + if(led_enc_p2_g /= '0') then + log("ERROR: P2 Green LED must be LOW.", VLOW); + error_flag <= true; + end if; + if(led_enc_p1_y /= '0') then + log("ERROR: P1 Yellow LED must be LOW.", VLOW); + error_flag <= true; + end if; + if(led_enc_p2_y /= '0') then + log("ERROR: P2 Yellow LED must be LOW.", VLOW); + error_flag <= true; + end if; + + wait for 3 ms; + if(led_enc_p1_g /= '0') then + log("ERROR: P1 Green LED must be LOW.", VLOW); + error_flag <= true; + end if; + if(led_enc_p2_g /= '0') then + log("ERROR: P2 Green LED must be LOW.", VLOW); + error_flag <= true; + end if; + if(led_enc_p1_y /= '1') then + log("ERROR: P1 Yellow LED must be HIGH.", VLOW); + error_flag <= true; + end if; + if(led_enc_p2_y /= '1') then + log("ERROR: P2 Yellow LED must be HIGH.", VLOW); + error_flag <= true; + end if; + + wait for 20 us; + + enc_p1 <= '0'; + wait for 100 ns; + if(led_enc_p1_g /= '1') then + log("ERROR: P1 Green LED must be HIGH.", VLOW); + error_flag <= true; + end if; + + wait for 3 ms; + if(led_enc_p1_g /= '0') then + log("ERROR: P1 Green LED must be LOW.", VLOW); + error_flag <= true; + end if; + + wait for 5 us; + enc_p1 <= '1'; + wait for 100 ns; + if(led_enc_p1_g /= '1') then + log("ERROR: P1 Green LED must be HIGH.", VLOW); + error_flag <= true; + end if; + wait for 10 us; + enc_p1 <= '0'; + wait for 10 us; + enc_p1 <= '1'; + wait for 10 us; + enc_p1 <= '0'; + wait for 10 us; + enc_p1 <= '1'; + wait for 10 us; + if(led_enc_p1_g /= '1') then + log("ERROR: P1 Green LED must be HIGH.", VLOW); + error_flag <= true; + end if; + + wait for 200 us; + enc_p2 <= '0'; + wait for 100 ns; + if(led_enc_p2_g /= '1') then + log("ERROR: P2 Green LED must be HIGH.", VLOW); + error_flag <= true; + end if; + + wait for 3 ms; + if(led_enc_p2_g /= '0') then + log("ERROR: P2 Green LED must be LOW.", VLOW); + error_flag <= true; + end if; + if(led_enc_p2_y /= '0') then + log("ERROR: P2 Yellow LED must be LOW.", VLOW); + error_flag <= true; + end if; + + wait for 3 ms; + if(led_enc_p2_g /= '0') then + log("ERROR: P2 Green LED must be LOW.", VLOW); + error_flag <= true; + end if; + if(led_enc_p2_y /= '1') then + log("ERROR: P2 Yellow LED must be HIGH.", VLOW); + error_flag <= true; + end if; + + wait for 10 us; + enc_p2 <= not enc_p2; + enc_p1 <= not enc_p1; + wait for 100 ns; + if(led_enc_p1_r /= '1') then + log("ERROR: P1 Red LED must be HIGH.", VLOW); + error_flag <= true; + end if; + if(led_enc_p2_r /= '1') then + log("ERROR: P2 Red LED must be HIGH.", VLOW); + error_flag <= true; + end if; + + wait for 6 ms; + wait for 100 ns; + if(led_enc_p1_r /= '0') then + log("ERROR: P1 Red LED must be LOW.", VLOW); + error_flag <= true; + end if; + if(led_enc_p2_r /= '0') then + log("ERROR: P2 Red LED must be LOW.", VLOW); + error_flag <= true; + end if; + if(led_enc_p1_y /= '1') then + log("ERROR: P1 Yellow LED must be HIGH.", VLOW); + error_flag <= true; + end if; + if(led_enc_p2_y /= '1') then + log("ERROR: P2 Yellow LED must be HIGH.", VLOW); + error_flag <= true; + end if; + + wait for 0.5 ms; + + if(error_flag = false) then + log("Encoder LEDs are OK.", VLOW); + end if; + + end if; -- RUN_ENC_TEST + + --------------------------------------------------------------------------- + -- End + --------------------------------------------------------------------------- + + wait for 20 us; + + passed <= true after 100 ns; + wait; + + end process pTEST_PROC; + + failed <= error_flag after 100 ns; + + CHECK_SIM_TIMEOUT: process + begin -- process CHECK_SIM_TIMEOUT + while now < MAX_SIM_TIME loop + wait for 100 us; + end loop; + test_timeout <= true; + wait; + end process CHECK_SIM_TIMEOUT; + + pREPORT_RESULT : process + begin + wait until failed = true or passed = true or test_timeout = 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); + elsif(test_timeout = true) then + log("FAILURE: test achieved max-sim-time without reaching ", VLOW); + log(" failed/passed condition.", VLOW); + end if; + log_separator_line(VLOW); + test_completed <= true; + end process pREPORT_RESULT; + + +end architecture behav; From 63ca72f1c2bb2da971a5ef78b7b65f84f06a1516 Mon Sep 17 00:00:00 2001 From: gianmarcogirau Date: Tue, 21 Jan 2020 17:20:09 +0000 Subject: [PATCH 13/15] CORE-73 CORE-80 - Some optimizations to EMS and Encoder Multiplier logic --- generic_ip/ems/0/src/ems_0.vhd | 89 +++++++++++++++++-- .../encoder_multiply/0/sim/wave_enc_mult.do | 5 +- .../0/src/encoder_multiply_0.vhd | 18 ++-- .../0/src/encoder_speed_detect_0.vhd | 15 ++-- .../0/src/test/encoder_multiply_tb.vhd | 30 +++---- .../0/src/test/encoder_speed_detect_tb.vhd | 6 +- .../fire_pulse_manager/5/sim/wave_led.do | 4 +- .../5/src/fire_pulse_manager_5.vhd | 6 +- .../5/src/seb_epd_led_gen_5.vhd | 13 --- 9 files changed, 124 insertions(+), 62 deletions(-) diff --git a/generic_ip/ems/0/src/ems_0.vhd b/generic_ip/ems/0/src/ems_0.vhd index 70f630b..38b5d83 100644 --- a/generic_ip/ems/0/src/ems_0.vhd +++ b/generic_ip/ems/0/src/ems_0.vhd @@ -6,7 +6,7 @@ -- Author : Gianmarco Girau -- Company : Global Inkjet Systems -- Created : 2018-05-24 --- Last update: 2019-12-17 +-- Last update: 2020-01-21 -- SVN ID : Git -- Standard : VHDL 2008 ------------------------------------------------------------------------------- @@ -27,7 +27,9 @@ use work.ems_0_pkg.all; entity ems_0 is generic( - GEN_PRINT_START : boolean := false); + ADD_ENC_ZP_LOGIC : boolean := true; + ADD_MULT_DEBUG_REG : boolean := true; + GEN_PRINT_START : boolean := false); port ( clk : in std_logic; reset_n : in std_logic := '1'; @@ -94,6 +96,7 @@ architecture rtl of ems_0 is signal m_step_pos, m_step_neg : std_logic; signal step_pos_retimed, step_neg_retimed : std_logic; signal init_mult, enable_mult : std_logic; + signal add_enc_zp, add_mult_dbg_regs : std_logic; -- signal enc_sel : std_logic_vector( 1 downto 0); signal pd_sel, mult_sel, pd_delay_line : std_logic_vector( 2 downto 0); @@ -106,7 +109,7 @@ architecture rtl of ems_0 is signal delta_init, time_out : std_logic_vector(27 downto 0); signal abs_pos_i, abs_pos_init : std_logic_vector(31 downto 0); signal abs_pos_in, abs_pos_vel : std_logic_vector(31 downto 0); - signal delta_t : std_logic_vector(39 downto 0); + signal delta_t : std_logic_vector(31 downto 0); begin @@ -129,7 +132,6 @@ begin pd_mux <= rs422_pd when pd_sel(0) = '0' else ttl_pd_i; p1_mux <= rs422_p1 when enc_sel(0) = '0' else ttl_p1; p2_mux <= rs422_p2 when enc_sel(0) = '0' else ttl_p2; - zp_mux <= rs422_zp when enc_sel(0) = '0' else ttl_zp; -- Filters iPD_FILT: entity work.digital_lpf @@ -180,6 +182,42 @@ begin rEdge => p2_re, fEdge => p2_fe); + gENC_ZP_FILT: if ADD_ENC_ZP_LOGIC = true generate + + add_enc_zp <= '1'; + + zp_mux <= rs422_zp when enc_sel(0) = '0' else ttl_zp; + + iZP_FILT: entity work.digital_lpf + generic map ( + MAX_ORDER => 32, + DEFAULT_ORDER => DEFAULT_FILT_ORDER, + DEFAULT_HYST => DEFAULT_FILT_HYST) + port map ( + clk => clk, + reset_n => reset_n, + ld_cfg => ld_filt_cfg_zp, + filt_order => filt_order, + hyst => filt_hyst, + filt_in => zp_mux, + filt_out => zp_i); + + -- Buffer the filtered signals + pZP_FiltOut_Buf : process(clk) + begin + if(clk = '1' and clk'event) then + filt_zp <= zp_i; + end if; + end process pZP_FiltOut_Buf; + + else generate + + add_enc_zp <= '0'; + + filt_zp <= '0'; + + end generate gENC_ZP_FILT; + iZP_FILT: entity work.digital_lpf generic map ( MAX_ORDER => 32, @@ -201,7 +239,6 @@ begin filt_pd <= pd_i; filt_p1 <= p1_i; filt_p2 <= p2_i; - filt_zp <= zp_i; end if; end process pFiltOut_Buf; @@ -337,6 +374,36 @@ begin wrap_neg <= wrap_neg_i when use_multiplier = '0' else m_step_neg; abs_position <= abs_pos_i; + + gMULT_DBG_REGs: if ADD_MULT_DEBUG_REG = true generate + + add_mult_dbg_regs <= '1'; + + pMULT_DBG_REGs : process(clk) + begin + if(clk = '1' and clk'event) then + if(set_pos_i = '1') then + abs_pos_in <= abs_pos_init; + elsif(step_pos = '1') then + abs_pos_in <= std_logic_vector(signed(abs_pos_in)+1); + elsif(step_neg = '1') then + abs_pos_in <= std_logic_vector(signed(abs_pos_in)-1); + end if; + if(set_pos_i = '1') then + abs_pos_vel <= abs_pos_init; + elsif(step_pos_retimed = '1') then + abs_pos_vel <= std_logic_vector(signed(abs_pos_vel)+1); + elsif(step_neg_retimed = '1') then + abs_pos_vel <= std_logic_vector(signed(abs_pos_vel)-1); + end if; + end if; + end process pMULT_DBG_REGs; + + else generate + + add_mult_dbg_regs <= '0'; + + end generate gMULT_DBG_REGs; ----------------------------------------------------------------------------- @@ -514,7 +581,9 @@ begin ld_filt_cfg_pd <= avs_writedata(16); ld_filt_cfg_p1 <= avs_writedata(17); ld_filt_cfg_p2 <= avs_writedata(18); - ld_filt_cfg_zp <= avs_writedata(19); + if(add_enc_zp = '1') then + ld_filt_cfg_zp <= avs_writedata(19); + end if; when CSR_MULT_CFG_ADDR => use_multiplier <= avs_writedata(0); mult_sel <= avs_writedata( 6 downto 4); @@ -575,9 +644,13 @@ begin when CSR_VEL_TIMEOUT_ADDR => avs_readdata <= X"0" & time_out; when CSR_ABS_POS_IN_ADDR => - avs_readdata <= abs_pos_in; + if(add_mult_dbg_regs = '1') then + avs_readdata <= abs_pos_in; + end if; when CSR_ABS_POS_VEL_ADDR => - avs_readdata <= abs_pos_vel; + if(add_mult_dbg_regs = '1') then + avs_readdata <= abs_pos_vel; + end if; when others => avs_readdata <= X"BAD1BAD0"; end case; diff --git a/generic_ip/encoder_multiply/0/sim/wave_enc_mult.do b/generic_ip/encoder_multiply/0/sim/wave_enc_mult.do index 5782124..b565d99 100644 --- a/generic_ip/encoder_multiply/0/sim/wave_enc_mult.do +++ b/generic_ip/encoder_multiply/0/sim/wave_enc_mult.do @@ -60,9 +60,7 @@ add wave -noupdate /encoder_multiply_tb/iMULT/realign_pos_d add wave -noupdate /encoder_multiply_tb/iMULT/realign_neg add wave -noupdate /encoder_multiply_tb/iMULT/realign_neg_d add wave -noupdate /encoder_multiply_tb/iMULT/norm_pos -add wave -noupdate /encoder_multiply_tb/iMULT/norm_pos_d add wave -noupdate /encoder_multiply_tb/iMULT/norm_neg -add wave -noupdate /encoder_multiply_tb/iMULT/norm_neg_d add wave -noupdate -radix decimal /encoder_multiply_tb/iMULT/pulse_cnt add wave -noupdate -radix decimal /encoder_multiply_tb/iMULT/m_pulse_cnt add wave -noupdate -radix unsigned /encoder_multiply_tb/iMULT/m_norm_value @@ -81,6 +79,7 @@ add wave -noupdate -radix unsigned /encoder_multiply_tb/iSPEED/time_out add wave -noupdate /encoder_multiply_tb/iSPEED/step_pos add wave -noupdate /encoder_multiply_tb/iSPEED/step_neg add wave -noupdate -radix hexadecimal /encoder_multiply_tb/iSPEED/delta_t +add wave -noupdate /encoder_multiply_tb/iSPEED/enforce_delta_min add wave -noupdate /encoder_multiply_tb/iSPEED/step_pos_out add wave -noupdate /encoder_multiply_tb/iSPEED/step_neg_out add wave -noupdate /encoder_multiply_tb/iSPEED/time_out_flag @@ -140,4 +139,4 @@ configure wave -griddelta 40 configure wave -timeline 0 configure wave -timelineunits ps update -WaveRestoreZoom {989186793 ps} {2009434857 ps} +WaveRestoreZoom {35459995308 ps} {37500491436 ps} diff --git a/generic_ip/encoder_multiply/0/src/encoder_multiply_0.vhd b/generic_ip/encoder_multiply/0/src/encoder_multiply_0.vhd index e6ced35..e1a23ee 100644 --- a/generic_ip/encoder_multiply/0/src/encoder_multiply_0.vhd +++ b/generic_ip/encoder_multiply/0/src/encoder_multiply_0.vhd @@ -6,7 +6,7 @@ -- Author : Gianmarco Girau -- Company : Global Inkjet Systems -- Created : 2019-02-27 --- Last update: 2019-04-25 +-- Last update: 2020-01-21 -- SVN ID : Git -- Standard : VHDL'2008 ------------------------------------------------------------------------------- @@ -20,7 +20,7 @@ -- enable : do not update the internal state when '0' -- mult_sel: mult_value = 2**mult_sel => max is 7 -- delta_t : average time difference between pulses, with signed magnitude, --- fixed point representation (8 bits mantissa), top bit is the sign: +-- top bit is the sign: -- 0 => avg time between pos steps, 1 => avg time between neg steps -- step_pos_in : positive encoder step, before multiplication -- step_neg_in : negative encoder step, before multiplication @@ -40,7 +40,7 @@ entity encoder_multiply_0 is init : in std_logic; enable : in std_logic; mult_sel : in std_logic_vector( 2 downto 0); - delta_t : in std_logic_vector(39 downto 0); + delta_t : in std_logic_vector(31 downto 0); step_pos_in : in std_logic; step_neg_in : in std_logic; step_pos_out : out std_logic; @@ -202,8 +202,8 @@ begin step_pos <= step_pos_in and enable; step_neg <= step_neg_in and enable; - delta_t_i <= delta_t(38 downto 8); - sign_i <= delta_t(39); + delta_t_i <= delta_t(30 downto 0); + sign_i <= delta_t(31); time_cnt_tc <= '1' when unsigned(time_cnt) = 1 else '0'; @@ -215,11 +215,11 @@ begin m_step_neg <= '1' when realign_neg_i = '1' or (sign = '1' and (kickoff = '1' or (time_cnt_tc = '1' and delta_m_pos = '1'))) else '0'; kickoff <= pending_kickoff and (step_pos or step_neg); - - norm_pos <= '1' when step_pos = '1' and signed(pulse_cnt) >= 2*NORM_VALUE else '0'; - norm_neg <= '1' when step_neg = '1' and signed(pulse_cnt) <= -2*NORM_VALUE else '0'; + + norm_pos <= '1' when step_pos = '1' and signed(pulse_cnt)-2*NORM_VALUE >= 0 else '0'; + norm_neg <= '1' when step_neg = '1' and signed(pulse_cnt)+2*NORM_VALUE <= 0 else '0'; delta_m_pos <= '1' when signed(delta_m) > 0 else '0'; - delta_m_neg <= '1' when signed(delta_m) < 0 else '0'; + delta_m_neg <= delta_m(delta_m'left); end architecture rtl; diff --git a/generic_ip/encoder_multiply/0/src/encoder_speed_detect_0.vhd b/generic_ip/encoder_multiply/0/src/encoder_speed_detect_0.vhd index 8bfadce..e765360 100644 --- a/generic_ip/encoder_multiply/0/src/encoder_speed_detect_0.vhd +++ b/generic_ip/encoder_multiply/0/src/encoder_speed_detect_0.vhd @@ -6,7 +6,7 @@ -- Author : Gianmarco Girau -- Company : Global Inkjet Systems -- Created : 2019-02-27 --- Last update: 2019-11-22 +-- Last update: 2020-01-21 -- SVN ID : Git -- Standard : VHDL'2008 ------------------------------------------------------------------------------- @@ -46,7 +46,7 @@ entity encoder_speed_detect_0 is time_out : in std_logic_vector(27 downto 0); step_pos : in std_logic; step_neg : in std_logic; - delta_t : out std_logic_vector(39 downto 0); + delta_t : out std_logic_vector(31 downto 0); step_pos_out : out std_logic; step_neg_out : out std_logic; time_out_flag : out std_logic); @@ -75,6 +75,7 @@ architecture rtl of encoder_speed_detect_0 is signal loc_time, time_out_cnt : std_logic_vector(27 downto 0); signal time_diff : std_logic_vector(29 downto 0); signal time_diff_i, delta_t_i : std_logic_vector(30 downto 0); + signal delta_t_min_check : std_logic_vector(30 downto 0); signal new_tag, tag_last_i, gnd_32 : std_logic_vector(31 downto 0); signal tag_first, tag_last : std_logic_vector(31 downto 0); @@ -205,12 +206,12 @@ begin last_step_type <= step_type; end if; if(init_i = '1') then - delta_t <= "0000" & delta_init & 8x"0"; + delta_t <= "0000" & delta_init; elsif(data_valid(data_valid'left) = '1') then if(first_step = '1' or enforce_delta_min = '1' or last_step_type /= step_balance(step_balance'left)) then - delta_t <= last_step_type & 3x"0" & delta_init & 8x"0"; + delta_t <= last_step_type & 3x"0" & delta_init; else - delta_t <= step_balance(step_balance'left) & delta_t_i & 8x"0"; + delta_t <= step_balance(step_balance'left) & delta_t_i; end if; end if; end if; @@ -232,7 +233,9 @@ begin inc_last <= new_step; inc_first <= new_step and (not avg_transient_on); - enforce_delta_min <= '1' when unsigned(delta_t_i) < unsigned(delta_init) else '0'; + --enforce_delta_min <= '1' when unsigned(delta_t_i) < unsigned(delta_init) else '0'; + delta_t_min_check <= std_logic_vector(unsigned(delta_t_i) - unsigned(delta_init)); + enforce_delta_min <= delta_t_min_check(delta_t_min_check'left); -- This RAM is for storing tag (time and encoder step-type iTIMING_RAM: entity work.dpram_sclk diff --git a/generic_ip/encoder_multiply/0/src/test/encoder_multiply_tb.vhd b/generic_ip/encoder_multiply/0/src/test/encoder_multiply_tb.vhd index 8751733..ca09a2b 100644 --- a/generic_ip/encoder_multiply/0/src/test/encoder_multiply_tb.vhd +++ b/generic_ip/encoder_multiply/0/src/test/encoder_multiply_tb.vhd @@ -6,7 +6,7 @@ -- Author : GMG -- Company : Global Inkjet Systems -- Created : 2019-03-05 --- Last update: 2019-04-25 +-- Last update: 2020-01-21 -- SVN ID : Git -- Standard : VHDL'2008 ------------------------------------------------------------------------------- @@ -67,8 +67,8 @@ architecture behav of encoder_multiply_tb is signal init : std_logic; signal enable : std_logic; signal mult_sel : std_logic_vector(2 downto 0); - signal delta_t : std_logic_vector(39 downto 0); - signal delta_t_i : std_logic_vector(39 downto 0); + signal delta_t : std_logic_vector(31 downto 0); + signal delta_t_i : std_logic_vector(31 downto 0); signal avg_steps : std_logic_vector( 6 downto 0); signal delta_init : std_logic_vector(27 downto 0); signal time_out : std_logic_vector(27 downto 0); @@ -159,7 +159,7 @@ architecture behav of encoder_multiply_tb is dir : in std_logic; max_steps : in natural; signal enable : out std_logic; - signal delta_t : out std_logic_vector(39 downto 0); + signal delta_t : out std_logic_vector(31 downto 0); signal step_pos : out std_logic; signal step_neg : out std_logic; init : in boolean := false) is @@ -187,9 +187,9 @@ architecture behav of encoder_multiply_tb is -- set the initial velocity estimation if(init = true) then - delta_t(delta_t'left-1 downto 0) <=std_logic_vector(to_unsigned(integer(maximum(DELTA_TMIN,2*MULT_VALUE))*256, 39)); + delta_t(delta_t'left-1 downto 0) <=std_logic_vector(to_unsigned(integer(maximum(DELTA_TMIN,2*MULT_VALUE)), 31)); else - delta_t(delta_t'left-1 downto 0) <= std_logic_vector(to_unsigned(integer(t_period*100.0*256.0), delta_t'left)); + delta_t(delta_t'left-1 downto 0) <= std_logic_vector(to_unsigned(integer(t_period*100.0), delta_t'left)); end if; delta_t(delta_t'left) <= dir; wait_clk_cycles(1); @@ -213,7 +213,7 @@ architecture behav of encoder_multiply_tb is if(now-t_ref > (1.0 us)*(real(step_cnt)*t_period)) then wait until clk = '1' and clk'event; -- issue the next step - delta_t(delta_t'left-1 downto 0) <= std_logic_vector(to_unsigned(integer(t_period*100.0*256.0), delta_t'left)); + delta_t(delta_t'left-1 downto 0) <= std_logic_vector(to_unsigned(integer(t_period*100.0), delta_t'left)); delta_t(delta_t'left) <= dir; if(dir = '0') then step_pos <= '1'; @@ -246,7 +246,7 @@ architecture behav of encoder_multiply_tb is max_steps : in natural; period_noise : in natural range 0 to 100; signal enable : out std_logic; - signal delta_t : out std_logic_vector(39 downto 0); + signal delta_t : out std_logic_vector(31 downto 0); signal step_pos : out std_logic; signal step_neg : out std_logic; init : in boolean := false) is @@ -276,9 +276,9 @@ architecture behav of encoder_multiply_tb is -- set the initial velocity estimation if(init = true) then - delta_t(delta_t'left-1 downto 0) <=std_logic_vector(to_unsigned(maximum(DELTA_TMIN,2*MULT_VALUE)*256, 39)); + delta_t(delta_t'left-1 downto 0) <=std_logic_vector(to_unsigned(maximum(DELTA_TMIN,2*MULT_VALUE), 31)); else - delta_t(delta_t'left-1 downto 0) <= std_logic_vector(to_unsigned(integer(t_period*100.0*256.0), delta_t'left)); + delta_t(delta_t'left-1 downto 0) <= std_logic_vector(to_unsigned(integer(t_period*100.0), delta_t'left)); end if; delta_t(delta_t'left) <= dir; wait_clk_cycles(1); @@ -303,7 +303,7 @@ architecture behav of encoder_multiply_tb is if(now-t_ref > (1.0 us)*((real(step_cnt-1)+((100.0+real(delta_period))/100.0))*t_period)) then wait until clk = '1' and clk'event; -- issue the next step - delta_t(delta_t'left-1 downto 0) <= std_logic_vector(to_unsigned(integer(t_period*100.0*256.0), delta_t'left)); + delta_t(delta_t'left-1 downto 0) <= std_logic_vector(to_unsigned(integer(t_period*100.0), delta_t'left)); delta_t(delta_t'left) <= dir; if(dir = '0') then step_pos <= '1'; @@ -340,7 +340,7 @@ architecture behav of encoder_multiply_tb is period_noise : in natural range 0 to 100; */ signal enable : out std_logic; - signal delta_t : out std_logic_vector(39 downto 0); + signal delta_t : out std_logic_vector(31 downto 0); signal step_pos : out std_logic; signal step_neg : out std_logic; init : in boolean := false) is @@ -378,9 +378,9 @@ architecture behav of encoder_multiply_tb is -- set the initial velocity estimation if(init = true) then - delta_t(delta_t'left-1 downto 0) <=std_logic_vector(to_unsigned(maximum(DELTA_TMIN,2*MULT_VALUE)*256, 39)); + delta_t(delta_t'left-1 downto 0) <=std_logic_vector(to_unsigned(maximum(DELTA_TMIN,2*MULT_VALUE), 31)); else - delta_t(delta_t'left-1 downto 0) <= std_logic_vector(to_unsigned(integer(t_period*100.0*256.0), delta_t'left)); + delta_t(delta_t'left-1 downto 0) <= std_logic_vector(to_unsigned(integer(t_period*100.0), delta_t'left)); end if; delta_t(delta_t'left) <= dir; wait_clk_cycles(1); @@ -543,7 +543,7 @@ begin -- architecture behav end if; end process pGEN_POS; - delta_t_norm <= to_integer(unsigned(delta_t_i(38 downto 8))) when delta_t_i(39) = '0' else -1*to_integer(unsigned(delta_t_i(38 downto 8))); + delta_t_norm <= to_integer(unsigned(delta_t_i(30 downto 0))) when delta_t_i(31) = '0' else -1*to_integer(unsigned(delta_t_i(30 downto 0))); ----------------------------------------------------------------------------- -- Testbench Logic diff --git a/generic_ip/encoder_multiply/0/src/test/encoder_speed_detect_tb.vhd b/generic_ip/encoder_multiply/0/src/test/encoder_speed_detect_tb.vhd index 03bb7ce..fda9d0b 100644 --- a/generic_ip/encoder_multiply/0/src/test/encoder_speed_detect_tb.vhd +++ b/generic_ip/encoder_multiply/0/src/test/encoder_speed_detect_tb.vhd @@ -6,7 +6,7 @@ -- Author : GMG -- Company : Global Inkjet Systems -- Created : 2019-03-05 --- Last update: 2019-04-18 +-- Last update: 2020-01-21 -- SVN ID : Git -- Standard : VHDL'2008 ------------------------------------------------------------------------------- @@ -67,7 +67,7 @@ architecture behav of encoder_speed_detect_tb is signal time_out : std_logic_vector(27 downto 0); signal step_pos : std_logic; signal step_neg : std_logic; - signal delta_t : std_logic_vector(39 downto 0); + signal delta_t : std_logic_vector(31 downto 0); signal step_pos_out : std_logic; signal step_neg_out : std_logic; signal time_out_flag : std_logic; @@ -433,7 +433,7 @@ begin -- architecture behav end if; end process pGEN_POS; - delta_t_norm <= to_integer(unsigned(delta_t(38 downto 8))) when delta_t(39) = '0' else -1*to_integer(unsigned(delta_t(38 downto 8))); + delta_t_norm <= to_integer(unsigned(delta_t(30 downto 0))) when delta_t(31) = '0' else -1*to_integer(unsigned(delta_t(30 downto 0))); ----------------------------------------------------------------------------- -- Testbench Logic diff --git a/generic_ip/fire_pulse_manager/5/sim/wave_led.do b/generic_ip/fire_pulse_manager/5/sim/wave_led.do index 5becfdc..b717ba6 100644 --- a/generic_ip/fire_pulse_manager/5/sim/wave_led.do +++ b/generic_ip/fire_pulse_manager/5/sim/wave_led.do @@ -52,8 +52,6 @@ add wave -noupdate /led_tb/iUUT/enc_p1_d add wave -noupdate /led_tb/iUUT/enc_p2_d add wave -noupdate /led_tb/iUUT/one_ms_pulse add wave -noupdate /led_tb/iUUT/pd_event -add wave -noupdate /led_tb/iUUT/p1_prev_event -add wave -noupdate /led_tb/iUUT/p2_prev_event add wave -noupdate /led_tb/iUUT/pd_cnt_zero_flag add wave -noupdate /led_tb/iUUT/rst_pd_green add wave -noupdate /led_tb/iUUT/pd_red @@ -102,4 +100,4 @@ configure wave -griddelta 40 configure wave -timeline 0 configure wave -timelineunits ps update -WaveRestoreZoom {0 ps} {16252698624 ps} +WaveRestoreZoom {33524561308 ps} {49777259932 ps} diff --git a/generic_ip/fire_pulse_manager/5/src/fire_pulse_manager_5.vhd b/generic_ip/fire_pulse_manager/5/src/fire_pulse_manager_5.vhd index 1343c04..01ff81c 100644 --- a/generic_ip/fire_pulse_manager/5/src/fire_pulse_manager_5.vhd +++ b/generic_ip/fire_pulse_manager/5/src/fire_pulse_manager_5.vhd @@ -6,7 +6,7 @@ -- Author : Gianmarco Girau -- Company : Global Inkjet Systems -- Created : 2017-09-06 --- Last update: 2020-01-17 +-- Last update: 2020-01-21 -- SVN ID : Git -- Standard : VHDL'08 ------------------------------------------------------------------------------- @@ -597,7 +597,9 @@ begin iEMS : entity work.ems_0 generic map( - GEN_PRINT_START => false) + ADD_ENC_ZP_LOGIC => false, + ADD_MULT_DEBUG_REG => false, + GEN_PRINT_START => false) port map ( clk => clk, reset_n => reset_n_i, diff --git a/generic_ip/fire_pulse_manager/5/src/seb_epd_led_gen_5.vhd b/generic_ip/fire_pulse_manager/5/src/seb_epd_led_gen_5.vhd index 2be8d6c..a382e33 100644 --- a/generic_ip/fire_pulse_manager/5/src/seb_epd_led_gen_5.vhd +++ b/generic_ip/fire_pulse_manager/5/src/seb_epd_led_gen_5.vhd @@ -55,7 +55,6 @@ architecture rtl of seb_epd_led_gen_5 is constant END_GREEN_PERIOD_MS : natural := MAX_PERIOD_MS - GREEN_PERIOD_MS; signal pd_d, enc_p1_d, enc_p2_d, one_ms_pulse : std_logic; - signal p1_prev_event, p2_prev_event : std_logic; signal pd_cnt_zero_flag, rst_pd_green, pd_red, pd_green : std_logic; signal p1_event, p2_event, p1_cnt_zero_flag : std_logic; signal p2_cnt_zero_flag, pd_event, rst_pof_green : std_logic; @@ -146,21 +145,9 @@ begin p1_green <= '0'; p2_red <= '0'; p2_green <= '0'; - p1_prev_event <= '0'; - p2_prev_event <= '0'; p1_active <= '0'; p2_active <= '0'; elsif(clk = '1' and clk'event) then - if(init = '1' or (p1_cnt_zero_flag = '1' and p1_event = '0')) then - p1_prev_event <= '0'; - elsif(p1_event = '1') then - p1_prev_event <= p1_event; - end if; - if(init = '1' or (p2_cnt_zero_flag = '1' and p2_event = '0')) then - p2_prev_event <= '0'; - elsif(p2_event = '1') then - p2_prev_event <= p2_event; - end if; if(init = '1') then p1_cnt <= (others => '0'); elsif(p1_event = '1' and p1_red = '0') then From 539ab3b6c82f38fcf883decf3ade9e7e81f1c943 Mon Sep 17 00:00:00 2001 From: gianmarcogirau Date: Wed, 22 Jan 2020 11:01:59 +0000 Subject: [PATCH 14/15] CORE-73 CORE-80 - Improved timing on the Encoder Speed Detection block --- .../encoder_multiply/0/src/encoder_speed_detect_0.vhd | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/generic_ip/encoder_multiply/0/src/encoder_speed_detect_0.vhd b/generic_ip/encoder_multiply/0/src/encoder_speed_detect_0.vhd index e765360..968bf6a 100644 --- a/generic_ip/encoder_multiply/0/src/encoder_speed_detect_0.vhd +++ b/generic_ip/encoder_multiply/0/src/encoder_speed_detect_0.vhd @@ -6,7 +6,7 @@ -- Author : Gianmarco Girau -- Company : Global Inkjet Systems -- Created : 2019-02-27 --- Last update: 2020-01-21 +-- Last update: 2020-01-22 -- SVN ID : Git -- Standard : VHDL'2008 ------------------------------------------------------------------------------- @@ -55,7 +55,7 @@ end encoder_speed_detect_0; architecture rtl of encoder_speed_detect_0 is -- number of pipeline stages for the divider - constant DIV_PIPE_STAGES : natural := 2; + constant DIV_PIPE_STAGES : natural := 3; signal step_type, step_pos_i, step_neg_i : std_logic; signal step_pos_filt, step_neg_filt, busy : std_logic; @@ -205,6 +205,7 @@ begin if(new_step = '1') then last_step_type <= step_type; end if; + enforce_delta_min <= delta_t_min_check(delta_t_min_check'left); if(init_i = '1') then delta_t <= "0000" & delta_init; elsif(data_valid(data_valid'left) = '1') then @@ -233,9 +234,7 @@ begin inc_last <= new_step; inc_first <= new_step and (not avg_transient_on); - --enforce_delta_min <= '1' when unsigned(delta_t_i) < unsigned(delta_init) else '0'; delta_t_min_check <= std_logic_vector(unsigned(delta_t_i) - unsigned(delta_init)); - enforce_delta_min <= delta_t_min_check(delta_t_min_check'left); -- This RAM is for storing tag (time and encoder step-type iTIMING_RAM: entity work.dpram_sclk From 555010ba9b686b33fac103d8e35cc7c89af78e62 Mon Sep 17 00:00:00 2001 From: gianmarcogirau Date: Thu, 23 Jan 2020 16:21:02 +0000 Subject: [PATCH 15/15] CORE-73 - Changed the multiplexing of pof_tx to enable using the drop-watch output on a daisy-chained SEB-EPD --- .../fire_pulse_manager/5/src/fire_pulse_manager_5.vhd | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/generic_ip/fire_pulse_manager/5/src/fire_pulse_manager_5.vhd b/generic_ip/fire_pulse_manager/5/src/fire_pulse_manager_5.vhd index 01ff81c..763e4be 100644 --- a/generic_ip/fire_pulse_manager/5/src/fire_pulse_manager_5.vhd +++ b/generic_ip/fire_pulse_manager/5/src/fire_pulse_manager_5.vhd @@ -6,7 +6,7 @@ -- Author : Gianmarco Girau -- Company : Global Inkjet Systems -- Created : 2017-09-06 --- Last update: 2020-01-21 +-- Last update: 2020-01-23 -- SVN ID : Git -- Standard : VHDL'08 ------------------------------------------------------------------------------- @@ -380,9 +380,9 @@ begin gPOF_TX_OUT : if SEB_EPD_MODE = true generate - pof_tx <= pof_tx_regen when src_sel(2) = '0' else - pof_tx_data when src_sel(3) = '0' else - dw_pulse; + pof_tx <= dw_pulse when src_sel(3) = '1' else + pof_tx_regen when src_sel(2) = '0' else + pof_tx_data; pBUF_SEB_EPD_MODE : process(clk) begin