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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [orp/] [orp_soc/] [rtl/] [verilog/] [ps2.old/] [ps2_translation_table.v] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 746 lampret
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  ps2_translation_table.v                                     ////
4
////                                                              ////
5
////  This file is part of the "ps2" project                      ////
6
////  http://www.opencores.org/cores/ps2/                         ////
7
////                                                              ////
8
////  Author(s):                                                  ////
9
////      - mihad@opencores.org                                   ////
10
////      - Miha Dolenc                                           ////
11
////                                                              ////
12
////  All additional information is avaliable in the README.txt   ////
13
////  file.                                                       ////
14
////                                                              ////
15
////                                                              ////
16
//////////////////////////////////////////////////////////////////////
17
////                                                              ////
18
//// Copyright (C) 2000 Miha Dolenc, mihad@opencores.org          ////
19
////                                                              ////
20
//// This source file may be used and distributed without         ////
21
//// restriction provided that this copyright statement is not    ////
22
//// removed from the file and that any derivative work contains  ////
23
//// the original copyright notice and the associated disclaimer. ////
24
////                                                              ////
25
//// This source file is free software; you can redistribute it   ////
26
//// and/or modify it under the terms of the GNU Lesser General   ////
27
//// Public License as published by the Free Software Foundation; ////
28
//// either version 2.1 of the License, or (at your option) any   ////
29
//// later version.                                               ////
30
////                                                              ////
31
//// This source is distributed in the hope that it will be       ////
32
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
33
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
34
//// PURPOSE.  See the GNU Lesser General Public License for more ////
35
//// details.                                                     ////
36
////                                                              ////
37
//// You should have received a copy of the GNU Lesser General    ////
38
//// Public License along with this source; if not, download it   ////
39
//// from http://www.opencores.org/lgpl.shtml                     ////
40
////                                                              ////
41
//////////////////////////////////////////////////////////////////////
42
//
43
// CVS Revision History
44
//
45
// $Log: not supported by cvs2svn $
46
// Revision 1.1.1.1  2002/02/18 16:16:56  mihad
47
// Initial project import - working
48
//
49
//
50
 
51
`include "ps2_defines.v"
52
 
53
// synopsys translate_off
54
`include "timescale.v"
55
// synopsys translate_on
56
 
57
module ps2_translation_table
58
(
59
    reset_i,
60
    clock_i,
61
    translate_i,
62
    code_i,
63
    code_o,
64
    address_i,
65
    data_i,
66
    we_i,
67
    re_i,
68
    data_o,
69
    rx_data_ready_i,
70
    rx_translated_data_ready_o,
71
    rx_read_i,
72
    rx_read_o,
73
    rx_extended_i,
74
    rx_released_i
75
) ;
76
 
77
input reset_i,
78
      clock_i,
79
      translate_i ;
80
 
81
input  [7:0] code_i ;
82
output [7:0] code_o ;
83
input  [7:0] address_i ;
84
input  [7:0] data_i ;
85
input        we_i,
86
             re_i ;
87
 
88
output [7:0] data_o ;
89
 
90
input rx_data_ready_i,
91
      rx_read_i ;
92
 
93
output rx_translated_data_ready_o ;
94
output rx_read_o ;
95
 
96
input  rx_extended_i,
97
       rx_released_i ;
98
 
99
wire translation_table_write_enable  = we_i && (!translate_i || !rx_data_ready_i) ;
100
wire [7:0] translation_table_address = ((we_i || re_i) && (!rx_data_ready_i || !translate_i)) ? address_i : code_i ;
101
wire translation_table_enable        = we_i || re_i || (translate_i && rx_data_ready_i) ;
102
 
103
reg rx_translated_data_ready ;
104
always@(posedge clock_i or posedge reset_i)
105
begin
106
    if ( reset_i )
107
        rx_translated_data_ready <= #1 1'b0 ;
108
    else if ( rx_read_i || !translate_i )
109
        rx_translated_data_ready <= #1 1'b0 ;
110
    else
111
        rx_translated_data_ready <= #1 rx_data_ready_i ;
112
end
113
 
114
`ifdef PS2_RAMB4
115
    `define PS2_RAM_SELECTED
116
 
117
    wire [7:0] ram_out ;
118
    RAMB4_S8 `ifdef SIM
119
             #("ignore",
120
               `PS2_TRANSLATION_TABLE_31_0,
121
               `PS2_TRANSLATION_TABLE_63_32,
122
               `PS2_TRANSLATION_TABLE_95_64,
123
               `PS2_TRANSLATION_TABLE_127_96,
124
               `PS2_TRANSLATION_TABLE_159_128,
125
               `PS2_TRANSLATION_TABLE_191_160,
126
               `PS2_TRANSLATION_TABLE_223_192,
127
               `PS2_TRANSLATION_TABLE_255_224)
128
              `endif
129
    ps2_ram
130
    (
131
        .DO   (ram_out),
132
        .ADDR ({1'b0, translation_table_address}),
133
        .DI   (data_i),
134
        .EN   (translation_table_enable),
135
        .CLK  (clock_i),
136
        .WE   (translation_table_write_enable),
137
        .RST  (reset_i)
138
    ) ;
139
 
140
`endif
141
 
142
`ifdef PS2_RAM_SELECTED
143
`else
144
    `define PS2_RAM_SELECTED
145
 
146
    reg [7:0] ps2_ram [0:255] ;
147
    reg [7:0] ram_out ;
148
 
149
    always@(posedge clock_i or posedge reset_i)
150
    begin
151
        if ( reset_i )
152
            ram_out <= #1 8'h0 ;
153
        else if ( translation_table_enable )
154
            ram_out <= #1 ps2_ram[translation_table_address] ;
155
    end
156
 
157
    always@(posedge clock_i)
158
    begin
159
        if ( translation_table_write_enable )
160
            ps2_ram[translation_table_address] <= #1 data_i ;
161
    end
162
 
163
    // synopsys translate_off
164
    integer i ;
165
    reg [255:0] temp_init_val ;
166
    initial
167
    begin
168
        temp_init_val = `PS2_TRANSLATION_TABLE_31_0 ;
169
 
170
        for ( i = 0 ; i <= 31 ; i = i + 1 )
171
        begin
172
            ps2_ram[i] = temp_init_val[7:0] ;
173
            temp_init_val = temp_init_val >> 8 ;
174
        end
175
 
176
        temp_init_val = `PS2_TRANSLATION_TABLE_63_32 ;
177
 
178
        for ( i = 32 ; i <= 63 ; i = i + 1 )
179
        begin
180
            ps2_ram[i] = temp_init_val[7:0] ;
181
            temp_init_val = temp_init_val >> 8 ;
182
        end
183
 
184
        temp_init_val = `PS2_TRANSLATION_TABLE_95_64 ;
185
 
186
        for ( i = 64 ; i <= 95 ; i = i + 1 )
187
        begin
188
            ps2_ram[i] = temp_init_val[7:0] ;
189
            temp_init_val = temp_init_val >> 8 ;
190
        end
191
 
192
        temp_init_val = `PS2_TRANSLATION_TABLE_127_96 ;
193
 
194
        for ( i = 96 ; i <= 127 ; i = i + 1 )
195
        begin
196
            ps2_ram[i] = temp_init_val[7:0] ;
197
            temp_init_val = temp_init_val >> 8 ;
198
        end
199
 
200
        temp_init_val = `PS2_TRANSLATION_TABLE_159_128 ;
201
 
202
        for ( i = 128 ; i <= 159 ; i = i + 1 )
203
        begin
204
            ps2_ram[i] = temp_init_val[7:0] ;
205
            temp_init_val = temp_init_val >> 8 ;
206
        end
207
 
208
        temp_init_val = `PS2_TRANSLATION_TABLE_191_160 ;
209
 
210
        for ( i = 160 ; i <= 191 ; i = i + 1 )
211
        begin
212
            ps2_ram[i] = temp_init_val[7:0] ;
213
            temp_init_val = temp_init_val >> 8 ;
214
        end
215
 
216
        temp_init_val = `PS2_TRANSLATION_TABLE_223_192 ;
217
 
218
        for ( i = 192 ; i <= 223 ; i = i + 1 )
219
        begin
220
            ps2_ram[i] = temp_init_val[7:0] ;
221
            temp_init_val = temp_init_val >> 8 ;
222
        end
223
 
224
        temp_init_val = `PS2_TRANSLATION_TABLE_255_224 ;
225
 
226
        for ( i = 224 ; i <= 255 ; i = i + 1 )
227
        begin
228
            ps2_ram[i] = temp_init_val[7:0] ;
229
            temp_init_val = temp_init_val >> 8 ;
230
        end
231
    end
232
 
233
    // synopsys translate_on
234
 
235
`endif
236
 
237
assign data_o = ram_out ;
238
assign code_o = translate_i ? {(rx_released_i | ram_out[7]), ram_out[6:0]} : code_i ;
239
assign rx_translated_data_ready_o = translate_i ? rx_translated_data_ready : rx_data_ready_i ;
240
assign rx_read_o = rx_read_i ;
241
 
242
`undef PS2_RAM_SELECTED
243
 
244
endmodule //ps2_translation_table

powered by: WebSVN 2.1.0

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