Skip to content

Commit

Permalink
New: Drive aprot[0] based on current priviledge mode
Browse files Browse the repository at this point in the history
  • Loading branch information
dpretet committed Nov 21, 2023
1 parent fcf3db2 commit 8f3bdc3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
4 changes: 3 additions & 1 deletion rtl/friscv_control.sv
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ module friscv_control
logic ecall_umode;
logic ecall_mmode;
logic [2 -1:0] priv_mode;
logic priv_bit;
logic [2 -1:0] mpp;
logic load_access_fault;
logic store_access_fault;
Expand Down Expand Up @@ -1057,7 +1058,8 @@ module friscv_control
// [0] Unprivileged or privileged
// [1] Secure or Non-secure
// [2] Instruction or data
assign arprot = 3'b100;
assign priv_bit = (priv_mode==`MMODE);
assign arprot = {2'b10, priv_bit};

// Needs to jump or branch, the request to cache/RAM needs to be restarted
assign jump_branch = (branching & goto_branch) | jalr;
Expand Down
16 changes: 12 additions & 4 deletions rtl/friscv_memfy.sv
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ module friscv_memfy
logic [`PRIV_W -1:0] priv;
logic [`PRIV_W -1:0] mpp;
logic mprv;
logic priv_bit;
logic [3 -1:0] aprot;

// read response channel
logic push_rd_or;
Expand Down Expand Up @@ -231,6 +233,8 @@ module friscv_memfy
awaddr <= {AXI_ADDR_W{1'b0}};
awcache <= 4'b0;
awvalid <= 1'b0;
awprot <= '0;
arprot <= '0;
wvalid <= 1'b0;
wdata <= {XLEN{1'b0}};
wstrb <= {XLEN/8{1'b0}};
Expand All @@ -243,6 +247,8 @@ module friscv_memfy
end else if (srst == 1'b1) begin
awaddr <= {AXI_ADDR_W{1'b0}};
awvalid <= 1'b0;
awprot <= '0;
arprot <= '0;
wvalid <= 1'b0;
wdata <= {XLEN{1'b0}};
wstrb <= {XLEN/8{1'b0}};
Expand Down Expand Up @@ -292,6 +298,8 @@ module friscv_memfy
araddr <= addr;
awcache <= acache;
arcache <= acache;
awprot <= aprot;
arprot <= aprot;

opcode_r <= opcode;

Expand Down Expand Up @@ -371,8 +379,8 @@ module friscv_memfy

// Wait until addr and data have been acknowledged
if (awready && wready || // addr & data channel acked on same cycle
~awvalid && wready || // addr has been acked before data
awready && ~wvalid // addr is acked and data has been acked before
!awvalid && wready || // addr has been acked before data
awready && !wvalid // addr is acked and data has been acked before
) begin
memfy_ready_fsm <= 1'b1;
state <= IDLE;
Expand Down Expand Up @@ -687,8 +695,8 @@ module friscv_memfy
// [0] Unprivileged or privileged
// [1] Secure or Non-secure
// [2] Instruction or data
assign awprot = 3'b000;
assign arprot = 3'b000;
assign priv_bit = (priv == `MMODE);
assign aprot = {2'b00, priv_bit};

// Completion are always accepted
assign bready = 1'b1;
Expand Down

0 comments on commit 8f3bdc3

Please sign in to comment.