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

Subversion Repositories or1k

[/] [or1k/] [tags/] [rel_13/] [or1200/] [rtl/] [verilog/] [or1200_tt.v] - Blame information for rev 663

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

Line No. Rev Author Line
1 504 lampret
//////////////////////////////////////////////////////////////////////
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 663 lampret
// Revision 1.2  2002/01/28 01:16:00  lampret
48
// 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.
49
//
50 617 lampret
// Revision 1.1  2002/01/03 08:16:15  lampret
51
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
52
//
53 504 lampret
// Revision 1.10  2001/11/13 10:00:49  lampret
54
// Fixed tick timer interrupt reporting by using TTCR[IP] bit.
55
//
56
// Revision 1.9  2001/11/10 03:43:57  lampret
57
// Fixed exceptions.
58
//
59
// Revision 1.8  2001/10/21 17:57:16  lampret
60
// 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.
61
//
62
// Revision 1.7  2001/10/14 13:12:10  lampret
63
// MP3 version.
64
//
65
// Revision 1.1.1.1  2001/10/06 10:18:35  igorm
66
// no message
67
//
68
// Revision 1.2  2001/08/09 13:39:33  lampret
69
// Major clean-up.
70
//
71
// Revision 1.1  2001/07/20 00:46:23  lampret
72
// Development version of RTL. Libraries are missing.
73
//
74
//
75
 
76
// synopsys translate_off
77
`include "timescale.v"
78
// synopsys translate_on
79
`include "or1200_defines.v"
80
 
81
module or1200_tt(
82
        // RISC Internal Interface
83 617 lampret
        clk, rst, du_stall,
84
        spr_cs, spr_write, spr_addr, spr_dat_i, spr_dat_o,
85 504 lampret
        int
86
);
87
 
88
//
89
// RISC Internal Interface
90
//
91
input           clk;            // Clock
92
input           rst;            // Reset
93 617 lampret
input           du_stall;       // DU stall
94 504 lampret
input           spr_cs;         // SPR CS
95
input           spr_write;      // SPR Write
96
input   [31:0]   spr_addr;       // SPR Address
97
input   [31:0]   spr_dat_i;      // SPR Write Data
98
output  [31:0]   spr_dat_o;      // SPR Read Data
99
output          int;            // Interrupt output
100
 
101
`ifdef OR1200_TT_IMPLEMENTED
102
 
103
//
104
// TT Mode Register bits (or no register)
105
//
106
`ifdef OR1200_TT_TTMR
107
reg     [31:0]   ttmr;   // TTMR bits
108
`else
109
wire    [31:0]   ttmr;   // No TTMR register
110
`endif
111
 
112
//
113
// TT Count Register bits (or no register)
114
//
115
`ifdef OR1200_TT_TTCR
116
reg     [31:0]   ttcr;   // TTCR bits
117
`else
118
wire    [31:0]   ttcr;   // No TTCR register
119
`endif
120
 
121
//
122
// Internal wires & regs
123
//
124
wire            ttmr_sel;       // TTMR select
125
wire            ttcr_sel;       // TTCR select
126
wire            match;          // Asserted when TTMR[TP]
127
                                // is equal to TTCR[27:0]
128
wire            restart;        // Restart counter when asserted
129
wire            stop;           // Stop counter when asserted
130
reg     [31:0]   spr_dat_o;      // SPR data out
131
 
132
//
133
// TT registers address decoder
134
//
135
assign ttmr_sel = (spr_cs && (spr_addr[`OR1200_TTOFS_BITS] == `OR1200_TT_OFS_TTMR)) ? 1'b1 : 1'b0;
136
assign ttcr_sel = (spr_cs && (spr_addr[`OR1200_TTOFS_BITS] == `OR1200_TT_OFS_TTCR)) ? 1'b1 : 1'b0;
137
 
138
//
139
// Write to TTMR or update of TTMR[IP] bit
140
//
141
`ifdef OR1200_TT_TTMR
142
always @(posedge clk or posedge rst)
143
        if (rst)
144
                ttmr <= 32'b0;
145
        else if (ttmr_sel && spr_write)
146
                ttmr <= #1 spr_dat_i;
147
        else if (ttmr[`OR1200_TT_TTMR_IE])
148
                ttmr[`OR1200_TT_TTMR_IP] <= #1 ttmr[`OR1200_TT_TTMR_IP] | (match & ttmr[`OR1200_TT_TTMR_IE]);
149
`else
150
assign ttmr = {2'b11, 30'b0};    // TTMR[M] = 0x3
151
`endif
152
 
153
//
154
// Write to or increment of TTCR
155
//
156
`ifdef OR1200_TT_TTCR
157
always @(posedge clk or posedge rst)
158
        if (rst)
159
                ttcr <= 32'b0;
160
        else if (restart)
161
                ttcr <= #1 32'b0;
162
        else if (ttcr_sel && spr_write)
163
                ttcr <= #1 spr_dat_i;
164
        else if (!stop)
165
                ttcr <= #1 ttcr + 1'd1;
166
`else
167
assign ttcr = 32'b0;
168
`endif
169
 
170
//
171
// Read TT registers
172
//
173
always @(spr_addr or ttmr or ttcr)
174
        case (spr_addr[`OR1200_TTOFS_BITS])     // synopsys full_case parallel_case
175
`ifdef OR1200_TT_READREGS
176
                `OR1200_TT_OFS_TTMR: spr_dat_o = ttmr;
177
`endif
178
                default: spr_dat_o = ttcr;
179
        endcase
180
 
181
//
182
// A match when TTMR[TP] is equal to TTCR[27:0]
183
//
184
assign match = (ttmr[`OR1200_TT_TTMR_TP] == ttcr[27:0]) ? 1'b1 : 1'b0;
185
 
186
//
187 663 lampret
// Restart when match and TTMR[M]==0x1
188 504 lampret
//
189 663 lampret
assign restart = match && (ttmr[`OR1200_TT_TTMR_M] == 2'b01);
190 504 lampret
 
191
//
192 617 lampret
// Stop when match and TTMR[M]==0x2 or when TTMR[M]==0x0 or when RISC is stalled by debug unit
193 504 lampret
//
194 617 lampret
assign stop = match & (ttmr[`OR1200_TT_TTMR_M] == 2'b10) | (ttmr[`OR1200_TT_TTMR_M] == 2'b00) | du_stall;
195 504 lampret
 
196
//
197
// Generate an interrupt request
198
//
199
assign int = ttmr[`OR1200_TT_TTMR_IP];
200
 
201
`else
202
 
203
//
204
// When TT is not implemented, drive all outputs as would when TT is disabled
205
//
206
assign int = 1'b0;
207
 
208
//
209
// Read TT registers
210
//
211
`ifdef OR1200_TT_READREGS
212
assign spr_dat_o = 32'b0;
213
`endif
214
 
215
`endif
216
 
217
endmodule

powered by: WebSVN 2.1.0

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