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

PoC: Implement syscalls using PicoRV32 interrupts #305

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
Draft
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
25 changes: 19 additions & 6 deletions hw/application_fpga/core/tk1/rtl/tk1.v
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ module tk1 #(
localparam FW_RAM_FIRST = 32'hd0000000;
localparam FW_RAM_LAST = 32'hd00007ff;

localparam FW_ROM_LAST = 32'h00001fff;

//----------------------------------------------------------------
// Registers including update variables and write enable.
Expand All @@ -115,6 +116,7 @@ module tk1 #(
reg cdi_mem_we;

reg system_mode_reg;
reg system_mode_new;
reg system_mode_we;

reg [ 2 : 0] led_reg;
Expand Down Expand Up @@ -291,7 +293,7 @@ module tk1 #(
gpio2_reg[1] <= gpio2_reg[0];

if (system_mode_we) begin
system_mode_reg <= 1'h1;
system_mode_reg <= system_mode_new;
Copy link
Member

Choose a reason for hiding this comment

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

I think we should keep system_mode_reg <= 1'h1;

Then we can remove system_mode_new completely. Since what I can see we never return to system_mode_reg = 0.

end

if (led_we) begin
Expand Down Expand Up @@ -412,12 +414,27 @@ module tk1 #(
end
end

//----------------------------------------------------------------
// system_mode_ctrl
//
// Automatically lower privilege when executing above ROM.
// ----------------------------------------------------------------
always @* begin : system_mode_ctrl
system_mode_new = 1'h0;
system_mode_we = 1'h0;

if (cpu_valid & cpu_instr) begin
if (cpu_addr > FW_ROM_LAST) begin
system_mode_new = 1'h1;
system_mode_we = 1'h1;
end
end
end

//----------------------------------------------------------------
// api
//----------------------------------------------------------------
always @* begin : api
system_mode_we = 1'h0;
led_we = 1'h0;
gpio3_we = 1'h0;
gpio4_we = 1'h0;
Expand All @@ -444,10 +461,6 @@ module tk1 #(
if (cs) begin
tmp_ready = 1'h1;
if (we) begin
if (address == ADDR_SYSTEM_MODE_CTRL) begin
system_mode_we = 1'h1;
end

if (address == ADDR_LED) begin
led_we = 1'h1;
end
Expand Down