From d1b70f80180fe4b5ac6078e2be9678fc36d74c5c Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Mon, 1 Oct 2012 21:07:55 -0500 Subject: Add initial files for direct FPGA programming --- fpga/xilinx/programmer/bit2svf/bitshandle.c | 144 ++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 fpga/xilinx/programmer/bit2svf/bitshandle.c (limited to 'fpga/xilinx/programmer/bit2svf/bitshandle.c') diff --git a/fpga/xilinx/programmer/bit2svf/bitshandle.c b/fpga/xilinx/programmer/bit2svf/bitshandle.c new file mode 100644 index 0000000..7fb2f40 --- /dev/null +++ b/fpga/xilinx/programmer/bit2svf/bitshandle.c @@ -0,0 +1,144 @@ + /**[txh]******************************************************************** + + Copyright (c) 2005 Juan Pablo D. Borgna + Copyright (c) 2006-2007 Salvador E. Tropea + Copyright (c) 2005-2007 Instituto Nacional de Tecnología Industrial + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA + + Description: Low level functions to output hexadecimal bitstreams. + +***************************************************************************/ +/***************************************************************************** + + Target: Any + Language: C + Compiler: gcc 3.3.5 (Debian GNU/Linux) + Text editor: SETEdit 0.5.5 + +*****************************************************************************/ + +#include +#include +#include +#include "global.h" +#include "bitshandle.h" + +/* This function returns the inverted bits of its argument */ +unsigned char +inv_byte(unsigned char b) +{ + int i; + unsigned char t=0; + + for (i=0;i<7;i++) + { + t|= (b & 0x01); + t = t << 1; + b = b >> 1; + } + t|=b & 0x01; + return t; +} + +/* This function is used to generate a string with the hex value of the + inverted bits of from */ +void +pbi(char *to, char *from,long nbytes) +{ + int i; + int j; + char t[]="ZZ"; + + if (to==NULL) return; + + j=nbytes*2; + + for (i=0;i