Skip to content

Fix reading and writing to mtimeh/mtimecmph on 64b Fabrics #15

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
Changes from 1 commit
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
Prev Previous commit
Fix writing to mtimeh/mtimecmph on 64b Fabrics
Example:
li  s0, (CLINT_BASE + MTIMECMPH_OFFSET) // 0x_xxxx_4004
sw t0, 4(s0)

MMU_Cache.fn_to_fabric_write_fields composes a 64-bit wdata assuming the waddr
is always gonna be 64-bit aligned, and thus puts the requested_wdata in the
upper 4-bytes of word64 with the corresponding 0xf0 strobe.

mkNear_Mem_IO.rl_process_wr_req however, handles writes to 0xxxx_bffc/0xxxx_4004,
expecting the wdata to contain the value in the LSB (lower 4 bytes).

The commit fixes mkNear_Mem_IO.rl_process_wr_req to handle "SW" writes on 64b fabrics
by extracting the upper 4-bytes set by MMU_Cache.fn_to_fabric_write_fields.
  • Loading branch information
heshamelmatary committed Mar 17, 2019
commit 517b2c628f3780b3cc5905babe94c91f04e49b96
35 changes: 27 additions & 8 deletions src_Core/Near_Mem_VM/Near_Mem_IO.bsv
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import ByteLane :: *;
// ================================================================
// Project imports

// None
import Fabric_Defs :: *;

// ================================================================
// Local constants and types
Expand Down Expand Up @@ -310,13 +310,22 @@ module mkNear_Mem_IO (Near_Mem_IO_IFC);
end
end

// The following ALIGN4B writes are only needed for 32b fabrics
'h_0004: noAction;
'h_4004: begin
Bit #(64) old_timecmp = crg_timecmp [1];
Bit #(64) new_timecmp = fn_update_strobed_bytes (old_timecmp,
{ req.wdata [31:0], 32'h0 },
{ req.wstrb [3:0], 4'h0 });
Bit #(64) new_timecmp;

// The following ALIGN4B writes are only needed for 32b fabrics
if (valueOf (Wd_Data) == 32)
new_timecmp = fn_update_strobed_bytes (old_timecmp,
{ req.wdata [31:0], 32'h0},
{ req.wstrb [3:0], 4'h0});
// The following writes are needed on 64b fabrics
else
new_timecmp = fn_update_strobed_bytes (old_timecmp,
{ req.wdata [63:0]},
{ req.wstrb [7:4], 4'h0});

crg_timecmp [1] <= new_timecmp;

if (cfg_verbosity > 1) begin
Expand All @@ -329,9 +338,19 @@ module mkNear_Mem_IO (Near_Mem_IO_IFC);
end
'h_BFFC: begin
Bit #(64) old_time = crg_time [1];
Bit #(64) new_time = fn_update_strobed_bytes (old_time,
{ req.wdata [31:0], 32'h0 },
{ req.wstrb [3:0], 4'h0 });
Bit #(64) new_time;

// The following ALIGN4B writes are only needed for 32b fabrics
if (valueOf (Wd_Data) == 32)
new_time = fn_update_strobed_bytes (old_time,
{ req.wdata [31:0], 32'h0},
{ req.wstrb [3:0], 4'h0});
// The following writes are needed on 64b fabrics
else
new_time = fn_update_strobed_bytes (old_time,
{ req.wdata [63:0]},
{ req.wstrb [7:4], 4'h0});

crg_time [1] <= new_time;

if (cfg_verbosity > 1) begin
Expand Down