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

Subversion Repositories t48

[/] [t48/] [tags/] [rel_0_6__beta/] [sw/] [i8039emu/] [main.c] - Blame information for rev 49

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 49 arniml
/*
2
 * $Id: main.c,v 1.1.1.1 2004-04-09 19:20:54 arniml Exp $
3
 *
4
 * Copyright (c) 2004, Arnim Laeuger (arniml@opencores.org)
5
 *
6
 * All rights reserved
7
 *
8
 *  This program is free software; you can redistribute it and/or modify
9
 *  it under the terms of the GNU General Public License as published by
10
 *  the Free Software Foundation; either version 2 of the License, or
11
 *  (at your option) any later version. See also the file COPYING which
12
 *  came with this application.
13
 *
14
 *  This program is distributed in the hope that it will be useful,
15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 *  GNU General Public License for more details.
18
 *
19
 *  You should have received a copy of the GNU General Public License
20
 *  along with this program; if not, write to the Free Software
21
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22
 *
23
 */
24
 
25
#include <stdio.h>
26
#include <unistd.h>
27
 
28
#include "types.h"
29
#include "memory.h"
30
#include "i8039.h"
31
 
32
 
33
void logerror(char *msg, UINT16 address, UINT8 opcode)
34
{
35
}
36
 
37
 
38
void print_usage(void) {
39
  printf("Usage:\n");
40
  printf(" i8039 -f <hex file> [-d] [-h]\n");
41
  printf("  -f : Name of hex file\n");
42
  printf("  -d : Dump machine state\n");
43
  printf("  -h : Print this help\n");
44
}
45
 
46
 
47
int main(int argc, char *argv[])
48
{
49
  int  do_cycles, real_cycles, total_cycles;
50
  char *hex_file = "";
51
  int  c;
52
  int  dump = 0;
53
 
54
  /* process options */
55
  while ((c = getopt(argc, argv, "df:h")) != -1) {
56
    switch (c) {
57
      case 'd':
58
        dump = 1;
59
        break;
60
 
61
      case 'f':
62
        hex_file = optarg;
63
        break;
64
 
65
      case 'h':
66
        /* fallthrough */
67
 
68
      default:
69
        print_usage();
70
        return(0);
71
        break;
72
    }
73
  }
74
 
75
  /* check options */
76
  if (strlen(hex_file) == 0) {
77
    print_usage();
78
    return(1);
79
  }
80
 
81
  printf("Reading %s\n", hex_file);
82
  if (!read_hex_file(hex_file)) {
83
    printf("Error reading file!\n");
84
    return(1);
85
  }
86
 
87
  printf("Resetting 8039\n");
88
  i8039_reset(NULL);
89
 
90
  do_cycles = 128;
91
 
92
  total_cycles = 0;
93
 
94
  do {
95
    real_cycles = i8039_execute(do_cycles, dump);
96
 
97
    if (real_cycles > 0)
98
      total_cycles += real_cycles;
99
  } while (real_cycles > 0);
100
 
101
  printf("Emulated %i cycles\n", total_cycles);
102
  printf("Simulation Result: %s\n", real_cycles == 0 ? "PASS" : "FAIL");
103
 
104
  return(0);
105
}

powered by: WebSVN 2.1.0

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