Skip to content

Instantly share code, notes, and snippets.

View lloydjatkinson's full-sized avatar
🌧️
Chilling

Lloyd Atkinson lloydjatkinson

🌧️
Chilling
  • England
  • 17:37 (UTC +01:00)
View GitHub Profile
@alexandrnikitin
alexandrnikitin / AhoCorasickTree.cs
Created April 14, 2017 07:44
Aho-Corasick C# implementation
using System.Collections.Generic;
using System.Linq;
namespace AhoCorasickTree
{
public class AhoCorasickTree
{
internal AhoCorasickTreeNode Root { get; set; }
public AhoCorasickTree(IEnumerable<string> keywords)
@clarkbw
clarkbw / redux-performance-mark.js
Last active February 8, 2024 05:03
A User Timing middleware for redux to create performance markers for dispatched actions
const timing = store => next => action => {
performance.mark(`${action.type}_start`);
let result = next(action);
performance.mark(`${action.type}_end`);
performance.measure(
`${action.type}`,
`${action.type}_start`,
`${action.type}_end`
);
return result;
@TAGC
TAGC / tictactoe.py
Last active July 16, 2017 23:43
Variable sized Tic-Tac-Toe end game detection logic in Python
from itertools import permutations
import math
X = 'X'
O = 'O'
_ = ' '
def inter_value_differences(values):
@mtranggit
mtranggit / .block
Last active October 15, 2018 22:07
Make d3 responsive
license: mit
public class PostActionTransformation<T> : ISpecimenBuilderTransformation
{
private readonly List<ISpecimenCommand> _commands = new List<ISpecimenCommand>();
public ISpecimenBuilder Transform(ISpecimenBuilder builder)
{
return new Postprocessor(
builder,
new CompositeSpecimenCommand(_commands),
new IsAssignableToTypeSpecification(typeof(T)));
anonymous
anonymous / Gb.cs
Created December 20, 2017 08:43
[StructLayout(LayoutKind.Sequential)]
public struct GbColor
{
public byte R;
public byte G;
public byte B;
}
private readonly GbColor[] _framebuffer = new GbColor[160 * 144];
@steven2358
steven2358 / ffmpeg.md
Last active July 13, 2025 16:26
FFmpeg cheat sheet
using System;
using System.Threading.Channels;
using System.Threading.Tasks;
namespace ChannelsAreCool
{
//Disclaimer : I didn't actually run this code so it might not quite work.
//Feel free to complain or ask questions and i'll fix it.
public static class Example
{
@Tewr
Tewr / MappingExtensions.cs
Created March 26, 2019 12:50
Provides object extensions Map and Tap. Like LINQ Select, but for non-collections. int.Parse("5") becomes "5".Map(int.Parse).
public static class MappingExtensions
{
/// <summary>
/// Applies the specified <paramref name="transformation"/> on the <paramref name="source"/>.
/// </summary>
/// <typeparam name="TSource"></typeparam>
/// <typeparam name="T"></typeparam>
/// <param name="source"></param>
/// <param name="transformation"></param>
/// <returns></returns>

Foreward

This document was originally written several years ago. At the time I was working as an execution core verification engineer at Arm. The following points are coloured heavily by working in and around the execution cores of various processors. Apply a pinch of salt; points contain varying degrees of opinion.

It is still my opinion that RISC-V could be much better designed; though I will also say that if I was building a 32 or 64-bit CPU today I'd likely implement the architecture to benefit from the existing tooling.

Mostly based upon the RISC-V ISA spec v2.0. Some updates have been made for v2.2

Original Foreword: Some Opinion

The RISC-V ISA has pursued minimalism to a fault. There is a large emphasis on minimizing instruction count, normalizing encoding, etc. This pursuit of minimalism has resulted in false orthogonalities (such as reusing the same instruction for branches, calls and returns) and a requirement for superfluous instructions which impacts code density both in terms of size and