Skip to content

Instantly share code, notes, and snippets.

View eugeneia's full-sized avatar

Max Rottenkolber eugeneia

View GitHub Profile
@eugeneia
eugeneia / ring.v
Created November 17, 2020 12:11
Four 32-bit element ring buffer in Verilog
// Four 32-bit element ring buffer
// https://www.snellman.net/blog/archive/2016-12-13-ring-buffers/
module ring
( input clk,
input push, input pop,
output full, output empty,
input [31:0] in, output [31:0] out );
reg [2:0] read;
reg [2:0] write;
diff --git a/src/lj_vm.c b/src/lj_vm.c
index 9c3843c3..c02b8764 100644
--- a/src/lj_vm.c
+++ b/src/lj_vm.c
@@ -500,6 +500,7 @@ void execute(lua_State *L) {
if (vm_return(L, BASE[-1].u64, resultofs, nresults)) return;
}
break;
+ default: assert(0 && "INVALID BYTECODE");
}
-- Observation: the natural push loop is slow at dropping packets. When a
-- packet doesn’t follow the happy path (either because it doesn’t meet the
-- test condition, or because the output link is full), the loop head for the
-- happy path is “replayed” for every “non-happy” packet because of the
-- side-traces created for error situations.
function A:push ()
local input, output = self.input.input, self.output.output
while not link.empty(input) do
local p = link.receive(input)
# Run like this:
# nix-build /path/to/this/directory
# ... and the files are produced in ./result/bin/snabb
{ pkgs ? (import <nixpkgs> {}), source ? ./., version ? "dev" }:
with pkgs;
stdenv.mkDerivation rec {
name = "athens-${version}";
#! /usr/bin/env nix-shell
#! nix-shell -i sh -p ccl
exec ccl --load ~/etc/httpd0/start.lisp
# Run like this:
# nix-build /path/to/this/directory
# ... and the files are produced in ./result/bin/snabb
{ pkgs ? (import <nixpkgs> {})
, source ? ./.
, version ? "dev"
}:
with pkgs;
{ config, pkgs, lib, ... }:
# allows sudo in chroots by introducing some impurities
# has to be available on all servers for builds to always have those paths available inside chroot
with pkgs;
let
# use sudo without pam (eaiser in chroots)
sudoChroot = sudo.overrideDerivation (super: {
$ sudo ./snabb snsh -i
Snabb> =memory
table: 0x41a8dce0
Snabb> S = require("syscall")
Snabb> h = memory.allocate_huge_page(64, true)
Error in core/main.lua:28: ftruncate
Snabb> h = memory.allocate_huge_page(memory.get_huge_page_size(), true)
Snabb> =h
cdata<void *>: 0x500024400000
Snabb>p = S.mmap(0x500024400000, 64, 'read, write', 'private, anonymous, hugetlb')
;;;; Operations and definitions for Cantor and Dedekind's set theory.
(defpackage bachelor-cs.set-theory
(:use :cl)
(:export :Ø :∈ :⊆ :power :size :∪ :∩ :diff :Δ :× ))
(in-package :bachelor-cs.set-theory)
(defvar Ø ()
"Empty set Ø")
#!snabb snsh
local intel_mp = require('apps.intel_mp.intel_mp')
local c = config.new()
config.app(c, "nic0", intel_mp.Intel, { pciaddr = main.parameters[1] })
config.app(c, "nic1", intel_mp.Intel, { pciaddr = main.parameters[2] })
config.link(c, "nic0.output -> nic1.input")
config.link(c, "nic1.output -> nic0.input")
engine.log = true
engine.configure(c)