File: ../../Sources/A23_run_interruption_update.vhd
0: ----------------------------------------------------------------------------------
1: -- Engineer: Vitor Mendes Camilo
2: --
3: -- Module Name: A23_run_interruption_update - Behavioral
4: --
5: -- Description: Code segment A.23
6: -- Update of variables for run interruption sample
7: --
8: ----------------------------------------------------------------------------------
9:
10: library ieee;
11: use ieee.std_logic_1164.all;
12: use ieee.numeric_std.all;
13: use work.openjls_pkg.all;
14:
15: entity a23_run_interruption_update is
16: generic (
17: A_WIDTH : natural := CO_AQ_WIDTH_STD;
18: N_WIDTH : natural := CO_NQ_WIDTH_STD;
19: NN_WIDTH : natural := CO_NNQ_WIDTH_STD;
20: ERROR_WIDTH : natural := CO_ERROR_VALUE_WIDTH_STD;
21: RESET : natural := CO_RESET_STD
22: );
23: port (
24: iErrVal : in signed (ERROR_WIDTH - 1 downto 0);
25: iRiType : in std_logic;
26: iAq : in unsigned (A_WIDTH - 1 downto 0);
27: iNq : in unsigned (N_WIDTH - 1 downto 0);
28: iNn : in unsigned (NN_WIDTH - 1 downto 0);
29: oAq : out unsigned (A_WIDTH - 1 downto 0);
30: oNq : out unsigned (N_WIDTH - 1 downto 0);
31: oNn : out unsigned (NN_WIDTH - 1 downto 0)
32: );
33: end entity a23_run_interruption_update;
34:
35: architecture behavioral of a23_run_interruption_update is
36:
37: begin
38:
39: p_ri_update : process (iErrVal, iRiType, iAq, iNq, iNn) is
40:
41: variable vAq : integer;
42: variable vNq : integer;
43: variable vNn : integer;
44:
45: begin
46:
47: vAq := to_integer(iAq);
48: vNq := to_integer(iNq);
49: vNn := to_integer(iNn);
50:
51: if (iErrVal < 0) then
52: vNn := vNn + 1;
53: end if;
54:
55: -- Mert 2018 Fig. 9 equivalence: A[Q] += abs(Errval) - RItype
56: vAq := vAq + abs(to_integer(iErrVal)) - std_to_int(iRiType);
57:
58: if (vNq = integer(RESET)) then
59: vAq := vAq / 2;
60: vNq := vNq / 2;
61: vNn := vNn / 2;
62: end if;
63:
64: vNq := vNq + 1;
65:
66: oAq <= to_unsigned(vAq, oAq'length);
67: oNq <= to_unsigned(vNq, oNq'length);
68: oNn <= to_unsigned(vNn, oNn'length);
69:
70: end process p_ri_update;
71:
72: end architecture behavioral;