summaryrefslogtreecommitdiffstats
path: root/de1/fpga-bbc-pq/master/audio-16bit-48k.patch
blob: 315a9fd0c599e3ed75dd12b8c5e2edbbb0af3726 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
diff --git a/bbc_micro_de1.vhd b/bbc_micro_de1.vhd
index 5cc666c..462e507 100644
--- a/bbc_micro_de1.vhd
+++ b/bbc_micro_de1.vhd
@@ -437,7 +437,7 @@ component sn76489_top is
     we_n_i     : in  std_logic;
     ready_o    : out std_logic;
     d_i        : in  std_logic_vector(0 to 7);
-    aout_o     : out signed(0 to 7)
+    aout_o     : out signed(0 to 15)
   );
 
 end component;
@@ -445,7 +445,7 @@ end component;
 component i2s_intf is
 generic(
 	mclk_rate : positive := 12000000;
-	sample_rate : positive := 8000;
+	sample_rate : positive := 48000;
 	preamble : positive := 1; -- I2S
 	word_length : positive := 16
 	);
@@ -713,7 +713,7 @@ signal keyb_break		:	std_logic;
 -- Sound generator
 signal sound_ready		:	std_logic;
 signal sound_di			:	std_logic_vector(7 downto 0);
-signal sound_ao			:	signed(7 downto 0);
+signal sound_ao			:	signed(15 downto 0);
 signal pcm_inl			:	std_logic_vector(15 downto 0);
 signal pcm_inr			:	std_logic_vector(15 downto 0);
 
@@ -938,13 +938,13 @@ begin
 		clock, mhz4_clken,
 		reset_n, '0', sound_enable_n,
 		sound_ready, sound_di,
-		sound_ao
+		sound_ao 
 		);
 	i2s : i2s_intf port map (
 		CLOCK_24(0), reset_n,
 		pcm_inl, pcm_inr,
-		std_logic_vector(sound_ao) & "00000000",
-		std_logic_vector(sound_ao) & "00000000",
+		std_logic_vector(sound_ao),
+		std_logic_vector(sound_ao),
 		AUD_XCK, AUD_DACLRCK,
 		AUD_BCLK, AUD_DACDAT, AUD_ADCDAT
 		);
diff --git a/i2c_loader.vhd b/i2c_loader.vhd
index 61bdd22..e0a7115 100644
--- a/i2c_loader.vhd
+++ b/i2c_loader.vhd
@@ -84,8 +84,8 @@ constant init_regs : regs := (
 	X"0C", X"62",
 	-- Format 16-bit I2S, no bit inversion or phase changes
 	X"0E", X"02",
-	-- Sampling control, 8 kHz USB mode (MCLK = 250fs * 6)
-	X"10", X"0D",
+	-- Sampling control, 48 kHz USB mode (MCLK = 250fs)
+	X"10", X"01", 
 	-- Activate
 	X"12", X"01"
 	);
diff --git a/i2s_intf.vhd b/i2s_intf.vhd
index 49b6efb..dc00622 100644
--- a/i2s_intf.vhd
+++ b/i2s_intf.vhd
@@ -43,7 +43,7 @@ use IEEE.STD_LOGIC_UNSIGNED.ALL;
 entity i2s_intf is
 generic(
 	mclk_rate : positive := 12000000;
-	sample_rate : positive := 8000;
+	sample_rate : positive := 48000;
 	preamble : positive := 1; -- I2S
 	word_length : positive := 16
 	);
diff --git a/sn76489-1.0/sn76489_attenuator.vhd b/sn76489-1.0/sn76489_attenuator.vhd
index 444064e..a160a05 100644
--- a/sn76489-1.0/sn76489_attenuator.vhd
+++ b/sn76489-1.0/sn76489_attenuator.vhd
@@ -53,7 +53,7 @@ entity sn76489_attenuator is
   port (
     attenuation_i : in  std_logic_vector(0 to 3);
     factor_i      : in  signed(0 to 1);
-    product_o     : out signed(0 to 7)
+    product_o     : out signed(0 to 15)
   );
 
 end sn76489_attenuator;
@@ -83,7 +83,7 @@ begin
 
     type     volume_t is array (natural range 0 to 15) of natural;
     constant volume_c : volume_t :=
-      (31, 25, 20, 16, 12, 10, 8, 6, 5, 4, 3, 2, 2, 2, 1, 0);
+        ( 1905, 1514, 1202, 955, 758, 602, 479, 380, 302, 240, 191, 151, 120, 95, 76, 0);
 
     variable attenuation_v  : unsigned(attenuation_i'range);
     variable volume_v       : signed(product_o'range);
diff --git a/sn76489-1.0/sn76489_comp_pack-p.vhd b/sn76489-1.0/sn76489_comp_pack-p.vhd
index c5fcc90..88c5c23 100644
--- a/sn76489-1.0/sn76489_comp_pack-p.vhd
+++ b/sn76489-1.0/sn76489_comp_pack-p.vhd
@@ -18,7 +18,7 @@ package sn76489_comp_pack is
     port (
       attenuation_i : in  std_logic_vector(0 to 3);
       factor_i      : in  signed(0 to 1);
-      product_o     : out signed(0 to 7)
+      product_o     : out signed(0 to 15)
     );
   end component;
 
@@ -33,7 +33,7 @@ package sn76489_comp_pack is
       rst_a_i  : in  std_logic_vector(0 to 3);
       rst_cnt_i: in  std_logic_vector(0 to 9);
       ff_o     : out std_logic;
-      tone_o   : out signed(0 to 7)
+      tone_o   : out signed(0 to 15)
     );
   end component;
 
@@ -46,7 +46,7 @@ package sn76489_comp_pack is
       d_i        : in  std_logic_vector(0 to 7);
       addr_i     : in  std_logic_vector(0 to 1);
       tone3_ff_i : in  std_logic;
-      noise_o    : out signed(0 to 7)
+      noise_o    : out signed(0 to 15)
     );
   end component;
 
@@ -74,7 +74,7 @@ package sn76489_comp_pack is
       we_n_i     : in  std_logic;
       ready_o    : out std_logic;
       d_i        : in  std_logic_vector(0 to 7);
-      aout_o     : out signed(0 to 7)
+      aout_o     : out signed(0 to 15)
     );
   end component;
 
diff --git a/sn76489-1.0/sn76489_noise.vhd b/sn76489-1.0/sn76489_noise.vhd
index 035adab..a19df77 100644
--- a/sn76489-1.0/sn76489_noise.vhd
+++ b/sn76489-1.0/sn76489_noise.vhd
@@ -58,7 +58,7 @@ entity sn76489_noise is
     d_i        : in  std_logic_vector(0 to 7);
     addr_i     : in  std_logic_vector(0 to 1);
     tone3_ff_i : in  std_logic;
-    noise_o    : out signed(0 to 7)
+    noise_o    : out signed(0 to 15)
   );
 
 end sn76489_noise;
@@ -81,7 +81,7 @@ architecture rtl of sn76489_noise is
          shift_source_q    : std_logic;
   signal shift_rise_edge_s : boolean;
 
-  signal lfsr_q            : std_logic_vector(0 to 7);
+  signal lfsr_q            : std_logic_vector(0 to 15);
 
   signal freq_s      : signed(0 to 1);
 
diff --git a/sn76489-1.0/sn76489_tone.vhd b/sn76489-1.0/sn76489_tone.vhd
index f1b6885..4421423 100644
--- a/sn76489-1.0/sn76489_tone.vhd
+++ b/sn76489-1.0/sn76489_tone.vhd
@@ -60,7 +60,7 @@ entity sn76489_tone is
     rst_a_i  : in  std_logic_vector(0 to 3);
     rst_cnt_i: in  std_logic_vector(0 to 9);
     ff_o     : out std_logic;
-    tone_o   : out signed(0 to 7)
+    tone_o   : out signed(0 to 15)
   );
 
 end sn76489_tone;
diff --git a/sn76489-1.0/sn76489_top.vhd b/sn76489-1.0/sn76489_top.vhd
index 2f6a01c..512521f 100644
--- a/sn76489-1.0/sn76489_top.vhd
+++ b/sn76489-1.0/sn76489_top.vhd
@@ -72,7 +72,7 @@ entity sn76489_top is
     we_n_i     : in  std_logic;
     ready_o    : out std_logic;
     d_i        : in  std_logic_vector(0 to 7);
-    aout_o     : out signed(0 to 7)
+    aout_o     : out signed(0 to 15)
   );
 
 end sn76489_top;