Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes and improvements from the PULP iDMA integration effort #49

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/backend/tpl/idma_backend.sv.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -628,10 +628,10 @@ _rsp_t ${protocol}_write_rsp_i,
// Add fall-through register to allow the input to be ready if the output is not. This
// does not add a cycle of delay
% if not one_read_port:
assign r_meta_req_tagged = '{
src_protocol: r_req.r_dp_req.src_protocol,
ar_req: r_req.ar_req
};
always_comb begin : assign_r_meta_req
r_meta_req_tagged.src_protocol = r_req.r_dp_req.src_protocol;
r_meta_req_tagged.ar_req = r_req.ar_req;
end
% endif

fall_through_register #(
Expand Down Expand Up @@ -776,10 +776,10 @@ _rsp_t ${protocol}_write_rsp_i,
// R-AW channel coupler
//--------------------------------------
% if not one_write_port:
assign w_meta_req_tagged = '{
dst_protocol: w_req.w_dp_req.dst_protocol,
aw_req: w_req.aw_req
};
always_comb begin : assign_tagged_w_req // need to have an always_comb block for Questa to not crap itself
w_meta_req_tagged.dst_protocol = w_req.w_dp_req.dst_protocol;
w_meta_req_tagged.aw_req = w_req.aw_req;
end
% endif

if (RAWCouplingAvail) begin : gen_r_aw_coupler
Expand Down
8 changes: 8 additions & 0 deletions src/frontend/reg/tpl/idma_reg.hjson.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ ${params}
name: "enable_nd",
desc: "ND-extension enabled"
}
{ bits: "${src_prot_range}",
name: "src_protocol",
desc: "Selection of the source protocol"
}
{ bits: "${dst_prot_range}",
name: "dst_protocol",
desc: "Selection of the destination protocol"
}
]
},
{ multireg:
Expand Down
28 changes: 20 additions & 8 deletions src/frontend/reg/tpl/idma_reg.sv.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ module idma_${identifier} #(
// register signals
reg_rsp_t [NumRegs-1:0] dma_ctrl_rsp;

always_comb begin
stream_idx_o = '0;
for (int r = 0; r < NumRegs; r++) begin
for (int c = 0; c < NumStreams; c++) begin
if (dma_reg2hw[r].next_id[c].re) begin
stream_idx_o = c;
end
end
end
end

// generate the registers
for (genvar i = 0; i < NumRegs; i++) begin : gen_core_regs

Expand All @@ -76,23 +87,20 @@ module idma_${identifier} #(
.devmode_i ( 1'b1 )
);

logic read_happens;
// DMA backpressure
always_comb begin : proc_dma_backpressure
// ready signal
dma_ctrl_rsp_o[i] = dma_ctrl_rsp[i];
dma_ctrl_rsp_o[i].ready = arb_ready[i];
dma_ctrl_rsp_o[i].ready = read_happens ? arb_ready[i] : dma_ctrl_rsp[i];
end

// valid signals
logic read_happens;

always_comb begin : proc_launch
read_happens = 1'b0;
stream_idx_o = '0;
for (int c = 0; c < NumStreams; c++) begin
read_happens |= dma_reg2hw[i].next_id[c].re;
if (dma_reg2hw[i].next_id[c].re) begin
stream_idx_o = c;
end
end
arb_valid[i] = read_happens;
end
Expand All @@ -113,6 +121,10 @@ module idma_${identifier} #(
arb_dma_req[i]${sep}dst_addr = {dma_reg2hw[i].dst_addr_high.q, dma_reg2hw[i].dst_addr_low.q};
% endif

// Protocols
arb_dma_req[i]${sep}opt.src_protocol = idma_pkg::protocol_e'(dma_reg2hw[i].conf.src_protocol);
arb_dma_req[i]${sep}opt.dst_protocol = idma_pkg::protocol_e'(dma_reg2hw[i].conf.dst_protocol);

// Current backend only supports incremental burst
arb_dma_req[i]${sep}opt.src.burst = axi_pkg::BURST_INCR;
arb_dma_req[i]${sep}opt.dst.burst = axi_pkg::BURST_INCR;
Expand Down Expand Up @@ -148,13 +160,13 @@ module idma_${identifier} #(
// Disable higher dimensions
if ( dma_reg2hw[i].conf.enable_nd.q == 0) begin
% for nd in range(0, num_dim-1):
arb_dma_req[i].d_req[${nd}].reps = '0;
arb_dma_req[i].d_req[${nd}].reps = ${"'0" if nd != num_dim-2 else "'d1"};
% endfor
end
% for nd in range(1, num_dim-1):
else if ( dma_reg2hw[i].conf.enable_nd.q == ${nd}) begin
% for snd in range(nd, num_dim-1):
arb_dma_req[i].d_req[${snd}].reps = '0;
arb_dma_req[i].d_req[${snd}].reps = 'd1;
% endfor
end
% endfor
Expand Down
1 change: 1 addition & 0 deletions target/rtl/.gitignore
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be no generated files checked in.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Bender.yml
include
*.sv
!idma_generated.sv
*.hjson
5 changes: 4 additions & 1 deletion util/mario/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import math
from mako.template import Template

NUM_PROT_BITS = 3

def render_register(content: dict):
"""Render a register"""
Expand Down Expand Up @@ -129,7 +130,9 @@ def render_reg_hjson(fe_ids: dict, tpl_file: str) -> str:
'identifier': fe_id,
'params': params,
'registers': regs,
'dim_range': f'{10+num_dim_bits}:10'
'dim_range': f'{10+num_dim_bits}:10',
'src_prot_range': f'{10+num_dim_bits+NUM_PROT_BITS}:{10+num_dim_bits+1}',
'dst_prot_range': f'{10+num_dim_bits+2*NUM_PROT_BITS}:{10+num_dim_bits+NUM_PROT_BITS+1}'
}

# render
Expand Down
19 changes: 13 additions & 6 deletions util/mario/legalizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ def render_legalizer(prot_ids: dict, db: dict, tpl_file: str) -> str:
data_path = indent_block(db[wp]['legalizer_write_data_path'], 3 - swp, 4)
db[wp]['legalizer_write_data_path'] = data_path


has_page_read_bursting = eval_key(used_read_prots, 'bursts', 'split_at_page_boundary', db)
has_pow2_read_bursting = eval_key(used_read_prots, 'bursts', 'only_pow2', db)
has_read_bursting = has_page_read_bursting or has_pow2_read_bursting
has_page_write_bursting = eval_key(used_write_prots, 'bursts', 'split_at_page_boundary', db)
has_pow2_write_bursting = eval_key(used_write_prots, 'bursts', 'only_pow2', db)
has_write_bursting = has_page_write_bursting or has_pow2_write_bursting
# assemble context
context = {
'name_uniqueifier': prot_id,
Expand All @@ -66,17 +73,17 @@ def render_legalizer(prot_ids: dict, db: dict, tpl_file: str) -> str:
'one_read_port': srp,
'one_write_port': swp,
'no_read_bursting':
eval_key(used_read_prots, 'bursts', 'not_supported', db),
not has_read_bursting,
'has_page_read_bursting':
eval_key(used_read_prots, 'bursts', 'split_at_page_boundary', db),
has_page_read_bursting,
'has_pow2_read_bursting':
eval_key(used_read_prots, 'bursts', 'only_pow2', db),
has_pow2_read_bursting,
'no_write_bursting':
eval_key(used_write_prots, 'bursts', 'not_supported', db),
not has_write_bursting,
'has_page_write_bursting':
eval_key(used_write_prots, 'bursts', 'split_at_page_boundary', db),
has_page_write_bursting,
'has_pow2_write_bursting':
eval_key(used_write_prots, 'bursts', 'only_pow2', db),
has_pow2_write_bursting,
'used_non_bursting_write_protocols':
prot_key(used_read_prots, 'bursts', 'not_supported', db),
'used_non_bursting_read_protocols':
Expand Down
Loading