
//Clase para hacer todo el interfaz JTAG
//Cristina Fern�ndez Bedoya

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <fstream>
#include <time.h>
#include <string.h>

#include "interfazio.h"

using namespace std;

class JTAG 
{
  public:
    JTAG(InterfazIO & myveryInterfazIO);
 	~JTAG();

	unsigned short send_1_bit(unsigned short TMS,unsigned short TDI,int JTAG_Reg1,unsigned short fpga);
	void jtag_reset(int JTAG_Reg1,unsigned short fpga);
	unsigned short send_n_bit(unsigned short TMS,unsigned short TDI,int JTAG_TDI_Reg2,int JTAG_TDO_Data,int nbits);
	void send_IR(int JTAG_Reg1,unsigned short fpga, int nbits, int INSTRUCTION,int SIstatetofinish,int stateIam);
	unsigned long send_DR(int JTAG_Reg1, unsigned short fpga, int nbits, unsigned long dr_data,int SDstatetofinish,int stateIam);
	unsigned long send_DR_middle_sinreg2(int JTAG_Reg1, unsigned short fpga, int nbits, int final, unsigned long dr_data);
	void prep_send_DR(int JTAG_Reg1, unsigned short fpga,int stateIam);
	unsigned long send_DR_middle(int JTAG_Reg1, unsigned short fpga, int JTAG_TDI_Reg2,int JTAG_TDO_Data, int final, int nbits, unsigned short dr_data);
	void exit_send_DR(int JTAG_Reg1, unsigned short fpga,int SDstatetofinish);
	void runtest(int JTAG_Reg1, unsigned short fpga,int waittime,int stateIam,int RUNstatetofinish);
	void gotoidle(int JTAG_Reg1, unsigned short fpga,int stateIam,int RUNstatetofinish);
	void gotodrpause(int JTAG_Reg1, unsigned short fpga,int stateIam,int RUNstatetofinish);
	void stateseq1(int JTAG_Reg1, unsigned short fpga,int stateIam,int RUNstatetofinish);
	void stateseq2(int JTAG_Reg1, unsigned short fpga,int stateIam,int RUNstatetofinish);

private:
	InterfazIO & myInterfazIO;
};

