OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_73/] [or1ksim/] [mprofiler.c] - Diff between revs 1308 and 1350

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 1308 Rev 1350
Line 28... Line 28...
#include <string.h>
#include <string.h>
#include <stdlib.h>
#include <stdlib.h>
#if HAVE_MALLOC_H
#if HAVE_MALLOC_H
#include <malloc.h>     /* calloc, free */
#include <malloc.h>     /* calloc, free */
#endif
#endif
 
#ifdef HAVE_INTTYPES_H
 
#include <inttypes.h>
 
#endif
 
 
 
#include "port.h"
 
#include "arch.h"
#include "support/profile.h"
#include "support/profile.h"
#include "mprofiler.h"
#include "mprofiler.h"
#include "sim-config.h"
#include "sim-config.h"
 
 
struct memory_hash {
struct memory_hash {
  struct memory_hash *next;
  struct memory_hash *next;
  unsigned long addr;
  oraddr_t addr;
  unsigned long cnt[3];    /* Various counters */
  unsigned long cnt[3];    /* Various counters */
} *hash[HASH_SIZE];
} *hash[HASH_SIZE];
 
 
/* Groups size -- how much addresses should be joined together */
/* Groups size -- how much addresses should be joined together */
int group_bits = 2;
int group_bits = 2;
 
 
/* Start address */
/* Start address */
int start_addr = 0;
oraddr_t start_addr = 0;
 
 
/* End address */
/* End address */
int end_addr = 0xffffffff;
oraddr_t end_addr = 0xffffffff;
 
 
/* File to read from */
/* File to read from */
static FILE *fprof = 0;
static FILE *fprof = 0;
 
 
void mp_help ()
void mp_help ()
Line 63... Line 69...
  PRINTF ("\t-g\t--group bits\t\tgroup 2^bits successive\n");
  PRINTF ("\t-g\t--group bits\t\tgroup 2^bits successive\n");
  PRINTF ("\t\t\t\t\taddresses together [2]\n");
  PRINTF ("\t\t\t\t\taddresses together [2]\n");
  PRINTF ("\t-h\t--help\t\t\toutput this screen\n");
  PRINTF ("\t-h\t--help\t\t\toutput this screen\n");
}
}
 
 
void hash_add (unsigned long addr, int index)
void hash_add (oraddr_t addr, int index)
{
{
  struct memory_hash *h = hash[HASH_FUNC(addr)];
  struct memory_hash *h = hash[HASH_FUNC(addr)];
  while (h && h->addr != addr) h = h->next;
  while (h && h->addr != addr) h = h->next;
 
 
  if (!h) {
  if (!h) {
Line 78... Line 84...
    h->cnt[0] = h->cnt[1] = h->cnt[2] = 0;
    h->cnt[0] = h->cnt[1] = h->cnt[2] = 0;
  }
  }
  h->cnt[index]++;
  h->cnt[index]++;
}
}
 
 
unsigned long hash_get (unsigned long addr, int index)
unsigned long hash_get (oraddr_t addr, int index)
{
{
  struct memory_hash *h = hash[HASH_FUNC(addr)];
  struct memory_hash *h = hash[HASH_FUNC(addr)];
  while (h && h->addr != addr) h = h->next;
  while (h && h->addr != addr) h = h->next;
 
 
  if (!h) return 0;
  if (!h) return 0;
Line 142... Line 148...
  return cnt - 1;
  return cnt - 1;
}
}
 
 
void printout (int mode)
void printout (int mode)
{
{
  unsigned long addr = start_addr & ~((1 << group_bits) - 1);
  oraddr_t addr = start_addr & ~((1 << group_bits) - 1);
  PRINTF ("start = %08x (%08lx); end = %08x; group_bits = %08x\n", start_addr, addr, end_addr, (1 << group_bits) - 1);
  PRINTF ("start = %"PRIxADDR" (%"PRIxADDR"); end = %"PRIxADDR"; group_bits = %08x\n", start_addr, addr, end_addr, (1 << group_bits) - 1);
  for (; addr <= end_addr; addr += (1 << group_bits)) {
  for (; addr <= end_addr; addr += (1 << group_bits)) {
    int i;
    int i;
    unsigned long a = hash_get (addr >> group_bits, 0);
    unsigned long a = hash_get (addr >> group_bits, 0);
    unsigned long b = hash_get (addr >> group_bits, 1);
    unsigned long b = hash_get (addr >> group_bits, 1);
    unsigned long c = hash_get (addr >> group_bits, 2);
    unsigned long c = hash_get (addr >> group_bits, 2);
    PRINTF ("%08lx:", addr);
    PRINTF ("%"PRIxADDR":", addr);
    switch (mode) {
    switch (mode) {
      case MODE_DETAIL:
      case MODE_DETAIL:
        if (a) PRINTF (" %10li R", a);
        if (a) PRINTF (" %10li R", a);
        else PRINTF ("            R");
        else PRINTF ("            R");
        if (b) PRINTF (" %10li W", b);
        if (b) PRINTF (" %10li W", b);

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.