Skip to content

Instantly share code, notes, and snippets.

// A round-robin priority arbiter for valid/ready signaling using carry chain logic.
module arbiter#(parameter N = 2)
(
input wire clk,
input wire [N-1:0] s_valid,
output wire [N-1:0] s_ready,
output wire m_valid,
input wire m_ready
);

From this paper: http://fpgacpu.ca/fpga/hdl/Tumbush%20DVCon%2005.pdf

  1. If any operand in an operation is unsigned the entire operation is unsigned.
  2. Investigate fully all "signed to unsigned conversion occurs" synthesis warnings. These point to incorrect functionality.
  3. All signed operands will be sign-extended to match the size of the largest signed operand.
  4. Type casting using $unsigned will make the operation unsigned. The operand will be extended with 0’s if necessary.
  5. Type casting using $signed makes the operand signed. The operand will be sign-extended with 1's if necessary. Pad the operand with a single 0 bit before the cast if this is not desired.
  6. Expression type depends only on the operands or operation; it does not depend on the LHS of the expression.

Additional points based on feedback from Owen Shepherd:

@toolness
toolness / adventures-in-python-core-dumping.md
Last active January 9, 2024 11:53
Adventures in Python Core Dumping

Adventures in Python Core Dumping

After watching Bryan Cantrill's presentation on [Running Aground: Debugging Docker in Production][aground] I got all excited (and strangely nostalgic) about the possibility of core-dumping server-side Python apps whenever they go awry. This would theoretically allow me to fully inspect the state of the program at the point it exploded, rather than relying solely on the information of a stack trace.

@subfuzion
subfuzion / tracing-with-pegjs.md
Last active March 6, 2021 12:56
Tracing with peg.js

PEG.js is a simple parser generator for JavaScript that produces fast parsers with excellent error reporting. You can use it to process complex data or computer languages and build transformers, interpreters, compilers and other tools easily.

PEG.js offers tracing support to help analyze parser issues with a grammar. The feature is very helpful, but it's not available yet on the version that's published to npm, it's not well-advertised, and not well-documented. This gist explains how to take advantage of PEG.js tracing support.

When you generate your parser, make sure you supply the trace option set to true. If using gulp, do something like this:

var peg = require('gulp-peg');

var paths = {
@remy
remy / weekend-commits.js
Last active January 14, 2020 08:09
Run this in the console of your github.com/<user> page (i.e. http://github.com/remy) and see how many weekends you were in front of a computer and committing code instead of taking a break.
$.getJSON('https://github.com/users/' + location.pathname.replace(/\//g, '') + '/contributions_calendar_data', weekendWork);
function weekendWork(contribs) {
var inwe = false, streak = 0, highest = 0, total = 0, possible = 0;
contribs.forEach(function (c) {
var d = new Date(c[0]).getDay();
if (d === 6) {
inwe = true;
} else if (d === 0 && inwe) {
possible++;
if (c[1] !== 0) {