P
Panic
Guest
I have an array that is supposed to act as a ROM-
lookup-table (actually a Rijndael G-box), and so I
want to give it a byte input and get a byte output.
The byte input, let's call it ADDR, is std_logic_vector(7 downto 0).
Sinse the indices of my "ROM"-array are integers, I need to convert
the ADDR vector to type integer. My "ROM"-array has 256 elements,
and the lookup should work something like this:
sub_byte <= ROM( 16*to_integer(ADDR(7 downto 4)) + to_integer(ADDR(3 downto
0)));
My problem is, no matter how I try, I can't get to_integer to work. I've
tried looking
at the FAQ, and I have search the net, and I have tried what has been
suggested, but
I can't seem to get it to work. So I need your help to convert ADDR from
being
a std_logic_vector(7 downto 0) into an integer.
Here is (part of) my code:
subbyte <= g_rom(addr) after lookup_delay;
type srd_array is array (0 to 255) of std_logic_vector(7 downto 0);
constant g_rom : srd_array := (
x"00",x"01",x"8D",x"F6",x"CB",x"52",x"7B",x"D1",x"E8",x"4F",x"29",x"C0",x"B0
",x"E1",x"E5",x"C7",
x"74",x"B4",x"AA",x"4B",x"99",x"2B",x"60",x"5F",x"58",x"3F",x"FD",x"CC",x"FF
",x"40",x"EE",x"B2",
x"3A",x"6E",x"5A",x"F1",x"55",x"4D",x"A8",x"C9",x"C1",x"0A",x"98",x"15",x"30
",x"44",x"A2",x"C2",
x"2C",x"45",x"92",x"6C",x"F3",x"39",x"66",x"42",x"F2",x"35",x"20",x"6F",x"77
",x"BB",x"59",x"19",
x"1D",x"FE",x"37",x"67",x"2D",x"31",x"F5",x"69",x"A7",x"64",x"AB",x"13",x"54
",x"25",x"E9",x"09",
x"ED",x"5C",x"05",x"CA",x"4C",x"24",x"87",x"BF",x"18",x"3E",x"22",x"F0",x"51
",x"EC",x"61",x"17",
x"16",x"5E",x"AF",x"D3",x"49",x"A6",x"36",x"43",x"F4",x"47",x"91",x"DF",x"33
",x"93",x"21",x"3B",
x"79",x"B7",x"97",x"85",x"10",x"B5",x"BA",x"3C",x"B6",x"70",x"D0",x"06",x"A1
",x"FA",x"81",x"82",
x"83",x"7E",x"7F",x"80",x"96",x"73",x"BE",x"56",x"9B",x"9E",x"95",x"D9",x"F7
",x"02",x"B9",x"A4",
x"DE",x"6A",x"32",x"6D",x"D8",x"8A",x"84",x"72",x"2A",x"14",x"9F",x"88",x"F9
",x"DC",x"89",x"9A",
x"FB",x"7C",x"2E",x"C3",x"8F",x"B8",x"65",x"48",x"26",x"C8",x"12",x"4A",x"CE
",x"E7",x"D2",x"62",
x"0C",x"E0",x"1F",x"EF",x"11",x"75",x"78",x"71",x"A5",x"8E",x"76",x"3D",x"BD
",x"BC",x"86",x"57",
x"0B",x"28",x"2F",x"A3",x"DA",x"D4",x"E4",x"0F",x"A9",x"27",x"53",x"04",x"1B
",x"FC",x"AC",x"E6",
x"7A",x"07",x"AE",x"63",x"C5",x"DB",x"E2",x"EA",x"94",x"8B",x"C4",x"D5",x"9D
",x"F8",x"90",x"6B",
x"B1",x"0D",x"D6",x"EB",x"C6",x"0E",x"CF",x"AD",x"08",x"4E",x"D7",x"E3",x"5D
",x"50",x"1E",x"B3",
x"5B",x"23",x"38",x"34",x"68",x"46",x"03",x"8C",x"DD",x"9C",x"7D",x"A0",x"CD
",x"1A",x"41",x"1C"
);
lookup-table (actually a Rijndael G-box), and so I
want to give it a byte input and get a byte output.
The byte input, let's call it ADDR, is std_logic_vector(7 downto 0).
Sinse the indices of my "ROM"-array are integers, I need to convert
the ADDR vector to type integer. My "ROM"-array has 256 elements,
and the lookup should work something like this:
sub_byte <= ROM( 16*to_integer(ADDR(7 downto 4)) + to_integer(ADDR(3 downto
0)));
My problem is, no matter how I try, I can't get to_integer to work. I've
tried looking
at the FAQ, and I have search the net, and I have tried what has been
suggested, but
I can't seem to get it to work. So I need your help to convert ADDR from
being
a std_logic_vector(7 downto 0) into an integer.
Here is (part of) my code:
subbyte <= g_rom(addr) after lookup_delay;
type srd_array is array (0 to 255) of std_logic_vector(7 downto 0);
constant g_rom : srd_array := (
x"00",x"01",x"8D",x"F6",x"CB",x"52",x"7B",x"D1",x"E8",x"4F",x"29",x"C0",x"B0
",x"E1",x"E5",x"C7",
x"74",x"B4",x"AA",x"4B",x"99",x"2B",x"60",x"5F",x"58",x"3F",x"FD",x"CC",x"FF
",x"40",x"EE",x"B2",
x"3A",x"6E",x"5A",x"F1",x"55",x"4D",x"A8",x"C9",x"C1",x"0A",x"98",x"15",x"30
",x"44",x"A2",x"C2",
x"2C",x"45",x"92",x"6C",x"F3",x"39",x"66",x"42",x"F2",x"35",x"20",x"6F",x"77
",x"BB",x"59",x"19",
x"1D",x"FE",x"37",x"67",x"2D",x"31",x"F5",x"69",x"A7",x"64",x"AB",x"13",x"54
",x"25",x"E9",x"09",
x"ED",x"5C",x"05",x"CA",x"4C",x"24",x"87",x"BF",x"18",x"3E",x"22",x"F0",x"51
",x"EC",x"61",x"17",
x"16",x"5E",x"AF",x"D3",x"49",x"A6",x"36",x"43",x"F4",x"47",x"91",x"DF",x"33
",x"93",x"21",x"3B",
x"79",x"B7",x"97",x"85",x"10",x"B5",x"BA",x"3C",x"B6",x"70",x"D0",x"06",x"A1
",x"FA",x"81",x"82",
x"83",x"7E",x"7F",x"80",x"96",x"73",x"BE",x"56",x"9B",x"9E",x"95",x"D9",x"F7
",x"02",x"B9",x"A4",
x"DE",x"6A",x"32",x"6D",x"D8",x"8A",x"84",x"72",x"2A",x"14",x"9F",x"88",x"F9
",x"DC",x"89",x"9A",
x"FB",x"7C",x"2E",x"C3",x"8F",x"B8",x"65",x"48",x"26",x"C8",x"12",x"4A",x"CE
",x"E7",x"D2",x"62",
x"0C",x"E0",x"1F",x"EF",x"11",x"75",x"78",x"71",x"A5",x"8E",x"76",x"3D",x"BD
",x"BC",x"86",x"57",
x"0B",x"28",x"2F",x"A3",x"DA",x"D4",x"E4",x"0F",x"A9",x"27",x"53",x"04",x"1B
",x"FC",x"AC",x"E6",
x"7A",x"07",x"AE",x"63",x"C5",x"DB",x"E2",x"EA",x"94",x"8B",x"C4",x"D5",x"9D
",x"F8",x"90",x"6B",
x"B1",x"0D",x"D6",x"EB",x"C6",x"0E",x"CF",x"AD",x"08",x"4E",x"D7",x"E3",x"5D
",x"50",x"1E",x"B3",
x"5B",x"23",x"38",x"34",x"68",x"46",x"03",x"8C",x"DD",x"9C",x"7D",x"A0",x"CD
",x"1A",x"41",x"1C"
);