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

Subversion Repositories ps2

[/] [ps2/] [tags/] [rel_2/] [rtl/] [verilog/] [ps2_translation_table.v] - Blame information for rev 51

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 mihad
//////////////////////////////////////////////////////////////////////
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 13 mihad
// Revision 1.1.1.1  2002/02/18 16:16:56  mihad
47
// Initial project import - working
48 2 mihad
//
49 13 mihad
//
50 2 mihad
 
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_released_i
74
) ;
75
 
76
input reset_i,
77
      clock_i,
78
      translate_i ;
79
 
80
input  [7:0] code_i ;
81
output [7:0] code_o ;
82
input  [7:0] address_i ;
83
input  [7:0] data_i ;
84
input        we_i,
85
             re_i ;
86
 
87
output [7:0] data_o ;
88
 
89
input rx_data_ready_i,
90
      rx_read_i ;
91
 
92
output rx_translated_data_ready_o ;
93
output rx_read_o ;
94
 
95 13 mihad
input  rx_released_i ;
96 2 mihad
 
97
wire translation_table_write_enable  = we_i && (!translate_i || !rx_data_ready_i) ;
98
wire [7:0] translation_table_address = ((we_i || re_i) && (!rx_data_ready_i || !translate_i)) ? address_i : code_i ;
99
wire translation_table_enable        = we_i || re_i || (translate_i && rx_data_ready_i) ;
100
 
101
reg rx_translated_data_ready ;
102
always@(posedge clock_i or posedge reset_i)
103
begin
104
    if ( reset_i )
105
        rx_translated_data_ready <= #1 1'b0 ;
106
    else if ( rx_read_i || !translate_i )
107
        rx_translated_data_ready <= #1 1'b0 ;
108
    else
109
        rx_translated_data_ready <= #1 rx_data_ready_i ;
110
end
111
 
112
`ifdef PS2_RAMB4
113
    `define PS2_RAM_SELECTED
114 13 mihad
 
115 2 mihad
    wire [7:0] ram_out ;
116
    RAMB4_S8 `ifdef SIM
117
             #("ignore",
118 13 mihad
               `PS2_TRANSLATION_TABLE_31_0,
119
               `PS2_TRANSLATION_TABLE_63_32,
120
               `PS2_TRANSLATION_TABLE_95_64,
121
               `PS2_TRANSLATION_TABLE_127_96,
122
               `PS2_TRANSLATION_TABLE_159_128,
123
               `PS2_TRANSLATION_TABLE_191_160,
124
               `PS2_TRANSLATION_TABLE_223_192,
125 2 mihad
               `PS2_TRANSLATION_TABLE_255_224)
126
              `endif
127
    ps2_ram
128
    (
129
        .DO   (ram_out),
130
        .ADDR ({1'b0, translation_table_address}),
131
        .DI   (data_i),
132
        .EN   (translation_table_enable),
133
        .CLK  (clock_i),
134
        .WE   (translation_table_write_enable),
135
        .RST  (reset_i)
136
    ) ;
137 13 mihad
 
138 2 mihad
`endif
139
 
140
`ifdef PS2_RAM_SELECTED
141
`else
142
    `define PS2_RAM_SELECTED
143 13 mihad
 
144 2 mihad
    reg [7:0] ps2_ram [0:255] ;
145
    reg [7:0] ram_out ;
146 13 mihad
 
147 2 mihad
    always@(posedge clock_i or posedge reset_i)
148
    begin
149
        if ( reset_i )
150
            ram_out <= #1 8'h0 ;
151
        else if ( translation_table_enable )
152
            ram_out <= #1 ps2_ram[translation_table_address] ;
153
    end
154
 
155
    always@(posedge clock_i)
156
    begin
157
        if ( translation_table_write_enable )
158
            ps2_ram[translation_table_address] <= #1 data_i ;
159
    end
160
 
161
    // synopsys translate_off
162
    integer i ;
163
    reg [255:0] temp_init_val ;
164
    initial
165
    begin
166
        temp_init_val = `PS2_TRANSLATION_TABLE_31_0 ;
167
 
168
        for ( i = 0 ; i <= 31 ; i = i + 1 )
169
        begin
170
            ps2_ram[i] = temp_init_val[7:0] ;
171
            temp_init_val = temp_init_val >> 8 ;
172
        end
173
 
174
        temp_init_val = `PS2_TRANSLATION_TABLE_63_32 ;
175 13 mihad
 
176 2 mihad
        for ( i = 32 ; i <= 63 ; i = i + 1 )
177
        begin
178
            ps2_ram[i] = temp_init_val[7:0] ;
179
            temp_init_val = temp_init_val >> 8 ;
180
        end
181
 
182
        temp_init_val = `PS2_TRANSLATION_TABLE_95_64 ;
183 13 mihad
 
184 2 mihad
        for ( i = 64 ; i <= 95 ; i = i + 1 )
185
        begin
186
            ps2_ram[i] = temp_init_val[7:0] ;
187
            temp_init_val = temp_init_val >> 8 ;
188
        end
189 13 mihad
 
190 2 mihad
        temp_init_val = `PS2_TRANSLATION_TABLE_127_96 ;
191 13 mihad
 
192 2 mihad
        for ( i = 96 ; i <= 127 ; i = i + 1 )
193
        begin
194
            ps2_ram[i] = temp_init_val[7:0] ;
195
            temp_init_val = temp_init_val >> 8 ;
196
        end
197
 
198
        temp_init_val = `PS2_TRANSLATION_TABLE_159_128 ;
199 13 mihad
 
200 2 mihad
        for ( i = 128 ; i <= 159 ; i = i + 1 )
201
        begin
202
            ps2_ram[i] = temp_init_val[7:0] ;
203
            temp_init_val = temp_init_val >> 8 ;
204
        end
205 13 mihad
 
206 2 mihad
        temp_init_val = `PS2_TRANSLATION_TABLE_191_160 ;
207 13 mihad
 
208 2 mihad
        for ( i = 160 ; i <= 191 ; i = i + 1 )
209
        begin
210
            ps2_ram[i] = temp_init_val[7:0] ;
211
            temp_init_val = temp_init_val >> 8 ;
212
        end
213 13 mihad
 
214 2 mihad
        temp_init_val = `PS2_TRANSLATION_TABLE_223_192 ;
215 13 mihad
 
216 2 mihad
        for ( i = 192 ; i <= 223 ; i = i + 1 )
217
        begin
218
            ps2_ram[i] = temp_init_val[7:0] ;
219
            temp_init_val = temp_init_val >> 8 ;
220
        end
221 13 mihad
 
222 2 mihad
        temp_init_val = `PS2_TRANSLATION_TABLE_255_224 ;
223 13 mihad
 
224 2 mihad
        for ( i = 224 ; i <= 255 ; i = i + 1 )
225
        begin
226
            ps2_ram[i] = temp_init_val[7:0] ;
227
            temp_init_val = temp_init_val >> 8 ;
228
        end
229
    end
230
 
231
    // synopsys translate_on
232
 
233
`endif
234
 
235
assign data_o = ram_out ;
236
assign code_o = translate_i ? {(rx_released_i | ram_out[7]), ram_out[6:0]} : code_i ;
237
assign rx_translated_data_ready_o = translate_i ? rx_translated_data_ready : rx_data_ready_i ;
238
assign rx_read_o = rx_read_i ;
239
 
240 13 mihad
`undef PS2_RAM_SELECTED
241 2 mihad
 
242
endmodule //ps2_translation_table

powered by: WebSVN 2.1.0

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