Commit ed12cb0e authored by Evangelia Gousiou's avatar Evangelia Gousiou

added tests for the DB9 RTM;

updated conv_ttl_rs485.vhd to the one from DB-new-conv-common-gw that treats the different RTMs
parent 289c8e93
......@@ -89,6 +89,8 @@ architecture behav of testbench is
signal in_out_same_err : cnt_ch_array;
signal pulse_cnt_ttl, pulse_cnt_rs485: cnt_ch_array;
signal inv_err : cnt_ch_array;
signal rtm_db9_ch0_err : integer;
signal rtm_db9_ch1_err : integer;
signal test_id : string(7 downto 1);
......@@ -284,6 +286,8 @@ begin
fp_rp_oppos_err <= (others=> (0));
in_out_same_err <= (others=> (0));
in_out_oppos_err <= (others=> (0));
rtm_db9_ch0_err <= 0;
rtm_db9_ch1_err <= 0;
else
for i in 0 to C_NR_CHANS-1 loop -- loop: 7 channels
if ttl_out(i) /= rs485_out(i) then
......@@ -303,6 +307,15 @@ begin
end if;
end loop;
if (rs485_out(0) /= rs485_out(1)) or (ttl_out(0) /= rs485_out(0)) then
rtm_db9_ch0_err <= rtm_db9_ch0_err+1;
end if;
if (rs485_out(4) /= rs485_out(5)) or (ttl_out(1) /= rs485_out(4)) then
rtm_db9_ch1_err <= rtm_db9_ch1_err+1;
end if;
end if;
end if;
end process;
......@@ -357,11 +370,11 @@ begin
end if;
end process pulse_counter_ttl;
pulse_counter_rs485: process (rs485_out)
pulse_counter_rs485: process (rs485_out, vme_sysreset_n, rst_cnt)
begin
if vme_sysreset_n = '0' or rst_cnt = '1' then
pulse_cnt_rs485 <= (others=> (0));
end if;
else
--for i in 0 to C_NR_CHANS-1 loop
if rising_edge(rs485_out(0)) then
pulse_cnt_rs485(0) <= pulse_cnt_rs485(0) +1;
......@@ -382,6 +395,7 @@ begin
pulse_cnt_rs485(5) <= pulse_cnt_rs485(5) +1;
end if;
--end loop;
end if;
end process pulse_counter_rs485;
--============================================================================
......@@ -693,6 +707,7 @@ begin
wait for 2 us; -- ML: does not work without this wait, no idea way?
rst_copm <= '0';
print_now_s_i("Sending pulses to TTL_N_IN(5): ", nb_pulses_to_send_bar);
generate_pulse (ttl_n_in(5), nb_pulses_to_send_bar, "fp", rs485_fs_n_in(5), 200ns, 200ns);
-- Check if TTL_N_IN is the opposite of TTL_O; Note: TTLbar does not invert the output!
......@@ -728,6 +743,7 @@ begin
rst_cnt <= '0';
-- create a 50ns glitch during a 450ns pulse: ------|____|-|____|------
print_now("Sending a 50ns glitch during a 450ns pulse to TTL_N_IN(5)");
generate_pulse (ttl_n_in(5), nb_pulses_to_send_bar, "fp", rs485_fs_n_in(5), 200ns, 50ns);
-- Checking that a single pulse passed to the output
......@@ -766,6 +782,7 @@ begin
rst_cnt <= '0';
-- create a 50ns glitch during a 450ns pulse: ------|____|-|____|------
print_now("Sending a 50ns glitch during a 450ns pulse to TTL_N_IN(5)");
generate_pulse (ttl_n_in(5), nb_pulses_to_send_bar, "fp", rs485_fs_n_in(5), 200ns, 50ns);
-- Checking that the glitch passed to the output
......@@ -782,7 +799,7 @@ begin
---------------------------------------------------------------------------
-- DB9 RTM test
-- DB9 RTM test from TTL_N_IN -> RS485_O
test_id <= "TEST 13";
print_now("----------------------------------------------------------------");
print_now("---> Test 13: Test RS485 outputs with DB9 RTM");
......@@ -802,10 +819,30 @@ begin
rst_cnt <= '0';
-- generate pulses
print_now_s_i("Sending pulses to TTL_N_IN(0): ", nb_pulses_to_send_fp);
generate_pulse (ttl_n_in(0), nb_pulses_to_send_fp, "fp", rs485_fs_n_in(0), 200ns, 200ns);
nb_pulses_to_send_fp := 4;
print_now_s_i("Sending pulses to TTL_N_IN(1): ", nb_pulses_to_send_fp);
generate_pulse (ttl_n_in(1), nb_pulses_to_send_fp, "fp", rs485_fs_n_in(1), 200ns, 200ns);
-- Checking that a single pulse passed to the output
-- Check that the TTL_N_IN(0) pulses arrived to both Rear Panel Channel 1 and Rear Panel Channel 2
print_now("Check that the TTL_N_IN(0) pulses arrived to the RS485_O(0) and RS485_O(1)");
if rtm_db9_ch0_err = 0 then
print_now("[OK] RS485_O(0) and RS485_O(1) match TTL_O(0)");
else
print_now("[ERR] RS485_O(0) or RS485_O(1) do not match TTL_O(0)");
err_cnt := err_cnt + 1;
end if;
-- Check that the TTL_N_IN(1) pulses arrived to both Rear Panel Channel 1 and Rear Panel Channel 2 have
print_now("Check that the TTL_N_IN(1) pulses arrived to the RS485_O(4) and RS485_O(5)");
if rtm_db9_ch1_err = 0 then
print_now("[OK] RS485_O(4) and RS485_O(5) match TTL_O(1)");
else
print_now("[ERR] RS485_O(4) or RS485_O(5) do not match TTL_O(1)");
err_cnt := err_cnt + 1;
end if;
---------------------------------------------------------------------------
print_now_s_i("Errors so far: ", err_cnt);
......@@ -813,6 +850,55 @@ begin
---------------------------------------------------------------------------
---------------------------------------------------------------------------
-- DB9 RTM test from RS485_N_I -> TTL_O
test_id <= "TEST 14";
print_now("----------------------------------------------------------------");
print_now("---> Test 14: Test TTL outputs with DB9 RTM");
print_now("----------------------------------------------------------------");
---------------------------------------------------------------------------
-- Change board settings
print_now("---> Configure board settings");
glitch_filter_en := '0';
ttl_out_bar_en := '0';
nb_pulses_to_send_rp := 10;
rtm := C_RTM_DB9;
settings_config (glitch_filter_en, ttl_out_bar_en, rtm, sw_gp_n_in, sw_other_in, pcbrev, rtm_in);
rst_copm <= '1';
rst_cnt <= '1';
wait for 2 us; -- ML: does not work without this wait, no idea way?
rst_copm <= '0';
rst_cnt <= '0';
-- generate pulses
print_now_s_i("Sending pulses to RS485_N_I(4): ", nb_pulses_to_send_rp);
generate_pulse (rs485_n_in(4), nb_pulses_to_send_rp, "rp", rs485_fs_n_in(4), 200ns, 200ns);
print_now("Check that the pulses arrived to the RS485_O(4)");
if pulse_cnt_rs485(4) = nb_pulses_to_send_rp then
print_now_s_i("[OK] Number of pulses measured at RS485_O(4) :",pulse_cnt_rs485(4));
else
print_now_s_i("[ERR] Number of pulses measured in the RS485_O(4) : ",pulse_cnt_rs485(4));
err_cnt := err_cnt + 1;
end if;
-- Check that the RS485_N_I(4) pulses arrived to RS485_OUT(4), RS485_OUT(5) and TTL_O(1)
print_now("Check that the RS485_N_I(4) pulses arrived to RS485_OUT(4), RS485_OUT(5) and TTL_O(1)");
if rtm_db9_ch1_err = 0 then
print_now("[OK] TTL_O(1) and RS485_N_I(5) match RS485_N_I(4)");
else
print_now("[ERR] TTL_O(1) or RS485_OUT(5) does not match RS485_OUT(4)");
err_cnt := err_cnt + 1;
end if;
---------------------------------------------------------------------------
print_now_s_i("Errors so far: ", err_cnt);
---------------------------------------------------------------------------
print("*****************************************************************************");
print(" Tests Summary");
print("*****************************************************************************");
......
......@@ -49,6 +49,7 @@ use work.wishbone_pkg.all;
use work.conv_common_gw_pkg.all;
entity conv_ttl_rs485 is
generic (g_simul : boolean := FALSE);
port
(
-- Clocks
......@@ -166,7 +167,7 @@ architecture arch of conv_ttl_rs485 is
constant c_board_id : std_logic_vector(31 downto 0) := x"54343835";
-- Gateware version
constant c_gwvers : std_logic_vector(7 downto 0) := x"10";
constant c_gwvers : std_logic_vector(7 downto 0) := x"20";
--============================================================================
-- Type declarations
......@@ -188,6 +189,7 @@ architecture arch of conv_ttl_rs485 is
signal inv_pulse_out : std_logic_vector(c_nr_inv_chans-1 downto 0);
signal pulse_ttl : std_logic_vector(c_nr_chans-1 downto 0);
signal pulse_rs485 : std_logic_vector(c_nr_chans-1 downto 0);
signal pulse_rs485_mapped : std_logic_vector(c_nr_chans-1 downto 0);
signal inhibit_first_pulse : std_logic;
signal inhibit_first_pulse_d0 : std_logic;
signal inhibit_cnt : unsigned(10 downto 0);
......@@ -277,7 +279,13 @@ begin
gen_rs485_input : for i in 0 to c_nr_chans-1 generate
rs485_fs(i) <= rs485_n_i(i) nor rs485_fs_n_i(i);
pulse_rs485(i) <= (not rs485_n_i(i)) when rs485_fs(i) = '0' else '0';
pulse_rs485_mapped(i) <= (not rs485_n_i(i)) when rs485_fs(i) = '0' else '0';
pulse_rs485(0) <= pulse_rs485_mapped(0);
pulse_rs485(1) <= pulse_rs485_mapped(4) when rtmp_i = "101" else pulse_rs485_mapped(1);
pulse_rs485(2) <= pulse_rs485_mapped(2) when rtmp_i = "101" else pulse_rs485_mapped(2);
pulse_rs485(3) <= pulse_rs485_mapped(3) when rtmp_i = "101" else pulse_rs485_mapped(3);
pulse_rs485(4) <= pulse_rs485_mapped(1) when rtmp_i = "101" else pulse_rs485_mapped(4);
pulse_rs485(5) <= pulse_rs485_mapped(5) when rtmp_i = "101" else pulse_rs485_mapped(5);
end generate gen_rs485_input;
......@@ -335,7 +343,7 @@ begin
cmp_conv_common : conv_common_gw
generic map
(
-- Number of repeater channels
g_simul => g_simul,
g_nr_chans => c_nr_chans,
g_board_id => c_board_id,
g_gwvers => c_gwvers,
......@@ -470,13 +478,12 @@ begin
bicolor_led_line_oen_o => bicolor_led_line_oen
);
--============================================================================
-- Channel output logic
--============================================================================
-- Front and rear panel outputs
ttl_o <= pulse_out when sw_ttl = '1' else
not pulse_out;
rs485_o (1 downto 0) <= pulse_out (1 downto 0);
-- rs485_o (1 downto 0) <= pulse_out (1 downto 0);
-- Channels 3 and 4 output copies of chans 1 and 2 respectively
-- depending on RTMP Id of RTM connected.
......@@ -485,9 +492,21 @@ begin
-- in these cases channel 3 copies channel 1
-- channel 4 copies channel 2
rs485_o (3 downto 2) <= pulse_out (1 downto 0) when rtmp_i = "101" or rtmp_i = "100"
else pulse_out (3 downto 2);
rs485_o (5 downto 4) <= pulse_out (5 downto 4);
-- rs485_o (3 downto 2) <= pulse_out (1 downto 0) when rtmp_i = "101" or rtmp_i = "100"
-- else pulse_out (3 downto 2);
-- rs485_o (5 downto 4) <= pulse_out (5 downto 4);
--============================================================================
-- Channel output logic
--============================================================================
-- Front and rear panel outputs
rs485_o(0) <= pulse_out(0);
rs485_o(1) <= pulse_out(0) when rtmp_i = "101" else pulse_out(1);
rs485_o(2) <= pulse_out(2);
rs485_o(3) <= pulse_out(3);
rs485_o(4) <= pulse_out(1) when rtmp_i = "101" else pulse_out(4);
rs485_o(5) <= pulse_out(1) when rtmp_i = "101" else pulse_out(5);
-- LED outputs
-- Boards earlier than v4 do not use -ve logic for LEDs.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment