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

Subversion Repositories turbo8051

[/] [turbo8051/] [trunk/] [rtl/] [lib/] [registers.v] - Blame information for rev 36

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

Line No. Rev Author Line
1 11 dinesha
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  Tubo 8051 cores common library Module                       ////
4
////                                                              ////
5
////  This file is part of the Turbo 8051 cores project           ////
6
////  http://www.opencores.org/cores/turbo8051/                   ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  Turbo 8051 definitions.                                     ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////    nothing                                                   ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Dinesh Annayya, dinesha@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
//`timescale 1ns/100ps
44
 
45
/*********************************************************************
46
** module: bit register
47
 
48
** description: infers a register, make it modular
49
 ***********************************************************************/
50
module bit_register (
51
                 //inputs
52
                 we,
53
                 clk,
54
                 reset_n,
55
                 data_in,
56
 
57
                 //outputs
58
                 data_out
59
                 );
60
 
61
//---------------------------------
62
// Reset Default value
63
//---------------------------------
64
parameter  RESET_DEFAULT = 1'h0;
65
 
66
  input  we;
67
  input  clk;
68
  input  reset_n;
69
  input  data_in;
70
  output data_out;
71
 
72
  reg    data_out;
73
 
74
  //infer the register
75
  always @(posedge clk or negedge reset_n)
76
    begin
77
      if (!reset_n)
78
        data_out <= RESET_DEFAULT;
79
      else if (we)
80
        data_out <= data_in;
81
    end // always @ (posedge clk or negedge reset_n)
82
endmodule // register
83
 
84
 
85
/*********************************************************************
86
** module: req register.
87
 
88
** description: This register is set by cpu writting 1 and reset by
89
                harward req = 1
90
 
91
 Note: When there is a clash between cpu and hardware, cpu is given higher
92
       priority
93
 
94
 ***********************************************************************/
95
module req_register (
96
                 //inputs
97
                 clk,
98
                 reset_n,
99
                 cpu_we,
100
                 cpu_req,
101
                 hware_ack,
102
 
103
                 //outputs
104
                 data_out
105
                 );
106
 
107
//---------------------------------
108
// Reset Default value
109
//---------------------------------
110
parameter  RESET_DEFAULT = 1'h0;
111
 
112
  input  clk      ;
113
  input  reset_n  ;
114
  input  cpu_we   ; // cpu write enable
115
  input  cpu_req  ; // CPU Request
116
  input  hware_ack; // Hardware Ack
117
  output data_out ;
118
 
119
  reg    data_out;
120
 
121
  //infer the register
122
  always @(posedge clk or negedge reset_n)
123
    begin
124
      if (!reset_n)
125
        data_out <= RESET_DEFAULT;
126
      else if (cpu_we & cpu_req) // Set on CPU Request
127
         data_out <= 1'b1;
128
      else if (hware_ack)  // Reset the flag on Hardware ack
129
         data_out <= 1'b0;
130
    end // always @ (posedge clk or negedge reset_n)
131
endmodule // register
132
 
133
 
134
/*********************************************************************
135
** module: req register.
136
 
137
** description: This register is cleared by cpu writting 1 and set by
138
                harward req = 1
139
 
140
 Note: When there is a clash between cpu and hardware,
141
       hardware is given higher priority
142
 
143
 ***********************************************************************/
144
module stat_register (
145
                 //inputs
146
                 clk,
147
                 reset_n,
148
                 cpu_we,
149
                 cpu_ack,
150
                 hware_req,
151
 
152
                 //outputs
153
                 data_out
154
                 );
155
 
156
//---------------------------------
157
// Reset Default value
158
//---------------------------------
159
parameter  RESET_DEFAULT = 1'h0;
160
 
161
  input  clk      ;
162
  input  reset_n  ;
163
  input  cpu_we   ; // cpu write enable
164
  input  cpu_ack  ; // CPU Ack
165
  input  hware_req; // Hardware Req
166
  output data_out ;
167
 
168
  reg    data_out;
169
 
170
  //infer the register
171
  always @(posedge clk or negedge reset_n)
172
    begin
173
      if (!reset_n)
174
        data_out <= RESET_DEFAULT;
175
      else if (hware_req)  // Set the flag on Hardware Req
176
         data_out <= 1'b1;
177
      else if (cpu_we & cpu_ack) // Clear on CPU Ack
178
         data_out <= 1'b0;
179
    end // always @ (posedge clk or negedge reset_n)
180
endmodule // register
181
 
182
 
183
 
184
 
185
 
186
/*********************************************************************
187
** copyright message here.
188
 
189
** module: generic register
190
 
191
***********************************************************************/
192
module  generic_register        (
193
              //List of Inputs
194
              we,
195
              data_in,
196
              reset_n,
197
              clk,
198
 
199
              //List of Outs
200
              data_out
201
              );
202
 
203
  parameter   WD               = 1;
204
  parameter   RESET_DEFAULT    = 0;
205
  input [WD-1:0]     we;
206
  input [WD-1:0]     data_in;
207
  input              reset_n;
208
  input              clk;
209
  output [WD-1:0]    data_out;
210
 
211
 
212
generate
213
  genvar i;
214
  for (i = 0; i < WD; i = i + 1) begin : gen_bit_reg
215
    bit_register #(RESET_DEFAULT[i]) u_bit_reg (
216
                .we         (we[i]),
217
                .clk        (clk),
218
                .reset_n    (reset_n),
219
                .data_in    (data_in[i]),
220
                .data_out   (data_out[i])
221
            );
222
  end
223
endgenerate
224
 
225
 
226
endmodule
227
 
228
 
229
/*********************************************************************
230
** copyright message here.
231
 
232
** module: generic register
233
 
234
***********************************************************************/
235
module  generic_intr_stat_reg   (
236
                 //inputs
237
                 clk,
238
                 reset_n,
239
                 reg_we,
240
                 reg_din,
241
                 hware_req,
242
 
243
                 //outputs
244
                 data_out
245
              );
246
 
247
  parameter   WD               = 1;
248
  parameter   RESET_DEFAULT    = 0;
249
  input [WD-1:0]     reg_we;
250
  input [WD-1:0]     reg_din;
251
  input [WD-1:0]     hware_req;
252
  input              reset_n;
253
  input              clk;
254
  output [WD-1:0]    data_out;
255
 
256
 
257
generate
258
  genvar i;
259
  for (i = 0; i < WD; i = i + 1) begin : gen_bit_reg
260
    stat_register #(RESET_DEFAULT[i]) u_bit_reg (
261
                 //inputs
262
                 . clk        (clk           ),
263
                 . reset_n    (reset_n       ),
264
                 . cpu_we     (reg_we[i]     ),
265
                 . cpu_ack    (reg_din[i]    ),
266
                 . hware_req  (hware_req[i]  ),
267
 
268
                 //outputs
269
                 . data_out  (data_out[i]    )
270
                 );
271
 
272
  end
273
endgenerate
274
 
275
 
276
endmodule

powered by: WebSVN 2.1.0

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