From 70be5e5d83e61bb8ed2d00c9854c1847fdc7e97f Mon Sep 17 00:00:00 2001 From: Julian Blake Kongslie Date: Fri, 18 Mar 2022 08:55:20 -0700 Subject: Ignore colons on inputs; use them to separate words in output. --- hdl/command_parser.sv | 12 +++++++++--- hdl/result_printer.sv | 14 ++++++++++---- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/hdl/command_parser.sv b/hdl/command_parser.sv index cf4fe65..964ac12 100644 --- a/hdl/command_parser.sv +++ b/hdl/command_parser.sv @@ -91,7 +91,9 @@ module command_parser end READ_ADDRESS: if (input_byte_valid) begin - if (input_byte >= "0" && input_byte <= "9") begin + if (input_byte == ":") begin + // ignore + end else if (input_byte >= "0" && input_byte <= "9") begin command_data.address = command_data.address << 4; command_data.address[$clog2(`RAM_LINE_WORDS)+:4] = input_byte - "0"; end else if (input_byte >= "a" && input_byte <= "f") begin @@ -109,7 +111,9 @@ module command_parser READ_DATA: if (input_byte_valid) begin automatic bit [$bits(command_data.data)-1:0] flat_data = command_data.data; flat_data = flat_data << 4; - if (input_byte >= "0" && input_byte <= "9") begin + if (input_byte == ":") begin + // ignore + end else if (input_byte >= "0" && input_byte <= "9") begin flat_data[3:0] = input_byte - "0"; command_data.data = flat_data; end else if (input_byte >= "a" && input_byte <= "f") begin @@ -126,7 +130,9 @@ module command_parser end READ_ZERO_COUNT: if (input_byte_valid) begin - if (input_byte >= "0" && input_byte <= "9") begin + if (input_byte == ":") begin + // ignore + end else if (input_byte >= "0" && input_byte <= "9") begin zero_count = zero_count << 4; zero_count[3:0] = input_byte - "0"; end else if (input_byte >= "a" && input_byte <= "f") begin diff --git a/hdl/result_printer.sv b/hdl/result_printer.sv index 4f27d0e..6e1bd53 100644 --- a/hdl/result_printer.sv +++ b/hdl/result_printer.sv @@ -21,6 +21,7 @@ module result_printer (* syn_encoding = "one-hot" *) enum int unsigned { HIGH_NIBBLE , LOW_NIBBLE + , WORD_SEPARATOR } state; always @(posedge clock) begin @@ -50,12 +51,17 @@ module result_printer case (state) HIGH_NIBBLE: echo_data = b[7:4]; LOW_NIBBLE: echo_data = b[3:0]; + WORD_SEPARATOR: echo_data = ":"; endcase - if (echo_data < 10) - echo_data = echo_data + "0"; - else - echo_data = echo_data + "A" - 10; + if (state != WORD_SEPARATOR) 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 -- cgit v1.2.3