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

Subversion Repositories plasma

[/] [plasma/] [trunk/] [vhdl/] [mlite_pack.vhd] - Blame information for rev 383

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

Line No. Rev Author Line
1 39 rhoads
---------------------------------------------------------------------
2 43 rhoads
-- TITLE: Plasma Misc. Package
3 39 rhoads
-- AUTHOR: Steve Rhoads (rhoadss@yahoo.com)
4
-- DATE CREATED: 2/15/01
5
-- FILENAME: mlite_pack.vhd
6 43 rhoads
-- PROJECT: Plasma CPU core
7 39 rhoads
-- COPYRIGHT: Software placed into the public domain by the author.
8
--    Software 'as is' without warranty.  Author liable for nothing.
9
-- DESCRIPTION:
10 43 rhoads
--    Data types, constants, and add functions needed for the Plasma CPU.
11 39 rhoads
---------------------------------------------------------------------
12
library ieee;
13
use ieee.std_logic_1164.all;
14
 
15
package mlite_pack is
16
   constant ZERO          : std_logic_vector(31 downto 0) :=
17
      "00000000000000000000000000000000";
18
   constant ONES          : std_logic_vector(31 downto 0) :=
19
      "11111111111111111111111111111111";
20
   --make HIGH_Z equal to ZERO if compiler complains
21
   constant HIGH_Z        : std_logic_vector(31 downto 0) :=
22
      "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ";
23
 
24 91 rhoads
   subtype alu_function_type is std_logic_vector(3 downto 0);
25 128 rhoads
   constant ALU_NOTHING   : alu_function_type := "0000";
26
   constant ALU_ADD       : alu_function_type := "0001";
27
   constant ALU_SUBTRACT  : alu_function_type := "0010";
28
   constant ALU_LESS_THAN : alu_function_type := "0011";
29
   constant ALU_LESS_THAN_SIGNED : alu_function_type := "0100";
30
   constant ALU_OR        : alu_function_type := "0101";
31
   constant ALU_AND       : alu_function_type := "0110";
32
   constant ALU_XOR       : alu_function_type := "0111";
33
   constant ALU_NOR       : alu_function_type := "1000";
34 39 rhoads
 
35
   subtype shift_function_type is std_logic_vector(1 downto 0);
36 128 rhoads
   constant SHIFT_NOTHING        : shift_function_type := "00";
37
   constant SHIFT_LEFT_UNSIGNED  : shift_function_type := "01";
38
   constant SHIFT_RIGHT_SIGNED   : shift_function_type := "11";
39
   constant SHIFT_RIGHT_UNSIGNED : shift_function_type := "10";
40 39 rhoads
 
41 44 rhoads
   subtype mult_function_type is std_logic_vector(3 downto 0);
42 128 rhoads
   constant MULT_NOTHING       : mult_function_type := "0000";
43
   constant MULT_READ_LO       : mult_function_type := "0001";
44
   constant MULT_READ_HI       : mult_function_type := "0010";
45
   constant MULT_WRITE_LO      : mult_function_type := "0011";
46
   constant MULT_WRITE_HI      : mult_function_type := "0100";
47
   constant MULT_MULT          : mult_function_type := "0101";
48
   constant MULT_SIGNED_MULT   : mult_function_type := "0110";
49
   constant MULT_DIVIDE        : mult_function_type := "0111";
50
   constant MULT_SIGNED_DIVIDE : mult_function_type := "1000";
51 39 rhoads
 
52
   subtype a_source_type is std_logic_vector(1 downto 0);
53 128 rhoads
   constant A_FROM_REG_SOURCE : a_source_type := "00";
54
   constant A_FROM_IMM10_6    : a_source_type := "01";
55
   constant A_FROM_PC         : a_source_type := "10";
56 39 rhoads
 
57
   subtype b_source_type is std_logic_vector(1 downto 0);
58 128 rhoads
   constant B_FROM_REG_TARGET : b_source_type := "00";
59
   constant B_FROM_IMM        : b_source_type := "01";
60
   constant B_FROM_SIGNED_IMM : b_source_type := "10";
61
   constant B_FROM_IMMX4      : b_source_type := "11";
62 39 rhoads
 
63
   subtype c_source_type is std_logic_vector(2 downto 0);
64 128 rhoads
   constant C_FROM_NULL       : c_source_type := "000";
65
   constant C_FROM_ALU        : c_source_type := "001";
66
   constant C_FROM_SHIFT      : c_source_type := "001"; --same as alu
67
   constant C_FROM_MULT       : c_source_type := "001"; --same as alu
68
   constant C_FROM_MEMORY     : c_source_type := "010";
69
   constant C_FROM_PC         : c_source_type := "011";
70
   constant C_FROM_PC_PLUS4   : c_source_type := "100";
71
   constant C_FROM_IMM_SHIFT16: c_source_type := "101";
72
   constant C_FROM_REG_SOURCEN: c_source_type := "110";
73 39 rhoads
 
74
   subtype pc_source_type is std_logic_vector(1 downto 0);
75 128 rhoads
   constant FROM_INC4       : pc_source_type := "00";
76
   constant FROM_OPCODE25_0 : pc_source_type := "01";
77
   constant FROM_BRANCH     : pc_source_type := "10";
78
   constant FROM_LBRANCH    : pc_source_type := "11";
79 39 rhoads
 
80
   subtype branch_function_type is std_logic_vector(2 downto 0);
81 128 rhoads
   constant BRANCH_LTZ : branch_function_type := "000";
82
   constant BRANCH_LEZ : branch_function_type := "001";
83
   constant BRANCH_EQ  : branch_function_type := "010";
84
   constant BRANCH_NE  : branch_function_type := "011";
85
   constant BRANCH_GEZ : branch_function_type := "100";
86
   constant BRANCH_GTZ : branch_function_type := "101";
87
   constant BRANCH_YES : branch_function_type := "110";
88 139 rhoads
   constant BRANCH_NO  : branch_function_type := "111";
89 39 rhoads
 
90
   -- mode(32=1,16=2,8=3), signed, write
91
   subtype mem_source_type is std_logic_vector(3 downto 0);
92 128 rhoads
   constant MEM_FETCH   : mem_source_type := "0000";
93
   constant MEM_READ32  : mem_source_type := "0100";
94
   constant MEM_WRITE32 : mem_source_type := "0101";
95
   constant MEM_READ16  : mem_source_type := "1000";
96 139 rhoads
   constant MEM_READ16S : mem_source_type := "1010";
97 128 rhoads
   constant MEM_WRITE16 : mem_source_type := "1001";
98
   constant MEM_READ8   : mem_source_type := "1100";
99 139 rhoads
   constant MEM_READ8S  : mem_source_type := "1110";
100 128 rhoads
   constant MEM_WRITE8  : mem_source_type := "1101";
101 39 rhoads
 
102 139 rhoads
   function bv_adder(a     : in std_logic_vector;
103
                     b     : in std_logic_vector;
104 47 rhoads
                     do_add: in std_logic) return std_logic_vector;
105 39 rhoads
   function bv_negate(a : in std_logic_vector) return std_logic_vector;
106
   function bv_increment(a : in std_logic_vector(31 downto 2)
107 139 rhoads
                         ) return std_logic_vector;
108
   function bv_inc(a : in std_logic_vector
109
                  ) return std_logic_vector;
110 47 rhoads
 
111
   -- For Altera
112
   COMPONENT lpm_ram_dp
113 332 rhoads
      generic (
114
         LPM_WIDTH : natural;    -- MUST be greater than 0
115
         LPM_WIDTHAD : natural;    -- MUST be greater than 0
116
         LPM_NUMWORDS : natural := 0;
117
         LPM_INDATA : string := "REGISTERED";
118
         LPM_OUTDATA : string := "REGISTERED";
119
         LPM_RDADDRESS_CONTROL : string := "REGISTERED";
120
         LPM_WRADDRESS_CONTROL : string := "REGISTERED";
121
         LPM_FILE : string := "UNUSED";
122
         LPM_TYPE : string := "LPM_RAM_DP";
123
         USE_EAB  : string := "OFF";
124
         INTENDED_DEVICE_FAMILY  : string := "UNUSED";
125
         RDEN_USED  : string := "TRUE";
126
         LPM_HINT : string := "UNUSED");
127
      port (
128
         RDCLOCK   : in std_logic := '0';
129
         RDCLKEN   : in std_logic := '1';
130
         RDADDRESS : in std_logic_vector(LPM_WIDTHAD-1 downto 0);
131
         RDEN      : in std_logic := '1';
132
         DATA      : in std_logic_vector(LPM_WIDTH-1 downto 0);
133
         WRADDRESS : in std_logic_vector(LPM_WIDTHAD-1 downto 0);
134
         WREN      : in std_logic;
135
         WRCLOCK   : in std_logic := '0';
136
         WRCLKEN   : in std_logic := '1';
137
         Q         : out std_logic_vector(LPM_WIDTH-1 downto 0));
138 47 rhoads
   END COMPONENT;
139
 
140
   -- For Altera
141 62 rhoads
   component LPM_RAM_DQ
142
      generic (
143 91 rhoads
         LPM_WIDTH    : natural;    -- MUST be greater than 0
144
         LPM_WIDTHAD  : natural;    -- MUST be greater than 0
145 62 rhoads
         LPM_NUMWORDS : natural := 0;
146 91 rhoads
         LPM_INDATA   : string := "REGISTERED";
147 62 rhoads
         LPM_ADDRESS_CONTROL: string := "REGISTERED";
148 91 rhoads
         LPM_OUTDATA  : string := "REGISTERED";
149
         LPM_FILE     : string := "UNUSED";
150
         LPM_TYPE     : string := "LPM_RAM_DQ";
151
         USE_EAB      : string := "OFF";
152 62 rhoads
         INTENDED_DEVICE_FAMILY  : string := "UNUSED";
153 91 rhoads
         LPM_HINT     : string := "UNUSED");
154 62 rhoads
                port (
155
         DATA     : in std_logic_vector(LPM_WIDTH-1 downto 0);
156
         ADDRESS  : in std_logic_vector(LPM_WIDTHAD-1 downto 0);
157
         INCLOCK  : in std_logic := '0';
158
         OUTCLOCK : in std_logic := '0';
159
         WE       : in std_logic;
160
         Q        : out std_logic_vector(LPM_WIDTH-1 downto 0));
161
   end component;
162 47 rhoads
 
163
   -- For Xilinx
164 264 rhoads
   component RAM16X1D
165
      -- synthesis translate_off 
166
      generic (INIT : bit_vector := X"16");
167
      -- synthesis translate_on 
168
      port (DPO   : out STD_ULOGIC;
169
            SPO   : out STD_ULOGIC;
170
            A0    : in STD_ULOGIC;
171
            A1    : in STD_ULOGIC;
172
            A2    : in STD_ULOGIC;
173
            A3    : in STD_ULOGIC;
174
            D     : in STD_ULOGIC;
175
            DPRA0 : in STD_ULOGIC;
176
            DPRA1 : in STD_ULOGIC;
177
            DPRA2 : in STD_ULOGIC;
178
            DPRA3 : in STD_ULOGIC;
179
            WCLK  : in STD_ULOGIC;
180
            WE    : in STD_ULOGIC);
181 47 rhoads
   end component;
182 346 rhoads
 
183 47 rhoads
   component pc_next
184 139 rhoads
      port(clk         : in std_logic;
185
           reset_in    : in std_logic;
186
           pc_new      : in std_logic_vector(31 downto 2);
187
           take_branch : in std_logic;
188
           pause_in    : in std_logic;
189
           opcode25_0  : in std_logic_vector(25 downto 0);
190
           pc_source   : in pc_source_type;
191
           pc_future   : out std_logic_vector(31 downto 2);
192
           pc_current  : out std_logic_vector(31 downto 2);
193
           pc_plus4    : out std_logic_vector(31 downto 2));
194 47 rhoads
   end component;
195
 
196
   component mem_ctrl
197
      port(clk          : in std_logic;
198
           reset_in     : in std_logic;
199
           pause_in     : in std_logic;
200
           nullify_op   : in std_logic;
201 139 rhoads
           address_pc   : in std_logic_vector(31 downto 2);
202 47 rhoads
           opcode_out   : out std_logic_vector(31 downto 0);
203
 
204 139 rhoads
           address_in   : in std_logic_vector(31 downto 0);
205 47 rhoads
           mem_source   : in mem_source_type;
206
           data_write   : in std_logic_vector(31 downto 0);
207
           data_read    : out std_logic_vector(31 downto 0);
208
           pause_out    : out std_logic;
209 264 rhoads
 
210
           address_next : out std_logic_vector(31 downto 2);
211
           byte_we_next : out std_logic_vector(3 downto 0);
212
 
213
           address      : out std_logic_vector(31 downto 2);
214
           byte_we      : out std_logic_vector(3 downto 0);
215
           data_w       : out std_logic_vector(31 downto 0);
216
           data_r       : in std_logic_vector(31 downto 0));
217 47 rhoads
   end component;
218
 
219
   component control
220
      port(opcode       : in  std_logic_vector(31 downto 0);
221
           intr_signal  : in  std_logic;
222
           rs_index     : out std_logic_vector(5 downto 0);
223
           rt_index     : out std_logic_vector(5 downto 0);
224
           rd_index     : out std_logic_vector(5 downto 0);
225
           imm_out      : out std_logic_vector(15 downto 0);
226
           alu_func     : out alu_function_type;
227
           shift_func   : out shift_function_type;
228
           mult_func    : out mult_function_type;
229
           branch_func  : out branch_function_type;
230
           a_source_out : out a_source_type;
231
           b_source_out : out b_source_type;
232
           c_source_out : out c_source_type;
233
           pc_source_out: out pc_source_type;
234 194 rhoads
           mem_source_out:out mem_source_type;
235
           exception_out: out std_logic);
236 47 rhoads
   end component;
237
 
238
   component reg_bank
239 139 rhoads
      generic(memory_type : string := "XILINX_16X");
240 47 rhoads
      port(clk            : in  std_logic;
241
           reset_in       : in  std_logic;
242 70 rhoads
           pause          : in  std_logic;
243 47 rhoads
           rs_index       : in  std_logic_vector(5 downto 0);
244
           rt_index       : in  std_logic_vector(5 downto 0);
245
           rd_index       : in  std_logic_vector(5 downto 0);
246
           reg_source_out : out std_logic_vector(31 downto 0);
247
           reg_target_out : out std_logic_vector(31 downto 0);
248
           reg_dest_new   : in  std_logic_vector(31 downto 0);
249
           intr_enable    : out std_logic);
250
   end component;
251
 
252
   component bus_mux
253
      port(imm_in       : in  std_logic_vector(15 downto 0);
254
           reg_source   : in  std_logic_vector(31 downto 0);
255
           a_mux        : in  a_source_type;
256
           a_out        : out std_logic_vector(31 downto 0);
257
 
258
           reg_target   : in  std_logic_vector(31 downto 0);
259
           b_mux        : in  b_source_type;
260
           b_out        : out std_logic_vector(31 downto 0);
261
 
262
           c_bus        : in  std_logic_vector(31 downto 0);
263
           c_memory     : in  std_logic_vector(31 downto 0);
264 139 rhoads
           c_pc         : in  std_logic_vector(31 downto 2);
265
           c_pc_plus4   : in  std_logic_vector(31 downto 2);
266 47 rhoads
           c_mux        : in  c_source_type;
267
           reg_dest_out : out std_logic_vector(31 downto 0);
268
 
269
           branch_func  : in  branch_function_type;
270
           take_branch  : out std_logic);
271
   end component;
272
 
273
   component alu
274 139 rhoads
      generic(alu_type  : string := "DEFAULT");
275 47 rhoads
      port(a_in         : in  std_logic_vector(31 downto 0);
276
           b_in         : in  std_logic_vector(31 downto 0);
277
           alu_function : in  alu_function_type;
278
           c_alu        : out std_logic_vector(31 downto 0));
279
   end component;
280
 
281
   component shifter
282 139 rhoads
      generic(shifter_type : string := "DEFAULT" );
283 47 rhoads
      port(value        : in  std_logic_vector(31 downto 0);
284
           shift_amount : in  std_logic_vector(4 downto 0);
285
           shift_func   : in  shift_function_type;
286
           c_shift      : out std_logic_vector(31 downto 0));
287
   end component;
288
 
289
   component mult
290 139 rhoads
      generic(mult_type  : string := "DEFAULT");
291
      port(clk       : in  std_logic;
292
           reset_in  : in  std_logic;
293
           a, b      : in  std_logic_vector(31 downto 0);
294
           mult_func : in  mult_function_type;
295
           c_mult    : out std_logic_vector(31 downto 0);
296
           pause_out : out std_logic);
297 47 rhoads
   end component;
298
 
299 70 rhoads
   component pipeline
300
      port(clk            : in  std_logic;
301
           reset          : in  std_logic;
302
           a_bus          : in  std_logic_vector(31 downto 0);
303
           a_busD         : out std_logic_vector(31 downto 0);
304
           b_bus          : in  std_logic_vector(31 downto 0);
305
           b_busD         : out std_logic_vector(31 downto 0);
306
           alu_func       : in  alu_function_type;
307
           alu_funcD      : out alu_function_type;
308
           shift_func     : in  shift_function_type;
309
           shift_funcD    : out shift_function_type;
310
           mult_func      : in  mult_function_type;
311
           mult_funcD     : out mult_function_type;
312
           reg_dest       : in  std_logic_vector(31 downto 0);
313
           reg_destD      : out std_logic_vector(31 downto 0);
314
           rd_index       : in  std_logic_vector(5 downto 0);
315
           rd_indexD      : out std_logic_vector(5 downto 0);
316
 
317
           rs_index       : in  std_logic_vector(5 downto 0);
318
           rt_index       : in  std_logic_vector(5 downto 0);
319
           pc_source      : in  pc_source_type;
320
           mem_source     : in  mem_source_type;
321
           a_source       : in  a_source_type;
322
           b_source       : in  b_source_type;
323
           c_source       : in  c_source_type;
324
           c_bus          : in  std_logic_vector(31 downto 0);
325
           pause_any      : in  std_logic;
326
           pause_pipeline : out std_logic);
327
   end component;
328
 
329 47 rhoads
   component mlite_cpu
330 139 rhoads
      generic(memory_type     : string := "XILINX_16X"; --ALTERA_LPM, or DUAL_PORT_
331 132 rhoads
              mult_type       : string := "DEFAULT";
332
              shifter_type    : string := "DEFAULT";
333 139 rhoads
              alu_type        : string := "DEFAULT";
334 202 rhoads
              pipeline_stages : natural := 2); --2 or 3
335 47 rhoads
      port(clk         : in std_logic;
336
           reset_in    : in std_logic;
337
           intr_in     : in std_logic;
338
 
339 264 rhoads
           address_next : out std_logic_vector(31 downto 2); --for synch ram
340
           byte_we_next : out std_logic_vector(3 downto 0);
341
 
342
           address      : out std_logic_vector(31 downto 2);
343
           byte_we      : out std_logic_vector(3 downto 0);
344
           data_w       : out std_logic_vector(31 downto 0);
345
           data_r       : in std_logic_vector(31 downto 0);
346
           mem_pause    : in std_logic);
347 47 rhoads
   end component;
348
 
349 346 rhoads
   component cache
350
      generic(memory_type : string := "DEFAULT");
351
      port(clk            : in std_logic;
352
           reset          : in std_logic;
353
           address_next   : in std_logic_vector(31 downto 2);
354
           byte_we_next   : in std_logic_vector(3 downto 0);
355
           cpu_address    : in std_logic_vector(31 downto 2);
356
           mem_busy       : in std_logic;
357
 
358 383 rhoads
           cache_access   : out std_logic;   --access 4KB cache
359
           cache_checking : out std_logic;   --checking if cache hit
360
           cache_miss     : out std_logic);  --cache miss
361 346 rhoads
   end component; --cache
362
 
363 50 rhoads
   component ram
364 132 rhoads
      generic(memory_type : string := "DEFAULT");
365 139 rhoads
      port(clk               : in std_logic;
366
           enable            : in std_logic;
367
           write_byte_enable : in std_logic_vector(3 downto 0);
368
           address           : in std_logic_vector(31 downto 2);
369
           data_write        : in std_logic_vector(31 downto 0);
370
           data_read         : out std_logic_vector(31 downto 0));
371 47 rhoads
   end component; --ram
372 264 rhoads
 
373 47 rhoads
   component uart
374 50 rhoads
      generic(log_file : string := "UNUSED");
375 139 rhoads
      port(clk          : in std_logic;
376
           reset        : in std_logic;
377
           enable_read  : in std_logic;
378
           enable_write : in std_logic;
379
           data_in      : in std_logic_vector(7 downto 0);
380
           data_out     : out std_logic_vector(7 downto 0);
381
           uart_read    : in std_logic;
382
           uart_write   : out std_logic;
383
           busy_write   : out std_logic;
384
           data_avail   : out std_logic);
385 47 rhoads
   end component; --uart
386
 
387 285 rhoads
   component eth_dma
388
      port(clk         : in std_logic;                      --25 MHz
389
           reset       : in std_logic;
390
           enable_eth  : in std_logic;
391
           select_eth  : in std_logic;
392
           rec_isr     : out std_logic;
393
           send_isr    : out std_logic;
394
 
395
           address     : out std_logic_vector(31 downto 2); --to DDR
396
           byte_we     : out std_logic_vector(3 downto 0);
397
           data_write  : out std_logic_vector(31 downto 0);
398
           data_read   : in std_logic_vector(31 downto 0);
399
           pause_in    : in std_logic;
400
 
401
           mem_address : in std_logic_vector(31 downto 2);  --from CPU
402
           mem_byte_we : in std_logic_vector(3 downto 0);
403
           data_w      : in std_logic_vector(31 downto 0);
404
           pause_out   : out std_logic;
405
 
406
           E_RX_CLK    : in std_logic;                      --2.5 MHz receive
407
           E_RX_DV     : in std_logic;                      --data valid
408
           E_RXD       : in std_logic_vector(3 downto 0);   --receive nibble
409
           E_TX_CLK    : in std_logic;                      --2.5 MHz transmit
410
           E_TX_EN     : out std_logic;                     --transmit enable
411
           E_TXD       : out std_logic_vector(3 downto 0)); --transmit nibble
412
   end component; --eth_dma
413
 
414 50 rhoads
   component plasma
415 139 rhoads
      generic(memory_type : string := "XILINX_X16"; --"DUAL_PORT_" "ALTERA_LPM";
416 285 rhoads
              log_file    : string := "UNUSED";
417 346 rhoads
              ethernet    : std_logic := '0';
418
              use_cache   : std_logic := '0');
419
      port(clk          : in std_logic;
420
           reset        : in std_logic;
421
           uart_write   : out std_logic;
422
           uart_read    : in std_logic;
423 139 rhoads
 
424 346 rhoads
           address      : out std_logic_vector(31 downto 2);
425
           byte_we      : out std_logic_vector(3 downto 0);
426
           data_write   : out std_logic_vector(31 downto 0);
427
           data_read    : in std_logic_vector(31 downto 0);
428
           mem_pause_in : in std_logic;
429
           no_ddr_start : out std_logic;
430
           no_ddr_stop  : out std_logic;
431 139 rhoads
 
432 346 rhoads
           gpio0_out    : out std_logic_vector(31 downto 0);
433
           gpioA_in     : in std_logic_vector(31 downto 0));
434 50 rhoads
   end component; --plasma
435
 
436 285 rhoads
   component ddr_ctrl
437
      port(clk      : in std_logic;
438
           clk_2x   : in std_logic;
439
           reset_in : in std_logic;
440
 
441
           address  : in std_logic_vector(25 downto 2);
442
           byte_we  : in std_logic_vector(3 downto 0);
443
           data_w   : in std_logic_vector(31 downto 0);
444
           data_r   : out std_logic_vector(31 downto 0);
445
           active   : in std_logic;
446 346 rhoads
           no_start : in std_logic;
447
           no_stop  : in std_logic;
448 285 rhoads
           pause    : out std_logic;
449
 
450
           SD_CK_P  : out std_logic;     --clock_positive
451
           SD_CK_N  : out std_logic;     --clock_negative
452
           SD_CKE   : out std_logic;     --clock_enable
453
 
454
           SD_BA    : out std_logic_vector(1 downto 0);  --bank_address
455
           SD_A     : out std_logic_vector(12 downto 0); --address(row or col)
456
           SD_CS    : out std_logic;     --chip_select
457
           SD_RAS   : out std_logic;     --row_address_strobe
458
           SD_CAS   : out std_logic;     --column_address_strobe
459
           SD_WE    : out std_logic;     --write_enable
460
 
461
           SD_DQ    : inout std_logic_vector(15 downto 0); --data
462
           SD_UDM   : out std_logic;     --upper_byte_enable
463
           SD_UDQS  : inout std_logic;   --upper_data_strobe
464
           SD_LDM   : out std_logic;     --low_byte_enable
465
           SD_LDQS  : inout std_logic);  --low_data_strobe
466
   end component; --ddr
467
 
468 139 rhoads
end; --package mlite_pack
469 62 rhoads
 
470
 
471 39 rhoads
package body mlite_pack is
472
 
473 139 rhoads
function bv_adder(a     : in std_logic_vector;
474
                  b     : in std_logic_vector;
475 47 rhoads
                  do_add: in std_logic) return std_logic_vector is
476 39 rhoads
   variable carry_in : std_logic;
477 139 rhoads
   variable bb       : std_logic_vector(a'length-1 downto 0);
478
   variable result   : std_logic_vector(a'length downto 0);
479 39 rhoads
begin
480 47 rhoads
   if do_add = '1' then
481 39 rhoads
      bb := b;
482
      carry_in := '0';
483
   else
484
      bb := not b;
485
      carry_in := '1';
486
   end if;
487 139 rhoads
   for index in 0 to a'length-1 loop
488 39 rhoads
      result(index) := a(index) xor bb(index) xor carry_in;
489
      carry_in := (carry_in and (a(index) or bb(index))) or
490
                  (a(index) and bb(index));
491
   end loop;
492 139 rhoads
   result(a'length) := carry_in xnor do_add;
493 39 rhoads
   return result;
494
end; --function
495
 
496 91 rhoads
 
497 39 rhoads
function bv_negate(a : in std_logic_vector) return std_logic_vector is
498
   variable carry_in : std_logic;
499 139 rhoads
   variable not_a    : std_logic_vector(a'length-1 downto 0);
500
   variable result   : std_logic_vector(a'length-1 downto 0);
501 39 rhoads
begin
502
   not_a := not a;
503
   carry_in := '1';
504
   for index in a'reverse_range loop
505
      result(index) := not_a(index) xor carry_in;
506
      carry_in := carry_in and not_a(index);
507
   end loop;
508
   return result;
509
end; --function
510
 
511 91 rhoads
 
512 39 rhoads
function bv_increment(a : in std_logic_vector(31 downto 2)
513
                     ) return std_logic_vector is
514
   variable carry_in : std_logic;
515
   variable result   : std_logic_vector(31 downto 2);
516
begin
517
   carry_in := '1';
518
   for index in 2 to 31 loop
519
      result(index) := a(index) xor carry_in;
520
      carry_in := a(index) and carry_in;
521
   end loop;
522
   return result;
523
end; --function
524
 
525 91 rhoads
 
526 139 rhoads
function bv_inc(a : in std_logic_vector
527
                ) return std_logic_vector is
528 39 rhoads
   variable carry_in : std_logic;
529 139 rhoads
   variable result   : std_logic_vector(a'length-1 downto 0);
530 39 rhoads
begin
531
   carry_in := '1';
532 139 rhoads
   for index in 0 to a'length-1 loop
533 39 rhoads
      result(index) := a(index) xor carry_in;
534
      carry_in := a(index) and carry_in;
535
   end loop;
536
   return result;
537
end; --function
538
 
539
end; --package body
540
 
541
 

powered by: WebSVN 2.1.0

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