audio_tasks.v
2.08 KB
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
task ai_test;
// audio test debug socket
begin
test_selected <= HIGH;
repeat (10) @(posedge sysclk);
mem_config;
// put some data in the dram first
swrite(BUS_ADDRESS_DRAM, 3, 32'h0ad00da0);
swrite(BUS_ADDRESS_DRAM+4, 3, 32'h1ad11da1);
swrite(BUS_ADDRESS_DRAM+8, 3, 32'h2ad22da2);
swrite(BUS_ADDRESS_DRAM+12, 3, 32'h3ad33da3);
swrite(BUS_ADDRESS_DRAM+16, 3, 32'h4ad44da4);
swrite(BUS_ADDRESS_DRAM+20, 3, 32'h5ad55da5);
swrite(BUS_ADDRESS_DRAM+24, 3, 32'h6ad66da6);
swrite(BUS_ADDRESS_DRAM+28, 3, 32'h7ad77da7);
swrite(BUS_ADDRESS_DRAM+32, 3, 32'h8ad88da8);
// protocol is:
// set bit 0 of control reg
// write address
// write length
// loop_forever {
// write address
// write length
// while (bit_31_of_status == 1) wait;
// }
// need set video control reg ctrl[5] vbus_clk_en_l
swrite(BUS_ADDRESS_VI_CTRL, 3, 0); // external video clock
//swrite(BUS_ADDRESS_VI_CTRL, 3, 5'b10000); // video clock = sys clock
// initialize
// set a dac rate 13:0
swrite(BUS_ADDRESS_AI_DACRATE, 3, 131);
// set bit rate 3:0
swrite(BUS_ADDRESS_AI_BITRATE, 3, 1);
// setting control bit 0 to 1 sets dma_enable
swrite(BUS_ADDRESS_AI_CONTROL, 3, 1);
swrite(BUS_ADDRESS_AI_DRAM_ADDRESS, 3, 8);
// length reg is 18 bits, 8byte aligned w/r max length is h3fff8
swrite(BUS_ADDRESS_AI_LENGTH, 3, 64);
sread(BUS_ADDRESS_AI_STATUS, 3, data[0]);
while ((data[0] && 32'h40000000) == 1) begin
$display (" Read of ai status %h ",data[0]);
sread(BUS_ADDRESS_AI_DRAM_ADDRESS, 3, data[0]);
$display (" Read of ai dram_address %h ",data[0]);
sread(BUS_ADDRESS_AI_LENGTH, 3, data[0]);
$display (" Read of ai length %h ",data[0]);
sread(BUS_ADDRESS_AI_STATUS, 3, data[0]);
end
// wait for a while and watch dma
repeat (200) @(posedge sysclk);
$finish;
end
endtask