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

Subversion Repositories or1k

[/] [or1k/] [branches/] [mp3_stable/] [or1200/] [rtl/] [verilog/] [tt.v] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 218 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
// Revision 1.7  2001/10/14 13:12:10  lampret
48
// MP3 version.
49
//
50
// Revision 1.1.1.1  2001/10/06 10:18:35  igorm
51
// no message
52
//
53
// Revision 1.2  2001/08/09 13:39:33  lampret
54
// Major clean-up.
55
//
56
// Revision 1.1  2001/07/20 00:46:23  lampret
57
// Development version of RTL. Libraries are missing.
58
//
59
//
60
 
61
// synopsys translate_off
62
`include "timescale.v"
63
// synopsys translate_on
64
`include "defines.v"
65
 
66
module tt(
67
        // RISC Internal Interface
68
        clk, rst, spr_cs, spr_write, spr_addr, spr_dat_i, spr_dat_o,
69
        int
70
);
71
 
72
//
73
// RISC Internal Interface
74
//
75
input           clk;            // Clock
76
input           rst;            // Reset
77
input           spr_cs;         // SPR CS
78
input           spr_write;      // SPR Write
79
input   [31:0]   spr_addr;       // SPR Address
80
input   [31:0]   spr_dat_i;      // SPR Write Data
81
output  [31:0]   spr_dat_o;      // SPR Read Data
82
output          int;            // Interrupt output
83
 
84
`ifdef TT_IMPLEMENTED
85
 
86
//
87
// TT Mode Register bits (or no register)
88
//
89
`ifdef TT_TTMR
90
reg     [31:0]   ttmr;   // TTMR bits
91
`else
92
wire    [31:0]   ttmr;   // No TTMR register
93
`endif
94
 
95
//
96
// TT Count Register bits (or no register)
97
//
98
`ifdef TT_TTCR
99
reg     [31:0]   ttcr;   // TTCR bits
100
`else
101
wire    [31:0]   ttcr;   // No TTCR register
102
`endif
103
 
104
//
105
// Internal wires & regs
106
//
107
wire            ttmr_sel;       // TTMR select
108
wire            ttcr_sel;       // TTCR select
109
wire            match;          // Asserted when TTMR[TP]
110
                                // is equal to TTCR[27:0]
111
wire            restart;        // Restart counter when asserted
112
wire            stop;           // Stop counter when asserted
113
reg     [31:0]   spr_dat_o;      // SPR data out
114
 
115
//
116
// TT registers address decoder
117
//
118
assign ttmr_sel = (spr_cs && (spr_addr[`TTOFS_BITS] == `TT_OFS_TTMR)) ? 1'b1 : 1'b0;
119
assign ttcr_sel = (spr_cs && (spr_addr[`TTOFS_BITS] == `TT_OFS_TTCR)) ? 1'b1 : 1'b0;
120
 
121
//
122
// Write to TTMR or update of TTMR[IP] bit
123
//
124
`ifdef TT_TTMR
125
always @(posedge clk or posedge rst)
126
        if (rst)
127
                ttmr <= 32'b0;
128
        else if (ttmr_sel && spr_write)
129
                ttmr <= #1 spr_dat_i;
130
        else if (ttmr[`TT_TTMR_IE])
131
                ttmr[`TT_TTMR_IP] <= #1 ttmr[`TT_TTMR_IP] | int;
132
`else
133
assign ttmr = {2'b11, 30'b0};    // TTMR[M] = 0x3
134
`endif
135
 
136
//
137
// Write to or increment of TTCR
138
//
139
`ifdef TT_TTCR
140
always @(posedge clk or posedge restart)
141
        if (restart)
142
                ttcr <= 32'b0;
143
        else if (ttcr_sel && spr_write)
144
                ttcr <= #1 spr_dat_i;
145
        else if (!stop)
146
                ttcr <= #1 ttcr + 1'd1;
147
`else
148
assign ttcr = 32'b0;
149
`endif
150
 
151
//
152
// Read TT registers
153
//
154
always @(spr_addr or ttmr or ttcr)
155
        case (spr_addr[`TTOFS_BITS])    // synopsys full_case parallel_case
156
`ifdef TT_READREGS
157
                `TT_OFS_TTMR: spr_dat_o = ttmr;
158
`endif
159
                default: spr_dat_o = ttcr;
160
        endcase
161
 
162
//
163
// A match when TTMR[TP] is equal to TTCR[27:0]
164
//
165
assign match = (ttmr[`TT_TTMR_TP] == ttcr[27:0]) ? 1'b1 : 1'b0;
166
 
167
//
168
// Restart when match and TTMR[M]==0x1 or when rst is asserted
169
//
170
assign restart = (match && (ttmr[`TT_TTMR_M] == 2'b01) || rst) ? 1'b1 : 1'b0;
171
 
172
//
173
// Stop when match and TTMR[M]==0x2 or when TTMR[M]==0x0
174
//
175
assign stop = (match && (ttmr[`TT_TTMR_M] == 2'b10) || (ttmr[`TT_TTMR_M] == 2'b00)) ? 1'b1 : 1'b0;
176
 
177
//
178
// Generate an interrupt request
179
//
180
assign int = match & ttmr[`TT_TTMR_IE];
181
 
182
`else
183
 
184
//
185
// When TT is not implemented, drive all outputs as would when TT is disabled
186
//
187
assign int = 1'b0;
188
 
189
//
190
// Read TT registers
191
//
192
`ifdef TT_READREGS
193
assign spr_dat_o = 32'b0;
194
`endif
195
 
196
`endif
197
 
198
endmodule

powered by: WebSVN 2.1.0

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