2 use ieee.std_logic_1164.all;
3 use ieee.numeric_std.all;
6 use work.decode_types.all;
7 use work.ppc_fx_insns.all;
11 rs : in std_ulogic_vector(63 downto 0);
12 rb : in std_ulogic_vector(63 downto 0);
14 invert_in : in std_ulogic;
15 invert_out : in std_ulogic;
16 result : out std_ulogic_vector(63 downto 0);
17 datalen : in std_logic_vector(3 downto 0)
21 architecture behaviour of logical is
23 subtype twobit is unsigned(1 downto 0);
24 type twobit32 is array(0 to 31) of twobit;
25 signal pc2 : twobit32;
26 subtype threebit is unsigned(2 downto 0);
27 type threebit16 is array(0 to 15) of threebit;
28 signal pc4 : threebit16;
29 subtype fourbit is unsigned(3 downto 0);
30 type fourbit8 is array(0 to 7) of fourbit;
31 signal pc8 : fourbit8;
32 subtype sixbit is unsigned(5 downto 0);
33 type sixbit2 is array(0 to 1) of sixbit;
34 signal pc32 : sixbit2;
35 signal par0, par1 : std_ulogic;
36 signal popcnt : std_ulogic_vector(63 downto 0);
37 signal parity : std_ulogic_vector(63 downto 0);
40 logical_0: process(all)
41 variable rb_adj, tmp : std_ulogic_vector(63 downto 0);
42 variable negative : std_ulogic;
46 pc2(i) <= unsigned("0" & rs(i * 2 downto i * 2)) + unsigned("0" & rs(i * 2 + 1 downto i * 2 + 1));
49 pc4(i) <= ('0' & pc2(i * 2)) + ('0' & pc2(i * 2 + 1));
52 pc8(i) <= ('0' & pc4(i * 2)) + ('0' & pc4(i * 2 + 1));
55 pc32(i) <= ("00" & pc8(i * 4)) + ("00" & pc8(i * 4 + 1)) +
56 ("00" & pc8(i * 4 + 2)) + ("00" & pc8(i * 4 + 3));
58 popcnt <= (others => '0');
59 if datalen(3 downto 2) = "00" then
62 popcnt(i * 8 + 3 downto i * 8) <= std_ulogic_vector(pc8(i));
64 elsif datalen(3) = '0' then
67 popcnt(i * 32 + 5 downto i * 32) <= std_ulogic_vector(pc32(i));
70 popcnt(6 downto 0) <= std_ulogic_vector(('0' & pc32(0)) + ('0' & pc32(1)));
73 -- parity calculations
74 par0 <= rs(0) xor rs(8) xor rs(16) xor rs(24);
75 par1 <= rs(32) xor rs(40) xor rs(48) xor rs(56);
76 parity <= (others => '0');
77 if datalen(3) = '1' then
78 parity(0) <= par0 xor par1;
85 if invert_in = '1' then
101 tmp := ppc_cmpb(rs, rb);
104 -- note datalen is a 1-hot encoding
105 negative := (datalen(0) and rs(7)) or
106 (datalen(1) and rs(15)) or
107 (datalen(2) and rs(31));
108 tmp := (others => negative);
109 if datalen(2) = '1' then
110 tmp(31 downto 16) := rs(31 downto 16);
112 if datalen(2) = '1' or datalen(1) = '1' then
113 tmp(15 downto 8) := rs(15 downto 8);
115 tmp(7 downto 0) := rs(7 downto 0);
118 if invert_out = '1' then