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

Subversion Repositories highload

[/] [highload/] [trunk/] [high_load.vhd] - Blame information for rev 3

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

Line No. Rev Author Line
1 2 alexadmin
-- High load test project. ***** TOP level file *****
2
-- Alexey Fedorov, 2014
3
-- email: FPGA@nerudo.com
4
--
5
-- It is intended for checking device 
6
-- for high consumption power.
7
-- Number of parameter gives possibility
8
-- to change number of used LC/DFF, DSP, RAM and I/O.
9
--
10
-- It can operate at 200 MHz in Cyclone 5E FPGA
11
--
12
--      1 LC core is about 1500 LUT4/FF (with default parameters)
13
--  1 DSP core is 7 DSP 18*18.
14
--  Each LC core also demands 4*N RAM block (32 bits width)
15
 
16
--To maximize power consumption:
17
--1) Find parameters for maximum FPGA resource usage
18
--2) Fed maximum frequency clock to CLK input (directly or via PLL instantiated in top level)
19
--3) Fed random data to inputs (lower ADC bits or data from PRBS generator)
20
--4) Connect maximal count of outputs. Be careful: They are switching simultaneously.
21
--
22
-- **** USE HIGH LOAD PROJECT AT YOUR OWN RISK ****
23
--
24
 
25
 
26
library ieee;
27
use ieee.std_logic_1164.all;
28
use ieee.numeric_std.all;
29
 
30
 
31
entity high_load is
32
        generic (
33
                NUM_IN  : positive := 3*14;     -- Input pins
34
                NUM_OUT : positive := 1;                -- Output pins
35
                NUM_LC : positive := 16;                -- Number of LC cores
36
                NUM_DSP : positive := 9;                -- Number of DSP cores
37
                RAM_DEPTH_LOG2 : integer range 4 to 30 := 10    -- RAM depth
38
                );
39
        port
40
        (
41
                -- Input ports
42
                clk     : in  std_logic;
43
                inputs: in std_logic_vector(NUM_IN-1 downto 0);
44
 
45
                -- Output ports
46
                dataout: out std_logic_vector(NUM_OUT-1 downto 0)
47
        );
48
end high_load;
49
 
50
 
51
 
52
architecture rtl of high_load is
53
 
54
--component aes_test_wrap is
55
--port(
56
--              clk     : in  std_logic;
57
--              datain: in std_logic_vector(127 downto 0);
58
--              key             : in std_logic_vector(127 downto 0);
59
--              dataout: out std_logic_vector(127 downto 0)
60
--      );
61
--end component;
62
 
63
component lc_use is
64
        generic (
65
                DATA_WIDTH : positive := 128;
66
                ARITH_SIZE : positive := 16; -- Should be divider of DATA_WIDTH
67 3 alexadmin
                NUM_ROWS: positive := 6;        -- Input pins
68
        ADD_PIPL_FF : boolean := false
69 2 alexadmin
                );
70
        port
71
        (
72
                clk     : in  std_logic;
73
                inputs: in std_logic_vector(DATA_WIDTH-1 downto 0);
74
                dataout: out std_logic_vector(DATA_WIDTH-1 downto 0)
75
        );
76
end component;
77
 
78
component dsp_use is
79
        generic (
80
                DATA_WIDTH  : positive := 16
81
                );
82
        port
83
        (
84
                clk     : in  std_logic;
85
                datain: in std_logic_vector(DATA_WIDTH-1 downto 0);
86
                dataout: out std_logic_vector(DATA_WIDTH-1 downto 0)
87
        );
88
end component;
89
 
90
component ram_buf IS
91
        generic (
92
                DATA_WIDTH: positive := 12;
93
                DEPTH_LOG2: positive := 10
94
                );
95
  port(
96
    clk    : in  std_logic;         -- input data clock
97
--    ena    : in  std_logic;         -- input data enable
98
    din    : in  std_logic_vector(DATA_WIDTH-1 downto 0);
99
    delay  : in  std_logic_vector(DEPTH_LOG2-1 downto 0);
100
    dout   : out std_logic_vector(DATA_WIDTH-1 downto 0)
101
    );
102
END component;
103
 
104
constant DSP_WIDTH : integer := 15;     -- Data width of DSP multipliers
105
 
106
constant LC_W : integer := 128*NUM_LC;
107
constant DSP_W : integer := DSP_WIDTH*NUM_DSP;
108
 
109
--constant key : bit_vector(127 downto 0) := X"2BAC93F18E4797830BD476554BBE27A5";
110
 
111
signal lc_in, lc_out, ram_in, ram_out : std_logic_vector(LC_W-1 downto 0);
112
signal dsp_in, dsp_out : std_logic_vector(DSP_W-1 downto 0);
113
 
114
signal xor_result : std_logic;
115
 
116
procedure assign_bus(
117
        signal inp  : in  std_logic_vector;
118
        signal outp : out std_logic_vector) is
119
 
120
        constant IN_W : integer := inp'length(1);
121
        constant OUT_W: integer := outp'length(1);
122
 
123
        begin
124
        for i in 1 to OUT_W/IN_W loop
125
                if i = 1 then
126
                        outp((i-1)*IN_W+IN_W-1 downto (i-1)*IN_W) <= inp;
127
                else
128
                        outp((i-1)*IN_W+IN_W-1 downto (i-1)*IN_W) <= inp xor to_stdlogicvector(to_bitvector(inp) rol (i-1));
129
                end if;
130
        end loop;
131
        if OUT_W mod IN_W > 0 then
132
                outp(OUT_W-1 downto (OUT_W/IN_W)*IN_W) <= inp(OUT_W mod IN_W - 1 downto 0);
133
        end if;
134
end procedure;
135
 
136
procedure xorbus(
137
        signal inp  : in  std_logic_vector;
138
        signal outp : out std_logic
139
) is
140
variable tmp : std_logic := '0';
141
begin
142
 
143
        for i in inp'range loop
144
                tmp := tmp xor inp(i);
145
        end loop;
146
 
147
        outp <= tmp;
148
 
149
end procedure;
150
 
151
 
152
procedure resultbus(
153
        signal inp  : in  std_logic_vector;
154
        signal outp : out std_logic
155
) is
156
variable tmp : integer := 0;
157
begin
158
        for i in inp'range loop
159
                if inp(i) = '1' then
160
                        tmp := tmp + 1;
161
                end if;
162
        end loop;
163
 
164
        if tmp >= inp'length(1) then
165
                outp <= '1';
166
        else
167
                outp <= '0';
168
        end if;
169
 
170
end procedure;
171
 
172
 
173
begin
174
 
175
assert lc_in'length(1) <  dsp_in'length(1) report "Implementing Input => DSP => RAM => LC => Output" severity warning;
176
assert lc_in'length(1) >= dsp_in'length(1) report "Implementing Input => LC => RAM => DSP => Output" severity warning;
177
 
178
process(clk) --inputs, lc_in, lc_out, ram_in, ram_out, dsp_in, dsp_out, xor_result)
179
begin
180
if rising_edge(clk) then
181
        if(lc_in'length(1) < dsp_in'length(1)) then
182
                assign_bus(inputs, lc_in);      -- Input => LC => RAM => DSP => Output
183
                assign_bus(lc_out, ram_in);
184
                assign_bus(ram_out, dsp_in);
185
--              resultbus(dsp_out, xor_result);
186
                xorbus(dsp_out, xor_result);
187
                dataout <= (others => xor_result);
188
        else
189
                assign_bus(inputs, dsp_in);     -- Input => DSP => RAM => LC => Output
190
                assign_bus(dsp_out, ram_in);
191
                assign_bus(ram_out, lc_in);
192
--              resultbus(lc_out, xor_result);
193
                xorbus(lc_out, xor_result);
194
                dataout <= (others => xor_result);
195
        end if;
196
end if;
197
 
198
end process;
199
 
200
 
201
LC_GEN: for i in 0 to NUM_LC-1 generate
202
--      aes_i : aes_test_wrap 
203
--      port map(
204
--              clk             => clk,
205
--              datain => aes_in(128*i+127 downto 128*i),
206
--              key      => to_stdlogicvector(key rol i),
207
--              dataout=> aes_out(128*i+127 downto 128*i)
208
--      );
209
        lc_i: lc_use
210
        generic map (
211
                DATA_WIDTH => 128,
212
                ARITH_SIZE => 16, -- Should be divider of DATA_WIDTH
213 3 alexadmin
                NUM_ROWS         => 6,  -- Input pins
214
                ADD_PIPL_FF => true
215 2 alexadmin
                )
216
        port map
217
        (
218
                clk              => clk,
219
                inputs => lc_in(128*i+127 downto 128*i),
220
                dataout=> lc_out(128*i+127 downto 128*i)
221
        );
222
 
223
end generate;
224
 
225
DSP_GEN: for i in 0 to NUM_DSP-1 generate
226
 
227
        dsp_i : dsp_use
228
        generic map(
229
                DATA_WIDTH  => DSP_WIDTH)
230
        port map
231
        (
232
                clk                     => clk,
233
                datain  => dsp_in(DSP_WIDTH*i+DSP_WIDTH-1 downto DSP_WIDTH*i),
234
                dataout => dsp_out(DSP_WIDTH*i+DSP_WIDTH-1 downto DSP_WIDTH*i)
235
        );
236
 
237
end generate;
238
 
239
RAM_GEN: for i in 0 to NUM_LC-1 generate
240
        ram_i: ram_buf
241
                generic map(
242
                DATA_WIDTH => 128,
243
                DEPTH_LOG2 => RAM_DEPTH_LOG2
244
                )
245
                port map(
246
                        clk   => clk,
247
                        din   => ram_in(128*i+127 downto 128*i),
248
                        delay => std_logic_vector(to_unsigned(2**RAM_DEPTH_LOG2-10, RAM_DEPTH_LOG2)),
249
                        dout  => ram_out(128*i+127 downto 128*i)
250
    );
251
end generate;
252
 
253
end rtl;

powered by: WebSVN 2.1.0

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