URL
https://opencores.org/ocsvn/gecko4/gecko4/trunk
Subversion Repositories gecko4
Compare Revisions
- This comparison shows the changes necessary to convert path
/
- from Rev 5 to Rev 6
- ↔ Reverse comparison
Rev 5 → Rev 6
/gecko4/trunk/GECKO4com/utils/c/generate_scpi_table.c
0,0 → 1,211
/******************************************************************************/ |
/* _ _ __ ____ */ |
/* / / | | / _| | __| */ |
/* | |_| | _ _ / / | |_ */ |
/* | _ | | | | | | | | _| */ |
/* | | | | | |_| | \ \_ | |__ */ |
/* |_| |_| \_____| \__| |____| microLab */ |
/* */ |
/* Bern University of Applied Sciences (BFH) */ |
/* Quellgasse 21 */ |
/* Room HG 4.33 */ |
/* 2501 Biel/Bienne */ |
/* Switzerland */ |
/* */ |
/* http://www.microlab.ch */ |
/******************************************************************************/ |
/* GECKO4com |
|
2010/2011 Dr. Theo Kluter |
|
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, either version 3 of the License, or |
(at your option) any later version. |
|
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 these sources. If not, see <http://www.gnu.org/licenses/>. |
*/ |
#include <stdio.h> |
#include <stdlib.h> |
#include <string.h> |
|
/* IMPORTANT: The below table list the already implemented SCPI commands. You |
can add more yourself, but must refrain from: |
1) Editing the ID values of the present SCPI commands. |
2) Using duplicate ID values or duplicate commands! |
3) Using commands longer than 14 chars |
*/ |
|
#define nr_of_known_scpi_commands 36 |
const char *scpi_table[nr_of_known_scpi_commands*2] = { |
/* ID , command */ |
"2","*CLS", |
"6","*ESE", |
"7","*ESE?", |
"8","*ESR?", |
"9","*IDN?", |
"10","*IST?", |
"11","*OPC", |
"12","*OPC?", |
"13","*PUD", |
"14","*PUD?", |
"15","*RST", |
"16","*SRE", |
"17","*SRE?", |
"18","*STB?", |
"20","*TST?", |
"21","*WAI", |
"22","BITFLASH", |
"23","BITFLASH?", |
"24","BOARD?", |
"25","CONFIG", |
"26","ERASE", |
"27","FIFO", |
"28","FIFO?", |
"29","FPGA", |
"30","FPGA?", |
"35","HEXSWITCH", |
"36","HEXSWITCH?", |
"37","IDENTIFY", |
"51","TRANS", |
"58","USERRESET", |
"59","VGA:BGCOL", |
"60","VGA:CLEAR", |
"61","VGA:CURSOR", |
"62","VGA:CURSOR?", |
"63","VGA:FGCOL", |
"64","VGA:PUTSTR"}; |
|
typedef struct comand_type { |
unsigned char ID; |
char *command; |
} comand_type_t; |
|
unsigned char get_dec( char *str ) { |
unsigned int result; |
int loop,sort; |
|
result = 0; |
for (loop = 0 ; loop < strlen(str) ; loop++) { |
if ((str[loop] >= '0')&& |
(str[loop] <= '9')) { |
result *= 10; |
result += (str[loop]-'0'); |
} else { |
printf("ERROR: invalid ID found!\n" ); |
return 255; |
} |
} |
if (result > 128) { |
printf( "ERROR: Too big ID found!\n" ); |
return 255; |
} else { |
return result; |
} |
} |
|
int main() { |
comand_type_t *commands[128],*dummy; |
unsigned char rom[2048]; |
int loop,sort,offset; |
|
if (nr_of_known_scpi_commands > 128) { |
printf( "ERROR: Too many SCPI commands defined!\n" ); |
return -1; |
} |
|
for (loop = 0 ; loop < 128 ; loop++) { |
commands[loop] = NULL; |
} |
|
for (loop = 0 ; loop < nr_of_known_scpi_commands ; loop++) { |
commands[loop] = (comand_type_t *) malloc( sizeof( comand_type_t ) ); |
if (commands[loop] == NULL) { |
printf( "ERROR: Unable to allocate memory!\n" ); |
return -1; |
} |
commands[loop]->ID = get_dec(scpi_table[loop*2]); |
if ((strlen(scpi_table[(loop*2)+1]) < 15)&& |
(strlen(scpi_table[(loop*2)+1]) > 0)) { |
commands[loop]->command = (char*) malloc( |
(strlen(scpi_table[(loop*2)+1])+1)*sizeof(char)); |
if (commands[loop]->command == NULL) { |
printf( "ERROR: Unable to allocate memory!\n" ); |
return -1; |
} |
strcpy(commands[loop]->command , scpi_table[(loop*2)+1]); |
for (sort = 0 ; sort < strlen(commands[loop]->command) ; sort++) { |
if ((commands[loop]->command[sort] >= 'a')&& |
(commands[loop]->command[sort] <= 'z')) { |
commands[loop]->command[sort] -= ('a'-'A'); |
} |
} |
} else { |
printf("ERROR: Too long SCPI command \"%s\" found!" , |
scpi_table[(loop*2)+1] ); |
return -1; |
} |
} |
|
for (loop = 0 ; loop < nr_of_known_scpi_commands-1 ; loop++) { |
for (sort = loop+1 ; sort < nr_of_known_scpi_commands ; sort++) { |
if (commands[loop]->ID == commands[sort]->ID) { |
printf( "ERROR: Duplicate ID found!\n" ); |
return -1; |
} |
if (strcmp(commands[loop]->command,commands[sort]->command) == 0) { |
printf( "ERROR: Duplicate SCPI command found!\n" ); |
return -1; |
} |
if (strcmp(commands[loop]->command,commands[sort]->command) > 0) { |
dummy = commands[loop]; |
commands[loop] = commands[sort]; |
commands[sort] = dummy; |
} |
} |
} |
printf( " -- Command ID <=> Command\n" ); |
for (loop = 0 ; loop < nr_of_known_scpi_commands ; loop++) { |
printf( " -- 0x%02X <=> \"%s\"\n" , commands[loop]->ID , commands[loop]->command ); |
offset=loop*16; |
sort = 0; |
while (sort < strlen(commands[loop]->command)) { |
rom[offset+sort] = commands[loop]->command[sort]; |
sort++; |
} |
rom[offset+sort] = 0; |
sort++; |
rom[offset+sort] = commands[loop]->ID; |
sort++; |
while (sort < 16) { |
rom[offset+sort] = 0xFF; |
sort++; |
} |
} |
for (loop = nr_of_known_scpi_commands ; loop < 128 ; loop++) { |
offset = loop*16; |
for (sort = 0 ; sort < 16 ; sort++) |
rom[offset+sort] = 0xFE; |
} |
for (loop = 0 ; loop < 64 ; loop++) { |
if (loop == 0) { |
printf( " GENERIC MAP ( INIT_00 => X\"" ); |
} else { |
printf( " INIT_%02X => X\"" , loop ); |
} |
for (sort = 31 ; sort > -1 ; sort--) { |
printf("%02X",rom[loop*32+sort] ); |
} |
if (loop != 63) { |
printf( "\",\n" ); |
} else { |
printf( "\")\n" ); |
} |
} |
return 0; |
} |
/gecko4/trunk/GECKO4com/utils/c/generate_fpga_board_strings.c
0,0 → 1,106
/******************************************************************************/ |
/* _ _ __ ____ */ |
/* / / | | / _| | __| */ |
/* | |_| | _ _ / / | |_ */ |
/* | _ | | | | | | | | _| */ |
/* | | | | | |_| | \ \_ | |__ */ |
/* |_| |_| \_____| \__| |____| microLab */ |
/* */ |
/* Bern University of Applied Sciences (BFH) */ |
/* Quellgasse 21 */ |
/* Room HG 4.33 */ |
/* 2501 Biel/Bienne */ |
/* Switzerland */ |
/* */ |
/* http://www.microlab.ch */ |
/******************************************************************************/ |
/* GECKO4com |
|
2010/2011 Dr. Theo Kluter |
|
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, either version 3 of the License, or |
(at your option) any later version. |
|
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 these sources. If not, see <http://www.gnu.org/licenses/>. |
*/ |
#include <stdio.h> |
#include <stdlib.h> |
#include <string.h> |
|
const char *strings[32] = { |
"Xilinx Spartan 3 XC3S1000FGG676, not configured\n", |
"Xilinx Spartan 3 XC3S1500FGG676, not configured\n", |
"Xilinx Spartan 3 XC3S2000FGG676, not configured\n", |
"Xilinx Spartan 3 XC3S4000FGG676, not configured\n", |
"Xilinx Spartan 3 XC3S5000FGG676, not configured\n", |
"No FPGA mounted or unknown FPGA type\n", |
"No FPGA mounted or unknown FPGA type\n", |
"No FPGA mounted or unknown FPGA type\n", |
"Xilinx Spartan 3 XC3S1000FGG676, running\n", |
"Xilinx Spartan 3 XC3S1500FGG676, running\n", |
"Xilinx Spartan 3 XC3S2000FGG676, running\n", |
"Xilinx Spartan 3 XC3S4000FGG676, running\n", |
"Xilinx Spartan 3 XC3S5000FGG676, running\n", |
"No FPGA mounted or unknown FPGA type\n", |
"No FPGA mounted or unknown FPGA type\n", |
"No FPGA mounted or unknown FPGA type\n", |
"Undefined State, soldering problem?\n", |
"GECKO4main: USB supplied, powering BUS, Flash programmed\n", |
"Undefined State, soldering problem?\n", |
"GECKO4main: USB supplied, Flash programmed\n", |
"GECKO4main: GENIO1 supplied, powering BUS, Flash programmed\n", |
"Undefined State, soldering problem?\n", |
"GECKO4main: GENIO1 supplied, Flash programmed\n", |
"Undefined State, soldering problem?\n", |
"Undefined State, soldering problem?\n", |
"GECKO4main: USB supplied, powering BUS, Flash empty\n", |
"Undefined State, soldering problem?\n", |
"GECKO4main: USB supplied, Flash empty\n", |
"GECKO4main: GENIO1 supplied, powering BUS, Flash empty\n", |
"Undefined State, soldering problem?\n", |
"GECKO4main: GENIO1 supplied, Flash empty\n", |
"Undefined State, soldering problem?\n"}; |
|
int main () { |
unsigned char rom[2048]; |
int loop,charcnt,index,sort; |
|
for (loop = 0 ; loop < 32 ; loop++) { |
if (strlen(strings[loop]) > 62) { |
printf ("Too long string found!\n"); |
return -1; |
} |
rom[loop*64] = strlen(strings[loop])+128; |
index = 1; |
for (charcnt = 0 ; charcnt < strlen(strings[loop]) ; charcnt++) { |
rom[(loop*64)+index++] = strings[loop][charcnt]; |
printf("%c",strings[loop][charcnt]); |
} |
while (index < 64) { |
rom[(loop*64)+index++] = 0; |
} |
} |
for (loop = 0 ; loop < 64 ; loop++) { |
if (loop == 0) { |
printf( " GENERIC MAP ( INIT_00 => X\"" ); |
} else { |
printf( " INIT_%02X => X\"" , loop ); |
} |
for (sort = 31 ; sort > -1 ; sort--) { |
printf("%02X",rom[loop*32+sort] ); |
} |
if (loop != 63) { |
printf( "\",\n" ); |
} else { |
printf( "\")\n" ); |
} |
} |
return 0; |
} |
/gecko4/trunk/GECKO4com/utils/c/generate_pud_data.c
0,0 → 1,81
/******************************************************************************/ |
/* _ _ __ ____ */ |
/* / / | | / _| | __| */ |
/* | |_| | _ _ / / | |_ */ |
/* | _ | | | | | | | | _| */ |
/* | | | | | |_| | \ \_ | |__ */ |
/* |_| |_| \_____| \__| |____| microLab */ |
/* */ |
/* Bern University of Applied Sciences (BFH) */ |
/* Quellgasse 21 */ |
/* Room HG 4.33 */ |
/* 2501 Biel/Bienne */ |
/* Switzerland */ |
/* */ |
/* http://www.microlab.ch */ |
/******************************************************************************/ |
/* GECKO4com |
|
2010/2011 Dr. Theo Kluter |
|
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, either version 3 of the License, or |
(at your option) any later version. |
|
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 these sources. If not, see <http://www.gnu.org/licenses/>. |
*/ |
#include <stdio.h> |
#include <stdlib.h> |
#include <string.h> |
|
unsigned char* strs[13] = { |
" ", |
"This is a static user window of 13 lines x 64 chars", |
"It is stored in the last 832 locations of the", |
"PUD memory an can be used to display for example", |
"user logos.", |
" ", |
"It's contents can be written with the *PUD command", |
" ", |
"For further information see http://gecko.microlab.ch", |
" ", |
"This is GECKO4main and GECKO4com", |
" ", |
"Dr. Theo Kluter 2011"}; |
|
|
int main() { |
unsigned char data[2048]; |
int loop,index,line,fill; |
FILE *ofile; |
|
for (loop = 0 ; loop < 2048 ; loop++) |
data[loop] = 0xFF; |
index=2048-832; |
for (loop = 0 ; loop < 13 ; loop++) { |
line = 0; |
for (fill = 0 ; fill <(64-strlen(strs[loop])) / 2; fill++) { |
data[index++] = 0x20; |
line++; |
} |
for (fill = 0 ; fill < strlen(strs[loop]) ; fill++) { |
data[index++] = strs[loop][fill]; |
line++; |
} |
while (line < 64) { |
data[index++] = 0x20; |
line++; |
} |
} |
printf("%d\n" , index ); |
ofile=fopen("pud.cmd","w"); |
fprintf( ofile , "*pud " ); |
for (loop = 0 ; loop < 2048 ; loop++) |
fputc(data[loop],ofile); |
} |
/gecko4/trunk/GECKO4com/utils/c/generate_gecko_vga_rom.c
0,0 → 1,122
/******************************************************************************/ |
/* _ _ __ ____ */ |
/* / / | | / _| | __| */ |
/* | |_| | _ _ / / | |_ */ |
/* | _ | | | | | | | | _| */ |
/* | | | | | |_| | \ \_ | |__ */ |
/* |_| |_| \_____| \__| |____| microLab */ |
/* */ |
/* Bern University of Applied Sciences (BFH) */ |
/* Quellgasse 21 */ |
/* Room HG 4.33 */ |
/* 2501 Biel/Bienne */ |
/* Switzerland */ |
/* */ |
/* http://www.microlab.ch */ |
/******************************************************************************/ |
/* GECKO4com |
|
2010/2011 Dr. Theo Kluter |
|
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, either version 3 of the License, or |
(at your option) any later version. |
|
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 these sources. If not, see <http://www.gnu.org/licenses/>. |
*/ |
|
#include <stdio.h> |
#include <stdlib.h> |
#include <string.h> |
|
const char *left_screen_strs[16] = { |
" _ _ __ ____ ", |
" / / | | / _| | __| ", |
" | |_| | _ _ / / | |_ ", |
" | _ | | | | | | | | _| ", |
" | | | | | |_| | \\ \\_ | |__ ", |
" |_| |_| \\_____| \\__| |____| microLab", |
" ", |
" Bern University of Applied Sciences (BFH)", |
" Quellgasse 21", |
" Room HG 4.33", |
" 2501 Biel/Bienne", |
" Switzerland", |
" ", |
" http://www.microlab.ch", |
" ________________", |
" /USBTMC messages:\\"}; |
|
const char *right_screen_strs[16] = { |
" ", |
" GECKO4main and GECKO4com", |
" ------------------------", |
" The GECKO system is a general purpose hardware/software co-", |
" design environment for real-time information processing or", |
" for system-on-chip (SoC) solutions. The GECKO project supports", |
" a new design methodology for system-on-chips, which", |
" necessitates co-design of software, fast hardware and", |
" dedicated real-time signal processing hardware. Within the", |
" GECKO project, the GECKO4main module represents an experimental", |
" platform, which offers the necessary computing power for speed", |
" intensive real-time algorithms as well as the necessary", |
" flexibility for control intensive software tasks.", |
" For more information see: http://gecko.microlab.ch", |
" ______________", |
" /FPGA messages:\\"}; |
|
|
int main() { |
unsigned char rom[2048]; |
int loop,index,chars,sort; |
|
index = 0; |
for (loop = 0 ; loop < 16 ; loop++) { |
if (strlen(left_screen_strs[loop]) > 64) { |
printf("Too long string found!\n" ); |
return -1; |
} |
for (chars = 0 ; chars < strlen(left_screen_strs[loop]) ; chars++) |
rom[index++] = left_screen_strs[loop][chars]; |
while(chars < 64) { |
chars++; |
rom[index++] = 32; |
} |
if (strlen(right_screen_strs[loop]) > 64) { |
printf("Too long string found!\n" ); |
return -1; |
} |
for (chars = 0 ; chars < strlen(right_screen_strs[loop]) ; chars++) |
rom[index++] = right_screen_strs[loop][chars]; |
while(chars < 64) { |
chars++; |
rom[index++] = 32; |
} |
} |
if (index != 2048) { |
printf( "ERROR!\n" ); |
return -1; |
} |
for (loop = 0 ; loop < 64 ; loop++) { |
if (loop == 0) { |
printf( " GENERIC MAP ( INIT_00 => X\"" ); |
} else { |
printf( " INIT_%02X => X\"" , loop ); |
} |
for (sort = 31 ; sort > -1 ; sort--) { |
printf("%02X",rom[loop*32+sort] ); |
} |
if (loop != 63) { |
printf( "\",\n" ); |
} else { |
printf( "\")\n" ); |
} |
} |
return 0; |
} |
/gecko4/trunk/GECKO4com/utils/c/generate_id_string.c
0,0 → 1,90
/******************************************************************************/ |
/* _ _ __ ____ */ |
/* / / | | / _| | __| */ |
/* | |_| | _ _ / / | |_ */ |
/* | _ | | | | | | | | _| */ |
/* | | | | | |_| | \ \_ | |__ */ |
/* |_| |_| \_____| \__| |____| microLab */ |
/* */ |
/* Bern University of Applied Sciences (BFH) */ |
/* Quellgasse 21 */ |
/* Room HG 4.33 */ |
/* 2501 Biel/Bienne */ |
/* Switzerland */ |
/* */ |
/* http://www.microlab.ch */ |
/******************************************************************************/ |
/* GECKO4com |
|
2010/2011 Dr. Theo Kluter |
|
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, either version 3 of the License, or |
(at your option) any later version. |
|
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 these sources. If not, see <http://www.gnu.org/licenses/>. |
*/ |
#include <stdio.h> |
#include <stdlib.h> |
#include <string.h> |
|
const unsigned char ID_STR[] = "HUCE-microlab,GECKO4COM,0,1.0"; |
|
void to_bin( int value ) { |
int mask; |
|
mask = 1<<4; |
while (mask > 0) { |
if ((value&mask) != 0) |
printf("1"); |
else |
printf("0"); |
mask >>= 1; |
} |
} |
|
int main() { |
int loop,index,len,mask; |
unsigned char buffer[32]; |
|
len = strlen(ID_STR); |
if (len > 31) { |
printf( "ERROR: ID string too long!\n" ); |
return -1; |
} |
index = 0; |
buffer[index]=len; |
for (loop = 0 ; loop < len ; loop++) |
buffer[loop+1] = ID_STR[loop]; |
index = len; |
printf( " done <= s_done;\n" ); |
printf( " push <= '1' WHEN s_rom_index(5) = '0' ELSE '0';\n" ); |
printf( " size_bit <= '1' WHEN s_rom_index = \"000000\" ELSE '0';\n\n " ); |
printf( " s_done <= '1' WHEN s_rom_index = \"0"); |
to_bin(index); |
printf( "\" ELSE '0';\n\n" ); |
printf( " make_rom_index : PROCESS( clock , start , reset , s_done )\n" ); |
printf( " BEGIN\n IF (clock'event AND (clock = '1')) THEN\n" ); |
printf( " IF (reset = '1' OR s_done = '1') THEN \n" ); |
printf( " s_rom_index <= (OTHERS => '1');\n" ); |
printf( " ELSIF (start = '1') THEN\n" ); |
printf( " s_rom_index <= (OTHERS => '0');\n" ); |
printf( " ELSEIF (s_rom_index(5) = '0') THEN \n" ); |
printf( " s_rom_index <= unsigned(s_rom_index) + 1;\n" ); |
printf( " END IF;\n END IF;\n END PROCESS make_rom_index;\n\n"); |
printf( " make_rom_data : PROCESS( s_rom_index )\n" ); |
printf( " BEGIN\n CASE (s_rom_index) IS\n" ); |
while (index > -1) { |
printf( " WHEN \"0" ); |
to_bin(index); |
printf( "\" => push_data <= X\"%02X\";\n" , buffer[index--] ); |
} |
printf( " WHEN OTHERS => push_data <= X\"00\";\n" ); |
printf( " END CASE;\n END PROCESS make_rom_data;\n" ); |
} |