audio_tasks.v 2.08 KB
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