ELGIP-22 Added files for FPM ver 1.0
This commit is contained in:
parent
61a5d2d13b
commit
d80e0b795d
15 changed files with 2378 additions and 0 deletions
310
generic_ip/fire_pulse_manager/1/doc/fpm_ctrl_1.json
Normal file
310
generic_ip/fire_pulse_manager/1/doc/fpm_ctrl_1.json
Normal file
|
|
@ -0,0 +1,310 @@
|
|||
[{
|
||||
"ip_name": "fpm_ctrl_1",
|
||||
"bus": "csr",
|
||||
"description": "This block is the fire pulse manager control",
|
||||
"registers": {
|
||||
"ip_id" : {
|
||||
"address" : "0",
|
||||
"width" : "32",
|
||||
"description" : "Unique ID for this IP block",
|
||||
"fields": {
|
||||
"ip_number" : {
|
||||
"type" : "c",
|
||||
"bit_len" : "8",
|
||||
"reset" : "0x14",
|
||||
"description" : "IP identifier number"
|
||||
},
|
||||
"mfr_number" : {
|
||||
"type" : "c",
|
||||
"bit_len" : "8",
|
||||
"reset" : "0xFF",
|
||||
"description" : "Manufacturer number"
|
||||
|
||||
},
|
||||
"reserved" : {
|
||||
"type" : "rsv",
|
||||
"bit_len" : "16",
|
||||
"description" : "Reserved bits"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ip_ver" : {
|
||||
"address" : "1",
|
||||
"width" : "32",
|
||||
"description" : "IP Version",
|
||||
"fields": {
|
||||
"minor_number" : {
|
||||
"type" : "c",
|
||||
"bit_len" : "8",
|
||||
"reset" : "0x00",
|
||||
"description" : "Minor number"
|
||||
},
|
||||
"major_number" : {
|
||||
"type" : "c",
|
||||
"bit_len" : "8",
|
||||
"reset" : "0x01",
|
||||
"description" : "Major number"
|
||||
|
||||
},
|
||||
"reserved" : {
|
||||
"type" : "rsv",
|
||||
"bit_len" : "16",
|
||||
"description" : "Reserved bits"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Signal selection": {
|
||||
"address": "2",
|
||||
"width": "2",
|
||||
"description": "Controls signal selection",
|
||||
"fields": {
|
||||
"fire_pulse_sel": {
|
||||
"type": "w",
|
||||
"bit_len": "1",
|
||||
"reset": "0x0",
|
||||
"description": "0 => Use External fire pulses, 1 => Use FPM fire pulses"
|
||||
},
|
||||
"enc_pd_emul_en": {
|
||||
"type": "w",
|
||||
"bit_len": "1",
|
||||
"reset": "0x0",
|
||||
"description": "0 => Use POF RX, 1 => Use internal enc/PD emulator"
|
||||
}
|
||||
}
|
||||
},
|
||||
"pof_receiver_control": {
|
||||
"address": "3",
|
||||
"width": "8",
|
||||
"description": "Controls POF receiver",
|
||||
"fields": {
|
||||
"pof_rx_enable": {
|
||||
"type": "w",
|
||||
"bit_len": "1",
|
||||
"reset": "0x0",
|
||||
"description": "0 => Disable POF RX, 1 => Enable POF RX"
|
||||
},
|
||||
"uart_regeneration_bypass": {
|
||||
"type": "w",
|
||||
"bit_len": "1",
|
||||
"reset": "0x0",
|
||||
"description": "0 => Use UART Regeneration, 1 => Bypass UART Regeneration"
|
||||
},
|
||||
"clear_max": {
|
||||
"type": "w",
|
||||
"bit_len": "1",
|
||||
"reset": "0x0",
|
||||
"description": "0 => Disabled, 1 => Load the current value of Absolute Position as new maximum"
|
||||
},
|
||||
"clear_min": {
|
||||
"type": "w",
|
||||
"bit_len": "1",
|
||||
"reset": "0x0",
|
||||
"description": "0 => Disabled, 1 => Load the current value of Absolute Position as new miniumum"
|
||||
},
|
||||
"uart_rx_div": {
|
||||
"type": "w",
|
||||
"bit_len": "4",
|
||||
"reset": "0x4",
|
||||
"description": "Defines the number of 200 MHz clock cycles per UART data bit"
|
||||
}
|
||||
}
|
||||
},
|
||||
"monitoring_point_selection": {
|
||||
"address": "4",
|
||||
"width": "16",
|
||||
"description": "Selects monitoring points for external header",
|
||||
"fields": {
|
||||
"mp0": {
|
||||
"type": "w",
|
||||
"bit_len": "4",
|
||||
"reset": "0x0",
|
||||
"description": "Selects first monitoring point"
|
||||
},
|
||||
"mp1": {
|
||||
"type": "w",
|
||||
"bit_len": "4",
|
||||
"reset": "0x0",
|
||||
"description": "Selects second monitoring point"
|
||||
},
|
||||
"mp2": {
|
||||
"type": "w",
|
||||
"bit_len": "4",
|
||||
"reset": "0x0",
|
||||
"description": "Selects third monitoring point"
|
||||
},
|
||||
"mp3": {
|
||||
"type": "w",
|
||||
"bit_len": "4",
|
||||
"reset": "0x0",
|
||||
"description": "Selects fourth monitoring point"
|
||||
}
|
||||
}
|
||||
},
|
||||
"coarse_time_init": {
|
||||
"type": "w",
|
||||
"address": "5",
|
||||
"reset": "0x00000000",
|
||||
"width": "32",
|
||||
"description": "Defines coarse time counter value"
|
||||
},
|
||||
"fine_time_init": {
|
||||
"address": "6",
|
||||
"width": "29",
|
||||
"description": "Fine time counter value/Load counter enable",
|
||||
"fields": {
|
||||
"fine_time_init": {
|
||||
"type" :"w",
|
||||
"bit_len": "28",
|
||||
"reset": "0x0000000",
|
||||
"description": "Defines fine time counter value"
|
||||
},
|
||||
"time_load_en": {
|
||||
"type" :"w",
|
||||
"bit_len" : "1",
|
||||
"reset": "0x0",
|
||||
"description" : "Writting 1 loads the coarse and fine time counters"
|
||||
}
|
||||
}
|
||||
},
|
||||
"fine_time_status": {
|
||||
"type": "r",
|
||||
"address": "7",
|
||||
"reset": "0x0000000",
|
||||
"width": "28",
|
||||
"description": "Current fine time counter value"
|
||||
},
|
||||
"coarse_time_status": {
|
||||
"type": "r",
|
||||
"address": "8",
|
||||
"reset": "0x00000000",
|
||||
"width": "32",
|
||||
"description": "Current coarse time counter value"
|
||||
},
|
||||
"pof_rx_status": {
|
||||
"address": "9",
|
||||
"width": "32",
|
||||
"description": "Status of POF receiver",
|
||||
"fields": {
|
||||
"parity_bit_error_count": {
|
||||
"type": "r",
|
||||
"bit_len": "16",
|
||||
"reset": "0x0000",
|
||||
"description": "Counts number of parity errors"
|
||||
},
|
||||
"skipped_position_error_count": {
|
||||
"type": "r",
|
||||
"bit_len": "16",
|
||||
"reset": "0x0000",
|
||||
"description": "Counts position skipped type errors"
|
||||
}
|
||||
}
|
||||
},
|
||||
"pof_rx_control": {
|
||||
"address": "10",
|
||||
"width": "12",
|
||||
"description": "POF receiver error control",
|
||||
"fields": {
|
||||
"error_rate_thres": {
|
||||
"type" : "w",
|
||||
"bit_len": "8",
|
||||
"reset": "0x0A",
|
||||
"description": "Defines RX error rate threshold"
|
||||
},
|
||||
"rx_watchdog_en": {
|
||||
"type": "w",
|
||||
"bit_len": "1",
|
||||
"reset": "0x1",
|
||||
"description": "0 => Disable RX watchdog, 1 => Enable RX Watchdog"
|
||||
},
|
||||
"rx_watchdog_clr": {
|
||||
"type": "w",
|
||||
"bit_len": "1",
|
||||
"reset": "0x0",
|
||||
"description": "0 => RX watchdog counter running, 1 => Clear RX watchdog counter"
|
||||
},
|
||||
"rx_watchdog": {
|
||||
"type": "r",
|
||||
"bit_len": "1",
|
||||
"reset": "0x0",
|
||||
"description": "0 => RX watchdog not triggered, 1 => RX watchdog triggered"
|
||||
},
|
||||
"rx_error_flag": {
|
||||
"type": "r",
|
||||
"bit_len": "1",
|
||||
"reset": "0x0",
|
||||
"description": "0 => Error rate below threshold, 1 => Error rate above threshold"
|
||||
}
|
||||
}
|
||||
},
|
||||
"fpm_interrupt": {
|
||||
"address": "11",
|
||||
"width": "16",
|
||||
"description": "Interrupt control",
|
||||
"fields": {
|
||||
"irq_en": {
|
||||
"type": "w",
|
||||
"bit_len": "1",
|
||||
"reset": "0x0",
|
||||
"description": "0 => Disable IRQ, 1 => Enable IRQ"
|
||||
},
|
||||
"reserved1": {
|
||||
"type": "rsv",
|
||||
"bit_len": "3",
|
||||
"description": "Reserved"
|
||||
},
|
||||
"irq_clr": {
|
||||
"type": "w",
|
||||
"bit_len": "1",
|
||||
"reset": "0x0",
|
||||
"description": "0 => Don't clear pending IRQ, 1 => Clear pending IRQ"
|
||||
},
|
||||
"reserved2": {
|
||||
"type": "rsv",
|
||||
"bit_len": "3",
|
||||
"description": "Reserved"
|
||||
},
|
||||
"irq_mask": {
|
||||
"type": "w",
|
||||
"bit_len": "1",
|
||||
"reset": "0x0",
|
||||
"description": "0 => IRQ not masked, 1 => IRQ masked"
|
||||
},
|
||||
"reserved3": {
|
||||
"type": "rsv",
|
||||
"bit_len": "3",
|
||||
"description": "Reserved"
|
||||
},
|
||||
"irq_status": {
|
||||
"type": "r",
|
||||
"bit_len": "1",
|
||||
"reset": "0x0",
|
||||
"description": "0 => IRQ not active, 1 => IRQ active"
|
||||
},
|
||||
"reserved4": {
|
||||
"type": "rsv",
|
||||
"bit_len": "3",
|
||||
"description": "Reserved"
|
||||
}
|
||||
}
|
||||
},
|
||||
"fpm_ext_ctrl": {
|
||||
"address": "12",
|
||||
"width": "32",
|
||||
"description": "Controls regeneration of external fire pulses",
|
||||
"fields": {
|
||||
"ext_fp_det": {
|
||||
"type": "w",
|
||||
"bit_len": "16",
|
||||
"reset": "0x0010",
|
||||
"description": "Minimum width of external fire pulses"
|
||||
},
|
||||
"ext_fp_gen": {
|
||||
"type": "w",
|
||||
"bit_len": "16",
|
||||
"reset": "0x0020",
|
||||
"description": "Width of regenerated external fire pulses"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}]
|
||||
169
generic_ip/fire_pulse_manager/1/doc/fpm_diags_1.json
Normal file
169
generic_ip/fire_pulse_manager/1/doc/fpm_diags_1.json
Normal file
|
|
@ -0,0 +1,169 @@
|
|||
[{
|
||||
"ip_name": "fpm_diags",
|
||||
"bus": "csr",
|
||||
"description": "This block is the fire pulse manager diagnostics",
|
||||
"registers": {
|
||||
"init": {
|
||||
"type": "w",
|
||||
"address": "0",
|
||||
"reset": "0x00",
|
||||
"width": "32",
|
||||
"description": "Write 1 then 0 to initialize the diagnostics block"
|
||||
},
|
||||
"input_status": {
|
||||
"address": "1",
|
||||
"width": "13",
|
||||
"description": "Instantaneous status of input signals",
|
||||
"fields": {
|
||||
"Rs422Phase0Input": {
|
||||
"type": "r",
|
||||
"bit_len": "1",
|
||||
"reset": "0x00",
|
||||
"description": ""
|
||||
},
|
||||
"Rs422Phase1Input": {
|
||||
"type": "r",
|
||||
"bit_len": "1",
|
||||
"reset": "0x00",
|
||||
"description": ""
|
||||
},
|
||||
"Rs422ZeroPhase": {
|
||||
"type": "r",
|
||||
"bit_len": "1",
|
||||
"reset": "0x00",
|
||||
"description": ""
|
||||
},
|
||||
"Rs422ProductDetect": {
|
||||
"type": "r",
|
||||
"bit_len": "1",
|
||||
"reset": "0x00",
|
||||
"description": ""
|
||||
},
|
||||
"TtlPhase0Input": {
|
||||
"type": "r",
|
||||
"bit_len": "1",
|
||||
"reset": "0x00",
|
||||
"description": ""
|
||||
},
|
||||
"TtlPhase1Input": {
|
||||
"type": "r",
|
||||
"bit_len": "1",
|
||||
"reset": "0x00",
|
||||
"description": ""
|
||||
},
|
||||
"TtlProductDetect": {
|
||||
"type": "r",
|
||||
"bit_len": "1",
|
||||
"reset": "0x00",
|
||||
"description": ""
|
||||
},
|
||||
"FilteredPhase0Input": {
|
||||
"type": "r",
|
||||
"bit_len": "1",
|
||||
"reset": "0x00",
|
||||
"description": ""
|
||||
},
|
||||
"FilteredPhase1Input": {
|
||||
"type": "r",
|
||||
"bit_len": "1",
|
||||
"reset": "0x00",
|
||||
"description": ""
|
||||
},
|
||||
"FilteredZeroPhase": {
|
||||
"type": "r",
|
||||
"bit_len": "1",
|
||||
"reset": "0x00",
|
||||
"description": ""
|
||||
},
|
||||
"FilteredProductDetect": {
|
||||
"type": "r",
|
||||
"bit_len": "1",
|
||||
"reset": "0x00",
|
||||
"description": ""
|
||||
},
|
||||
"EmsEncoderOutput": {
|
||||
"type": "r",
|
||||
"bit_len": "1",
|
||||
"reset": "0x00",
|
||||
"description": ""
|
||||
},
|
||||
"EmsProductDetectOutput": {
|
||||
"type": "r",
|
||||
"bit_len": "1",
|
||||
"reset": "0x00",
|
||||
"description": ""
|
||||
}
|
||||
}
|
||||
},
|
||||
"phase0_counter": {
|
||||
"type": "r",
|
||||
"address": "2",
|
||||
"reset": "0x0",
|
||||
"width": "32",
|
||||
"description": ""
|
||||
},
|
||||
"phase1_counter": {
|
||||
"type": "r",
|
||||
"address": "3",
|
||||
"reset": "0x0",
|
||||
"width": "32",
|
||||
"description": ""
|
||||
},
|
||||
"ems_encoder_output_counter": {
|
||||
"type": "r",
|
||||
"address": "6",
|
||||
"reset": "0x0",
|
||||
"width": "32",
|
||||
"description": ""
|
||||
},
|
||||
"ems_pd_output_counter": {
|
||||
"type": "r",
|
||||
"address": "7",
|
||||
"reset": "0x0",
|
||||
"width": "32",
|
||||
"description": ""
|
||||
},
|
||||
"fire_request_channel_counter": {
|
||||
"type": "r",
|
||||
"address": "8",
|
||||
"reset": "0x0",
|
||||
"width": "32",
|
||||
"description": ""
|
||||
},
|
||||
"delta_time_measurement_interval": {
|
||||
"type": "w",
|
||||
"address": "16",
|
||||
"reset": "0x0",
|
||||
"width": "32",
|
||||
"description": ""
|
||||
},
|
||||
"position": {
|
||||
"type": "r",
|
||||
"address": "17",
|
||||
"reset": "0x0",
|
||||
"width": "32",
|
||||
"description": ""
|
||||
},
|
||||
"delta_position_measurement_interval": {
|
||||
"type": "w",
|
||||
"address": "20",
|
||||
"reset": "0x0",
|
||||
"width": "32",
|
||||
"description": ""
|
||||
},
|
||||
"delta_position_fifo_control": {
|
||||
"type": "w",
|
||||
"address": "21",
|
||||
"reset": "0x0",
|
||||
"width": "32",
|
||||
"description": ""
|
||||
},
|
||||
"irq_management": {
|
||||
"type": "w",
|
||||
"address": "27",
|
||||
"reset": "0x0",
|
||||
"width": "32",
|
||||
"description": ""
|
||||
}
|
||||
}
|
||||
}]
|
||||
57
generic_ip/fire_pulse_manager/1/doc/fpm_event_log_1.json
Normal file
57
generic_ip/fire_pulse_manager/1/doc/fpm_event_log_1.json
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
[{
|
||||
"ip_name" : "fpm_event_log",
|
||||
"bus" : "csr",
|
||||
"description" : "This block is the fire pulse manager diags",
|
||||
"registers" : {
|
||||
"ip_id" : {
|
||||
"address" : "0",
|
||||
"width" : "32",
|
||||
"description" : "Unique ID for this IP block",
|
||||
"fields": {
|
||||
"ip_number" : {
|
||||
"type" : "c",
|
||||
"bit_len" : "8",
|
||||
"reset" : "0xFF",
|
||||
"description" : "IP identifier number (unknown)"
|
||||
},
|
||||
"mfr_number" : {
|
||||
"type" : "c",
|
||||
"bit_len" : "8",
|
||||
"reset" : "0xFF",
|
||||
"description" : "Manufacturer number"
|
||||
|
||||
},
|
||||
"reserved" : {
|
||||
"type" : "rsv",
|
||||
"bit_len" : "16",
|
||||
"description" : "Reserved bits"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ip_ver" : {
|
||||
"address" : "1",
|
||||
"width" : "32",
|
||||
"description" : "Bits[7:0] = Minor version number, Bits[15:8] = Major version number, etc.",
|
||||
"fields": {
|
||||
"minor_number" : {
|
||||
"type" : "c",
|
||||
"bit_len" : "8",
|
||||
"reset" : "0x01",
|
||||
"description" : "Minor number"
|
||||
},
|
||||
"major_number" : {
|
||||
"type" : "c",
|
||||
"bit_len" : "8",
|
||||
"reset" : "0x00",
|
||||
"description" : "Major number"
|
||||
|
||||
},
|
||||
"reserved" : {
|
||||
"type" : "rsv",
|
||||
"bit_len" : "16",
|
||||
"description" : "Reserved bits"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}]
|
||||
|
|
@ -0,0 +1 @@
|
|||
### REPLACED BY THE ENC/PD EMULATOR BLOCK ###
|
||||
57
generic_ip/fire_pulse_manager/1/doc/fpm_net_sync_1.json
Normal file
57
generic_ip/fire_pulse_manager/1/doc/fpm_net_sync_1.json
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
[{
|
||||
"ip_name" : "fpm_net_sync",
|
||||
"bus" : "csr",
|
||||
"description" : "This block is the fire pulse manager net sync",
|
||||
"registers" : {
|
||||
"ip_id" : {
|
||||
"address" : "0",
|
||||
"width" : "32",
|
||||
"description" : "Unique ID for this IP block",
|
||||
"fields": {
|
||||
"ip_number" : {
|
||||
"type" : "c",
|
||||
"bit_len" : "8",
|
||||
"reset" : "0xFF",
|
||||
"description" : "IP identifier number (unknown)"
|
||||
},
|
||||
"mfr_number" : {
|
||||
"type" : "c",
|
||||
"bit_len" : "8",
|
||||
"reset" : "0xFF",
|
||||
"description" : "Manufacturer number"
|
||||
|
||||
},
|
||||
"reserved" : {
|
||||
"type" : "rsv",
|
||||
"bit_len" : "16",
|
||||
"description" : "Reserved bits"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ip_ver" : {
|
||||
"address" : "1",
|
||||
"width" : "32",
|
||||
"description" : "Bits[7:0] = Minor version number, Bits[15:8] = Major version number, etc.",
|
||||
"fields": {
|
||||
"minor_number" : {
|
||||
"type" : "c",
|
||||
"bit_len" : "8",
|
||||
"reset" : "0x01",
|
||||
"description" : "Minor number"
|
||||
},
|
||||
"major_number" : {
|
||||
"type" : "c",
|
||||
"bit_len" : "8",
|
||||
"reset" : "0x00",
|
||||
"description" : "Major number"
|
||||
|
||||
},
|
||||
"reserved" : {
|
||||
"type" : "rsv",
|
||||
"bit_len" : "16",
|
||||
"description" : "Reserved bits"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}]
|
||||
116
generic_ip/fire_pulse_manager/1/src/cs_bus_itf_1.vhd
Normal file
116
generic_ip/fire_pulse_manager/1/src/cs_bus_itf_1.vhd
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
-------------------------------------------------------------------------------
|
||||
-- Title : cs_bus_ift
|
||||
-------------------------------------------------------------------------------
|
||||
-- File : cs_bus_ift.vhd
|
||||
-- Author : Gianmarco Girau
|
||||
-- Company : Global Inkjet Systems
|
||||
-- Target : Altera Nios/HPS based systems
|
||||
-- Dependency : none
|
||||
-------------------------------------------------------------------------------
|
||||
-- Description: Split the memory space from the Avalon-MM I/F and drive the C&S
|
||||
-- bus for a programmable number of FW processing blocks
|
||||
-------------------------------------------------------------------------------
|
||||
-- Last update: 2016-10-28
|
||||
-------------------------------------------------------------------------------
|
||||
-- Revisions :
|
||||
-- Date Version Author Description
|
||||
-- 2015-10-19 1.0 gmg Created
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
use ieee.numeric_std.all;
|
||||
|
||||
entity cs_bus_ift_1 is
|
||||
generic(blk_num : integer range 1 to 16 := 1);
|
||||
port(
|
||||
rstN : in std_logic;
|
||||
clk : in std_logic;
|
||||
-- Avalon-MM itf
|
||||
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);
|
||||
-- C&S bus
|
||||
cs_addr : out std_logic_vector(10 downto 0);
|
||||
cs_we : out std_logic_vector(blk_num-1 downto 0);
|
||||
cs_wr_data : out std_logic_vector(31 downto 0);
|
||||
cs_re : out std_logic_vector(blk_num-1 downto 0);
|
||||
cs_rv : in std_logic_vector(blk_num-1 downto 0);
|
||||
cs_rd_data : in std_logic_vector(32*blk_num-1 downto 0));
|
||||
end cs_bus_ift_1;
|
||||
|
||||
architecture RTL of cs_bus_ift_1 is
|
||||
|
||||
-- limit to 16 the maximum number of user blocks
|
||||
type rd_bus_t is array (0 to blk_num-1) of std_logic_vector(31 downto 0);
|
||||
|
||||
signal cs_rd_data_i : rd_bus_t;
|
||||
signal avs_read_d : std_logic;
|
||||
signal avs_rd_en : std_logic;
|
||||
signal dummy_rv : std_logic; -- Dummy Read valid: asserted when
|
||||
-- trying to read from not allocated addresses
|
||||
signal avs_address_i : std_logic_vector(14 downto 0);
|
||||
|
||||
begin
|
||||
|
||||
BUS_REMAP: for i in 0 to blk_num-1 generate
|
||||
cs_rd_data_i(i) <= cs_rd_data((i+1)*32-1 downto i*32);
|
||||
end generate BUS_REMAP;
|
||||
|
||||
pLatchIO : process(rstN, clk)
|
||||
begin
|
||||
if(rstN = '0') then
|
||||
avs_address_i <= (others => '0');
|
||||
cs_we <= (others => '0');
|
||||
cs_wr_data <= (others => '0');
|
||||
cs_re <= (others => '0');
|
||||
avs_readdatavalid <= '0';
|
||||
avs_readdata <= (others => '0');
|
||||
avs_read_d <= '0';
|
||||
dummy_rv <= '0';
|
||||
elsif(clk = '1' and clk'event) then
|
||||
if(avs_write = '1' or avs_read = '1') then
|
||||
avs_address_i <= avs_address;
|
||||
end if;
|
||||
avs_read_d <= avs_read;
|
||||
for i in 0 to blk_num-1 loop
|
||||
-- limit to 16 the maximum number of user blocks
|
||||
if(avs_write = '1' and to_integer(unsigned(avs_address(avs_address'high downto avs_address'high-3))) = i) then
|
||||
cs_we(i) <= '1';
|
||||
else
|
||||
cs_we(i) <= '0';
|
||||
end if;
|
||||
end loop; -- i
|
||||
cs_wr_data <= avs_writedata;
|
||||
for i in 0 to blk_num-1 loop
|
||||
if(avs_rd_en = '1' and to_integer(unsigned(avs_address(avs_address'high downto avs_address'high-3))) = i) then
|
||||
cs_re(i) <= '1';
|
||||
else
|
||||
cs_re(i) <= '0';
|
||||
end if;
|
||||
end loop; -- i
|
||||
if(avs_rd_en = '1' and (to_integer(unsigned(avs_address(avs_address'high downto avs_address'high-3))) >= blk_num)) then
|
||||
dummy_rv <= '1';
|
||||
else
|
||||
dummy_rv <= '0';
|
||||
end if;
|
||||
avs_readdatavalid <= dummy_rv or cs_rv(to_integer(unsigned(avs_address_i(avs_address'high downto avs_address'high-3))));
|
||||
if(dummy_rv = '0') then
|
||||
avs_readdata <= cs_rd_data_i(to_integer(unsigned(avs_address_i(avs_address'high downto avs_address'high-3))));
|
||||
else
|
||||
avs_readdata <= X"DEAD_BEEF";
|
||||
end if;
|
||||
end if;
|
||||
end process pLatchIO;
|
||||
|
||||
avs_rd_en <= avs_read and not avs_read_d;
|
||||
|
||||
cs_addr <= avs_address_i(10 downto 0);
|
||||
|
||||
end RTL;
|
||||
|
||||
|
||||
|
||||
275
generic_ip/fire_pulse_manager/1/src/fire_pulse_ctrl_1.vhd
Normal file
275
generic_ip/fire_pulse_manager/1/src/fire_pulse_ctrl_1.vhd
Normal file
|
|
@ -0,0 +1,275 @@
|
|||
-------------------------------------------------------------------------------
|
||||
-- Title : fire_pulse_ctrl
|
||||
-- Project : HMB/EMB/SMB
|
||||
-------------------------------------------------------------------------------
|
||||
-- File : fire_pulse_ctrl.vhd
|
||||
-- Author : Gianmarco Girau
|
||||
-- Company : Global Inkjet Systems
|
||||
-- Created : 2017-09-06
|
||||
-- Last update: 2017-11-27
|
||||
-- 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_1 is
|
||||
port(
|
||||
reset_n : in std_logic;
|
||||
clk : in std_logic;
|
||||
src_sel : out std_logic_vector( 1 downto 0);
|
||||
uart_regen_bypass : out std_logic;
|
||||
upd_max_pos : out std_logic;
|
||||
upd_min_pos : out std_logic;
|
||||
enable_rx : out std_logic;
|
||||
uart_bit_div : out std_logic_vector( 3 downto 0);
|
||||
error_rate_thres : out std_logic_vector( 7 downto 0);
|
||||
max_error_flag : in std_logic;
|
||||
rx_watchdog : in std_logic;
|
||||
rx_watchdog_en : out std_logic;
|
||||
rx_watchdog_clr : out std_logic;
|
||||
parity_err_cnt : in std_logic_vector(15 downto 0);
|
||||
skip_pos_cnt : in std_logic_vector(15 downto 0);
|
||||
mon_point_src : in std_logic_vector(15 downto 0);
|
||||
mon_points : out std_logic_vector( 3 downto 0);
|
||||
coarse_time : out std_logic_vector(31 downto 0);
|
||||
fine_time : out std_logic_vector(27 downto 0);
|
||||
one_pps : out std_logic;
|
||||
ext_fp_det : out std_logic_vector(15 downto 0);
|
||||
ext_fp_gen : out std_logic_vector(15 downto 0);
|
||||
-- Interrupt Senders
|
||||
ins_fpm_irq_0 : out std_logic;
|
||||
-- Avalon MM Interface
|
||||
avs_address : in std_logic_vector( 3 downto 0);
|
||||
avs_write : in std_logic;
|
||||
avs_writedata : in std_logic_vector(31 downto 0);
|
||||
avs_read : in std_logic;
|
||||
avs_readdatavalid : out std_logic;
|
||||
avs_readdata : out std_logic_vector(31 downto 0));
|
||||
end entity fire_pulse_ctrl_1;
|
||||
|
||||
architecture rtl of fire_pulse_ctrl_1 is
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Control & Status Registers Map
|
||||
-----------------------------------------------------------------------------
|
||||
constant CSR_IP_ID : std_logic_vector(31 downto 0) := x"0000FF14";
|
||||
constant CSR_IP_VER : std_logic_vector(31 downto 0) := x"00000100";
|
||||
|
||||
constant CSR_IP_ID_REG : std_logic_vector( 3 downto 0) := b"0000";
|
||||
constant CSR_IP_VER_REG : std_logic_vector( 3 downto 0) := b"0001";
|
||||
constant SRC_SEL_REG : std_logic_vector( 3 downto 0) := b"0010";
|
||||
constant POF_RX_CTRL : std_logic_vector( 3 downto 0) := b"0011";
|
||||
constant MON_PT_CTRL_REG : std_logic_vector( 3 downto 0) := b"0100";
|
||||
constant COARSE_TIME_INIT_REG : std_logic_vector( 3 downto 0) := b"0101";
|
||||
constant FINE_TIME_INIT_REG : std_logic_vector( 3 downto 0) := b"0110";
|
||||
constant FINE_TIME_REG : std_logic_vector( 3 downto 0) := b"0111";
|
||||
constant COARSE_TIME_REG : std_logic_vector( 3 downto 0) := b"1000";
|
||||
constant RX_ERROR_STATUS : std_logic_vector( 3 downto 0) := b"1001";
|
||||
constant RX_ERROR_CSR : std_logic_vector( 3 downto 0) := b"1010";
|
||||
constant IRQ_MNG_REG : std_logic_vector( 3 downto 0) := b"1011";
|
||||
constant EXT_FP_CTRL_REG : std_logic_vector( 3 downto 0) := b"1100";
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Constants, Signals
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
constant FINE_TIME_TC : integer := 100000000-1; -- clk must be 100MHz to
|
||||
-- make it right
|
||||
|
||||
signal enable_rx_i : std_logic;
|
||||
signal fine_time_wrap, time_ld_en : std_logic;
|
||||
signal rx_watchdog_en_i, rx_watchdog_clr_i : std_logic;
|
||||
signal uart_regen_bypass_i : std_logic;
|
||||
signal upd_min_pos_i, upd_max_pos_i : std_logic;
|
||||
signal irq, irq_src, irq_src_d : std_logic_vector( 0 downto 0);
|
||||
signal irq_en, irq_mask, irq_val, irq_clr : std_logic_vector( 0 downto 0);
|
||||
signal src_sel_i : std_logic_vector( 1 downto 0);
|
||||
signal mp_sel0, mp_sel1, mp_sel2, mp_sel3 : std_logic_vector( 3 downto 0);
|
||||
signal bit_div : std_logic_vector( 3 downto 0);
|
||||
signal error_rate_thres_i : std_logic_vector( 7 downto 0);
|
||||
signal fine_time_init, fine_time_i : std_logic_vector(27 downto 0);
|
||||
signal coarse_time_init, coarse_time_i : std_logic_vector(31 downto 0);
|
||||
signal ext_fp_det_i, ext_fp_gen_i : std_logic_vector(15 downto 0);
|
||||
|
||||
begin
|
||||
|
||||
pCTRL_REGs : process(reset_n, clk)
|
||||
begin -- process
|
||||
if(reset_n = '0') then
|
||||
fine_time_i <= (others => '0');
|
||||
coarse_time_i <= (others => '0');
|
||||
elsif(clk = '1' and clk'event) then
|
||||
if(time_ld_en = '1') then
|
||||
fine_time_i <= fine_time_init;
|
||||
elsif(fine_time_wrap = '1') then
|
||||
fine_time_i <= (others => '0');
|
||||
else
|
||||
fine_time_i <= std_logic_vector(unsigned(fine_time_i)+1);
|
||||
end if;
|
||||
if(time_ld_en = '1') then
|
||||
coarse_time_i <= coarse_time_init;
|
||||
elsif(fine_time_wrap = '1') then
|
||||
coarse_time_i <= std_logic_vector(unsigned(coarse_time_i)+1);
|
||||
end if;
|
||||
one_pps <= fine_time_wrap;
|
||||
end if;
|
||||
end process pCTRL_REGs;
|
||||
|
||||
fine_time_wrap <= '1' when unsigned(fine_time_i) = FINE_TIME_TC else '0';
|
||||
|
||||
coarse_time <= coarse_time_i;
|
||||
fine_time <= fine_time_i;
|
||||
|
||||
-- MOnitoring Point selection
|
||||
mon_points(0) <= mon_point_src(to_integer(unsigned(mp_sel0)));
|
||||
mon_points(1) <= mon_point_src(to_integer(unsigned(mp_sel1)));
|
||||
mon_points(2) <= mon_point_src(to_integer(unsigned(mp_sel2)));
|
||||
mon_points(3) <= mon_point_src(to_integer(unsigned(mp_sel3)));
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- IRQ generation and management
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
pIRQ : process(reset_n, clk)
|
||||
begin
|
||||
if(reset_n = '0') then
|
||||
ins_fpm_irq_0 <= '0';
|
||||
irq <= "0";
|
||||
irq_src_d <= "0";
|
||||
elsif(clk = '1' and clk'event) then
|
||||
irq_src_d <= irq_src;
|
||||
for n in 0 to irq'left loop
|
||||
if(irq_clr(n) = '1') then
|
||||
irq(n) <= '0';
|
||||
elsif(irq_en(n) = '1' and irq_src(n) = '1' and irq_src_d(n) = '0') then
|
||||
irq(n) <= '1';
|
||||
end if;
|
||||
end loop; -- n
|
||||
ins_fpm_irq_0 <= irq_val(0);
|
||||
end if;
|
||||
end process pIRQ;
|
||||
|
||||
irq_val <= irq and not irq_mask;
|
||||
irq_src <= "1" when max_error_flag = '1' or rx_watchdog = '1' else "0";
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- C&S registers
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
src_sel <= src_sel_i;
|
||||
enable_rx <= enable_rx_i;
|
||||
uart_regen_bypass <= uart_regen_bypass_i;
|
||||
|
||||
uart_bit_div <= bit_div;
|
||||
upd_max_pos <= upd_max_pos_i;
|
||||
upd_min_pos <= upd_min_pos_i;
|
||||
|
||||
error_rate_thres <= error_rate_thres_i;
|
||||
rx_watchdog_en <= rx_watchdog_en_i;
|
||||
rx_watchdog_clr <= rx_watchdog_clr_i;
|
||||
|
||||
ext_fp_det <= ext_fp_det_i;
|
||||
ext_fp_gen <= ext_fp_gen_i;
|
||||
|
||||
pCTRL_STATUS : process(reset_n, clk)
|
||||
begin
|
||||
if(reset_n = '0') then
|
||||
avs_readdatavalid <= '0';
|
||||
src_sel_i <= "00";
|
||||
enable_rx_i <= '0';
|
||||
uart_regen_bypass_i <= '0';
|
||||
upd_max_pos_i <= '0';
|
||||
upd_min_pos_i <= '0';
|
||||
bit_div <= "0100";
|
||||
error_rate_thres_i <= X"0A";
|
||||
rx_watchdog_en_i <= '1';
|
||||
rx_watchdog_clr_i <= '0';
|
||||
mp_sel0 <= X"0";
|
||||
mp_sel1 <= X"0";
|
||||
mp_sel2 <= X"0";
|
||||
mp_sel3 <= X"0";
|
||||
coarse_time_init <= (others => '0');
|
||||
fine_time_init <= (others => '0');
|
||||
time_ld_en <= '0';
|
||||
ext_fp_det_i <= X"0010";
|
||||
ext_fp_gen_i <= X"0020";
|
||||
elsif(clk = '1' and clk'event) then
|
||||
-- CTRL registers
|
||||
if(avs_write = '1') then
|
||||
case avs_address is
|
||||
when SRC_SEL_REG =>
|
||||
src_sel_i <= avs_writedata( 1 downto 0);
|
||||
when POF_RX_CTRL =>
|
||||
enable_rx_i <= avs_writedata(0);
|
||||
uart_regen_bypass_i <= avs_writedata(1);
|
||||
upd_max_pos_i <= avs_writedata(2);
|
||||
upd_min_pos_i <= avs_writedata(3);
|
||||
bit_div <= avs_writedata( 7 downto 4);
|
||||
when MON_PT_CTRL_REG =>
|
||||
mp_sel0 <= avs_writedata( 3 downto 0);
|
||||
mp_sel1 <= avs_writedata( 7 downto 4);
|
||||
mp_sel2 <= avs_writedata(11 downto 8);
|
||||
mp_sel3 <= avs_writedata(15 downto 12);
|
||||
when COARSE_TIME_INIT_REG =>
|
||||
coarse_time_init <= avs_writedata;
|
||||
when FINE_TIME_INIT_REG =>
|
||||
time_ld_en <= avs_writedata(28);
|
||||
fine_time_init <= avs_writedata(27 downto 0);
|
||||
when RX_ERROR_CSR =>
|
||||
error_rate_thres_i <= avs_writedata( 7 downto 0);
|
||||
rx_watchdog_en_i <= avs_writedata(8);
|
||||
rx_watchdog_clr_i <= avs_writedata(9);
|
||||
when IRQ_MNG_REG =>
|
||||
irq_en <= avs_writedata( 0 downto 0);
|
||||
irq_clr <= avs_writedata( 4 downto 4);
|
||||
irq_mask <= avs_writedata( 8 downto 8);
|
||||
when EXT_FP_CTRL_REG =>
|
||||
ext_fp_det_i <= avs_writedata(15 downto 0);
|
||||
ext_fp_gen_i <= avs_writedata(31 downto 16);
|
||||
when others => null;
|
||||
end case;
|
||||
end if;
|
||||
-- Read Ctrl & Status registers
|
||||
avs_readdatavalid <= avs_read;
|
||||
if(avs_read = '1') then
|
||||
case avs_address is
|
||||
when CSR_IP_ID_REG =>
|
||||
avs_readdata <= CSR_IP_ID;
|
||||
when CSR_IP_VER_REG =>
|
||||
avs_readdata <= CSR_IP_VER;
|
||||
when SRC_SEL_REG =>
|
||||
avs_readdata <= (0 => src_sel_i(0), 1 => src_sel_i(1), others => '0');
|
||||
when POF_RX_CTRL =>
|
||||
avs_readdata <= X"000000" & bit_div & upd_min_pos_i & upd_max_pos_i & uart_regen_bypass_i & enable_rx_i;
|
||||
when MON_PT_CTRL_REG =>
|
||||
avs_readdata <= X"0000" & mp_sel3 & mp_sel2 & mp_sel1 & mp_sel0;
|
||||
when COARSE_TIME_INIT_REG =>
|
||||
avs_readdata <= coarse_time_init;
|
||||
when FINE_TIME_INIT_REG =>
|
||||
avs_readdata <= b"000" & time_ld_en & fine_time_init;
|
||||
when RX_ERROR_STATUS =>
|
||||
avs_readdata <= skip_pos_cnt & parity_err_cnt;
|
||||
when FINE_TIME_REG =>
|
||||
avs_readdata <= X"0" & fine_time_i;
|
||||
when COARSE_TIME_REG =>
|
||||
avs_readdata <= coarse_time_i;
|
||||
when RX_ERROR_CSR =>
|
||||
avs_readdata <= X"00000" & max_error_flag & rx_watchdog & rx_watchdog_clr_i & rx_watchdog_en_i & error_rate_thres_i;
|
||||
when IRQ_MNG_REG =>
|
||||
avs_readdata <= X"0000" & "000" & irq_val & "000" & irq_mask & "000" & irq_clr & "000" & irq_en;
|
||||
when EXT_FP_CTRL_REG =>
|
||||
avs_readdata <= ext_fp_gen_i & ext_fp_det_i;
|
||||
when others =>
|
||||
avs_readdata <= X"BAD1BAD0";
|
||||
end case;
|
||||
end if;
|
||||
end if;
|
||||
end process pCTRL_STATUS;
|
||||
|
||||
end architecture rtl;
|
||||
107
generic_ip/fire_pulse_manager/1/src/fire_pulse_ext_1.vhd
Normal file
107
generic_ip/fire_pulse_manager/1/src/fire_pulse_ext_1.vhd
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
-------------------------------------------------------------------------------
|
||||
-- Title : fire_pulse_manager
|
||||
-- Project : GMA
|
||||
-------------------------------------------------------------------------------
|
||||
-- File : fire_pulse_ext.vhd
|
||||
-- Author : Christos Spirotis
|
||||
-- Company : Global Inkjet Systems
|
||||
-- Created : 2017-10-03
|
||||
-- Last update: 2018-10-03
|
||||
-- SVN ID : Git
|
||||
-- Standard : VHDL'08
|
||||
-------------------------------------------------------------------------------
|
||||
-- Description:
|
||||
-- Detects external fire pulse and regenerates it
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
use ieee.numeric_std.all;
|
||||
|
||||
library work;
|
||||
|
||||
entity fire_pulse_ext_1 is
|
||||
port(
|
||||
reset_n : in std_logic;
|
||||
clk : in std_logic; -- 100MHz
|
||||
|
||||
ext_fp_det : in std_logic_vector(15 downto 0);
|
||||
ext_fp_gen : in std_logic_vector(15 downto 0);
|
||||
|
||||
ext_in : in std_logic;
|
||||
ext_out : out std_logic
|
||||
);
|
||||
end entity fire_pulse_ext_1;
|
||||
|
||||
architecture rtl of fire_pulse_ext_1 is
|
||||
|
||||
signal ext_in_cnt : unsigned(15 downto 0);
|
||||
signal ext_out_cnt : unsigned(15 downto 0);
|
||||
signal ext_in_det : std_logic_vector( 2 downto 0);
|
||||
signal fp_gen : std_logic;
|
||||
|
||||
begin
|
||||
|
||||
-- Detect pulse
|
||||
pulse_det : process (clk, reset_n)
|
||||
begin
|
||||
if (reset_n = '0') then
|
||||
ext_in_cnt <= (others => '0');
|
||||
ext_in_det <= (others => '0');
|
||||
fp_gen <= '0';
|
||||
elsif rising_edge(clk) then
|
||||
fp_gen <= '0';
|
||||
ext_in_det <= ext_in_det(1 downto 0) & ext_in;
|
||||
|
||||
-- Detect rising edge while idle
|
||||
if (ext_in_det(2 downto 1) = "01" and ext_in_cnt = 0) then
|
||||
-- Start width counter
|
||||
ext_in_cnt <= X"0001";
|
||||
-- Measure width while signal high
|
||||
elsif ext_in_cnt /= 0 and ext_in_det(1) = '1' then
|
||||
-- Counter++
|
||||
ext_in_cnt <= ext_in_cnt + 1;
|
||||
-- If reached minimum width
|
||||
if ext_in_cnt >= unsigned(ext_fp_det) then
|
||||
-- Regenerate pulse
|
||||
fp_gen <= '1';
|
||||
-- Reset width counter
|
||||
ext_in_cnt <= (others => '0');
|
||||
end if;
|
||||
-- If signal drops before detection
|
||||
elsif ext_in_cnt /= 0 and ext_in_det(1) = '0' then
|
||||
-- Reset width counter
|
||||
ext_in_cnt <= (others => '0');
|
||||
end if;
|
||||
end if;
|
||||
end process pulse_det;
|
||||
|
||||
-- Regenerate pulse
|
||||
pulse_regen : process (clk, reset_n)
|
||||
begin
|
||||
if (reset_n = '0') then
|
||||
ext_out_cnt <= (others => '0');
|
||||
ext_out <= '0';
|
||||
elsif rising_edge(clk) then
|
||||
-- Look for pulse detected
|
||||
if fp_gen = '1' and ext_out_cnt = 0 then
|
||||
-- Start width counter
|
||||
ext_out_cnt <= X"0001";
|
||||
-- Generate pulse
|
||||
ext_out <= '1';
|
||||
-- If counting
|
||||
elsif ext_out_cnt /= 0 then
|
||||
-- Increment width
|
||||
ext_out_cnt <= ext_out_cnt + 1;
|
||||
-- If width reached programmed value
|
||||
if ext_out_cnt >= unsigned(ext_fp_gen) then
|
||||
-- Reset pulse
|
||||
ext_out <= '0';
|
||||
-- Reset width counter
|
||||
ext_out_cnt <= (others => '0');
|
||||
end if;
|
||||
end if;
|
||||
end if;
|
||||
end process pulse_regen;
|
||||
|
||||
end architecture rtl;
|
||||
408
generic_ip/fire_pulse_manager/1/src/fire_pulse_manager_1.vhd
Normal file
408
generic_ip/fire_pulse_manager/1/src/fire_pulse_manager_1.vhd
Normal file
|
|
@ -0,0 +1,408 @@
|
|||
-------------------------------------------------------------------------------
|
||||
-- Title : fire_pulse_manager
|
||||
-- Project : HMB/EMB/SMB
|
||||
-------------------------------------------------------------------------------
|
||||
-- File : fire_pulse_manager.vhd
|
||||
-- Author : Gianmarco Girau
|
||||
-- Company : Global Inkjet Systems
|
||||
-- Created : 2017-09-06
|
||||
-- Last update: 2018-06-28
|
||||
-- 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_1_pkg.all;
|
||||
|
||||
entity fire_pulse_manager_1 is
|
||||
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_vector(ch_num-1 downto 0);
|
||||
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_1;
|
||||
|
||||
architecture rtl of fire_pulse_manager_1 is
|
||||
|
||||
signal reset_n_i : std_logic;
|
||||
--
|
||||
signal cs_addr : std_logic_vector(10 downto 0);
|
||||
signal cs_write_en : std_logic_vector(blk_num-1 downto 0);
|
||||
signal cs_write_data : std_logic_vector(31 downto 0);
|
||||
signal cs_read_en : std_logic_vector(blk_num-1 downto 0);
|
||||
signal cs_read_valid : std_logic_vector(blk_num-1 downto 0);
|
||||
signal cs_read_data : std_logic_vector(32*blk_num-1 downto 0);
|
||||
--
|
||||
signal cs_ctrl_write_en : std_logic;
|
||||
signal cs_ctrl_read_en : std_logic;
|
||||
signal cs_ctrl_read_valid : std_logic;
|
||||
signal cs_ctrl_read_data : std_logic_vector(31 downto 0);
|
||||
--
|
||||
signal cs_pg_write_en : std_logic_vector(ch_num-1 downto 0);
|
||||
signal cs_pg_read_en : std_logic_vector(ch_num-1 downto 0);
|
||||
signal cs_pg_read_valid : std_logic_vector(ch_num-1 downto 0);
|
||||
signal cs_pg_read_data : std_logic_vector(32*ch_num-1 downto 0);
|
||||
--
|
||||
signal cs_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_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 remote_init : std_logic;
|
||||
signal dp_dir : std_logic_vector(ch_num-1 downto 0);
|
||||
signal set_pos_ie : std_logic;
|
||||
signal enc_pulse : std_logic;
|
||||
signal enc_pulse_ie : std_logic;
|
||||
signal enc_pulse_pof : std_logic;
|
||||
signal pd_pulse : std_logic;
|
||||
signal pd_pulse_ie : std_logic;
|
||||
signal pd_pulse_pof : std_logic;
|
||||
signal inc_pos : std_logic;
|
||||
signal inc_pos_pof : std_logic;
|
||||
signal inc_pos_ie : std_logic;
|
||||
signal dec_pos : std_logic;
|
||||
signal dec_pos_pof : std_logic;
|
||||
signal dec_pos_ie : std_logic;
|
||||
signal abs_pos : std_logic_vector(31 downto 0);
|
||||
signal abs_pos_pof : std_logic_vector(31 downto 0);
|
||||
signal abs_pos_ie : std_logic_vector(39 downto 0);
|
||||
--
|
||||
signal ch_pd, ch_pulse_out : std_logic_vector(ch_num-1 downto 0);
|
||||
signal ch_raw_pulse, ch_mask : std_logic_vector(ch_num-1 downto 0);
|
||||
signal fire_pulse_i : std_logic_vector(ch_num-1 downto 0);
|
||||
signal src_sel : std_logic_vector(1 downto 0);
|
||||
--
|
||||
signal one_pps : std_logic;
|
||||
signal ext_fp_det : std_logic_vector(15 downto 0);
|
||||
signal ext_fp_gen : std_logic_vector(15 downto 0);
|
||||
signal pof_rx_regen : std_logic;
|
||||
|
||||
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_1
|
||||
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_g : for i in 1 to ch_num generate
|
||||
cs_pg_write_en(i-1) <= cs_write_en(pg_ch_id+i-1);
|
||||
end generate;
|
||||
cs_nsnk_write_en <= cs_write_en(net_snk_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_g : for i in 1 to ch_num generate
|
||||
cs_pg_read_en(i-1) <= cs_read_en(pg_ch_id+i-1);
|
||||
end generate;
|
||||
cs_nsnk_read_en <= cs_read_en(net_snk_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_g : for i in 1 to ch_num generate
|
||||
cs_read_valid(pg_ch_id+i-1) <= cs_pg_read_valid(i-1);
|
||||
end generate;
|
||||
cs_read_valid(net_snk_id) <= cs_nsnk_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_pg_g : for i in 1 to ch_num generate
|
||||
cs_read_data(31+32*(pg_ch_id+i-1) downto 32*(pg_ch_id+i-1)) <= cs_pg_read_data(31+32*(i-1) downto 32*(i-1));
|
||||
end generate;
|
||||
cs_read_data(31+32*net_snk_id downto 32*net_snk_id) <= cs_nsnk_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_1
|
||||
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,
|
||||
ext_fp_det => ext_fp_det,
|
||||
ext_fp_gen => ext_fp_gen,
|
||||
ins_fpm_irq_0 => ins_fpm_irq_0,
|
||||
avs_address => cs_addr(3 downto 0),
|
||||
avs_write => cs_ctrl_write_en,
|
||||
avs_writedata => cs_write_data,
|
||||
avs_read => cs_ctrl_read_en,
|
||||
avs_readdatavalid => cs_ctrl_read_valid,
|
||||
avs_readdata => cs_ctrl_read_data);
|
||||
|
||||
-- Output multiplexer
|
||||
fire_pulse_i <= ch_pulse_out when src_sel(0) = '1' else (others => pof_rx_regen);
|
||||
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;
|
||||
|
||||
mon_point_src( 0) <= remote_init;
|
||||
mon_point_src( 1) <= dp_dir(0);
|
||||
mon_point_src( 2) <= pd_pulse;
|
||||
mon_point_src( 3) <= enc_pulse;
|
||||
mon_point_src( 4) <= ch_pd(0);
|
||||
mon_point_src( 5) <= ch_pulse_out(0);
|
||||
mon_point_src( 6) <= ch_raw_pulse(0);
|
||||
mon_point_src( 7) <= ch_mask(0);
|
||||
mon_point_src( 8) <= pof_rx;
|
||||
mon_point_src( 9) <= fire_pulse_i(0);
|
||||
--
|
||||
mon_point_src(15 downto 10) <= (others => '0');
|
||||
|
||||
pof_iso_en <= enable_rx;
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Pulse Generator
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
pulse_generator_g : for i in 1 to ch_num generate
|
||||
iCH_PG: entity work.pulse_generator_1
|
||||
generic map(
|
||||
out_pulse_condition => true)
|
||||
port map (
|
||||
clk => clk,
|
||||
reset_n => reset_n_i,
|
||||
init => remote_init,
|
||||
pd_in => pd_pulse,
|
||||
abs_position => abs_pos,
|
||||
dp_dir => dp_dir(i-1),
|
||||
pulse_out => ch_pulse_out(i-1),
|
||||
ch_pd => ch_pd(i-1),
|
||||
ch_mask => ch_mask(i-1),
|
||||
raw_pulse_out => ch_raw_pulse(i-1),
|
||||
enc_pulse => open,
|
||||
avs_address => cs_addr(9 downto 0),
|
||||
avs_write => cs_pg_write_en(i-1),
|
||||
avs_writedata => cs_write_data,
|
||||
avs_read => cs_pg_read_en(i-1),
|
||||
avs_readdatavalid => cs_pg_read_valid(i-1),
|
||||
avs_readdata => cs_pg_read_data(31+32*(i-1) downto 32*(i-1)));
|
||||
end generate;
|
||||
-----------------------------------------------------------------------------
|
||||
-- POF Interface
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
-- POF Receiver
|
||||
iPOF_RX : entity work.pof_rx
|
||||
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(0),
|
||||
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
|
||||
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);
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Ext fire pulse regen
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
fire_pulse_ext_i : entity work.fire_pulse_ext_1
|
||||
port map (
|
||||
reset_n => reset_n_i,
|
||||
clk => clk,
|
||||
|
||||
ext_fp_det => ext_fp_det,
|
||||
ext_fp_gen => ext_fp_gen,
|
||||
|
||||
ext_in => pof_rx,
|
||||
ext_out => pof_rx_regen
|
||||
);
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Internal encoder generator
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
iEMUL: entity work.enc_pd_emul_1
|
||||
generic map (
|
||||
SEQ_ENABLE => false)
|
||||
port map (
|
||||
clk => clk,
|
||||
reset_n => reset_n_i,
|
||||
ttl_pd => open,
|
||||
ttl_enc_p1 => open,
|
||||
ttl_enc_p2 => open,
|
||||
ttl_enc_zp => open,
|
||||
rs422_pd => pd_pulse_ie,
|
||||
rs422_enc_p1 => open,
|
||||
rs422_enc_p2 => open,
|
||||
rs422_enc_zp => open,
|
||||
abs_pos_out => abs_pos_ie,
|
||||
set_pos_out => set_pos_ie,
|
||||
inc_pos_out => inc_pos_ie,
|
||||
dec_pos_out => dec_pos_ie,
|
||||
avs_address => cs_addr(9 downto 0),
|
||||
avs_write => cs_ie_write_en,
|
||||
avs_writedata => cs_write_data,
|
||||
avs_read => cs_ie_read_en,
|
||||
avs_readdatavalid => cs_ie_read_valid,
|
||||
avs_readdata => cs_ie_read_data);
|
||||
|
||||
enc_pulse_ie <= inc_pos_ie when dp_dir(0) = '0' else dec_pos_ie;
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- NetSync Sink
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
-- Not instantiated yet
|
||||
pNSNK_RD_VALID : process(clk)
|
||||
begin
|
||||
if(clk = '1' and clk'event) then
|
||||
cs_nsnk_read_valid <= cs_nsnk_read_en;
|
||||
end if;
|
||||
end process pNSNK_RD_VALID;
|
||||
|
||||
cs_nsnk_read_data <= X"DEAD_BEEF";
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Event Logger
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
-- Not instantiated yet
|
||||
pLOG_RD_VALID : process(clk)
|
||||
begin
|
||||
if(clk = '1' and clk'event) then
|
||||
cs_log_read_valid <= cs_log_read_en;
|
||||
end if;
|
||||
end process pLOG_RD_VALID;
|
||||
|
||||
cs_log_read_data <= X"DEAD_BEEF";
|
||||
|
||||
end architecture rtl;
|
||||
37
generic_ip/fire_pulse_manager/1/src/fire_pulse_pkg_1.vhd
Normal file
37
generic_ip/fire_pulse_manager/1/src/fire_pulse_pkg_1.vhd
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
-------------------------------------------------------------------------------
|
||||
-- Title : fire_pulse_pkg
|
||||
-- Project : HMB/EMB/SMB
|
||||
-------------------------------------------------------------------------------
|
||||
-- File : fire_pulse_pkg.vhd
|
||||
-- Author : Gianmarco Girau
|
||||
-- Company : Global Inkjet Systems
|
||||
-- Created : 2017-09-08
|
||||
-- Last update: 2017-09-08
|
||||
-- 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_1_pkg is
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Inner block mapping
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
constant blk_num : integer := 8; -- number of sub-blocks with dedicated
|
||||
-- C&S registers
|
||||
constant ch_num : integer := 4; -- number of Pulse-Generator blocks
|
||||
|
||||
constant fp_ctrl_id : natural := 0; -- Block ID for the Fire-Pulse-Mang Controller
|
||||
constant net_snk_id : natural := 1; -- Block ID for Net-Sync Sink
|
||||
constant log_blk_id : natural := 2; -- Block ID for the Event Logger
|
||||
constant int_enc_id : natural := 3; -- Block ID for the Internal Encoder Block
|
||||
constant pg_ch_id : natural := 4; -- Block ID for Pulse-Generator
|
||||
|
||||
end package fire_pulse_1_pkg;
|
||||
357
generic_ip/fire_pulse_manager/1/src/pof_rx.vhd
Normal file
357
generic_ip/fire_pulse_manager/1/src/pof_rx.vhd
Normal file
|
|
@ -0,0 +1,357 @@
|
|||
-------------------------------------------------------------------------------
|
||||
-- Title : pof_rx
|
||||
-- Project : SMB
|
||||
-------------------------------------------------------------------------------
|
||||
-- File : pof_rx.vhd
|
||||
-- Author : Gianmarco Girau
|
||||
-- Company : Global Inkjet Systems
|
||||
-- Created : 2017-08-23
|
||||
-- Last update: 2018-06-28
|
||||
-- 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 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;
|
||||
|
||||
architecture rtl of pof_rx 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;
|
||||
61
generic_ip/fire_pulse_manager/1/src/sync_wire.vhd
Normal file
61
generic_ip/fire_pulse_manager/1/src/sync_wire.vhd
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
-------------------------------------------------------------------------------
|
||||
-- Title : sync_wire
|
||||
-------------------------------------------------------------------------------
|
||||
-- File : sync_wire.vhd
|
||||
-- Author : Gianmarco Girau <ggianmarco.girau@gmail.com>
|
||||
-- Company : On my own
|
||||
-- Target : Generic (simulation), Generic (synthesis)
|
||||
-- Dependency : none
|
||||
-------------------------------------------------------------------------------
|
||||
-- Description: synchronize a std_logic signal to a clock domain
|
||||
-------------------------------------------------------------------------------
|
||||
-- Last update: 2015-08-17
|
||||
-------------------------------------------------------------------------------
|
||||
-- Revisions :
|
||||
-- Date Version Author Description
|
||||
-- 2010-10-25 1.0 gmg Created
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
|
||||
entity sync_wire is
|
||||
generic(
|
||||
rst_val : std_logic := '0';
|
||||
sync_stages : positive := 2);
|
||||
port(
|
||||
rstN : in std_logic;
|
||||
clk : in std_logic;
|
||||
async_in : in std_logic;
|
||||
sync_out : out std_logic);
|
||||
end sync_wire;
|
||||
|
||||
architecture RTL of sync_wire is
|
||||
|
||||
signal sync_sig : std_logic_vector(sync_stages-1 downto 0);
|
||||
|
||||
begin
|
||||
|
||||
pSYNC : process(rstN, clk)
|
||||
begin
|
||||
if(rstN = '0') then
|
||||
for n in 0 to sync_stages-1 loop
|
||||
sync_sig(n) <= rst_val;
|
||||
end loop; -- n
|
||||
elsif(clk = '1' and clk'event) then
|
||||
for n in 0 to sync_stages-1 loop
|
||||
if(n = 0) then
|
||||
sync_sig(0) <= async_in;
|
||||
else
|
||||
sync_sig(n) <= sync_sig(n-1);
|
||||
end if;
|
||||
end loop; -- n
|
||||
end if;
|
||||
end process pSYNC;
|
||||
|
||||
sync_out <= sync_sig(sync_stages-1);
|
||||
|
||||
end RTL;
|
||||
|
||||
|
||||
|
||||
66
generic_ip/fire_pulse_manager/1/src/sync_wire_rEdge.vhd
Normal file
66
generic_ip/fire_pulse_manager/1/src/sync_wire_rEdge.vhd
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
-------------------------------------------------------------------------------
|
||||
-- Title : sync_wire_rEdge
|
||||
-------------------------------------------------------------------------------
|
||||
-- File : sync_wire_rEdge.vhd
|
||||
-- Author : Gianmarco Girau <ggianmarco.girau@gmail.com>
|
||||
-- Company : On my own
|
||||
-- Target : Generic (simulation), Generic (synthesis)
|
||||
-- Dependency : none
|
||||
-------------------------------------------------------------------------------
|
||||
-- Description: synchronize a std_logic signal to a clock domain with rising edge
|
||||
-------------------------------------------------------------------------------
|
||||
-- Last update: 2015-08-17
|
||||
-------------------------------------------------------------------------------
|
||||
-- Revisions :
|
||||
-- Date Version Author Description
|
||||
-- 2010-12-03 1.0 gmg Created
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
|
||||
entity sync_wire_rEdge is
|
||||
generic(
|
||||
rst_val : std_logic := '0';
|
||||
sync_stages : positive := 2);
|
||||
port(
|
||||
rstN : in std_logic;
|
||||
clk : in std_logic;
|
||||
async_in : in std_logic;
|
||||
sync_out : out std_logic);
|
||||
end sync_wire_rEdge;
|
||||
|
||||
architecture RTL of sync_wire_rEdge is
|
||||
|
||||
signal sync_out_i, sync_out_d : std_logic;
|
||||
signal sync_sig : std_logic_vector(sync_stages-1 downto 0);
|
||||
|
||||
begin
|
||||
|
||||
pSYNC : process(rstN, clk)
|
||||
begin
|
||||
if(rstN = '0') then
|
||||
sync_out_d <= rst_val;
|
||||
for n in 0 to sync_stages-1 loop
|
||||
sync_sig(n) <= rst_val;
|
||||
end loop; -- n
|
||||
elsif(clk = '1' and clk'event) then
|
||||
sync_out_d <= sync_out_i;
|
||||
for n in 0 to sync_stages-1 loop
|
||||
if(n = 0) then
|
||||
sync_sig(0) <= async_in;
|
||||
else
|
||||
sync_sig(n) <= sync_sig(n-1);
|
||||
end if;
|
||||
end loop; -- n
|
||||
end if;
|
||||
end process pSYNC;
|
||||
|
||||
sync_out_i <= sync_sig(sync_stages-1);
|
||||
-- rising edge detect
|
||||
sync_out <= sync_out_i and not sync_out_d;
|
||||
|
||||
end RTL;
|
||||
|
||||
|
||||
|
||||
169
generic_ip/fire_pulse_manager/1/src/uart_regen.vhd
Normal file
169
generic_ip/fire_pulse_manager/1/src/uart_regen.vhd
Normal file
|
|
@ -0,0 +1,169 @@
|
|||
-------------------------------------------------------------------------------
|
||||
-- Title : uart_regen
|
||||
-- Project : EMB-1
|
||||
-------------------------------------------------------------------------------
|
||||
-- File : uart_regen.vhd
|
||||
-- Author : Gianmarco Girau
|
||||
-- Company : Global Inkjet Systems
|
||||
-- Created : 2017-10-31
|
||||
-- Last update: 2017-10-31
|
||||
-- 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 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;
|
||||
|
||||
architecture rtl of uart_regen 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;
|
||||
188
generic_ip/fire_pulse_manager/1/src/uart_rx.vhd
Normal file
188
generic_ip/fire_pulse_manager/1/src/uart_rx.vhd
Normal file
|
|
@ -0,0 +1,188 @@
|
|||
-------------------------------------------------------------------------------
|
||||
-- Title : uart_rx
|
||||
-- Project : EMB-1
|
||||
-------------------------------------------------------------------------------
|
||||
-- File : uart_rx.vhd
|
||||
-- Author : Gianmarco Girau
|
||||
-- Company : Global Inkjet Systems
|
||||
-- Created : 2016-10-24
|
||||
-- Last update: 2018-09-12
|
||||
-- SVN ID : Git
|
||||
-- Standard : VHDL'08
|
||||
-------------------------------------------------------------------------------
|
||||
-- Description:
|
||||
-- Simple UART receiver, used to receive data over the POF, 1 start, 1 stop
|
||||
-- bit, no parity
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
library ieee;
|
||||
use ieee.std_logic_1164.all;
|
||||
use ieee.numeric_std.all;
|
||||
|
||||
entity uart_rx 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
|
||||
init : in std_logic;
|
||||
data_out : out std_logic_vector(data_width-1 downto 0);
|
||||
data_out_valid : out std_logic;
|
||||
rx_error : out std_logic;
|
||||
rx_data : in std_logic);
|
||||
end entity uart_rx;
|
||||
|
||||
architecture rtl of uart_rx 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_get_start_bit, s_get_data, s_get_stop_bit);
|
||||
|
||||
signal fsm_state_curr, fsm_state_next : fsm_state_t;
|
||||
--
|
||||
signal rx_data_i, shf_data, rst_bit_cnt, inc_bit_cnt : std_logic;
|
||||
signal rst_clk_cnt, end_of_bit, end_of_rx, data_valid : std_logic;
|
||||
signal stop_bit, rx_error_i : std_logic;
|
||||
--
|
||||
signal data : std_logic_vector(data_width-1 downto 0);
|
||||
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 => rx_data,
|
||||
sync_out => rx_data_i);
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- 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(rst_clk_cnt = '1') then
|
||||
data <= (others => '0');
|
||||
elsif(shf_data = '1') then
|
||||
data <= rx_data_i & data(data'high downto 1);
|
||||
end if;
|
||||
data_out_valid <= data_valid;
|
||||
if(init = '1') then
|
||||
data_out <= (others => '0');
|
||||
elsif(data_valid = '1') then
|
||||
data_out <= data;
|
||||
end if;
|
||||
rx_error <= rx_error_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 else '0';
|
||||
|
||||
--shf_data <= '1' when unsigned(clk_cnt) = 1 and stop_bit = '0' else '0';
|
||||
shf_data <= '1' when unsigned(clk_cnt) = (unsigned(bit_div(bit_div'high downto 1))-1) and stop_bit = '0' else '0';
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- FSM
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
-- FSM state register
|
||||
pFSM_SR : process(clk)
|
||||
begin
|
||||
if(clk = '1' and clk'event) then
|
||||
if(init = '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, rx_data_i, end_of_bit, end_of_rx)
|
||||
begin
|
||||
--default assignments
|
||||
rst_clk_cnt <= '0';
|
||||
rst_bit_cnt <= '0';
|
||||
inc_bit_cnt <= '0';
|
||||
data_valid <= '0';
|
||||
stop_bit <= '0';
|
||||
rx_error_i <= '0';
|
||||
--
|
||||
fsm_state_next <= fsm_state_curr;
|
||||
|
||||
case fsm_state_curr is
|
||||
when s_init =>
|
||||
if(rx_data_i = '1') then
|
||||
fsm_state_next <= s_idle;
|
||||
end if;
|
||||
|
||||
when s_idle =>
|
||||
if(rx_data_i = '0') then
|
||||
rst_clk_cnt <= '1';
|
||||
rst_bit_cnt <= '1';
|
||||
fsm_state_next <= s_get_start_bit;
|
||||
end if;
|
||||
|
||||
when s_get_start_bit =>
|
||||
if(end_of_bit = '1') then
|
||||
inc_bit_cnt <= '1';
|
||||
fsm_state_next <= s_get_data;
|
||||
end if;
|
||||
|
||||
when s_get_data =>
|
||||
if(end_of_bit = '1') then
|
||||
inc_bit_cnt <= '1';
|
||||
if(end_of_rx = '1') then
|
||||
fsm_state_next <= s_get_stop_bit;
|
||||
end if;
|
||||
end if;
|
||||
|
||||
when s_get_stop_bit =>
|
||||
stop_bit <= '1';
|
||||
if(end_of_bit = '1') then
|
||||
if(rx_data_i = '1') then
|
||||
data_valid <= '1';
|
||||
fsm_state_next <= s_idle;
|
||||
else
|
||||
rx_error_i <= '1';
|
||||
fsm_state_next <= s_init;
|
||||
end if;
|
||||
end if;
|
||||
|
||||
when others => null;
|
||||
end case;
|
||||
end process pFSM_CL;
|
||||
|
||||
|
||||
end architecture rtl;
|
||||
Loading…
Add table
Add a link
Reference in a new issue