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

Subversion Repositories oms8051mini

[/] [oms8051mini/] [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/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 25 dinesha
////   v0.0 - Dinesh A, 5th Jan 2017
20
////        1. Active edge of reset changed from High to Low
21
//////////////////////////////////////////////////////////////////////
22 2 dinesha
////                                                              ////
23
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
24
////                                                              ////
25
//// This source file may be used and distributed without         ////
26
//// restriction provided that this copyright statement is not    ////
27
//// removed from the file and that any derivative work contains  ////
28
//// the original copyright notice and the associated disclaimer. ////
29
////                                                              ////
30
//// This source file is free software; you can redistribute it   ////
31
//// and/or modify it under the terms of the GNU Lesser General   ////
32
//// Public License as published by the Free Software Foundation; ////
33
//// either version 2.1 of the License, or (at your option) any   ////
34
//// later version.                                               ////
35
////                                                              ////
36
//// This source is distributed in the hope that it will be       ////
37
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
38
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
39
//// PURPOSE.  See the GNU Lesser General Public License for more ////
40
//// details.                                                     ////
41
////                                                              ////
42
//// You should have received a copy of the GNU Lesser General    ////
43
//// Public License along with this source; if not, download it   ////
44
//// from http://www.opencores.org/lgpl.shtml                     ////
45
////                                                              ////
46
//////////////////////////////////////////////////////////////////////
47
//
48
// CVS Revision History
49
//
50
// $Log: not supported by cvs2svn $
51
// Revision 1.9  2003/04/10 12:43:19  simont
52
// defines for pherypherals added
53
//
54
// Revision 1.8  2003/04/07 14:58:02  simont
55
// change sfr's interface.
56
//
57
// Revision 1.7  2003/01/13 14:14:41  simont
58
// replace some modules
59
//
60
// Revision 1.6  2002/09/30 17:33:59  simont
61
// prepared header
62
//
63
//
64
 
65
 
66
`include "top_defines.v"
67
 
68
 
69
module oc8051_ports (clk,
70 25 dinesha
                    resetn,
71 2 dinesha
                    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 25 dinesha
             resetn,    //reset
106 2 dinesha
             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 25 dinesha
always @(posedge clk or negedge resetn)
155 2 dinesha
begin
156 25 dinesha
  if (resetn == 1'b0) begin
157 2 dinesha
`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.