types_p.vhd


1
library IEEE;
2
use IEEE.STD_LOGIC_1164.ALL;
3
package types is
4
  constant SPI_DATA_LENGTH  : integer := 120;  -- number of data bytes in spi data packet  EDIT: Wert aus SPI_NUMBER und SLAVE_NUMBER ausrechnen
5
  constant DATA_LENGTH  : integer := 16;
6
  constant SS_NUMBER     : integer := 3;
7
  constant SPI_NUMBER    : integer := 1;
8
  constant SLAVE_NUMBER  : integer := 1;      -- number of spi-slaves on a channel (first constant number on every channel)
9
  constant FREQUENCY    : integer := 130000000;  -- System clock frequency 100 MHz
10
  constant SAMPLE_RATE  : integer := 40000;  -- 10 kHZ Sample Rate
11
  constant CONV_TIME    : integer := 1714;    -- Converiton time 1.714 us = 1714 ns
12
  constant SAMPLE_DELAY  : integer := (1000000000/SAMPLE_RATE-CONV_TIME)/(1000000000/FREQUENCY);
13
                      -------------- Berechnung des Parameters SAMPLE_DELAY ---------------------------------------------
14
                      --
15
                      --                   (Abtastperiode - Wandlungszeit)       (1/f_A - Wandlungszeit)
16
                      -- SAMPLE_DELAY = ------------------------------------ = -------------------------------
17
                      --                       Systemtakt-Periode                    1/Systemfrequenz
18
                      --
19
                      -- hier Zaehler und Nenner mit 1000,000,000 multipliziert, damit Wandlungszeit in ns angegeben
20
                      -- werden kann
21
  type uString is array (4 downto 0) of std_logic_vector(7 downto 0);
22
  type DataBuff is array (SLAVE_NUMBER-1 downto 0) of std_logic_vector(DATA_LENGTH-1 downto 0);
23
  type SsVectorArray is array (natural range<>) of std_logic_vector(SS_NUMBER-1 downto 0);
24
  type DataVectorArray is array (natural range<>) of std_logic_vector(DATA_LENGTH-1 downto 0);
25
  -- user defined string
26
  type DataBuff_3d is array (natural range<>) of DataBuff;
27
  type IntArray  is array (0 to SPI_NUMBER-1) of integer;
28
  type Data is array (0 to SPI_DATA_LENGTH-1) of std_logic_vector(7 downto 0);
29
  
30
  type SPI_CHAN_DATA  is array (0 to SLAVE_NUMBER-1) of std_logic_vector(DATA_LENGTH-1 downto 0);
31
  type SPI_DATA  is array (0 to SPI_NUMBER-1) of SPI_CHAN_DATA;
32
  
33
  type SPI_BUFF  is array (0 to SPI_DATA_LENGTH-1+8) of std_logic_vector(7 downto 0);
34
35
  type SPIDATNEU is
36
    record
37
      CMD    : std_logic_vector(7 downto 0);
38
      ID    : std_logic_vector(7 downto 0);
39
      TYPE_h  : std_logic_vector(7 downto 0);
40
      SUB_CMD  : std_logic_vector(7 downto 0);
41
      LEN    : std_logic_vector(15 downto 0);
42
      Daten  : Data;
43
      EDC    : std_logic_vector(15 downto 0);
44
    end record;
45
end types;