From 586abb70a0b78f72c0a58865e1f8f6d0322b258e Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Wed, 25 Sep 2019 16:54:25 +1000 Subject: [PATCH 01/10] Update dependency Signed-off-by: Benjamin Herrenschmidt --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index c4c2848..13d245e 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ common.o: decode_types.o sim_jtag.o: sim_jtag_socket.o core_tb.o: common.o wishbone_types.o core.o soc.o sim_jtag.o core.o: common.o wishbone_types.o fetch1.o fetch2.o icache.o decode1.o decode2.o register_file.o cr_file.o execute1.o execute2.o loadstore1.o loadstore2.o multiply.o writeback.o core_debug.o divider.o -core_debug.o: +core_debug.o: common.o cr_file.o: common.o crhelpers.o: common.o decode1.o: common.o decode_types.o @@ -50,7 +50,7 @@ wishbone_arbiter.o: wishbone_types.o wishbone_types.o: writeback.o: common.o dmi_dtm_tb.o: dmi_dtm_xilinx.o wishbone_debug_master.o -dmi_dtm_xilinx.o: sim-unisim/unisim_vcomponents.o +dmi_dtm_xilinx.o: wishbone_types.o sim-unisim/unisim_vcomponents.o wishbone_debug_master.o: wishbone_types.o UNISIM_BITS = sim-unisim/unisim_vcomponents.vhdl sim-unisim/BSCANE2.vhdl sim-unisim/BUFG.vhdl From 3a6fcc09d4a82de4087343ce83ad5f7fa408d525 Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Tue, 24 Sep 2019 12:11:24 +1000 Subject: [PATCH 02/10] Reformat fetch1 No code change Signed-off-by: Benjamin Herrenschmidt --- fetch1.vhdl | 99 +++++++++++++++++++++++++++-------------------------- 1 file changed, 50 insertions(+), 49 deletions(-) diff --git a/fetch1.vhdl b/fetch1.vhdl index 8e8c5a5..29ff71f 100644 --- a/fetch1.vhdl +++ b/fetch1.vhdl @@ -6,70 +6,71 @@ library work; use work.common.all; entity fetch1 is - generic( - RESET_ADDRESS : std_logic_vector(63 downto 0) := (others => '0') + generic( + RESET_ADDRESS : std_logic_vector(63 downto 0) := (others => '0') ); - port( - clk : in std_ulogic; - rst : in std_ulogic; + port( + clk : in std_ulogic; + rst : in std_ulogic; - -- Control inputs: - stall_in : in std_ulogic; - flush_in : in std_ulogic; + -- Control inputs: + stall_in : in std_ulogic; + flush_in : in std_ulogic; - -- redirect from execution unit - e_in : in Execute1ToFetch1Type; + -- redirect from execution unit + e_in : in Execute1ToFetch1Type; - -- fetch data out - f_out : out Fetch1ToFetch2Type + -- fetch data out + f_out : out Fetch1ToFetch2Type ); end entity fetch1; architecture behaviour of fetch1 is - type reg_internal_type is record - nia_next : std_ulogic_vector(63 downto 0); - end record; - signal r_int, rin_int : reg_internal_type; - signal r, rin : Fetch1ToFetch2Type; + type reg_internal_type is record + nia_next : std_ulogic_vector(63 downto 0); + end record; + signal r_int, rin_int : reg_internal_type; + signal r, rin : Fetch1ToFetch2Type; begin - regs : process(clk) - begin - if rising_edge(clk) then - r <= rin; - r_int <= rin_int; - end if; - end process; + regs : process(clk) + begin + if rising_edge(clk) then + r <= rin; + r_int <= rin_int; + end if; + end process; - comb : process(all) - variable v : Fetch1ToFetch2Type; - variable v_int : reg_internal_type; - begin - v := r; - v_int := r_int; + comb : process(all) + variable v : Fetch1ToFetch2Type; + variable v_int : reg_internal_type; + begin + v := r; + v_int := r_int; - if stall_in = '0' then - v.nia := r_int.nia_next; - v_int.nia_next := std_logic_vector(unsigned(r_int.nia_next) + 4); - end if; + if stall_in = '0' then + v.nia := r_int.nia_next; + v_int.nia_next := std_logic_vector(unsigned(r_int.nia_next) + 4); + end if; - if e_in.redirect = '1' then - v.nia := e_in.redirect_nia; - v_int.nia_next := std_logic_vector(unsigned(e_in.redirect_nia) + 4); - end if; + if e_in.redirect = '1' then + v.nia := e_in.redirect_nia; + v_int.nia_next := std_logic_vector(unsigned(e_in.redirect_nia) + 4); + end if; - if rst = '1' then - v.nia := RESET_ADDRESS; - v_int.nia_next := std_logic_vector(unsigned(RESET_ADDRESS) + 4); - end if; + if rst = '1' then + v.nia := RESET_ADDRESS; + v_int.nia_next := std_logic_vector(unsigned(RESET_ADDRESS) + 4); + end if; - -- Update registers - rin <= v; - rin_int <= v_int; + -- Update registers + rin <= v; + rin_int <= v_int; - -- Update outputs - f_out <= r; + -- Update outputs + f_out <= r; - report "fetch1 R:" & std_ulogic'image(e_in.redirect) & " v.nia:" & to_hstring(v.nia) & " f_out.nia:" & to_hstring(f_out.nia); - end process; + report "fetch1 R:" & std_ulogic'image(e_in.redirect) & " v.nia:" & to_hstring(v.nia) & " f_out.nia:" & to_hstring(f_out.nia); + + end process; end architecture behaviour; From 8af2b004c389aeb65e12621eb59f5416706268f1 Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Tue, 24 Sep 2019 12:17:42 +1000 Subject: [PATCH 03/10] Simplify fetch1 Do the +4 in a single place. This shouldn't cause any difference in behaviour as these are sequential variable assignments. Signed-off-by: Benjamin Herrenschmidt --- fetch1.vhdl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fetch1.vhdl b/fetch1.vhdl index 29ff71f..643e8c8 100644 --- a/fetch1.vhdl +++ b/fetch1.vhdl @@ -49,19 +49,18 @@ begin if stall_in = '0' then v.nia := r_int.nia_next; - v_int.nia_next := std_logic_vector(unsigned(r_int.nia_next) + 4); end if; if e_in.redirect = '1' then v.nia := e_in.redirect_nia; - v_int.nia_next := std_logic_vector(unsigned(e_in.redirect_nia) + 4); end if; if rst = '1' then v.nia := RESET_ADDRESS; - v_int.nia_next := std_logic_vector(unsigned(RESET_ADDRESS) + 4); end if; + v_int.nia_next := std_logic_vector(unsigned(v.nia) + 4); + -- Update registers rin <= v; rin_int <= v_int; From 79b0b9a046564879ef183035cd07de5d2eac5e47 Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Wed, 11 Sep 2019 12:18:22 +0100 Subject: [PATCH 04/10] Fix PLL reset signal name in toplevel It shouldn't have a _n suffix, it's active positive. Signed-off-by: Benjamin Herrenschmidt --- fpga/toplevel.vhdl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fpga/toplevel.vhdl b/fpga/toplevel.vhdl index 489080b..c6ed4ae 100644 --- a/fpga/toplevel.vhdl +++ b/fpga/toplevel.vhdl @@ -21,7 +21,7 @@ architecture behaviour of toplevel is -- Reset signals: signal soc_rst : std_ulogic; - signal pll_rst_n : std_ulogic; + signal pll_rst : std_ulogic; -- Internal clock signals: signal system_clk : std_ulogic; @@ -38,14 +38,14 @@ begin pll_clk => system_clk, pll_locked_in => system_clk_locked, ext_rst_in => ext_rst, - pll_rst_out => pll_rst_n, + pll_rst_out => pll_rst, rst_out => soc_rst ); clkgen: entity work.clock_generator port map( ext_clk => ext_clk, - pll_rst_in => pll_rst_n, + pll_rst_in => pll_rst, pll_clk_out => system_clk, pll_locked_out => system_clk_locked ); From 79b64baefc8c1d174defd7523a5bd6d84225ee96 Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Wed, 25 Sep 2019 12:48:15 +1000 Subject: [PATCH 05/10] Remove unused pipe_stop in Fetch1ToFetch2Type Signed-off-by: Benjamin Herrenschmidt --- common.vhdl | 1 - 1 file changed, 1 deletion(-) diff --git a/common.vhdl b/common.vhdl index d7252f6..8f30d95 100644 --- a/common.vhdl +++ b/common.vhdl @@ -14,7 +14,6 @@ package common is type Fetch1ToFetch2Type is record nia: std_ulogic_vector(63 downto 0); - pipe_stop : std_ulogic; end record; type Fetch2ToDecode1Type is record From 41a4eb82716d4199263ebed493d941d1d1300ab7 Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Wed, 25 Sep 2019 11:26:36 +1000 Subject: [PATCH 06/10] Move fetch2 <-> icache definitions To a more logical place before decode related ones Signed-off-by: Benjamin Herrenschmidt --- common.vhdl | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/common.vhdl b/common.vhdl index 8f30d95..bb898a0 100644 --- a/common.vhdl +++ b/common.vhdl @@ -16,6 +16,16 @@ package common is nia: std_ulogic_vector(63 downto 0); end record; + type Fetch2ToIcacheType is record + req: std_ulogic; + addr: std_ulogic_vector(63 downto 0); + end record; + + type IcacheToFetch2Type is record + ack: std_ulogic; + insn: std_ulogic_vector(31 downto 0); + end record; + type Fetch2ToDecode1Type is record valid: std_ulogic; stop_mark : std_ulogic; @@ -33,16 +43,6 @@ package common is end record; constant Decode1ToDecode2Init : Decode1ToDecode2Type := (valid => '0', stop_mark => '0', decode => decode_rom_init, others => (others => '0')); - type Fetch2ToIcacheType is record - req: std_ulogic; - addr: std_ulogic_vector(63 downto 0); - end record; - - type IcacheToFetch2Type is record - ack: std_ulogic; - insn: std_ulogic_vector(31 downto 0); - end record; - type Decode2ToExecute1Type is record valid: std_ulogic; insn_type: insn_type_t; From 8b55fc4d9e2acbedcdde0e143744b5847dabee6e Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Wed, 25 Sep 2019 11:28:20 +1000 Subject: [PATCH 07/10] Reformat fetch2 Signed-off-by: Benjamin Herrenschmidt --- fetch2.vhdl | 82 ++++++++++++++++++++++++++--------------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/fetch2.vhdl b/fetch2.vhdl index 9573761..2b34836 100644 --- a/fetch2.vhdl +++ b/fetch2.vhdl @@ -7,60 +7,60 @@ use work.common.all; use work.wishbone_types.all; entity fetch2 is - port( - clk : in std_ulogic; - rst : in std_ulogic; + port( + clk : in std_ulogic; + rst : in std_ulogic; - stall_in : in std_ulogic; - stall_out : out std_ulogic; + stall_in : in std_ulogic; + stall_out : out std_ulogic; - flush_in : in std_ulogic; - stop_in : in std_ulogic; + flush_in : in std_ulogic; + stop_in : in std_ulogic; - i_in : in IcacheToFetch2Type; - i_out : out Fetch2ToIcacheType; + i_in : in IcacheToFetch2Type; + i_out : out Fetch2ToIcacheType; - f_in : in Fetch1ToFetch2Type; + f_in : in Fetch1ToFetch2Type; - f_out : out Fetch2ToDecode1Type + f_out : out Fetch2ToDecode1Type ); end entity fetch2; architecture behaviour of fetch2 is - signal r, rin : Fetch2ToDecode1Type; + signal r, rin : Fetch2ToDecode1Type; begin - regs : process(clk) - begin - if rising_edge(clk) then - -- Output state remains unchanged on stall, unless we are flushing - if rst = '1' or flush_in = '1' or stall_in = '0' then - r <= rin; - end if; - end if; - end process; + regs : process(clk) + begin + if rising_edge(clk) then + -- Output state remains unchanged on stall, unless we are flushing + if rst = '1' or flush_in = '1' or stall_in = '0' then + r <= rin; + end if; + end if; + end process; - comb : process(all) - variable v : Fetch2ToDecode1Type; - begin - v := r; + comb : process(all) + variable v : Fetch2ToDecode1Type; + begin + v := r; - -- asynchronous icache lookup - i_out.req <= '1'; - i_out.addr <= f_in.nia; - v.valid := i_in.ack; - v.nia := f_in.nia; - v.insn := i_in.insn; - stall_out <= stop_in or not i_in.ack; + -- asynchronous icache lookup + i_out.req <= '1'; + i_out.addr <= f_in.nia; + v.valid := i_in.ack; + v.nia := f_in.nia; + v.insn := i_in.insn; + stall_out <= stop_in or not i_in.ack; - if flush_in = '1' or stop_in = '1' then - v.valid := '0'; - end if; - v.stop_mark := stop_in; + if flush_in = '1' or stop_in = '1' then + v.valid := '0'; + end if; + v.stop_mark := stop_in; - -- Update registers - rin <= v; + -- Update registers + rin <= v; - -- Update outputs - f_out <= r; - end process; + -- Update outputs + f_out <= r; + end process; end architecture behaviour; From 80a0e7fcf3044c8e7c4e377206f0be0ce147bbda Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Wed, 25 Sep 2019 16:42:44 +1000 Subject: [PATCH 08/10] execute1: simplify flush_out It's always set when f_out.redirect is set, so may as well set it once at the end. It's all combo from the register. Signed-off-by: Benjamin Herrenschmidt --- execute1.vhdl | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/execute1.vhdl b/execute1.vhdl index 436b782..cec431f 100644 --- a/execute1.vhdl +++ b/execute1.vhdl @@ -70,7 +70,6 @@ begin ctrl_tmp.tb <= std_ulogic_vector(unsigned(ctrl.tb) + 1); terminate_out <= '0'; - flush_out <= '0'; f_out <= Execute1ToFetch1TypeInit; if e_in.valid = '1' then @@ -100,7 +99,6 @@ begin result := ppc_andc(e_in.read_data1, e_in.read_data2); result_en := 1; when OP_B => - flush_out <= '1'; f_out.redirect <= '1'; f_out.redirect_nia <= std_ulogic_vector(signed(e_in.nia) + signed(e_in.read_data2)); when OP_BC => @@ -108,7 +106,6 @@ begin ctrl_tmp.ctr <= std_ulogic_vector(unsigned(ctrl.ctr) - 1); end if; if ppc_bc_taken(e_in.const1(4 downto 0), e_in.const2(4 downto 0), e_in.cr, ctrl.ctr) = 1 then - flush_out <= '1'; f_out.redirect <= '1'; f_out.redirect_nia <= std_ulogic_vector(signed(e_in.nia) + signed(e_in.read_data2)); end if; @@ -117,13 +114,11 @@ begin ctrl_tmp.ctr <= std_ulogic_vector(unsigned(ctrl.ctr) - 1); end if; if ppc_bc_taken(e_in.const1(4 downto 0), e_in.const2(4 downto 0), e_in.cr, ctrl.ctr) = 1 then - flush_out <= '1'; f_out.redirect <= '1'; f_out.redirect_nia <= ctrl.lr(63 downto 2) & "00"; end if; when OP_BCCTR => if ppc_bcctr_taken(e_in.const1(4 downto 0), e_in.const2(4 downto 0), e_in.cr) = 1 then - flush_out <= '1'; f_out.redirect <= '1'; f_out.redirect_nia <= ctrl.ctr(63 downto 2) & "00"; end if; @@ -354,5 +349,6 @@ begin -- update outputs --f_out <= r.f; e_out <= r.e; + flush_out <= f_out.redirect; end process; end architecture behaviour; From ab5c6ab9ac98ff18dc27d9e5a71b5d08a513b602 Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Mon, 30 Sep 2019 12:56:09 +1000 Subject: [PATCH 09/10] fpga: Arty A7's don't need multiple filesets the XDC is identical between variants, so is the fileset Signed-off-by: Benjamin Herrenschmidt --- fpga/{arty_a7-35.xdc => arty_a7.xdc} | 0 microwatt.core | 13 ++++--------- 2 files changed, 4 insertions(+), 9 deletions(-) rename fpga/{arty_a7-35.xdc => arty_a7.xdc} (100%) diff --git a/fpga/arty_a7-35.xdc b/fpga/arty_a7.xdc similarity index 100% rename from fpga/arty_a7-35.xdc rename to fpga/arty_a7.xdc diff --git a/microwatt.core b/microwatt.core index 9604cee..f815c15 100644 --- a/microwatt.core +++ b/microwatt.core @@ -68,14 +68,9 @@ filesets: - fpga/nexys-video.xdc : {file_type : xdc} - fpga/clk_gen_plle2.vhd : {file_type : vhdlSource-2008} - arty_a7-35: - files: - - fpga/arty_a7-35.xdc : {file_type : xdc} - - fpga/clk_gen_plle2.vhd : {file_type : vhdlSource-2008} - - arty_a7-100: + arty_a7: files: - - fpga/arty_a7-35.xdc : {file_type : xdc} + - fpga/arty_a7.xdc : {file_type : xdc} - fpga/clk_gen_plle2.vhd : {file_type : vhdlSource-2008} cmod_a7-35: @@ -102,7 +97,7 @@ targets: arty_a7-35: default_tool: vivado - filesets: [core, arty_a7-35, soc, fpga, debug_xilinx] + filesets: [core, arty_a7, soc, fpga, debug_xilinx] parameters : [memory_size, ram_init_file] tools: vivado: {part : xc7a35ticsg324-1L} @@ -110,7 +105,7 @@ targets: arty_a7-100: default_tool: vivado - filesets: [core, arty_a7-100, soc, fpga, debug_xilinx] + filesets: [core, arty_a7, soc, fpga, debug_xilinx] parameters : [memory_size, ram_init_file] tools: vivado: {part : xc7a100ticsg324-1L} From 492bf06740954089869a93c8947fcaa222cff0a4 Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Mon, 30 Sep 2019 13:54:04 +1000 Subject: [PATCH 10/10] corefile: Remove duplicate wishbone_debug_master It's both in core and soc, it should only be in the latter Signed-off-by: Benjamin Herrenschmidt --- microwatt.core | 1 - 1 file changed, 1 deletion(-) diff --git a/microwatt.core b/microwatt.core index f815c15..b32148a 100644 --- a/microwatt.core +++ b/microwatt.core @@ -26,7 +26,6 @@ filesets: - divider.vhdl - writeback.vhdl - insn_helpers.vhdl - - wishbone_debug_master.vhdl - core.vhdl - icache.vhdl - core_debug.vhdl