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

Subversion Repositories tv80

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

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 111 ghutchis
#include "tv80_scenv.h"
32
 
33 2 ghutchis
sfr at 0x80 sim_ctl_port;
34
sfr at 0x81 msg_port;
35
sfr at 0x82 timeout_port;
36
sfr at 0x83 max_timeout_low;
37
sfr at 0x84 max_timeout_high;
38 32 ghutchis
sfr at 0x90 intr_cntdwn;
39 39 ghutchis
sfr at 0x91 cksum_value;
40
sfr at 0x92 cksum_accum;
41
sfr at 0x93 inc_on_read;
42 40 ghutchis
sfr at 0x94 randval;
43 89 ghutchis
sfr at 0x95 nmi_cntdwn;
44
sfr at 0xA0 nmi_trig_opcode;
45 2 ghutchis
 
46 111 ghutchis
/* now included from scenv.h
47 2 ghutchis
#define SC_TEST_PASSED 0x01
48
#define SC_TEST_FAILED 0x02
49
#define SC_DUMPON      0x03
50
#define SC_DUMPOFF     0x04
51 111 ghutchis
*/
52 2 ghutchis
 
53
void print (char *string)
54
{
55
  char *iter;
56 62 ghutchis
  char timeout;
57 2 ghutchis
 
58 62 ghutchis
  timeout = timeout_port;
59 2 ghutchis
  timeout_port = 0x02;
60 62 ghutchis
  timeout_port = timeout;
61 2 ghutchis
 
62
  iter = string;
63
  while (*iter != 0) {
64
    msg_port = *iter++;
65
  }
66
}
67
 
68 79 ghutchis
void print_hex (unsigned int num)
69
{
70
  char i, digit;
71
 
72
  for (i=3; i>=0; i--) {
73
    digit = (num >> (i*4)) & 0xf;
74
    if (digit < 10) msg_port = digit + '0';
75
    else msg_port = digit + 'a' - 10;
76
  }
77
}
78
 
79 2 ghutchis
void print_num (int num)
80
{
81 79 ghutchis
  char cd = 0;
82 2 ghutchis
  int i;
83
  char digits[8];
84 62 ghutchis
  char timeout;
85 2 ghutchis
 
86 62 ghutchis
  timeout = timeout_port;
87 2 ghutchis
  timeout_port = 0x02;
88 62 ghutchis
  timeout_port = timeout;
89 2 ghutchis
 
90 79 ghutchis
  if (num == 0) { msg_port = '0'; return; }
91 2 ghutchis
  while (num > 0) {
92
    digits[cd++] = (num % 10) + '0';
93
    num /= 10;
94
  }
95
  for (i=cd; i>0; i--)
96
    msg_port = digits[i-1];
97
}
98
 
99 32 ghutchis
#define sim_ctl(code) sim_ctl_port = code
100 2 ghutchis
 
101
void set_timeout (unsigned int max_timeout)
102
{
103
  timeout_port = 0x02;
104
 
105
  max_timeout_low = (max_timeout & 0xFF);
106
  max_timeout_high = (max_timeout >> 8);
107
 
108
  timeout_port = 0x01;
109
}
110
 
111
#endif

powered by: WebSVN 2.1.0

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