Skip to content

Instantly share code, notes, and snippets.

View avesus's full-sized avatar
🎯
Focusing

Brian Cannard avesus

🎯
Focusing
View GitHub Profile
@avesus
avesus / old-testbench.v
Last active May 10, 2021 22:52
Working reprogrammer
`timescale 1ns / 1ps
module testbench ();
endmodule
/*
module testbench2 ();
reg GCLK100 = 1'b0;
wire ETH_MDC;
@avesus
avesus / stylus-detection-methods.js
Last active January 26, 2021 08:23
Stylus Detection
// Apple:
var body = document.getElementByTagName('body')
body.addEventListener('touchstart', function(evt){
// should be either "stylus" or "direct"
console.log(evt.touches[0].touchType)
})
// Chrome & Edge:
if (window.PointerEvent) {
// Pointer events are supported.
@avesus
avesus / fold.ml
Created October 15, 2020 16:31 — forked from keleshev/fold.ml
let (=>) left right = print_char (if left = right then '.' else 'F')
open Printf
let id x = x
let const x = fun _ -> x
let sum = List.fold_left (+) 0
let (>>) f g x = g (f x)
let () =
@avesus
avesus / clocked-fsm-in-fpga.circ
Created February 25, 2020 16:02
Logisim circuit clocked FSM in FPGA
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project source="2.7.1" version="1.0">
This file is intended to be loaded by Logisim (http://www.cburch.com/logisim/).
<lib desc="#Wiring" name="0"/>
<lib desc="#Gates" name="1"/>
<lib desc="#Plexers" name="2"/>
<lib desc="#Arithmetic" name="3"/>
<lib desc="#Memory" name="4">
<tool name="ROM">
@avesus
avesus / icestick.pcf
Last active February 10, 2020 16:04
icestick
# full iCEstick pinout:
# http://www.pighixxx.com/test/portfolio-items/icestick/
set_io CLK_pad 21
set_io FT2232H_GPIOL2_pad 1
set_io FT2232H_GPIOL1_pad 2
set_io FT2232H_GPIOL0_pad 3
set_io FT2232H_TMS_CS_pad 4
set_io FT2232H_TDO_DI_pad 7
{"nodes":[{"x":462,"y":465,"text":"reset_btn_pressed","isAcceptState":false},{"x":462,"y":743,"text":"reset_btn_released","isAcceptState":false},{"x":1537,"y":112,"text":"powered_on","isAcceptState":false},{"x":1555,"y":325,"text":"resetting","isAcceptState":false},{"x":1738,"y":582,"text":"clearing_registers","isAcceptState":false},{"x":2210,"y":590,"text":"select_random","isAcceptState":false},{"x":1231,"y":582,"text":"not_resetting","isAcceptState":false},{"x":2286,"y":325,"text":"\"playing\"","isAcceptState":false},{"x":3171,"y":248,"text":"lcd_rdy_scrn","isAcceptState":false},{"x":3217,"y":1314,"text":"led_green_on","isAcceptState":false},{"x":3502,"y":1530,"text":"LED_strip","isAcceptState":false},{"x":3243,"y":1897,"text":"bad_sound","isAcceptState":false},{"x":3381,"y":94,"text":"lcd_off","isAcceptState":false},{"x":3217,"y":1517,"text":"led_green_off","isAcceptState":false},{"x":3489,"y":1819,"text":"no_sound","isAcceptState":false},{"x":3429,"y":622,"text":"lcd_make_selections","isAcceptState":false
@avesus
avesus / machine.js
Last active January 4, 2020 21:53
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@avesus
avesus / experiment.js
Last active December 8, 2019 18:15
Experimental Statechart
const deviceMachine = Machine({
id: 'device',
initial: 'powered_off',
states: {
powered_on: {
type: 'parallel',
on: {
@avesus
avesus / bit_bit_jump.cpp
Created November 19, 2019 15:08
BitBitJump interpreter in 12 bit RAM
# include <stdio.h>
bool memory[12] = {
0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0,
// 0 1 0 1 0 1 0 1 0 1 0 1
// 0 0 1 1 0 0 1 1 0 0 1 1
// 0 0 0 0 1 1 1 1 0 0 0 0
// 0 0 0 0 0 0 0 0 1 1 1 1
};
bool current_instruction[12] = { 0 };
@avesus
avesus / fold.txt
Created September 9, 2019 22:23
Fold
https://en.wikipedia.org/wiki/Fold_(higher-order_function)#Folds_as_structural_transformations