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

Subversion Repositories highload

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

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

powered by: WebSVN 2.1.0

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