From 3e5a998a2cb380d90615b524b5e41c671ab8004d Mon Sep 17 00:00:00 2001 From: Julian Blake Kongslie Date: Sun, 29 May 2022 16:38:00 -0700 Subject: Add support for bulk memory dumping to command parser. --- hdl/result_printer.sv | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) (limited to 'hdl/result_printer.sv') diff --git a/hdl/result_printer.sv b/hdl/result_printer.sv index 6e1bd53..322fac0 100644 --- a/hdl/result_printer.sv +++ b/hdl/result_printer.sv @@ -11,15 +11,21 @@ module result_printer , input bit echo_ready , output bit echo_valid , output uart_byte_t echo_data + + , output bit loop_ready + , input bit loop_valid + , input bit loop_data ); bit hold_valid; ram_read_response_t hold; + bit loop; ram_byte_count_t byte_count; ram_word_count_t word_count; (* syn_encoding = "one-hot" *) enum int unsigned - { HIGH_NIBBLE + { EQUALS_SIGN + , HIGH_NIBBLE , LOW_NIBBLE , WORD_SEPARATOR } state; @@ -29,12 +35,16 @@ module result_printer result_ready = 0; echo_valid = 0; echo_data = 0; + loop_ready = 0; hold_valid = 0; + loop = 0; byte_count = 0; word_count = 0; state = state.first; end else begin if (echo_ready) echo_valid = 0; + if (loop_ready && loop_valid) + loop = loop_data; if (result_ready && result_valid) begin hold_valid = 1; hold = result_data; @@ -48,35 +58,44 @@ module result_printer automatic ram_word_t w = hold.data[word_count-1]; automatic ram_byte_t b = w[byte_count-1]; echo_valid = 1; + if (state == EQUALS_SIGN && !loop) + state = state.next; case (state) + EQUALS_SIGN: echo_data = "="; HIGH_NIBBLE: echo_data = b[7:4]; LOW_NIBBLE: echo_data = b[3:0]; WORD_SEPARATOR: echo_data = ":"; endcase - if (state != WORD_SEPARATOR) begin + if (state == HIGH_NIBBLE || state == LOW_NIBBLE) begin if (echo_data < 10) echo_data = echo_data + "0"; else echo_data = echo_data + "A" - 10; end - state = state.next; - if (state == WORD_SEPARATOR && (byte_count != 1 || word_count == 1)) - state = state.next; - if (state == state.first) begin - byte_count = byte_count - 1; - if (byte_count == 0) begin + if (state == LOW_NIBBLE) begin + if (byte_count == 1) begin byte_count = `RAM_WORD_BYTES; word_count = word_count - 1; + state = state.next; + end else begin + byte_count = byte_count - 1; + state = HIGH_NIBBLE; end + end else begin + state = state.next; end end else begin echo_valid = 1; - echo_data = "\n"; + if (loop && hold.address[3:0] != 'hf) + echo_data = " "; + else + echo_data = "\n"; hold_valid = 0; end end result_ready = !hold_valid; + loop_ready = 1; end end -- cgit v1.2.3