//
|
//
|
// Copyright (c) 2005 Guy Hutchison (ghutchis@opencores.org)
|
// Copyright (c) 2005 Guy Hutchison (ghutchis@opencores.org)
|
//
|
//
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
// to deal in the Software without restriction, including without limitation
|
// to deal in the Software without restriction, including without limitation
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
// and/or sell copies of the Software, and to permit persons to whom the
|
// and/or sell copies of the Software, and to permit persons to whom the
|
// Software is furnished to do so, subject to the following conditions:
|
// Software is furnished to do so, subject to the following conditions:
|
//
|
//
|
// The above copyright notice and this permission notice shall be included
|
// The above copyright notice and this permission notice shall be included
|
// in all copies or substantial portions of the Software.
|
// in all copies or substantial portions of the Software.
|
//
|
//
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
//
|
//
|
|
|
// Environment library
|
// Environment library
|
// Creates definitions of the special I/O ports used by the
|
// Creates definitions of the special I/O ports used by the
|
// environment, as well as some utility functions to allow
|
// environment, as well as some utility functions to allow
|
// programs to print out strings in the test log.
|
// programs to print out strings in the test log.
|
|
|
#ifndef TV80_ENV_H
|
#ifndef TV80_ENV_H
|
#define TV80_ENV_H
|
#define TV80_ENV_H
|
|
|
|
#include "tv80_scenv.h"
|
|
|
sfr at 0x80 sim_ctl_port;
|
sfr at 0x80 sim_ctl_port;
|
sfr at 0x81 msg_port;
|
sfr at 0x81 msg_port;
|
sfr at 0x82 timeout_port;
|
sfr at 0x82 timeout_port;
|
sfr at 0x83 max_timeout_low;
|
sfr at 0x83 max_timeout_low;
|
sfr at 0x84 max_timeout_high;
|
sfr at 0x84 max_timeout_high;
|
sfr at 0x90 intr_cntdwn;
|
sfr at 0x90 intr_cntdwn;
|
sfr at 0x91 cksum_value;
|
sfr at 0x91 cksum_value;
|
sfr at 0x92 cksum_accum;
|
sfr at 0x92 cksum_accum;
|
sfr at 0x93 inc_on_read;
|
sfr at 0x93 inc_on_read;
|
sfr at 0x94 randval;
|
sfr at 0x94 randval;
|
sfr at 0x95 nmi_cntdwn;
|
sfr at 0x95 nmi_cntdwn;
|
sfr at 0xA0 nmi_trig_opcode;
|
sfr at 0xA0 nmi_trig_opcode;
|
|
|
#define SC_TEST_PASSED 0x01
|
/* now included from scenv.h
|
#define SC_TEST_FAILED 0x02
|
#define SC_TEST_PASSED 0x01
|
#define SC_DUMPON 0x03
|
#define SC_TEST_FAILED 0x02
|
#define SC_DUMPOFF 0x04
|
#define SC_DUMPON 0x03
|
|
#define SC_DUMPOFF 0x04
|
|
*/
|
|
|
void print (char *string)
|
void print (char *string)
|
{
|
{
|
char *iter;
|
char *iter;
|
char timeout;
|
char timeout;
|
|
|
timeout = timeout_port;
|
timeout = timeout_port;
|
timeout_port = 0x02;
|
timeout_port = 0x02;
|
timeout_port = timeout;
|
timeout_port = timeout;
|
|
|
iter = string;
|
iter = string;
|
while (*iter != 0) {
|
while (*iter != 0) {
|
msg_port = *iter++;
|
msg_port = *iter++;
|
}
|
}
|
}
|
}
|
|
|
void print_hex (unsigned int num)
|
void print_hex (unsigned int num)
|
{
|
{
|
char i, digit;
|
char i, digit;
|
|
|
for (i=3; i>=0; i--) {
|
for (i=3; i>=0; i--) {
|
digit = (num >> (i*4)) & 0xf;
|
digit = (num >> (i*4)) & 0xf;
|
if (digit < 10) msg_port = digit + '0';
|
if (digit < 10) msg_port = digit + '0';
|
else msg_port = digit + 'a' - 10;
|
else msg_port = digit + 'a' - 10;
|
}
|
}
|
}
|
}
|
|
|
void print_num (int num)
|
void print_num (int num)
|
{
|
{
|
char cd = 0;
|
char cd = 0;
|
int i;
|
int i;
|
char digits[8];
|
char digits[8];
|
char timeout;
|
char timeout;
|
|
|
timeout = timeout_port;
|
timeout = timeout_port;
|
timeout_port = 0x02;
|
timeout_port = 0x02;
|
timeout_port = timeout;
|
timeout_port = timeout;
|
|
|
if (num == 0) { msg_port = '0'; return; }
|
if (num == 0) { msg_port = '0'; return; }
|
while (num > 0) {
|
while (num > 0) {
|
digits[cd++] = (num % 10) + '0';
|
digits[cd++] = (num % 10) + '0';
|
num /= 10;
|
num /= 10;
|
}
|
}
|
for (i=cd; i>0; i--)
|
for (i=cd; i>0; i--)
|
msg_port = digits[i-1];
|
msg_port = digits[i-1];
|
}
|
}
|
|
|
#define sim_ctl(code) sim_ctl_port = code
|
#define sim_ctl(code) sim_ctl_port = code
|
|
|
void set_timeout (unsigned int max_timeout)
|
void set_timeout (unsigned int max_timeout)
|
{
|
{
|
timeout_port = 0x02;
|
timeout_port = 0x02;
|
|
|
max_timeout_low = (max_timeout & 0xFF);
|
max_timeout_low = (max_timeout & 0xFF);
|
max_timeout_high = (max_timeout >> 8);
|
max_timeout_high = (max_timeout >> 8);
|
|
|
timeout_port = 0x01;
|
timeout_port = 0x01;
|
}
|
}
|
|
|
#endif
|
#endif
|
|
|