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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
module ex14_top (
CLOCK_50,
DAC_SDI,
DAC_CS,
DAC_LD,
DAC_SCK,
PWM_OUT,
SW,
HEX0,
HEX1,
HEX2,
HEX3
);
input CLOCK_50;
input [9:0] SW;
output DAC_SDI,DAC_CS,DAC_SCK,DAC_LD,PWM_OUT;
output [6:0] HEX0,HEX1,HEX2,HEX3;
wire CLOCK_DIVIDED;
reg [9:0] A;
wire [9:0] D;
wire [23:0] MULTRESULT;
wire [3:0] BCD0,BCD1,BCD2,BCD3;
divider_5000 DIV0 (CLOCK_50, CLOCK_DIVIDED);
always @ (posedge CLOCK_DIVIDED)
begin
A <= A + SW;
end
MULT_accum_u5f MULT10K (
.clock(CLOCK_50),
.sload(CLOCK_DIVIDED),
.data(SW[9:0]),
.result(MULTRESULT)
);
bin2bcd_16 BIN0 (
.B(MULTRESULT[23:10]),
.BCD_0(BCD0),
.BCD_1(BCD1),
.BCD_2(BCD2),
.BCD_3(BCD3)
);
hex_to_7seg SEG0 (.out(HEX0),.in(BCD0));
hex_to_7seg SEG1 (.out(HEX1),.in(BCD1));
hex_to_7seg SEG2 (.out(HEX2),.in(BCD2));
hex_to_7seg SEG3 (.out(HEX3),.in(BCD3));
ROM ROM0 (
.address(A),
.clock(CLOCK_DIVIDED),
.q(D[9:0])
);
spi2dac SPI0 (
.sysclk(CLOCK_50),
.data_in(D[9:0]),
.load(CLOCK_DIVIDED),
.dac_sdi(DAC_SDI),
.dac_cs(DAC_CS),
.dac_sck(DAC_SCK),
.dac_ld(DAC_LD)
);
pwm PWM0 (
.clk(CLOCK_50),
.data_in(D[9:0]),
.load(CLOCK_DIVIDED),
.pwm_out(PWM_OUT)
);
endmodule
|