test009.v 1.89 KB
//
// test009	Test subblock ordered DMA reads
//

task test009;
  fork
    test009_cmddata;
    test009_check;
  join
endtask

task test009_check;
  integer	i;
  begin
    for (i = 0; i < 4; i = i + 1)
    begin
      while (!dma_start)
	@(posedge clock);
      if (!dma_last)
      begin
	$write("test009: dma_last expected: %d was %d at time %d\n",
	       1'b1, dma_last, $time);
	errors = errors + 1;
      end
      @(posedge clock);
    end
    check_subblock("test009");
  end
endtask

task test009_cmddata;
  reg		[CBUS_DATA_SIZE-1:0] address;
  reg		[DBUS_DATA_SIZE-1:0] actual_d_data;
  reg		[EBUS_DATA_SIZE-1:0] actual_e_data;
  reg		[3:0] nibble;
  integer	i, j;

  begin 

    // Put known patterns in first four doublewords of memory

    address = 0;
    for (i = 0; i < 4; i = i + 1)
    begin
     cbus_dma_write(`DMA_UNMASKED, `DMA_UP, address, BUS_DEVICE_MI, -2, 8);

     nibble = i;

     dbus_put_data({16{nibble}}, {2{nibble}}, -2);

     address = address + 8;
    end

    // Read two doublewords of memory with both beginning address offsets

    for (i = 0; i < 2; i = i + 1)
    begin
      address = i*8;

      cbus_dma_read(`DMA_SUBBLOCK, `DMA_UP, address, BUS_DEVICE_MI, 3, 2*8);

      while (!dma_start)
	@(posedge clock);

      for (j = 0; j < 2; j = j + 1)
      begin
        nibble = i ^ j;
	check_data("test009", {16{nibble}}, dbus_data_reg,
			      { 2{nibble}}, ebus_data_reg);
	@(posedge clock);
      end
    end

    // Read four doublewords of memory with all beginning address offsets

    for (i = 0; i < 4; i = i + 1)
    begin
      address = i*8;

      cbus_dma_read(`DMA_SUBBLOCK, `DMA_UP, address, BUS_DEVICE_MI, 3, 4*8);

      while (!dma_start)
	@(posedge clock);

      for (j = 0; j < 4; j = j + 1)
      begin
        nibble = i ^ j;
	check_data("test009", {16{nibble}}, dbus_data_reg,
			      { 2{nibble}}, ebus_data_reg);
	@(posedge clock);
      end
    end
  end
endtask