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

Subversion Repositories jt51

[/] [jt51/] [trunk/] [contra/] [ymplayer.v] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 gryzor
`timescale 1ns / 1ps
2
`timescale 1ns / 1ps
3
 
4
module ymplayer(
5
        input   clk50,
6
        input   rst,
7
        // sound
8
        output  speaker_left,
9
        output  speaker_right,
10
        // switches
11
        input [1:0]      sw_sel, // 
12
        input           send_data, // 1=Send music over UART, 0=stop
13
        // UART wires
14
        input           uart_rx,
15
        output          uart_tx,
16
        output [7:0] led
17
);
18
 
19
wire clk_dac, clk, locked, rst_clk, rst_clk50;
20
 
21
// Send data
22
reg     [9:0] send_data_shr;
23
wire send_data_s = &send_data_shr;
24
 
25
always @(posedge clk50)
26
        send_data_shr <= { send_data_shr[8:0], send_data };
27
 
28
clocks u_clocks(
29
    .rst        ( rst           ),
30
    .clk50      ( clk50         ),
31
        .locked ( locked        ),
32
        .divide_more( send_data_s ),
33
    .clk_cpu( clk               ),
34
        .clk_dac( clk_dac       )
35
);
36
 
37
// wire clk_per = clk; // cpu09l.vhd
38
wire clk_per = ~clk; // cpu09new.vhd
39
wire cpu_rst_req;
40
 
41
rst_sync u_rst1(
42
        .rst_in ( rst|(~locked)|cpu_rst_req     ),
43
        .clk    ( clk                   ),
44
        .rst_out( rst_clk               )
45
);
46
/*
47
rst_sync u_rst2(
48
        .rst_in ( rst_clk       ),
49
        .clk    ( clk_dac       ),
50
        .rst_out( rst_fast      )
51
);
52
*/
53
rst_sync u_rst50(
54
        .rst_in ( rst|(~locked) ),
55
        .clk    ( clk50                 ),
56
        .rst_out( rst_clk50             )
57
);
58
 
59
wire [7:0] cpu_data_in, cpu_data_out;
60
wire [15:0] cpu_addr;
61
wire [7:0]jt_data_out;
62
 
63
wire cpu_rw;
64
 
65
wire signed     [15:0] jt_left, jt_right;
66
 
67
wire jt_sample;
68
 
69
// JT51
70
`ifndef NOJT
71
jt51 u_jt51(
72
        .clk    ( clk_per               ),
73
        .rst    ( rst_clk               ),
74
        .cs_n   ( jt_cs_n               ),      // chip select
75
        .wr_n   ( cpu_rw                ),      // write
76
        .a0             ( cpu_addr[0]    ),
77
        .d_in   ( cpu_data_out  ), // data in
78
        .d_out  ( jt_data_out   ), // data out
79
        .irq_n  ( jt_irq_n              ),
80
        // uso salidas exactas para el DAC
81
        .sample ( jt_sample             ),
82
        .xleft  ( jt_left               ),
83
        .xright ( jt_right              )
84
);
85
`endif
86
 
87
speaker u_speaker(
88
        .clk100         ( clk50         ), // the faster the clock the better !
89
        .left_in        ( jt_left       ),
90
        .right_in       ( jt_right      ),
91
        .left_out       ( speaker_left  ),
92
        .right_out      ( speaker_right )
93
);
94
 
95
parameter RAM_MSB = 10; // 10 for Contra;
96
 
97
wire [7:0] ROM_data_out, RAM_data;
98
 
99
wire            fsm_wr;
100
wire [ 7:0]      fsm_data;
101
wire [14:0]      fsm_addr;
102
wire            rom_prog;
103
 
104
//synthesis attribute box_type ram32 "black_box"
105
ram32 ROM( // 32kb
106
        .clka   ( clk_per               ),
107
        .dina   ( fsm_data              ),
108
        .ena    ( 1'b1                  ),
109
        .wea    ( fsm_wr                ),
110
        .douta  ( ROM_data_out  ),
111
        .addra  ( rom_prog ? fsm_addr : cpu_addr[14:0])
112
);
113
 
114
//synthesis attribute box_type ram2 "black_box"
115
ram2 RAM( // 2kb
116
        .clka   ( clk_per               ),
117
        .dina   ( cpu_data_out  ),
118
        .douta  ( RAM_data              ),
119
        .addra  ( cpu_addr[RAM_MSB:0] ),
120
        .ena    ( RAM_cs                ),
121
        .wea    ( ~cpu_rw               )
122
);
123
 
124
wire [7:0] sound_latch;
125
wire clear_irq;
126
 
127
assign led = rom_prog ? fsm_addr[14:7] : sound_latch;
128
 
129
 
130
fsm_control fsm_ctrl(
131
        .clk            ( clk50         ),
132
        .clk_cpu        ( clk           ),
133
        .rst            ( rst_clk50     ),
134
        // Sound
135
        .sound_latch(sound_latch),
136
        .jt_left        ( jt_left       ),
137
        .jt_right       ( jt_right      ),
138
        .jt_sample      ( jt_sample     ),
139
        .irq            ( irq           ),
140
        .clear_irq      ( clear_irq     ),
141
        // Programming
142
        .cpu_rst        ( cpu_rst_req),
143
        .rom_prog       ( rom_prog      ),
144
    .rom_wr             ( fsm_wr        ),
145
    .rom_addr   ( fsm_addr      ),
146
    .rom_data   ( fsm_data      ),
147
        // UART wires
148
        .uart_rx        ( uart_rx       ),
149
        .uart_tx        ( uart_tx       )
150
);
151
 
152
 
153
bus_manager #(RAM_MSB) bus_mng(
154
        .rst50                  ( rst_clk50             ),
155
        .clk50                  ( clk50                 ),
156
        .clk_per                ( clk_per               ),
157
        .sw_sel                 ( sw_sel                ),
158
        .ROM_data_out   ( ROM_data_out  ),
159
        .RAM_data               ( RAM_data              ),
160
        .sound_latch    ( sound_latch   ),
161
        .clear_irq              ( clear_irq             ),
162
        .cpu_data_out   ( cpu_data_out  ),
163
        .jt_data_out    ( jt_data_out   ),
164
        //
165
        .cpu_data_in    ( cpu_data_in   ),
166
        .cpu_rw                 ( cpu_rw                ),
167
        .addr                   ( cpu_addr              ),
168
        .cpu_vma                ( cpu_vma               ),
169
        .RAM_cs                 ( RAM_cs                ),
170
        .opm_cs_n               ( jt_cs_n               )
171
        );
172
 
173
wire [15:0] dummy_pcout; // cpu09 debug
174
 
175
wire    cpu_firq = sw_sel[0] ? ~jt_irq_n : 1'b0;
176
 
177
cpu09 cpu(
178
        .clk            ( clk                   ),
179
        .rst            ( rst_clk               ),
180
        .rw                     ( cpu_rw                ),
181
        .vma            ( cpu_vma               ),
182
        .address        ( cpu_addr              ),
183
        .data_in        ( cpu_data_in   ),
184
        .data_out       ( cpu_data_out  ),
185
        .halt           ( 1'b0                  ),
186
        .hold           ( 1'b0                  ),
187
        .irq            ( irq                   ),
188
        .firq           ( cpu_firq              ), // for Contra        
189
        .nmi            ( 1'b0                  ),
190
        .pc_out         ( dummy_pcout   )
191
        );
192
 
193
/*
194
// cpu09l.vhd
195
cpu09 cpu(
196
        .clk            ( clk                   ),
197
        .rst            ( rst_clk               ),
198
        .rw                     ( cpu_rw                ),
199
        .vma            ( cpu_vma               ),
200
        .addr           ( cpu_addr              ),
201
        .data_in        ( cpu_data_in   ),
202
        .data_out       ( cpu_data_out  ),
203
        .halt           ( 1'b0                  ),
204
        .hold           ( 1'b0                  ),
205
        .irq            ( irq                   ),
206
        .firq           ( 1'b0                  ), // for Contra
207
        .nmi            ( 1'b0                  ),
208
        .lic            (),
209
        .ifetch         (),
210
        .ba                     (),
211
        .bs                     ()
212
        //.pc_out               ( pc_out                )
213
        );
214
*/
215
endmodule
216
 

powered by: WebSVN 2.1.0

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