URL
https://opencores.org/ocsvn/tv80/tv80/trunk
Subversion Repositories tv80
Compare Revisions
- This comparison shows the changes necessary to convert path
/tv80/trunk/sc_env
- from Rev 108 to Rev 111
- ↔ Reverse comparison
Rev 108 → Rev 111
/tv_responder.h
2,6 → 2,7
#define TV_RESPONDER_H_ |
|
#include "sc_env.h" |
#include "tv80_scenv.h" |
|
SC_MODULE(tv_responder) |
{ |
/env_memory.cpp
30,6 → 30,8
{ |
int c = 1, cnt = 0; |
|
assert (fh != NULL); |
|
if (feof(fh)) { |
*buf = (char) 0; |
return 0; |
86,6 → 88,7
sscanf (lp, "%02x", &databyte); |
lp += 2; |
//printf ("DEBUG: loaded mem[%04x]=%02x\n", addr+c, databyte); |
assert ( (addr+c) < AM_DEPTH ); |
memory[addr+c] = databyte; dcount++; |
} |
rv = readline (fh, line); |
/tv80_scenv.h
0,0 → 1,29
/* This file contains defines which are common to both the |
* SystemC testbench and the SDCC/Z80 C tests. This should |
* contain only defines and statements which can be understood |
* by both SDCC and gcc. Any types referenced should use the |
* stdint.h types rather than int/char. |
*/ |
|
#ifndef TV80_SCENV_H_ |
#define TV80_SCENV_H_ |
|
#define SIM_CTL_PORT 0x80 |
#define MSG_PORT 0x81 |
#define TIMEOUT_PORT 0x82 |
#define MAX_TIMEOUT_LOW 0x83 |
#define MAX_TIMEOUT_HIGH 0x84 |
#define INTR_CNTDWN 0x90 |
#define CKSUM_VALUE 0x91 |
#define CKSUM_ACCUM 0x92 |
#define INC_ON_READ 0x93 |
#define RANDVAL 0x94 |
#define NMI_CNTDWN 0x95 |
#define NMI_TRIG_OPCODE 0xA0 |
|
#define SC_TEST_PASSED 0x01 |
#define SC_TEST_FAILED 0x02 |
#define SC_DUMPON 0x03 |
#define SC_DUMPOFF 0x04 |
|
#endif /*TV80_SCENV_H_*/ |
/env_memory.h
3,7 → 3,7
#ifndef ENV_MEMORY_H |
#define ENV_MEMORY_H |
#define AM_ASZ 16 |
#define AM_DEPTH (1<<16) |
#define AM_DEPTH (1<<AM_ASZ) |
|
SC_MODULE(env_memory) { |
|
/tv_responder.cpp
1,5 → 1,12
#include "tv_responder.h" |
|
uint64_t get_time_stamp () { |
sc_time t; |
|
t = sc_time_stamp(); |
return t.value(); |
} |
|
void tv_responder::event () |
{ |
// init |
11,6 → 18,7
busrq_n = 1; |
di_resp = 0; |
*/ |
uint8_t oldval; |
|
if (reset_time > 0) { |
reset_n = 0; |
39,7 → 47,10
case(0x84) : di_resp = max_timeout >> 8; break; |
|
case(0x90) : di_resp = int_countdown; break; |
case(0x91) : di_resp = checksum; break; |
case(CKSUM_VALUE) : |
di_resp = checksum; |
//printf ("%2.6f: Read checksum value of %02x\n", sc_time_stamp().to_seconds(), checksum); |
break; |
case(0x93) : di_resp = ior_value; break; |
case(0x94) : di_resp = rand(); break; |
case(0x95) : di_resp = nmi_countdown; break; |
67,31 → 78,26
|
last_iowrite = true; |
switch ( l_addr & 0xff) { |
case(0x80) : |
case(SIM_CTL_PORT) : |
// dump control deprecated |
if (l_dout == 1) { |
printf ("%8d: --- TEST PASSED ---\n", 0); |
printf ("%2.6f: --- TEST PASSED ---\n", sc_time_stamp().to_seconds()); |
sc_stop(); |
} else if (l_dout == 2) { |
printf ("%8d: !!! TEST FAILED !!!\n", 0); |
printf ("%2.6f: !!! TEST FAILED !!!\n", sc_time_stamp().to_seconds()); |
sc_stop(); |
} |
break; |
|
case(0x81) : |
case(MSG_PORT) : |
|
//printf ("%s: DEBUG : Detected write of character %x\n", sc_time_stamp().to_string(), l_dout); |
//cout << sc_time_stamp().to_string() << "DEBUG : Detected write of character " << l_dout << endl; |
if (l_dout == 0x0A) { |
//printf ("%8d: PROGRAM : ", sc_simulation_time()); |
cout << sc_time_stamp() << ": PROGRAM : "; |
printf ("%2.6f: PROGRAM : ", sc_time_stamp().to_seconds()); |
|
for (int i=0; i<buf_ptr; i=i+1) |
//printf ("%s", str_buf[i]); |
cout << str_buf[i]; |
printf ("%c", str_buf[i]); |
|
//printf ("\n"); |
cout << endl; |
printf ("\n"); |
buf_ptr = 0; |
} else { |
str_buf[buf_ptr] = (char) (l_dout & 0xff); |
99,21 → 105,26
} |
break; |
|
case(0x82) : |
case(TIMEOUT_PORT) : |
timeout_ctl = l_dout; |
break; |
|
case(0x83) : |
case(MAX_TIMEOUT_LOW) : |
max_timeout = l_dout | (max_timeout & 0xFF00); |
break; |
|
case(0x84) : |
max_timeout = l_dout << 8 | (max_timeout & 0x00FF); |
case(MAX_TIMEOUT_HIGH) : |
max_timeout = (l_dout << 8) | (max_timeout & 0x00FF); |
printf ("%2.6f: ENVIRON : Timeout reset to %d (dout=%d)\n", sc_time_stamp().to_seconds(), max_timeout, l_dout); |
break; |
|
case(0x90) : int_countdown = dout; break; |
case(0x91) : checksum = dout; break; |
case(0x92) : checksum = checksum + dout; break; |
case(CKSUM_VALUE) : checksum = dout; break; |
case(CKSUM_ACCUM) : |
oldval = checksum; |
checksum = checksum + dout; |
//printf ("%2.6f: ENVIRON : cksum %02x=%02x + %02x\n", sc_time_stamp().to_seconds(), checksum, oldval, l_dout); |
break; |
case(0x93) : ior_value = dout; break; |
case(0x95) : nmi_countdown = dout; break; |
case(0xA0) : nmi_trigger = dout; break; |
121,13 → 132,14
} else if (iorq_n) |
last_iowrite = false; |
|
if (timeout_ctl & 0x2) |
if (timeout_ctl & 0x2) { |
cur_timeout = 0; |
else if (timeout_ctl & 0x1) |
timeout_ctl = timeout_ctl & 1; |
} else if (timeout_ctl & 0x1) |
cur_timeout = cur_timeout + 1; |
|
if (cur_timeout >= max_timeout) { |
printf ("%8d: ERROR : Reached timeout %d cycles\n", 0, max_timeout); |
printf ("%2.6f: ERROR : Reached timeout %d cycles\n", sc_time_stamp().to_seconds(), max_timeout); |
//tb_top.test_fail; |
sc_stop(); |
} |