This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from enum import Enum | |
from nmigen import * | |
from nmigen.asserts import * | |
from nmigen.sim import pysim | |
class Opcodes(Enum): | |
NOPO = 0x0 | |
LD = 0x1 | |
LDC = 0x2 | |
AND = 0x3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
#include <stdint.h> | |
#include <sys/stat.h> | |
#include <fcntl.h> | |
#include <unistd.h> | |
#include <sys/io.h> | |
#include <sys/mman.h> | |
#include "elf.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
def main(): | |
input_file = sys.argv[1] | |
output_file = sys.argv[2] | |
with open(input_file, 'rb') as f_in, open(output_file, 'wb') as f_out: | |
decompressed_length = int.from_bytes(f_in.read(4), 'little') | |
bytes_written = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
`default_nettype none | |
module top(input CLK, output PIN_24); | |
wire tx_buf_empty; | |
reg tx_data_ready; | |
reg [7:0] tx_data; | |
uart_tx #( | |
.BAUD_DIVISOR(16000000 / 115200) | |
) uart_tx_inst ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Build with gcc -o bug bug.c | |
// | |
// Prints non-NULL address of y when executed outside of valgrind, and a NULL | |
// (rendered as "(nil)" by printf) when executed inside valgrind. | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <sys/ipc.h> | |
#include <sys/shm.h> | |
#include <sys/stat.h> | |
#include <sys/types.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* !heavily! work in progress */ | |
MEMORY { | |
ram (rwx) : org = 0x00000000, l = 64K | |
user (rx) : org = 0xFFF80000, l = 512K | |
} | |
SECTIONS { | |
.text : { | |
*(.text) | |
*(.text*) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from nmigen import * | |
from nmigen.cli import main | |
class Test: | |
def __init__(self): | |
self.out = Signal(8) | |
def get_fragment(self, platform): | |
data = list(range(10)) | |
arr = Array(data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LAI x (01XX) | |
load accumulator immediate | |
acc = x | |
LAM x (02XX) | |
load accumulator memory | |
acc = mem[x] | |
LAI x (0300) | |
load accumulator memory indirect | |
acc = mem[mem[0]] | |
SAM x (04XX) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def generate_stacks(n): | |
if n == 1: | |
yield (True,) | |
yield (False,) | |
else: | |
for stack in generate_stacks(n - 1): | |
yield stack + (True,) | |
yield stack + (False,) | |
def stack_flip(stack, n): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Sandpile: | |
def __init__(self, size, data=None): | |
self.size = size | |
if data: | |
assert(isinstance(data, list)) | |
assert(len(data) == size) | |
for row in data: | |
assert(isinstance(row, list)) |
NewerOlder