Skip to content

Instantly share code, notes, and snippets.

View raczben's full-sized avatar

Benedek Racz raczben

View GitHub Profile
@raczben
raczben / numrange.py
Last active June 15, 2021 09:34
Convert string represented numbers, list and range of numbers to python structures
# Number, list range util
def number(a, just_try=False):
"""
Parse any representation of number from string.
:param a: String represented number
:type a: Union[str, int, float]
:param just_try: True: Return :a: if it is not a number, defaults to False
:type just_try: bool, optional
@raczben
raczben / pool.py
Created February 18, 2021 12:56 — forked from nfaggian/pool.py
Multiprocessing example
from __future__ import print_function
import multiprocessing
import ctypes
import numpy as np
def shared_array(shape):
"""
Form a shared memory numpy array.
@raczben
raczben / getlab.py
Last active February 9, 2021 08:46
Simple python script to fetch gitlab's artifact from a job / from privately
#!/usr/bin/env python
import logging
import sys
import os
import subprocess
import argparse
import configparser
try:
import gitlab
@raczben
raczben / fast_bsdl_parser.py
Created November 9, 2020 15:05
Fast BSDL Parser: https://github.com/cyrozap/python-bsdl-parser is a fully featured BSDL parser, but it is slow. This Fast BSDL parser parses the attributes fast to fetch the IDCODE fast from dozen of BSDL files.
#!/usr/bin/env python3
#
# fast_bsdl_parser.py
#
# Based on https://gist.github.com/raczben/88693d22600d743a5ccad797e7374260
#
import os
import sys
import re
@raczben
raczben / argparse_files.py
Last active November 20, 2020 08:40 — forked from 89465127/argparse_files.py
Get a list of filenames using argparse (updated to use default formatter)
import argparse
import os
import glob
def main():
#Does not currently have support to read files from folders recursively
parser = argparse.ArgumentParser(description='Read in a file or set of files, and return the result.', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('path', nargs='+', help='Path of a file or a folder of files.')
parser.add_argument('-e', '--extension', action='append', default=[''], help='File extension to filter by.')
args = parser.parse_args()
@raczben
raczben / xil_sprintf.c
Last active February 28, 2024 13:27
This is a simple sprintf implementation to minimaze ROM and RAM usage
#include "xil_sprintf.h" // Define here: void xil_sprintf(char* s, const char *ctrl1, ...);
#include "xil_types.h"
#include "ctype.h"
#include "stdarg.h"
#if defined (__aarch64__)
Not tested on __aarch64__!!!
Remove these lines to use on __aarch64__, but no guarantee:
__aarch64__ related lines has not been reviewed.
#endif
@raczben
raczben / coherent_cdc.vhd
Created June 18, 2020 07:36
Coherent CDC -- transfer signals between two clock domains.
----------------------------------------------------------------------------------------------------
--
-- Coherent CDC
--
-- This module transfer signals between two clock domains.
--
-- Use this module to transfer slow signal groups, where
-- - the latency is not critical, but
-- - the coherency is mandatory.
--
@raczben
raczben / unused_signals.py
Created April 2, 2020 16:30
Prints unused signals in one or multiple VHDL files
#
# unused_signals.py
#
# Prints unused signals in one or multiple VHDL files
#
import os
import sys
import re
import argparse
@raczben
raczben / wexpect.py
Last active March 30, 2020 13:46
Latest wexpect *one-file* version
"""Wexpect is a Windows variant of pexpect https://pexpect.readthedocs.io.
Wexpect is a Python module for spawning child applications and controlling
them automatically. Wexpect can be used for automating interactive applications
such as ssh, ftp, passwd, telnet, etc. It can be used to a automate setup
scripts for duplicating software package installations on different servers. It
can be used for automated software testing. Wexpect is in the spirit of Don
Libes' Expect, but Wexpect is pure Python. Other Expect-like modules for Python
require TCL and Expect or require C extensions to be compiled. Wexpect does not
use C, Expect, or TCL extensions.