]>
Commit | Line | Data |
---|---|---|
782690d0 MG |
1 | //\r |
2 | // XAPP154 based SigmaDeltaPCM Module\r | |
3 | //\r | |
4 | // Important !\r | |
5 | //\r | |
6 | // This program is freeware for non-commercial use. \r | |
7 | // An author does no guarantee about this program.\r | |
8 | // You can use this under your own risk. \r | |
9 | //\r | |
10 | // See the xapp154.pdf on Xilinx application note.\r | |
11 | //\r | |
12 | //\r | |
13 | \r | |
14 | `timescale 100 ps / 10 ps\r | |
15 | `define MSBI 7 // Most significant Bit of DAC input\r | |
16 | //This is a Delta-Sigma Digital to Analog Converter\r | |
17 | \r | |
18 | module dac(DACout, DACin, Clk, Reset);\r | |
19 | output DACout; // This is the average output that feeds low pass filter\r | |
20 | reg DACout; // for optimum performance, ensure that this ff is in IOB\r | |
21 | input [`MSBI:0] DACin; // DAC input (excess 2**MSBI)\r | |
22 | input Clk;\r | |
23 | input Reset;\r | |
24 | reg [`MSBI+2:0] DeltaAdder; // Output of Delta adder\r | |
25 | reg [`MSBI+2:0] SigmaAdder; // Output of Sigma adder\r | |
26 | reg [`MSBI+2:0] SigmaLatch; // Latches output of Sigma adder\r | |
27 | reg [`MSBI+2:0] DeltaB; // B input of Delta adder\r | |
28 | \r | |
29 | always @(SigmaLatch) DeltaB = {SigmaLatch[`MSBI+2], SigmaLatch[`MSBI+2]} << (`MSBI+1);\r | |
30 | \r | |
31 | always @(DACin or DeltaB) DeltaAdder = DACin + DeltaB;\r | |
32 | \r | |
33 | always @(DeltaAdder or SigmaLatch) SigmaAdder = DeltaAdder + SigmaLatch;\r | |
34 | \r | |
35 | always @(posedge Clk or posedge Reset)\r | |
36 | begin\r | |
37 | if(Reset)\r | |
38 | begin\r | |
39 | SigmaLatch <= #1 1'b1 << (`MSBI+1);\r | |
40 | DACout <= #1 1'b0;\r | |
41 | end\r | |
42 | else\r | |
43 | begin\r | |
44 | // SigmaLatch <== #1 SigmaAdder;\r | |
45 | SigmaLatch <= #1 SigmaAdder;\r | |
46 | DACout <= #1 SigmaLatch[`MSBI+2];\r | |
47 | end\r | |
48 | end\r | |
49 | endmodule\r | |
50 | \r |