-
Notifications
You must be signed in to change notification settings - Fork 0
/
Triangle Dac.txt
51 lines (45 loc) · 688 Bytes
/
Triangle Dac.txt
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
module triangle(input clk,rst,output reg [0:7] dac
);
reg [15:0]clkdiv;
wire intclk;
reg [0:7]count;
reg en=1'b0;
always@(posedge clk)
begin
clkdiv=clkdiv+1;
end
assign intclk=clkdiv[2];
always@(posedge intclk)
begin
if(rst==1)
count<=8'h00;
else
begin
if(en==1'b0)
begin
if(count<8'hff)
count<=count+1;
else
en<=1'b1;
end
else
begin
if(count>8'h00)
count<=count-1;
else
en=1'b0;
end
end
dac<=count;
end
endmodule
UCF
net "clk" loc="p55";
net "dac<0>" loc="p24";
net "dac<1>" loc="p22";
net "dac<2>" loc="p21";
net "dac<3>" loc="p17";
net "dac<4>" loc="p15";
net "dac<5>" loc="p14";
net "dac<6>" loc="p12";
net "dac<7>" loc="p1";