Skip to content

Commit

Permalink
Merge pull request #876 from en-sc/en-sc/gen-printers
Browse files Browse the repository at this point in the history
Address review comments on `debug_defines.h`
  • Loading branch information
timsifive authored Sep 19, 2023
2 parents 0b80f88 + 2cd44e5 commit f546ddf
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ There are two other interesting make targets:
1. `make debug_defines` creates a C header and implementation files containing
constants for addresses and fields of all the registers and abstract
commands, as well as function and structures used to decode register values.
An implementation of such decoder can be seen in `debug_register_printers.c/h`.
An implementation of such decoder can be seen in `debug_reg_printer.c/h`.
2. `make chisel` creates scala files for DM registers and abstract commands
with the same information.

Expand Down
8 changes: 4 additions & 4 deletions debug_register_printers.c → debug_reg_printer.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <assert.h>
#include <stdarg.h>

#include "debug_register_printers.h"
#include "debug_reg_printer.h"

static unsigned int get_len_or_sprintf(char *buf, unsigned int curr, const char *format, ...)
{
Expand All @@ -23,7 +23,7 @@ static unsigned int get_len_or_sprintf(char *buf, unsigned int curr, const char
return (unsigned int)length;
}

static unsigned int print_value(char *buf, unsigned int offset, uint64_t value)
static unsigned int print_number(char *buf, unsigned int offset, uint64_t value)
{
const char * const format = value > 9 ? "0x%" PRIx64 : "%" PRIx64;

Expand All @@ -38,7 +38,7 @@ static unsigned int riscv_debug_reg_field_value_to_s(char *buf, unsigned int off
NULL;

if (!field_value_name)
return print_value(buf, offset, field_value);
return print_number(buf, offset, field_value);
return get_len_or_sprintf(buf, offset, "%s", field_value_name);
}

Expand Down Expand Up @@ -82,7 +82,7 @@ unsigned int riscv_debug_reg_to_s(char *buf, enum riscv_debug_reg_ordinal reg_or
riscv_debug_reg_info_t reg = get_riscv_debug_reg_info(reg_ordinal);

length += get_len_or_sprintf(buf, length, "%s=", reg.name);
length += print_value(buf, length, value);
length += print_number(buf, length, value);

if (reg.get_fields_head)
length += riscv_debug_reg_fields_to_s(buf, length, reg.get_fields_head(context),
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion registers.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def getter(f, getter_name, next_getter_name):
syms = f.symbols()
all_valid = ' && '.join(map(is_valid, syms))
field = f.c_info(to_c).replace('\n', '\n\t\t')
return (f"riscv_debug_reg_field_list_t {getter_name}(riscv_debug_reg_ctx_t context)\n" +
return (f"static riscv_debug_reg_field_list_t {getter_name}(riscv_debug_reg_ctx_t context)\n" +
"{\n\t" +
add_indent((f"assert({all_valid});\n" if syms else "") +
f"riscv_debug_reg_field_list_t result = {{\n" +
Expand Down

0 comments on commit f546ddf

Please sign in to comment.