sp_tasks.v 1.81 KB
// 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