spandata_mon.v 2.44 KB
module spandata_mon(clock, reset_l);

`include "rcp.vh"
`include "define.vh"

`define STATE_WAITGRANT			4'h0
`define STATE_WAITSTART			4'h1
`define	STATE_WAITDATA1			4'h2
`define	STATE_WAITDATA2			4'h3
`define STATE_PRINTDATA1		4'h4
`define STATE_PRINTDATA2		4'h5
`define STATE_PRINTDATA3		4'h6
`define STATE_PRINTDATA4		4'h7

input		clock;
input		reset_l;

reg		monitor;
reg [2:0]	state;

initial begin
    monitor = $test$plusargs("spandata_mon");
    state = `STATE_WAITGRANT;
end

always @(posedge clock) begin
    if (monitor && reset_l) begin
	case (state)
	`STATE_WAITGRANT:
	    begin
		if (reality.rcp_0.span_dma_grant)
		    state <= `STATE_WAITSTART;
	    end
	`STATE_WAITSTART:
	    begin
		if (reality.rcp_0.dma_start)
		    if (reality.rcp_0.dma_last)
			state <= `STATE_WAITDATA2;
		    else
			state <= `STATE_WAITDATA1;
	    end
	`STATE_WAITDATA1:
	    begin
		if (!reality.rcp_0.span_dbus_write_enable)
		    state <= `STATE_WAITGRANT;
		else if (reality.rcp_0.dma_last)
		    state <= `STATE_PRINTDATA2;
		else
		    state <= `STATE_PRINTDATA1;
	    end

	`STATE_WAITDATA2:
	    begin
		if (!reality.rcp_0.span_dbus_write_enable)
		    state <= `STATE_WAITGRANT;
		else
		    state <= `STATE_PRINTDATA3;
	    end

	`STATE_PRINTDATA1:
	    begin
		$display(`CLOCK_COUNT, " : dbus   data - %h, from span",
			 reality.rcp_0.rdp_0.ms.dbus_dout);
		$display(`CLOCK_COUNT, " : ebus   data - %h, from span",
		 	  reality.rcp_0.rdp_0.ms.ebus_dout);
		if (reality.rcp_0.dma_last)
		    state <= `STATE_PRINTDATA2;
		else
		    state <= `STATE_PRINTDATA1;
	    end
	`STATE_PRINTDATA2:
	    begin
		$display(`CLOCK_COUNT, " : dbus   data - %h, from span",
			 reality.rcp_0.rdp_0.ms.dbus_dout);
		$display(`CLOCK_COUNT, " : ebus   data - %h, from span",
		 	  reality.rcp_0.rdp_0.ms.ebus_dout);
		state <= `STATE_PRINTDATA3;
	    end
	`STATE_PRINTDATA3:
	    begin
		$display(`CLOCK_COUNT, " : dbus   data - %h, from span",
			 reality.rcp_0.rdp_0.ms.dbus_dout);
		$display(`CLOCK_COUNT, " : ebus   data - %h, from span",
			 reality.rcp_0.rdp_0.ms.ebus_dout);
		state <= `STATE_PRINTDATA4;
	    end
	`STATE_PRINTDATA4:
	    begin
		$display(`CLOCK_COUNT, " : dbus   data - %h, from span",
			 reality.rcp_0.rdp_0.ms.dbus_dout);
		$display(`CLOCK_COUNT, " : ebus   data - %h, from span",
			 reality.rcp_0.rdp_0.ms.ebus_dout);
		if (reality.rcp_0.span_dma_grant)
		    state <= `STATE_WAITSTART;
		else
		    state <= `STATE_WAITGRANT;
	    end
	endcase      	
    end
end

endmodule