CORE-73 CORE-80 - Restructured the logic for SEB-EPD LEDs

This commit is contained in:
gianmarcogirau 2020-01-20 16:44:16 +00:00
commit 491d84fc17
10 changed files with 1027 additions and 301 deletions

View file

@ -99,7 +99,7 @@
"type" : "w",
"bit_len" : "3",
"reset" : "0x0",
"description" : "PD source selection"
"description" : "PD source selection: Bit-0: 0 => RS422, 1 => Single-Ended. Bit-1: 1 => Exclude Harware PDs. Bit-2: 0 => In single-ended mode use PNP, 1 => In single-ended mode use NPN"
},
"enc_ph1_en" : {
"type" : "w",

View file

@ -6,7 +6,7 @@
-- Author : Gianmarco Girau
-- Company : Global Inkjet Systems
-- Created : 2019-04-17
-- Last update: 2019-04-17
-- Last update: 2020-01-17
-- SVN ID : Git
-- Standard : VHDL'2008
-------------------------------------------------------------------------------
@ -72,41 +72,6 @@ architecture rtl of lut_divider_0 is
X"011A7B96", X"01194538", X"01181181", X"0116E068", X"0115B1E5", X"011485F0", X"01135C81", X"0112358E",
X"01111111", X"010FEF01", X"010ECF56", X"010DB20A", X"010C9714", X"010B7E6E", X"010A6810", X"010953F3",
X"01084210", X"01073260", X"010624DD", X"0105197F", X"01041041", X"0103091B", X"01020408", X"01010101");
/*
X"FFFFFFFF", X"7FFFFFFF", X"55555555", X"3FFFFFFF", X"33333333", X"2AAAAAAA", X"24924924", X"1FFFFFFF",
X"1C71C71C", X"19999999", X"1745D174", X"15555555", X"13B13B13", X"12492492", X"11111111", X"0FFFFFFF",
X"0F0F0F0F", X"0E38E38E", X"0D79435E", X"0CCCCCCC", X"0C30C30C", X"0BA2E8BA", X"0B21642C", X"0AAAAAAA",
X"0A3D70A3", X"09D89D89", X"097B425E", X"09249249", X"08D3DCB0", X"08888888", X"08421084", X"07FFFFFF",
X"07C1F07C", X"07878787", X"07507507", X"071C71C7", X"06EB3E45", X"06BCA1AF", X"06906906", X"06666666",
X"063E7063", X"06186186", X"05F417D0", X"05D1745D", X"05B05B05", X"0590B216", X"0572620A", X"05555555",
X"05397829", X"051EB851", X"05050505", X"04EC4EC4", X"04D4873E", X"04BDA12F", X"04A7904A", X"04924924",
X"047DC11F", X"0469EE58", X"0456C797", X"04444444", X"04325C53", X"04210842", X"04104104", X"03FFFFFF",
X"03F03F03", X"03E0F83E", X"03D22635", X"03C3C3C3", X"03B5CC0E", X"03A83A83", X"039B0AD1", X"038E38E3",
X"0381C0E0", X"03759F22", X"0369D036", X"035E50D7", X"03531DEC", X"03483483", X"033D91D2", X"03333333",
X"0329161F", X"031F3831", X"03159721", X"030C30C3", X"03030303", X"02FA0BE8", X"02F14990", X"02E8BA2E",
X"02E05C0B", X"02D82D82", X"02D02D02", X"02C8590B", X"02C0B02C", X"02B93105", X"02B1DA46", X"02AAAAAA",
X"02A3A0FD", X"029CBC14", X"0295FAD4", X"028F5C28", X"0288DF0C", X"02828282", X"027C4597", X"02762762",
X"02702702", X"026A439F", X"02647C69", X"025ED097", X"02593F69", X"0253C825", X"024E6A17", X"02492492",
X"0243F6F0", X"023EE08F", X"0239E0D5", X"0234F72C", X"02302302", X"022B63CB", X"0226B902", X"02222222",
X"021D9EAD", X"02192E29", X"0214D021", X"02108421", X"020C49BA", X"02082082", X"02040810", X"01FFFFFF",
X"01FC07F0", X"01F81F81", X"01F44659", X"01F07C1F", X"01ECC07B", X"01E9131A", X"01E573AC", X"01E1E1E1",
X"01DE5D6E", X"01DAE607", X"01D77B65", X"01D41D41", X"01D0CB58", X"01CD8568", X"01CA4B30", X"01C71C71",
X"01C3F8F0", X"01C0E070", X"01BDD2B8", X"01BACF91", X"01B7D6C3", X"01B4E81B", X"01B20364", X"01AF286B",
X"01AC5701", X"01A98EF6", X"01A6D01A", X"01A41A41", X"01A16D3F", X"019EC8E9", X"019C2D14", X"01999999",
X"01970E4F", X"01948B0F", X"01920FB4", X"018F9C18", X"018D3018", X"018ACB90", X"01886E5F", X"01861861",
X"0183C977", X"01818181", X"017F405F", X"017D05F4", X"017AD220", X"0178A4C8", X"01767DCE", X"01745D17",
X"01724287", X"01702E05", X"016E1F76", X"016C16C1", X"016A13CD", X"01681681", X"01661EC6", X"01642C85",
X"01623FA7", X"01605816", X"015E75BB", X"015C9882", X"015AC056", X"0158ED23", X"01571ED3", X"01555555",
X"01539094", X"0151D07E", X"01501501", X"014E5E0A", X"014CAB88", X"014AFD6A", X"0149539E", X"0147AE14",
X"01460CBC", X"01446F86", X"0142D662", X"01414141", X"013FB013", X"013E22CB", X"013C995A", X"013B13B1",
X"013991C2", X"01381381", X"013698DF", X"013521CF", X"0133AE45", X"01323E34", X"0130D190", X"012F684B",
X"012E025C", X"012C9FB4", X"012B404A", X"0129E412", X"01288B01", X"0127350B", X"0125E227", X"01249249",
X"01234567", X"0121FB78", X"0120B470", X"011F7047", X"011E2EF3", X"011CF06A", X"011BB4A4", X"011A7B96",
X"01194538", X"01181181", X"0116E068", X"0115B1E5", X"011485F0", X"01135C81", X"0112358E", X"01111111",
X"010FEF01", X"010ECF56", X"010DB20A", X"010C9714", X"010B7E6E", X"010A6810", X"010953F3", X"01084210",
X"01073260", X"010624DD", X"0105197F", X"01041041", X"0103091B", X"01020408", X"01010101", X"00FFFFFF");
*/
signal addr : std_logic_vector( 7 downto 0);
signal lut_q : std_logic_vector(31 downto 0);

View file

@ -53,8 +53,63 @@
}
}
},
"fpm_init": {
"fpm_config": {
"address": "2",
"width": "11",
"description": "Configuration values for the FPM",
"fields": {
"ch_num" : {
"type" : "r",
"bit_len" : "4",
"reset" : "0",
"description" : "Number of channels"
},
"seb_epd_logic_present" : {
"type" : "r",
"bit_len" : "1",
"reset" : "0",
"description" : "0 => SEB-EPD logic not present, 1 => SEB-EPD logic present"
},
"smb_diagnostic_present" : {
"type" : "r",
"bit_len" : "1",
"reset" : "0",
"description" : "0 => SMB diagnostic block not present, 1 => SMB diagnostic block present"
},
"event_logger_present" : {
"type" : "r",
"bit_len" : "1",
"reset" : "0",
"description" : "0 => Event Logger block not present, 1 => Event Logger block present"
},
"pof_protocol_version" : {
"type" : "r",
"bit_len" : "1",
"reset" : "0",
"description" : "0 => Support POF protocol version 0, 1 => Support POF protocol version 1"
},
"delay_equalization_enable" : {
"type" : "r",
"bit_len" : "1",
"reset" : "0",
"description" : "0 => No support for delay equalization, 1 => Support for delay equalization"
},
"tof_comp_enable" : {
"type" : "r",
"bit_len" : "1",
"reset" : "0",
"description" : "0 => No support for Time-of-Flight compensation, 1 => Support for Time-of-Flight compensation"
},
"pixel_pitch_corr_enable" : {
"type" : "r",
"bit_len" : "1",
"reset" : "0",
"description" : "0 => No support for pixel-pitch correction, 1 => Support for pixel-pitch correction"
}
}
},
"fpm_init": {
"address": "3",
"width": "2",
"description": "Controls signal selection",
"fields": {
@ -73,7 +128,7 @@
}
},
"Signal selection": {
"address": "3",
"address": "4",
"width": "4",
"description": "Controls signal selection",
"fields": {
@ -104,7 +159,7 @@
}
},
"pof_receiver_control": {
"address": "4",
"address": "5",
"width": "8",
"description": "Controls POF receiver",
"fields": {
@ -141,7 +196,7 @@
}
},
"monitoring_point_selection": {
"address": "5",
"address": "6",
"width": "16",
"description": "Selects monitoring points for external header",
"fields": {
@ -173,13 +228,13 @@
},
"coarse_time_init": {
"type": "w",
"address": "6",
"address": "7",
"reset": "0x00000000",
"width": "32",
"description": "Defines coarse time counter value"
},
"fine_time_init": {
"address": "7",
"address": "8",
"width": "29",
"description": "Fine time counter value/Load counter enable",
"fields": {
@ -199,20 +254,20 @@
},
"fine_time_status": {
"type": "r",
"address": "8",
"address": "9",
"reset": "0x0000000",
"width": "28",
"description": "Current fine time counter value"
},
"coarse_time_status": {
"type": "r",
"address": "9",
"address": "10",
"reset": "0x00000000",
"width": "32",
"description": "Current coarse time counter value"
},
"pof_rx_status": {
"address": "10",
"address": "11",
"width": "32",
"description": "Status of POF receiver",
"fields": {
@ -231,7 +286,7 @@
}
},
"pof_rx_control": {
"address": "11",
"address": "12",
"width": "12",
"description": "POF receiver error control",
"fields": {
@ -268,7 +323,7 @@
}
},
"fpm_interrupt": {
"address": "12",
"address": "13",
"width": "16",
"description": "Interrupt control",
"fields": {
@ -319,7 +374,7 @@
}
},
"fpm_ext_ctrl": {
"address": "13",
"address": "14",
"width": "32",
"description": "Controls regeneration of external fire pulses",
"fields": {
@ -338,7 +393,7 @@
}
},
"drop_watch_config": {
"address": "14",
"address": "15",
"width": "32",
"description": "Drop-Watch configuration",
"fields": {
@ -362,7 +417,7 @@
}
},
"seb_epd_led_status": {
"address": "15",
"address": "16",
"width": "12",
"description": "SEB-EPD LED status",
"fields": {

View file

@ -0,0 +1,49 @@
# Simulation macro
#.main clear
set OSVVM_PATH ../../../common/0/src/test/OSVVM
set COMMON_PATH ../../../common/0/src
set WORKLIB work
vlib ./work
vmap work ./work
# Compile the UUT
vcom -2008 -work $WORKLIB ../src/seb_epd_led_gen_5.vhd
# Compile the constrained random related packages
vlib OSVVM
vcom -2008 -work OSVVM \
$OSVVM_PATH/RandomBasePkg.vhd \
$OSVVM_PATH/SortListPkg_int.vhd \
$OSVVM_PATH/RandomPkg.vhd \
$OSVVM_PATH/NamePkg.vhd \
$OSVVM_PATH/MessagePkg.vhd \
$OSVVM_PATH/CoveragePkg.vhd
# Compile support files
vcom -2008 -work $WORKLIB $COMMON_PATH/test/common_test_pkg.vhd
vcom -2008 -work $WORKLIB $COMMON_PATH/test/log_pkg.vhd
vcom -2008 -work $WORKLIB $COMMON_PATH//test/avalon_verify_pkg.vhd
# Compile the testbench
vcom -2008 -work $WORKLIB ./../src/test/led_tb.vhd
vsim -t ps work.led_tb
#add wave /led_tb/*
#add wave /led_tb/iUUT/*
# remove warnings from standard numeric/arithmetic packages (speed-up simulation)
set StdArithNoWarnings 1
set NumericStdNoWarnings 1
do wave_led.do
when -label end_of_simulation {test_completed == true} {echo "Simulation Completed"; stop ;}
run -all
#run 200 us;

View file

@ -0,0 +1,105 @@
onerror {resume}
quietly WaveActivateNextPane {} 0
add wave -noupdate /led_tb/reset_n
add wave -noupdate /led_tb/clk
add wave -noupdate /led_tb/init
add wave -noupdate /led_tb/pd
add wave -noupdate /led_tb/enc_p1
add wave -noupdate /led_tb/enc_p2
add wave -noupdate /led_tb/pof
add wave -noupdate /led_tb/all_ok
add wave -noupdate /led_tb/led_pd_g
add wave -noupdate /led_tb/led_pd_y
add wave -noupdate /led_tb/led_pd_r
add wave -noupdate /led_tb/led_enc_p1_g
add wave -noupdate /led_tb/led_enc_p1_y
add wave -noupdate /led_tb/led_enc_p1_r
add wave -noupdate /led_tb/led_enc_p2_g
add wave -noupdate /led_tb/led_enc_p2_y
add wave -noupdate /led_tb/led_enc_p2_r
add wave -noupdate /led_tb/led_pof_g
add wave -noupdate /led_tb/led_pof_y
add wave -noupdate /led_tb/led_pof_r
add wave -noupdate /led_tb/setup
add wave -noupdate /led_tb/running
add wave -noupdate /led_tb/passed
add wave -noupdate /led_tb/failed
add wave -noupdate /led_tb/test_timeout
add wave -noupdate /led_tb/test_completed
add wave -noupdate /led_tb/error_flag
add wave -noupdate /led_tb/iUUT/reset_n
add wave -noupdate /led_tb/iUUT/clk
add wave -noupdate /led_tb/iUUT/init
add wave -noupdate /led_tb/iUUT/pd
add wave -noupdate /led_tb/iUUT/enc_p1
add wave -noupdate /led_tb/iUUT/enc_p2
add wave -noupdate /led_tb/iUUT/pof
add wave -noupdate /led_tb/iUUT/all_ok
add wave -noupdate /led_tb/iUUT/led_pd_g
add wave -noupdate /led_tb/iUUT/led_pd_y
add wave -noupdate /led_tb/iUUT/led_pd_r
add wave -noupdate /led_tb/iUUT/led_enc_p1_g
add wave -noupdate /led_tb/iUUT/led_enc_p1_y
add wave -noupdate /led_tb/iUUT/led_enc_p1_r
add wave -noupdate /led_tb/iUUT/led_enc_p2_g
add wave -noupdate /led_tb/iUUT/led_enc_p2_y
add wave -noupdate /led_tb/iUUT/led_enc_p2_r
add wave -noupdate /led_tb/iUUT/led_pof_g
add wave -noupdate /led_tb/iUUT/led_pof_y
add wave -noupdate /led_tb/iUUT/led_pof_r
add wave -noupdate /led_tb/iUUT/pd_d
add wave -noupdate /led_tb/iUUT/enc_p1_d
add wave -noupdate /led_tb/iUUT/enc_p2_d
add wave -noupdate /led_tb/iUUT/one_ms_pulse
add wave -noupdate /led_tb/iUUT/pd_event
add wave -noupdate /led_tb/iUUT/p1_prev_event
add wave -noupdate /led_tb/iUUT/p2_prev_event
add wave -noupdate /led_tb/iUUT/pd_cnt_zero_flag
add wave -noupdate /led_tb/iUUT/rst_pd_green
add wave -noupdate /led_tb/iUUT/pd_red
add wave -noupdate /led_tb/iUUT/pd_green
add wave -noupdate /led_tb/iUUT/p1_event
add wave -noupdate /led_tb/iUUT/p2_event
add wave -noupdate /led_tb/iUUT/p1_cnt_zero_flag
add wave -noupdate /led_tb/iUUT/p2_cnt_zero_flag
add wave -noupdate /led_tb/iUUT/rst_p1_green
add wave -noupdate /led_tb/iUUT/rst_p2_green
add wave -noupdate /led_tb/iUUT/p1_red
add wave -noupdate /led_tb/iUUT/p2_red
add wave -noupdate /led_tb/iUUT/p1_green
add wave -noupdate /led_tb/iUUT/p2_green
add wave -noupdate /led_tb/iUUT/pof_green
add wave -noupdate /led_tb/iUUT/rst_pof_green
add wave -noupdate /led_tb/iUUT/pof_d
add wave -noupdate /led_tb/iUUT/pof_event
add wave -noupdate /led_tb/iUUT/pof_cnt_zero_flag
add wave -noupdate /led_tb/iUUT/all_ok_d
add wave -noupdate /led_tb/iUUT/alert_cnt_zero_flag
add wave -noupdate /led_tb/iUUT/pd_active
add wave -noupdate /led_tb/iUUT/p1_active
add wave -noupdate /led_tb/iUUT/p2_active
add wave -noupdate /led_tb/iUUT/alert_led
add wave -noupdate -radix unsigned /led_tb/iUUT/pd_cnt
add wave -noupdate -radix unsigned /led_tb/iUUT/p1_cnt
add wave -noupdate -radix unsigned /led_tb/iUUT/p2_cnt
add wave -noupdate -radix unsigned /led_tb/iUUT/pof_cnt
add wave -noupdate -radix unsigned /led_tb/iUUT/alert_cnt
add wave -noupdate -radix unsigned /led_tb/iUUT/one_ms_cnt
TreeUpdate [SetDefaultTree]
WaveRestoreCursors {{Cursor 1} {510235000 ps} 0}
quietly wave cursor active 1
configure wave -namecolwidth 238
configure wave -valuecolwidth 137
configure wave -justifyvalue left
configure wave -signalnamewidth 0
configure wave -snapdistance 10
configure wave -datasetprefix 0
configure wave -rowmargin 4
configure wave -childrowmargin 2
configure wave -gridoffset 0
configure wave -gridperiod 1
configure wave -griddelta 40
configure wave -timeline 0
configure wave -timelineunits ps
update
WaveRestoreZoom {0 ps} {16252698624 ps}

View file

@ -6,7 +6,7 @@
-- Author : Gianmarco Girau
-- Company : Global Inkjet Systems
-- Created : 2017-09-06
-- Last update: 2020-01-16
-- Last update: 2020-01-17
-- SVN ID : Git
-- Standard : VHDL'08
-------------------------------------------------------------------------------
@ -26,6 +26,7 @@ entity fire_pulse_ctrl_5 is
port(
reset_n : in std_logic;
clk : in std_logic;
fpm_config : in std_logic_vector(10 downto 0);
fpm_init : out std_logic;
src_sel : out std_logic_vector(3 downto 0);
uart_regen_bypass : out std_logic;
@ -50,7 +51,7 @@ entity fire_pulse_ctrl_5 is
-- Interrupt Senders
ins_fpm_irq_0 : out std_logic;
-- Avalon MM Interface
avs_address : in std_logic_vector(3 downto 0);
avs_address : in std_logic_vector(4 downto 0);
avs_write : in std_logic;
avs_writedata : in std_logic_vector(31 downto 0);
avs_read : in std_logic;
@ -264,6 +265,9 @@ begin
avs_readdata <= CSR_IP_ID;
when CSR_IP_VER_REG =>
avs_readdata <= CSR_IP_VER;
when FPM_CONFIG_REG =>
avs_readdata(fpm_config'range) <= fpm_config;
avs_readdata(31 downto fpm_config'length) <= (others => '0');
when FPM_INIT_REG =>
avs_readdata <= (0 => fpm_init_start, 1 => fpm_init_done_flag, others => '0');
when SRC_SEL_REG =>

View file

@ -6,7 +6,7 @@
-- Author : GMG
-- Company : Global Inkjet Systems
-- Created : 2018-05-24
-- Last update: 2020-01-16
-- Last update: 2020-01-17
-- SVN ID : Git
-- Standard : VHDL'2008
-------------------------------------------------------------------------------
@ -21,21 +21,22 @@ use ieee.numeric_std.all;
package fire_pulse_ctrl_5_pkg is
constant CSR_IP_ID_REG : std_logic_vector(3 downto 0) := X"0";
constant CSR_IP_VER_REG : std_logic_vector(3 downto 0) := X"1";
constant FPM_INIT_REG : std_logic_vector(3 downto 0) := X"2";
constant SRC_SEL_REG : std_logic_vector(3 downto 0) := X"3";
constant POF_RX_CTRL : std_logic_vector(3 downto 0) := X"4";
constant MON_PT_CTRL_REG : std_logic_vector(3 downto 0) := X"5";
constant COARSE_TIME_INIT_REG : std_logic_vector(3 downto 0) := X"6";
constant FINE_TIME_INIT_REG : std_logic_vector(3 downto 0) := X"7";
constant FINE_TIME_REG : std_logic_vector(3 downto 0) := X"8";
constant COARSE_TIME_REG : std_logic_vector(3 downto 0) := X"9";
constant RX_ERROR_STATUS : std_logic_vector(3 downto 0) := X"A";
constant RX_ERROR_CSR : std_logic_vector(3 downto 0) := X"B";
constant IRQ_MNG_REG : std_logic_vector(3 downto 0) := X"C";
constant EXT_FP_CTRL_REG : std_logic_vector(3 downto 0) := X"D";
constant DW_CFG_REG : std_logic_vector(3 downto 0) := X"E";
constant LED_STATUS_REG : std_logic_vector(3 downto 0) := X"F";
constant CSR_IP_ID_REG : std_logic_vector(4 downto 0) := 5x"00";
constant CSR_IP_VER_REG : std_logic_vector(4 downto 0) := 5x"01";
constant FPM_CONFIG_REG : std_logic_vector(4 downto 0) := 5x"02";
constant FPM_INIT_REG : std_logic_vector(4 downto 0) := 5x"03";
constant SRC_SEL_REG : std_logic_vector(4 downto 0) := 5x"04";
constant POF_RX_CTRL : std_logic_vector(4 downto 0) := 5x"05";
constant MON_PT_CTRL_REG : std_logic_vector(4 downto 0) := 5x"06";
constant COARSE_TIME_INIT_REG : std_logic_vector(4 downto 0) := 5x"07";
constant FINE_TIME_INIT_REG : std_logic_vector(4 downto 0) := 5x"08";
constant FINE_TIME_REG : std_logic_vector(4 downto 0) := 5x"09";
constant COARSE_TIME_REG : std_logic_vector(4 downto 0) := 5x"0A";
constant RX_ERROR_STATUS : std_logic_vector(4 downto 0) := 5x"0B";
constant RX_ERROR_CSR : std_logic_vector(4 downto 0) := 5x"0C";
constant IRQ_MNG_REG : std_logic_vector(4 downto 0) := 5x"0D";
constant EXT_FP_CTRL_REG : std_logic_vector(4 downto 0) := 5x"0E";
constant DW_CFG_REG : std_logic_vector(4 downto 0) := 5x"0F";
constant LED_STATUS_REG : std_logic_vector(4 downto 0) := 5x"10";
end package fire_pulse_ctrl_5_pkg;

View file

@ -6,7 +6,7 @@
-- Author : Gianmarco Girau
-- Company : Global Inkjet Systems
-- Created : 2017-09-06
-- Last update: 2020-01-16
-- Last update: 2020-01-17
-- SVN ID : Git
-- Standard : VHDL'08
-------------------------------------------------------------------------------
@ -26,7 +26,7 @@ use work.fire_pulse_5_pkg.all;
entity fire_pulse_manager_5 is
generic (
SEB_EPD_MODE : boolean := false; -- Support SEB-EPD
CH_NUM : integer := 4; -- number of Pulse-Generator blocks
CH_NUM : integer range 1 to 15 := 4; -- number of Pulse-Generator blocks
PD_QUEUE_SIZE : natural := 512;
ADD_SMB_DIAG : boolean := false; -- Instantiate SMB Diagnostic block
ADD_EVENT_LOGGER : boolean := false; -- Instantiate Event-Logger block
@ -36,7 +36,6 @@ entity fire_pulse_manager_5 is
PULSE_DELAY_EQUAL_EN : boolean := false;
TOF_COMP_EN : boolean := false;
PIXEL_PITCH_CORR_EN : boolean := false;
DW_GEN_EN : boolean := false;
OUT_PULSE_CONDITION : boolean := true);
port(
reset_n : in std_logic;
@ -214,6 +213,8 @@ architecture rtl of fire_pulse_manager_5 is
signal led_pof_y : std_logic;
signal led_pof_r : std_logic;
signal led_status : std_logic_vector(11 downto 0);
--
signal fpm_generic_status : std_logic_vector(10 downto 0);
begin
@ -299,6 +300,7 @@ begin
port map(
reset_n => reset_n_i,
clk => clk,
fpm_config => fpm_generic_status,
fpm_init => fpm_init,
src_sel => src_sel,
uart_regen_bypass => uart_regen_bypass,
@ -321,13 +323,24 @@ begin
dw_pulse_width => dw_pulse_width,
led_status => led_status,
ins_fpm_irq_0 => ins_fpm_irq_0,
avs_address => cs_addr(3 downto 0),
avs_address => cs_addr(4 downto 0),
avs_write => cs_ctrl_write_en,
avs_writedata => cs_write_data,
avs_read => cs_ctrl_read_en,
avs_readdatavalid => cs_ctrl_read_valid,
avs_readdata => cs_ctrl_read_data);
fpm_generic_status( 3 downto 0) <= std_logic_vector(to_unsigned(CH_NUM, 4));
fpm_generic_status(4) <= '1' when SEB_EPD_MODE = true else '0';
fpm_generic_status(5) <= '1' when ADD_SMB_DIAG = true else '0';
fpm_generic_status(6) <= '1' when ADD_EVENT_LOGGER = true else '0';
fpm_generic_status(7) <= '1' when POF_PROT_VER = 1 else '0';
fpm_generic_status(8) <= '1' when PULSE_DELAY_EQUAL_EN = true else '0';
fpm_generic_status(9) <= '1' when TOF_COMP_EN = true else '0';
fpm_generic_status(10) <= '1' when PIXEL_PITCH_CORR_EN = true else '0';
-----------------------------------------------------------------------------
-- I/Os selection
@ -684,30 +697,11 @@ begin
reset_n => reset_n,
clk => clk,
init => init,
ld_pd_max_t => '0',
ld_pd_end_g_t => '0',
ld_enc_max_t => '0',
ld_enc_end_g_t => '0',
ld_pof_g_t => '0',
timing_value => (others => '0'),
host_pwr_is_up => '1',
p_good => '1',
p_in_good => '1',
p_host_good => '1',
pg_iso_5v => '1',
pg_iso_12v => '1',
rs422_pd => ems_filt_pd,
rs422_p1 => ems_filt_p1,
rs422_p2 => ems_filt_p2,
ttl_pd => '0',
ttl_pd_npn => '0',
ttl_p1 => '0',
ttl_p2 => '0',
pof_out => pof_rx,
smb_ok => '1',
led_pwr_g => open,
led_pwr_y => open,
led_pwr_r => open,
pd => ems_filt_pd,
enc_p1 => ems_filt_p1,
enc_p2 => ems_filt_p2,
pof => pof_rx,
all_ok => '1',
led_pd_g => led_pd_g,
led_pd_y => led_pd_y,
led_pd_r => led_pd_r,

View file

@ -6,7 +6,7 @@
-- Author : Gianmarco Girau
-- Company : Global Inkjet Systems
-- Created : 2018-08-06
-- Last update: 2020-01-16
-- Last update: 2020-01-20
-- SVN ID : Git
-- Standard : VHDL'08
-------------------------------------------------------------------------------
@ -21,37 +21,21 @@ use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity seb_epd_led_gen_5 is
generic(
MAX_PERIOD_MS : natural := 1000;
GREEN_PERIOD_MS : natural := 200);
port(
reset_n : in std_logic;
clk : in std_logic;
-- config
init : in std_logic;
ld_pd_max_t : in std_logic;
ld_pd_end_g_t : in std_logic;
ld_enc_max_t : in std_logic;
ld_enc_end_g_t : in std_logic;
ld_pof_g_t : in std_logic;
timing_value : in std_logic_vector(31 downto 0);
-- input status signals
host_pwr_is_up : in std_logic;
p_good : in std_logic;
p_in_good : in std_logic;
p_host_good : in std_logic;
pg_iso_5v : in std_logic;
pg_iso_12v : in std_logic;
rs422_pd : in std_logic;
rs422_p1 : in std_logic;
rs422_p2 : in std_logic;
ttl_pd : in std_logic;
ttl_pd_npn : in std_logic;
ttl_p1 : in std_logic;
ttl_p2 : in std_logic;
pof_out : in std_logic;
smb_ok : in std_logic;
pd : in std_logic;
enc_p1 : in std_logic;
enc_p2 : in std_logic;
pof : in std_logic;
all_ok : in std_logic;
-- LEDs outputs values
led_pwr_g : out std_logic;
led_pwr_y : out std_logic;
led_pwr_r : out std_logic;
led_pd_g : out std_logic;
led_pd_y : out std_logic;
led_pd_r : out std_logic;
@ -68,114 +52,75 @@ end entity seb_epd_led_gen_5;
architecture rtl of seb_epd_led_gen_5 is
signal power_good, rs422_pd_i, ttl_pd_i, ttl_npn_pd_i : std_logic;
signal rs422_pd_d, ttl_pd_d, ttl_npn_pd_d : std_logic;
constant END_GREEN_PERIOD_MS : natural := MAX_PERIOD_MS - GREEN_PERIOD_MS;
signal pd_d, enc_p1_d, enc_p2_d, one_ms_pulse : std_logic;
signal p1_prev_event, p2_prev_event : std_logic;
signal pd_cnt_zero_flag, rst_pd_green, pd_red, pd_green : std_logic;
signal rs422_p1_i, rs422_p2_i, ttl_p1_i, ttl_p2_i : std_logic;
signal rs422_p1_d, rs422_p2_d, ttl_p1_d, ttl_p2_d : std_logic;
signal rs422_p1_event, rs422_p2_event, p1_cnt_zero_flag : std_logic;
signal ttl_p1_event, ttl_p2_event, p2_cnt_zero_flag : std_logic;
signal p1_event, p2_event, p1_cnt_zero_flag : std_logic;
signal p2_cnt_zero_flag, pd_event, rst_pof_green : std_logic;
signal rst_p1_green, rst_p2_green, p1_red, p2_red : std_logic;
signal p1_green, p2_green, pof_green, pof_out_d : std_logic;
signal pof_event, pof_cnt_zero_flag, pd_multiple_event : std_logic;
signal smb_ok_d, alert_cnt_zero_flag : std_logic;
signal p1_green, p2_green, pof_green, pof_d : std_logic;
signal pof_event, pof_cnt_zero_flag, pof_active : std_logic;
signal all_ok_d, alert_cnt_zero_flag : std_logic;
signal pd_active, p1_active, p2_active : std_logic;
--
signal p1_event, p2_event : std_logic_vector( 1 downto 0);
signal p1_prev_event, p2_prev_event : std_logic_vector( 1 downto 0);
signal pd_event, pd_previous_event : std_logic_vector( 2 downto 0);
signal alert_led : std_logic_vector( 3 downto 0);
signal pd_max_period, pd_end_green_t, pd_cnt : std_logic_vector(29 downto 0);
signal enc_max_period, enc_end_green_t : std_logic_vector(29 downto 0);
signal pof_green_t : std_logic_vector(29 downto 0);
signal p1_cnt, p2_cnt, pof_cnt, alert_cnt : std_logic_vector(29 downto 0);
signal pd_cnt, pof_cnt : std_logic_vector( 9 downto 0);
signal p1_cnt, p2_cnt, alert_cnt : std_logic_vector( 9 downto 0);
signal one_ms_cnt : std_logic_vector(16 downto 0);
begin
-----------------------------------------------------------------------------
-- Power LED
-----------------------------------------------------------------------------
power_good <= '0' when p_good = '0' or p_in_good = '0' or p_host_good = '0' or pg_iso_12v = '0' or pg_iso_5v = '0' else '1';
led_pwr_r <= '1' when power_good = '0' and host_pwr_is_up = '1' else '0';
led_pwr_y <= '1' when host_pwr_is_up = '0' else '0';
led_pwr_g <= '1' when power_good = '1' and host_pwr_is_up = '1' else '0';
pGEN_1MS_PULSE : process(reset_n, clk)
begin
if(reset_n = '0') then
one_ms_pulse <= '0';
one_ms_cnt <= (others => '0');
elsif(clk = '1' and clk'event) then
if(unsigned(one_ms_cnt) = 100000-1) then
one_ms_pulse <= '1';
one_ms_cnt <= (others => '0');
else
one_ms_pulse <= '0';
one_ms_cnt <= std_logic_vector(unsigned(one_ms_cnt)+1);
end if;
end if;
end process pGEN_1MS_PULSE;
-----------------------------------------------------------------------------
-- PD LEDs
-----------------------------------------------------------------------------
-- synchronize to the local clock and generate a pulse on the rising edge
iRS422_PD_SYNC: entity work.sync_wire
generic map (rst_val => '0', sync_stages => 3)
port map (rstN => reset_n, clk => clk, async_in => rs422_pd, sync_out => rs422_pd_i);
iTTL_PNP_PD_SYNC: entity work.sync_wire
generic map (rst_val => '0', sync_stages => 3)
port map (rstN => reset_n, clk => clk, async_in => ttl_pd, sync_out => ttl_pd_i);
iTTL_NPN_PD_SYNC: entity work.sync_wire
generic map (rst_val => '0', sync_stages => 3)
port map (rstN => reset_n, clk => clk, async_in => ttl_pd_npn, sync_out => ttl_npn_pd_i);
pd_event <= (ttl_npn_pd_i xor ttl_npn_pd_d) & (ttl_pd_i xor ttl_pd_d) & (rs422_pd_i xor rs422_pd_d);
pPD_LEDs : process(reset_n, clk) is
begin -- process
if(reset_n = '0') then
rs422_pd_d <= '0';
ttl_pd_d <= '0';
ttl_npn_pd_d <= '0';
pd_previous_event <= "000";
pd_max_period <= std_logic_vector(to_unsigned(100000000-1, 30));
pd_end_green_t <= std_logic_vector(to_unsigned( 50000000-1, 30));
pd_d <= '0';
pd_event <= '0';
pd_cnt <= (others => '0');
pd_previous_event <= "000";
pd_red <= '0';
pd_green <= '0';
led_pd_r <= '0';
led_pd_y <= '0';
led_pd_g <= '0';
pd_active <= '0';
elsif(clk = '1' and clk'event) then
rs422_pd_d <= rs422_pd_i;
ttl_pd_d <= ttl_pd_i;
ttl_npn_pd_d <= ttl_npn_pd_i;
if(ld_pd_max_t = '1') then
pd_max_period <= timing_value(pd_max_period'range);
end if;
if(ld_pd_end_g_t = '1') then
pd_end_green_t <= timing_value(pd_end_green_t'range);
end if;
if(init = '1' or (pd_cnt_zero_flag = '1' and pd_event = "000")) then
pd_previous_event <= "000";
elsif(pd_event /= "000") then
pd_previous_event <= pd_event;
end if;
pd_d <= pd;
pd_event <= pd xor pd_d;
if(init = '1') then
pd_cnt <= (others => '0');
elsif(pd_event /= "000" and pd_red = '0') then
pd_cnt <= pd_max_period;
elsif(pd_cnt_zero_flag = '0') then
elsif(pd_event = '1') then
pd_cnt <= std_logic_vector(to_unsigned(MAX_PERIOD_MS, pd_cnt'length));
elsif(pd_cnt_zero_flag = '0' and one_ms_pulse = '1') then
pd_cnt <= std_logic_vector(unsigned(pd_cnt)-1);
end if;
if(init = '1' or (pd_cnt_zero_flag = '1' and pd_event = "000")) then
pd_red <= '0';
elsif((pd_event /= "000" and pd_previous_event /= "000" and pd_event /= pd_previous_event) or pd_multiple_event = '1') then
pd_red <= '1';
end if;
if(pd_red = '1' or rst_pd_green = '1' or init = '1') then
pd_green <= '0';
elsif(pd_event = "001" or pd_event = "010" or pd_event = "100") then
if(pd_event = '1') then
pd_green <= '1';
elsif(rst_pd_green = '1' or init = '1') then
pd_green <= '0';
end if;
led_pd_r <= smb_ok and power_good and pd_red;
led_pd_y <= (smb_ok and power_good and pd_cnt_zero_flag and pd_active) or alert_led(0);
led_pd_g <= smb_ok and power_good and pd_green;
if(pd_event(0) = '1' or pd_event(1) = '1' or pd_event(2) = '1') then
led_pd_r <= all_ok and pd_red;
led_pd_y <= (all_ok and pd_cnt_zero_flag and pd_active) or alert_led(0);
led_pd_g <= all_ok and pd_green;
if(pd_event = '1') then
pd_active <= '1';
end if;
end if;
@ -183,101 +128,77 @@ begin
pd_cnt_zero_flag <= '1' when unsigned(pd_cnt) = 0 else '0';
rst_pd_green <= '1' when unsigned(pd_cnt) = unsigned(pd_end_green_t) else '0';
rst_pd_green <= '1' when one_ms_pulse = '1' and unsigned(pd_cnt) = END_GREEN_PERIOD_MS else '0';
pd_multiple_event <= '1' when pd_event = "011" or pd_event = "101" or pd_event = "110" or pd_event = "111" else '0';
-- PD red LED is never activated because there is only one PD source
pd_red <= '0';
-----------------------------------------------------------------------------
-- Encoder LEDs
-----------------------------------------------------------------------------
-- synchronize the signals to the local clock domain
iRS422_P1_SYNC: entity work.sync_wire
generic map (rst_val => '0', sync_stages => 3)
port map (rstN => reset_n, clk => clk, async_in => rs422_p1, sync_out => rs422_p1_i);
iRS422_P2_SYNC: entity work.sync_wire
generic map (rst_val => '0', sync_stages => 3)
port map (rstN => reset_n, clk => clk, async_in => rs422_p2, sync_out => rs422_p2_i);
iTTL_P1_SYNC: entity work.sync_wire
generic map (rst_val => '0', sync_stages => 3)
port map (rstN => reset_n, clk => clk, async_in => ttl_p1, sync_out => ttl_p1_i);
iTTL_P2_SYNC: entity work.sync_wire
generic map (rst_val => '0', sync_stages => 3)
port map (rstN => reset_n, clk => clk, async_in => ttl_p2, sync_out => ttl_p2_i);
pENC_LEDs : process(reset_n, clk)
begin
if(reset_n = '0') then
enc_max_period <= std_logic_vector(to_unsigned(100000000-1, 30));
enc_end_green_t <= std_logic_vector(to_unsigned( 50000000-1, 30));
p1_cnt <= (others => '0');
p2_cnt <= (others => '0');
p1_red <= '0';
p1_green <= '0';
p2_red <= '0';
p2_green <= '0';
p1_prev_event <= "00";
p2_prev_event <= "00";
p1_cnt <= (others => '0');
p2_cnt <= (others => '0');
p1_red <= '0';
p1_green <= '0';
p2_red <= '0';
p2_green <= '0';
p1_prev_event <= '0';
p2_prev_event <= '0';
p1_active <= '0';
p2_active <= '0';
elsif(clk = '1' and clk'event) then
if(ld_enc_max_t = '1') then
enc_max_period <= timing_value(enc_max_period'range);
end if;
if(ld_enc_end_g_t = '1') then
enc_end_green_t <= timing_value(enc_end_green_t'range);
end if;
if(init = '1' or (p1_cnt_zero_flag = '1' and p1_event = "00")) then
p1_prev_event <= "00";
elsif(p1_event(0) = '1' or p1_event(1) = '1') then
if(init = '1' or (p1_cnt_zero_flag = '1' and p1_event = '0')) then
p1_prev_event <= '0';
elsif(p1_event = '1') then
p1_prev_event <= p1_event;
end if;
if(init = '1' or (p2_cnt_zero_flag = '1' and p2_event = "00")) then
p2_prev_event <= "00";
elsif(p2_event(0) = '1' or p2_event(1) = '1') then
if(init = '1' or (p2_cnt_zero_flag = '1' and p2_event = '0')) then
p2_prev_event <= '0';
elsif(p2_event = '1') then
p2_prev_event <= p2_event;
end if;
if(init = '1') then
p1_cnt <= (others => '0');
elsif((p1_event(0) = '1' or p1_event(1) = '1') and p1_red = '0') then
p1_cnt <= enc_max_period;
elsif(p1_cnt_zero_flag = '0') then
elsif(p1_event = '1' and p1_red = '0') then
p1_cnt <= std_logic_vector(to_unsigned(MAX_PERIOD_MS-1, p1_cnt'length));
elsif(p1_cnt_zero_flag = '0' and one_ms_pulse = '1') then
p1_cnt <= std_logic_vector(unsigned(p1_cnt)-1);
end if;
if(init = '1') then
p2_cnt <= (others => '0');
elsif((p2_event(0) = '1' or p2_event(1) = '1') and p2_red = '0') then
p2_cnt <= enc_max_period;
elsif(p2_cnt_zero_flag = '0') then
elsif(p2_event = '1' and p2_red = '0') then
p2_cnt <= std_logic_vector(to_unsigned(MAX_PERIOD_MS-1, p2_cnt'length));
elsif(p2_cnt_zero_flag = '0' and one_ms_pulse = '1') then
p2_cnt <= std_logic_vector(unsigned(p2_cnt)-1);
end if;
if(init = '1' or (p1_cnt_zero_flag = '1' and p1_event = "00")) then
if(init = '1' or (p1_cnt_zero_flag = '1' and p1_event = '0')) then
p1_red <= '0';
elsif((p1_event(0) = '1' and ((p2_event(0) ='1' or p2_event(1) = '1') or p1_event(1) = '1' or p1_prev_event(1) = '1' or p2_prev_event(1) = '1')) or (p1_event(1) = '1' and (p1_event(0) = '1' or p1_prev_event(0) = '1' or p2_prev_event(0) = '1'))) then
elsif(p1_event = '1' and p2_event ='1') then
p1_red <= '1';
end if;
if(init = '1' or (p2_cnt_zero_flag = '1' and p2_event = "00")) then
if(init = '1' or (p2_cnt_zero_flag = '1' and p2_event = '0')) then
p2_red <= '0';
elsif((p2_event(0) = '1' and ((p1_event(0) ='1' or p1_event(1) = '1') or p2_event(1) = '1' or p2_prev_event(1) = '1' or p1_prev_event(1) = '1')) or (p2_event(1) = '1' and (p2_event(0) = '1' or p2_prev_event(0) = '1' or p1_prev_event(0) = '1'))) then
elsif(p2_event = '1' and p1_event ='1') then
p2_red <= '1';
end if;
if(p1_red = '1' or rst_p1_green = '1' or init = '1') then
p1_green <= '0';
elsif(p1_event = "01" or p1_event = "10") then
elsif(p1_event = '1') then
p1_green <= '1';
end if;
if(p2_red = '1' or rst_p2_green = '1' or init = '1') then
p2_green <= '0';
elsif(p2_event = "01" or p2_event = "10") then
elsif(p2_event = '1') then
p2_green <= '1';
end if;
if(p1_event(0) = '1' or p1_event(1) = '1') then
if(p1_event = '1') then
p1_active <= '1';
end if;
if(p2_event(0) = '1' or p2_event(1) = '1') then
if(p2_event = '1') then
p2_active <= '1';
end if;
end if;
@ -286,31 +207,24 @@ begin
pENC_LEDs_NR : process(clk)
begin
if(clk = '1' and clk'event) then
rs422_p1_d <= rs422_p1_i;
rs422_p2_d <= rs422_p2_i;
ttl_p1_d <= ttl_p1_i;
ttl_p2_d <= ttl_p2_i;
p1_event <= ttl_p1_event & rs422_p1_event;
p2_event <= ttl_p2_event & rs422_p2_event;
led_enc_p1_r <= smb_ok and power_good and p1_red;
led_enc_p1_y <= (smb_ok and power_good and p1_cnt_zero_flag and not p1_red and p1_active) or alert_led(1);
led_enc_p1_g <= smb_ok and power_good and p1_green and not p1_red;
led_enc_p2_r <= smb_ok and power_good and p2_red;
led_enc_p2_y <= (smb_ok and power_good and p2_cnt_zero_flag and not p2_red and p2_active) or alert_led(2);
led_enc_p2_g <= smb_ok and power_good and p2_green and not p2_red;
enc_p1_d <= enc_p1;
enc_p2_d <= enc_p2;
p1_event <= enc_p1 xor enc_p1_d;
p2_event <= enc_p2 xor enc_p2_d;
led_enc_p1_r <= all_ok and p1_red;
led_enc_p1_y <= (all_ok and p1_cnt_zero_flag and not p1_red and p1_active) or alert_led(1);
led_enc_p1_g <= all_ok and p1_green and not p1_red;
led_enc_p2_r <= all_ok and p2_red;
led_enc_p2_y <= (all_ok and p2_cnt_zero_flag and not p2_red and p2_active) or alert_led(2);
led_enc_p2_g <= all_ok and p2_green and not p2_red;
end if;
end process pENC_LEDs_NR;
rs422_p1_event <= rs422_p1_i xor rs422_p1_d;
rs422_p2_event <= rs422_p2_i xor rs422_p2_d;
ttl_p1_event <= ttl_p1_i xor ttl_p1_d;
ttl_p2_event <= ttl_p2_i xor ttl_p2_d;
p1_cnt_zero_flag <= '1' when unsigned(p1_cnt) = 0 else '0';
p2_cnt_zero_flag <= '1' when unsigned(p2_cnt) = 0 else '0';
rst_p1_green <= '1' when unsigned(p1_cnt) = unsigned(enc_end_green_t) else '0';
rst_p2_green <= '1' when unsigned(p2_cnt) = unsigned(enc_end_green_t) else '0';
rst_p1_green <= '1' when unsigned(p1_cnt) = END_GREEN_PERIOD_MS-1 and one_ms_pulse = '1' else '0';
rst_p2_green <= '1' when unsigned(p2_cnt) = END_GREEN_PERIOD_MS-1 and one_ms_pulse = '1' else '0';
-----------------------------------------------------------------------------
-- POF LEDs
@ -319,38 +233,40 @@ begin
pPOF_LED : process(reset_n, clk)
begin
if(reset_n = '0') then
pof_green_t <= std_logic_vector(to_unsigned( 50000000-1, 30));
pof_cnt <= (others => '0');
pof_out_d <= '0';
pof_d <= '0';
pof_green <= '0';
led_pof_g <= '0';
led_pof_y <= '0';
pof_event <= '0';
pof_active <= '0';
elsif(clk = '1' and clk'event) then
if(ld_pof_g_t = '1') then
pof_green_t <= timing_value(pof_green_t'range);
end if;
pof_out_d <= pof_out;
pof_d <= pof;
pof_event <= pof and not pof_d;
if(init = '1') then
pof_cnt <= (others => '0');
elsif(pof_event = '1') then
pof_cnt <= pof_green_t;
elsif(pof_cnt_zero_flag = '0') then
pof_cnt <= std_logic_vector(to_unsigned(MAX_PERIOD_MS, pof_cnt'length));
elsif(pof_cnt_zero_flag = '0' and one_ms_pulse = '1') then
pof_cnt <= std_logic_vector(unsigned(pof_cnt)-1);
end if;
if(init = '1' or (pof_cnt_zero_flag = '1' and pof_event = '0')) then
if(init = '1' or (rst_pof_green = '1' and pof_event = '0')) then
pof_green <= '0';
elsif(pof_event = '1') then
pof_green <= '1';
end if;
led_pof_g <= smb_ok and power_good and pof_green;
led_pof_g <= all_ok and pof_green;
led_pof_y <= (all_ok and pof_cnt_zero_flag and pof_active) or alert_led(3);
if(pof_event = '1') then
pof_active <= '1';
end if;
end if;
end process pPOF_LED;
-- create event only on the rising edge
pof_event <= pof_out and not pof_out_d;
pof_cnt_zero_flag <= '1' when unsigned(pof_cnt) = 0 else '0';
led_pof_y <= alert_led(3);
rst_pof_green <= '1' when one_ms_pulse = '1' and unsigned(pof_cnt) = END_GREEN_PERIOD_MS else '0';
led_pof_r <= '0';
@ -358,17 +274,21 @@ begin
-- Emergency Flashing
-----------------------------------------------------------------------------
-- when the smb_ctrl watchdog is triggered (smb_ok deasserted), all the LEDs,
-- apart from the power LED, needs to start flashing
-- when the smb_ctrl watchdog is triggered (all_ok deasserted), all the LEDs
-- need to start flashing
pEMERGENCY_FLASH : process(clk)
pEMERGENCY_FLASH : process(reset_n, clk)
begin
if(clk = '1' and clk'event) then
smb_ok_d <= smb_ok;
if(smb_ok = '1') then
if(reset_n = '0') then
all_ok_d <= '0';
alert_led <= "0000";
alert_cnt <= std_logic_vector(to_unsigned(END_GREEN_PERIOD_MS-1, alert_cnt'length));
elsif(clk = '1' and clk'event) then
all_ok_d <= all_ok;
if(all_ok = '1') then
alert_led <= "0000";
elsif(smb_ok = '0' and smb_ok_d = '1') then
alert_cnt <= std_logic_vector(to_unsigned( 50000000-1, 30));
elsif(all_ok = '0' and all_ok_d = '1') then
alert_cnt <= std_logic_vector(to_unsigned(END_GREEN_PERIOD_MS-1, alert_cnt'length));
else
if(alert_cnt_zero_flag = '1') then
if(alert_led = "1111") then
@ -376,8 +296,8 @@ begin
else
alert_led <= alert_led(2 downto 0) & '1';
end if;
alert_cnt <= std_logic_vector(to_unsigned( 50000000-1, 30));
else
alert_cnt <= std_logic_vector(to_unsigned(END_GREEN_PERIOD_MS-1, alert_cnt'length));
elsif(one_ms_pulse = '1') then
alert_cnt <= std_logic_vector(unsigned(alert_cnt)-1);
end if;
end if;

View file

@ -0,0 +1,633 @@
-------------------------------------------------------------------------------
-- Title : led_tb
-- Project : FPM
-------------------------------------------------------------------------------
-- File : led_tb.vhd
-- Author : GMG
-- Company : Global Inkjet Systems
-- Created : 2018-06-12
-- Last update: 2020-01-20
-- SVN ID : Git
-- Standard : VHDL'2008
-------------------------------------------------------------------------------
-- Description:
-- Testbench for the FPM LED generator
-------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
library work;
use work.log_pkg.all;
entity led_tb is
-- ..
end entity led_tb;
architecture behav of led_tb is
constant CLK_PERIOD : time := 10 ns;
constant CLK_FREQ : real := 100.0e6; -- target clock frequency
-- Logging Verbosity Level
constant VERBOSITY_LEVEL : verb_level_t := VMEDIUM;
constant MAX_SIM_TIME : time := 50.0 ms; -- Maximum simulation time
constant MAX_PERIOD_MS : natural := 5;
constant GREEN_PERIOD_MS : natural := 2;
constant RUN_ENC_TEST : boolean := true;
constant RUN_PD_TEST : boolean := true;
constant RUN_POF_TEST : boolean := true;
signal reset_n : std_logic := '0';
signal clk : std_logic := '0';
--
signal init : std_logic;
signal pd : std_logic;
signal enc_p1 : std_logic;
signal enc_p2 : std_logic;
signal pof : std_logic;
signal all_ok : std_logic;
signal led_pd_g : std_logic;
signal led_pd_y : std_logic;
signal led_pd_r : std_logic;
signal led_enc_p1_g : std_logic;
signal led_enc_p1_y : std_logic;
signal led_enc_p1_r : std_logic;
signal led_enc_p2_g : std_logic;
signal led_enc_p2_y : std_logic;
signal led_enc_p2_r : std_logic;
signal led_pof_g : std_logic;
signal led_pof_y : std_logic;
signal led_pof_r : std_logic;
-- TB specific signals
signal setup : boolean;
signal running : boolean;
signal passed : boolean := false;
signal failed : boolean := false;
signal test_timeout : boolean := false;
signal test_completed : boolean := false;
signal error_flag : boolean;
begin -- architecture behav
clk <= not clk after 0.5*CLK_PERIOD;
-----------------------------------------------------------------------------
-- LED Generator (UUT)
-----------------------------------------------------------------------------
iUUT: entity work.seb_epd_led_gen_5
generic map (
MAX_PERIOD_MS => MAX_PERIOD_MS,
GREEN_PERIOD_MS => GREEN_PERIOD_MS)
port map (
reset_n => reset_n,
clk => clk,
init => init,
pd => pd,
enc_p1 => enc_p1,
enc_p2 => enc_p2,
pof => pof,
all_ok => all_ok,
led_pd_g => led_pd_g,
led_pd_y => led_pd_y,
led_pd_r => led_pd_r,
led_enc_p1_g => led_enc_p1_g,
led_enc_p1_y => led_enc_p1_y,
led_enc_p1_r => led_enc_p1_r,
led_enc_p2_g => led_enc_p2_g,
led_enc_p2_y => led_enc_p2_y,
led_enc_p2_r => led_enc_p2_r,
led_pof_g => led_pof_g,
led_pof_y => led_pof_y,
led_pof_r => led_pof_r);
-----------------------------------------------------------------------------
-- Testbench Logic
-----------------------------------------------------------------------------
pTEST_PROC : process
begin
---------------------------------------------------------------------------
-- Initialize & Configure
---------------------------------------------------------------------------
reset_n <= '0';
init <= '0';
setup <= false;
running <= false;
error_flag <= false;
--Set the verbosity level for logging
set_log_verbosity(VERBOSITY_LEVEL);
pd <= '0';
enc_p1 <= '0';
enc_p2 <= '0';
pof <= '0';
all_ok <= '0';
wait for 100 ns;
reset_n <= '1';
wait for 100 ns;
wait until clk = '1' and clk'event;
all_ok <= '1';
-- Nothing really to do here
setup <= true;
---------------------------------------------------------------------------
-- Running
---------------------------------------------------------------------------
running <= true;
log_separator_line(VLOW);
log("FPM (SEB-EPD) LEDs verification:", VLOW);
log_separator_line(VLOW);
wait for 0.5 ms;
---------------------------------------------------------------------------
-- POF LED
---------------------------------------------------------------------------
if(RUN_POF_TEST = true) then
log_separator_line(VLOW);
log("Testing POF LED:", VLOW);
wait for 5 us;
if(led_pof_r /= '0') then
log("ERROR: POF Red LED must be LOW.", VLOW);
error_flag <= true;
end if;
if(led_pof_y /= '0') then
log("ERROR: POF Yellow LED must be LOW.", VLOW);
error_flag <= true;
end if;
if(led_pof_g /= '0') then
log("ERROR: POF Green LED must be LOW.", VLOW);
error_flag <= true;
end if;
wait for 5 us;
wait until clk = '1' and clk'event;
pof <= not pof;
wait until clk = '1' and clk'event;
pof <= not pof;
wait for 100 ns;
if(led_pof_g /= '1') then
log("ERROR: POF Green LED must be HIGH.", VLOW);
error_flag <= true;
end if;
if(led_pof_y /= '0') then
log("ERROR: POF Yellow LED must be LOW.", VLOW);
error_flag <= true;
end if;
wait for 3 ms;
if(led_pof_g /= '0') then
log("ERROR: POF Green LED must be LOW.", VLOW);
error_flag <= true;
end if;
if(led_pof_y /= '0') then
log("ERROR: POF Yellow LED must be LOW.", VLOW);
error_flag <= true;
end if;
wait for 3 ms;
if(led_pof_g /= '0') then
log("ERROR: POF Green LED must be LOW.", VLOW);
error_flag <= true;
end if;
if(led_pof_y /= '1') then
log("ERROR: POF Yellow LED must be HIGH.", VLOW);
error_flag <= true;
end if;
wait for 5 us;
wait until clk = '1' and clk'event;
pof <= not pof;
wait until clk = '1' and clk'event;
pof <= not pof;
wait for 100 ns;
if(led_pof_g /= '1') then
log("ERROR: POF Green LED must be HIGH.", VLOW);
error_flag <= true;
end if;
if(led_pof_y /= '0') then
log("ERROR: POF Yellow LED must be LOW.", VLOW);
error_flag <= true;
end if;
for n in 0 to 8 loop
wait for 10 us;
wait until clk = '1' and clk'event;
pof <= not pof;
wait until clk = '1' and clk'event;
pof <= not pof;
end loop; -- n
wait for 100 ns;
if(led_pof_g /= '1') then
log("ERROR: POF Green LED must be HIGH.", VLOW);
error_flag <= true;
end if;
if(led_pof_y /= '0') then
log("ERROR: POF Yellow LED must be LOW.", VLOW);
error_flag <= true;
end if;
wait for 3 ms;
if(led_pof_g /= '0') then
log("ERROR: POF Green LED must be LOW.", VLOW);
error_flag <= true;
end if;
if(led_pof_y /= '0') then
log("ERROR: POF Yellow LED must be LOW.", VLOW);
error_flag <= true;
end if;
wait for 3 ms;
if(led_pof_g /= '0') then
log("ERROR: POF Green LED must be LOW.", VLOW);
error_flag <= true;
end if;
if(led_pof_y /= '1') then
log("ERROR: POF Yellow LED must be HIGH.", VLOW);
error_flag <= true;
end if;
wait for 50 ns;
if(error_flag = false) then
log("POF LEDs are OK.", VLOW);
end if;
wait for 0.5 ms;
end if; -- RUN_POF_TEST
---------------------------------------------------------------------------
-- PD LEDs
---------------------------------------------------------------------------
if(RUN_PD_TEST = true) then
log_separator_line(VLOW);
log("Testing PD LEDs:", VLOW);
pd <= '1';
wait for 100 ns;
if(led_pd_g /= '1') then
log("ERROR: PD Green LED must be HIGH.", VLOW);
error_flag <= true;
end if;
if(led_pd_y /= '0') then
log("ERROR: PD Yellow LED must be LOW.", VLOW);
error_flag <= true;
end if;
wait for 1 us;
pd <= '0';
wait for 1 us;
wait for 3 ms;
if(led_pd_g /= '0') then
log("ERROR: PD Green LED must be LOW.", VLOW);
error_flag <= true;
end if;
if(led_pd_y /= '0') then
log("ERROR: PD Yellow LED must be LOW.", VLOW);
error_flag <= true;
end if;
wait for 3 ms;
if(led_pd_g /= '0') then
log("ERROR: PD Green LED must be LOW.", VLOW);
error_flag <= true;
end if;
if(led_pd_y /= '1') then
log("ERROR: PD Yellow LED must be HIGH.", VLOW);
error_flag <= true;
end if;
wait for 1.5 ms;
pd <= '1';
wait for 1 us;
pd <= '0';
wait for 10 us;
pd <= '1';
wait for 1 us;
pd <= '0';
wait for 10 us;
pd <= '1';
wait for 1 us;
pd <= '0';
wait for 10 us;
pd <= '1';
wait for 1 us;
pd <= '0';
if(led_pd_g /= '1') then
log("ERROR: PD Green LED must be HIGH.", VLOW);
error_flag <= true;
end if;
if(led_pd_y /= '0') then
log("ERROR: PD Yellow LED must be LOW.", VLOW);
error_flag <= true;
end if;
wait for 3.0 ms;
if(led_pd_g /= '0') then
log("ERROR: PD Green LED must be LOW.", VLOW);
error_flag <= true;
end if;
if(led_pd_y /= '0') then
log("ERROR: PD Yellow LED must be LOW.", VLOW);
error_flag <= true;
end if;
wait for 3 ms;
if(led_pd_g /= '0') then
log("ERROR: PD Green LED must be LOW.", VLOW);
error_flag <= true;
end if;
if(led_pd_y /= '1') then
log("ERROR: PD Yellow LED must be HIGH.", VLOW);
error_flag <= true;
end if;
wait for 50 ns;
if(error_flag = false) then
log("PD LEDs are OK.", VLOW);
end if;
wait for 0.5 ms;
end if; -- RUN_PD_TEST
---------------------------------------------------------------------------
-- Encoder LEDs
---------------------------------------------------------------------------
if(RUN_ENC_TEST = true) then
log_separator_line(VLOW);
log("Testing Encoder LEDs:", VLOW);
wait for 5 us;
if(led_enc_p1_y /= '0') then
log("ERROR: P1 Yellow LED must be LOW.", VLOW);
error_flag <= true;
end if;
if(led_enc_p2_y /= '0') then
log("ERROR: P2 Yellow LED must be LOW.", VLOW);
error_flag <= true;
end if;
if(led_enc_p1_g /= '0') then
log("ERROR: P1 Green LED must be LOW.", VLOW);
error_flag <= true;
end if;
if(led_enc_p2_g /= '0') then
log("ERROR: P2 Green LED must be LOW.", VLOW);
error_flag <= true;
end if;
if(led_enc_p1_r /= '0') then
log("ERROR: P1 Red LED must be LOW.", VLOW);
error_flag <= true;
end if;
if(led_enc_p2_r /= '0') then
log("ERROR: P2 Red LED must be LOW.", VLOW);
error_flag <= true;
end if;
wait for 1 us;
enc_p1 <= '1';
wait for 10 us;
enc_p2 <= '1';
wait for 100 ns;
if(led_enc_p1_g /= '1') then
log("ERROR: P1 Green LED must be HIGH.", VLOW);
error_flag <= true;
end if;
if(led_enc_p2_g /= '1') then
log("ERROR: P2 Green LED must be HIGH.", VLOW);
error_flag <= true;
end if;
if(led_enc_p1_y /= '0') then
log("ERROR: P1 Yellow LED must be LOW.", VLOW);
error_flag <= true;
end if;
if(led_enc_p2_y /= '0') then
log("ERROR: P2 Yellow LED must be LOW.", VLOW);
error_flag <= true;
end if;
wait for 3 ms;
if(led_enc_p1_g /= '0') then
log("ERROR: P1 Green LED must be LOW.", VLOW);
error_flag <= true;
end if;
if(led_enc_p2_g /= '0') then
log("ERROR: P2 Green LED must be LOW.", VLOW);
error_flag <= true;
end if;
if(led_enc_p1_y /= '0') then
log("ERROR: P1 Yellow LED must be LOW.", VLOW);
error_flag <= true;
end if;
if(led_enc_p2_y /= '0') then
log("ERROR: P2 Yellow LED must be LOW.", VLOW);
error_flag <= true;
end if;
wait for 3 ms;
if(led_enc_p1_g /= '0') then
log("ERROR: P1 Green LED must be LOW.", VLOW);
error_flag <= true;
end if;
if(led_enc_p2_g /= '0') then
log("ERROR: P2 Green LED must be LOW.", VLOW);
error_flag <= true;
end if;
if(led_enc_p1_y /= '1') then
log("ERROR: P1 Yellow LED must be HIGH.", VLOW);
error_flag <= true;
end if;
if(led_enc_p2_y /= '1') then
log("ERROR: P2 Yellow LED must be HIGH.", VLOW);
error_flag <= true;
end if;
wait for 20 us;
enc_p1 <= '0';
wait for 100 ns;
if(led_enc_p1_g /= '1') then
log("ERROR: P1 Green LED must be HIGH.", VLOW);
error_flag <= true;
end if;
wait for 3 ms;
if(led_enc_p1_g /= '0') then
log("ERROR: P1 Green LED must be LOW.", VLOW);
error_flag <= true;
end if;
wait for 5 us;
enc_p1 <= '1';
wait for 100 ns;
if(led_enc_p1_g /= '1') then
log("ERROR: P1 Green LED must be HIGH.", VLOW);
error_flag <= true;
end if;
wait for 10 us;
enc_p1 <= '0';
wait for 10 us;
enc_p1 <= '1';
wait for 10 us;
enc_p1 <= '0';
wait for 10 us;
enc_p1 <= '1';
wait for 10 us;
if(led_enc_p1_g /= '1') then
log("ERROR: P1 Green LED must be HIGH.", VLOW);
error_flag <= true;
end if;
wait for 200 us;
enc_p2 <= '0';
wait for 100 ns;
if(led_enc_p2_g /= '1') then
log("ERROR: P2 Green LED must be HIGH.", VLOW);
error_flag <= true;
end if;
wait for 3 ms;
if(led_enc_p2_g /= '0') then
log("ERROR: P2 Green LED must be LOW.", VLOW);
error_flag <= true;
end if;
if(led_enc_p2_y /= '0') then
log("ERROR: P2 Yellow LED must be LOW.", VLOW);
error_flag <= true;
end if;
wait for 3 ms;
if(led_enc_p2_g /= '0') then
log("ERROR: P2 Green LED must be LOW.", VLOW);
error_flag <= true;
end if;
if(led_enc_p2_y /= '1') then
log("ERROR: P2 Yellow LED must be HIGH.", VLOW);
error_flag <= true;
end if;
wait for 10 us;
enc_p2 <= not enc_p2;
enc_p1 <= not enc_p1;
wait for 100 ns;
if(led_enc_p1_r /= '1') then
log("ERROR: P1 Red LED must be HIGH.", VLOW);
error_flag <= true;
end if;
if(led_enc_p2_r /= '1') then
log("ERROR: P2 Red LED must be HIGH.", VLOW);
error_flag <= true;
end if;
wait for 6 ms;
wait for 100 ns;
if(led_enc_p1_r /= '0') then
log("ERROR: P1 Red LED must be LOW.", VLOW);
error_flag <= true;
end if;
if(led_enc_p2_r /= '0') then
log("ERROR: P2 Red LED must be LOW.", VLOW);
error_flag <= true;
end if;
if(led_enc_p1_y /= '1') then
log("ERROR: P1 Yellow LED must be HIGH.", VLOW);
error_flag <= true;
end if;
if(led_enc_p2_y /= '1') then
log("ERROR: P2 Yellow LED must be HIGH.", VLOW);
error_flag <= true;
end if;
wait for 0.5 ms;
if(error_flag = false) then
log("Encoder LEDs are OK.", VLOW);
end if;
end if; -- RUN_ENC_TEST
---------------------------------------------------------------------------
-- End
---------------------------------------------------------------------------
wait for 20 us;
passed <= true after 100 ns;
wait;
end process pTEST_PROC;
failed <= error_flag after 100 ns;
CHECK_SIM_TIMEOUT: process
begin -- process CHECK_SIM_TIMEOUT
while now < MAX_SIM_TIME loop
wait for 100 us;
end loop;
test_timeout <= true;
wait;
end process CHECK_SIM_TIMEOUT;
pREPORT_RESULT : process
begin
wait until failed = true or passed = true or test_timeout = true;
wait for 1 us;
log_separator_line(VLOW);
if(failed = true) then
log("FAILURE: test completed with errors.", VLOW);
elsif(passed = true) then
log("SUCCESS: test successfully completed.", VLOW);
elsif(test_timeout = true) then
log("FAILURE: test achieved max-sim-time without reaching ", VLOW);
log(" failed/passed condition.", VLOW);
end if;
log_separator_line(VLOW);
test_completed <= true;
end process pREPORT_RESULT;
end architecture behav;