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

Subversion Repositories tv80

[/] [tv80/] [trunk/] [tests/] [tv80_env.h] - Blame information for rev 102

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

Line No. Rev Author Line
1 72 ghutchis
//
2
// Copyright (c) 2005 Guy Hutchison (ghutchis@opencores.org)
3
//
4
// Permission is hereby granted, free of charge, to any person obtaining a 
5
// copy of this software and associated documentation files (the "Software"), 
6
// to deal in the Software without restriction, including without limitation 
7
// the rights to use, copy, modify, merge, publish, distribute, sublicense, 
8
// and/or sell copies of the Software, and to permit persons to whom the 
9
// Software is furnished to do so, subject to the following conditions:
10
//
11
// The above copyright notice and this permission notice shall be included 
12
// in all copies or substantial portions of the Software.
13
//
14
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
15
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
16
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
17
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 
18
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 
19
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 
20
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
//
22
 
23 2 ghutchis
// Environment library
24
// Creates definitions of the special I/O ports used by the
25
// environment, as well as some utility functions to allow
26
// programs to print out strings in the test log.
27
 
28
#ifndef TV80_ENV_H
29
#define TV80_ENV_H
30
 
31
sfr at 0x80 sim_ctl_port;
32
sfr at 0x81 msg_port;
33
sfr at 0x82 timeout_port;
34
sfr at 0x83 max_timeout_low;
35
sfr at 0x84 max_timeout_high;
36 32 ghutchis
sfr at 0x90 intr_cntdwn;
37 39 ghutchis
sfr at 0x91 cksum_value;
38
sfr at 0x92 cksum_accum;
39
sfr at 0x93 inc_on_read;
40 40 ghutchis
sfr at 0x94 randval;
41 89 ghutchis
sfr at 0x95 nmi_cntdwn;
42
sfr at 0xA0 nmi_trig_opcode;
43 2 ghutchis
 
44
#define SC_TEST_PASSED 0x01
45
#define SC_TEST_FAILED 0x02
46
#define SC_DUMPON      0x03
47
#define SC_DUMPOFF     0x04
48
 
49
void print (char *string)
50
{
51
  char *iter;
52 62 ghutchis
  char timeout;
53 2 ghutchis
 
54 62 ghutchis
  timeout = timeout_port;
55 2 ghutchis
  timeout_port = 0x02;
56 62 ghutchis
  timeout_port = timeout;
57 2 ghutchis
 
58
  iter = string;
59
  while (*iter != 0) {
60
    msg_port = *iter++;
61
  }
62
}
63
 
64 79 ghutchis
void print_hex (unsigned int num)
65
{
66
  char i, digit;
67
 
68
  for (i=3; i>=0; i--) {
69
    digit = (num >> (i*4)) & 0xf;
70
    if (digit < 10) msg_port = digit + '0';
71
    else msg_port = digit + 'a' - 10;
72
  }
73
}
74
 
75 2 ghutchis
void print_num (int num)
76
{
77 79 ghutchis
  char cd = 0;
78 2 ghutchis
  int i;
79
  char digits[8];
80 62 ghutchis
  char timeout;
81 2 ghutchis
 
82 62 ghutchis
  timeout = timeout_port;
83 2 ghutchis
  timeout_port = 0x02;
84 62 ghutchis
  timeout_port = timeout;
85 2 ghutchis
 
86 79 ghutchis
  if (num == 0) { msg_port = '0'; return; }
87 2 ghutchis
  while (num > 0) {
88
    digits[cd++] = (num % 10) + '0';
89
    num /= 10;
90
  }
91
  for (i=cd; i>0; i--)
92
    msg_port = digits[i-1];
93
}
94
 
95 32 ghutchis
#define sim_ctl(code) sim_ctl_port = code
96 2 ghutchis
 
97
void set_timeout (unsigned int max_timeout)
98
{
99
  timeout_port = 0x02;
100
 
101
  max_timeout_low = (max_timeout & 0xFF);
102
  max_timeout_high = (max_timeout >> 8);
103
 
104
  timeout_port = 0x01;
105
}
106
 
107
#endif

powered by: WebSVN 2.1.0

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