Skip to content

Instantly share code, notes, and snippets.

@ajgappmark
ajgappmark / top.v
Created October 19, 2026 15:15
bcd_to_7seg_vec
module top (
input wire [3:0] sw, // sw[3]=A, sw[2]=B, sw[1]=C, sw[0]=D
output wire [7:0] seven, // seven[0..6] = segments a..g, seven[7] = DP
output wire [3:0] segment // Digit select enable
);
wire [6:0] seg_bus;
// Instantiate BCD-to-7-Segment Decoder
bcd_to_7seg_vec u_bcd (
@ajgappmark
ajgappmark / top.v
Created October 19, 2026 14:23
4x1 Mux Behavioral Description
module top (
input wire [3:0] btn, // Data inputs: btn[0]..btn[3]
input wire [1:0] sw, // Select inputs: sw[0] = S0, sw[1] = S1
output wire [7:0] led // Active-high output LED: led[0]
);
// Buttons with PULL_MODE=UP read 0 when pressed and 1 when unpressed.
// Inverting 'btn' converts the active-low button press to logic 1,
// so pressing the selected button turns the active-high LED ON (1 = ON).
wire [3:0] data_in = ~btn;
module top (
input wire [3:0] sw, // sw[0]=A, sw[1]=B, sw[2]=C, sw[3]=D
output wire [7:0] led, // led[0]=F, led[1]=G, led[7:2]=1
output wire [7:0] seven, // 7-segment segment signals (driven to 0)
output wire [3:0] segment // 7-segment digit select signals (driven to 0)
);
// Instantiate the gate-level circuit
mano_circuit u_mano (
.A(sw[0]), // Pin 73
module mano_circuit (
input wire [3:0] sw, // sw[0]=A, sw[1]=B, sw[2]=C, sw[3]=D
output wire [1:0] led // led[0]=F, led[1]=G
);
// Map inputs for schematic clarity
wire A = sw[0];
wire B = sw[1];
wire C = sw[2];
wire D = sw[3];
// ==============================================================================
// Tang Nano 9K Physical Constraints File (tangnano9k.cst)
// ==============================================================================
// --- Clock Input ---
IO_LOC "clk" 52;
IO_PORT "clk" PULL_MODE=UP;
// --- Push Buttons besides USB Port ---
IO_LOC "key" 3; // button S2
@ajgappmark
ajgappmark / Makefile
Created October 18, 2026 01:55
tangnano9k Makefile
# ==============================================================================
# Reusable Gowin FPGA Makefile Template (Tang Nano Series)
# ==============================================================================
# Project Configuration
PROJECT ?= counter
TOP_MODULE ?= $(PROJECT)
VERILOG_SRCS ?= $(PROJECT).v
CST_FILE ?= tangnano9k.cst
@ajgappmark
ajgappmark / .git_aliases
Created September 10, 2026 12:53 — forked from rappleg/.git_aliases
Git Aliases
alias vig='vi $HOME/scripts/bash/.git_aliases'
# GIT aliases
alias st='git status --short'
alias rb='git rebase -p'
alias rbi='git rebase -p --interactive'
alias rbm='git rebase -p master'
alias gcp='git cherry-pick'
alias stash='git stash'
alias pop='git stash pop'
@ajgappmark
ajgappmark / castanet.sh
Created January 20, 2026 08:02 — forked from interfect/castanet.sh
Set up a Chromecast from a Linux PC, without an Android or iOS mobile device and without Google Home
#!/usr/bin/env bash
# castanet.sh: Script to connect a chromecast to a WiFi network.
#
# Allows you to put your Chromecast on WiFi and do Chromecast initial setup
# without using the Google Home app at all, just using a normal Linux computer.
#
# You do need your Chromecast to be on Ethernet, or (untested) to join its setup WiFi
# network with your PC, and you also need to find out its IP yourself with e.g.
# Wireshark.
//C++ copy files
#include <fstream>
std::ifstream src("from.ogv", std::ios::binary);
std::ofstream dst("to.ogv", std::ios::binary | std::ios::trunc);
dst << src.rdbuf();
/*
the one-liner:
std::ofstream(dest) << std::ifstream(src).rdbuf();
@ajgappmark
ajgappmark / MAC-by-Vendor.txt
Created September 14, 2025 06:58 — forked from NullArray/MAC-by-Vendor.txt
List of valid MAC adresses sorted by vendor
Misc MACs:
Num MAC Vendor
--- --- ------
0000 - 00:00:00 - XEROX CORPORATION
0001 - 00:00:01 - XEROX CORPORATION
0002 - 00:00:02 - XEROX CORPORATION
0003 - 00:00:03 - XEROX CORPORATION
0004 - 00:00:04 - XEROX CORPORATION
0005 - 00:00:05 - XEROX CORPORATION
0006 - 00:00:06 - XEROX CORPORATION