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

Subversion Repositories oms8051mini

[/] [oms8051mini/] [trunk/] [rtl/] [lib/] [registers.v] - Blame information for rev 14

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

Line No. Rev Author Line
1 2 dinesha
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OMS 8051 cores common library Module                        ////
4
////                                                              ////
5
////  This file is part of the OMS 8051 cores project             ////
6
////  http://www.opencores.org/cores/oms8051mini/                 ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  OMS 8051 definitions.                                       ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////    nothing                                                   ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Dinesh Annayya, dinesha@opencores.org                 ////
16
////                                                              ////
17
////  Revision : Nov 26, 2016                                     //// 
18
////                                                              ////
19
//////////////////////////////////////////////////////////////////////
20
////                                                              ////
21
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
22
////                                                              ////
23
//// This source file may be used and distributed without         ////
24
//// restriction provided that this copyright statement is not    ////
25
//// removed from the file and that any derivative work contains  ////
26
//// the original copyright notice and the associated disclaimer. ////
27
////                                                              ////
28
//// This source file is free software; you can redistribute it   ////
29
//// and/or modify it under the terms of the GNU Lesser General   ////
30
//// Public License as published by the Free Software Foundation; ////
31
//// either version 2.1 of the License, or (at your option) any   ////
32
//// later version.                                               ////
33
////                                                              ////
34
//// This source is distributed in the hope that it will be       ////
35
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
36
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
37
//// PURPOSE.  See the GNU Lesser General Public License for more ////
38
//// details.                                                     ////
39
////                                                              ////
40
//// You should have received a copy of the GNU Lesser General    ////
41
//// Public License along with this source; if not, download it   ////
42
//// from http://www.opencores.org/lgpl.shtml                     ////
43
////                                                              ////
44
//////////////////////////////////////////////////////////////////////
45
 
46
/*********************************************************************
47
** module: bit register
48
 
49
** description: infers a register, make it modular
50
 ***********************************************************************/
51
module bit_register (
52
                 //inputs
53
                 we,
54
                 clk,
55
                 reset_n,
56
                 data_in,
57
 
58
                 //outputs
59
                 data_out
60
                 );
61
 
62
//---------------------------------
63
// Reset Default value
64
//---------------------------------
65
parameter  RESET_DEFAULT = 1'h0;
66
 
67
  input  we;
68
  input  clk;
69
  input  reset_n;
70
  input  data_in;
71
  output data_out;
72
 
73
  reg    data_out;
74
 
75
  //infer the register
76
  always @(posedge clk or negedge reset_n)
77
    begin
78
      if (!reset_n)
79
        data_out <= RESET_DEFAULT;
80
      else if (we)
81
        data_out <= data_in;
82
    end // always @ (posedge clk or negedge reset_n)
83
endmodule // register
84
 
85
 
86
/*********************************************************************
87
** module: req register.
88
 
89
** description: This register is set by cpu writting 1 and reset by
90
                harward req = 1
91
 
92
 Note: When there is a clash between cpu and hardware, cpu is given higher
93
       priority
94
 
95
 ***********************************************************************/
96
module req_register (
97
                 //inputs
98
                 clk,
99
                 reset_n,
100
                 cpu_we,
101
                 cpu_req,
102
                 hware_ack,
103
 
104
                 //outputs
105
                 data_out
106
                 );
107
 
108
//---------------------------------
109
// Reset Default value
110
//---------------------------------
111
parameter  RESET_DEFAULT = 1'h0;
112
 
113
  input  clk      ;
114
  input  reset_n  ;
115
  input  cpu_we   ; // cpu write enable
116
  input  cpu_req  ; // CPU Request
117
  input  hware_ack; // Hardware Ack
118
  output data_out ;
119
 
120
  reg    data_out;
121
 
122
  //infer the register
123
  always @(posedge clk or negedge reset_n)
124
    begin
125
      if (!reset_n)
126
        data_out <= RESET_DEFAULT;
127
      else if (cpu_we & cpu_req) // Set on CPU Request
128
         data_out <= 1'b1;
129
      else if (hware_ack)  // Reset the flag on Hardware ack
130
         data_out <= 1'b0;
131
    end // always @ (posedge clk or negedge reset_n)
132
endmodule // register
133
 
134
 
135
/*********************************************************************
136
** module: req register.
137
 
138
** description: This register is cleared by cpu writting 1 and set by
139
                harward req = 1
140
 
141
 Note: When there is a clash between cpu and hardware,
142
       hardware is given higher priority
143
 
144
 ***********************************************************************/
145
module stat_register (
146
                 //inputs
147
                 clk,
148
                 reset_n,
149
                 cpu_we,
150
                 cpu_ack,
151
                 hware_req,
152
 
153
                 //outputs
154
                 data_out
155
                 );
156
 
157
//---------------------------------
158
// Reset Default value
159
//---------------------------------
160
parameter  RESET_DEFAULT = 1'h0;
161
 
162
  input  clk      ;
163
  input  reset_n  ;
164
  input  cpu_we   ; // cpu write enable
165
  input  cpu_ack  ; // CPU Ack
166
  input  hware_req; // Hardware Req
167
  output data_out ;
168
 
169
  reg    data_out;
170
 
171
  //infer the register
172
  always @(posedge clk or negedge reset_n)
173
    begin
174
      if (!reset_n)
175
        data_out <= RESET_DEFAULT;
176
      else if (hware_req)  // Set the flag on Hardware Req
177
         data_out <= 1'b1;
178
      else if (cpu_we & cpu_ack) // Clear on CPU Ack
179
         data_out <= 1'b0;
180
    end // always @ (posedge clk or negedge reset_n)
181
endmodule // register
182
 
183
 
184
 
185
 
186
 
187
/*********************************************************************
188
** copyright message here.
189
 
190
** module: generic register
191
 
192
***********************************************************************/
193
module  generic_register        (
194
              //List of Inputs
195
              we,
196
              data_in,
197
              reset_n,
198
              clk,
199
 
200
              //List of Outs
201
              data_out
202
              );
203
 
204
  parameter   WD               = 1;
205
  parameter   RESET_DEFAULT    = 0;
206
  input [WD-1:0]     we;
207
  input [WD-1:0]     data_in;
208
  input              reset_n;
209
  input              clk;
210
  output [WD-1:0]    data_out;
211
 
212
 
213
generate
214
  genvar i;
215
  for (i = 0; i < WD; i = i + 1) begin : gen_bit_reg
216
    bit_register #(RESET_DEFAULT[i]) u_bit_reg (
217
                .we         (we[i]),
218
                .clk        (clk),
219
                .reset_n    (reset_n),
220
                .data_in    (data_in[i]),
221
                .data_out   (data_out[i])
222
            );
223
  end
224
endgenerate
225
 
226
 
227
endmodule
228
 
229
 
230
/*********************************************************************
231
** copyright message here.
232
 
233
** module: generic register
234
 
235
***********************************************************************/
236
module  generic_intr_stat_reg   (
237
                 //inputs
238
                 clk,
239
                 reset_n,
240
                 reg_we,
241
                 reg_din,
242
                 hware_req,
243
 
244
                 //outputs
245
                 data_out
246
              );
247
 
248
  parameter   WD               = 1;
249
  parameter   RESET_DEFAULT    = 0;
250
  input [WD-1:0]     reg_we;
251
  input [WD-1:0]     reg_din;
252
  input [WD-1:0]     hware_req;
253
  input              reset_n;
254
  input              clk;
255
  output [WD-1:0]    data_out;
256
 
257
 
258
generate
259
  genvar i;
260
  for (i = 0; i < WD; i = i + 1) begin : gen_bit_reg
261
    stat_register #(RESET_DEFAULT[i]) u_bit_reg (
262
                 //inputs
263
                 . clk        (clk           ),
264
                 . reset_n    (reset_n       ),
265
                 . cpu_we     (reg_we[i]     ),
266
                 . cpu_ack    (reg_din[i]    ),
267
                 . hware_req  (hware_req[i]  ),
268
 
269
                 //outputs
270
                 . data_out  (data_out[i]    )
271
                 );
272
 
273
  end
274
endgenerate
275
 
276
 
277
endmodule

powered by: WebSVN 2.1.0

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