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

Subversion Repositories tv80

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

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 2 ghutchis
 
42
#define SC_TEST_PASSED 0x01
43
#define SC_TEST_FAILED 0x02
44
#define SC_DUMPON      0x03
45
#define SC_DUMPOFF     0x04
46
 
47
void print (char *string)
48
{
49
  char *iter;
50 62 ghutchis
  char timeout;
51 2 ghutchis
 
52 62 ghutchis
  timeout = timeout_port;
53 2 ghutchis
  timeout_port = 0x02;
54 62 ghutchis
  timeout_port = timeout;
55 2 ghutchis
 
56
  iter = string;
57
  while (*iter != 0) {
58
    msg_port = *iter++;
59
  }
60
}
61
 
62 79 ghutchis
void print_hex (unsigned int num)
63
{
64
  char i, digit;
65
 
66
  for (i=3; i>=0; i--) {
67
    digit = (num >> (i*4)) & 0xf;
68
    if (digit < 10) msg_port = digit + '0';
69
    else msg_port = digit + 'a' - 10;
70
  }
71
}
72
 
73 2 ghutchis
void print_num (int num)
74
{
75 79 ghutchis
  char cd = 0;
76 2 ghutchis
  int i;
77
  char digits[8];
78 62 ghutchis
  char timeout;
79 2 ghutchis
 
80 62 ghutchis
  timeout = timeout_port;
81 2 ghutchis
  timeout_port = 0x02;
82 62 ghutchis
  timeout_port = timeout;
83 2 ghutchis
 
84 79 ghutchis
  if (num == 0) { msg_port = '0'; return; }
85 2 ghutchis
  while (num > 0) {
86
    digits[cd++] = (num % 10) + '0';
87
    num /= 10;
88
  }
89
  for (i=cd; i>0; i--)
90
    msg_port = digits[i-1];
91
}
92
 
93 32 ghutchis
#define sim_ctl(code) sim_ctl_port = code
94 2 ghutchis
 
95
void set_timeout (unsigned int max_timeout)
96
{
97
  timeout_port = 0x02;
98
 
99
  max_timeout_low = (max_timeout & 0xFF);
100
  max_timeout_high = (max_timeout >> 8);
101
 
102
  timeout_port = 0x01;
103
}
104
 
105
#endif

powered by: WebSVN 2.1.0

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