1 |
17 |
bporcella |
///////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
////
|
3 |
|
|
//// file name: z80_core_top.v
|
4 |
|
|
//// description: interconnect module for z80 core.
|
5 |
|
|
//// project: wb_z80 ////
|
6 |
|
|
////
|
7 |
|
|
//// Author: B.J. Porcella
|
8 |
|
|
//// bporcella@sbcglobal.net
|
9 |
|
|
////
|
10 |
|
|
////
|
11 |
|
|
////
|
12 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
13 |
|
|
////
|
14 |
|
|
//// Copyright (C) 2000-2002 B.J. Porcella
|
15 |
|
|
//// Real Time Solutions
|
16 |
|
|
////
|
17 |
|
|
////
|
18 |
|
|
//// This source file may be used and distributed without
|
19 |
|
|
//// restriction provided that this copyright statement is not
|
20 |
|
|
//// removed from the file and that any derivative work contains
|
21 |
|
|
//// the original copyright notice and the associated disclaimer.
|
22 |
|
|
////
|
23 |
|
|
//// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY
|
24 |
|
|
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
25 |
|
|
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
26 |
|
|
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR
|
27 |
|
|
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
28 |
|
|
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
29 |
|
|
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
30 |
|
|
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
31 |
|
|
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
32 |
|
|
//// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
33 |
|
|
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
34 |
|
|
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
35 |
|
|
//// POSSIBILITY OF SUCH DAMAGE.
|
36 |
|
|
////
|
37 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
38 |
|
|
// CVS Log
|
39 |
|
|
//
|
40 |
23 |
bporcella |
// $Id: z80_core_top.v,v 1.3 2004-05-13 14:58:53 bporcella Exp $
|
41 |
17 |
bporcella |
//
|
42 |
23 |
bporcella |
// $Date: 2004-05-13 14:58:53 $
|
43 |
|
|
// $Revision: 1.3 $
|
44 |
17 |
bporcella |
// $Author: bporcella $
|
45 |
|
|
// $Locker: $
|
46 |
|
|
// $State: Exp $
|
47 |
|
|
//
|
48 |
|
|
// Change History:
|
49 |
|
|
// $Log: not supported by cvs2svn $
|
50 |
23 |
bporcella |
// Revision 1.2 2004/04/27 21:38:22 bporcella
|
51 |
|
|
// test lint on core
|
52 |
|
|
//
|
53 |
18 |
bporcella |
// Revision 1.1 2004/04/27 21:27:13 bporcella
|
54 |
|
|
// first core build
|
55 |
|
|
//
|
56 |
17 |
bporcella |
// Revision 1.1.1.1 2004/04/13 23:47:42 bporcella
|
57 |
|
|
// import first files
|
58 |
|
|
//
|
59 |
|
|
//
|
60 |
|
|
//
|
61 |
|
|
// connects modules:
|
62 |
|
|
// memstate2.v // main state machine for z8
|
63 |
|
|
// inst_exec.v // main execution engine for z80
|
64 |
|
|
// generic_spram.v // main memory (on board)
|
65 |
|
|
// z80_sdram_config.v // fundamentally wishbone glue logic - not on top per design guidelines
|
66 |
18 |
bporcella |
// add a comment test lint
|
67 |
17 |
bporcella |
//-------1---------2---------3--------Module Name and Port List------7---------8---------9--------0
|
68 |
23 |
bporcella |
module z80_core_top(
|
69 |
|
|
wb_dat_o,
|
70 |
17 |
bporcella |
wb_stb_o,
|
71 |
|
|
wb_cyc_o,
|
72 |
|
|
wb_we_o,
|
73 |
|
|
wb_adr_o,
|
74 |
|
|
wb_tga_o,
|
75 |
|
|
wb_ack_i,
|
76 |
|
|
wb_clk_i,
|
77 |
|
|
wb_dat_i,
|
78 |
23 |
bporcella |
wb_rst_i,
|
79 |
|
|
`ifdef COMPILE_BIST
|
80 |
|
|
bist_ack_o,
|
81 |
|
|
bist_err_o,
|
82 |
17 |
bporcella |
bist_req_i,
|
83 |
23 |
bporcella |
`endif
|
84 |
17 |
bporcella |
int_req_i
|
85 |
|
|
|
86 |
|
|
);
|
87 |
|
|
|
88 |
|
|
//-------1---------2---------3--------Output Ports---------6---------7---------8---------9--------0
|
89 |
|
|
|
90 |
|
|
output [7:0] wb_dat_o;
|
91 |
|
|
output wb_stb_o;
|
92 |
|
|
output wb_cyc_o;
|
93 |
|
|
output wb_we_o;
|
94 |
|
|
output [15:0] wb_adr_o;
|
95 |
|
|
output [1:0] wb_tga_o;
|
96 |
|
|
|
97 |
|
|
|
98 |
|
|
//-------1---------2---------3--------Input Ports----------6---------7---------8---------9--------0
|
99 |
|
|
|
100 |
|
|
input wb_ack_i;
|
101 |
|
|
input wb_clk_i;
|
102 |
|
|
input [7:0] wb_dat_i;
|
103 |
23 |
bporcella |
input wb_rst_i;
|
104 |
17 |
bporcella |
input int_req_i;
|
105 |
|
|
|
106 |
|
|
|
107 |
23 |
bporcella |
`ifdef COMPILE_BIST
|
108 |
|
|
output bist_err_o;
|
109 |
|
|
output bist_ack_o;
|
110 |
|
|
input bist_req_i;
|
111 |
|
|
`endif
|
112 |
|
|
|
113 |
|
|
|
114 |
17 |
bporcella |
//-------1---------2---------3--------Parameters-----------6---------7---------8---------9--------0
|
115 |
|
|
//-------1---------2---------3--------Wires------5---------6---------7---------8---------9--------0
|
116 |
|
|
wire [15:0] wb_adr_o;
|
117 |
|
|
wire [9:0] ir1, ir2;
|
118 |
|
|
wire [15:0] nn;
|
119 |
|
|
wire [15:0] sp;
|
120 |
23 |
bporcella |
wire [7:0] ar, fr, br, cr, dr, er, hr, lr, intr;
|
121 |
17 |
bporcella |
wire [15:0] ixr, iyr;
|
122 |
|
|
wire [7:0] wb_dat_i, wb_dat_o, sdram_do, cfg_do;
|
123 |
|
|
wire [15:0] add16; // ir2 execution engine output for sp updates
|
124 |
|
|
|
125 |
|
|
|
126 |
|
|
|
127 |
|
|
|
128 |
|
|
|
129 |
|
|
|
130 |
|
|
|
131 |
|
|
//-------1---------2---------3--------Registers--5---------6---------7---------8---------9--------0
|
132 |
|
|
//-------1---------2---------3--------Assignments----------6---------7---------8---------9--------0
|
133 |
|
|
//-------1---------2---------3--------State Machines-------6---------7---------8---------9--------0
|
134 |
|
|
|
135 |
23 |
bporcella |
|
136 |
|
|
`ifdef COMPILE_BIST
|
137 |
|
|
z80_bist_logic i_z80_bist_logic(
|
138 |
|
|
.bist_err_o(bist_err_o), .bist_ack_o(bist_ack_o),
|
139 |
|
|
.wb_adr_i(wb_adr_o), .wb_dat_i(wb_dat_o), .wb_we_i(wb_we_o), .wb_cyc_i(wb_cyc_o),
|
140 |
|
|
.wb_stb_i(wb_stb_o), .wb_tga_i(wb_tga_o), .wb_clk_i(wb_clk_i), .wb_rst_i(wb_rst_i)
|
141 |
|
|
);
|
142 |
|
|
`endif
|
143 |
|
|
|
144 |
|
|
|
145 |
|
|
|
146 |
17 |
bporcella |
z80_memstate2 i_z80_memstate2(
|
147 |
|
|
.wb_adr_o(wb_adr_o), .wb_we_o(wb_we_o), .wb_cyc_o(wb_cyc_o), .wb_stb_o(wb_stb_o), .wb_tga_o(wb_tga_o), .wb_dat_o(wb_dat_o),
|
148 |
|
|
.exec_ir2(exec_ir2), .ir1(ir1), .ir2(ir2), .ir1dd(ir1dd), .ir1fd(ir1fd), .ir2dd(ir2dd), .ir2fd(ir2fd), .nn(nn), .sp(sp),
|
149 |
|
|
.upd_ar(upd_ar), .upd_br(upd_br), .upd_cr(upd_cr), .upd_dr(upd_dr), .upd_er(upd_er), .upd_hr(upd_hr), .upd_lr(upd_lr),.upd_fr(upd_fr),
|
150 |
23 |
bporcella |
.beq0(br_eq0), .ceq0(cr_eq0),
|
151 |
17 |
bporcella |
.ar(ar), .fr(fr), .br(br), .cr(cr), .dr(dr), .er(er), .hr(hr), .lr(lr),
|
152 |
|
|
.ixr(ixr), .iyr(iyr),
|
153 |
23 |
bporcella |
.wb_dat_i(cfg_do), .wb_ack_i(cfg_ack_o),
|
154 |
17 |
bporcella |
.int_req_i(int_req_i),
|
155 |
|
|
.add16(add16),
|
156 |
|
|
.wb_clk_i(wb_clk_i),
|
157 |
23 |
bporcella |
.rst_i(wb_rst_i) // keep this generic - may turn out to be different from wb_rst
|
158 |
|
|
);
|
159 |
17 |
bporcella |
|
160 |
|
|
|
161 |
|
|
z80_inst_exec i_z80_inst_exec(
|
162 |
|
|
.br_eq0(br_eq0),
|
163 |
|
|
.cr_eq0(cr_eq0),
|
164 |
|
|
.upd_ar(upd_ar), .upd_br(upd_br), .upd_cr(upd_cr), .upd_dr(upd_dr), .upd_er(upd_er), .upd_hr(upd_hr), .upd_lr(upd_lr),.upd_fr(upd_fr),
|
165 |
23 |
bporcella |
.ar(ar), .fr(fr), .br(br), .cr(cr), .dr(dr), .er(er), .hr(hr), .lr(lr), .intr(intr),
|
166 |
17 |
bporcella |
.ixr(ixr), .iyr(iyr), .add16(add16),
|
167 |
|
|
.exec_ir2(exec_ir2),
|
168 |
|
|
.exec_decbc(exec_decbc), .exec_decb(exec_decb),
|
169 |
|
|
.ir2(ir2),
|
170 |
|
|
.clk(wb_clk_i),
|
171 |
23 |
bporcella |
.rst(wb_rst_i),
|
172 |
17 |
bporcella |
.nn(nn), .sp(sp),
|
173 |
23 |
bporcella |
.ir2dd(ir2dd),
|
174 |
|
|
.ir2fd(ir2fd)
|
175 |
17 |
bporcella |
);
|
176 |
|
|
|
177 |
|
|
// The parameter passed to i_generic_sprem specifies the number of address bits used by the
|
178 |
|
|
// memory -- and thus the memory size. We expect to use 15 here in the released documentation -
|
179 |
|
|
// giving an onboard 32k SRAM and allowing 32k space for off-chip memory. Note that any change to
|
180 |
|
|
// this parameter requires modifications to the decode logic in z80_sdram_cfg.
|
181 |
|
|
//
|
182 |
|
|
// The generic_spram is being used here per Open Cores coding guidelines. I'm not sure I'm totally
|
183 |
|
|
// happy with this...... Depending on which target technology is specified, read behavior changes.
|
184 |
|
|
// It is easy to insure all possible behavior will in fact operate properly -- see the data reduction
|
185 |
|
|
// logic in sdram_cfg.v -- but still... I guess the important thing to be aware of is that
|
186 |
23 |
bporcella |
// big memories like this typically require special back-end handeling. This is likely to prove
|
187 |
17 |
bporcella |
// no exception - despite the work that has been done to make this file as generally useful as
|
188 |
|
|
// possible.
|
189 |
|
|
|
190 |
23 |
bporcella |
generic_spram #(15) i_generic_spram(
|
191 |
17 |
bporcella |
// Generic synchronous single-port RAM interface
|
192 |
23 |
bporcella |
.clk(wb_clk_i), .rst(wb_rst_i), .ce(cfg_ce_spram_o), .we(wb_we_o), .oe(1'b1), .addr(wb_adr_o[14:0]), .di(wb_dat_o), .do(sdram_do)
|
193 |
|
|
);
|
194 |
17 |
bporcella |
|
195 |
|
|
|
196 |
|
|
|
197 |
|
|
z80_sdram_cfg i_z80_sdram_cfg(
|
198 |
|
|
.cfg_ce_spram_o(cfg_ce_spram_o), .cfg_do(cfg_do), .cfg_ack_o(cfg_ack_o), .sdram_di(sdram_do),
|
199 |
23 |
bporcella |
.wb_adr_i(wb_adr_o), .wb_dat_i(wb_dat_i), .wb_ack_i(wb_ack_i), .wb_stb_i(wb_stb_o),
|
200 |
|
|
.wb_cyc_i(wb_cyc_o), .wb_tga_i(wb_tga_o)
|
201 |
|
|
);
|
202 |
17 |
bporcella |
|
203 |
|
|
|
204 |
|
|
endmodule
|