Skip to content

Commit

Permalink
Introduce separate CMD_IN state
Browse files Browse the repository at this point in the history
  • Loading branch information
cchr-ledger committed Sep 9, 2024
1 parent b71173f commit f61de50
Show file tree
Hide file tree
Showing 2 changed files with 180 additions and 177 deletions.
7 changes: 4 additions & 3 deletions fpga-arch/bsv/SWD.bsv
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ typedef struct {

typedef enum {
IDLE,
CMD_IN,
RESET,
RW
} State deriving (Eq, Bits);
Expand Down Expand Up @@ -97,23 +98,23 @@ module swd_module (ScaffoldSWDModule);
bus_reg_status <= {pack(state == IDLE), 5'b0, pack(status)};
endrule

// Only register writes if we are currently idling
rule do_bus_write ((bus_write == 1) && (state == IDLE));
if (bus_en_wdata == 1) begin
wdata <= shiftInAt0(wdata, bus_write_data);
end

if (bus_en_cmd == 1) begin
cmd <= tagged Valid(unpack(bus_write_data));
state <= CMD_IN;
end
endrule

rule do_ready;
ready <= swd_controller.ready;
endrule

// ONLY do something if there is a valid command registered, and if
// the user is not currently writing to some register.
rule do_idle ((state == IDLE) && (bus_write == 0) && isValid(cmd));
rule do_cmd ((state == CMD_IN) && isValid(cmd));
let new_cmd = fromMaybe(?, cmd);

if (new_cmd.reset == 1) begin
Expand Down
Loading

0 comments on commit f61de50

Please sign in to comment.