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

Subversion Repositories oms8051mini

[/] [oms8051mini/] [trunk/] [rtl/] [8051/] [oc8051_ports.v] - Blame information for rev 2

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/oms8051mini/                 ////
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
////      - Dinesh Annayya, simont@opencores.org                  ////
17
////                                                              ////
18
//////////////////////////////////////////////////////////////////////
19
////                                                              ////
20
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
21
////                                                              ////
22
//// This source file may be used and distributed without         ////
23
//// restriction provided that this copyright statement is not    ////
24
//// removed from the file and that any derivative work contains  ////
25
//// the original copyright notice and the associated disclaimer. ////
26
////                                                              ////
27
//// This source file is free software; you can redistribute it   ////
28
//// and/or modify it under the terms of the GNU Lesser General   ////
29
//// Public License as published by the Free Software Foundation; ////
30
//// either version 2.1 of the License, or (at your option) any   ////
31
//// later version.                                               ////
32
////                                                              ////
33
//// This source is distributed in the hope that it will be       ////
34
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
35
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
36
//// PURPOSE.  See the GNU Lesser General Public License for more ////
37
//// details.                                                     ////
38
////                                                              ////
39
//// You should have received a copy of the GNU Lesser General    ////
40
//// Public License along with this source; if not, download it   ////
41
//// from http://www.opencores.org/lgpl.shtml                     ////
42
////                                                              ////
43
//////////////////////////////////////////////////////////////////////
44
//
45
// CVS Revision History
46
//
47
// $Log: not supported by cvs2svn $
48
// Revision 1.9  2003/04/10 12:43:19  simont
49
// defines for pherypherals added
50
//
51
// Revision 1.8  2003/04/07 14:58:02  simont
52
// change sfr's interface.
53
//
54
// Revision 1.7  2003/01/13 14:14:41  simont
55
// replace some modules
56
//
57
// Revision 1.6  2002/09/30 17:33:59  simont
58
// prepared header
59
//
60
//
61
 
62
 
63
`include "top_defines.v"
64
 
65
 
66
module oc8051_ports (clk,
67
                    rst,
68
                    bit_in,
69
                    data_in,
70
                    wr,
71
                    wr_bit,
72
                    wr_addr,
73
 
74
        `ifdef OC8051_PORT0
75
                    p0_out,
76
                    p0_in,
77
                    p0_data,
78
        `endif
79
 
80
        `ifdef OC8051_PORT1
81
                    p1_out,
82
                    p1_in,
83
                    p1_data,
84
 
85
        `endif
86
 
87
        `ifdef OC8051_PORT2
88
                    p2_out,
89
                    p2_in,
90
                    p2_data,
91
        `endif
92
 
93
        `ifdef OC8051_PORT3
94
                    p3_out,
95
                    p3_in,
96
                    p3_data,
97
        `endif
98
 
99
                    rmw);
100
 
101
input        clk,       //clock
102
             rst,       //reset
103
             wr,        //write [oc8051_decoder.wr -r]
104
             wr_bit,    //write bit addresable [oc8051_decoder.bit_addr -r]
105
             bit_in,    //bit input [oc8051_alu.desCy]
106
             rmw;       //read modify write feature [oc8051_decoder.rmw]
107
input [7:0]  wr_addr,    //write address [oc8051_ram_wr_sel.out]
108
             data_in;   //data input (from alu destiantion 1) [oc8051_alu.des1]
109
 
110
`ifdef OC8051_PORT0
111
  input  [7:0] p0_in;
112
  output [7:0] p0_out,
113
               p0_data;
114
  reg    [7:0] p0_out;
115
 
116
  assign p0_data = rmw ? p0_out : p0_in;
117
`endif
118
 
119
 
120
`ifdef OC8051_PORT1
121
  input  [7:0] p1_in;
122
  output [7:0] p1_out,
123
               p1_data;
124
  reg    [7:0] p1_out;
125
 
126
  assign p1_data = rmw ? p1_out : p1_in;
127
`endif
128
 
129
 
130
`ifdef OC8051_PORT2
131
  input  [7:0] p2_in;
132
  output [7:0] p2_out,
133
               p2_data;
134
  reg    [7:0] p2_out;
135
 
136
  assign p2_data = rmw ? p2_out : p2_in;
137
`endif
138
 
139
 
140
`ifdef OC8051_PORT3
141
  input  [7:0] p3_in;
142
  output [7:0] p3_out,
143
               p3_data;
144
  reg    [7:0] p3_out;
145
 
146
  assign p3_data = rmw ? p3_out : p3_in;
147
`endif
148
 
149
//
150
// case of writing to port
151
always @(posedge clk or posedge rst)
152
begin
153
  if (rst) begin
154
`ifdef OC8051_PORT0
155
    p0_out <= #1 `OC8051_RST_P0;
156
`endif
157
 
158
`ifdef OC8051_PORT1
159
    p1_out <= #1 `OC8051_RST_P1;
160
`endif
161
 
162
`ifdef OC8051_PORT2
163
    p2_out <= #1 `OC8051_RST_P2;
164
`endif
165
 
166
`ifdef OC8051_PORT3
167
    p3_out <= #1 `OC8051_RST_P3;
168
`endif
169
  end else if (wr) begin
170
    if (!wr_bit) begin
171
      case (wr_addr) /* synopsys full_case parallel_case */
172
//
173
// bytaddresable
174
`ifdef OC8051_PORT0
175
        `OC8051_SFR_P0: begin p0_out <= #1 data_in;
176
         end
177
`endif
178
 
179
`ifdef OC8051_PORT1
180
        `OC8051_SFR_P1: p1_out <= #1 data_in;
181
`endif
182
 
183
`ifdef OC8051_PORT2
184
        `OC8051_SFR_P2: p2_out <= #1 data_in;
185
`endif
186
 
187
`ifdef OC8051_PORT3
188
        `OC8051_SFR_P3: p3_out <= #1 data_in;
189
`endif
190
      endcase
191
    end else begin
192
      case (wr_addr[7:3]) /* synopsys full_case parallel_case */
193
 
194
//
195
// bit addressable
196
`ifdef OC8051_PORT0
197
        `OC8051_SFR_B_P0: p0_out[wr_addr[2:0]] <= #1 bit_in;
198
`endif
199
 
200
`ifdef OC8051_PORT1
201
        `OC8051_SFR_B_P1: p1_out[wr_addr[2:0]] <= #1 bit_in;
202
`endif
203
 
204
`ifdef OC8051_PORT2
205
        `OC8051_SFR_B_P2: p2_out[wr_addr[2:0]] <= #1 bit_in;
206
`endif
207
 
208
`ifdef OC8051_PORT3
209
        `OC8051_SFR_B_P3: p3_out[wr_addr[2:0]] <= #1 bit_in;
210
`endif
211
      endcase
212
    end
213
  end
214
end
215
 
216
 
217
endmodule
218
 

powered by: WebSVN 2.1.0

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