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

Subversion Repositories tv80

[/] [tv80/] [trunk/] [tests/] [bintr.c] - Blame information for rev 89

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

Line No. Rev Author Line
1 32 ghutchis
#include "tv80_env.h"
2
 
3
/*
4
 * This test covers interrupt handling routines.  The actual interrupt code
5
 * is in assembly, in bintr_crt0.asm.
6
 *
7
 * The test generates five interrupts, and clears the interrupt after
8
 * each one.
9
 *
10
 * The isr routine uses the two writes to intr_cntdwn to first clear
11
 * assertion of the current interrupt and then disable the countdown
12
 * timer.
13
 */
14
 
15
unsigned char foo;
16
volatile unsigned char test_pass;
17
static unsigned char triggers;
18 89 ghutchis
int phase;
19
char done;
20
char nmi_trig;
21 32 ghutchis
 
22 89 ghutchis
void nmi_isr (void)
23
{
24
  nmi_trig++;
25
 
26
  switch (phase) {
27
    // nmi test
28
  case 1 :
29
    if (nmi_trig > 5) {
30
      phase += 1;
31
      nmi_trig = 0;
32
      //intr_cntdwn = 255;
33
      //intr_cntdwn = 0;
34
      intr_cntdwn = 32;
35
      nmi_cntdwn = 0;
36
    } else
37
      nmi_cntdwn = 32;
38
    break;
39
 
40
    // just trigger once, and disable interrupt
41
  case 3 :
42
    nmi_cntdwn = 0;
43
    nmi_trig_opcode = 0; // pop AF opcode
44
    break;
45
  }
46
}
47
 
48 32 ghutchis
void isr (void)
49
{
50 89 ghutchis
  int i;
51 32 ghutchis
  triggers++;
52
 
53 89 ghutchis
  switch (phase) {
54
    // int test
55
  case 0 :
56
    if (triggers > 5) {
57
      phase += 1;
58
      triggers = 0;
59
      intr_cntdwn = 0;
60
      nmi_cntdwn = 64;
61
    } else {
62
      intr_cntdwn = 32;
63
 
64
    }
65
    break;
66
 
67
 
68
    // int / nmi interaction
69
    // in this phase set up interrupt call
70
    // which will be interrupted by an nmi
71
  case 2 :
72
    phase += 1;
73
    triggers = 0;
74
    nmi_trig = 0;
75
    intr_cntdwn = 20;
76
    nmi_trig_opcode = 0xF1; // pop AF opcode
77
 
78
    break;
79
 
80
    // wait for a while while servicing interrupt
81
    // nmi should interrupt us and increment nmi_trig
82
    // if test pass is true when we are done then exit
83
  case 3 :
84 32 ghutchis
    intr_cntdwn = 0;
85 89 ghutchis
    if (nmi_trig == 1)
86
      test_pass = 1;
87
    break;
88
 
89
  }
90 32 ghutchis
}
91
 
92
int main ()
93
{
94
  int i;
95
  unsigned char check;
96
 
97
  test_pass = 0;
98
  triggers = 0;
99 89 ghutchis
  nmi_trig = 0;
100 32 ghutchis
 
101 89 ghutchis
  phase = 0;
102
 
103 32 ghutchis
  // start interrupt countdown
104
  intr_cntdwn = 64;
105 89 ghutchis
  set_timeout (50000);
106 32 ghutchis
 
107 89 ghutchis
  for (i=0; i<1024; i++) {
108
    if (test_pass)
109
      break;
110 32 ghutchis
    check = sim_ctl_port;
111 89 ghutchis
  }
112 32 ghutchis
 
113
  if (test_pass)
114
    sim_ctl (SC_TEST_PASSED);
115
  else
116
    sim_ctl (SC_TEST_FAILED);
117
 
118
  return 0;
119
}
120
 

powered by: WebSVN 2.1.0

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