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

Subversion Repositories core_arm

[/] [core_arm/] [trunk/] [vhdl/] [libs/] [memdef.vhd] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 tarookumic
-- $(lic)
2
-- $(help_generic)
3
-- $(help_local)
4
 
5
library ieee;
6
use ieee.std_logic_1164.all;
7
use work.amba.all;
8
 
9
-- PREFIX: lmd_xxx
10
package memdef is
11
 
12
-- memsizes
13
type lmd_memsize is (
14
  lmd_word,
15
  lmd_byte,
16
  lmd_half,
17
  lmd_dbl
18
);
19
 
20
-- lmd_big:    byte[0 1 2 3], hw[0 1]
21
-- lmd_little: byte[3 2 1 0], hw[1 0]
22
type lmd_byteorder is (lmd_big, lmd_little);
23
 
24
-- return amba size constant
25
function lmd_toamba (
26
  size : lmd_memsize
27
) return Std_Logic_Vector;
28
 
29
-- endianess converter
30
function lmd_convert (
31
  data : std_logic_vector(31 downto 0);
32
  intype : lmd_byteorder;
33
  outtype : lmd_byteorder
34
) return std_logic_vector;
35
 
36
end memdef;
37
 
38
package body memdef is
39
 
40
function lmd_toamba (
41
  size : lmd_memsize
42
) return Std_Logic_Vector is
43
 variable tmp : std_logic_vector(2 downto 0);
44
begin
45
  tmp := HSIZE_WORD;
46
  case size is
47
    when lmd_byte => tmp := HSIZE_BYTE;
48
    when lmd_half => tmp := HSIZE_HWORD;
49
    when lmd_word => tmp := HSIZE_WORD;
50
    when others => null;
51
  end case;
52
  return tmp;
53
end;
54
 
55
function lmd_convert (
56
  data : std_logic_vector(31 downto 0);
57
  intype : lmd_byteorder;
58
  outtype : lmd_byteorder
59
) return std_logic_vector is
60
variable tmp : std_logic_vector(31 downto 0);
61
begin
62
  tmp := data;
63
  if intype /= outtype then
64
    tmp := tmp(7 downto 0) & tmp(15 downto 8) & tmp(23 downto 16) & tmp(31 downto 24);
65
  end if;
66
  return tmp;
67
end;
68
 
69
end memdef;

powered by: WebSVN 2.1.0

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