sp_tasks.v
1.81 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// sp_tasks.v v1 Frank Berndt
// SP tasks;
task sp_dma_write;
input [31:0] master_address;
input [31:0] slave_address;
input [11:0] skip;
input [7:0] count;
input [11:0] length;
integer status;
begin
// while busy
sread(BUS_ADDRESS_SP_STATUS, 3, data[0]);
status = data[0];
while (status[3]) begin
sread(BUS_ADDRESS_SP_STATUS, 3, data[0]);
status = data[0];
end
swrite(BUS_ADDRESS_SP_MASTER, 3, master_address);
swrite(BUS_ADDRESS_SP_SLAVE, 3, slave_address);
swrite(BUS_ADDRESS_SP_WRITE, 3, {skip, count, length});
pvalid <= LOW;
@(posedge sysclk);
end
endtask
task sp_dma_read;
input [31:0] master_address;
input [31:0] slave_address;
input [11:0] skip;
input [7:0] count;
input [11:0] length;
integer status;
begin
// while busy
sread(BUS_ADDRESS_SP_STATUS, 3, data[0]);
status = data[0];
while (status[3]) begin
sread(BUS_ADDRESS_SP_STATUS, 3, data[0]);
status = data[0];
end
swrite(BUS_ADDRESS_SP_MASTER, 3, master_address);
swrite(BUS_ADDRESS_SP_SLAVE, 3, slave_address);
swrite(BUS_ADDRESS_SP_READ, 3, {skip, count, length});
pvalid <= LOW;
@(posedge sysclk);
end
endtask
task sp_mem_write;
input [31:0] address;
input [31:0] write_data;
integer status;
begin
// while busy
sread(BUS_ADDRESS_SP_STATUS, 3, data[0]);
status = data[0];
while (status[4]) begin
sread(BUS_ADDRESS_SP_STATUS, 3, data[0]);
status = data[0];
end
swrite(BUS_ADDRESS_SP_DMEM+address, 3, write_data);
pvalid <= LOW;
@(posedge sysclk);
end
endtask
task sp_mem_read;
input [31:0] address;
integer status;
begin
// while busy
sread(BUS_ADDRESS_SP_STATUS, 3, data[0]);
status = data[0];
while (status[4]) begin
sread(BUS_ADDRESS_SP_STATUS, 3, data[0]);
status = data[0];
end
sread(BUS_ADDRESS_SP_DMEM+address, 3, data[0]);
end
endtask