Untitled

mail@pastecode.io avatar
unknown
c_cpp
7 months ago
1.4 kB
1
Indexable
Never
#include "xparameters.h"
#include "xil_io.h"
#include "DES.h"


//====================================================

int main (void) {

	int messageH = 0x01234567;
	int messageL = 0x89ABCDEF;
	int keyH = 0x01234567;
	int keyL = 0x89ABCDEF;
	int outputH;
	int outputL;
	int i = 0;
	int ret;


    xil_printf("-- Inicio del programa para validar el uso de IP cores propios --\r\n");

    DES_mWriteReg(XPAR_DES_0_S00_AXI_BASEADDR, DES_S00_AXI_SLV_REG0_OFFSET, messageH);
    DES_mWriteReg(XPAR_DES_0_S00_AXI_BASEADDR, DES_S00_AXI_SLV_REG1_OFFSET, messageL);
    DES_mWriteReg(XPAR_DES_0_S00_AXI_BASEADDR, DES_S00_AXI_SLV_REG2_OFFSET, keyH);
    DES_mWriteReg(XPAR_DES_0_S00_AXI_BASEADDR, DES_S00_AXI_SLV_REG3_OFFSET, keyL);
    DES_mWriteReg(XPAR_DES_0_S00_AXI_BASEADDR, DES_S00_AXI_SLV_REG4_OFFSET, 1);
    xil_printf("-- Inicio el modulo DES --\r\n");
    ret = DES_mReadReg(XPAR_DES_0_S00_AXI_BASEADDR, DES_S00_AXI_SLV_REG7_OFFSET);
    while(ret == 0){
    	xil_printf("Esperando a que termine el calculo\r\n");
    	for (i=0; i<9999999; i++);
    	ret = DES_mReadReg(XPAR_DES_0_S00_AXI_BASEADDR, DES_S00_AXI_SLV_REG7_OFFSET);
    }
    outputH = DES_mReadReg(XPAR_DES_0_S00_AXI_BASEADDR, DES_S00_AXI_SLV_REG5_OFFSET);
    outputL = DES_mReadReg(XPAR_DES_0_S00_AXI_BASEADDR, DES_S00_AXI_SLV_REG6_OFFSET);

    xil_printf("Resultado: %X %X \r\n", outputH, outputL);

}
Leave a Comment