1 |
2 |
dinesha |
//////////////////////////////////////////////////////////////////////
|
2 |
|
|
//// ////
|
3 |
|
|
//// 8051 data pointer ////
|
4 |
|
|
//// ////
|
5 |
|
|
//// This file is part of the 8051 cores project ////
|
6 |
|
|
//// http://www.opencores.org/cores/8051/ ////
|
7 |
|
|
//// ////
|
8 |
|
|
//// Description ////
|
9 |
|
|
//// 8051 special function register: data pointer ////
|
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 |
|
|
// $Log: not supported by cvs2svn $
|
47 |
|
|
// Revision 1.3 2003/01/13 14:14:40 simont
|
48 |
|
|
// replace some modules
|
49 |
|
|
//
|
50 |
|
|
// Revision 1.2 2002/09/30 17:33:59 simont
|
51 |
|
|
// prepared header
|
52 |
|
|
//
|
53 |
|
|
//
|
54 |
|
|
|
55 |
|
|
// synopsys translate_off
|
56 |
|
|
`include "oc8051_timescale.v"
|
57 |
|
|
// synopsys translate_on
|
58 |
|
|
|
59 |
|
|
`include "oc8051_defines.v"
|
60 |
|
|
|
61 |
|
|
|
62 |
|
|
module oc8051_dptr(clk, rst, addr, data_in, data2_in, wr, wr_sfr, wr_bit, data_hi, data_lo);
|
63 |
|
|
//
|
64 |
|
|
// clk (in) clock
|
65 |
|
|
// rst (in) reset
|
66 |
|
|
// addr (in) write address input [oc8051_ram_wr_sel.out]
|
67 |
|
|
// data_in (in) destination 1 from alu [oc8051_alu.des1]
|
68 |
|
|
// data2_in (in) destination 2 from alu [oc8051_alu.des2]
|
69 |
|
|
// wr (in) write to ram [oc8051_decoder.wr -r]
|
70 |
|
|
// wd2 (in) write from destination 2 [oc8051_decoder.ram_wr_sel -r]
|
71 |
|
|
// wr_bit (in) write bit addresable [oc8051_decoder.bit_addr -r]
|
72 |
|
|
// data_hi (out) output (high bits) [oc8051_alu_src3_sel.dptr, oc8051_ext_addr_sel.dptr_hi, oc8051_ram_sel.dptr_hi]
|
73 |
|
|
// data_lo (out) output (low bits) [oc8051_ext_addr_sel.dptr_lo]
|
74 |
|
|
//
|
75 |
|
|
|
76 |
|
|
|
77 |
|
|
input clk, rst, wr, wr_bit;
|
78 |
|
|
input [1:0] wr_sfr;
|
79 |
|
|
input [7:0] addr, data_in, data2_in;
|
80 |
|
|
|
81 |
|
|
output [7:0] data_hi, data_lo;
|
82 |
|
|
|
83 |
|
|
reg [7:0] data_hi, data_lo;
|
84 |
|
|
|
85 |
|
|
always @(posedge clk or posedge rst)
|
86 |
|
|
begin
|
87 |
|
|
if (rst) begin
|
88 |
|
|
data_hi <= #1 `OC8051_RST_DPH;
|
89 |
|
|
data_lo <= #1 `OC8051_RST_DPL;
|
90 |
|
|
end else if (wr_sfr==`OC8051_WRS_DPTR) begin
|
91 |
|
|
//
|
92 |
|
|
//write from destination 2 and 1
|
93 |
|
|
data_hi <= #1 data2_in;
|
94 |
|
|
data_lo <= #1 data_in;
|
95 |
|
|
end else if ((addr==`OC8051_SFR_DPTR_HI) & (wr) & !(wr_bit))
|
96 |
|
|
//
|
97 |
|
|
//case of writing to dptr
|
98 |
|
|
data_hi <= #1 data_in;
|
99 |
|
|
else if ((addr==`OC8051_SFR_DPTR_LO) & (wr) & !(wr_bit))
|
100 |
|
|
data_lo <= #1 data_in;
|
101 |
|
|
end
|
102 |
|
|
|
103 |
|
|
endmodule
|
104 |
|
|
|