WH-17 - Correction mechanism implemented in the logic and simulated. Created new major version of the FPM
This commit is contained in:
parent
7fcaef7819
commit
409018182c
18 changed files with 3295 additions and 46 deletions
|
|
@ -6,7 +6,7 @@
|
|||
-- Author : Gianmarco Girau
|
||||
-- Company : Global Inkjet Systems
|
||||
-- Created : 2017-09-06
|
||||
-- Last update: 2019-05-13
|
||||
-- Last update: 2019-05-29
|
||||
-- SVN ID : Git
|
||||
-- Standard : VHDL'08
|
||||
-------------------------------------------------------------------------------
|
||||
|
|
@ -137,7 +137,7 @@ architecture rtl of fire_pulse_manager_0 is
|
|||
signal src_sel : std_logic_vector( 1 downto 0);
|
||||
--
|
||||
signal one_pps : std_logic;
|
||||
signal log_data_src : std_logic_vector(15 downto 0);
|
||||
signal log_data_src : std_logic_vector(31 downto 0);
|
||||
|
||||
begin
|
||||
|
||||
|
|
@ -487,7 +487,7 @@ begin
|
|||
log_data_src(11) <= dec_pos;
|
||||
log_data_src(12) <= filtered_pd;
|
||||
--
|
||||
log_data_src(15 downto 13) <= (others => '0');
|
||||
log_data_src(31 downto 13) <= (others => '0');
|
||||
|
||||
end generate gEL1;
|
||||
|
||||
|
|
|
|||
2
generic_ip/fire_pulse_manager/2/Readme.txt
Normal file
2
generic_ip/fire_pulse_manager/2/Readme.txt
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
This major version instantiates Pulse-Generator major version 2, which is a custom build for W&H,
|
||||
with dedicated logic for managing Flexo and CI wheels corrections
|
||||
|
|
@ -0,0 +1,274 @@
|
|||
# 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_0" 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_2
|
||||
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_2
|
||||
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_2
|
||||
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 uart_rx.vhd VHDL PATH ../../../common/0/src/uart_rx.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 pulse_conditioning_1.vhd VHDL PATH ../../../pulse_generator/1/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_rx_2.vhd VHDL PATH ../src/pof_rx_2.vhd
|
||||
add_fileset_file smb_diagnostics_2.vhd VHDL PATH ../src/smb_diagnostics_2.vhd
|
||||
add_fileset_file fire_pulse_2_pkg.vhd VHDL PATH ../src/fire_pulse_2_pkg.vhd
|
||||
add_fileset_file uart_regen_2.vhd VHDL PATH ../src/uart_regen_2.vhd
|
||||
add_fileset_file fire_pulse_ctrl_2.vhd VHDL PATH ../src/fire_pulse_ctrl_2.vhd
|
||||
add_fileset_file fire_pulse_manager_2.vhd VHDL PATH ../src/fire_pulse_manager_2.vhd TOP_LEVEL_FILE
|
||||
|
||||
add_fileset SIM_VHDL SIM_VHDL "" ""
|
||||
set_fileset_property SIM_VHDL TOP_LEVEL fire_pulse_manager_2
|
||||
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 uart_rx.vhd VHDL PATH ../../../common/0/src/uart_rx.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 pulse_conditioning_1.vhd VHDL PATH ../../../pulse_generator/1/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_rx_2.vhd VHDL PATH ../src/pof_rx_2.vhd
|
||||
add_fileset_file smb_diagnostics_2.vhd VHDL PATH ../src/smb_diagnostics_2.vhd
|
||||
add_fileset_file fire_pulse_2_pkg.vhd VHDL PATH ../src/fire_pulse_2_pkg.vhd
|
||||
add_fileset_file uart_regen_2.vhd VHDL PATH ../src/uart_regen_2.vhd
|
||||
add_fileset_file fire_pulse_ctrl_2.vhd VHDL PATH ../src/fire_pulse_ctrl_2.vhd
|
||||
add_fileset_file fire_pulse_manager_2.vhd VHDL PATH ../src/fire_pulse_manager_2.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 1
|
||||
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_readdatavalid readdatavalid Output 1
|
||||
add_interface_port avs avs_readdata readdata Output 32
|
||||
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 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 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 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 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 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
|
||||
|
||||
241
generic_ip/fire_pulse_manager/2/doc/fire_pulse_ctrl_2.json
Normal file
241
generic_ip/fire_pulse_manager/2/doc/fire_pulse_ctrl_2.json
Normal file
|
|
@ -0,0 +1,241 @@
|
|||
[{
|
||||
"ip_name": "fire_pulse_ctrl_2",
|
||||
"bus": "csr",
|
||||
"description": "Fire-Pulse Controller",
|
||||
"registers": {
|
||||
"src_sel": {
|
||||
"address": "0",
|
||||
"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_rx_ctrl": {
|
||||
"address": "1",
|
||||
"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": "2",
|
||||
"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": "3",
|
||||
"reset": "0x00000000",
|
||||
"width": "32",
|
||||
"description": "Defines coarse time counter value"
|
||||
},
|
||||
"fine_time_init": {
|
||||
"address": "4",
|
||||
"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": "5",
|
||||
"reset": "0x0000000",
|
||||
"width": "28",
|
||||
"description": "Current fine time counter value"
|
||||
},
|
||||
"coarse_time_status": {
|
||||
"type": "r",
|
||||
"address": "6",
|
||||
"reset": "0x00000000",
|
||||
"width": "32",
|
||||
"description": "Current coarse time counter value"
|
||||
},
|
||||
"pof_rx_error_status": {
|
||||
"address": "7",
|
||||
"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_error_ctrl": {
|
||||
"address": "8",
|
||||
"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_irq": {
|
||||
"address": "9",
|
||||
"width": "16",
|
||||
"description": "FPM 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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}]
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
[{
|
||||
"ip_name" : "fire_pulse_manager_2",
|
||||
"bus" : "csr",
|
||||
"addr_hi_bit" : "14",
|
||||
"addr_lo_bit" : "11",
|
||||
"description" : "Single-Channel Fire-Pulse-Manager",
|
||||
"sub_blocks" : {
|
||||
"fire_pulse_ctrl_2" : {
|
||||
"instance" : "",
|
||||
"process" : "enabled",
|
||||
"offset" : "0x0000"
|
||||
},
|
||||
"pulse_generator_2" : {
|
||||
"instance" : "",
|
||||
"process" : "enabled",
|
||||
"offset" : "0x0800"
|
||||
},
|
||||
"smb_diagnostics_2" : {
|
||||
"instance" : "",
|
||||
"process" : "enabled",
|
||||
"offset" : "0x1800"
|
||||
},
|
||||
"enc_pd_emul_1" : {
|
||||
"instance" : "",
|
||||
"process" : "enabled",
|
||||
"offset" : "0x2800"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
474
generic_ip/fire_pulse_manager/2/doc/smb_diagnostics_2.json
Normal file
474
generic_ip/fire_pulse_manager/2/doc/smb_diagnostics_2.json
Normal file
|
|
@ -0,0 +1,474 @@
|
|||
[{
|
||||
"ip_name": "smb_diagnostics_2",
|
||||
"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"
|
||||
},
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}]
|
||||
64
generic_ip/fire_pulse_manager/2/sim/com_fpm.do
Normal file
64
generic_ip/fire_pulse_manager/2/sim/com_fpm.do
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
# Single-Channel FPM compilation macro
|
||||
|
||||
.main clear
|
||||
|
||||
# Cleanup libraries
|
||||
foreach lib [list work OSVVM] {
|
||||
file delete -force -- $lib
|
||||
vlib $lib
|
||||
}
|
||||
|
||||
# Path variables
|
||||
set SRC_PATH ../src
|
||||
set COMMON_PATH ../../../common/0/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 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
|
||||
|
||||
# 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 $COMMON_PATH/altera/sync_fifo.vhd
|
||||
vcom -2008 -work $WORKLIB $COMMON_PATH/queue_and_delay.vhd
|
||||
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
|
||||
|
||||
# Fire-Pulse-Manager
|
||||
vcom -2008 -work $WORKLIB $COMMON_PATH/cs_bus_itf.vhd
|
||||
vcom -2008 -work $WORKLIB $COMMON_PATH/uart_rx.vhd
|
||||
vcom -2008 -work $WORKLIB $SRC_PATH/pof_rx_2.vhd
|
||||
vcom -2008 -work $WORKLIB $SRC_PATH/smb_diagnostics_2.vhd
|
||||
vcom -2008 -work $WORKLIB $SRC_PATH/fire_pulse_2_pkg.vhd
|
||||
vcom -2008 -work $WORKLIB $SRC_PATH/uart_regen_2.vhd
|
||||
vcom -2008 -work $WORKLIB $SRC_PATH/fire_pulse_ctrl_2.vhd
|
||||
vcom -2008 -work $WORKLIB $SRC_PATH/fire_pulse_manager_2.vhd
|
||||
|
||||
|
||||
|
||||
|
||||
37
generic_ip/fire_pulse_manager/2/src/fire_pulse_2_pkg.vhd
Normal file
37
generic_ip/fire_pulse_manager/2/src/fire_pulse_2_pkg.vhd
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
-------------------------------------------------------------------------------
|
||||
-- Title : fire_pulse_2_pkg
|
||||
-- Project : HMB/EMB/SMB
|
||||
-------------------------------------------------------------------------------
|
||||
-- File : fire_pulse_2_pkg.vhd
|
||||
-- Author : Gianmarco Girau
|
||||
-- Company : Global Inkjet Systems
|
||||
-- Created : 2017-09-08
|
||||
-- Last update: 2019-05-29
|
||||
-- SVN ID : Git
|
||||
-- Standard : VHDL'08
|
||||
-------------------------------------------------------------------------------
|
||||
-- Description:
|
||||
-- Package for fire_pulse_manager block
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
use ieee.numeric_std.all;
|
||||
|
||||
package fire_pulse_2_pkg is
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Inner block mapping
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
constant blk_num : integer := 6; -- number of sub-blocks with dedicated
|
||||
-- C&S registers
|
||||
|
||||
constant fp_ctrl_id : natural := 0; -- Block ID for the Fire-Pulse-Mang Controller
|
||||
constant pg_ch_id : natural := 1; -- Block ID for Pulse-Generator
|
||||
constant net_snk_id : natural := 2; -- Block ID for Net-Sync Sink
|
||||
constant diag_blk_id : natural := 3; -- Block ID for the Diagnostic Block
|
||||
constant log_blk_id : natural := 4; -- Block ID for the Event Logger
|
||||
constant int_enc_id : natural := 5; -- Block ID for the Internal Encoder Block
|
||||
|
||||
end package fire_pulse_2_pkg;
|
||||
253
generic_ip/fire_pulse_manager/2/src/fire_pulse_ctrl_2.vhd
Normal file
253
generic_ip/fire_pulse_manager/2/src/fire_pulse_ctrl_2.vhd
Normal file
|
|
@ -0,0 +1,253 @@
|
|||
-------------------------------------------------------------------------------
|
||||
-- Title : fire_pulse_ctrl_2
|
||||
-- Project : HMB/EMB/SMB
|
||||
-------------------------------------------------------------------------------
|
||||
-- File : fire_pulse_ctrl_2.vhd
|
||||
-- Author : Gianmarco Girau
|
||||
-- Company : Global Inkjet Systems
|
||||
-- Created : 2017-09-06
|
||||
-- Last update: 2019-05-29
|
||||
-- SVN ID : Git
|
||||
-- Standard : VHDL'08
|
||||
-------------------------------------------------------------------------------
|
||||
-- Description:
|
||||
-- Control service logic for the Fire-Controller-Manager
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
use ieee.numeric_std.all;
|
||||
|
||||
entity fire_pulse_ctrl_2 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;
|
||||
-- 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_2;
|
||||
|
||||
architecture rtl of fire_pulse_ctrl_2 is
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Control & Status Registers Map
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
constant SRC_SEL_REG : std_logic_vector( 3 downto 0) := b"0000";
|
||||
constant POF_RX_CTRL : std_logic_vector( 3 downto 0) := b"0001";
|
||||
constant MON_PT_CTRL_REG : std_logic_vector( 3 downto 0) := b"0010";
|
||||
constant COARSE_TIME_INIT_REG : std_logic_vector( 3 downto 0) := b"0011";
|
||||
constant FINE_TIME_INIT_REG : std_logic_vector( 3 downto 0) := b"0100";
|
||||
constant FINE_TIME_REG : std_logic_vector( 3 downto 0) := b"0101";
|
||||
constant COARSE_TIME_REG : std_logic_vector( 3 downto 0) := b"0110";
|
||||
constant RX_ERROR_STATUS : std_logic_vector( 3 downto 0) := b"0111";
|
||||
constant RX_ERROR_CSR : std_logic_vector( 3 downto 0) := b"1000";
|
||||
constant IRQ_MNG_REG : std_logic_vector( 3 downto 0) := b"1001";
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- 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);
|
||||
|
||||
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;
|
||||
|
||||
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';
|
||||
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 others => null;
|
||||
end case;
|
||||
end if;
|
||||
-- Read Ctrl & Status registers
|
||||
avs_readdatavalid <= avs_read;
|
||||
if(avs_read = '1') then
|
||||
case avs_address is
|
||||
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 others =>
|
||||
avs_readdata <= X"BAD1BAD0";
|
||||
end case;
|
||||
end if;
|
||||
end if;
|
||||
end process pCTRL_STATUS;
|
||||
|
||||
end architecture rtl;
|
||||
494
generic_ip/fire_pulse_manager/2/src/fire_pulse_manager_2.vhd
Normal file
494
generic_ip/fire_pulse_manager/2/src/fire_pulse_manager_2.vhd
Normal file
|
|
@ -0,0 +1,494 @@
|
|||
-------------------------------------------------------------------------------
|
||||
-- Title : fire_pulse_manager_2
|
||||
-- Project : HMB/EMB/SMB
|
||||
-------------------------------------------------------------------------------
|
||||
-- File : fire_pulse_manager_2.vhd
|
||||
-- Author : Gianmarco Girau
|
||||
-- Company : Global Inkjet Systems
|
||||
-- Created : 2017-09-06
|
||||
-- Last update: 2019-05-29
|
||||
-- SVN ID : Git
|
||||
-- Standard : VHDL'08
|
||||
-------------------------------------------------------------------------------
|
||||
-- Description:
|
||||
-- Generates fire request from the EMS output data, transferred either via POF
|
||||
-- or through NetSync
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
use ieee.numeric_std.all;
|
||||
|
||||
library work;
|
||||
use work.fire_pulse_2_pkg.all;
|
||||
|
||||
entity fire_pulse_manager_2 is
|
||||
generic(
|
||||
ADD_EVENT_LOGGER : boolean := false;
|
||||
LOG_FIFO_SIZE : natural range 256 to 4096 := 1024);
|
||||
port(
|
||||
reset_n : in std_logic;
|
||||
clk : in std_logic; -- 100MHz
|
||||
rx_clk : in std_logic; -- 200MHz
|
||||
-- Datapath I/Os
|
||||
pof_rx : in std_logic;
|
||||
pof_tx : out std_logic;
|
||||
pof_iso_en : out std_logic;
|
||||
fire_pulse : 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;
|
||||
ins_fpm_irq_2 : out std_logic;
|
||||
ins_fpm_irq_3 : out std_logic;
|
||||
-- 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_readdatavalid : out std_logic;
|
||||
avs_readdata : out std_logic_vector(31 downto 0));
|
||||
end entity fire_pulse_manager_2;
|
||||
|
||||
architecture rtl of fire_pulse_manager_2 is
|
||||
|
||||
constant PD_QUEUE_SIZE : natural := 512;
|
||||
|
||||
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;
|
||||
signal cs_pg_read_en : std_logic;
|
||||
signal cs_pg_read_valid : std_logic;
|
||||
signal cs_pg_read_data : std_logic_vector(31 downto 0);
|
||||
--
|
||||
signal cs_nsnk_write_en : std_logic;
|
||||
signal cs_nsnk_read_en : std_logic;
|
||||
signal cs_nsnk_read_valid : std_logic;
|
||||
signal cs_nsnk_read_data : std_logic_vector(31 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 upd_max_pos : std_logic;
|
||||
signal upd_min_pos : 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 bit_div : 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 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;
|
||||
signal enc_pulse : std_logic;
|
||||
signal enc_pulse_pof : std_logic;
|
||||
signal enc_pulse_ie : std_logic;
|
||||
signal pd_pulse_pof : std_logic;
|
||||
signal pd_pulse_ie : std_logic;
|
||||
signal pd_pulse : std_logic;
|
||||
signal set_pos_ie : std_logic;
|
||||
signal inc_pos_ie : std_logic;
|
||||
signal dec_pos_ie : std_logic;
|
||||
signal inc_pos_pof : std_logic;
|
||||
signal dec_pos_pof : std_logic;
|
||||
signal inc_pos : std_logic;
|
||||
signal dec_pos : std_logic;
|
||||
signal abs_pos_pof : std_logic_vector(31 downto 0);
|
||||
signal abs_pos_ie : std_logic_vector(39 downto 0);
|
||||
signal abs_pos : std_logic_vector(31 downto 0);
|
||||
--
|
||||
signal filtered_pd : std_logic;
|
||||
signal ch_pd, ch_pulse_out : std_logic;
|
||||
signal ch_raw_pulse, ch_mask : std_logic;
|
||||
signal fire_pulse_i : std_logic;
|
||||
signal fire_req : std_logic;
|
||||
signal src_sel : std_logic_vector( 1 downto 0);
|
||||
--
|
||||
signal one_pps : 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_readdatavalid => avs_readdatavalid,
|
||||
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_pg_write_en <= cs_write_en(pg_ch_id);
|
||||
cs_nsnk_write_en <= cs_write_en(net_snk_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_ctrl_read_en <= cs_read_en(fp_ctrl_id);
|
||||
cs_pg_read_en <= cs_read_en(pg_ch_id);
|
||||
cs_nsnk_read_en <= cs_read_en(net_snk_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_read_valid(fp_ctrl_id) <= cs_ctrl_read_valid;
|
||||
cs_read_valid(pg_ch_id) <= cs_pg_read_valid;
|
||||
cs_read_valid(net_snk_id) <= cs_nsnk_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_data(31+32*fp_ctrl_id downto 32*fp_ctrl_id) <= cs_ctrl_read_data;
|
||||
cs_read_data(31+32*pg_ch_id downto 32*pg_ch_id) <= cs_pg_read_data;
|
||||
cs_read_data(31+32*net_snk_id downto 32*net_snk_id) <= cs_nsnk_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;
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Fire-Pulse-Manager Controller
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
iCTRL : entity work.fire_pulse_ctrl_2
|
||||
port map(
|
||||
reset_n => reset_n_i,
|
||||
clk => clk,
|
||||
src_sel => src_sel,
|
||||
uart_regen_bypass => uart_regen_bypass,
|
||||
upd_max_pos => upd_max_pos,
|
||||
upd_min_pos => upd_min_pos,
|
||||
enable_rx => enable_rx,
|
||||
uart_bit_div => bit_div,
|
||||
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,
|
||||
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);
|
||||
|
||||
-- Output multiplexer
|
||||
fire_pulse_i <= ch_pulse_out when src_sel(0) = '1' else pof_rx;
|
||||
fire_pulse <= fire_pulse_i;
|
||||
|
||||
pd_pulse <= pd_pulse_pof when src_sel(1) = '0' else pd_pulse_ie;
|
||||
enc_pulse <= enc_pulse_pof when src_sel(1) = '0' else enc_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;
|
||||
|
||||
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;
|
||||
mon_point_src(2) <= pd_pulse;
|
||||
mon_point_src(3) <= enc_pulse;
|
||||
mon_point_src(4) <= ch_pd;
|
||||
mon_point_src(5) <= ch_pulse_out;
|
||||
mon_point_src(6) <= ch_raw_pulse;
|
||||
mon_point_src(7) <= ch_mask;
|
||||
mon_point_src(8) <= pof_rx;
|
||||
mon_point_src(9) <= fire_pulse_i;
|
||||
mon_point_src(10) <= inc_pos;
|
||||
mon_point_src(11) <= dec_pos;
|
||||
--
|
||||
mon_point_src(15 downto 12) <= (others => '0');
|
||||
|
||||
pof_iso_en <= enable_rx;
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Pulse Generator
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
iCH_PG : entity work.pulse_generator_2
|
||||
generic map(
|
||||
pd_queue_size => PD_QUEUE_SIZE,
|
||||
out_pulse_condition => true)
|
||||
port map(
|
||||
clk => clk,
|
||||
reset_n => reset_n_i,
|
||||
init => init,
|
||||
pd_in => pd_pulse,
|
||||
abs_position => abs_pos,
|
||||
dp_dir => dp_dir,
|
||||
pulse_out => ch_pulse_out,
|
||||
filtered_pd => filtered_pd,
|
||||
ch_pd => ch_pd,
|
||||
ch_mask => ch_mask,
|
||||
raw_pulse_out => ch_raw_pulse,
|
||||
enc_pulse => open,
|
||||
avs_address => cs_addr(9 downto 0),
|
||||
avs_write => cs_pg_write_en,
|
||||
avs_writedata => cs_write_data,
|
||||
avs_read => cs_pg_read_en,
|
||||
avs_readdatavalid => cs_pg_read_valid,
|
||||
avs_readdata => cs_pg_read_data);
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- POF Interface
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
-- POF Receiver
|
||||
iPOF_RX : entity work.pof_rx_2
|
||||
port map(
|
||||
reset_n => reset_n_i,
|
||||
clk => clk,
|
||||
init => '0',
|
||||
rx_clk => rx_clk,
|
||||
rx_data => pof_rx,
|
||||
init_out => remote_init,
|
||||
dp_dir => dp_dir,
|
||||
enc_out => enc_pulse_pof,
|
||||
pd_out => pd_pulse_pof,
|
||||
inc_pos => inc_pos_pof,
|
||||
dec_pos => dec_pos_pof,
|
||||
abs_pos => abs_pos_pof,
|
||||
enable => enable_rx,
|
||||
bit_div => bit_div,
|
||||
error_rate_thres => error_rate_thres,
|
||||
one_pps => one_pps,
|
||||
upd_max_pos => upd_max_pos,
|
||||
upd_min_pos => upd_min_pos,
|
||||
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.uart_regen_2
|
||||
generic map(
|
||||
data_width => 8)
|
||||
port map(
|
||||
reset_n => reset_n,
|
||||
clk => rx_clk,
|
||||
bit_div => bit_div,
|
||||
enable => enable_rx,
|
||||
bypass_en => uart_regen_bypass,
|
||||
uart_rx => pof_rx,
|
||||
uart_tx => pof_tx);
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Diagnostic block
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
iDiagnostic : entity work.smb_diagnostics_2
|
||||
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,
|
||||
--filt_prod_det => filtered_pd,
|
||||
enc_out => enc_pulse,
|
||||
pd_out => ch_pd,
|
||||
pos_step => inc_pos,
|
||||
neg_step => dec_pos,
|
||||
drop_watch => '0',
|
||||
fire_req => fire_req,
|
||||
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);
|
||||
|
||||
fire_req <= ch_pulse_out;
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- 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);
|
||||
|
||||
enc_pulse_ie <= inc_pos_ie when dp_dir = '0' else dec_pos_ie;
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- NetSync Sink
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
-- Not instantiated yet
|
||||
pNSNK_RD : process(clk)
|
||||
begin
|
||||
if(clk = '1' and clk'event) then
|
||||
cs_nsnk_read_valid <= cs_nsnk_read_en;
|
||||
end if;
|
||||
end process pNSNK_RD;
|
||||
|
||||
cs_nsnk_read_data <= X"DEAD_BEEF";
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Event Logger
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
gEL0: 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";
|
||||
|
||||
end generate gEL0;
|
||||
|
||||
gEL1: if ADD_EVENT_LOGGER = false 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;
|
||||
log_data_src(2) <= pd_pulse;
|
||||
log_data_src(3) <= enc_pulse;
|
||||
log_data_src(4) <= ch_pd;
|
||||
log_data_src(5) <= ch_pulse_out;
|
||||
log_data_src(6) <= ch_raw_pulse;
|
||||
log_data_src(7) <= ch_mask;
|
||||
log_data_src(8) <= pof_rx;
|
||||
log_data_src(9) <= fire_pulse_i;
|
||||
log_data_src(10) <= inc_pos;
|
||||
log_data_src(11) <= dec_pos;
|
||||
log_data_src(12) <= filtered_pd;
|
||||
--
|
||||
log_data_src(31 downto 13) <= (others => '0');
|
||||
|
||||
end generate gEL1;
|
||||
|
||||
end architecture rtl;
|
||||
357
generic_ip/fire_pulse_manager/2/src/pof_rx_2.vhd
Normal file
357
generic_ip/fire_pulse_manager/2/src/pof_rx_2.vhd
Normal file
|
|
@ -0,0 +1,357 @@
|
|||
-------------------------------------------------------------------------------
|
||||
-- Title : pof_rx_2
|
||||
-- Project : SMB
|
||||
-------------------------------------------------------------------------------
|
||||
-- File : pof_rx_2.vhd
|
||||
-- Author : Gianmarco Girau
|
||||
-- Company : Global Inkjet Systems
|
||||
-- Created : 2017-08-23
|
||||
-- Last update: 2019-05-29
|
||||
-- SVN ID : Git
|
||||
-- Standard : VHDL'08
|
||||
-------------------------------------------------------------------------------
|
||||
-- Description:
|
||||
-- Deserializes and decodes the EMS (SMB) output, received from the POF.
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
use ieee.numeric_std.all;
|
||||
|
||||
entity pof_rx_2 is
|
||||
port(
|
||||
reset_n : in std_logic;
|
||||
clk : in std_logic;
|
||||
--
|
||||
init : in std_logic;
|
||||
rx_clk : in std_logic;
|
||||
rx_data : in std_logic;
|
||||
init_out : out std_logic;
|
||||
dp_dir : in std_logic;
|
||||
enc_out : out std_logic;
|
||||
pd_out : out std_logic;
|
||||
inc_pos : out std_logic;
|
||||
dec_pos : out std_logic;
|
||||
abs_pos : out std_logic_vector(31 downto 0);
|
||||
-- C&S
|
||||
enable : in std_logic;
|
||||
bit_div : in std_logic_vector( 3 downto 0);
|
||||
error_rate_thres : in std_logic_vector( 7 downto 0);
|
||||
one_pps : in std_logic;
|
||||
upd_max_pos : in std_logic;
|
||||
upd_min_pos : in std_logic;
|
||||
max_error_flag : out std_logic;
|
||||
rx_watchdog : out std_logic;
|
||||
rx_watchdog_en : in std_logic;
|
||||
rx_watchdog_clr : in std_logic;
|
||||
parity_err_cnt : out std_logic_vector(15 downto 0);
|
||||
skip_pos_cnt : out std_logic_vector(15 downto 0));
|
||||
end entity pof_rx_2;
|
||||
|
||||
architecture rtl of pof_rx_2 is
|
||||
|
||||
-- check the parity bit (odd parity)
|
||||
function odd_parity_check(data : std_logic_vector) return std_logic is
|
||||
variable parity_bit : std_logic := '0';
|
||||
begin
|
||||
for n in 0 to data'length-1 loop
|
||||
parity_bit := parity_bit xor data(n);
|
||||
end loop; -- n
|
||||
return parity_bit;
|
||||
end function odd_parity_check;
|
||||
|
||||
-- Gray-to-Binary coding
|
||||
function gray2bin(gray : std_logic_vector) return std_logic_vector is
|
||||
variable bin : std_logic_vector(gray'range);
|
||||
begin
|
||||
bin(gray'length-1) := gray(gray'length-1);
|
||||
for i in gray'length-2 downto 0 loop
|
||||
bin(i) := bin(i+1) xor gray(i);
|
||||
end loop; -- n
|
||||
return bin;
|
||||
end function gray2bin;
|
||||
|
||||
signal clear, symbol_ok, inc_pos_i, dec_pos_i : std_logic;
|
||||
signal sync_gen, pd_gen, symbol_error, sync_d : std_logic;
|
||||
signal symbol_valid, symbol_valid_i, symbol_valid_d : std_logic;
|
||||
signal toggle_sync, sync_confirmed, sync_toggle_test, sync : std_logic;
|
||||
signal toggle_pd, pd_confirmed, pd_toggle_test, pd : std_logic;
|
||||
signal valid_pos, upd_pos, corr_done, corr_sign : std_logic;
|
||||
signal skip_pos, apply_corr, inc_pos_ii, dec_pos_ii : std_logic;
|
||||
signal new_max, new_min, rx_error, rx_error_i : std_logic;
|
||||
signal rx_symbol_val, clear_i, skip_pos_d, pos_recovery : std_logic;
|
||||
signal dp_dir_d, dp_dir_change, max_error_flag_i : std_logic;
|
||||
--
|
||||
signal clk_cnt : std_logic_vector( 1 downto 0);
|
||||
signal dist, abs_dist, skip_cnt : std_logic_vector( 3 downto 0);
|
||||
signal next_pos_lsb, curr_pos_lsb : std_logic_vector( 3 downto 0);
|
||||
signal pos_corr, max_dist, rx_error_v : std_logic_vector( 3 downto 0);
|
||||
signal gray_pos, rx_symbol_val_v : std_logic_vector( 3 downto 0);
|
||||
signal symbol, symbol_i, rx_symbol : std_logic_vector( 7 downto 0);
|
||||
signal rx_wd_cnt : std_logic_vector( 9 downto 0);
|
||||
signal parity_err_cnt_i, skip_pos_cnt_i : std_logic_vector(15 downto 0);
|
||||
signal error_rate_cnt, error_rate : std_logic_vector(15 downto 0);
|
||||
signal abs_pos_i, pos_max, pos_min : std_logic_vector(31 downto 0);
|
||||
signal dist_pos, dist_neg : std_logic_vector(31 downto 0);
|
||||
|
||||
begin
|
||||
|
||||
clear <= not enable or init;
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- De-serialize symbols (Serial clock at 200 MHz)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
iRX_SYMBOL : entity work.uart_rx
|
||||
generic map (
|
||||
data_width => 8)
|
||||
port map (
|
||||
reset_n => reset_n,
|
||||
clk => rx_clk,
|
||||
bit_div => bit_div,
|
||||
init => clear_i,
|
||||
data_out => rx_symbol,
|
||||
data_out_valid => rx_symbol_val,
|
||||
rx_error => rx_error,
|
||||
rx_data => rx_data);
|
||||
|
||||
-- Synchronize to the local clock
|
||||
pLATCH_RX_DATA : process(rx_clk)
|
||||
begin
|
||||
if(rx_clk = '1' and rx_clk'event) then
|
||||
if(rx_symbol_val = '1') then
|
||||
symbol <= rx_symbol;
|
||||
end if;
|
||||
if(rx_symbol_val = '1') then
|
||||
rx_symbol_val_v <= "1111";
|
||||
else
|
||||
rx_symbol_val_v <= '0' & rx_symbol_val_v(3 downto 1);
|
||||
end if;
|
||||
if(rx_error = '1') then
|
||||
rx_error_v <= "1111";
|
||||
else
|
||||
rx_error_v <= '0' & rx_error_v(3 downto 1);
|
||||
end if;
|
||||
end if;
|
||||
end process pLATCH_RX_DATA;
|
||||
|
||||
iSYNC_SYMBOL_VAL : entity work.sync_wire_rEdge
|
||||
generic map (rst_val => '0', sync_stages => 3)
|
||||
port map (rstN => reset_n, clk => clk, async_in => rx_symbol_val_v(0), sync_out => symbol_valid);
|
||||
|
||||
iSYNC_RX_ERROR : entity work.sync_wire_rEdge
|
||||
generic map (rst_val => '0', sync_stages => 3)
|
||||
port map (rstN => reset_n, clk => clk, async_in => rx_error_v(0), sync_out => rx_error_i);
|
||||
-- synchronize clear to tx_clk
|
||||
iSYNC_CLEAR: entity work.sync_wire
|
||||
generic map (rst_val => '1', sync_stages => 2)
|
||||
port map (
|
||||
rstN => reset_n, clk => rx_clk, async_in => clear, sync_out => clear_i);
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Toggle-Bits Decoding
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
pTOGGLE_DEC : process(clk)
|
||||
begin
|
||||
if(clk = '1' and clk'event) then
|
||||
-- Toggle Bits
|
||||
if(clear = '1') then
|
||||
toggle_sync <= '0';
|
||||
elsif(sync_confirmed = '1') then
|
||||
toggle_sync <= not toggle_sync;
|
||||
end if;
|
||||
if(clear = '1' or sync_confirmed = '1' or (symbol_valid_i = '1' and symbol_i(0) = toggle_sync)) then
|
||||
sync_toggle_test <= '0';
|
||||
elsif(sync_gen = '1') then
|
||||
sync_toggle_test <= '1';
|
||||
end if;
|
||||
sync <= sync_confirmed;
|
||||
sync_d <= sync;
|
||||
if(clear = '1') then
|
||||
toggle_pd <= '0';
|
||||
elsif(pd_confirmed = '1') then
|
||||
toggle_pd <= not toggle_pd;
|
||||
end if;
|
||||
if(clear = '1' or pd_confirmed = '1' or (symbol_valid_i = '1' and symbol_i(2) = toggle_pd)) then
|
||||
pd_toggle_test <= '0';
|
||||
elsif(pd_gen = '1') then
|
||||
pd_toggle_test <= '1';
|
||||
end if;
|
||||
pd <= pd_confirmed;
|
||||
--
|
||||
symbol_valid_i <= symbol_valid and symbol_ok;
|
||||
symbol_error <= symbol_valid and not symbol_ok;
|
||||
if(clear = '1') then
|
||||
parity_err_cnt_i <= (others => '0');
|
||||
elsif(symbol_error = '1') then
|
||||
parity_err_cnt_i <= std_logic_vector(unsigned(parity_err_cnt_i)+1);
|
||||
end if;
|
||||
end if;
|
||||
end process pTOGGLE_DEC;
|
||||
|
||||
symbol_i <= symbol;
|
||||
|
||||
-- The received symbol is assumed to be vaild when there is not parity error
|
||||
-- and when the two bits with the PD-toggle bit are equal
|
||||
symbol_ok <= '1' when odd_parity_check(symbol) = '1' and (symbol(1) = symbol(2)) else '0';
|
||||
|
||||
sync_gen <= '1' when symbol_valid_i = '1' and symbol_i(0) /= toggle_sync else '0';
|
||||
pd_gen <= '1' when symbol_valid_i = '1' and symbol_i(2) /= toggle_pd else '0';
|
||||
--
|
||||
sync_confirmed <= sync_gen and sync_toggle_test;
|
||||
pd_confirmed <= pd_gen and pd_toggle_test;
|
||||
--
|
||||
init_out <= sync;
|
||||
pd_out <= pd;
|
||||
|
||||
parity_err_cnt <= parity_err_cnt_i;
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Position management & Error Recovery
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
gray_pos <= symbol_i(6 downto 3);
|
||||
next_pos_lsb <= gray2bin(gray_pos);
|
||||
curr_pos_lsb <= abs_pos_i(3 downto 0);
|
||||
|
||||
--dist <= std_logic_vector(signed(next_pos_lsb)-signed(curr_pos_lsb));
|
||||
abs_dist <= dist when dist(3) = '0' else std_logic_vector(unsigned(not dist)+1);
|
||||
|
||||
pPOS_MNG : process(clk)
|
||||
begin
|
||||
if(clk = '1' and clk'event) then
|
||||
dist <= std_logic_vector(signed(next_pos_lsb)-signed(curr_pos_lsb));
|
||||
symbol_valid_d <= symbol_valid_i;
|
||||
if(clear = '1' or (symbol_valid_d = '1' and signed(dist) = 0) or pos_recovery = '1') then
|
||||
max_dist <= "0001";
|
||||
elsif(skip_pos = '1' or rx_error_i = '1') then
|
||||
max_dist <= std_logic_vector(unsigned(max_dist) + 1);
|
||||
end if;
|
||||
if(symbol_valid_d = '1' and valid_pos = '1') then
|
||||
pos_corr <= abs_dist;
|
||||
elsif(apply_corr = '1') then
|
||||
pos_corr <= std_logic_vector(unsigned(pos_corr)-1);
|
||||
end if;
|
||||
if(clear = '1' or corr_done = '1') then
|
||||
upd_pos <= '0';
|
||||
elsif(symbol_valid_d = '1' and valid_pos = '1') then
|
||||
upd_pos <= '1';
|
||||
end if;
|
||||
if(upd_pos = '0' or unsigned(clk_cnt) = 2) then
|
||||
clk_cnt <= (others => '0');
|
||||
else
|
||||
clk_cnt <= std_logic_vector(unsigned(clk_cnt)+1);
|
||||
end if;
|
||||
if(symbol_valid_d = '1' and valid_pos = '1') then
|
||||
corr_sign <= dist(3);
|
||||
end if;
|
||||
inc_pos_i <= inc_pos_ii;
|
||||
dec_pos_i <= dec_pos_ii;
|
||||
inc_pos <= inc_pos_i;
|
||||
dec_pos <= dec_pos_i;
|
||||
if(clear = '1' or sync = '1') then
|
||||
abs_pos_i <= (others => '0');
|
||||
elsif(inc_pos_ii = '1') then
|
||||
abs_pos_i <= std_logic_vector(signed(abs_pos_i)+1);
|
||||
elsif(dec_pos_ii = '1') then
|
||||
abs_pos_i <= std_logic_vector(signed(abs_pos_i)-1);
|
||||
end if;
|
||||
abs_pos <= abs_pos_i;
|
||||
skip_pos_d <= skip_pos;
|
||||
if(clear = '1' or (symbol_valid_d = '1' and valid_pos = '1')) then
|
||||
skip_cnt <= (others => '0');
|
||||
elsif(skip_pos = '1' and skip_pos_d = '0') then
|
||||
skip_cnt <= std_logic_vector(unsigned(skip_cnt)+1);
|
||||
end if;
|
||||
if(clear = '1') then
|
||||
skip_pos_cnt_i <= (others => '0');
|
||||
elsif(skip_pos_d = '1') then
|
||||
skip_pos_cnt_i <= std_logic_vector(unsigned(skip_pos_cnt_i)+1);
|
||||
end if;
|
||||
end if;
|
||||
end process pPOS_MNG;
|
||||
|
||||
skip_pos <= '1' when (symbol_valid = '1' and symbol_ok = '0') or (symbol_valid_d = '1' and valid_pos = '0' ) else '0';
|
||||
|
||||
pos_recovery <= '1' when unsigned(skip_cnt) >= 3 else '0';
|
||||
valid_pos <= '1' when unsigned(abs_dist) <= unsigned(max_dist) or pos_recovery = '1' else '0';
|
||||
|
||||
apply_corr <= '1' when upd_pos = '1' and clk_cnt = "01" else '0';
|
||||
corr_done <= '1' when signed(dist) = 0 else '0';
|
||||
|
||||
inc_pos_ii <= '1' when apply_corr = '1' and corr_sign = '0' else '0';
|
||||
dec_pos_ii <= '1' when apply_corr = '1' and corr_sign = '1' else '0';
|
||||
|
||||
skip_pos_cnt <= skip_pos_cnt_i;
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Additional logic for error reporting
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
pERROR_REPORTING : process(clk)
|
||||
begin
|
||||
if(clk = '1' and clk'event) then
|
||||
if(clear = '1' or one_pps = '1') then
|
||||
error_rate_cnt <= (others => '0');
|
||||
elsif(symbol_error = '1') then
|
||||
error_rate_cnt <= std_logic_vector(unsigned(error_rate_cnt)+1);
|
||||
end if;
|
||||
if(clear = '1') then
|
||||
error_rate <= (others => '0');
|
||||
elsif(one_pps = '1') then
|
||||
error_rate <= error_rate_cnt;
|
||||
end if;
|
||||
max_error_flag <= not clear and max_error_flag_i;
|
||||
if(clear = '1' or symbol_valid_i = '1' or rx_watchdog_clr = '1') then
|
||||
rx_wd_cnt <= (others => '0');
|
||||
else
|
||||
rx_wd_cnt <= std_logic_vector(unsigned(rx_wd_cnt)+1);
|
||||
end if;
|
||||
if(clear = '1' or rx_watchdog_clr = '1' or rx_watchdog_en = '0' or sync = '1') then
|
||||
rx_watchdog <= '0';
|
||||
elsif(unsigned(rx_wd_cnt) > 1000) then
|
||||
rx_watchdog <= '1';
|
||||
end if;
|
||||
end if;
|
||||
end process pERROR_REPORTING;
|
||||
|
||||
max_error_flag_i <= '1' when unsigned(error_rate) > unsigned(error_rate_thres) else '0';
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Encoder Pulse management
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
-- Encoder pulses are generated only when there is an increment of the
|
||||
-- position in the intended direction, which exceeds the previous maximum.
|
||||
-- The value of the maximum is reset in the following situations:
|
||||
-- 1. After a Init/Sync pulse
|
||||
-- 2. After a direction change
|
||||
-- 3. When the distance between the current position and the previous maximum
|
||||
-- exceeds a programmable threshold, where the threshold is a 32 bit signed
|
||||
-- number. Only the 16 MSBs of this threshold can be configured. The threshold
|
||||
-- is set to the maximum value by default (e.g.: (2^23 = 8388608)
|
||||
|
||||
pENC_MNG : process(clk)
|
||||
begin
|
||||
if(clk = '1' and clk'event) then
|
||||
dp_dir_d <= dp_dir;
|
||||
if(sync_d = '1' or dp_dir_change = '1' or new_max = '1' or upd_max_pos = '1') then
|
||||
pos_max <= abs_pos_i;
|
||||
end if;
|
||||
if(sync_d = '1' or dp_dir_change = '1' or new_min = '1' or upd_min_pos = '1') then
|
||||
pos_min <= abs_pos_i;
|
||||
end if;
|
||||
enc_out <= new_min or new_max;
|
||||
end if;
|
||||
end process pENC_MNG;
|
||||
|
||||
dp_dir_change <= dp_dir xor dp_dir_d;
|
||||
|
||||
dist_pos <= std_logic_vector(signed(abs_pos_i)-signed(pos_max));
|
||||
dist_neg <= std_logic_vector(signed(pos_min)-signed(abs_pos_i));
|
||||
|
||||
new_max <= '1' when inc_pos_i = '1' and dp_dir = '0' and dist_pos(31) = '0' and unsigned(dist_pos(3 downto 0)) /= 0 else '0';
|
||||
new_min <= '1' when dec_pos_i = '1' and dp_dir = '1' and dist_neg(31) = '0' and unsigned(dist_neg(3 downto 0)) /= 0 else '0';
|
||||
|
||||
end architecture rtl;
|
||||
701
generic_ip/fire_pulse_manager/2/src/smb_diagnostics_2.vhd
Normal file
701
generic_ip/fire_pulse_manager/2/src/smb_diagnostics_2.vhd
Normal file
|
|
@ -0,0 +1,701 @@
|
|||
-------------------------------------------------------------------------------
|
||||
-- Title : smb diagnostic block
|
||||
-- Project : SMB
|
||||
-------------------------------------------------------------------------------
|
||||
-- File : smb_diagnostics_2.vhd
|
||||
-- Author : Gianmarco Girau
|
||||
-- Company : Global Inkjet Systems
|
||||
-- Created : 2016-08-02
|
||||
-- Last update: 2019-05-29
|
||||
-- SVN ID : Git
|
||||
-- Standard : VHDL'2008
|
||||
-------------------------------------------------------------------------------
|
||||
-- Description: This block includes all the SMB diagnostic functionalities
|
||||
-- except the event logger.
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
use ieee.numeric_std.all;
|
||||
|
||||
entity smb_diagnostics_2 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_2;
|
||||
|
||||
architecture rtl of smb_diagnostics_2 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;
|
||||
169
generic_ip/fire_pulse_manager/2/src/uart_regen_2.vhd
Normal file
169
generic_ip/fire_pulse_manager/2/src/uart_regen_2.vhd
Normal file
|
|
@ -0,0 +1,169 @@
|
|||
-------------------------------------------------------------------------------
|
||||
-- Title : uart_regen_2
|
||||
-- Project : EMB-1
|
||||
-------------------------------------------------------------------------------
|
||||
-- File : uart_regen_2.vhd
|
||||
-- Author : Gianmarco Girau
|
||||
-- Company : Global Inkjet Systems
|
||||
-- Created : 2017-10-31
|
||||
-- Last update: 2019-05-29
|
||||
-- SVN ID : Git
|
||||
-- Standard : VHDL'08
|
||||
-------------------------------------------------------------------------------
|
||||
-- Description:
|
||||
-- Regenerate the UART signal
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
use ieee.numeric_std.all;
|
||||
|
||||
entity uart_regen_2 is
|
||||
generic(
|
||||
data_width : natural range 1 to 31);
|
||||
port(
|
||||
reset_n : in std_logic;
|
||||
clk : in std_logic;
|
||||
bit_div : in std_logic_vector(3 downto 0); -- number of clock cycles per tx bit
|
||||
enable : in std_logic;
|
||||
bypass_en : in std_logic;
|
||||
uart_rx : in std_logic;
|
||||
uart_tx : out std_logic);
|
||||
end entity uart_regen_2;
|
||||
|
||||
architecture rtl of uart_regen_2 is
|
||||
|
||||
component sync_wire
|
||||
generic (
|
||||
rst_val : std_logic;
|
||||
sync_stages : positive);
|
||||
port (
|
||||
rstN : in std_logic;
|
||||
clk : in std_logic;
|
||||
async_in : in std_logic;
|
||||
sync_out : out std_logic);
|
||||
end component;
|
||||
|
||||
type fsm_state_t is (s_init, s_idle, s_regen);
|
||||
|
||||
signal fsm_state_curr, fsm_state_next : fsm_state_t;
|
||||
--
|
||||
signal uart_rx_i, ld_data, rst_bit_cnt, inc_bit_cnt : std_logic;
|
||||
signal rst_clk_cnt, end_of_bit, end_of_rx : std_logic;
|
||||
signal uart_regen, uart_regen_i : std_logic;
|
||||
--
|
||||
signal clk_cnt : std_logic_vector(3 downto 0);
|
||||
signal bit_cnt : std_logic_vector(5 downto 0);
|
||||
|
||||
begin
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Input Synchronization
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
iSYNC_IN : sync_wire
|
||||
generic map (
|
||||
rst_val => '1',
|
||||
sync_stages => 3)
|
||||
port map (
|
||||
rstN => reset_n,
|
||||
clk => clk,
|
||||
async_in => uart_rx,
|
||||
sync_out => uart_rx_i);
|
||||
|
||||
-- NOTE : No NEED TO SYNCHRONIZE TO THE LOCAL CLOCK inputs enable, bypass_en
|
||||
-- and bit_biv BECAUSE THOSE SIGNALS ARE PREDOMINANTLY STATIC
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- UART registers and sequential logic
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
pREGs : process(clk)
|
||||
begin
|
||||
if(clk ='1' and clk'event) then
|
||||
if(rst_bit_cnt = '1') then
|
||||
bit_cnt <= (others => '0');
|
||||
elsif(inc_bit_cnt = '1') then
|
||||
bit_cnt <= std_logic_vector(unsigned(bit_cnt)+1);
|
||||
end if;
|
||||
if(rst_clk_cnt = '1' or end_of_bit = '1') then
|
||||
clk_cnt <= (others => '0');
|
||||
else
|
||||
clk_cnt <= std_logic_vector(unsigned(clk_cnt)+1);
|
||||
end if;
|
||||
if(enable = '0') then
|
||||
uart_regen_i <= '1';
|
||||
elsif(ld_data = '1') then
|
||||
uart_regen_i <= uart_rx_i;
|
||||
end if;
|
||||
uart_regen <= uart_regen_i;
|
||||
end if;
|
||||
end process pREGs;
|
||||
|
||||
end_of_bit <= '1' when unsigned(clk_cnt) = (unsigned(bit_div)-1) else '0';
|
||||
end_of_rx <= '1' when unsigned(bit_cnt) = data_width+1 else '0';
|
||||
|
||||
-- output mux
|
||||
uart_tx <= uart_rx when bypass_en = '1' else uart_regen;
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- FSM
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
-- FSM state register
|
||||
pFSM_SR : process(clk)
|
||||
begin
|
||||
if(clk = '1' and clk'event) then
|
||||
if(enable = '0' or bypass_en = '1') then
|
||||
fsm_state_curr <= s_init;
|
||||
else
|
||||
fsm_state_curr <= fsm_state_next;
|
||||
end if;
|
||||
end if;
|
||||
end process pFSM_SR;
|
||||
|
||||
-- FSM Combinational Logic
|
||||
pFSM_CL : process(fsm_state_curr, uart_rx_i, end_of_bit, end_of_rx, clk_cnt, bit_div)
|
||||
begin
|
||||
--default assignments
|
||||
rst_clk_cnt <= '0';
|
||||
rst_bit_cnt <= '0';
|
||||
inc_bit_cnt <= '0';
|
||||
ld_data <= '0';
|
||||
--
|
||||
fsm_state_next <= fsm_state_curr;
|
||||
|
||||
case fsm_state_curr is
|
||||
when s_init =>
|
||||
if(uart_rx_i = '1') then
|
||||
fsm_state_next <= s_idle;
|
||||
end if;
|
||||
|
||||
when s_idle =>
|
||||
if(uart_rx_i = '0') then
|
||||
rst_clk_cnt <= '1';
|
||||
rst_bit_cnt <= '1';
|
||||
fsm_state_next <= s_regen;
|
||||
end if;
|
||||
|
||||
when s_regen =>
|
||||
if(unsigned(clk_cnt) = (unsigned(bit_div(bit_div'high downto 1))-1)) then
|
||||
ld_data <= '1';
|
||||
end if;
|
||||
if(end_of_bit = '1') then
|
||||
inc_bit_cnt <= '1';
|
||||
if(end_of_rx = '1') then
|
||||
if(uart_rx_i = '1') then
|
||||
fsm_state_next <= s_idle;
|
||||
else
|
||||
fsm_state_next <= s_init;
|
||||
end if;
|
||||
end if;
|
||||
end if;
|
||||
|
||||
when others => null;
|
||||
end case;
|
||||
end process pFSM_CL;
|
||||
|
||||
|
||||
end architecture rtl;
|
||||
1
generic_ip/pulse_generator/2/Readme.txt
Normal file
1
generic_ip/pulse_generator/2/Readme.txt
Normal file
|
|
@ -0,0 +1 @@
|
|||
This major version of the Pulse-Generator is a custom build for W&H, with dedicated logic for managing Flexo and CI wheels corrections
|
||||
|
|
@ -10,6 +10,7 @@ add wave -noupdate /ch_ctrl_cfg_tb/div_ratio_r
|
|||
add wave -noupdate -radix hexadecimal /ch_ctrl_cfg_tb/iUUT/div_ratio
|
||||
add wave -noupdate -radix hexadecimal /ch_ctrl_cfg_tb/iUUT/div_ratio_i
|
||||
add wave -noupdate -radix hexadecimal /ch_ctrl_cfg_tb/iUUT/div_ratio_corr
|
||||
add wave -noupdate /ch_ctrl_cfg_tb/wh_pos_err_r
|
||||
add wave -noupdate /ch_ctrl_cfg_tb/init
|
||||
add wave -noupdate /ch_ctrl_cfg_tb/pd_in
|
||||
add wave -noupdate /ch_ctrl_cfg_tb/wheel_pos
|
||||
|
|
@ -35,6 +36,25 @@ add wave -noupdate /ch_ctrl_cfg_tb/setup
|
|||
add wave -noupdate /ch_ctrl_cfg_tb/running
|
||||
add wave -noupdate /ch_ctrl_cfg_tb/passed
|
||||
add wave -noupdate /ch_ctrl_cfg_tb/failed
|
||||
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/wh_apply_corr_en
|
||||
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/wh_error_meas_avail
|
||||
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/wh_corr_ready
|
||||
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/wh_error_meas_started
|
||||
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/init_wh
|
||||
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/loc_pd_d
|
||||
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/wh_meas_event
|
||||
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/ch_mask_fe
|
||||
add wave -noupdate -radix decimal /ch_ctrl_cfg_tb/iUUT/basic_pos_error
|
||||
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/wh_pos_err
|
||||
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/wh_pos_err_max
|
||||
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/wh_pos_err_abs
|
||||
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/wh_pos_err_2_corr
|
||||
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/div_ratio_corr_i
|
||||
add wave -noupdate -radix decimal /ch_ctrl_cfg_tb/iUUT/pos_error
|
||||
add wave -noupdate -radix hexadecimal /ch_ctrl_cfg_tb/iUUT/div_ratio_corr_ext
|
||||
add wave -noupdate -radix hexadecimal /ch_ctrl_cfg_tb/iUUT/div_ratio
|
||||
add wave -noupdate -radix hexadecimal /ch_ctrl_cfg_tb/iUUT/div_ratio_i
|
||||
add wave -noupdate -radix hexadecimal /ch_ctrl_cfg_tb/iUUT/div_ratio_corr
|
||||
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/clk
|
||||
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/reset_n
|
||||
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/init
|
||||
|
|
@ -173,7 +193,7 @@ add wave -noupdate -radix hexadecimal /ch_ctrl_cfg_tb/iUUT/div_ratio
|
|||
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/div_ratio_i
|
||||
add wave -noupdate /ch_ctrl_cfg_tb/iUUT/div_ratio_corr
|
||||
TreeUpdate [SetDefaultTree]
|
||||
WaveRestoreCursors {{Cursor 1} {6965000 ps} 1} {{Cursor 2} {15967382293 ps} 0}
|
||||
WaveRestoreCursors {{Cursor 1} {6965000 ps} 1} {{Cursor 2} {219085000 ps} 0}
|
||||
quietly wave cursor active 2
|
||||
configure wave -namecolwidth 293
|
||||
configure wave -valuecolwidth 216
|
||||
|
|
@ -189,4 +209,4 @@ configure wave -griddelta 40
|
|||
configure wave -timeline 0
|
||||
configure wave -timelineunits ps
|
||||
update
|
||||
WaveRestoreZoom {13992428918 ps} {17707009398 ps}
|
||||
WaveRestoreZoom {0 ps} {3714580480 ps}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
-- Author : Gianmarco Girau
|
||||
-- Company : Global Inkjet Systems
|
||||
-- Created : 2016-10-24
|
||||
-- Last update: 2019-05-24
|
||||
-- Last update: 2019-05-29
|
||||
-- SVN ID : Git
|
||||
-- Standard : VHDL'93
|
||||
-------------------------------------------------------------------------------
|
||||
|
|
@ -96,8 +96,12 @@ architecture rtl of pulse_generator_2 is
|
|||
signal close_to_zero, close_to_mid, bypass_pulse_cond : std_logic;
|
||||
signal div_pulse_i, spitting_enable, spit_pulse : std_logic;
|
||||
signal seq_bus_valid, spit_nco_msb : std_logic;
|
||||
signal wh_apply_corr_en, wh_error_meas_avail, wh_corr_ready : std_logic;
|
||||
signal wh_error_meas_started, init_wh, loc_pd_d : std_logic;
|
||||
signal wh_meas_event, ch_mask_fe, first_pd_arrived : std_logic;
|
||||
--
|
||||
signal abs_pos_msb_old : std_logic_vector( 1 downto 0);
|
||||
signal wh_corr_ready_v : std_logic_vector( 2 downto 0);
|
||||
signal ch_ctrl_csr_addr, ch_ctrl_trigger_in : std_logic_vector( 3 downto 0);
|
||||
signal avs_addr : std_logic_vector( 4 downto 0);
|
||||
signal pulse_width, pulse_width_ext, init_v : std_logic_vector( 7 downto 0);
|
||||
|
|
@ -105,9 +109,11 @@ architecture rtl of pulse_generator_2 is
|
|||
signal ch_ctrl_address : std_logic_vector( 7 downto 0);
|
||||
signal avs_address_i : std_logic_vector( 9 downto 0);
|
||||
signal overdrive_events, overdrive_thres : std_logic_vector(15 downto 0);
|
||||
signal pulse_interval : std_logic_vector(15 downto 0);
|
||||
signal pulse_interval, basic_pos_error : std_logic_vector(15 downto 0);
|
||||
signal img_size, pixel_cnt : std_logic_vector(23 downto 0);
|
||||
signal ch_ctrl_vector_out : std_logic_vector(23 downto 0);
|
||||
signal wh_pos_err, wh_pos_err_max : std_logic_vector(23 downto 0);
|
||||
signal wh_pos_err_abs : std_logic_vector(23 downto 0);
|
||||
signal ch_offset, ch_delay, avs_readdata_i : std_logic_vector(31 downto 0);
|
||||
signal ch_ctrl_writedata, ch_ctrl_readdata : std_logic_vector(31 downto 0);
|
||||
signal ch_ctrl_csr_writedata : std_logic_vector(31 downto 0);
|
||||
|
|
@ -117,8 +123,12 @@ architecture rtl of pulse_generator_2 is
|
|||
signal last_pd_pos : std_logic_vector(31 downto 0);
|
||||
signal pd_in_cnt, fire_req_cnt : std_logic_vector(31 downto 0);
|
||||
signal seq_bus_data, spit_nco, spit_nco_inc : std_logic_vector(31 downto 0);
|
||||
signal div_offset, div_ratio : std_logic_vector(33 downto 0);
|
||||
signal div_ratio_i, div_ratio_corr : std_logic_vector(33 downto 0);
|
||||
signal start_pos, abs_pos_d : std_logic_vector(31 downto 0);
|
||||
signal wh_pos_err_2_corr : std_logic_vector(31 downto 0);
|
||||
signal div_offset, div_ratio, div_ratio_i : std_logic_vector(33 downto 0);
|
||||
signal div_ratio_corr, div_ratio_corr_i : std_logic_vector(33 downto 0);
|
||||
signal pos_error : std_logic_vector(39 downto 0);
|
||||
signal div_ratio_corr_ext : std_logic_vector(55 downto 0);
|
||||
|
||||
begin
|
||||
|
||||
|
|
@ -394,13 +404,71 @@ begin
|
|||
pDIV_RATIO_CORR : process(clk)
|
||||
begin
|
||||
if(clk = '1' and clk'event) then
|
||||
if(init = '1' or enable = '0') then
|
||||
-- latch the absolute-position to prevent excessive degradation of timing
|
||||
abs_pos_d <= abs_position;
|
||||
ch_mask_fe <= not ch_mask_i and ch_mask_d;
|
||||
loc_pd_d <= loc_pd;
|
||||
init_wh <= init or (not enable) or (not wh_apply_corr_en);
|
||||
if(init_wh = '1') then
|
||||
div_ratio_corr <= (others => '0');
|
||||
elsif(wh_corr_ready = '1') then
|
||||
div_ratio_corr <= div_ratio_corr_i;
|
||||
end if;
|
||||
div_ratio_i <= std_logic_vector(signed(div_ratio)+signed(div_ratio_corr));
|
||||
if(init_wh = '1' ) then
|
||||
first_pd_arrived <= '0';
|
||||
elsif(loc_pd_d = '1') then
|
||||
first_pd_arrived <= '1';
|
||||
end if;
|
||||
if(init_wh = '1' ) then
|
||||
wh_error_meas_started <= '0';
|
||||
elsif(wh_meas_event = '1' and first_pd_arrived = '1') then
|
||||
wh_error_meas_started <= not wh_error_meas_started;
|
||||
end if;
|
||||
if(wh_meas_event = '1' and wh_error_meas_started = '0') then
|
||||
start_pos <= abs_pos_d;
|
||||
end if;
|
||||
if((loc_pd_d and ch_mask_fe) = '1') then
|
||||
basic_pos_error <= (others => '0');
|
||||
elsif(wh_meas_event = '1' and wh_error_meas_started = '1') then
|
||||
if(loc_pd_d = '1') then
|
||||
basic_pos_error <= std_logic_vector(resize(signed(abs_pos_d)-signed(start_pos), basic_pos_error'length));
|
||||
else
|
||||
basic_pos_error <= std_logic_vector(resize(signed(start_pos)-signed(abs_pos_d), basic_pos_error'length));
|
||||
end if;
|
||||
end if;
|
||||
if(wh_error_meas_started = '1' and (loc_pd_d or ch_mask_fe) = '1') then
|
||||
wh_error_meas_avail <= '1';
|
||||
else
|
||||
wh_error_meas_avail <= '0';
|
||||
end if;
|
||||
wh_corr_ready_v <= wh_corr_ready_v(wh_corr_ready_v'left-1 downto 0) & wh_error_meas_avail;
|
||||
pos_error <= std_logic_vector(signed(basic_pos_error & 24x"0") - signed(div_ratio));
|
||||
div_ratio_corr_ext <= std_logic_vector(signed(wh_pos_err)*signed(wh_pos_err_2_corr));
|
||||
-- Compute the absolute value of the position-error. Use a simple 1's
|
||||
-- complement if you need to do sign inversion
|
||||
if(wh_pos_err(wh_pos_err'left) = '1') then
|
||||
wh_pos_err_abs <= not wh_pos_err;
|
||||
else
|
||||
wh_pos_err_abs <= wh_pos_err;
|
||||
end if;
|
||||
if(init_wh = '1') then
|
||||
wh_pos_err_max <= (others => '0');
|
||||
elsif(wh_corr_ready = '1' and unsigned(wh_pos_err_abs) > unsigned(wh_pos_err_max)) then
|
||||
wh_pos_err_max <= wh_pos_err_abs;
|
||||
end if;
|
||||
end if;
|
||||
end process pDIV_RATIO_CORR;
|
||||
|
||||
wh_meas_event <= loc_pd_d xor ch_mask_fe;
|
||||
|
||||
div_ratio_corr_i <= std_logic_vector(resize(signed(div_ratio_corr_ext(div_ratio_corr_ext'left downto 16)),div_ratio'length));
|
||||
|
||||
wh_corr_ready <= wh_corr_ready_v(wh_corr_ready_v'left);
|
||||
|
||||
-- No need to use 24 bits mantissa for pos_error, 8 bits are plenty
|
||||
wh_pos_err <= pos_error(pos_error'left downto 16);
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Spitting logic
|
||||
-----------------------------------------------------------------------------
|
||||
|
|
@ -654,9 +722,12 @@ begin
|
|||
--
|
||||
div_offset <= (others => '0');
|
||||
div_ratio <= (others => '0');
|
||||
--
|
||||
wh_apply_corr_en <= '0';
|
||||
wh_pos_err_2_corr <= (others => '0');
|
||||
elsif(clk = '1' and clk'event) then
|
||||
-- CTRL registers
|
||||
if(avs_write_i = '1' and avs_address(9 downto 4) = "000000") then
|
||||
if(avs_write_i = '1' and avs_address(9 downto 5) = "00000") then
|
||||
case avs_addr is
|
||||
when PULSE_GEN_CTRL_REG =>
|
||||
enable_i <= avs_writedata(0);
|
||||
|
|
@ -664,6 +735,7 @@ begin
|
|||
bypass_pulse_cond <= avs_writedata(2);
|
||||
bypass_delay_equal <= avs_writedata(3);
|
||||
sw_ctrl_dp_dir <= avs_writedata(4);
|
||||
wh_apply_corr_en <= avs_writedata(11);
|
||||
enable_out <= avs_writedata(16);
|
||||
abort_fire <= avs_writedata(17);
|
||||
rst_diag_regs <= avs_writedata(18);
|
||||
|
|
@ -694,6 +766,8 @@ begin
|
|||
div_offset(33 downto 24) <= avs_writedata( 9 downto 0);
|
||||
when SP_OFFSET_FRAC =>
|
||||
div_offset(23 downto 0) <= avs_writedata(23 downto 0);
|
||||
when WH_POS_ERR_2_CORR_REG =>
|
||||
wh_pos_err_2_corr <= avs_writedata;
|
||||
when others => null;
|
||||
end case;
|
||||
end if;
|
||||
|
|
@ -708,7 +782,8 @@ begin
|
|||
when CSR_IP_VER_ADDR =>
|
||||
avs_readdata_i <= CSR_IP_VER;
|
||||
when PULSE_GEN_CTRL_REG =>
|
||||
avs_readdata_i(31 downto 8) <= (8 => ch_mask_i, 9 => fire_enable, 10 => dp_dir, 16 => enable_out, 17 => abort_fire, 18 => rst_diag_regs, others => '0');
|
||||
avs_readdata_i(31 downto 8) <= (8 => ch_mask_i, 9 => fire_enable, 10 => dp_dir, 11 => wh_apply_corr_en,
|
||||
16 => enable_out, 17 => abort_fire, 18 => rst_diag_regs, others => '0');
|
||||
avs_readdata_i( 7 downto 4) <= b"0" & de_queue_error & pd_queue_error & sw_ctrl_dp_dir;
|
||||
avs_readdata_i( 3 downto 0) <= bypass_delay_equal & bypass_pulse_cond & bypass_ch_ctrl & enable_i;
|
||||
when CH_OFFSET_D0_REG =>
|
||||
|
|
@ -746,6 +821,12 @@ begin
|
|||
avs_readdata_i <= pd_in_cnt;
|
||||
when FIRE_REQ_CNT_REG =>
|
||||
avs_readdata_i <= fire_req_cnt;
|
||||
when WH_POS_ERR_2_CORR_REG =>
|
||||
avs_readdata_i <= wh_pos_err_2_corr;
|
||||
when WH_POS_ERR_CURR_REG =>
|
||||
avs_readdata_i <= X"00" & wh_pos_err;
|
||||
when WH_POS_ERR_MAX_REG =>
|
||||
avs_readdata_i <= X"00" & wh_pos_err_max;
|
||||
when others =>
|
||||
avs_readdata_i <= X"BAD1BAD0";
|
||||
end case;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
-- Author : GMG
|
||||
-- Company : Global Inkjet Systems
|
||||
-- Created : 2018-08-22
|
||||
-- Last update: 2019-05-22
|
||||
-- Last update: 2019-05-28
|
||||
-- SVN ID : Git
|
||||
-- Standard : VHDL'2008
|
||||
-------------------------------------------------------------------------------
|
||||
|
|
@ -21,26 +21,29 @@ use ieee.numeric_std.all;
|
|||
|
||||
package pulse_generator_2_pkg is
|
||||
|
||||
constant CSR_IP_ID_ADDR : std_logic_vector( 4 downto 0) := 5x"00";
|
||||
constant CSR_IP_VER_ADDR : std_logic_vector( 4 downto 0) := 5x"01";
|
||||
constant PULSE_GEN_CTRL_REG : std_logic_vector( 4 downto 0) := 5x"02";
|
||||
constant CH_OFFSET_D0_REG : std_logic_vector( 4 downto 0) := 5x"03";
|
||||
constant CH_OFFSET_D1_REG : std_logic_vector( 4 downto 0) := 5x"04";
|
||||
constant CH_DELAY_REG : std_logic_vector( 4 downto 0) := 5x"05";
|
||||
constant CH_CTRL_CTRL_REG : std_logic_vector( 4 downto 0) := 5x"06";
|
||||
constant FRAC_DIV_CTRL_REG : std_logic_vector( 4 downto 0) := 5x"07";
|
||||
constant PULSE_WIDTH_REG : std_logic_vector( 4 downto 0) := 5x"08";
|
||||
constant OVERDRV_THRES_REG : std_logic_vector( 4 downto 0) := 5x"09";
|
||||
constant OVERDRV_EVENT_REG : std_logic_vector( 4 downto 0) := 5x"0A";
|
||||
constant DIV_RATIO_INT : std_logic_vector( 4 downto 0) := 5x"0B";
|
||||
constant DIV_RATIO_FRAC : std_logic_vector( 4 downto 0) := 5x"0C";
|
||||
constant SP_OFFSET_INT : std_logic_vector( 4 downto 0) := 5x"0D";
|
||||
constant SP_OFFSET_FRAC : std_logic_vector( 4 downto 0) := 5x"0E";
|
||||
constant POS_MAX_REG : std_logic_vector( 4 downto 0) := 5x"0F";
|
||||
constant POS_MIN_REG : std_logic_vector( 4 downto 0) := 5x"10";
|
||||
constant ABS_POS_STAT : std_logic_vector( 4 downto 0) := 5x"11";
|
||||
constant PD_IN_CNT_REG : std_logic_vector( 4 downto 0) := 5x"12";
|
||||
constant FIRE_REQ_CNT_REG : std_logic_vector( 4 downto 0) := 5x"13";
|
||||
constant CSR_IP_ID_ADDR : std_logic_vector(4 downto 0) := 5x"00";
|
||||
constant CSR_IP_VER_ADDR : std_logic_vector(4 downto 0) := 5x"01";
|
||||
constant PULSE_GEN_CTRL_REG : std_logic_vector(4 downto 0) := 5x"02";
|
||||
constant CH_OFFSET_D0_REG : std_logic_vector(4 downto 0) := 5x"03";
|
||||
constant CH_OFFSET_D1_REG : std_logic_vector(4 downto 0) := 5x"04";
|
||||
constant CH_DELAY_REG : std_logic_vector(4 downto 0) := 5x"05";
|
||||
constant CH_CTRL_CTRL_REG : std_logic_vector(4 downto 0) := 5x"06";
|
||||
constant FRAC_DIV_CTRL_REG : std_logic_vector(4 downto 0) := 5x"07";
|
||||
constant PULSE_WIDTH_REG : std_logic_vector(4 downto 0) := 5x"08";
|
||||
constant OVERDRV_THRES_REG : std_logic_vector(4 downto 0) := 5x"09";
|
||||
constant OVERDRV_EVENT_REG : std_logic_vector(4 downto 0) := 5x"0A";
|
||||
constant DIV_RATIO_INT : std_logic_vector(4 downto 0) := 5x"0B";
|
||||
constant DIV_RATIO_FRAC : std_logic_vector(4 downto 0) := 5x"0C";
|
||||
constant SP_OFFSET_INT : std_logic_vector(4 downto 0) := 5x"0D";
|
||||
constant SP_OFFSET_FRAC : std_logic_vector(4 downto 0) := 5x"0E";
|
||||
constant POS_MAX_REG : std_logic_vector(4 downto 0) := 5x"0F";
|
||||
constant POS_MIN_REG : std_logic_vector(4 downto 0) := 5x"10";
|
||||
constant ABS_POS_STAT : std_logic_vector(4 downto 0) := 5x"11";
|
||||
constant PD_IN_CNT_REG : std_logic_vector(4 downto 0) := 5x"12";
|
||||
constant FIRE_REQ_CNT_REG : std_logic_vector(4 downto 0) := 5x"13";
|
||||
constant WH_POS_ERR_2_CORR_REG : std_logic_vector(4 downto 0) := 5x"14";
|
||||
constant WH_POS_ERR_CURR_REG : std_logic_vector(4 downto 0) := 5x"15";
|
||||
constant WH_POS_ERR_MAX_REG : std_logic_vector(4 downto 0) := 5x"16";
|
||||
|
||||
constant SEQ_CSR_OFFSET : std_logic_vector(9 downto 0) := 10x"20";
|
||||
constant SEQ_RAM_OFFSET : std_logic_vector(9 downto 0) := 10x"200";
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
-- Author : GMG
|
||||
-- Company : Global Inkjet Systems
|
||||
-- Created : 2019-05-17
|
||||
-- Last update: 2019-05-24
|
||||
-- Last update: 2019-05-29
|
||||
-- SVN ID : Git
|
||||
-- Standard : VHDL'2008
|
||||
-------------------------------------------------------------------------------
|
||||
|
|
@ -61,7 +61,14 @@ architecture behav of ch_ctrl_cfg_tb is
|
|||
-- constant SIM_ROTATIONS : natural := TOTAL_ROTATIONS;
|
||||
constant SIM_ROTATIONS : natural := 90;
|
||||
|
||||
constant APPLY_CORR_EN : boolean := true;
|
||||
constant APPLY_CORR_EN : boolean := true;
|
||||
constant APPLY_EMUL_CORR : boolean := false;
|
||||
|
||||
--constant INIT_ABS_POS : std_logic_vector(31 downto 0) := (others => '0');
|
||||
--constant INIT_ABS_POS : std_logic_vector(31 downto 0) := X"7FFFFFCD"; -- (0x7FFFFFFF - 50)
|
||||
--constant INIT_ABS_POS : std_logic_vector(31 downto 0) := X"7FFFFE5A"; -- (0x7FFFFFFF - 421)
|
||||
constant INIT_ABS_POS : std_logic_vector(31 downto 0) := X"FFFFFE5A"; -- (0xFFFFFFFF - 421)
|
||||
|
||||
|
||||
type wheel_error_t is array (0 to TOTAL_ROTATIONS-1) of integer;
|
||||
|
||||
|
|
@ -75,8 +82,7 @@ architecture behav of ch_ctrl_cfg_tb is
|
|||
0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 1, 1,
|
||||
1, 1, 0, 0, -1, -1, -1, -1, 0, 0, others => 0);
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
signal wheel_error : wheel_error_t := (
|
||||
0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
|
||||
2, 2, 3, 3, 4, 4, 5, 5, 4, 4,
|
||||
|
|
@ -85,8 +91,8 @@ architecture behav of ch_ctrl_cfg_tb is
|
|||
-3, -3, -2, -2, -1, -1, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 1, 1,
|
||||
1, 1, 0, 0, -1, -1, -1, -1, 0, 0, -40, 0, 0, +80, others => 0);
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
signal wheel_error : wheel_error_t := (
|
||||
0, 0, 0, 0, 0, -1, -1, -1, -1, -1,
|
||||
-2, -2, -3, -3, -4, -4, -5, -5, -4, -4,
|
||||
|
|
@ -95,6 +101,7 @@ architecture behav of ch_ctrl_cfg_tb is
|
|||
3, 3, 2, 2, 1, 1, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 1, 1,
|
||||
1, 1, 0, 0, -1, -1, -1, -1, 0, 0, -40, 0, 0, +80, others => 0);
|
||||
*/
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Signal declarations
|
||||
|
|
@ -138,6 +145,7 @@ architecture behav of ch_ctrl_cfg_tb is
|
|||
signal rotation_idx : natural;
|
||||
signal div_ratio_corr_r : real;
|
||||
signal div_ratio_r : real;
|
||||
signal wh_pos_err_r : real;
|
||||
|
||||
|
||||
|
||||
|
|
@ -316,9 +324,14 @@ architecture behav of ch_ctrl_cfg_tb is
|
|||
data := (0 => '1', others => '0');
|
||||
mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
|
||||
|
||||
-- enable the pulse scaler
|
||||
-- Compute and constant for W&H Correction
|
||||
addr := std_logic_vector(resize(unsigned(WH_POS_ERR_2_CORR_REG), 32));
|
||||
data := std_logic_vector(to_unsigned(integer(round((1.0/real(IMG_LEN))*(2.0**32))), 32));
|
||||
mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
|
||||
|
||||
-- enable the pulse-generator + Enable W&H Correction
|
||||
addr := std_logic_vector(resize(unsigned(PULSE_GEN_CTRL_REG), 32));
|
||||
data := (0 => '1', 16 => '1', others => '0');
|
||||
data := (0 => '1', 11 => '1', 16 => '1', others => '0');
|
||||
mm_32b_write(addr, data, mm_s_rec, mm_m_rec);
|
||||
|
||||
log_separator_line(VMEDIUM);
|
||||
|
|
@ -360,6 +373,14 @@ begin -- architecture behav
|
|||
avs_readdatavalid => avs_readdatavalid,
|
||||
avs_readdata => avs_readdata);
|
||||
|
||||
|
||||
pGET_WH_ERR : process
|
||||
alias wh_pos_err is <<signal iUUT.wh_pos_err : std_logic_vector(23 downto 0)>>;
|
||||
begin
|
||||
wh_pos_err_r <= real(to_integer(signed(wh_pos_err)))/256.0;
|
||||
wait until clk = '1' and clk'event;
|
||||
end process pGET_WH_ERR;
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Avalon interface
|
||||
-----------------------------------------------------------------------------
|
||||
|
|
@ -403,7 +424,7 @@ begin -- architecture behav
|
|||
pd_in <= '0';
|
||||
pd_in_cnt <= 0;
|
||||
--
|
||||
abs_position <= (others => '0');
|
||||
abs_position <= INIT_ABS_POS;
|
||||
wheel_pos <= 0;
|
||||
|
||||
-- wait until init is deasserted
|
||||
|
|
@ -464,18 +485,44 @@ begin -- architecture behav
|
|||
begin
|
||||
-- read first the current value of the correction
|
||||
--div_ratio_corr_r <= div_ratio_corr_r + (pos_error*(DIV_RATIO/WHEEL_CIRCUM));
|
||||
div_ratio_new := div_ratio_r + (pos_error*(DIV_RATIO/WHEEL_CIRCUM));
|
||||
div_ratio_new := div_ratio_r + (pos_error*(1.0/real(IMG_LEN)));
|
||||
div_ratio_corr_r <= div_ratio_new - DIV_RATIO;
|
||||
|
||||
div_ratio_vec(33 downto 24) := std_logic_vector(to_unsigned(integer(floor(div_ratio_new)),10));
|
||||
div_ratio_man := (div_ratio_new - floor(div_ratio_new))*(2.0**24);
|
||||
div_ratio_vec(23 downto 0) := std_logic_vector(to_unsigned(integer(floor(div_ratio_man)),24));
|
||||
-- force the correction into the UUT:
|
||||
div_ratio_i <= force div_ratio_vec;
|
||||
if(APPLY_EMUL_CORR = true) then
|
||||
div_ratio_i <= force div_ratio_vec;
|
||||
end if;
|
||||
-- save the correction value
|
||||
log("Division Ratio Correction =" & to_string(div_ratio_new-DIV_RATIO) & ".", VMEDIUM);
|
||||
|
||||
end procedure apply_correction;
|
||||
|
||||
-- The correction is computed emulating fixed-point numbers
|
||||
-- (pos_err-to-correction is represented with a 32 bits mantissa)
|
||||
procedure apply_correction_int(pos_error: in real) is
|
||||
variable div_ratio_new : real;
|
||||
variable div_ratio_man : real;
|
||||
variable div_ratio_vec : std_logic_vector(33 downto 0);
|
||||
variable pos_err_to_corr : integer := integer(round((1.0/real(IMG_LEN))*(2.0**32)));
|
||||
begin
|
||||
-- read first the current value of the correction
|
||||
div_ratio_new := div_ratio_r + (pos_error*real(pos_err_to_corr)/(2.0**32));
|
||||
div_ratio_corr_r <= div_ratio_new - DIV_RATIO;
|
||||
|
||||
div_ratio_vec(33 downto 24) := std_logic_vector(to_unsigned(integer(floor(div_ratio_new)),10));
|
||||
div_ratio_man := (div_ratio_new - floor(div_ratio_new))*(2.0**24);
|
||||
div_ratio_vec(23 downto 0) := std_logic_vector(to_unsigned(integer(floor(div_ratio_man)),24));
|
||||
-- force the correction into the UUT:
|
||||
if(APPLY_EMUL_CORR = true) then
|
||||
div_ratio_i <= force div_ratio_vec;
|
||||
end if;
|
||||
-- save the correction value
|
||||
log("Division Ratio Correction =" & to_string(div_ratio_new-DIV_RATIO) & ".", VMEDIUM);
|
||||
|
||||
end procedure apply_correction_int;
|
||||
|
||||
begin
|
||||
|
||||
|
|
@ -514,7 +561,7 @@ begin -- architecture behav
|
|||
start_pos := to_integer(signed(abs_position));
|
||||
measure_started := true;
|
||||
else
|
||||
pos_error <= -(real(to_integer(signed(abs_position)) - start_pos) + DIV_RATIO);
|
||||
pos_error <= -(real(to_integer(signed(abs_position)) - start_pos)) - DIV_RATIO;
|
||||
rotation_idx <= rotation_idx + 1;
|
||||
measure_started := false;
|
||||
pos_error_avail := true;
|
||||
|
|
@ -525,7 +572,8 @@ begin -- architecture behav
|
|||
wait until clk = '0' and clk'event;
|
||||
log("Rotation #" & to_string(rotation_idx) & ": pos_error = " & to_string(pos_error) & ".", VMEDIUM);
|
||||
if(APPLY_CORR_EN = true) then
|
||||
apply_correction(pos_error);
|
||||
--apply_correction(pos_error);
|
||||
apply_correction_int(pos_error);
|
||||
end if;
|
||||
pos_error_avail := false;
|
||||
end if;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue