Skip to content

Commit

Permalink
added second master port from PULP jtag and mux to select which of th…
Browse files Browse the repository at this point in the history
…e tap is granted
  • Loading branch information
davideschiavone committed Feb 19, 2019
1 parent 6d19c0e commit 994ceb7
Show file tree
Hide file tree
Showing 3 changed files with 195 additions and 56 deletions.
131 changes: 131 additions & 0 deletions rtl/components/tcdm_arbiter_2x1.sv
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/*
* Copyright (C) 2013-2017 ETH Zurich, University of Bologna
* All rights reserved.
*
* This code is under development and not yet released to the public.
* Until it is released, the code is under the copyright of ETH Zurich and
* the University of Bologna, and may contain confidential and/or unpublished
* work. Any reuse/redistribution is strictly forbidden without written
* permission from ETH Zurich.
*
* Bug fixes and contributions will eventually be released under the
* SolderPad open hardware license in the context of the PULP platform
* (http://www.pulp-platform.org), under the copyright of ETH Zurich and the
* University of Bologna.
*/

module tcdm_arbiter_2x1
(
input logic clk_i,
input logic rst_ni,

XBAR_TCDM_BUS.Slave tcdm_bus_1_i,
XBAR_TCDM_BUS.Slave tcdm_bus_0_i,
XBAR_TCDM_BUS.Master tcdm_bus_o
);

logic SEL_req;
logic SEL_resp;
logic RR_FLAG;

enum logic[2:0] {IDLE, WAIT_GNT_0, WAIT_GNT_1, WAIT_VALID_0, WAIT_VALID_1 } offset_fsm_cs, offset_fsm_ns;

// offset FSM state transition logic
always_comb
begin
offset_fsm_ns = offset_fsm_cs;
tcdm_bus_o.req = 1'b0;
tcdm_bus_0_i.gnt = 1'b0;
tcdm_bus_1_i.gnt = 1'b0;
tcdm_bus_0_i.r_valid = 1'b0;
tcdm_bus_1_i.r_valid = 1'b0;
tcdm_bus_0_i.r_rdata = tcdm_bus_o.r_rdata;
tcdm_bus_1_i.r_rdata = tcdm_bus_o.r_rdata;

unique case (offset_fsm_cs)

IDLE: begin

if (tcdm_bus_0_i.req) begin
tcdm_bus_o.req = tcdm_bus_0_i.req;
tcdm_bus_0_i.gnt = tcdm_bus_o.gnt;
tcdm_bus_o.add = tcdm_bus_0_i.add;
tcdm_bus_o.wen = tcdm_bus_0_i.wen;
tcdm_bus_o.wdata = tcdm_bus_0_i.wdata;
tcdm_bus_o.be = tcdm_bus_0_i.be;

offset_fsm_ns = tcdm_bus_o.gnt ? WAIT_VALID_0 : WAIT_GNT_0;
end else if(tcdm_bus_1_i.req) begin
tcdm_bus_o.req = tcdm_bus_1_i.req;
tcdm_bus_1_i.gnt = tcdm_bus_o.gnt;
tcdm_bus_o.add = tcdm_bus_1_i.add;
tcdm_bus_o.wen = tcdm_bus_1_i.wen;
tcdm_bus_o.wdata = tcdm_bus_1_i.wdata;
tcdm_bus_o.be = tcdm_bus_1_i.be;

offset_fsm_ns = tcdm_bus_o.gnt ? WAIT_VALID_1 : WAIT_GNT_1;
end
end

WAIT_GNT_0: begin
tcdm_bus_o.req = tcdm_bus_0_i.req;
tcdm_bus_0_i.gnt = tcdm_bus_o.gnt;
tcdm_bus_0_i.r_valid = tcdm_bus_o.r_valid;
tcdm_bus_o.add = tcdm_bus_0_i.add;
tcdm_bus_o.wen = tcdm_bus_0_i.wen;
tcdm_bus_o.wdata = tcdm_bus_0_i.wdata;
tcdm_bus_o.be = tcdm_bus_0_i.be;
offset_fsm_ns = tcdm_bus_o.gnt ? WAIT_VALID_0 : WAIT_GNT_0;
end

WAIT_VALID_0: begin
tcdm_bus_o.req = tcdm_bus_0_i.req;
tcdm_bus_0_i.gnt = tcdm_bus_o.gnt;
tcdm_bus_0_i.r_valid = tcdm_bus_o.r_valid;
tcdm_bus_o.add = tcdm_bus_0_i.add;
tcdm_bus_o.wen = tcdm_bus_0_i.wen;
tcdm_bus_o.wdata = tcdm_bus_0_i.wdata;
tcdm_bus_o.be = tcdm_bus_0_i.be;
offset_fsm_ns = tcdm_bus_o.r_valid ? IDLE : WAIT_VALID_0;
end

WAIT_GNT_1: begin
tcdm_bus_o.req = tcdm_bus_1_i.req;
tcdm_bus_1_i.gnt = tcdm_bus_o.gnt;
tcdm_bus_1_i.r_valid = tcdm_bus_o.r_valid;
tcdm_bus_o.add = tcdm_bus_1_i.add;
tcdm_bus_o.wen = tcdm_bus_1_i.wen;
tcdm_bus_o.wdata = tcdm_bus_1_i.wdata;
tcdm_bus_o.be = tcdm_bus_1_i.be;
offset_fsm_ns = tcdm_bus_o.gnt ? WAIT_VALID_1 : WAIT_GNT_1;
end

WAIT_VALID_1: begin
tcdm_bus_o.req = tcdm_bus_1_i.req;
tcdm_bus_1_i.gnt = tcdm_bus_o.gnt;
tcdm_bus_1_i.r_valid = tcdm_bus_o.r_valid;
tcdm_bus_o.add = tcdm_bus_1_i.add;
tcdm_bus_o.wen = tcdm_bus_1_i.wen;
tcdm_bus_o.wdata = tcdm_bus_1_i.wdata;
tcdm_bus_o.be = tcdm_bus_1_i.be;
offset_fsm_ns = tcdm_bus_o.r_valid ? IDLE : WAIT_VALID_1;
end

endcase
end


always_ff @(posedge clk_i or negedge rst_ni)
begin : RR_SEL_resp_GEN
if(~rst_ni)
begin
offset_fsm_cs <= IDLE;
end
else
begin
offset_fsm_cs <= offset_fsm_ns;
end
end


endmodule // TCDM_BUS_2x1_ARB
119 changes: 63 additions & 56 deletions rtl/pulp_soc/pulp_soc.sv
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,9 @@ module pulp_soc #(
UNICAD_MEM_BUS_32 s_scm_l2_instr_bus ();
`endif

XBAR_TCDM_BUS s_lint_debug_bus ();
XBAR_TCDM_BUS s_lint_jtag_bus ();
XBAR_TCDM_BUS s_lint_debug_bus();
XBAR_TCDM_BUS s_lint_pulp_jtag_bus();
XBAR_TCDM_BUS s_lint_riscv_jtag_bus();
XBAR_TCDM_BUS s_lint_udma_tx_bus ();
XBAR_TCDM_BUS s_lint_udma_rx_bus ();
XBAR_TCDM_BUS s_lint_fc_data_bus ();
Expand Down Expand Up @@ -497,7 +498,7 @@ module pulp_soc #(
.clk_i ( s_soc_clk ),
.periph_clk_i ( s_periph_clk ),
.rst_ni ( s_soc_rstn ),
.sel_fll_clk_i ( sel_fll_clk_i ),
.sel_fll_clk_i ( s_sel_fll_clk ),
.ref_clk_i ( ref_clk_i ),
.slow_clk_i ( slow_clk_i ),

Expand All @@ -516,8 +517,8 @@ module pulp_soc #(
.l2_rx_master ( s_lint_udma_rx_bus ),
.l2_tx_master ( s_lint_udma_tx_bus ),

.soc_jtag_reg_i ( soc_jtag_reg_i ),
.soc_jtag_reg_o ( soc_jtag_reg_o ),
.soc_jtag_reg_i ( soc_jtag_reg_tap ),
.soc_jtag_reg_o ( soc_jtag_reg_soc ),

.fc_hwpe_events_i ( s_fc_hwpe_events ),
.fc_events_o ( s_fc_events ),
Expand Down Expand Up @@ -683,7 +684,7 @@ module pulp_soc #(
soc_clk_rst_gen i_clk_rst_gen (
.ref_clk_i ( ref_clk_i ),
.test_clk_i ( test_clk_i ),
.sel_fll_clk_i ( sel_fll_clk ),
.sel_fll_clk_i ( s_sel_fll_clk ),

.rstn_glob_i ( rstn_glob_i ),
.rstn_soc_sync_o ( s_soc_rstn ),
Expand Down Expand Up @@ -770,7 +771,7 @@ module pulp_soc #(
logic slave_grant, slave_valid, slave_req , slave_we;
logic [31:0] slave_addr, slave_wdata, slave_rdata;
logic [3:0] slave_be;
logic lint_debug_master_we;
logic lint_riscv_jtag_bus_master_we;
logic int_td;

logic master_req;
Expand All @@ -783,22 +784,6 @@ module pulp_soc #(
logic [31:0] master_r_rdata;

/* Debug Subsystem */
/*
lint_jtag_wrap i_lint_jtag (
.tck_i ( jtag_tck_i ),
.tdi_i ( jtag_axireg_tdi_i ),
.trstn_i ( jtag_trst_ni ),
.tdo_o ( jtag_axireg_tdo_o ),
.shift_dr_i ( jtag_shift_dr_i ),
.pause_dr_i ( 1'b0 ),
.update_dr_i ( jtag_update_dr_i ),
.capture_dr_i ( jtag_capture_dr_i ),
.lint_select_i( jtag_axireg_sel_i ),
.clk_i ( s_soc_clk ),
.rst_ni ( s_soc_rstn ),
.jtag_lint_master(s_lint_debug_bus)
);
*/

dmi_jtag i_dmi_jtag (
.clk_i ( s_soc_clk ),
Expand All @@ -819,30 +804,6 @@ module pulp_soc #(
.tdo_oe_o ( )
);

jtag_tap_top jtag_tap_top_i
(
.tck_i ( jtag_tck_i ),
.trst_ni ( jtag_trst_ni ),
.tms_i ( jtag_tms_i ),
.td_i ( int_td ),
.td_o ( jtag_tdo_o ),

.test_clk_i ( 1'b0 ),
.test_rstn_i ( s_rstn_sync ),

.jtag_shift_dr_o ( ),
.jtag_update_dr_o ( ),
.jtag_capture_dr_o ( ),

.axireg_sel_o ( ),
.dbg_axi_scan_in_o ( ),
.dbg_axi_scan_out_i ( ),
.soc_jtag_reg_i ( soc_jtag_reg_soc ),
.soc_jtag_reg_o ( soc_jtag_reg_tap ),
.sel_fll_clk_o ( sel_fll_clk )
);


dm_top #(
.NrHarts ( NrHarts ),
.BusWidth ( 32 ),
Expand All @@ -864,14 +825,14 @@ module pulp_soc #(
.slave_wdata_i ( slave_wdata ),
.slave_rdata_o ( slave_rdata ),

.master_req_o ( s_lint_debug_bus.req ),
.master_add_o ( s_lint_debug_bus.add ),
.master_we_o ( lint_debug_master_we ),
.master_wdata_o ( s_lint_debug_bus.wdata ),
.master_be_o ( s_lint_debug_bus.be ),
.master_gnt_i ( s_lint_debug_bus.gnt ),
.master_r_valid_i ( s_lint_debug_bus.r_valid ),
.master_r_rdata_i ( s_lint_debug_bus.r_rdata ),
.master_req_o ( s_lint_riscv_jtag_bus.req ),
.master_add_o ( s_lint_riscv_jtag_bus.add ),
.master_we_o ( lint_riscv_jtag_bus_master_we ),
.master_wdata_o ( s_lint_riscv_jtag_bus.wdata ),
.master_be_o ( s_lint_riscv_jtag_bus.be ),
.master_gnt_i ( s_lint_riscv_jtag_bus.gnt ),
.master_r_valid_i ( s_lint_riscv_jtag_bus.r_valid ),
.master_r_rdata_i ( s_lint_riscv_jtag_bus.r_rdata ),

.dmi_rst_ni ( s_soc_rstn ),
.dmi_req_valid_i ( jtag_req_valid ),
Expand All @@ -881,8 +842,54 @@ module pulp_soc #(
.dmi_resp_ready_i ( jtag_resp_ready ),
.dmi_resp_o ( debug_resp )
);
assign s_lint_debug_bus.wen = ~lint_debug_master_we;
assign s_lint_riscv_jtag_bus.wen = ~lint_riscv_jtag_bus_master_we;

jtag_tap_top jtag_tap_top_i
(
.tck_i ( jtag_tck_i ),
.trst_ni ( jtag_trst_ni ),
.tms_i ( jtag_tms_i ),
.td_i ( int_td ),
.td_o ( jtag_tdo_o ),

.test_clk_i ( 1'b0 ),
.test_rstn_i ( s_soc_rstn ),

.jtag_shift_dr_o ( s_jtag_shift_dr ),
.jtag_update_dr_o ( s_jtag_update_dr ),
.jtag_capture_dr_o ( s_jtag_capture_dr ),

.axireg_sel_o ( s_jtag_axireg_sel ),
.dbg_axi_scan_in_o ( s_jtag_axireg_tdi ),
.dbg_axi_scan_out_i ( s_jtag_axireg_tdo ),
.soc_jtag_reg_i ( soc_jtag_reg_soc ),
.soc_jtag_reg_o ( soc_jtag_reg_tap ),
.sel_fll_clk_o ( s_sel_fll_clk )
);

lint_jtag_wrap i_lint_jtag (
.tck_i ( jtag_tck_i ),
.tdi_i ( s_jtag_axireg_tdi ),
.trstn_i ( jtag_trst_ni ),
.tdo_o ( s_jtag_axireg_tdo ),
.shift_dr_i ( s_jtag_shift_dr ),
.pause_dr_i ( 1'b0 ),
.update_dr_i ( s_jtag_update_dr ),
.capture_dr_i ( s_jtag_capture_dr ),
.lint_select_i ( s_jtag_axireg_sel ),
.clk_i ( s_soc_clk ),
.rst_ni ( s_soc_rstn ),
.jtag_lint_master ( s_lint_pulp_jtag_bus )
);

tcdm_arbiter_2x1 jtag_lint_arbiter_i
(
.clk_i(s_soc_clk),
.rst_ni(s_soc_rstn),
.tcdm_bus_1_i(s_lint_pulp_jtag_bus),
.tcdm_bus_0_i(s_lint_riscv_jtag_bus),
.tcdm_bus_o(s_lint_debug_bus)
);

apb2per #(
.PER_ADDR_WIDTH ( 32 ),
Expand Down
1 change: 1 addition & 0 deletions src_files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ components:
rtl/components/glitch_free_clk_mux.sv,
rtl/components/scm_2048x32.sv,
rtl/components/scm_512x32.sv,
rtl/components/tcdm_arbiter_2x1.sv,
]

components_rtl:
Expand Down

0 comments on commit 994ceb7

Please sign in to comment.