OpenCores
URL https://opencores.org/ocsvn/versatile_fft/versatile_fft/trunk

Subversion Repositories versatile_fft

[/] [versatile_fft/] [trunk/] [multiple_units/] [src/] [icpx_pkg.vhd] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 wzab
-------------------------------------------------------------------------------
2
-- Title      : icpx
3
-- Project    : DP RAM based FFT processor
4
-------------------------------------------------------------------------------
5
-- File       : icpx_pkg.vhd
6
-- Author     : Wojciech Zabolotny  wzab01<at>gmail.com
7
-- Company    : 
8
-- License    : BSD
9
-- Created    : 2014-01-18
10
-- Platform   : 
11
-- Standard   : VHDL'93
12
-------------------------------------------------------------------------------
13
-- Description: This package defines the format used to store complex numbers
14
--              In this implementation we store numbers from range <-2.0, 2.0)
15
--              scaled to signed integers with width of ICPX_WIDTH (including
16
--              the sign bit)
17
-------------------------------------------------------------------------------
18
-- Copyright (c) 2014 
19
-------------------------------------------------------------------------------
20
-- Revisions  :
21
-- Date        Version  Author  Description
22
-- 2014-01-18  1.0      wzab    Created
23
-------------------------------------------------------------------------------
24
library ieee;
25
use ieee.std_logic_1164.all;
26
use ieee.numeric_std.all;
27
use ieee.math_real.all;
28
use ieee.math_complex.all;
29
library work;
30
use work.fft_len.all;
31
package icpx is
32
 
33
  -- Definition below is generated in the fft_len package
34
  --constant ICPX_WIDTH : integer := 16;
35
 
36
  -- constant defining the size of std_logic_vector
37
  -- needed to store the number
38
  constant ICPX_BV_LEN : integer := ICPX_WIDTH * 2;
39
 
40
  type icpx_number is record
41
    Re : signed(ICPX_WIDTH-1 downto 0);
42
    Im : signed(ICPX_WIDTH-1 downto 0);
43
  end record;
44
 
45
 
46
  -- conversion functions
47
  function icpx2stlv (
48
    constant din : icpx_number)
49
    return std_logic_vector;
50
 
51
  function stlv2icpx (
52
    constant din : std_logic_vector)
53
    return icpx_number;
54
 
55
  function cplx2icpx (
56
    constant din : complex)
57
    return icpx_number;
58
 
59
  function icpx_zero
60
    return icpx_number;
61
 
62
 
63
end icpx;
64
 
65
package body icpx is
66
 
67
  function icpx2stlv (
68
    constant din : icpx_number)
69
    return std_logic_vector is
70
 
71
    variable vres : std_logic_vector(2*ICPX_WIDTH-1 downto 0) :=
72
      (others => '0');
73
 
74
  begin  -- icpx2stlv
75
    vres := std_logic_vector(din.re) & std_logic_vector(din.im);
76
    return vres;
77
  end icpx2stlv;
78
 
79
  function stlv2icpx (
80
    constant din : std_logic_vector)
81
    return icpx_number is
82
 
83
    variable vres : ICPX_NUMBER := icpx_zero;
84
 
85
  begin  -- stlv2icpx
86
    vres.Re := signed(din(2*ICPX_WIDTH-1 downto ICPX_WIDTH));
87
    vres.Im := signed(din(ICPX_WIDTH-1 downto 0));
88
    return vres;
89
  end stlv2icpx;
90
 
91
  function cplx2icpx (
92
    constant din : complex)
93
    return icpx_number is
94
 
95
    variable vres : ICPX_NUMBER := icpx_zero;
96
 
97
  begin  -- cplx2icpx
98
    vres.Re := to_signed(integer(din.Re*(2.0**(ICPX_WIDTH-2))), ICPX_WIDTH);
99
    vres.Im := to_signed(integer(din.Im*(2.0**(ICPX_WIDTH-2))), ICPX_WIDTH);
100
    return vres;
101
  end cplx2icpx;
102
 
103
  function icpx_zero
104
    return icpx_number is
105
 
106
    variable vres : ICPX_NUMBER;
107
  begin  -- icpx_zero
108
 
109
    vres.Re := (others => '0');
110
    vres.Im := (others => '0');
111
    return vres;
112
  end icpx_zero;
113
 
114
end icpx;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.