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

Subversion Repositories t48

[/] [t48/] [tags/] [rel_1_2/] [sw/] [i8039emu/] [main.c] - Blame information for rev 300

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 49 arniml
/*
2 295 arniml
 * $Id: main.c 295 2009-04-01 19:32:48Z arniml $
3 49 arniml
 *
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 123 arniml
#include <string.h>
28 49 arniml
 
29
#include "types.h"
30
#include "memory.h"
31
#include "i8039.h"
32
 
33
 
34
void logerror(char *msg, UINT16 address, UINT8 opcode)
35
{
36
}
37
 
38
 
39
void print_usage(void) {
40
  printf("Usage:\n");
41 123 arniml
  printf(" i8039 -f <hex file> [-x <hex file>] [-d] [-h]\n");
42
  printf("  -f : Name of hex file for internal ROM\n");
43
  printf("  -x : Name of hex file for external ROM (optional)\n");
44 49 arniml
  printf("  -d : Dump machine state\n");
45
  printf("  -h : Print this help\n");
46
}
47
 
48
 
49
int main(int argc, char *argv[])
50
{
51
  int  do_cycles, real_cycles, total_cycles;
52
  char *hex_file = "";
53 123 arniml
  char *ext_hex_file = "";
54 49 arniml
  int  c;
55
  int  dump = 0;
56
 
57
  /* process options */
58 123 arniml
  while ((c = getopt(argc, argv, "df:hx:")) != -1) {
59 49 arniml
    switch (c) {
60
      case 'd':
61
        dump = 1;
62
        break;
63
 
64
      case 'f':
65
        hex_file = optarg;
66
        break;
67
 
68 123 arniml
      case 'x':
69
        ext_hex_file = optarg;
70
        break;
71
 
72 49 arniml
      case 'h':
73
        /* fallthrough */
74
 
75
      default:
76
        print_usage();
77
        return(0);
78
        break;
79
    }
80
  }
81
 
82
  /* check options */
83
  if (strlen(hex_file) == 0) {
84
    print_usage();
85
    return(1);
86
  }
87
 
88 123 arniml
  /* read hex file for internal ROM */
89 49 arniml
  printf("Reading %s\n", hex_file);
90 123 arniml
  if (!read_hex_file(hex_file, 0)) {
91 49 arniml
    printf("Error reading file!\n");
92
    return(1);
93
  }
94
 
95 123 arniml
  /* read hex fiel for external ROM */
96
  if (strlen(ext_hex_file) > 0) {
97
    printf("Reading %s\n", ext_hex_file);
98
    if (!read_hex_file(ext_hex_file, 0x800)) {
99
      printf("Error reading file!\n");
100
      return(1);
101
    }
102
  }
103
 
104 49 arniml
  printf("Resetting 8039\n");
105
  i8039_reset(NULL);
106
 
107 58 arniml
  do_cycles = 52;
108 49 arniml
 
109
  total_cycles = 0;
110
 
111
  do {
112
    real_cycles = i8039_execute(do_cycles, dump);
113
 
114 58 arniml
    /* activate interrupt */
115
    set_irq_line(0, HOLD_LINE);
116
    /* hold interrupt for 3 machine cycles */
117
    real_cycles += i8039_execute(3, dump);
118
    set_irq_line(0, CLEAR_LINE);
119
 
120 49 arniml
    if (real_cycles > 0)
121
      total_cycles += real_cycles;
122
  } while (real_cycles > 0);
123
 
124
  printf("Emulated %i cycles\n", total_cycles);
125
  printf("Simulation Result: %s\n", real_cycles == 0 ? "PASS" : "FAIL");
126
 
127
  return(0);
128
}

powered by: WebSVN 2.1.0

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