From 8953fe2731eb24845a4bebd10695f92a98b383b5 Mon Sep 17 00:00:00 2001 From: Peter Lawrence Date: Sun, 13 Dec 2020 15:46:00 -0600 Subject: [PATCH 1/2] remedy endless feedback loop --- src/dm_mem.sv | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/src/dm_mem.sv b/src/dm_mem.sv index 178259f..5e2a796 100755 --- a/src/dm_mem.sv +++ b/src/dm_mem.sv @@ -132,18 +132,41 @@ module dm_mem #( typedef enum logic [1:0] { Idle, Go, Resume, CmdExecuting } state_e; state_e state_d, state_q; + // hart state decode + always_comb begin : p_state_decode + go = 1'b0; + resume = 1'b0; + cmdbusy_o = 1'b1; + + unique case (state_q) + Idle: begin + cmdbusy_o = 1'b0; + end + Go: begin + // we are already busy here since we scheduled the execution of a program + cmdbusy_o = 1'b1; + go = 1'b1; + end + Resume: begin + cmdbusy_o = 1'b1; + resume = 1'b1; + end + CmdExecuting: begin + cmdbusy_o = 1'b1; + go = 1'b0; + end + default: ; + endcase + end + // hart ctrl queue always_comb begin : p_hart_ctrl_queue cmderror_valid_o = 1'b0; cmderror_o = dm::CmdErrNone; state_d = state_q; - go = 1'b0; - resume = 1'b0; - cmdbusy_o = 1'b1; unique case (state_q) Idle: begin - cmdbusy_o = 1'b0; if (cmd_valid_i && halted_q_aligned[hartsel] && !unsupported_command) begin // give the go signal state_d = Go; @@ -161,9 +184,6 @@ module dm_mem #( end Go: begin - // we are already busy here since we scheduled the execution of a program - cmdbusy_o = 1'b1; - go = 1'b1; // the thread is now executing the command, track its state if (going) begin state_d = CmdExecuting; @@ -171,16 +191,12 @@ module dm_mem #( end Resume: begin - cmdbusy_o = 1'b1; - resume = 1'b1; if (resuming_q_aligned[hartsel]) begin state_d = Idle; end end CmdExecuting: begin - cmdbusy_o = 1'b1; - go = 1'b0; // wait until the hart has halted again if (halted_aligned[hartsel]) begin state_d = Idle; From 4a3b7862056dbdeeabaedfae29de1c478ab199ab Mon Sep 17 00:00:00 2001 From: Peter Lawrence Date: Sun, 28 Feb 2021 16:38:03 -0600 Subject: [PATCH 2/2] alternate remedy for endless feedback loop --- src/dm_mem.sv | 46 ++++++++++++++++++---------------------------- 1 file changed, 18 insertions(+), 28 deletions(-) mode change 100755 => 100644 src/dm_mem.sv diff --git a/src/dm_mem.sv b/src/dm_mem.sv old mode 100755 new mode 100644 index 5e2a796..b83de45 --- a/src/dm_mem.sv +++ b/src/dm_mem.sv @@ -132,33 +132,6 @@ module dm_mem #( typedef enum logic [1:0] { Idle, Go, Resume, CmdExecuting } state_e; state_e state_d, state_q; - // hart state decode - always_comb begin : p_state_decode - go = 1'b0; - resume = 1'b0; - cmdbusy_o = 1'b1; - - unique case (state_q) - Idle: begin - cmdbusy_o = 1'b0; - end - Go: begin - // we are already busy here since we scheduled the execution of a program - cmdbusy_o = 1'b1; - go = 1'b1; - end - Resume: begin - cmdbusy_o = 1'b1; - resume = 1'b1; - end - CmdExecuting: begin - cmdbusy_o = 1'b1; - go = 1'b0; - end - default: ; - endcase - end - // hart ctrl queue always_comb begin : p_hart_ctrl_queue cmderror_valid_o = 1'b0; @@ -167,6 +140,9 @@ module dm_mem #( unique case (state_q) Idle: begin + cmdbusy_o = 1'b0; + go = 1'b0; + resume = 1'b0; if (cmd_valid_i && halted_q_aligned[hartsel] && !unsupported_command) begin // give the go signal state_d = Go; @@ -184,6 +160,10 @@ module dm_mem #( end Go: begin + // we are already busy here since we scheduled the execution of a program + cmdbusy_o = 1'b1; + go = 1'b1; + resume = 1'b0; // the thread is now executing the command, track its state if (going) begin state_d = CmdExecuting; @@ -191,19 +171,29 @@ module dm_mem #( end Resume: begin + cmdbusy_o = 1'b1; + go = 1'b0; + resume = 1'b1; if (resuming_q_aligned[hartsel]) begin state_d = Idle; end end CmdExecuting: begin + cmdbusy_o = 1'b1; + go = 1'b0; + resume = 1'b0; // wait until the hart has halted again if (halted_aligned[hartsel]) begin state_d = Idle; end end - default: ; + default: begin + cmdbusy_o = 1'b1; + go = 1'b0; + resume = 1'b0; + end endcase // only signal once that cmd is unsupported so that we can clear cmderr