vi.c 1.4 KB
#include <stdio.h>

#include "acc_user.h"
#include "vcsuser.h"

FILE *OutFile;

void PrintTabHeader(char *header)
{
    fprintf(OutFile, "#\n");
    fprintf(OutFile, "#   created by %s.c\n", header);
    fprintf(OutFile, "#\n");
    fprintf(OutFile, "vclk                @C 1(8) 0(8)\n");
    fprintf(OutFile, "vbus_data[6:0]      @I @E 2\n");
    fprintf(OutFile, "vbus_sync           @I @E 2\n");
    fprintf(OutFile, "\n"); /* required newline */    
}

void open_viout_file(void)
{
    char *filename;

    acc_initialize();
    acc_configure(accDevelopmentVersion, "1.6");

    if (tf_nump() != 1)
	{
	    tf_error("Illegal number of arguments to open_viout_file");
	    tf_putp(0, -1);
	}
    else
	{
	    if ((filename = tf_getcstringp(1)) == NULL)
		{
		    tf_error("Illegal parameters passed to open_out_file");
		    tf_putp(0, -1);
		}
	    else
		{
		    if ((OutFile = fopen(filename, "w")) == NULL)
			{
			    tf_error("Couldn't open output file");
			    tf_putp(0, -1);
			}
		    PrintTabHeader("top level rdp vi");
		}
	}
    tf_putp(0, 0);
}

void output_vi()
{
    int vbus_data, vbus_sync;

    if (OutFile != NULL)
	{
	    if (tf_nump() != 2)
		{
		    tf_error("Illegal number of arguments to output_vi");
		    tf_putp(0, -1);
		}
	    else
		{
		    vbus_data   = tf_getp(1);
		    vbus_sync   = tf_getp(2);

		    fprintf(OutFile, "0x%.2x %d \n", vbus_data, vbus_sync);
		}
	}

    tf_putp(0, 0);    

}