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

Subversion Repositories or1200_hp

[/] [or1200_hp/] [trunk/] [rtl/] [rtl_cm3/] [verilog/] [or1200_tt.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 tobil
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OR1200's Tick Timer                                         ////
4
////                                                              ////
5
////  This file is part of the OpenRISC 1200 project              ////
6
////  http://www.opencores.org/cores/or1k/                        ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  TT according to OR1K architectural specification.           ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////   None                                                       ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Damjan Lampret, lampret@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.4  2002/03/29 15:16:56  lampret
48
// Some of the warnings fixed.
49
//
50
// Revision 1.3  2002/02/12 01:33:47  lampret
51
// No longer using async rst as sync reset for the counter.
52
//
53
// Revision 1.2  2002/01/28 01:16:00  lampret
54
// Changed 'void' nop-ops instead of insn[0] to use insn[16]. Debug unit stalls the tick timer. Prepared new flag generation for add and and insns. Blocked DC/IC while they are turned off. Fixed I/D MMU SPRs layout except WAYs. TODO: smart IC invalidate, l.j 2 and TLB ways.
55
//
56
// Revision 1.1  2002/01/03 08:16:15  lampret
57
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
58
//
59
// Revision 1.10  2001/11/13 10:00:49  lampret
60
// Fixed tick timer interrupt reporting by using TTCR[IP] bit.
61
//
62
// Revision 1.9  2001/11/10 03:43:57  lampret
63
// Fixed exceptions.
64
//
65
// Revision 1.8  2001/10/21 17:57:16  lampret
66
// Removed params from generic_XX.v. Added translate_off/on in sprs.v and id.v. Removed spr_addr from dc.v and ic.v. Fixed CR+LF.
67
//
68
// Revision 1.7  2001/10/14 13:12:10  lampret
69
// MP3 version.
70
//
71
// Revision 1.1.1.1  2001/10/06 10:18:35  igorm
72
// no message
73
//
74
// Revision 1.2  2001/08/09 13:39:33  lampret
75
// Major clean-up.
76
//
77
// Revision 1.1  2001/07/20 00:46:23  lampret
78
// Development version of RTL. Libraries are missing.
79
//
80
//
81
 
82
// synopsys translate_off
83
`include "timescale.v"
84
// synopsys translate_on
85
`include "or1200_defines.v"
86
 
87
module or1200_tt_cm3(
88
                clk_i_cml_1,
89
                clk_i_cml_2,
90
 
91
        // RISC Internal Interface
92
        clk, rst, du_stall,
93
        spr_cs, spr_write, spr_addr, spr_dat_i, spr_dat_o,
94
        intr
95
);
96
 
97
 
98
input clk_i_cml_1;
99
input clk_i_cml_2;
100
reg  du_stall_cml_2;
101
reg  spr_write_cml_2;
102
reg [ 31 : 0 ] spr_addr_cml_2;
103
reg [ 31 : 0 ] spr_addr_cml_1;
104
reg [ 31 : 0 ] spr_dat_i_cml_2;
105
reg [ 31 : 0 ] spr_dat_i_cml_1;
106
reg [ 31 : 0 ] ttmr_cml_2;
107
reg [ 31 : 0 ] ttmr_cml_1;
108
reg [ 31 : 0 ] ttcr_cml_2;
109
reg [ 31 : 0 ] ttcr_cml_1;
110
reg  match_cml_2;
111
 
112
 
113
 
114
//
115
// RISC Internal Interface
116
//
117
input           clk;            // Clock
118
input           rst;            // Reset
119
input           du_stall;       // DU stall
120
input           spr_cs;         // SPR CS
121
input           spr_write;      // SPR Write
122
input   [31:0]   spr_addr;       // SPR Address
123
input   [31:0]   spr_dat_i;      // SPR Write Data
124
output  [31:0]   spr_dat_o;      // SPR Read Data
125
output          intr;           // Interrupt output
126
 
127
`ifdef OR1200_TT_IMPLEMENTED
128
 
129
//
130
// TT Mode Register bits (or no register)
131
//
132
`ifdef OR1200_TT_TTMR
133
reg     [31:0]   ttmr;   // TTMR bits
134
`else
135
wire    [31:0]   ttmr;   // No TTMR register
136
`endif
137
 
138
//
139
// TT Count Register bits (or no register)
140
//
141
`ifdef OR1200_TT_TTCR
142
reg     [31:0]   ttcr;   // TTCR bits
143
`else
144
wire    [31:0]   ttcr;   // No TTCR register
145
`endif
146
 
147
//
148
// Internal wires & regs
149
//
150
wire            ttmr_sel;       // TTMR select
151
wire            ttcr_sel;       // TTCR select
152
wire            match;          // Asserted when TTMR[TP]
153
                                // is equal to TTCR[27:0]
154
wire            restart;        // Restart counter when asserted
155
wire            stop;           // Stop counter when asserted
156
reg     [31:0]   spr_dat_o;      // SPR data out
157
 
158
//
159
// TT registers address decoder
160
//
161
 
162
// SynEDA CoreMultiplier
163
// assignment(s): ttmr_sel
164
// replace(s): spr_addr
165
assign ttmr_sel = (spr_cs && (spr_addr_cml_2[`OR1200_TTOFS_BITS] == `OR1200_TT_OFS_TTMR)) ? 1'b1 : 1'b0;
166
 
167
// SynEDA CoreMultiplier
168
// assignment(s): ttcr_sel
169
// replace(s): spr_addr
170
assign ttcr_sel = (spr_cs && (spr_addr_cml_2[`OR1200_TTOFS_BITS] == `OR1200_TT_OFS_TTCR)) ? 1'b1 : 1'b0;
171
 
172
//
173
// Write to TTMR or update of TTMR[IP] bit
174
//
175
`ifdef OR1200_TT_TTMR
176
 
177
// SynEDA CoreMultiplier
178
// assignment(s): ttmr
179
// replace(s): spr_write, spr_dat_i, ttmr, match
180
always @(posedge clk or posedge rst)
181
        if (rst)
182
                ttmr <= 32'b0;
183
        else begin  ttmr <= ttmr_cml_2; if (ttmr_sel && spr_write_cml_2)
184
                ttmr <= #1 spr_dat_i_cml_2;
185
        else if (ttmr_cml_2[`OR1200_TT_TTMR_IE])
186
                ttmr[`OR1200_TT_TTMR_IP] <= #1 ttmr_cml_2[`OR1200_TT_TTMR_IP] | (match_cml_2 & ttmr_cml_2[`OR1200_TT_TTMR_IE]); end
187
`else
188
assign ttmr = {2'b11, 30'b0};    // TTMR[M] = 0x3
189
`endif
190
 
191
//
192
// Write to or increment of TTCR
193
//
194
`ifdef OR1200_TT_TTCR
195
 
196
// SynEDA CoreMultiplier
197
// assignment(s): ttcr
198
// replace(s): spr_write, spr_dat_i, ttcr
199
always @(posedge clk or posedge rst)
200
        if (rst)
201
                ttcr <= 32'b0;
202
        else begin  ttcr <= ttcr_cml_2; if (restart)
203
                ttcr <= #1 32'b0;
204
        else if (ttcr_sel && spr_write_cml_2)
205
                ttcr <= #1 spr_dat_i_cml_2;
206
        else if (!stop)
207
                ttcr <= #1 ttcr_cml_2 + 32'd1; end
208
`else
209
assign ttcr = 32'b0;
210
`endif
211
 
212
//
213
// Read TT registers
214
//
215
 
216
// SynEDA CoreMultiplier
217
// assignment(s): spr_dat_o
218
// replace(s): spr_addr, ttmr, ttcr
219
always @(spr_addr_cml_1 or ttmr_cml_1 or ttcr_cml_1)
220
        case (spr_addr_cml_1[`OR1200_TTOFS_BITS])       // synopsys parallel_case
221
`ifdef OR1200_TT_READREGS
222
                `OR1200_TT_OFS_TTMR: spr_dat_o = ttmr_cml_1;
223
`endif
224
                default: spr_dat_o = ttcr_cml_1;
225
        endcase
226
 
227
//
228
// A match when TTMR[TP] is equal to TTCR[27:0]
229
//
230
 
231
// SynEDA CoreMultiplier
232
// assignment(s): match
233
// replace(s): ttmr, ttcr
234
assign match = (ttmr_cml_1[`OR1200_TT_TTMR_TP] == ttcr_cml_1[27:0]) ? 1'b1 : 1'b0;
235
 
236
//
237
// Restart when match and TTMR[M]==0x1
238
//
239
 
240
// SynEDA CoreMultiplier
241
// assignment(s): restart
242
// replace(s): ttmr, match
243
assign restart = match_cml_2 && (ttmr_cml_2[`OR1200_TT_TTMR_M] == 2'b01);
244
 
245
//
246
// Stop when match and TTMR[M]==0x2 or when TTMR[M]==0x0 or when RISC is stalled by debug unit
247
//
248
 
249
// SynEDA CoreMultiplier
250
// assignment(s): stop
251
// replace(s): du_stall, ttmr, match
252
assign stop = match_cml_2 & (ttmr_cml_2[`OR1200_TT_TTMR_M] == 2'b10) | (ttmr_cml_2[`OR1200_TT_TTMR_M] == 2'b00) | du_stall_cml_2;
253
 
254
//
255
// Generate an interrupt request
256
//
257
 
258
// SynEDA CoreMultiplier
259
// assignment(s): intr
260
// replace(s): ttmr
261
assign intr = ttmr_cml_1[`OR1200_TT_TTMR_IP];
262
 
263
`else
264
 
265
//
266
// When TT is not implemented, drive all outputs as would when TT is disabled
267
//
268
assign intr = 1'b0;
269
 
270
//
271
// Read TT registers
272
//
273
`ifdef OR1200_TT_READREGS
274
assign spr_dat_o = 32'b0;
275
`endif
276
 
277
`endif
278
 
279
 
280
always @ (posedge clk_i_cml_1) begin
281
spr_addr_cml_1 <= spr_addr;
282
spr_dat_i_cml_1 <= spr_dat_i;
283
ttmr_cml_1 <= ttmr;
284
ttcr_cml_1 <= ttcr;
285
end
286
always @ (posedge clk_i_cml_2) begin
287
du_stall_cml_2 <= du_stall;
288
spr_write_cml_2 <= spr_write;
289
spr_addr_cml_2 <= spr_addr_cml_1;
290
spr_dat_i_cml_2 <= spr_dat_i_cml_1;
291
ttmr_cml_2 <= ttmr_cml_1;
292
ttcr_cml_2 <= ttcr_cml_1;
293
match_cml_2 <= match;
294
end
295
endmodule
296
 

powered by: WebSVN 2.1.0

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