]> cvs.zerfleddert.de Git - fpga-games/blame - galaxian/src/dac.v
faster clock for roms
[fpga-games] / galaxian / src / dac.v
CommitLineData
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
18module dac(DACout, DACin, Clk, Reset);\r
19output DACout; // This is the average output that feeds low pass filter\r
20reg DACout; // for optimum performance, ensure that this ff is in IOB\r
21input [`MSBI:0] DACin; // DAC input (excess 2**MSBI)\r
22input Clk;\r
23input Reset;\r
24reg [`MSBI+2:0] DeltaAdder; // Output of Delta adder\r
25reg [`MSBI+2:0] SigmaAdder; // Output of Sigma adder\r
26reg [`MSBI+2:0] SigmaLatch; // Latches output of Sigma adder\r
27reg [`MSBI+2:0] DeltaB; // B input of Delta adder\r
28\r
29always @(SigmaLatch) DeltaB = {SigmaLatch[`MSBI+2], SigmaLatch[`MSBI+2]} << (`MSBI+1);\r
30\r
31always @(DACin or DeltaB) DeltaAdder = DACin + DeltaB;\r
32\r
33always @(DeltaAdder or SigmaLatch) SigmaAdder = DeltaAdder + SigmaLatch;\r
34\r
35always @(posedge Clk or posedge Reset)\r
36begin\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
48end\r
49endmodule\r
50\r
Impressum, Datenschutz