Skip to content

Fix for issue #58 #85

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

Open
wants to merge 2 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
3 changes: 1 addition & 2 deletions src/dm_csrs.sv
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ module dm_csrs #(
if (dmcontrol_q.resumereq && resumeack_i) begin
dmcontrol_d.resumereq = 1'b0;
end
// static values for dcsr
// static values for sbcs
sbcs_d.sbversion = 3'b1;
sbcs_d.sbbusy = sbbusy_i;
sbcs_d.sbasize = $bits(sbcs_d.sbasize)'(BusWidth);
Expand All @@ -519,7 +519,6 @@ module dm_csrs #(
sbcs_d.sbaccess32 = logic'(BusWidth == 32'd32);
sbcs_d.sbaccess16 = 1'b0;
sbcs_d.sbaccess8 = 1'b0;
sbcs_d.sbaccess = (BusWidth == 32'd64) ? 3'd3 : 3'd2;
end

// output multiplexer
Expand Down
27 changes: 20 additions & 7 deletions src/dm_sba.sv
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ module dm_sba #(
unique case (state_q)
dm::Idle: begin
// debugger requested a read
if (sbaddress_write_valid_i && sbreadonaddr_i) state_d = dm::Read;
if (sbaddress_write_valid_i && sbreadonaddr_i) state_d = dm::Read;
// debugger requested a write
if (sbdata_write_valid_i) state_d = dm::Write;
// perform another read
Expand Down Expand Up @@ -140,12 +140,25 @@ module dm_sba #(
default: state_d = dm::Idle; // catch parasitic state
endcase

// handle error case
if (sbaccess_i > 3 && state_q != dm::Idle) begin
req = 1'b0;
state_d = dm::Idle;
sberror_valid_o = 1'b1;
sberror_o = 3'd3;
// check for SBA configuration errors at start of transaction
if (state_q != dm::Idle) begin
// handle unsupported sbaccess value error case (currently only supporting full bus width transfers)
if (!(((sbaccess_i == 3'd2) && (BusWidth == 32'd32)) || ((sbaccess_i == 3'd3) && (BusWidth == 32'd64)))) begin
req = 1'b0;
state_d = dm::Idle;
sberror_valid_o = 1'b1;
sberror_o = 3'd4;
end else begin
// handle misalignment case
if (((sbaccess_i == 3'd1) && (sbaddress_i[0:0] != 1'b0)) ||
((sbaccess_i == 3'd2) && (sbaddress_i[1:0] != 2'b0)) ||
((sbaccess_i == 3'd3) && (sbaddress_i[2:0] != 3'b0))) begin
req = 1'b0;
state_d = dm::Idle;
sberror_valid_o = 1'b1;
sberror_o = 3'd3;
end
end
end
// further error handling should go here ...
end
Expand Down