Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View ryos36's full-sized avatar

Ryos Suzuki ryos36

  • Sinby Corp.
  • Chiba
View GitHub Profile
@ryos36
ryos36 / tk_mutex_cond.h
Created June 16, 2023 02:07
Pthread の mutex_cond を TKernel に移植。tk で始まるがオーソライズされた API ではない。テストが不十分なので broadcast は怪しい。
/* Copyright (C) 2007, 2016 Sinby Corporation. All Rights Reserved. */
#ifndef __LIB_TK_MUTEX_COND_H__
#define __LIB_TK_MUTEX_COND_H__
#include <assert.h>
#include <stdbool.h>
#include "kernel.h"
//------------------------------------------------------------------------
@ryos36
ryos36 / ts2mp4-simple.sh
Created September 1, 2020 02:33
gstreamer による ts から mp4 への変換プログラム。ただし、音声が抜けてしまう。
#!/bin/sh
FORCE_MODE=0
if [ "$1" = "-f" ]; then
FORCE_MODE=1
shift
fi
if [ $# -eq 0 ]; then
echo Usage $0 '<video>.ts'
exit 1
fi
@ryos36
ryos36 / fix_bounce.py
Created March 11, 2019 17:31
Polyphony によるチャタリング除去プログラム
from polyphony import testbench, module, is_worker_running
from polyphony.timing import clksleep, wait_rising, wait_value
from polyphony.io import Port, Queue
from polyphony.typing import bit, bit32
@module
class fix_bounce_contact:
def __init__(self, wait_n, long_press_count_n):
self.wait_n = wait_n
self.long_press_count_n = long_press_count_n
from polyphony import testbench
from polyphony import rule
from polyphony import module
from polyphony.typing import bit, bit8, bit16
from polyphony.io import Queue, Port
from polyphony import is_worker_running
from polyphony.timing import clksleep, wait_value, clkfence
@ryos36
ryos36 / blink.py
Last active December 7, 2018 09:05
LED チカチカ
#[derive(Debug, Copy, Clone)]
#[repr(packed)]
pub struct B {
pub flag1: bool,
pub flag2: bool,
pub flag3: bool,
pub flag4: bool,
pub flag5: bool,
pub flag6: bool,
pub flag7: bool,
@ryos36
ryos36 / sha256_func.py
Last active December 9, 2017 12:39
sha256 with polyphony
from polyphony import testbench, module, is_worker_running
from polyphony import rule
_k = [0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
@ryos36
ryos36 / gist:1611dff6d106fad185891120d3351dc3
Created December 7, 2017 15:13
Polyphony example for Lattice ice40 system-bus
import polyphony
from polyphony import testbench, module, is_worker_running
from polyphony.io import Port, Queue
from polyphony.typing import bit, uint8, uint3, uint4
from polyphony.timing import clksleep, clkfence, wait_rising, wait_falling, wait_value
CONVST_PULSE_CYCLE = 10
CONVERSION_CYCLE = 39
@polyphony.module
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use iEEE.std_logic_arith.all;
use iEEE.std_logic_unsigned."+";
use IEEE.std_logic_textio.all;
library std;
use std.textio.all;