Skip to content

Instantly share code, notes, and snippets.

View Martoni's full-sized avatar

Fabien Marteau Martoni

View GitHub Profile
#example from https://pramode.in/2016/10/05/random-bitstream-using-lfsr/
from migen import *
MAX_PERIOD = 50000
def new_val(lfsr):
bit = ((lfsr >> 0) ^ \
(lfsr >> 2) ^ \
(lfsr >> 3) ^ \
(lfsr >> 5)) & 1
@pepijndevos
pepijndevos / patch.py
Created June 12, 2022 20:05
Gowin IDE patcher
#!/usr/bin/python3
import os
import re
import subprocess
import mmap
def patch(filename : str, bytes):
subprocess.run(["cp",filename, filename + '_patched'])
with open(filename + "_patched", "r+b") as f:
@pepijndevos
pepijndevos / nodevoltage.jl
Created December 2, 2020 19:54
Calculate node voltages from a netlist
using LinearAlgebra
@enum Element Resistor Voltage Current
netlist = [
(0, 1, Resistor, 4),
(0, 1, Current, 6),
(0, 2, Resistor, 6),
(0, 3, Resistor, 8),
(1, 2, Resistor, 3),
@uXeBoy
uXeBoy / NES-controller.ino
Last active January 15, 2024 12:41
NES-controller.ino
/* Quick and dirty NES to DMG button driver (originally by Mr.Blinky)
*
* Using digital pins so it can be easily run on any Arduino
* Because DigitalRead and DigitalWrite are pretty slow, no delays are
* required when changing controller pin states and reading in data
*/
//NES button state masks
#define BS_A _BV(7)
#define BS_B _BV(6)
@devdsp
devdsp / GoL.v
Created June 6, 2011 04:53
Conway's Game of Life in Verilog
/*
Conway's Game of Life modeled in Verilog by Adam Thomas / devdsp
*/
/*
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <github.com/devdsp> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return. - Adam