rdp_tasks.v 2.36 KB
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 sysclk);

  // set test mode bit
  swrite(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
  swrite(BUS_ADDRESS_SPAN_ADDR, 3,    field); // choice 0,1,2

  // send data word to stage reg under control of load select (test_addr lsbs)
  swrite(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;
  swrite(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
  swrite(BUS_ADDRESS_SPAN_ADDR, 3,   0); // 

end

  // select data field for read
  swrite(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
  swrite(BUS_ADDRESS_SPAN_ADDR, 3, address); //  7 = lsb's 3 = msb's

  sread(BUS_ADDRESS_SPAN_DATA, 3, data[0]); // 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