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

Subversion Repositories astron_multiplier

[/] [astron_multiplier/] [trunk/] [common_complex_mult.vhd] - Blame information for rev 3

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 danv
-------------------------------------------------------------------------------
2
--
3 3 danv
-- Copyright 2020
4 2 danv
-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
5
-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
6 3 danv
-- 
7
-- Licensed under the Apache License, Version 2.0 (the "License");
8
-- you may not use this file except in compliance with the License.
9
-- You may obtain a copy of the License at
10
-- 
11
--     http://www.apache.org/licenses/LICENSE-2.0
12
-- 
13
-- Unless required by applicable law or agreed to in writing, software
14
-- distributed under the License is distributed on an "AS IS" BASIS,
15
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
-- See the License for the specific language governing permissions and
17
-- limitations under the License.
18 2 danv
--
19
-------------------------------------------------------------------------------
20
 
21
LIBRARY IEEE, common_pkg_lib, common_components_lib, technology_lib, tech_mult_lib;
22
USE IEEE.std_logic_1164.ALL;
23
USE IEEE.numeric_std.ALL;
24
USE common_pkg_lib.common_pkg.ALL;
25
USE technology_lib.technology_select_pkg.ALL;
26
 
27
--
28
-- Function: Signed complex multiply
29
--   p = a * b       when g_conjugate_b = FALSE
30
--     = (ar + j ai) * (br + j bi)
31
--     =  ar*br - ai*bi + j ( ar*bi + ai*br)
32
--
33
--   p = a * conj(b) when g_conjugate_b = TRUE
34
--     = (ar + j ai) * (br - j bi)
35
--     =  ar*br + ai*bi + j (-ar*bi + ai*br)
36
--
37
-- Architectures:
38
-- . rtl          : uses RTL to have all registers in one clocked process
39
-- . str          : uses two RTL instances of common_mult_add2 for out_pr and out_pi
40
-- . str_stratix4 : uses two Stratix4 instances of common_mult_add2 for out_pr and out_pi
41
-- . stratix4     : uses MegaWizard component from common_complex_mult(stratix4).vhd
42
-- . rtl_dsp      : uses RTL with one process (as in Altera example)
43
-- . altera_rtl   : uses RTL with one process (as in Altera example, by Raj R. Thilak)
44
--
45
-- Preferred architecture: 'str', see synth\quartus\common_top.vhd
46
 
47
ENTITY common_complex_mult IS
48
  GENERIC (
49
    g_sim              : BOOLEAN := FALSE;
50
    g_sim_level        : NATURAL := 0; -- 0: Simulate variant passed via g_variant for given g_technology
51
    g_technology       : NATURAL  := c_tech_select_default;
52
    g_variant          : STRING := "RTL";
53
    g_in_a_w           : POSITIVE;
54
    g_in_b_w           : POSITIVE;
55
    g_out_p_w          : POSITIVE;          -- default use g_out_p_w = g_in_a_w+g_in_b_w = c_prod_w
56
    g_conjugate_b      : BOOLEAN := FALSE;
57
    g_pipeline_input   : NATURAL := 1;      -- 0 or 1
58
    g_pipeline_product : NATURAL := 0;      -- 0 or 1
59
    g_pipeline_adder   : NATURAL := 1;      -- 0 or 1
60
    g_pipeline_output  : NATURAL := 1       -- >= 0
61
  );
62
  PORT (
63
    rst        : IN   STD_LOGIC := '0';
64
    clk        : IN   STD_LOGIC;
65
    clken      : IN   STD_LOGIC := '1';
66
    in_ar      : IN   STD_LOGIC_VECTOR(g_in_a_w-1 DOWNTO 0);
67
    in_ai      : IN   STD_LOGIC_VECTOR(g_in_a_w-1 DOWNTO 0);
68
    in_br      : IN   STD_LOGIC_VECTOR(g_in_b_w-1 DOWNTO 0);
69
    in_bi      : IN   STD_LOGIC_VECTOR(g_in_b_w-1 DOWNTO 0);
70
    in_val     : IN   STD_LOGIC := '1';
71
    out_pr     : OUT  STD_LOGIC_VECTOR(g_out_p_w-1 DOWNTO 0);
72
    out_pi     : OUT  STD_LOGIC_VECTOR(g_out_p_w-1 DOWNTO 0);
73
    out_val    : OUT  STD_LOGIC
74
  );
75
END common_complex_mult;
76
 
77
 
78
ARCHITECTURE str OF common_complex_mult IS
79
 
80
  CONSTANT c_pipeline        : NATURAL := g_pipeline_input + g_pipeline_product + g_pipeline_adder + g_pipeline_output;
81
 
82
  -- MegaWizard IP ip_stratixiv_complex_mult was generated with latency c_dsp_latency = 3
83
  CONSTANT c_dsp_latency     : NATURAL := 3;
84
 
85
  -- Extra output pipelining is only needed when c_pipeline > c_dsp_latency
86
  CONSTANT c_pipeline_output : NATURAL := sel_a_b(c_pipeline>c_dsp_latency, c_pipeline-c_dsp_latency, 0);
87
 
88
  SIGNAL result_re : STD_LOGIC_VECTOR(g_out_p_w-1 DOWNTO 0);
89
  SIGNAL result_im : STD_LOGIC_VECTOR(g_out_p_w-1 DOWNTO 0);
90
 
91
BEGIN
92
 
93
  -- User specificied latency must be >= MegaWizard IP dsp_mult_add2 latency
94
  ASSERT c_pipeline >= c_dsp_latency
95
    REPORT "tech_complex_mult: pipeline value not supported"
96
    SEVERITY FAILURE;
97
 
98
  -- Propagate in_val with c_pipeline latency
99
  u_out_val : ENTITY common_components_lib.common_pipeline_sl
100
  GENERIC MAP (
101
    g_pipeline  => c_pipeline
102
  )
103
  PORT MAP (
104
    rst     => rst,
105
    clk     => clk,
106
    clken   => clken,
107
    in_dat  => in_val,
108
    out_dat => out_val
109
  );
110
 
111
  u_complex_mult : ENTITY tech_mult_lib.tech_complex_mult
112
  GENERIC MAP(
113
    g_sim              => g_sim,
114
    g_sim_level        => g_sim_level,
115
    g_technology       => g_technology,
116
    g_variant          => g_variant,
117
    g_in_a_w           => g_in_a_w,
118
    g_in_b_w           => g_in_b_w,
119
    g_out_p_w          => g_out_p_w,
120
    g_conjugate_b      => g_conjugate_b,
121
    g_pipeline_input   => g_pipeline_input,
122
    g_pipeline_product => g_pipeline_product,
123
    g_pipeline_adder   => g_pipeline_adder,
124
    g_pipeline_output  => g_pipeline_output
125
  )
126
  PORT MAP(
127
    rst        => rst,
128
    clk        => clk,
129
    clken      => clken,
130
    in_ar      => in_ar,
131
    in_ai      => in_ai,
132
    in_br      => in_br,
133
    in_bi      => in_bi,
134
    result_re  => result_re,
135
    result_im  => result_im
136
  );
137
 
138
  ------------------------------------------------------------------------------
139
  -- Extra output pipelining
140
  ------------------------------------------------------------------------------
141
 
142
  u_output_re_pipe : ENTITY common_components_lib.common_pipeline  -- pipeline output
143
  GENERIC MAP (
144
    g_representation => "SIGNED",
145
    g_pipeline       => c_pipeline_output,
146
    g_in_dat_w       => g_out_p_w,
147
    g_out_dat_w      => g_out_p_w
148
  )
149
  PORT MAP (
150
    clk     => clk,
151
    clken   => clken,
152
    in_dat  => STD_LOGIC_VECTOR(result_re),
153
    out_dat => out_pr
154
  );
155
 
156
  u_output_im_pipe : ENTITY common_components_lib.common_pipeline  -- pipeline output
157
  GENERIC MAP (
158
    g_representation => "SIGNED",
159
    g_pipeline       => c_pipeline_output,
160
    g_in_dat_w       => g_out_p_w,
161
    g_out_dat_w      => g_out_p_w
162
  )
163
  PORT MAP (
164
    clk     => clk,
165
    clken   => clken,
166
    in_dat  => STD_LOGIC_VECTOR(result_im),
167
    out_dat => out_pi
168
  );
169
 
170
 
171
END str;

powered by: WebSVN 2.1.0

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