Skip to content

Instantly share code, notes, and snippets.

View mohamed's full-sized avatar

Mohamed A. Bamakhrama mohamed

View GitHub Profile
@mohamed
mohamed / build-gn.sh
Last active September 23, 2022 06:25
Build Google gn build tool standalone
#!/usr/bin/env sh
set -euv
# Updated on April 2019 to reflect changes in GN
# See:
# https://github.com/ninja-build/ninja
# https://gn.googlesource.com/gn/
# We need a recent git
@mohamed
mohamed / Matrix.md
Created May 29, 2018 09:25 — forked from nadavrot/Matrix.md
Efficient matrix multiplication

High-Performance Matrix Multiplication

This is a short post that explains how to write a high-performance matrix multiplication program on modern processors. In this tutorial I will use a single core of the Skylake-client CPU with AVX2, but the principles in this post also apply to other processors with different instruction sets (such as AVX512).

Intro

Matrix multiplication is a mathematical operation that defines the product of

@mohamed
mohamed / deca-litex.md
Last active June 18, 2022 22:06
Using DECA board with LiteX

Using the DECA board with LiteX

  1. Follow LiteX installation steps outlined here

  2. Install Intel Quartus Prime (Lite Edition) from here

  3. Build and run the example shipped with LiteX:

$ cd litex-boards/litex_boards/targets

#!/usr/bin/env bash
# journal.sh
# ==========
#
# One daily text file to rule them all.
#
# Copyright: 2022 Tyler Cipriani <tyler@tylercipriani.com
# License: GPLv3
set -euo pipefail
@mohamed
mohamed / audio.py
Created November 20, 2022 18:40
Record and plot audio from microphone
import pyaudio
import matplotlib.pyplot as plt
import numpy
import wave
FORMAT = pyaudio.paInt16 # We use 16bit format per sample
CHANNELS = 1
RATE = 44100
CHUNK = 1024 # 1024bytes of data red from a buffer
@mohamed
mohamed / tarjan.py
Last active May 16, 2023 11:08
Tarjan's strongly connected components algorithm
"""
Tarjan's strongly connected components algorithm + Topological sort
Taken from: http://www.logarithmic.net/pfh/blog/01208083168
Public domain. Use it as you will
"""
def strongly_connected_components(graph):
"""
Tarjan's Algorithm (named for its discoverer, Robert Tarjan) is a graph
@mohamed
mohamed / Makefile
Created May 22, 2023 13:54
cocotb example
# Run with make SIM=verilator
TOPLEVEL_LANG = verilog
VERILOG_SOURCES = $(shell pwd)/skid_buffer.sv
TOPLEVEL = skid_buffer
MODULE = skid_buffer_tb
EXTRA_ARGS += --coverage --trace-fst --trace-structs
include $(shell cocotb-config --makefiles)/Makefile.sim
@mohamed
mohamed / IQ-UpDownConversion.ipynb
Created June 20, 2023 12:39
IQ Up and Down Conversion
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mohamed
mohamed / riscv-toolchain.md
Last active January 26, 2024 20:48
Setting up RISC-V toolchain and simulator
@mohamed
mohamed / arm-cortexm0plus-compilation.md
Created September 18, 2023 09:28
Compiling baremetal C program for Arm Cortex-M0+

Compiling baremetal C program for Arm Cortex-M0+

  1. Install Arm GNU GCC compiler. Download the tar.xv archive from: https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads Define the environmet variable $ARM_GCC_ROOT to point to the location where you extract this archive. This guide was tested with arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi

  2. Update your $PATH and $LD_LIBRARY_PATH as follows:

    setenv PATH $ARM_GCC_ROOT/bin:$PATH
    

setenv LD_LIBRARY_PATH $ARM_GCC_ROOT/lib:$LD_LIBRARY_PATH