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