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

Subversion Repositories 8051

[/] [8051/] [trunk/] [rtl/] [verilog/] [oc8051_top.v] - Blame information for rev 82

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

Line No. Rev Author Line
1 72 simont
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  8051 cores top level module                                 ////
4
////                                                              ////
5
////  This file is part of the 8051 cores project                 ////
6
////  http://www.opencores.org/cores/8051/                        ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  8051 definitions.                                           ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////    nothing                                                   ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Simon Teran, simont@opencores.org                     ////
16
////                                                              ////
17
//////////////////////////////////////////////////////////////////////
18
////                                                              ////
19
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
20
////                                                              ////
21
//// This source file may be used and distributed without         ////
22
//// restriction provided that this copyright statement is not    ////
23
//// removed from the file and that any derivative work contains  ////
24
//// the original copyright notice and the associated disclaimer. ////
25
////                                                              ////
26
//// This source file is free software; you can redistribute it   ////
27
//// and/or modify it under the terms of the GNU Lesser General   ////
28
//// Public License as published by the Free Software Foundation; ////
29
//// either version 2.1 of the License, or (at your option) any   ////
30
//// later version.                                               ////
31
////                                                              ////
32
//// This source is distributed in the hope that it will be       ////
33
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
34
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
35
//// PURPOSE.  See the GNU Lesser General Public License for more ////
36
//// details.                                                     ////
37
////                                                              ////
38
//// You should have received a copy of the GNU Lesser General    ////
39
//// Public License along with this source; if not, download it   ////
40
//// from http://www.opencores.org/lgpl.shtml                     ////
41
////                                                              ////
42
//////////////////////////////////////////////////////////////////////
43
//
44
// CVS Revision History
45
//
46 54 simont
// $Log: not supported by cvs2svn $
47 82 simont
// Revision 1.17  2002/11/05 17:23:54  simont
48
// add module oc8051_sfr, 256 bytes internal ram
49
//
50 76 simont
// Revision 1.16  2002/10/28 14:55:00  simont
51
// fix bug in interface to external data ram
52
//
53 72 simont
// Revision 1.15  2002/10/23 16:53:39  simont
54
// fix bugs in instruction interface
55
//
56 62 simont
// Revision 1.14  2002/10/17 18:50:00  simont
57
// cahnge interface to instruction rom
58
//
59 54 simont
// Revision 1.13  2002/09/30 17:33:59  simont
60
// prepared header
61 72 simont
//
62
//
63
 
64
// synopsys translate_off
65
`include "oc8051_timescale.v"
66
// synopsys translate_on
67
 
68
 
69 82 simont
module oc8051_top (rst_i, clk, int0, int1, ea, iadr_o, idat_i,istb_o, iack_i, ddat_i,
70
                icyc_o, ddat_o, dadr_o, dwe_o, dack_i, dstb_o, dcyc_o, p0_in, p1_in, p2_in, p3_in, p0_out,
71
                p1_out, p2_out, p3_out, rxd, txd, t0, t1, t2, t2ex);
72 72 simont
//
73 82 simont
// rst_i         (in)  reset - pin
74 72 simont
// clk           (in)  clock - pin
75
// iadr_o        (out) program rom addres (pin + internal)
76
// int0          (in)  external interrupt 0
77
// int1          (in)  external interrupt 1
78
// dat_i         (in)  exteranal ram input
79
// dat_o         (out) exteranal ram output
80
// adr_o         (out) external address
81 82 simont
// dwe_o         (out) write to external ram
82
// dstb_o
83 72 simont
// ack_i
84 54 simont
// idat_i        (in)  data from external program rom
85
// istb_o        (out) strobe to program rom
86
// iack_i        (in)  acknowlage from external rom
87
// icyc_o        (out)
88 72 simont
// p0_in, p1_in, p2_in, p3_in           (in)  port inputs
89
// p0_out, p1_out, p2_out, p3_out       (out) port outputs
90
// rxd           (in) receive
91
// txd           (out) transmit
92
// t0, t1        (in)  t/c external inputs
93
//
94
//
95
 
96
 
97
 
98 82 simont
input rst_i, clk, int0, int1, ea, rxd, t0, t1, dack_i, iack_i, t2, t2ex;
99
input [7:0] ddat_i, p0_in, p1_in, p2_in, p3_in;
100 54 simont
input [31:0] idat_i;
101 72 simont
 
102 82 simont
output dwe_o, txd, dstb_o, dcyc_o, istb_o, icyc_o;
103
output [7:0] ddat_o, p0_out, p1_out, p2_out, p3_out;
104 72 simont
 
105 82 simont
output [15:0] dadr_o, iadr_o;
106
 
107
wire [7:0] op1_i, op2_i, op3_i, dptr_hi, dptr_lo, ri, rn_mem, data_out;
108 54 simont
wire [7:0] op1, op2, op3;
109 76 simont
wire [7:0] acc, p0_out, p1_out, p2_out, p3_out;
110 82 simont
wire [7:0] sp, sp_w;
111 72 simont
 
112
wire [15:0] pc;
113
 
114 82 simont
wire rst;
115
assign rst = rst_i;
116 72 simont
 
117 82 simont
assign dcyc_o = dstb_o;
118 54 simont
assign icyc_o = istb_o;
119
 
120 72 simont
//
121
// ram_rd_sel    ram read (internal)
122
// ram_wr_sel    ram write (internal)
123
// src_sel1, src_sel2    from decoder to register
124 82 simont
wire src_sel3;
125
wire [2:0] ram_rd_sel, ram_wr_sel, wr_sfr;
126
wire [2:0] src_sel2, src_sel1;
127 72 simont
 
128
//
129
// wr_addr       ram write addres
130
// ram_out       data from ram
131
// rd_addr       data ram read addres
132
// rd_addr_r     data ram read addres registerd
133 82 simont
wire [7:0] ram_data, ram_out, sfr_out, wr_dat;
134
wire [7:0] wr_addr, rd_addr;
135 76 simont
wire sfr_bit;
136 72 simont
 
137
 
138
//
139
// cy_sel       carry select; from decoder to cy_selct1
140
// rom_addr_sel rom addres select; alu or pc
141
// ext_adddr_sel        external addres select; data pointer or Ri
142
// write_p      output from decoder; write to external ram, go to register;
143 82 simont
wire [1:0] cy_sel, bank_sel;
144
wire rom_addr_sel, rmw, ea_int;
145 72 simont
 
146
//
147
// int_uart     interrupt from uart
148
// tf0          interrupt from t/c 0
149
// tf1          interrupt from t/c 1
150
// tr0          timer 0 run
151
// tr1          timer 1 run
152 76 simont
wire reti, intr, int_ack, istb;
153 72 simont
wire [7:0] int_src;
154
 
155
//
156
//alu_op        alu operation (from decoder)
157
//psw_set       write to psw or not; from decoder to psw (through register)
158 82 simont
wire mem_wait;
159
wire [2:0] mem_act;
160
wire [3:0] alu_op;
161
wire [1:0] psw_set;
162 72 simont
 
163
//
164
// immediate1_r         from imediate_sel1 to alu_src1_sel1
165
// immediate2_r         from imediate_sel1 to alu_src2_sel1
166
// src1. src2, src2     alu sources
167
// des2, des2           alu destinations
168
// des1_r               destination 1 registerd (to comp1)
169
// desCy                carry out
170
// desAc
171
// desOv                overflow
172 82 simont
// wr                   write to data ram
173
wire [7:0] src1, src2, des1, des2, des1_r;
174
wire [7:0] src3;
175
wire desCy, desAc, desOv, alu_cy, wr, wr_o;
176 72 simont
 
177
 
178
//
179
// rd           read program rom
180
// pc_wr_sel    program counter write select (from decoder to pc)
181
wire rd, pc_wr;
182 82 simont
wire [2:0] pc_wr_sel;
183 72 simont
 
184
//
185
// op1_n                from op_select to decoder
186
// op2_n,         output of op_select, to immediate_sel1, pc1, comp1
187
// op3_n,         output of op_select, to immediate_sel1, ram_wr_sel1
188
// op2_dr,      output of op_select, to ram_rd_sel1, ram_wr_sel1
189 82 simont
wire [7:0] op1_n, op2_n, op3_n;
190 72 simont
 
191
//
192
// comp_sel     select source1 and source2 to compare
193
// eq           result (from comp1 to decoder)
194
wire [1:0] comp_sel;
195 82 simont
wire eq, srcAc, cy, rd_ind, wr_ind;
196
wire [2:0] op1_cur;
197 72 simont
 
198
 
199
//
200
// bit_addr     bit addresable instruction
201
// bit_data     bit data from ram to ram_select
202
// bit_out      bit data from ram_select to alu and cy_select
203 82 simont
wire bit_addr, bit_data, bit_out, bit_addr_o;
204 72 simont
 
205
//
206
 
207
 
208
 
209
//
210
// decoder
211 82 simont
oc8051_decoder oc8051_decoder1(.clk(clk), .rst(rst), .op_in(op1_n), .op1_c(op1_cur),
212 76 simont
     .ram_rd_sel(ram_rd_sel), .ram_wr_sel(ram_wr_sel), .bit_addr(bit_addr),
213 82 simont
     .src_sel1(src_sel1), .src_sel2(src_sel2),
214 62 simont
     .src_sel3(src_sel3), .alu_op(alu_op), .psw_set(psw_set),
215 82 simont
     .cy_sel(cy_sel), .wr(wr), .pc_wr(pc_wr),
216 76 simont
     .pc_sel(pc_wr_sel), .comp_sel(comp_sel), .eq(eq),
217 82 simont
     .wr_sfr(wr_sfr), .rd(rd), .rmw(rmw),
218
     .istb(istb), .mem_act(mem_act), .mem_wait(mem_wait));
219 72 simont
 
220
 
221
//
222
//alu
223 82 simont
oc8051_alu oc8051_alu1(.rst(rst), .clk(clk), .op_code(alu_op), .rd(rd),
224
     .src1(src1), .src2(src2), .src3(src3), .srcCy(alu_cy), .srcAc(srcAc),
225
     .des1(des1), .des2(des2), .des1_r(des1_r), .desCy(desCy),
226
     .desAc(desAc), .desOv(desOv), .bit_in(bit_out));
227 72 simont
 
228
//
229
//data ram
230
oc8051_ram_top oc8051_ram_top1(.clk(clk), .rst(rst), .rd_addr(rd_addr), .rd_data(ram_data),
231 82 simont
          .wr_addr(wr_addr), .bit_addr(bit_addr_o), .wr_data(wr_dat), .wr(wr_o && (!wr_addr[7] || wr_ind)),
232 72 simont
          .bit_data_in(desCy), .bit_data_out(bit_data));
233
 
234
//
235
 
236 82 simont
oc8051_alu_src_sel oc8051_alu_src_sel1(.clk(clk), .rst(rst), .rd(rd),
237
     .sel1(src_sel1), .sel2(src_sel2), .sel3(src_sel3),
238
     .acc(acc), .ram(ram_out), .pc(pc), .dptr({dptr_hi, dptr_lo}),
239
     .op1(op1_n), .op2(op2_n), .op3(op3_n),
240
     .src1(src1), .src2(src2), .src3(src3));
241
 
242
 
243 72 simont
//
244
//
245 76 simont
oc8051_comp oc8051_comp1(.sel(comp_sel), .eq(eq), .b_in(bit_out), .cy(cy), .acc(acc), .des(des1_r));
246 72 simont
 
247
 
248
//
249
//program rom
250 76 simont
oc8051_rom oc8051_rom1(.rst(rst), .clk(clk), .ea_int(ea_int), .addr(iadr_o),
251 72 simont
                .data1(op1_i), .data2(op2_i), .data3(op3_i));
252
 
253
//
254
//
255 82 simont
oc8051_cy_select oc8051_cy_select1(.cy_sel(cy_sel), .cy_in(cy), .data_in(bit_out),
256 72 simont
                 .data_out(alu_cy));
257
//
258
//
259 82 simont
oc8051_indi_addr oc8051_indi_addr1 (.clk(clk), .rst(rst), .rd_addr(rd_addr), .wr_addr(wr_addr),
260
      .data_in(wr_dat), .wr(wr_o), .wr_bit(bit_addr_o), .rn_out(rn_mem),
261
      .ri_out(ri), .sel(op1_cur), .bank(bank_sel));
262 72 simont
 
263
 
264
//
265
//
266 82 simont
oc8051_memory_interface oc8051_memory_interface1(.clk(clk), .rst(rst),
267
   .wr_i(wr), .wr_o(wr_o), .wr_bit_i(bit_addr), .wr_bit_o(bit_addr_o), .wr_dat(wr_dat),
268
//rom_addr_sel
269
   .iack_i(iack_i), .des1(des1), .des2(des2),
270
   .iadr_o(iadr_o), .sp_w(sp_w),
271 72 simont
 
272 82 simont
//ext_addr_sel
273
   .dptr({dptr_hi, dptr_lo}), .ri(ri), .rn_mem(rn_mem), .dadr_o(dadr_o), .ddat_o(ddat_o),
274
   .dwe_o(dwe_o), .dstb_o(dstb_o), .ddat_i(ddat_i), .acc(acc), .dack_i(dack_i),
275
 
276
//ram_addr_sel
277
   .rd_sel(ram_rd_sel), .wr_sel(ram_wr_sel), .sp(sp), .rn({bank_sel, op1_n[2:0]}),
278
   .rd_addr(rd_addr), .wr_addr(wr_addr), .rd_ind(rd_ind), .wr_ind(wr_ind),
279
 
280
//op_select
281
   .ea(ea), .ea_int(ea_int),
282
   .op1_i(op1_i), .op2_i(op2_i), .op3_i(op3_i),
283
   .idat_i(idat_i),
284
   .op1_out(op1_n), .op2_out(op2_n), .op3_out(op3_n),
285
   .intr(intr), .int_v(int_src), .rd(rd), .int_ack(int_ack), .istb(istb),
286
   .istb_o(istb_o),
287
 
288
//pc
289
   .pc_wr_sel(pc_wr_sel), .pc_wr(pc_wr), .pc(pc),
290
   .mem_act(mem_act), .mem_wait(mem_wait),
291
   .bit_in(bit_data), .in_ram(ram_data),
292
   .sfr(sfr_out), .sfr_bit(sfr_bit), .bit_out(bit_out), .iram_out(ram_out),
293
   .reti(reti));
294
 
295
 
296 72 simont
//
297
//
298
 
299 82 simont
oc8051_sfr oc8051_sfr1(.rst(rst), .clk(clk), .adr0(rd_addr[7:0]), .adr1(wr_addr[7:0]),
300
       .dat0(sfr_out), .dat1(wr_dat), .dat2(des2), .we(wr_o && !wr_ind), .bit_in(desCy),
301
       .bit_out(sfr_bit), .wr_bit(bit_addr_o), .ram_rd_sel(ram_rd_sel), .ram_wr_sel(ram_wr_sel), .wr_sfr(wr_sfr),
302 76 simont
// acc
303 82 simont
       .acc(acc),
304 76 simont
// sp
305 82 simont
       .sp(sp), .sp_w(sp_w),
306 76 simont
// psw
307 82 simont
       .bank_sel(bank_sel), .desAc(desAc), .desOv(desOv), .psw_set(psw_set),
308 76 simont
       .srcAc(srcAc), .cy(cy),
309
// ports
310
       .rmw(rmw), .p0_out(p0_out), .p1_out(p1_out), .p2_out(p2_out), .p3_out(p3_out),
311
       .p0_in(p0_in), .p1_in(p1_in), .p2_in(p2_in), .p3_in(p3_in),
312
// uart
313
       .rxd(rxd), .txd(txd),
314
// int
315
       .int_ack(int_ack), .intr(intr), .int0(int0), .int1(int1), .reti(reti), .int_src(int_src),
316
// t/c
317 82 simont
       .t0(t0), .t1(t1), .t2(t2), .t2ex(t2ex),
318 76 simont
// dptr
319
       .dptr_hi(dptr_hi), .dptr_lo(dptr_lo));
320 72 simont
 
321 82 simont
 
322 72 simont
endmodule

powered by: WebSVN 2.1.0

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