Skip to content

Instantly share code, notes, and snippets.

View pcornier's full-sized avatar

Pierco pcornier

View GitHub Profile
@pcornier
pcornier / package.json
Last active January 11, 2023 13:41
debug simple JS file with GTKWave
{
"dependencies": {
"escodegen": "^2.0.0",
"esprima": "^4.0.1",
"estraverse": "^5.3.0",
"minimist": "^1.2.7"
}
}
@pcornier
pcornier / info.md
Last active September 22, 2022 08:34
Quartus - Pocket - WSL2

Docker + WSL2 + VcXsrv

compile from WSL2:

docker run -it --rm -v ~/FPGA/_Pocket/core-template/src/fpga:/build raetro/quartus:pocket quartus_sh --flow compile ap_core.qpf

run Quartus GUI:

docker run -it --rm -v ~/FPGA/_Pocket/core-template/src/fpga:/build -e DISPLAY="$(netsh.exe interface ipv4 show addresses Wi-Fi | head -n 4 | grep -oP [0-9.]+)":0 raetro/quartus:pocket quartus
@pcornier
pcornier / gist:2da9976a9d5603f717e384a88ff30fd5
Last active July 13, 2022 09:30
yosys/ghdl -> verilog (VHDL to Verilog with Yosys & GHDL)
# make sure it's python 2.7
sudo update-alternatives --config python
# build ghdl
sudo apt install -y git make gnat zlib1g-dev
git clone https://github.com/ghdl/ghdl
cd ghdl
./configure --prefix=/usr/local
make
sudo make install
@pcornier
pcornier / futoshiki.js
Last active April 19, 2021 07:48
Futoshiki
// A basic Futoshiki prototype
let size = 5 // decrease for easier games
let width = 300
let height = 300
let padding = width*0.03
let cellwidth = (width/size)-padding*2;
let cellheight = (height/size)-padding*2
let hv = 4 // vertical helpers
let hh = 4 // horizontal helpers
@pcornier
pcornier / gameEngine.js
Last active November 12, 2021 13:10
A minimal Javascript game engine that has an ECS, a state manager and a global bus event system in 30 lines
const Bus = () => {
let listeners = {}
return {
register: (event, cb) => {
listeners[event] = listeners[event] || []
listeners[event].push(cb)
},
emit: (event, ...payload) => {
listeners[event].forEach(cb => cb(...payload))
}
@pcornier
pcornier / Dockerfile
Last active July 21, 2021 09:04
Dockerfile for compiling the Android version of TIC-80
FROM ubuntu:latest
WORKDIR /home/root
RUN apt update
RUN apt install git wget unzip apt-utils -y
RUN apt-get install -y locales
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
dpkg-reconfigure --frontend=noninteractive locales && \
@pcornier
pcornier / test.lua
Created July 22, 2019 09:16
LUA FFI byte union struct
local ffi = require 'ffi'
local ct = [[
union {
struct {
uint8_t nlow:4;
uint8_t nhigh:4;
};
struct {
@pcornier
pcornier / dump.py
Created February 8, 2019 13:14
Signals in jupyter notebook
from IPython.display import HTML
from Verilog_VCD import Verilog_VCD as vcd
dump = vcd.parse_vcd('./dump.vcd')
# make some signals more readable
resolvers = {
'ir': lambda v: opc._fields[int(v,2)] if len(opc)>=int(v,2) else str(hex(int(v,2))),
'cyc': lambda v: (['F1','F2','D','E','M1','M2'][int(v,2)],['#faa','#faa','#aaf','#faf','#0f0','#0f0'][int(v,2)])
}
@pcornier
pcornier / fix.py
Last active January 29, 2019 08:57
Jupyter + nbwavedrom, JS error
# MyHDL + MyHDLPeek + NBWaveDrom
# replace the last <script> tag with a <style onload="">
# vim $PREFIX/lib/python3.7/site-packages/nbwavedrom/__init__.py
def _draw_wavedrom_javascript(data, width):
style = ""
if width != None:
style = ' style="width: ' + str(int(width)) + 'px'
htmldata = '<script>' + open(_get_js_path('wavedromskin.js')).read() + '</script>'
htmldata += '<script>' + open(_get_js_path('wavedrom.min.js')).read() + '</script>'
@pcornier
pcornier / fix.py
Created January 29, 2019 08:54
Jupyter + nbwavedrom JS error
# MyHDL + MyHDLPeek + NBWaveDrom
# replace the last htmldata += ... line by a <style onload>
def _draw_wavedrom_javascript(data, width):
style = ""
if width != None:
style = ' style="width: ' + str(int(width)) + 'px'
htmldata = '<script>' + open(_get_js_path('wavedromskin.js')).read() + '</script>'
htmldata += '<script>' + open(_get_js_path('wavedrom.min.js')).read() + '</script>'
htmldata += '<div' + style + '><script type="WaveDrom">' + data + '</script></div>'