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

Subversion Repositories tv80

[/] [tv80/] [branches/] [gth1/] [rtl/] [core/] [tv80s.v] - Blame information for rev 2

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
  m1_n, mreq_n, iorq_n, rd_n, wr_n, rfsh_n, halt_n, busak_n, A, do,
28
  // 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
  parameter T2Write = 0; // 0 => wr_n active in T3, /=0 => wr_n active in T2
34
  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
  output [7:0]  do;
54
 
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
  wire [2:0]    mcycle;
67
  wire [2:0]    tstate;
68
 
69
  assign    cen = 1;
70
 
71
  tv80_core i_tv80_core
72
    (
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
     .do (do),
93
     .mc (mcycle),
94
     .ts (tstate),
95
     .intcycle_n (intcycle_n)
96
     );
97
 
98
  always @(posedge clk)
99
    begin
100
      if (!reset_n)
101
        begin
102
          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
        end
108
      else
109
        begin
110
          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 == 3'b001)
115
            begin
116
              if (tstate == 3'b001 || (tstate == 3'b010 && wait_n == 1'b0))
117
                begin
118
                  rd_n <= #1 ~ intcycle_n;
119
                  mreq_n <= #1 ~ intcycle_n;
120
                  iorq_n <= #1 intcycle_n;
121
                end
122
              if (tstate == 3'b011)
123
                mreq_n <= #1 1'b0;
124
            end // if (mcycle == 3'b001)          
125
          else
126
            begin
127
              if ((tstate == 3'b001 || (tstate == 3'b010 && wait_n == 1'b0)) && no_read == 1'b0 && write == 1'b0)
128
                begin
129
                  rd_n <= #1 1'b0;
130
                  iorq_n <= #1 ~ iorq;
131
                  mreq_n <= #1 iorq;
132
                end
133
              if (T2Write == 0)
134
                begin
135
                  if (tstate == 3'b010 && write == 1'b1)
136
                    begin
137
                      wr_n <= #1 1'b0;
138
                      iorq_n <= #1 ~ iorq;
139
                      mreq_n <= #1 iorq;
140
                    end
141
                end
142
              else
143
                begin
144
                  if ((tstate == 3'b001 || (tstate == 3'b010 && wait_n == 1'b0)) && write == 1'b1)
145
                    begin
146
                      wr_n <= #1 1'b0;
147
                      iorq_n <= #1 ~ iorq;
148
                      mreq_n <= #1 iorq;
149
                  end
150
                end // else: !if(T2write == 0)
151
 
152
            end // else: !if(mcycle == 3'b001)
153
 
154
          if (tstate == 3'b010 && wait_n == 1'b1)
155
            di_reg <= #1 di;
156
        end // else: !if(!reset_n)
157
    end // always @ (posedge clk or negedge reset_n)
158
 
159
endmodule // t80s
160
 

powered by: WebSVN 2.1.0

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