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

Subversion Repositories highload

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

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
                NUM_ROWS: positive := 6 -- Input pins
68
                );
69
        port
70
        (
71
                clk     : in  std_logic;
72
                inputs: in std_logic_vector(DATA_WIDTH-1 downto 0);
73
                dataout: out std_logic_vector(DATA_WIDTH-1 downto 0)
74
        );
75
end component;
76
 
77
component dsp_use is
78
        generic (
79
                DATA_WIDTH  : positive := 16
80
                );
81
        port
82
        (
83
                clk     : in  std_logic;
84
                datain: in std_logic_vector(DATA_WIDTH-1 downto 0);
85
                dataout: out std_logic_vector(DATA_WIDTH-1 downto 0)
86
        );
87
end component;
88
 
89
component ram_buf IS
90
        generic (
91
                DATA_WIDTH: positive := 12;
92
                DEPTH_LOG2: positive := 10
93
                );
94
  port(
95
    clk    : in  std_logic;         -- input data clock
96
--    ena    : in  std_logic;         -- input data enable
97
    din    : in  std_logic_vector(DATA_WIDTH-1 downto 0);
98
    delay  : in  std_logic_vector(DEPTH_LOG2-1 downto 0);
99
    dout   : out std_logic_vector(DATA_WIDTH-1 downto 0)
100
    );
101
END component;
102
 
103
constant DSP_WIDTH : integer := 15;     -- Data width of DSP multipliers
104
 
105
constant LC_W : integer := 128*NUM_LC;
106
constant DSP_W : integer := DSP_WIDTH*NUM_DSP;
107
 
108
--constant key : bit_vector(127 downto 0) := X"2BAC93F18E4797830BD476554BBE27A5";
109
 
110
signal lc_in, lc_out, ram_in, ram_out : std_logic_vector(LC_W-1 downto 0);
111
signal dsp_in, dsp_out : std_logic_vector(DSP_W-1 downto 0);
112
 
113
signal xor_result : std_logic;
114
 
115
procedure assign_bus(
116
        signal inp  : in  std_logic_vector;
117
        signal outp : out std_logic_vector) is
118
 
119
        constant IN_W : integer := inp'length(1);
120
        constant OUT_W: integer := outp'length(1);
121
 
122
        begin
123
        for i in 1 to OUT_W/IN_W loop
124
                if i = 1 then
125
                        outp((i-1)*IN_W+IN_W-1 downto (i-1)*IN_W) <= inp;
126
                else
127
                        outp((i-1)*IN_W+IN_W-1 downto (i-1)*IN_W) <= inp xor to_stdlogicvector(to_bitvector(inp) rol (i-1));
128
                end if;
129
        end loop;
130
        if OUT_W mod IN_W > 0 then
131
                outp(OUT_W-1 downto (OUT_W/IN_W)*IN_W) <= inp(OUT_W mod IN_W - 1 downto 0);
132
        end if;
133
end procedure;
134
 
135
procedure xorbus(
136
        signal inp  : in  std_logic_vector;
137
        signal outp : out std_logic
138
) is
139
variable tmp : std_logic := '0';
140
begin
141
 
142
        for i in inp'range loop
143
                tmp := tmp xor inp(i);
144
        end loop;
145
 
146
        outp <= tmp;
147
 
148
end procedure;
149
 
150
 
151
procedure resultbus(
152
        signal inp  : in  std_logic_vector;
153
        signal outp : out std_logic
154
) is
155
variable tmp : integer := 0;
156
begin
157
        for i in inp'range loop
158
                if inp(i) = '1' then
159
                        tmp := tmp + 1;
160
                end if;
161
        end loop;
162
 
163
        if tmp >= inp'length(1) then
164
                outp <= '1';
165
        else
166
                outp <= '0';
167
        end if;
168
 
169
end procedure;
170
 
171
 
172
begin
173
 
174
assert lc_in'length(1) <  dsp_in'length(1) report "Implementing Input => DSP => RAM => LC => Output" severity warning;
175
assert lc_in'length(1) >= dsp_in'length(1) report "Implementing Input => LC => RAM => DSP => Output" severity warning;
176
 
177
process(clk) --inputs, lc_in, lc_out, ram_in, ram_out, dsp_in, dsp_out, xor_result)
178
begin
179
if rising_edge(clk) then
180
        if(lc_in'length(1) < dsp_in'length(1)) then
181
                assign_bus(inputs, lc_in);      -- Input => LC => RAM => DSP => Output
182
                assign_bus(lc_out, ram_in);
183
                assign_bus(ram_out, dsp_in);
184
--              resultbus(dsp_out, xor_result);
185
                xorbus(dsp_out, xor_result);
186
                dataout <= (others => xor_result);
187
        else
188
                assign_bus(inputs, dsp_in);     -- Input => DSP => RAM => LC => Output
189
                assign_bus(dsp_out, ram_in);
190
                assign_bus(ram_out, lc_in);
191
--              resultbus(lc_out, xor_result);
192
                xorbus(lc_out, xor_result);
193
                dataout <= (others => xor_result);
194
        end if;
195
end if;
196
 
197
end process;
198
 
199
 
200
LC_GEN: for i in 0 to NUM_LC-1 generate
201
--      aes_i : aes_test_wrap 
202
--      port map(
203
--              clk             => clk,
204
--              datain => aes_in(128*i+127 downto 128*i),
205
--              key      => to_stdlogicvector(key rol i),
206
--              dataout=> aes_out(128*i+127 downto 128*i)
207
--      );
208
        lc_i: lc_use
209
        generic map (
210
                DATA_WIDTH => 128,
211
                ARITH_SIZE => 16, -- Should be divider of DATA_WIDTH
212
                NUM_ROWS         => 6   -- Input pins
213
                )
214
        port map
215
        (
216
                clk              => clk,
217
                inputs => lc_in(128*i+127 downto 128*i),
218
                dataout=> lc_out(128*i+127 downto 128*i)
219
        );
220
 
221
end generate;
222
 
223
DSP_GEN: for i in 0 to NUM_DSP-1 generate
224
 
225
        dsp_i : dsp_use
226
        generic map(
227
                DATA_WIDTH  => DSP_WIDTH)
228
        port map
229
        (
230
                clk                     => clk,
231
                datain  => dsp_in(DSP_WIDTH*i+DSP_WIDTH-1 downto DSP_WIDTH*i),
232
                dataout => dsp_out(DSP_WIDTH*i+DSP_WIDTH-1 downto DSP_WIDTH*i)
233
        );
234
 
235
end generate;
236
 
237
RAM_GEN: for i in 0 to NUM_LC-1 generate
238
        ram_i: ram_buf
239
                generic map(
240
                DATA_WIDTH => 128,
241
                DEPTH_LOG2 => RAM_DEPTH_LOG2
242
                )
243
                port map(
244
                        clk   => clk,
245
                        din   => ram_in(128*i+127 downto 128*i),
246
                        delay => std_logic_vector(to_unsigned(2**RAM_DEPTH_LOG2-10, RAM_DEPTH_LOG2)),
247
                        dout  => ram_out(128*i+127 downto 128*i)
248
    );
249
end generate;
250
 
251
end rtl;

powered by: WebSVN 2.1.0

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