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

Subversion Repositories mlite

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

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
 
352
      port(clk            : in std_logic;
353
           reset          : in std_logic;
354
           address_next   : in std_logic_vector(31 downto 2);
355
           byte_we_next   : in std_logic_vector(3 downto 0);
356
           cpu_address    : in std_logic_vector(31 downto 2);
357
           mem_busy       : in std_logic;
358
 
359
           cache_check    : out std_logic;   --Stage1: address_next in first 2MB DDR
360
           cache_checking : out std_logic;   --Stage2: cache checking
361
           cache_miss     : out std_logic);  --Stage2-3: cache miss
362
   end component; --cache
363
 
364 50 rhoads
   component ram
365 132 rhoads
      generic(memory_type : string := "DEFAULT");
366 139 rhoads
      port(clk               : in std_logic;
367
           enable            : in std_logic;
368
           write_byte_enable : in std_logic_vector(3 downto 0);
369
           address           : in std_logic_vector(31 downto 2);
370
           data_write        : in std_logic_vector(31 downto 0);
371
           data_read         : out std_logic_vector(31 downto 0));
372 47 rhoads
   end component; --ram
373 264 rhoads
 
374 47 rhoads
   component uart
375 50 rhoads
      generic(log_file : string := "UNUSED");
376 139 rhoads
      port(clk          : in std_logic;
377
           reset        : in std_logic;
378
           enable_read  : in std_logic;
379
           enable_write : in std_logic;
380
           data_in      : in std_logic_vector(7 downto 0);
381
           data_out     : out std_logic_vector(7 downto 0);
382
           uart_read    : in std_logic;
383
           uart_write   : out std_logic;
384
           busy_write   : out std_logic;
385
           data_avail   : out std_logic);
386 47 rhoads
   end component; --uart
387
 
388 285 rhoads
   component eth_dma
389
      port(clk         : in std_logic;                      --25 MHz
390
           reset       : in std_logic;
391
           enable_eth  : in std_logic;
392
           select_eth  : in std_logic;
393
           rec_isr     : out std_logic;
394
           send_isr    : out std_logic;
395
 
396
           address     : out std_logic_vector(31 downto 2); --to DDR
397
           byte_we     : out std_logic_vector(3 downto 0);
398
           data_write  : out std_logic_vector(31 downto 0);
399
           data_read   : in std_logic_vector(31 downto 0);
400
           pause_in    : in std_logic;
401
 
402
           mem_address : in std_logic_vector(31 downto 2);  --from CPU
403
           mem_byte_we : in std_logic_vector(3 downto 0);
404
           data_w      : in std_logic_vector(31 downto 0);
405
           pause_out   : out std_logic;
406
 
407
           E_RX_CLK    : in std_logic;                      --2.5 MHz receive
408
           E_RX_DV     : in std_logic;                      --data valid
409
           E_RXD       : in std_logic_vector(3 downto 0);   --receive nibble
410
           E_TX_CLK    : in std_logic;                      --2.5 MHz transmit
411
           E_TX_EN     : out std_logic;                     --transmit enable
412
           E_TXD       : out std_logic_vector(3 downto 0)); --transmit nibble
413
   end component; --eth_dma
414
 
415 50 rhoads
   component plasma
416 139 rhoads
      generic(memory_type : string := "XILINX_X16"; --"DUAL_PORT_" "ALTERA_LPM";
417 285 rhoads
              log_file    : string := "UNUSED";
418 346 rhoads
              ethernet    : std_logic := '0';
419
              use_cache   : std_logic := '0');
420
      port(clk          : in std_logic;
421
           reset        : in std_logic;
422
           uart_write   : out std_logic;
423
           uart_read    : in std_logic;
424 139 rhoads
 
425 346 rhoads
           address      : out std_logic_vector(31 downto 2);
426
           byte_we      : out std_logic_vector(3 downto 0);
427
           data_write   : out std_logic_vector(31 downto 0);
428
           data_read    : in std_logic_vector(31 downto 0);
429
           mem_pause_in : in std_logic;
430
           no_ddr_start : out std_logic;
431
           no_ddr_stop  : out std_logic;
432 139 rhoads
 
433 346 rhoads
           gpio0_out    : out std_logic_vector(31 downto 0);
434
           gpioA_in     : in std_logic_vector(31 downto 0));
435 50 rhoads
   end component; --plasma
436
 
437 285 rhoads
   component ddr_ctrl
438
      port(clk      : in std_logic;
439
           clk_2x   : in std_logic;
440
           reset_in : in std_logic;
441
 
442
           address  : in std_logic_vector(25 downto 2);
443
           byte_we  : in std_logic_vector(3 downto 0);
444
           data_w   : in std_logic_vector(31 downto 0);
445
           data_r   : out std_logic_vector(31 downto 0);
446
           active   : in std_logic;
447 346 rhoads
           no_start : in std_logic;
448
           no_stop  : in std_logic;
449 285 rhoads
           pause    : out std_logic;
450
 
451
           SD_CK_P  : out std_logic;     --clock_positive
452
           SD_CK_N  : out std_logic;     --clock_negative
453
           SD_CKE   : out std_logic;     --clock_enable
454
 
455
           SD_BA    : out std_logic_vector(1 downto 0);  --bank_address
456
           SD_A     : out std_logic_vector(12 downto 0); --address(row or col)
457
           SD_CS    : out std_logic;     --chip_select
458
           SD_RAS   : out std_logic;     --row_address_strobe
459
           SD_CAS   : out std_logic;     --column_address_strobe
460
           SD_WE    : out std_logic;     --write_enable
461
 
462
           SD_DQ    : inout std_logic_vector(15 downto 0); --data
463
           SD_UDM   : out std_logic;     --upper_byte_enable
464
           SD_UDQS  : inout std_logic;   --upper_data_strobe
465
           SD_LDM   : out std_logic;     --low_byte_enable
466
           SD_LDQS  : inout std_logic);  --low_data_strobe
467
   end component; --ddr
468
 
469 139 rhoads
end; --package mlite_pack
470 62 rhoads
 
471
 
472 39 rhoads
package body mlite_pack is
473
 
474 139 rhoads
function bv_adder(a     : in std_logic_vector;
475
                  b     : in std_logic_vector;
476 47 rhoads
                  do_add: in std_logic) return std_logic_vector is
477 39 rhoads
   variable carry_in : std_logic;
478 139 rhoads
   variable bb       : std_logic_vector(a'length-1 downto 0);
479
   variable result   : std_logic_vector(a'length downto 0);
480 39 rhoads
begin
481 47 rhoads
   if do_add = '1' then
482 39 rhoads
      bb := b;
483
      carry_in := '0';
484
   else
485
      bb := not b;
486
      carry_in := '1';
487
   end if;
488 139 rhoads
   for index in 0 to a'length-1 loop
489 39 rhoads
      result(index) := a(index) xor bb(index) xor carry_in;
490
      carry_in := (carry_in and (a(index) or bb(index))) or
491
                  (a(index) and bb(index));
492
   end loop;
493 139 rhoads
   result(a'length) := carry_in xnor do_add;
494 39 rhoads
   return result;
495
end; --function
496
 
497 91 rhoads
 
498 39 rhoads
function bv_negate(a : in std_logic_vector) return std_logic_vector is
499
   variable carry_in : std_logic;
500 139 rhoads
   variable not_a    : std_logic_vector(a'length-1 downto 0);
501
   variable result   : std_logic_vector(a'length-1 downto 0);
502 39 rhoads
begin
503
   not_a := not a;
504
   carry_in := '1';
505
   for index in a'reverse_range loop
506
      result(index) := not_a(index) xor carry_in;
507
      carry_in := carry_in and not_a(index);
508
   end loop;
509
   return result;
510
end; --function
511
 
512 91 rhoads
 
513 39 rhoads
function bv_increment(a : in std_logic_vector(31 downto 2)
514
                     ) return std_logic_vector is
515
   variable carry_in : std_logic;
516
   variable result   : std_logic_vector(31 downto 2);
517
begin
518
   carry_in := '1';
519
   for index in 2 to 31 loop
520
      result(index) := a(index) xor carry_in;
521
      carry_in := a(index) and carry_in;
522
   end loop;
523
   return result;
524
end; --function
525
 
526 91 rhoads
 
527 139 rhoads
function bv_inc(a : in std_logic_vector
528
                ) return std_logic_vector is
529 39 rhoads
   variable carry_in : std_logic;
530 139 rhoads
   variable result   : std_logic_vector(a'length-1 downto 0);
531 39 rhoads
begin
532
   carry_in := '1';
533 139 rhoads
   for index in 0 to a'length-1 loop
534 39 rhoads
      result(index) := a(index) xor carry_in;
535
      carry_in := a(index) and carry_in;
536
   end loop;
537
   return result;
538
end; --function
539
 
540
end; --package body
541
 
542
 

powered by: WebSVN 2.1.0

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