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

Subversion Repositories mlite

[/] [mlite/] [trunk/] [vhdl/] [mlite_pack.vhd] - Blame information for rev 96

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
--   type alu_function_type is (alu_nothing, alu_add, alu_subtract, 
25 91 rhoads
--      alu_less_than, alu_less_than_signed, 
26 39 rhoads
--      alu_or, alu_and, alu_xor, alu_nor);
27 91 rhoads
   subtype alu_function_type is std_logic_vector(3 downto 0);
28
   constant alu_nothing   : alu_function_type := "0000";
29
   constant alu_add       : alu_function_type := "0001";
30
   constant alu_subtract  : alu_function_type := "0010";
31
   constant alu_less_than : alu_function_type := "0011";
32
   constant alu_less_than_signed : alu_function_type := "0100";
33
   constant alu_or        : alu_function_type := "0101";
34
   constant alu_and       : alu_function_type := "0110";
35
   constant alu_xor       : alu_function_type := "0111";
36
   constant alu_nor       : alu_function_type := "1000";
37 39 rhoads
 
38
--   type shift_function_type is (
39
--      shift_nothing, shift_left_unsigned,
40
--      shift_right_signed, do_right_unsigned);
41
   subtype shift_function_type is std_logic_vector(1 downto 0);
42
   constant shift_nothing        : shift_function_type := "00";
43
   constant shift_left_unsigned  : shift_function_type := "01";
44
   constant shift_right_signed   : shift_function_type := "11";
45
   constant shift_right_unsigned : shift_function_type := "10";
46
 
47
--   type mult_function_type is (
48
--      mult_nothing, mult_read_lo, mult_read_hi, mult_write_lo, 
49
--      mult_write_hi, mult_mult, mult_divide, mult_signed_divide);
50 44 rhoads
   subtype mult_function_type is std_logic_vector(3 downto 0);
51
   constant mult_nothing       : mult_function_type := "0000";
52
   constant mult_read_lo       : mult_function_type := "0001";
53
   constant mult_read_hi       : mult_function_type := "0010";
54
   constant mult_write_lo      : mult_function_type := "0011";
55
   constant mult_write_hi      : mult_function_type := "0100";
56
   constant mult_mult          : mult_function_type := "0101";
57
   constant mult_signed_mult   : mult_function_type := "0110";
58
   constant mult_divide        : mult_function_type := "0111";
59
   constant mult_signed_divide : mult_function_type := "1000";
60 39 rhoads
 
61
--   type a_source_type is (from_reg_source, from_imm10_6);
62
   subtype a_source_type is std_logic_vector(1 downto 0);
63
   constant a_from_reg_source : a_source_type := "00";
64
   constant a_from_imm10_6    : a_source_type := "01";
65
   constant a_from_pc         : a_source_type := "10";
66
 
67
--   type b_source_type is (from_reg_target, from_imm, from_signed_imm);
68
   subtype b_source_type is std_logic_vector(1 downto 0);
69
   constant b_from_reg_target : b_source_type := "00";
70
   constant b_from_imm        : b_source_type := "01";
71
   constant b_from_signed_imm : b_source_type := "10";
72
   constant b_from_immX4      : b_source_type := "11";
73
 
74
--   type c_source_type is (from_null, from_alu, from_shift, 
75
--      from_mult, from_memory, from_pc, from_imm_shift16,
76
--      from_reg_source_nez, from_reg_source_eqz);
77
   subtype c_source_type is std_logic_vector(2 downto 0);
78
   constant c_from_null       : c_source_type := "000";
79
   constant c_from_alu        : c_source_type := "001";
80
   constant c_from_shift      : c_source_type := "001"; --same as alu
81
   constant c_from_mult       : c_source_type := "001"; --same as alu
82
   constant c_from_memory     : c_source_type := "010";
83
   constant c_from_pc         : c_source_type := "011";
84
   constant c_from_pc_plus4   : c_source_type := "100";
85
   constant c_from_imm_shift16: c_source_type := "101";
86
   constant c_from_reg_sourcen: c_source_type := "110";
87
 
88
--   type pc_source_type is (from_inc4, from_inc8, from_reg_source, 
89
--      from_opcode25_0, from_branch, from_lbranch);
90
   subtype pc_source_type is std_logic_vector(1 downto 0);
91
   constant from_inc4       : pc_source_type := "00";
92
   constant from_opcode25_0 : pc_source_type := "01";
93
   constant from_branch     : pc_source_type := "10";
94
   constant from_lbranch    : pc_source_type := "11";
95
 
96
   subtype branch_function_type is std_logic_vector(2 downto 0);
97
   constant branch_ltz : branch_function_type := "000";
98
   constant branch_lez : branch_function_type := "001";
99
   constant branch_eq  : branch_function_type := "010";
100
   constant branch_ne  : branch_function_type := "011";
101
   constant branch_gez : branch_function_type := "100";
102
   constant branch_gtz : branch_function_type := "101";
103
   constant branch_yes : branch_function_type := "110";
104
 
105
   -- mode(32=1,16=2,8=3), signed, write
106
   subtype mem_source_type is std_logic_vector(3 downto 0);
107 62 rhoads
   constant mem_fetch   : mem_source_type := "0000";
108 39 rhoads
   constant mem_read32  : mem_source_type := "0100";
109
   constant mem_write32 : mem_source_type := "0101";
110
   constant mem_read16  : mem_source_type := "1000";
111
   constant mem_read16s : mem_source_type := "1010";
112
   constant mem_write16 : mem_source_type := "1001";
113
   constant mem_read8   : mem_source_type := "1100";
114
   constant mem_read8s  : mem_source_type := "1110";
115
   constant mem_write8  : mem_source_type := "1101";
116
 
117
   function bv_to_integer(bv: in std_logic_vector) return integer;
118
   function bv_adder(a     : in std_logic_vector(32 downto 0);
119
                     b     : in std_logic_vector(32 downto 0);
120 47 rhoads
                     do_add: in std_logic) return std_logic_vector;
121 39 rhoads
   function bv_adder_lookahead(
122
                     a     : in std_logic_vector(32 downto 0);
123
                     b     : in std_logic_vector(32 downto 0);
124 47 rhoads
                     do_add: in std_logic) return std_logic_vector;
125 39 rhoads
   function bv_negate(a : in std_logic_vector) return std_logic_vector;
126
   function bv_increment(a : in std_logic_vector(31 downto 2)
127
                     ) return std_logic_vector;
128
   function bv_inc6(a : in std_logic_vector
129
                     ) return std_logic_vector;
130 47 rhoads
 
131
   -- For Altera
132
   COMPONENT lpm_add_sub
133
      GENERIC (
134 91 rhoads
         lpm_width     : NATURAL;
135
         lpm_direction : STRING := "UNUSED";
136
         lpm_type      : STRING;
137
         lpm_hint      : STRING);
138 47 rhoads
      PORT (
139 91 rhoads
         dataa   : IN STD_LOGIC_VECTOR (lpm_width-1 DOWNTO 0);
140
         add_sub : IN STD_LOGIC ;
141
         datab   : IN STD_LOGIC_VECTOR (lpm_width-1 DOWNTO 0);
142
         result  : OUT STD_LOGIC_VECTOR (lpm_width-1 DOWNTO 0));
143 47 rhoads
   END COMPONENT;
144
 
145
   -- For Altera
146
   COMPONENT lpm_ram_dp
147
      GENERIC (
148
         lpm_width        : NATURAL;
149
         lpm_widthad      : NATURAL;
150
         rden_used        : STRING;
151
         intended_device_family : STRING;
152
         lpm_indata       : STRING;
153
         lpm_wraddress_control          : STRING;
154
         lpm_rdaddress_control          : STRING;
155
         lpm_outdata      : STRING;
156
         use_eab          : STRING;
157
         lpm_type         : STRING);
158
      PORT (
159 91 rhoads
         wren      : IN STD_LOGIC ;
160 47 rhoads
         wrclock   : IN STD_LOGIC ;
161 91 rhoads
         q         : OUT STD_LOGIC_VECTOR (lpm_width-1 DOWNTO 0);
162
         data      : IN STD_LOGIC_VECTOR (lpm_width-1 DOWNTO 0);
163
         rdaddress : IN STD_LOGIC_VECTOR (lpm_widthad-1 DOWNTO 0);
164
         wraddress : IN STD_LOGIC_VECTOR (lpm_widthad-1 DOWNTO 0));
165 47 rhoads
   END COMPONENT;
166
 
167
   -- For Altera
168 62 rhoads
   component LPM_RAM_DQ
169
      generic (
170 91 rhoads
         LPM_WIDTH    : natural;    -- MUST be greater than 0
171
         LPM_WIDTHAD  : natural;    -- MUST be greater than 0
172 62 rhoads
         LPM_NUMWORDS : natural := 0;
173 91 rhoads
         LPM_INDATA   : string := "REGISTERED";
174 62 rhoads
         LPM_ADDRESS_CONTROL: string := "REGISTERED";
175 91 rhoads
         LPM_OUTDATA  : string := "REGISTERED";
176
         LPM_FILE     : string := "UNUSED";
177
         LPM_TYPE     : string := "LPM_RAM_DQ";
178
         USE_EAB      : string := "OFF";
179 62 rhoads
         INTENDED_DEVICE_FAMILY  : string := "UNUSED";
180 91 rhoads
         LPM_HINT     : string := "UNUSED");
181 62 rhoads
                port (
182
         DATA     : in std_logic_vector(LPM_WIDTH-1 downto 0);
183
         ADDRESS  : in std_logic_vector(LPM_WIDTHAD-1 downto 0);
184
         INCLOCK  : in std_logic := '0';
185
         OUTCLOCK : in std_logic := '0';
186
         WE       : in std_logic;
187
         Q        : out std_logic_vector(LPM_WIDTH-1 downto 0));
188
   end component;
189 47 rhoads
 
190
   -- For Xilinx
191
   component ramb4_s16_s16
192
      port (
193
         clka  : in std_logic;
194
         rsta  : in std_logic;
195
         addra : in std_logic_vector;
196
         dia   : in std_logic_vector;
197
         ena   : in std_logic;
198
         wea   : in std_logic;
199
         doa   : out std_logic_vector;
200
 
201
         clkb  : in std_logic;
202
         rstb  : in std_logic;
203
         addrb : in std_logic_vector;
204
         dib   : in std_logic_vector;
205
         enb   : in std_logic;
206
         web   : in std_logic);
207
   end component;
208
 
209
   component pc_next
210
      port(clk          : in std_logic;
211
           reset_in     : in std_logic;
212
           pc_new       : in std_logic_vector(31 downto 2);
213
           take_branch  : in std_logic;
214
           pause_in     : in std_logic;
215
           opcode25_0   : in std_logic_vector(25 downto 0);
216
           pc_source    : in pc_source_type;
217
           pc_out       : out std_logic_vector(31 downto 0);
218
           pc_out_plus4 : out std_logic_vector(31 downto 0));
219
   end component;
220
 
221
   component mem_ctrl
222 70 rhoads
      generic(ACCURATE_TIMING : boolean := false);
223 47 rhoads
      port(clk          : in std_logic;
224
           reset_in     : in std_logic;
225
           pause_in     : in std_logic;
226
           nullify_op   : in std_logic;
227
           address_pc   : in std_logic_vector(31 downto 0);
228
           opcode_out   : out std_logic_vector(31 downto 0);
229
 
230
           address_data : in std_logic_vector(31 downto 0);
231
           mem_source   : in mem_source_type;
232
           data_write   : in std_logic_vector(31 downto 0);
233
           data_read    : out std_logic_vector(31 downto 0);
234
           pause_out    : out std_logic;
235
 
236
           mem_address  : out std_logic_vector(31 downto 0);
237
           mem_data_w   : out std_logic_vector(31 downto 0);
238
           mem_data_r   : in std_logic_vector(31 downto 0);
239
           mem_byte_sel : out std_logic_vector(3 downto 0);
240 70 rhoads
           mem_write    : out std_logic);
241 47 rhoads
   end component;
242
 
243
   component control
244
      port(opcode       : in  std_logic_vector(31 downto 0);
245
           intr_signal  : in  std_logic;
246
           rs_index     : out std_logic_vector(5 downto 0);
247
           rt_index     : out std_logic_vector(5 downto 0);
248
           rd_index     : out std_logic_vector(5 downto 0);
249
           imm_out      : out std_logic_vector(15 downto 0);
250
           alu_func     : out alu_function_type;
251
           shift_func   : out shift_function_type;
252
           mult_func    : out mult_function_type;
253
           branch_func  : out branch_function_type;
254
           a_source_out : out a_source_type;
255
           b_source_out : out b_source_type;
256
           c_source_out : out c_source_type;
257
           pc_source_out: out pc_source_type;
258
           mem_source_out:out mem_source_type);
259
   end component;
260
 
261
   component reg_bank
262
      generic(memory_type : string := "TRI_PORT");
263
      port(clk            : in  std_logic;
264
           reset_in       : in  std_logic;
265 70 rhoads
           pause          : in  std_logic;
266 47 rhoads
           rs_index       : in  std_logic_vector(5 downto 0);
267
           rt_index       : in  std_logic_vector(5 downto 0);
268
           rd_index       : in  std_logic_vector(5 downto 0);
269
           reg_source_out : out std_logic_vector(31 downto 0);
270
           reg_target_out : out std_logic_vector(31 downto 0);
271
           reg_dest_new   : in  std_logic_vector(31 downto 0);
272
           intr_enable    : out std_logic);
273
   end component;
274
 
275
   component bus_mux
276
      port(imm_in       : in  std_logic_vector(15 downto 0);
277
           reg_source   : in  std_logic_vector(31 downto 0);
278
           a_mux        : in  a_source_type;
279
           a_out        : out std_logic_vector(31 downto 0);
280
 
281
           reg_target   : in  std_logic_vector(31 downto 0);
282
           b_mux        : in  b_source_type;
283
           b_out        : out std_logic_vector(31 downto 0);
284
 
285
           c_bus        : in  std_logic_vector(31 downto 0);
286
           c_memory     : in  std_logic_vector(31 downto 0);
287
           c_pc         : in  std_logic_vector(31 downto 0);
288
           c_pc_plus4   : in  std_logic_vector(31 downto 0);
289
           c_mux        : in  c_source_type;
290
           reg_dest_out : out std_logic_vector(31 downto 0);
291
 
292
           branch_func  : in  branch_function_type;
293
           take_branch  : out std_logic);
294
   end component;
295
 
296
   component alu
297
      generic(adder_type : string := "GENERIC");
298
      port(a_in         : in  std_logic_vector(31 downto 0);
299
           b_in         : in  std_logic_vector(31 downto 0);
300
           alu_function : in  alu_function_type;
301
           c_alu        : out std_logic_vector(31 downto 0));
302
   end component;
303
 
304
   component shifter
305
      port(value        : in  std_logic_vector(31 downto 0);
306
           shift_amount : in  std_logic_vector(4 downto 0);
307
           shift_func   : in  shift_function_type;
308
           c_shift      : out std_logic_vector(31 downto 0));
309
   end component;
310
 
311
   component mult
312
      generic(adder_type : string := "GENERIC");
313
      port(clk       : in std_logic;
314
           a, b      : in std_logic_vector(31 downto 0);
315
           mult_func : in mult_function_type;
316
           c_mult    : out std_logic_vector(31 downto 0);
317
           pause_out : out std_logic);
318
   end component;
319
 
320 70 rhoads
   component pipeline
321
      port(clk            : in  std_logic;
322
           reset          : in  std_logic;
323
           a_bus          : in  std_logic_vector(31 downto 0);
324
           a_busD         : out std_logic_vector(31 downto 0);
325
           b_bus          : in  std_logic_vector(31 downto 0);
326
           b_busD         : out std_logic_vector(31 downto 0);
327
           alu_func       : in  alu_function_type;
328
           alu_funcD      : out alu_function_type;
329
           shift_func     : in  shift_function_type;
330
           shift_funcD    : out shift_function_type;
331
           mult_func      : in  mult_function_type;
332
           mult_funcD     : out mult_function_type;
333
           reg_dest       : in  std_logic_vector(31 downto 0);
334
           reg_destD      : out std_logic_vector(31 downto 0);
335
           rd_index       : in  std_logic_vector(5 downto 0);
336
           rd_indexD      : out std_logic_vector(5 downto 0);
337
 
338
           rs_index       : in  std_logic_vector(5 downto 0);
339
           rt_index       : in  std_logic_vector(5 downto 0);
340
           pc_source      : in  pc_source_type;
341
           mem_source     : in  mem_source_type;
342
           a_source       : in  a_source_type;
343
           b_source       : in  b_source_type;
344
           c_source       : in  c_source_type;
345
           c_bus          : in  std_logic_vector(31 downto 0);
346
           pause_any      : in  std_logic;
347
           pause_pipeline : out std_logic);
348
   end component;
349
 
350 47 rhoads
   component mlite_cpu
351 91 rhoads
      generic(memory_type     : string := "ALTERA";
352 70 rhoads
              pipeline_stages : natural := 3);
353 47 rhoads
      port(clk         : in std_logic;
354
           reset_in    : in std_logic;
355
           intr_in     : in std_logic;
356
 
357
           mem_address : out std_logic_vector(31 downto 0);
358
           mem_data_w  : out std_logic_vector(31 downto 0);
359
           mem_data_r  : in std_logic_vector(31 downto 0);
360
           mem_byte_sel: out std_logic_vector(3 downto 0);
361
           mem_write   : out std_logic;
362
           mem_pause   : in std_logic);
363
   end component;
364
 
365 50 rhoads
   component ram
366
      generic(memory_type : string := "GENERIC");
367 47 rhoads
      port(clk          : in std_logic;
368
           mem_byte_sel : in std_logic_vector(3 downto 0);
369
           mem_write    : in std_logic;
370 50 rhoads
           mem_address  : in std_logic_vector(31 downto 0);
371 62 rhoads
           mem_data_w   : in std_logic_vector(31 downto 0);
372
           mem_data_r   : out std_logic_vector(31 downto 0));
373 47 rhoads
   end component; --ram
374
 
375
   component uart
376 50 rhoads
      generic(log_file : string := "UNUSED");
377
      port(clk        : in std_logic;
378
           reset      : in std_logic;
379
           uart_sel   : in std_logic;
380
           data       : in std_logic_vector(7 downto 0);
381
           uart_read  : in std_logic;
382
           uart_write : out std_logic;
383
           pause      : out std_logic);
384 47 rhoads
   end component; --uart
385
 
386 50 rhoads
   component plasma
387
      generic(memory_type : string := "GENERIC";
388
              log_file    : string := "UNUSED");
389
      port(clk_in           : in std_logic;
390
           reset_in         : in std_logic;
391
           intr_in          : in std_logic;
392
 
393
           uart_read        : in std_logic;
394
           uart_write       : out std_logic;
395
 
396
           mem_address_out  : out std_logic_vector(31 downto 0);
397 62 rhoads
           mem_data         : out std_logic_vector(31 downto 0);
398 50 rhoads
           mem_byte_sel_out : out std_logic_vector(3 downto 0);
399
           mem_write_out    : out std_logic;
400
           mem_pause_in     : in std_logic);
401
   end component; --plasma
402
 
403 62 rhoads
   component plasma_if
404
      generic(memory_type : string := "ALTERA";
405
              log_file    : string := "UNUSED");
406
      port(clk_in     : in std_logic;
407
           reset_n    : in std_logic;
408
           uart_read  : in std_logic;
409
           uart_write : out std_logic;
410
 
411
           address    : out std_logic_vector(31 downto 0);
412
           data       : out std_logic_vector(31 downto 0);
413
           we_n       : out std_logic;
414
           oe_n       : out std_logic;
415
           be_n       : out std_logic_vector(3 downto 0);
416
           sram0_cs_n : out std_logic;
417
           sram1_cs_n : out std_logic);
418
   end component; --plasma_if
419
 
420 39 rhoads
end; --package mlite_pack
421
 
422
package body mlite_pack is
423
 
424
function bv_to_integer(bv: in std_logic_vector) return integer is
425
   variable result : integer;
426
   variable b      : integer;
427
begin
428
   result := 0;
429
   b := 0;
430
   for index in bv'range loop
431
      if bv(index) = '1' then
432
         b := 1;
433
      else
434
         b := 0;
435
      end if;
436
      result := result * 2 + b;
437
   end loop;
438
   return result;
439
end; --function bv_to_integer
440
 
441 91 rhoads
 
442 39 rhoads
function bv_adder(a     : in std_logic_vector(32 downto 0);
443
                  b     : in std_logic_vector(32 downto 0);
444 47 rhoads
                  do_add: in std_logic) return std_logic_vector is
445 39 rhoads
   variable carry_in : std_logic;
446
   variable bb       : std_logic_vector(32 downto 0);
447
   variable result   : std_logic_vector(32 downto 0);
448
begin
449 47 rhoads
   result := '0' & ZERO;
450
   if do_add = '1' then
451 39 rhoads
      bb := b;
452
      carry_in := '0';
453
   else
454
      bb := not b;
455
      carry_in := '1';
456
   end if;
457
   for index in 0 to 32 loop
458
      result(index) := a(index) xor bb(index) xor carry_in;
459
      carry_in := (carry_in and (a(index) or bb(index))) or
460
                  (a(index) and bb(index));
461
   end loop;
462
   return result;
463
end; --function
464
 
465 91 rhoads
 
466 39 rhoads
function bv_adder_lookahead(
467
                  a     : in std_logic_vector(32 downto 0);
468
                  b     : in std_logic_vector(32 downto 0);
469 47 rhoads
                  do_add: in std_logic) return std_logic_vector is
470 39 rhoads
   variable carry    : std_logic_vector(32 downto 0);
471
   variable p, g     : std_logic_vector(32 downto 0);
472
   variable bb       : std_logic_vector(32 downto 0);
473
   variable result   : std_logic_vector(32 downto 0);
474
   variable i        : natural;
475
begin
476 47 rhoads
   carry := '0' & ZERO;
477
   if do_add = '1' then
478 39 rhoads
      bb := b;
479
      carry(0) := '0';
480
   else
481
      bb := not b;
482
      carry(0) := '1';
483
   end if;
484
 
485
   p := a or bb;   --propogate
486
   g := a and bb;  --generate
487
   for index in 0 to 7 loop
488
      i := index*4;
489
      carry(i+1) := g(i) or
490
                    (p(i) and carry(i));
491
      i := index*4+1;
492
      carry(i+1) := g(i) or
493
                    (p(i) and g(i-1)) or
494
                    ((p(i) and p(i-1)) and carry(i-1));
495
      i := index*4+2;
496
      carry(i+1) := g(i) or
497
                    (p(i) and g(i-1)) or
498
                    (p(i) and p(i-1) and g(i-2)) or
499
                    ((p(i) and p(i-1) and p(i-2)) and carry(i-2));
500
      i := index*4+3;
501
      carry(i+1) := g(i) or
502
                    (p(i) and g(i-1)) or
503
                    (p(i) and p(i-1) and g(i-2)) or
504
                    (p(i) and p(i-1) and p(i-2) and g(i-3)) or
505
                    (((p(i) and p(i-1)) and (p(i-2) and p(i-3)))
506
                       and carry(i-3));
507
   end loop;
508
   result := (a xor bb) xor carry;
509
   return result;
510
end; --function
511
 
512 91 rhoads
 
513 39 rhoads
function bv_negate(a : in std_logic_vector) return std_logic_vector is
514
   variable carry_in : std_logic;
515
   variable not_a    : std_logic_vector(31 downto 0);
516
   variable result   : std_logic_vector(31 downto 0);
517
begin
518
   result := ZERO;
519
   not_a := not a;
520
   carry_in := '1';
521
   for index in a'reverse_range loop
522
      result(index) := not_a(index) xor carry_in;
523
      carry_in := carry_in and not_a(index);
524
   end loop;
525
   return result;
526
end; --function
527
 
528 91 rhoads
 
529 39 rhoads
function bv_increment(a : in std_logic_vector(31 downto 2)
530
                     ) return std_logic_vector is
531
   variable carry_in : std_logic;
532
   variable result   : std_logic_vector(31 downto 2);
533
begin
534 47 rhoads
   result := ZERO(31 downto 2);
535 39 rhoads
   carry_in := '1';
536
   for index in 2 to 31 loop
537
      result(index) := a(index) xor carry_in;
538
      carry_in := a(index) and carry_in;
539
   end loop;
540
   return result;
541
end; --function
542
 
543 91 rhoads
 
544 39 rhoads
function bv_inc6(a : in std_logic_vector
545
                     ) return std_logic_vector is
546
   variable carry_in : std_logic;
547
   variable result   : std_logic_vector(5 downto 0);
548
begin
549
   result := "000000";
550
   carry_in := '1';
551
   for index in 0 to 5 loop
552
      result(index) := a(index) xor carry_in;
553
      carry_in := a(index) and carry_in;
554
   end loop;
555
   return result;
556
end; --function
557
 
558
end; --package body
559
 
560
 

powered by: WebSVN 2.1.0

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