core: Don't generate logic for log data when LOG_LENGTH = 0

This adds "if LOG_LENGTH > 0 generate" to the places in the core
where log output data is latched, so that when LOG_LENGTH = 0 we
don't create the logic to collect the data which won't be stored.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
pull/233/head
Paul Mackerras 4 years ago
parent 03a3a5d326
commit 893d2bc6a2

@ -202,7 +202,8 @@ begin
SIM => SIM, SIM => SIM,
LINE_SIZE => 64, LINE_SIZE => 64,
NUM_LINES => 64, NUM_LINES => 64,
NUM_WAYS => 2 NUM_WAYS => 2,
LOG_LENGTH => LOG_LENGTH
) )
port map( port map(
clk => clk, clk => clk,
@ -222,6 +223,9 @@ begin
icache_stall_in <= decode1_busy; icache_stall_in <= decode1_busy;


decode1_0: entity work.decode1 decode1_0: entity work.decode1
generic map(
LOG_LENGTH => LOG_LENGTH
)
port map ( port map (
clk => clk, clk => clk,
rst => rst_dec1, rst => rst_dec1,
@ -239,7 +243,8 @@ begin


decode2_0: entity work.decode2 decode2_0: entity work.decode2
generic map ( generic map (
EX1_BYPASS => EX1_BYPASS EX1_BYPASS => EX1_BYPASS,
LOG_LENGTH => LOG_LENGTH
) )
port map ( port map (
clk => clk, clk => clk,
@ -261,7 +266,8 @@ begin


register_file_0: entity work.register_file register_file_0: entity work.register_file
generic map ( generic map (
SIM => SIM SIM => SIM,
LOG_LENGTH => LOG_LENGTH
) )
port map ( port map (
clk => clk, clk => clk,
@ -279,7 +285,8 @@ begin


cr_file_0: entity work.cr_file cr_file_0: entity work.cr_file
generic map ( generic map (
SIM => SIM SIM => SIM,
LOG_LENGTH => LOG_LENGTH
) )
port map ( port map (
clk => clk, clk => clk,
@ -292,7 +299,8 @@ begin


execute1_0: entity work.execute1 execute1_0: entity work.execute1
generic map ( generic map (
EX1_BYPASS => EX1_BYPASS EX1_BYPASS => EX1_BYPASS,
LOG_LENGTH => LOG_LENGTH
) )
port map ( port map (
clk => clk, clk => clk,
@ -315,6 +323,9 @@ begin
); );


loadstore1_0: entity work.loadstore1 loadstore1_0: entity work.loadstore1
generic map (
LOG_LENGTH => LOG_LENGTH
)
port map ( port map (
clk => clk, clk => clk,
rst => rst_ls1, rst => rst_ls1,
@ -344,7 +355,8 @@ begin
generic map( generic map(
LINE_SIZE => 64, LINE_SIZE => 64,
NUM_LINES => 64, NUM_LINES => 64,
NUM_WAYS => 2 NUM_WAYS => 2,
LOG_LENGTH => LOG_LENGTH
) )
port map ( port map (
clk => clk, clk => clk,

@ -7,7 +7,9 @@ use work.common.all;


entity cr_file is entity cr_file is
generic ( generic (
SIM : boolean := false SIM : boolean := false;
-- Non-zero to enable log data collection
LOG_LENGTH : natural := 0
); );
port( port(
clk : in std_logic; clk : in std_logic;
@ -29,7 +31,6 @@ architecture behaviour of cr_file is
signal crs_updated : std_ulogic_vector(31 downto 0); signal crs_updated : std_ulogic_vector(31 downto 0);
signal xerc : xer_common_t := xerc_init; signal xerc : xer_common_t := xerc_init;
signal xerc_updated : xer_common_t; signal xerc_updated : xer_common_t;
signal log_data : std_ulogic_vector(12 downto 0);
begin begin
cr_create_0: process(all) cr_create_0: process(all)
variable hi, lo : integer := 0; variable hi, lo : integer := 0;
@ -91,14 +92,18 @@ begin
end process; end process;
end generate; end generate;


cr_log: process(clk) cf_log: if LOG_LENGTH > 0 generate
signal log_data : std_ulogic_vector(12 downto 0);
begin begin
if rising_edge(clk) then cr_log: process(clk)
log_data <= w_in.write_cr_enable & begin
w_in.write_cr_data(31 downto 28) & if rising_edge(clk) then
w_in.write_cr_mask; log_data <= w_in.write_cr_enable &
end if; w_in.write_cr_data(31 downto 28) &
end process; w_in.write_cr_mask;
log_out <= log_data; end if;
end process;
log_out <= log_data;
end generate;


end architecture behaviour; end architecture behaviour;

@ -31,7 +31,9 @@ entity dcache is
-- L1 DTLB number of sets -- L1 DTLB number of sets
TLB_NUM_WAYS : positive := 2; TLB_NUM_WAYS : positive := 2;
-- L1 DTLB log_2(page_size) -- L1 DTLB log_2(page_size)
TLB_LG_PGSZ : positive := 12 TLB_LG_PGSZ : positive := 12;
-- Non-zero to enable log data collection
LOG_LENGTH : natural := 0
); );
port ( port (
clk : in std_ulogic; clk : in std_ulogic;
@ -463,8 +465,6 @@ architecture rtl of dcache is
ptes(j + TLB_PTE_BITS - 1 downto j) := newpte; ptes(j + TLB_PTE_BITS - 1 downto j) := newpte;
end; end;


signal log_data : std_ulogic_vector(19 downto 0);

begin begin


assert LINE_SIZE mod ROW_SIZE = 0 report "LINE_SIZE not multiple of ROW_SIZE" severity FAILURE; assert LINE_SIZE mod ROW_SIZE = 0 report "LINE_SIZE not multiple of ROW_SIZE" severity FAILURE;
@ -1460,21 +1460,25 @@ begin
end if; end if;
end process; end process;


dcache_log: process(clk) dc_log: if LOG_LENGTH > 0 generate
signal log_data : std_ulogic_vector(19 downto 0);
begin begin
if rising_edge(clk) then dcache_log: process(clk)
log_data <= r1.wb.adr(5 downto 3) & begin
wishbone_in.stall & if rising_edge(clk) then
wishbone_in.ack & log_data <= r1.wb.adr(5 downto 3) &
r1.wb.stb & r1.wb.cyc & wishbone_in.stall &
d_out.error & wishbone_in.ack &
d_out.valid & r1.wb.stb & r1.wb.cyc &
std_ulogic_vector(to_unsigned(op_t'pos(req_op), 3)) & d_out.error &
stall_out & d_out.valid &
std_ulogic_vector(to_unsigned(tlb_hit_way, 3)) & std_ulogic_vector(to_unsigned(op_t'pos(req_op), 3)) &
valid_ra & stall_out &
std_ulogic_vector(to_unsigned(state_t'pos(r1.state), 3)); std_ulogic_vector(to_unsigned(tlb_hit_way, 3)) &
end if; valid_ra &
end process; std_ulogic_vector(to_unsigned(state_t'pos(r1.state), 3));
log_out <= log_data; end if;
end process;
log_out <= log_data;
end generate;
end; end;

@ -7,6 +7,10 @@ use work.common.all;
use work.decode_types.all; use work.decode_types.all;


entity decode1 is entity decode1 is
generic (
-- Non-zero to enable log data collection
LOG_LENGTH : natural := 0
);
port ( port (
clk : in std_ulogic; clk : in std_ulogic;
rst : in std_ulogic; rst : in std_ulogic;
@ -357,8 +361,6 @@ architecture behaviour of decode1 is
constant nop_instr : decode_rom_t := (ALU, OP_NOP, NONE, NONE, NONE, NONE, '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', NONE, '0', '0'); constant nop_instr : decode_rom_t := (ALU, OP_NOP, NONE, NONE, NONE, NONE, '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', NONE, '0', '0');
constant fetch_fail_inst: decode_rom_t := (LDST, OP_FETCH_FAILED, NONE, NONE, NONE, NONE, '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', NONE, '0', '0'); constant fetch_fail_inst: decode_rom_t := (LDST, OP_FETCH_FAILED, NONE, NONE, NONE, NONE, '0', '0', '0', '0', ZERO, '0', NONE, '0', '0', '0', '0', '0', '0', NONE, '0', '0');


signal log_data : std_ulogic_vector(12 downto 0);

begin begin
decode1_0: process(clk) decode1_0: process(clk)
begin begin
@ -524,15 +526,19 @@ begin
flush_out <= f.redirect; flush_out <= f.redirect;
end process; end process;


dec1_log : process(clk) d1_log: if LOG_LENGTH > 0 generate
signal log_data : std_ulogic_vector(12 downto 0);
begin begin
if rising_edge(clk) then dec1_log : process(clk)
log_data <= std_ulogic_vector(to_unsigned(insn_type_t'pos(r.decode.insn_type), 6)) & begin
r.nia(5 downto 2) & if rising_edge(clk) then
std_ulogic_vector(to_unsigned(unit_t'pos(r.decode.unit), 2)) & log_data <= std_ulogic_vector(to_unsigned(insn_type_t'pos(r.decode.insn_type), 6)) &
r.valid; r.nia(5 downto 2) &
end if; std_ulogic_vector(to_unsigned(unit_t'pos(r.decode.unit), 2)) &
end process; r.valid;
log_out <= log_data; end if;
end process;
log_out <= log_data;
end generate;


end architecture behaviour; end architecture behaviour;

@ -10,7 +10,9 @@ use work.insn_helpers.all;


entity decode2 is entity decode2 is
generic ( generic (
EX1_BYPASS : boolean := true EX1_BYPASS : boolean := true;
-- Non-zero to enable log data collection
LOG_LENGTH : natural := 0
); );
port ( port (
clk : in std_ulogic; clk : in std_ulogic;
@ -47,8 +49,6 @@ architecture behaviour of decode2 is


signal deferred : std_ulogic; signal deferred : std_ulogic;


signal log_data : std_ulogic_vector(9 downto 0);

type decode_input_reg_t is record type decode_input_reg_t is record
reg_valid : std_ulogic; reg_valid : std_ulogic;
reg : gspr_index_t; reg : gspr_index_t;
@ -415,18 +415,22 @@ begin
e_out <= r.e; e_out <= r.e;
end process; end process;


dec2_log : process(clk) d2_log: if LOG_LENGTH > 0 generate
signal log_data : std_ulogic_vector(9 downto 0);
begin begin
if rising_edge(clk) then dec2_log : process(clk)
log_data <= r.e.nia(5 downto 2) & begin
r.e.valid & if rising_edge(clk) then
stopped_out & log_data <= r.e.nia(5 downto 2) &
stall_out & r.e.valid &
r.e.bypass_data3 & stopped_out &
r.e.bypass_data2 & stall_out &
r.e.bypass_data1; r.e.bypass_data3 &
end if; r.e.bypass_data2 &
end process; r.e.bypass_data1;
log_out <= log_data; end if;
end process;
log_out <= log_data;
end generate;


end architecture behaviour; end architecture behaviour;

@ -12,7 +12,9 @@ use work.ppc_fx_insns.all;


entity execute1 is entity execute1 is
generic ( generic (
EX1_BYPASS : boolean := true EX1_BYPASS : boolean := true;
-- Non-zero to enable log data collection
LOG_LENGTH : natural := 0
); );
port ( port (
clk : in std_ulogic; clk : in std_ulogic;
@ -97,7 +99,6 @@ architecture behaviour of execute1 is
-- signals for logging -- signals for logging
signal exception_log : std_ulogic; signal exception_log : std_ulogic;
signal irq_valid_log : std_ulogic; signal irq_valid_log : std_ulogic;
signal log_data : std_ulogic_vector(14 downto 0);


type privilege_level is (USER, SUPER); type privilege_level is (USER, SUPER);
type op_privilege_array is array(insn_type_t) of privilege_level; type op_privilege_array is array(insn_type_t) of privilege_level;
@ -1083,21 +1084,25 @@ begin
irq_valid_log <= irq_valid; irq_valid_log <= irq_valid;
end process; end process;


ex1_log : process(clk) e1_log: if LOG_LENGTH > 0 generate
signal log_data : std_ulogic_vector(14 downto 0);
begin begin
if rising_edge(clk) then ex1_log : process(clk)
log_data <= ctrl.msr(MSR_EE) & ctrl.msr(MSR_PR) & begin
ctrl.msr(MSR_IR) & ctrl.msr(MSR_DR) & if rising_edge(clk) then
exception_log & log_data <= ctrl.msr(MSR_EE) & ctrl.msr(MSR_PR) &
irq_valid_log & ctrl.msr(MSR_IR) & ctrl.msr(MSR_DR) &
std_ulogic_vector(to_unsigned(irq_state_t'pos(ctrl.irq_state), 1)) & exception_log &
"000" & irq_valid_log &
r.e.write_enable & std_ulogic_vector(to_unsigned(irq_state_t'pos(ctrl.irq_state), 1)) &
r.e.valid & "000" &
f_out.redirect & r.e.write_enable &
r.busy & r.e.valid &
flush_out; f_out.redirect &
end if; r.busy &
end process; flush_out;
log_out <= log_data; end if;
end process;
log_out <= log_data;
end generate;
end architecture behaviour; end architecture behaviour;

@ -47,7 +47,9 @@ entity icache is
-- L1 ITLB log_2(page_size) -- L1 ITLB log_2(page_size)
TLB_LG_PGSZ : positive := 12; TLB_LG_PGSZ : positive := 12;
-- Number of real address bits that we store -- Number of real address bits that we store
REAL_ADDR_BITS : positive := 56 REAL_ADDR_BITS : positive := 56;
-- Non-zero to enable log data collection
LOG_LENGTH : natural := 0
); );
port ( port (
clk : in std_ulogic; clk : in std_ulogic;
@ -207,9 +209,6 @@ architecture rtl of icache is
signal access_ok : std_ulogic; signal access_ok : std_ulogic;
signal use_previous : std_ulogic; signal use_previous : std_ulogic;


-- Output data to logger
signal log_data : std_ulogic_vector(53 downto 0);

-- Cache RAM interface -- Cache RAM interface
type cache_ram_out_t is array(way_t) of cache_row_t; type cache_ram_out_t is array(way_t) of cache_row_t;
signal cache_out : cache_ram_out_t; signal cache_out : cache_ram_out_t;
@ -729,31 +728,36 @@ begin
end if; end if;
end process; end process;


data_log: process(clk) icache_log: if LOG_LENGTH > 0 generate
variable lway: way_t; -- Output data to logger
variable wstate: std_ulogic; signal log_data : std_ulogic_vector(53 downto 0);
begin begin
if rising_edge(clk) then data_log: process(clk)
lway := req_hit_way; variable lway: way_t;
wstate := '0'; variable wstate: std_ulogic;
if r.state /= IDLE then begin
wstate := '1'; if rising_edge(clk) then
lway := req_hit_way;
wstate := '0';
if r.state /= IDLE then
wstate := '1';
end if;
log_data <= i_out.valid &
i_out.insn &
wishbone_in.ack &
r.wb.adr(5 downto 3) &
r.wb.stb & r.wb.cyc &
wishbone_in.stall &
stall_out &
r.fetch_failed &
r.hit_nia(5 downto 2) &
wstate &
std_ulogic_vector(to_unsigned(lway, 3)) &
req_is_hit & req_is_miss &
access_ok &
ra_valid;
end if; end if;
log_data <= i_out.valid & end process;
i_out.insn & log_out <= log_data;
wishbone_in.ack & end generate;
r.wb.adr(5 downto 3) &
r.wb.stb & r.wb.cyc &
wishbone_in.stall &
stall_out &
r.fetch_failed &
r.hit_nia(5 downto 2) &
wstate &
std_ulogic_vector(to_unsigned(lway, 3)) &
req_is_hit & req_is_miss &
access_ok &
ra_valid;
end if;
end process;
log_out <= log_data;
end; end;

@ -10,6 +10,10 @@ use work.common.all;
-- We calculate the address in the first cycle -- We calculate the address in the first cycle


entity loadstore1 is entity loadstore1 is
generic (
-- Non-zero to enable log data collection
LOG_LENGTH : natural := 0
);
port ( port (
clk : in std_ulogic; clk : in std_ulogic;
rst : in std_ulogic; rst : in std_ulogic;
@ -85,8 +89,6 @@ architecture behave of loadstore1 is
signal r, rin : reg_stage_t; signal r, rin : reg_stage_t;
signal lsu_sum : std_ulogic_vector(63 downto 0); signal lsu_sum : std_ulogic_vector(63 downto 0);


signal log_data : std_ulogic_vector(9 downto 0);

-- Generate byte enables from sizes -- Generate byte enables from sizes
function length_to_sel(length : in std_logic_vector(3 downto 0)) return std_ulogic_vector is function length_to_sel(length : in std_logic_vector(3 downto 0)) return std_ulogic_vector is
begin begin
@ -515,18 +517,23 @@ begin


end process; end process;


ls1_log: process(clk) l1_log: if LOG_LENGTH > 0 generate
signal log_data : std_ulogic_vector(9 downto 0);
begin begin
if rising_edge(clk) then ls1_log: process(clk)
log_data <= e_out.busy & begin
e_out.exception & if rising_edge(clk) then
l_out.valid & log_data <= e_out.busy &
m_out.valid & e_out.exception &
d_out.valid & l_out.valid &
m_in.done & m_out.valid &
r.dwords_done & d_out.valid &
std_ulogic_vector(to_unsigned(state_t'pos(r.state), 3)); m_in.done &
end if; r.dwords_done &
end process; std_ulogic_vector(to_unsigned(state_t'pos(r.state), 3));
log_out <= log_data; end if;
end process;
log_out <= log_data;
end generate;

end; end;

@ -7,7 +7,9 @@ use work.common.all;


entity register_file is entity register_file is
generic ( generic (
SIM : boolean := false SIM : boolean := false;
-- Non-zero to enable log data collection
LOG_LENGTH : natural := 0
); );
port( port(
clk : in std_logic; clk : in std_logic;
@ -36,7 +38,6 @@ architecture behaviour of register_file is
signal rd_port_b : std_ulogic_vector(63 downto 0); signal rd_port_b : std_ulogic_vector(63 downto 0);
signal dbg_data : std_ulogic_vector(63 downto 0); signal dbg_data : std_ulogic_vector(63 downto 0);
signal dbg_ack : std_ulogic; signal dbg_ack : std_ulogic;
signal log_data : std_ulogic_vector(70 downto 0);
begin begin
-- synchronous writes -- synchronous writes
register_write_0: process(clk) register_write_0: process(clk)
@ -134,13 +135,18 @@ begin
sim_dump_done <= '0'; sim_dump_done <= '0';
end generate; end generate;


reg_log: process(clk) rf_log: if LOG_LENGTH > 0 generate
signal log_data : std_ulogic_vector(70 downto 0);
begin begin
if rising_edge(clk) then reg_log: process(clk)
log_data <= w_in.write_data & begin
w_in.write_enable & if rising_edge(clk) then
w_in.write_reg; log_data <= w_in.write_data &
end if; w_in.write_enable &
end process; w_in.write_reg;
log_out <= log_data; end if;
end process;
log_out <= log_data;
end generate;

end architecture behaviour; end architecture behaviour;

Loading…
Cancel
Save