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

Subversion Repositories tv80

[/] [tv80/] [trunk/] [rtl/] [core/] [tv80s.v] - Blame information for rev 116

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

Line No. Rev Author Line
1 2 ghutchis
//
2
// TV80 8-Bit Microprocessor Core
3
// Based on the VHDL T80 core by Daniel Wallner (jesus@opencores.org)
4
//
5
// Copyright (c) 2004 Guy Hutchison (ghutchis@opencores.org)
6
//
7
// Permission is hereby granted, free of charge, to any person obtaining a 
8
// copy of this software and associated documentation files (the "Software"), 
9
// to deal in the Software without restriction, including without limitation 
10
// the rights to use, copy, modify, merge, publish, distribute, sublicense, 
11
// and/or sell copies of the Software, and to permit persons to whom the 
12
// Software is furnished to do so, subject to the following conditions:
13
//
14
// The above copyright notice and this permission notice shall be included 
15
// in all copies or substantial portions of the Software.
16
//
17
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
18
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
19
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
20
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 
21
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 
22
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 
23
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
 
25
module tv80s (/*AUTOARG*/
26
  // Outputs
27 89 ghutchis
  m1_n, mreq_n, iorq_n, rd_n, wr_n, rfsh_n, halt_n, busak_n, A, dout,
28 2 ghutchis
  // Inputs
29
  reset_n, clk, wait_n, int_n, nmi_n, busrq_n, di
30
  );
31
 
32
  parameter Mode = 0;    // 0 => Z80, 1 => Fast Z80, 2 => 8080, 3 => GB
33 74 ghutchis
  parameter T2Write = 1; // 0 => wr_n active in T3, /=0 => wr_n active in T2
34 2 ghutchis
  parameter IOWait  = 1; // 0 => Single cycle I/O, 1 => Std I/O cycle
35
 
36
 
37
  input         reset_n;
38
  input         clk;
39
  input         wait_n;
40
  input         int_n;
41
  input         nmi_n;
42
  input         busrq_n;
43
  output        m1_n;
44
  output        mreq_n;
45
  output        iorq_n;
46
  output        rd_n;
47
  output        wr_n;
48
  output        rfsh_n;
49
  output        halt_n;
50
  output        busak_n;
51
  output [15:0] A;
52
  input [7:0]   di;
53 89 ghutchis
  output [7:0]  dout;
54 2 ghutchis
 
55
  reg           mreq_n;
56
  reg           iorq_n;
57
  reg           rd_n;
58
  reg           wr_n;
59
 
60
  wire          cen;
61
  wire          intcycle_n;
62
  wire          no_read;
63
  wire          write;
64
  wire          iorq;
65
  reg [7:0]     di_reg;
66 21 ghutchis
  wire [6:0]    mcycle;
67
  wire [6:0]    tstate;
68 2 ghutchis
 
69
  assign    cen = 1;
70
 
71 24 ghutchis
  tv80_core #(Mode, IOWait) i_tv80_core
72 2 ghutchis
    (
73
     .cen (cen),
74
     .m1_n (m1_n),
75
     .iorq (iorq),
76
     .no_read (no_read),
77
     .write (write),
78
     .rfsh_n (rfsh_n),
79
     .halt_n (halt_n),
80
     .wait_n (wait_n),
81
     .int_n (int_n),
82
     .nmi_n (nmi_n),
83
     .reset_n (reset_n),
84
     .busrq_n (busrq_n),
85
     .busak_n (busak_n),
86
     .clk (clk),
87
     .IntE (),
88
     .stop (),
89
     .A (A),
90
     .dinst (di),
91
     .di (di_reg),
92 89 ghutchis
     .dout (dout),
93 2 ghutchis
     .mc (mcycle),
94
     .ts (tstate),
95
     .intcycle_n (intcycle_n)
96
     );
97
 
98 89 ghutchis
  always @(posedge clk or negedge reset_n)
99 2 ghutchis
    begin
100
      if (!reset_n)
101
        begin
102 60 ghutchis
          rd_n   <= #1 1'b1;
103
          wr_n   <= #1 1'b1;
104
          iorq_n <= #1 1'b1;
105
          mreq_n <= #1 1'b1;
106
          di_reg <= #1 0;
107 2 ghutchis
        end
108
      else
109
        begin
110 60 ghutchis
          rd_n <= #1 1'b1;
111
          wr_n <= #1 1'b1;
112
          iorq_n <= #1 1'b1;
113
          mreq_n <= #1 1'b1;
114
          if (mcycle[0])
115 2 ghutchis
            begin
116 60 ghutchis
              if (tstate[1] || (tstate[2] && wait_n == 1'b0))
117 2 ghutchis
                begin
118 60 ghutchis
                  rd_n <= #1 ~ intcycle_n;
119
                  mreq_n <= #1 ~ intcycle_n;
120
                  iorq_n <= #1 intcycle_n;
121
                end
122
            `ifdef TV80_REFRESH
123
              if (tstate[3])
124
            mreq_n <= #1 1'b0;
125
            `endif
126 21 ghutchis
            end // if (mcycle[0])          
127 60 ghutchis
          else
128 2 ghutchis
            begin
129 60 ghutchis
              if ((tstate[1] || (tstate[2] && wait_n == 1'b0)) && no_read == 1'b0 && write == 1'b0)
130 2 ghutchis
                begin
131 60 ghutchis
                  rd_n <= #1 1'b0;
132
                  iorq_n <= #1 ~ iorq;
133
                  mreq_n <= #1 iorq;
134
                end
135
              if (T2Write == 0)
136 2 ghutchis
                begin
137 60 ghutchis
                  if (tstate[2] && write == 1'b1)
138 2 ghutchis
                    begin
139 60 ghutchis
                      wr_n <= #1 1'b0;
140
                      iorq_n <= #1 ~ iorq;
141
                      mreq_n <= #1 iorq;
142 2 ghutchis
                    end
143
                end
144 60 ghutchis
              else
145 2 ghutchis
                begin
146 60 ghutchis
                  if ((tstate[1] || (tstate[2] && wait_n == 1'b0)) && write == 1'b1)
147 2 ghutchis
                    begin
148 60 ghutchis
                      wr_n <= #1 1'b0;
149
                      iorq_n <= #1 ~ iorq;
150
                      mreq_n <= #1 iorq;
151
                  end
152
                end // else: !if(T2write == 0)
153 2 ghutchis
 
154 60 ghutchis
            end // else: !if(mcycle[0])
155 2 ghutchis
 
156 60 ghutchis
          if (tstate[2] && wait_n == 1'b1)
157
            di_reg <= #1 di;
158
        end // else: !if(!reset_n)
159 2 ghutchis
    end // always @ (posedge clk or negedge reset_n)
160
 
161
endmodule // t80s
162
 

powered by: WebSVN 2.1.0

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