-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathsid_wave.sv
More file actions
41 lines (31 loc) · 937 Bytes
/
sid_wave.sv
File metadata and controls
41 lines (31 loc) · 937 Bytes
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
module sid_wave(
output[11:0] out,
input[23:0] acc,
input[22:0] lfsr,
input[7:0] vol,
input noise, pulse, saw, triangle,
input[11:0] pw,
input ring, ring_in
);
always_comb
begin
bit [11:0] out_noise, out_pulse, out_saw, out_triangle;
out_noise = {
lfsr[20], lfsr[18], lfsr[14], lfsr[11],
lfsr[ 9], lfsr[ 5], lfsr[ 2], lfsr[ 0], 4'b0
};
out_pulse = acc[23:12] < pw ? '1 : '0;
out_saw = acc[23:12];
out_triangle = acc[22:12] << 1;
if (acc[23])
out_triangle ^= '1;
if (ring && ring_in)
out_triangle ^= '1;
out = '1;
if (noise) out &= out_noise;
if (pulse) out &= out_pulse;
if (saw) out &= out_saw;
if (triangle) out &= out_triangle;
out = 12'( (20'(out) * vol) >> 8 );
end
endmodule