Commit 55a2fd2f authored by Ille, Ondrej, Ing.'s avatar Ille, Ondrej, Ing.

test: Bug-fix of TIMESTAMP register read.

constants which correspond to TIMESTAMP registers are in
can_fd_register_map. Constants are TIMESTAMP_HIGH_ADR and
TIMESTAMP_LOW_ADR.

TIMESTAMP_L_W_ADR is address of TIMESTAMP word within CAN frame
read from RX Buffer or stored to TXT Buffer.
parent e5c9644f
Pipeline #5986 canceled with stages
in 6 minutes and 5 seconds
......@@ -88,26 +88,33 @@ package body timestamp_registers_feature is
wait for 1000 ns;
for i in 0 to 50 loop
------------------------------------------------------------------------
-------------------------------------------------------------------
-- Read and save timestamp from registers
------------------------------------------------------------------------
-------------------------------------------------------------------
ts_input := iout(1).stat_bus(STAT_TS_HIGH downto STAT_TS_LOW);
------------------------------------------------------------------------
-------------------------------------------------------------------
-- Read timestamp with lib function
------------------------------------------------------------------------
-------------------------------------------------------------------
CAN_read_timestamp(ts_read, ID_1, mem_bus(1));
------------------------------------------------------------------------
-------------------------------------------------------------------
-- Compare both values
------------------------------------------------------------------------
-------------------------------------------------------------------
info("Timestamp input: 0x" & to_hstring(ts_input));
info("Timestamp read: 0x" & to_hstring(ts_read));
diff := unsigned(ts_input) - unsigned(ts_read);
-------------------------------------------------------------------
-- Substract Read timestamp from Input timestamp. Input timestamp is
-- stored first, thus it will be always lower than read timestamp
-- (memory access lasts one clock cycle). When substracting in this
-- order, we avoid underflow on "unsigned" data type, which is
-- defined from 0.
-------------------------------------------------------------------
diff := unsigned(ts_read) - unsigned(ts_input);
check(diff < 10, "Timestamp difference is too big! " &
"Difference " & integer'image(to_integer(diff)));
check(to_integer(diff) < 10, "Timestamp difference is too big! " &
"Difference " & integer'image(to_integer(diff)));
end loop;
end procedure;
......
......@@ -4407,11 +4407,11 @@ package body CANtestLib is
constant ID : in natural range 0 to 15;
signal mem_bus : inout Avalon_mem_type
) is
variable lower_word : std_logic_vector(31 downto 0);
variable upper_word : std_logic_vector(31 downto 0);
variable lower_word : std_logic_vector(31 downto 0);
variable upper_word : std_logic_vector(31 downto 0);
begin
CAN_read(lower_word, TIMESTAMP_L_W_ADR, ID, mem_bus);
CAN_read(upper_word, TIMESTAMP_U_W_ADR, ID, mem_bus);
CAN_read(lower_word, TIMESTAMP_LOW_ADR, ID, mem_bus);
CAN_read(upper_word, TIMESTAMP_HIGH_ADR, ID, mem_bus);
ts := upper_word & lower_word;
end procedure;
......
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