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

Subversion Repositories turbo8051

[/] [turbo8051/] [trunk/] [rtl/] [8051/] [oc8051_ports.v] - Blame information for rev 25

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

Line No. Rev Author Line
1 2 dinesha
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  8051 port output                                            ////
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 registers: port 0:3 - output         ////
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.9  2003/04/10 12:43:19  simont
48
// defines for pherypherals added
49
//
50
// Revision 1.8  2003/04/07 14:58:02  simont
51
// change sfr's interface.
52
//
53
// Revision 1.7  2003/01/13 14:14:41  simont
54
// replace some modules
55
//
56
// Revision 1.6  2002/09/30 17:33:59  simont
57
// prepared header
58
//
59
//
60
 
61
 
62
// synopsys translate_off
63
`include "oc8051_timescale.v"
64
// synopsys translate_on
65
 
66
`include "oc8051_defines.v"
67
 
68
 
69
module oc8051_ports (clk,
70
                    rst,
71
                    bit_in,
72
                    data_in,
73
                    wr,
74
                    wr_bit,
75
                    wr_addr,
76
 
77
        `ifdef OC8051_PORT0
78
                    p0_out,
79
                    p0_in,
80
                    p0_data,
81
        `endif
82
 
83
        `ifdef OC8051_PORT1
84
                    p1_out,
85
                    p1_in,
86
                    p1_data,
87
 
88
        `endif
89
 
90
        `ifdef OC8051_PORT2
91
                    p2_out,
92
                    p2_in,
93
                    p2_data,
94
        `endif
95
 
96
        `ifdef OC8051_PORT3
97
                    p3_out,
98
                    p3_in,
99
                    p3_data,
100
        `endif
101
 
102
                    rmw);
103
 
104
input        clk,       //clock
105
             rst,       //reset
106
             wr,        //write [oc8051_decoder.wr -r]
107
             wr_bit,    //write bit addresable [oc8051_decoder.bit_addr -r]
108
             bit_in,    //bit input [oc8051_alu.desCy]
109
             rmw;       //read modify write feature [oc8051_decoder.rmw]
110
input [7:0]  wr_addr,    //write address [oc8051_ram_wr_sel.out]
111
             data_in;   //data input (from alu destiantion 1) [oc8051_alu.des1]
112
 
113
`ifdef OC8051_PORT0
114
  input  [7:0] p0_in;
115
  output [7:0] p0_out,
116
               p0_data;
117
  reg    [7:0] p0_out;
118
 
119
  assign p0_data = rmw ? p0_out : p0_in;
120
`endif
121
 
122
 
123
`ifdef OC8051_PORT1
124
  input  [7:0] p1_in;
125
  output [7:0] p1_out,
126
               p1_data;
127
  reg    [7:0] p1_out;
128
 
129
  assign p1_data = rmw ? p1_out : p1_in;
130
`endif
131
 
132
 
133
`ifdef OC8051_PORT2
134
  input  [7:0] p2_in;
135
  output [7:0] p2_out,
136
               p2_data;
137
  reg    [7:0] p2_out;
138
 
139
  assign p2_data = rmw ? p2_out : p2_in;
140
`endif
141
 
142
 
143
`ifdef OC8051_PORT3
144
  input  [7:0] p3_in;
145
  output [7:0] p3_out,
146
               p3_data;
147
  reg    [7:0] p3_out;
148
 
149
  assign p3_data = rmw ? p3_out : p3_in;
150
`endif
151
 
152
//
153
// case of writing to port
154
always @(posedge clk or posedge rst)
155
begin
156
  if (rst) begin
157
`ifdef OC8051_PORT0
158
    p0_out <= #1 `OC8051_RST_P0;
159
`endif
160
 
161
`ifdef OC8051_PORT1
162
    p1_out <= #1 `OC8051_RST_P1;
163
`endif
164
 
165
`ifdef OC8051_PORT2
166
    p2_out <= #1 `OC8051_RST_P2;
167
`endif
168
 
169
`ifdef OC8051_PORT3
170
    p3_out <= #1 `OC8051_RST_P3;
171
`endif
172
  end else if (wr) begin
173
    if (!wr_bit) begin
174
      case (wr_addr) /* synopsys full_case parallel_case */
175
//
176
// bytaddresable
177
`ifdef OC8051_PORT0
178
        `OC8051_SFR_P0: begin p0_out <= #1 data_in;
179
         end
180
`endif
181
 
182
`ifdef OC8051_PORT1
183
        `OC8051_SFR_P1: p1_out <= #1 data_in;
184
`endif
185
 
186
`ifdef OC8051_PORT2
187
        `OC8051_SFR_P2: p2_out <= #1 data_in;
188
`endif
189
 
190
`ifdef OC8051_PORT3
191
        `OC8051_SFR_P3: p3_out <= #1 data_in;
192
`endif
193
      endcase
194
    end else begin
195
      case (wr_addr[7:3]) /* synopsys full_case parallel_case */
196
 
197
//
198
// bit addressable
199
`ifdef OC8051_PORT0
200
        `OC8051_SFR_B_P0: p0_out[wr_addr[2:0]] <= #1 bit_in;
201
`endif
202
 
203
`ifdef OC8051_PORT1
204
        `OC8051_SFR_B_P1: p1_out[wr_addr[2:0]] <= #1 bit_in;
205
`endif
206
 
207
`ifdef OC8051_PORT2
208
        `OC8051_SFR_B_P2: p2_out[wr_addr[2:0]] <= #1 bit_in;
209
`endif
210
 
211
`ifdef OC8051_PORT3
212
        `OC8051_SFR_B_P3: p3_out[wr_addr[2:0]] <= #1 bit_in;
213
`endif
214
      endcase
215
    end
216
  end
217
end
218
 
219
 
220
endmodule
221
 

powered by: WebSVN 2.1.0

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