From 0c90d335d2e3c7cf5b8fb5fd70483fcfcd52d234 Mon Sep 17 00:00:00 2001 From: malenov Date: Fri, 24 Nov 2023 08:17:46 +0100 Subject: [PATCH 1/5] assume 32b words for each PROM instruction, report in bytes --- lib_debug/wmc_auto.c | 4 ++-- lib_debug/wmc_auto.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_debug/wmc_auto.c b/lib_debug/wmc_auto.c index 0ff7786f05..db98d7752d 100644 --- a/lib_debug/wmc_auto.c +++ b/lib_debug/wmc_auto.c @@ -1903,8 +1903,8 @@ void print_mem( ROM_Size_Lookup_Table Const_Data_PROM_Table[] ) } else { - /* bytes */ - fprintf( stdout, "Program ROM size (%s): %d bytes\n", Const_Data_PROM_Table[i].file_spec, Const_Data_PROM_Table[i].PROM_size << Stat_Cnt_Size ); + /* bytes (here, we assume that it was measured by the WMC tool as PROM_INST_SIZE bit words) */ + fprintf( stdout, "Program ROM size (%s): %d bytes\n", Const_Data_PROM_Table[i].file_spec, Const_Data_PROM_Table[i].PROM_size << ( PROM_INST_SIZE / 8 ) ); } } diff --git a/lib_debug/wmc_auto.h b/lib_debug/wmc_auto.h index e2f2af4d8f..cbfbb656c6 100644 --- a/lib_debug/wmc_auto.h +++ b/lib_debug/wmc_auto.h @@ -33,10 +33,10 @@ #define INT_MAX 32767 #endif -/* Real-time relationships */ #define FRAMES_PER_SECOND 50.0 #define WMOPS_BOOST_FAC ( 1.0f ) /* scaling factor for equalizing the difference between automatic and manual instrumentation */ #define FAC ( FRAMES_PER_SECOND / 1e6 * WMOPS_BOOST_FAC ) +#define PROM_INST_SIZE 32 /* number of bits of each program instruction when stored in the PROM memory */ #ifdef WMOPS enum instructions -- GitLab From c6f5d66a8f12ea88635a0e5573f7be088014d09a Mon Sep 17 00:00:00 2001 From: malenov Date: Fri, 24 Nov 2023 08:22:53 +0100 Subject: [PATCH 2/5] cleanup in macros --- lib_debug/wmc_auto.c | 2 ++ lib_debug/wmc_auto.h | 34 ++++++++++++++++------------------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lib_debug/wmc_auto.c b/lib_debug/wmc_auto.c index db98d7752d..4bf2fb511e 100644 --- a/lib_debug/wmc_auto.c +++ b/lib_debug/wmc_auto.c @@ -42,6 +42,8 @@ #define MAX_NUM_RECORDS_REALLOC_STEP 50 /* When re-allocating the list of records, increase the number of records by this number */ #define MAX_CALL_TREE_DEPTH 100 /* maximum depth of the function call tree */ #define DOUBLE_MAX 0x80000000 +#define FAC ( FRAMES_PER_SECOND / 1e6 ) + typedef struct { diff --git a/lib_debug/wmc_auto.h b/lib_debug/wmc_auto.h index cbfbb656c6..7a289f8391 100644 --- a/lib_debug/wmc_auto.h +++ b/lib_debug/wmc_auto.h @@ -34,8 +34,6 @@ #endif #define FRAMES_PER_SECOND 50.0 -#define WMOPS_BOOST_FAC ( 1.0f ) /* scaling factor for equalizing the difference between automatic and manual instrumentation */ -#define FAC ( FRAMES_PER_SECOND / 1e6 * WMOPS_BOOST_FAC ) #define PROM_INST_SIZE 32 /* number of bits of each program instruction when stored in the PROM memory */ #ifdef WMOPS @@ -670,24 +668,24 @@ static int wmc_flag_ = 0; #endif /* Define all Macros without '{' & '}' (None of these should be called externally!) */ -#define ABS_( x ) OP_COUNT_( _ABS, ( x ) / WMOPS_BOOST_FAC ) -#define ADD_( x ) OP_COUNT_( _ADD, ( x ) / WMOPS_BOOST_FAC ) -#define MULT_( x ) OP_COUNT_( _MULT, ( x ) / WMOPS_BOOST_FAC ) -#define MAC_( x ) OP_COUNT_( _MAC, ( x ) / WMOPS_BOOST_FAC ) -#define MOVE_( x ) OP_COUNT_( _MOVE, ( x ) / WMOPS_BOOST_FAC ) -#define STORE_( x ) OP_COUNT_( _STORE, ( x ) / WMOPS_BOOST_FAC ) -#define LOGIC_( x ) OP_COUNT_( _LOGIC, ( x ) / WMOPS_BOOST_FAC ) -#define SHIFT_( x ) OP_COUNT_( _SHIFT, ( x ) / WMOPS_BOOST_FAC ) -#define BRANCH_( x ) OP_COUNT_( _BRANCH, ( x ) / WMOPS_BOOST_FAC ) -#define DIV_( x ) OP_COUNT_( _DIV, ( x ) / WMOPS_BOOST_FAC ) -#define SQRT_( x ) OP_COUNT_( _SQRT, ( x ) / WMOPS_BOOST_FAC ) -#define TRANS_( x ) OP_COUNT_( _TRANS, ( x ) / WMOPS_BOOST_FAC ) +#define ABS_( x ) OP_COUNT_( _ABS, ( x ) ) +#define ADD_( x ) OP_COUNT_( _ADD, ( x ) ) +#define MULT_( x ) OP_COUNT_( _MULT, ( x ) ) +#define MAC_( x ) OP_COUNT_( _MAC, ( x ) ) +#define MOVE_( x ) OP_COUNT_( _MOVE, ( x ) ) +#define STORE_( x ) OP_COUNT_( _STORE, ( x ) ) +#define LOGIC_( x ) OP_COUNT_( _LOGIC, ( x ) ) +#define SHIFT_( x ) OP_COUNT_( _SHIFT, ( x ) ) +#define BRANCH_( x ) OP_COUNT_( _BRANCH, ( x ) ) +#define DIV_( x ) OP_COUNT_( _DIV, ( x ) ) +#define SQRT_( x ) OP_COUNT_( _SQRT, ( x ) ) +#define TRANS_( x ) OP_COUNT_( _TRANS, ( x ) ) #define POWER_( x ) TRANS_( x ) #define LOG_( x ) TRANS_( x ) -#define LOOP_( x ) OP_COUNT_( _LOOP, ( x ) / WMOPS_BOOST_FAC ) -#define INDIRECT_( x ) OP_COUNT_( _INDIRECT, ( x ) / WMOPS_BOOST_FAC ) -#define PTR_INIT_( x ) OP_COUNT_( _PTR_INIT, ( x ) / WMOPS_BOOST_FAC ) -#define FUNC_( x ) ( OP_COUNT_( _MOVE, ( x ) / WMOPS_BOOST_FAC ), OP_COUNT_( _FUNC, 1 ) ) +#define LOOP_( x ) OP_COUNT_( _LOOP, ( x ) ) +#define INDIRECT_( x ) OP_COUNT_( _INDIRECT, ( x ) ) +#define PTR_INIT_( x ) OP_COUNT_( _PTR_INIT, ( x ) ) +#define FUNC_( x ) ( OP_COUNT_( _MOVE, ( x ) ), OP_COUNT_( _FUNC, 1 ) ) #define MISC_( x ) ABS_( x ) /* Math Operations */ -- GitLab From 24cc56ba6f18a8267e5d41929a8a43e446ff2d5c Mon Sep 17 00:00:00 2001 From: malenov Date: Mon, 27 Nov 2023 10:50:23 +0100 Subject: [PATCH 3/5] fix 32b ->8b PROM conversion --- lib_debug/wmc_auto.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_debug/wmc_auto.c b/lib_debug/wmc_auto.c index 4bf2fb511e..8769c9747a 100644 --- a/lib_debug/wmc_auto.c +++ b/lib_debug/wmc_auto.c @@ -1905,8 +1905,8 @@ void print_mem( ROM_Size_Lookup_Table Const_Data_PROM_Table[] ) } else { - /* bytes (here, we assume that it was measured by the WMC tool as PROM_INST_SIZE bit words) */ - fprintf( stdout, "Program ROM size (%s): %d bytes\n", Const_Data_PROM_Table[i].file_spec, Const_Data_PROM_Table[i].PROM_size << ( PROM_INST_SIZE / 8 ) ); + /* bytes (here, we assume that each instruction takes PROM_INST_SIZE bits of the PROM memory) */ + fprintf( stdout, "Program ROM size (%s): %d bytes\n", Const_Data_PROM_Table[i].file_spec, Const_Data_PROM_Table[i].PROM_size * ( PROM_INST_SIZE / 8 ) ); } } -- GitLab From ea40491f7b6cc97653c07516ae3c4a2ccb56071d Mon Sep 17 00:00:00 2001 From: malenov Date: Mon, 27 Nov 2023 16:29:40 +0100 Subject: [PATCH 4/5] improve the printout --- lib_debug/wmc_auto.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib_debug/wmc_auto.c b/lib_debug/wmc_auto.c index 8769c9747a..52e4bbf8bb 100644 --- a/lib_debug/wmc_auto.c +++ b/lib_debug/wmc_auto.c @@ -1996,10 +1996,15 @@ void print_mem( ROM_Size_Lookup_Table Const_Data_PROM_Table[] ) mem_count_summary(); #endif - if ( Stat_Cnt_Size == 0 ) + if ( Stat_Cnt_Size > 0 ) + { + /* words */ + fprintf( stdout, "\nNote: The Program ROM size is calculated under the assumption that 1 instruction word is stored with %d bits\n", 8 << Stat_Cnt_Size ); + } + else { /* bytes */ - fprintf( stdout, "\nNote: The Program ROM size is calculated under the assumption that 1 instruction word is stored with %d bytes (%d bits)\n", 1 << Stat_Cnt_Size, 8 << Stat_Cnt_Size ); + fprintf( stdout, "\nNote: The Program ROM size is calculated under the assumption that 1 instruction word is stored with %d bits\n", 32 ); } fprintf( stdout, "Note: The Data ROM size is calculated using the sizeof(type) built-in function\n" ); -- GitLab From e184c67c15ee0c71c491bd0ca6fb0d18c98c40d8 Mon Sep 17 00:00:00 2001 From: malenov Date: Tue, 28 Nov 2023 09:46:34 +0100 Subject: [PATCH 5/5] small change in the printed message --- lib_debug/wmc_auto.c | 2 +- lib_debug/wmc_auto.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_debug/wmc_auto.c b/lib_debug/wmc_auto.c index 52e4bbf8bb..6ddebc5a78 100644 --- a/lib_debug/wmc_auto.c +++ b/lib_debug/wmc_auto.c @@ -2004,7 +2004,7 @@ void print_mem( ROM_Size_Lookup_Table Const_Data_PROM_Table[] ) else { /* bytes */ - fprintf( stdout, "\nNote: The Program ROM size is calculated under the assumption that 1 instruction word is stored with %d bits\n", 32 ); + fprintf( stdout, "\nNote: The Program ROM size is calculated under the assumption that 1 instruction word is stored with %d bits\n", PROM_INST_SIZE ); } fprintf( stdout, "Note: The Data ROM size is calculated using the sizeof(type) built-in function\n" ); diff --git a/lib_debug/wmc_auto.h b/lib_debug/wmc_auto.h index 7a289f8391..5670f90722 100644 --- a/lib_debug/wmc_auto.h +++ b/lib_debug/wmc_auto.h @@ -34,7 +34,7 @@ #endif #define FRAMES_PER_SECOND 50.0 -#define PROM_INST_SIZE 32 /* number of bits of each program instruction when stored in the PROM memory */ +#define PROM_INST_SIZE 32 /* number of bits of each program instruction when stored in the PROM memory (applied only when the user selects reporting in bytes) */ #ifdef WMOPS enum instructions -- GitLab