Skip to content

Instantly share code, notes, and snippets.

@stone3311
stone3311 / alu.vhd
Last active February 19, 2017 12:01
A simple 4-bit processor, written in VHDL, moved to https://github.com/stone3311/f4001
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
ENTITY alu IS
PORT (
opcode : IN std_logic_vector (7 DOWNTO 0);
in_0, in_1 : IN std_logic_vector (3 DOWNTO 0);
output : OUT std_logic_vector (3 DOWNTO 0);
equal_zero : OUT std_logic;
@stone3311
stone3311 / framebuffer_demo.c
Created July 4, 2016 13:25
This is a demo for the Nintendo DS framebuffer which uses the libnds library.
//---------------------------------------------------------------------------------
// Framebuffer demo for Nintendo DS, using the libnds library
//---------------------------------------------------------------------------------
#include <nds.h>
void framebufferDemoDrawPattern() {
int color = 0;
for (int pixelPosition = 0; pixelPosition < SCREEN_HEIGHT*SCREEN_WIDTH; pixelPosition++) {
VRAM_A[pixelPosition] = RGB15(color, color, color);
@stone3311
stone3311 / mpi-primes.c
Created May 1, 2016 20:35
This is a program which calculates primes using MPI.
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <mpi.h>
#define PRIME_MAX 1000000
#define SEND_CHUNK_SIZE 10000
#define SAVE_CHUNK_SIZE 1000
@stone3311
stone3311 / intvalue.swift
Created February 12, 2016 21:12
This is a Bool extension which adds a "intValue" property
extension Bool {
var intValue: Int {
if (self) {
return 1;
} else {
return 0;
}
}
}
@stone3311
stone3311 / binsearch.swift
Created December 8, 2015 17:02
This is a simple binary search algorithm implemented in Swift 2
func binarySearch(list: [Int], value: Int) -> Int {
let count = list.count
var min: Int = 0
var max: Int = count
var mid: Int = Int(round(Double(max / 2)))
while(list[mid] != value) {
if (list[mid] > value) {
max = mid
@stone3311
stone3311 / board.swift
Created October 10, 2015 20:49
This is a simple Swift class representing a board
import Foundation
class Board {
// Board is quadratic
var boardSize: Int = 0
// The raw array
private var data: [[Int]] = []