rdp_tasks.v
2.38 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
task span_buf_test; // ms test bed
reg [31:0] data_word;
reg [5:0] i;
reg [31:0] address_root;
reg [31:0] address;
reg [1:0] buff_choice ;
reg [2:0] field;
begin
test_selected <= HIGH;
repeat (10) @(posedge clock);
// set test mode bit
write_word(BUS_ADDRESS_SPAN_MODE, 3, 1); // lsb 0 or 1
for (buff_choice = 0 ; buff_choice <= 1 ; buff_choice = buff_choice +1 ) begin
for (field = 0 ; field < 3 ; field = field +1) begin
if (buff_choice == 0 )
address_root = 3'b111;
else
address_root = 3'b011;
data_word = 32'ha000000;
for (i = 0 ; i < 16 ; i = i + 1) begin
// select data field to load within 72 bit word
write_word(BUS_ADDRESS_SPAN_ADDR, 3, field); // choice 0,1,2
// send data word to stage reg under control of load select (test_addr lsbs)
write_word(BUS_ADDRESS_SPAN_DATA, 3, (data_word +i) ); // load stage reg
// select address in buf and choose msb or lsb buffer
// setting adder 2:0 to 3 or 7 allows next reg_write_enbale to
// generate a write pulse to the memory.
// setting addr [2:0] 7 choses lsb buffer
// setting addr [2:0] 3 choses msb buffer
// addr 6:3 = address within selected buffer
address = (i<<3 ) + address_root;
write_word(BUS_ADDRESS_SPAN_ADDR, 3, address); // 7 = lsb's 3 = msb's
// perform the write data is null
// any reg_write enbale will write the mem at previously loaded addres
write_word(BUS_ADDRESS_SPAN_ADDR, 3, 0); //
end
// select data field for read
write_word(BUS_ADDRESS_SPAN_ADDR, 3, 32'b100); // choice 0,1,2
if (buff_choice == 0)
address_root = 3'b100 + field;
else
address_root = field;
data_word = 32'ha000000;
for (i = 0 ; i < 16 ; i = i + 1) begin
address = (i<<3 ) + address_root;
// set test address for the read, duplicate settings
// used to write the staging reg
write_word(BUS_ADDRESS_SPAN_ADDR, 3, address); // 7 = lsb's 3 = msb's
read_word(BUS_ADDRESS_SPAN_DATA, 3); // read data, addressed by test_addr
if (field != 2) begin
if (data[0] != (data_word +i))
$display ("spanbuf read fail buff_choice %h field %h i %h data %h address %h ", buff_choice , field, i, data[0], address);
end
else begin
if (data[0] != (32'hf & (data_word +i)))
$display ("spanbuf read fail buff_choice %h field %h i %h data %h address %h ", buff_choice , field, i, data[0], address);
end
end // i
end // field
end // buff_choice
$finish;
end
endtask