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

Subversion Repositories zx_ula

[/] [zx_ula/] [branches/] [xilinx/] [spectrum_48k_spartan3a_for_gameduino_mod_vga_timex_hicolor_ulaplus/] [audio_management.v] - Blame information for rev 29

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 29 mcleod_ide
`timescale 1ns / 1ps
2
//////////////////////////////////////////////////////////////////////////////////
3
// Company: 
4
// Engineer: 
5
// 
6
// Create Date:    04:04:00 04/01/2012 
7
// Design Name: 
8
// Module Name:    sigma_delta_dac 
9
// Project Name: 
10
// Target Devices: 
11
// Tool versions: 
12
// Description: 
13
//
14
// Dependencies: 
15
//
16
// Revision: 
17
// Revision 0.01 - File Created
18
// Additional Comments: 
19
//
20
//////////////////////////////////////////////////////////////////////////////////
21
 
22
`define MSBI 7 // Most significant Bit of DAC input
23
 
24
//This is a Delta-Sigma Digital to Analog Converter
25
module dac (DACout, DACin, Clk, Reset);
26
        output DACout; // This is the average output that feeds low pass filter
27
        input [`MSBI:0] DACin; // DAC input (excess 2**MSBI)
28
        input Clk;
29
        input Reset;
30
 
31
        reg DACout; // for optimum performance, ensure that this ff is in IOB
32
        reg [`MSBI+2:0] DeltaAdder; // Output of Delta adder
33
        reg [`MSBI+2:0] SigmaAdder; // Output of Sigma adder
34
        reg [`MSBI+2:0] SigmaLatch; // Latches output of Sigma adder
35
        reg [`MSBI+2:0] DeltaB; // B input of Delta adder
36
 
37
        always @(SigmaLatch) DeltaB = {SigmaLatch[`MSBI+2], SigmaLatch[`MSBI+2]} << (`MSBI+1);
38
        always @(DACin or DeltaB) DeltaAdder = DACin + DeltaB;
39
        always @(DeltaAdder or SigmaLatch) SigmaAdder = DeltaAdder + SigmaLatch;
40
        always @(posedge Clk or posedge Reset)
41
        begin
42
                if(Reset)
43
                begin
44
                        SigmaLatch <= #1 1'b1 << (`MSBI+1);
45
                        DACout <= #1 1'b0;
46
                end
47
                else
48
                begin
49
                        SigmaLatch <= #1 SigmaAdder;
50
                        DACout <= #1 SigmaLatch[`MSBI+2];
51
                end
52
        end
53
endmodule
54
 
55
module mixer (
56
        input clkdac,
57
        input reset,
58
        input ear,
59
        input mic,
60
        input spk,
61
        output audio
62
        );
63
 
64
        reg [7:0] mix = 0;
65
 
66
        always @(posedge clkdac)
67
                mix <= ({ear,spk,mic}==3'b000)? 17 :
68
                       ({ear,spk,mic}==3'b001)? 36 :
69
                                 ({ear,spk,mic}==3'b010)? 184 :
70
                                 ({ear,spk,mic}==3'b011)? 192 :
71
                                 ({ear,spk,mic}==3'b100)? 22 :
72
                       ({ear,spk,mic}==3'b101)? 48 :
73
                                 ({ear,spk,mic}==3'b110)? 244 : 255;
74
 
75
        dac audio_dac (
76
                .DACout(audio),
77
                .DACin(mix),
78
                .Clk(clkdac),
79
                .Reset(reset)
80
                );
81
endmodule

powered by: WebSVN 2.1.0

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