URL
https://opencores.org/ocsvn/sqmusic/sqmusic/trunk
Subversion Repositories sqmusic
Compare Revisions
- This comparison shows the changes necessary to convert path
/sqmusic
- from Rev 4 to Rev 5
- ↔ Reverse comparison
Rev 4 → Rev 5
/trunk/1942/1942.v
21,8 → 21,9
reg reset_n, clk, int_n, sound_clk; |
|
initial begin |
//$dumpfile("dump.lxt"); |
//$dumpvars(1,map.ym2203_0); |
/* $dumpfile("dump.lxt"); |
$dumpvars(1,pwm0); |
$dumpvars(1,pwm1);*/ |
// $dumpvars(); |
// $dumpon; |
// $shm_open("1942.shm"); |
31,7 → 32,7
#1500 reset_n=1; |
// change finish time depending on song |
//#4e6 $finish; |
#5e9 $finish; |
#6e9 $finish; |
end |
|
always begin // main clock |
55,8 → 56,7
end |
end |
|
always #22676 $display("%d", amp0_y+amp1_y ); // 44.1kHz sample |
|
|
wire [3:0] ay0_a, ay0_b, ay0_c, ay1_a, ay1_b, ay1_c; |
computer_1942 #(0) game( .clk(clk), .sound_clk(sound_clk), |
.int_n(int_n), .reset_n(reset_n), |
63,11 → 63,33
.ay0_a(ay0_a), .ay0_b(ay0_b), .ay0_c(ay0_c), |
.ay1_a(ay1_a), .ay1_b(ay1_b), .ay1_c(ay1_c) ); |
// sound amplifier: |
/* |
wire [15:0] amp0_y, amp1_y; |
SQM_AMP amp0( .A(ay0_a), .B(ay0_b), .C(ay0_c), .Y( amp0_y )); |
SQM_AMP amp1( .A(ay1_a), .B(ay1_b), .C(ay1_c), .Y( amp1_y )); |
endmodule |
SQM_AMP amp1( .A(ay1_a), .B(ay1_b), .C(ay1_c), .Y( amp1_y )); |
always #22676 $display("%d", amp0_y+amp1_y ); // 44.1kHz sample |
*/ |
reg vhf_clk; |
always begin |
vhf_clk=0; |
forever begin |
if( vhf_clk ) begin |
$display("%d, %d, %d, %d, %d, %d", |
pwm0_a, pwm0_b, pwm0_c, pwm1_a, pwm1_b, pwm1_c ); |
end |
#10 vhf_clk <= ~vhf_clk; // 50MHz |
end |
end |
|
SQM_PWM_1 a0pwm( .clk(vhf_clk), .reset_n(reset_n), .din(ay0_a), .pwm(pwm0_a) ); |
SQM_PWM_1 b0pwm( .clk(vhf_clk), .reset_n(reset_n), .din(ay0_b), .pwm(pwm0_b) ); |
SQM_PWM_1 c0pwm( .clk(vhf_clk), .reset_n(reset_n), .din(ay0_c), .pwm(pwm0_c) ); |
|
SQM_PWM_1 a1pwm( .clk(vhf_clk), .reset_n(reset_n), .din(ay1_a), .pwm(pwm1_a) ); |
SQM_PWM_1 b1pwm( .clk(vhf_clk), .reset_n(reset_n), .din(ay1_b), .pwm(pwm1_b) ); |
SQM_PWM_1 c1pwm( .clk(vhf_clk), .reset_n(reset_n), .din(ay1_c), .pwm(pwm1_c) ); |
endmodule |
|
///////////////////////////////////////////////////// |
module computer_1942 |
#(parameter dump_regs=0) // set to 1 to dump sqmusic registers |
/trunk/1942/log2wav.cc
28,7 → 28,8
int skip; |
string filename; |
string outputfile; |
Args( int argc, char *argv[]) : skip(0), outputfile("out.wav") { |
bool stereo; |
Args( int argc, char *argv[]) : skip(0), outputfile("out.wav"), stereo(false) { |
int k=1; |
bool filename_known=false; |
while( k < argc ) { |
47,6 → 48,11
k++; |
continue; |
} |
if( strcmp(argv[k],"-s")==0 ) { // stereo |
k++; |
stereo = true; |
continue; |
} |
if( filename_known ) { |
cout << "Unknown parameter " << argv[k] << "\n"; |
throw "Incorrect command line"; |
106,12 → 112,13
fout.write( (char*)&aux, 4 );// suubchunk 1 size |
short int aux_short = 1; |
fout.write( (char*)&aux_short, 2 ); // audio format (1) |
aux_short = ar.stereo ? 2 : 1; |
fout.write( (char*)&aux_short, 2 ); // num channels (1) |
aux=44100; |
fout.write( (char*)&aux, 4 ); |
aux=44100*1*2; |
aux=44100*1*2 * (ar.stereo?2:1); |
fout.write( (char*)&aux, 4 ); // byte rate |
aux_short=2; |
aux_short= ar.stereo ? 4 : 2; |
fout.write( (char*)&aux_short, 2 ); // block align |
aux_short=16; |
fout.write( (char*)&aux_short, 2 ); // bits per sample |
/trunk/1942/gather
6,3 → 6,4
../tv80/rtl/core/tv80_reg.v |
../sqm/sqm_amp.v |
../sqm/sqmusic.v |
../sqm/sqm_pwm.v |
/trunk/1942/pwm2log.cc
0,0 → 1,78
/* |
Converts PWM output from 1942.v to .log file |
the output can be piped into log2wav in order to get the wav file |
|
(c) Jose Tejada Gomez, 9th May 2013 |
You can use this file following the GNU GENERAL PUBLIC LICENSE version 3 |
Read the details of the license in: |
http://www.gnu.org/licenses/gpl.txt |
|
Send comments to: jose.tejada@ieee.org |
|
*/ |
|
// Compile with g++ pwm2wav.cc -o pwm2wav |
|
#include <iostream> |
#include <string.h> |
#include <stdlib.h> |
|
using namespace std; |
|
struct ym_output { |
double a,b,c; |
}; |
|
void parse( char *buf, int len, double pwm[6] ) { |
int k=0; |
buf=strtok( buf, ","); |
for( k=0; k<6; k++ ) { |
if( buf==NULL ) throw "incomplete line (1)"; |
pwm[k] = (double)atoi( buf ); |
if( pwm[k]!=0 && pwm[k]!=1 ) pwm[k]=0; |
buf=strtok( NULL, " "); |
} |
} |
|
void calc_voltage( double& vcap, double pwm[3] ) { |
const double res = 7.23; |
const double cap = 4e-6; // if RC=7.23 us => f0=22kHz |
double dv=0; |
const double dt = 20e-9; |
for(int k=0; k<3; k++ ) |
dv += pwm[k] - vcap; |
vcap += dv*dt/res/cap; |
} |
|
int main( int argc, char *argv[] ) { |
double vcap_left=0, vcap_right=0; |
char buf[1024]; |
int skip = 1; // lines to skip |
for(int k=0; k<skip; k++ ) |
cin.getline( buf, sizeof(buf) ); |
// conversion |
try { |
long int sample=0; |
// skip first line |
cin.getline( buf, sizeof(buf) ); |
|
cin.getline( buf, sizeof(buf) ); |
while( buf[0] && !cin.eof() ) { |
double pwm[6]; |
parse( buf, sizeof(buf), pwm ); |
calc_voltage( vcap_left, pwm ); |
calc_voltage( vcap_right, &pwm[3] ); |
if( sample == 1134 ) { |
cout << (int)(vcap_left*65535) << "\n"; |
cout << (int)(vcap_right*65535) << "\n"; |
sample = 0; |
} else sample++; |
cin.getline( buf, sizeof(buf) ); |
} |
return 0; |
} |
catch( const char *x ) { |
cout << "ERROR: " << x << "\n"; |
return -1; |
} |
} |
trunk/1942/pwm2log.cc
Property changes :
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property