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
/** | |
* @file circular_buffer.h The circular buffer. | |
*/ | |
#ifndef CIRCULAR_BUFFER_H | |
#define CIRCULAR_BUFFER_H | |
/** | |
* @brief The circular buffer class. | |
*/ |
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
#!python | |
from math import pi | |
# The first-order low-pass filter has following transfer function of s-domain | |
# H(s) = a / (s + a). | |
# Its pole is s = −a, and the pole in digital filter will be z = e^−aT | |
# Therefore the H(z) is (1 - e^-aT)*z / ( z - e^-aT ) | |
FREQ_SAMPLING = 50e3 | |
TIME_SAMPLING = 1 / FREQ_SAMPLING |
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
#!python | |
# coding: utf-8 | |
import numpy as np | |
import matplotlib.pyplot as plt | |
dt = 0.1 # The time interval of sampling. | |
# Make input data with some white noise. | |
z = np.arange(1, 100, dt) |
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
#!python | |
# -*- coding: utf-8 -*- | |
import drawsvg as draw | |
# Reference: https://github.com/cduck/drawsvg/blob/master/docs/index.md | |
reg = { | |
'31': 'EN', |
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
#!/bin/sh | |
verible-verilog-format \ | |
--inplace \ | |
--column_limit=200 \ | |
--indentation_spaces=4 \ | |
--line_break_penalty=4 \ | |
--assignment_statement_alignment=align \ | |
--case_items_alignment=align \ | |
--class_member_variable_alignment=align \ | |
--formal_parameters_alignment=align \ |
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
#!python | |
# coding: utf-8 | |
import sys | |
from invoke import task, Program, Collection | |
@task | |
def task1(c): | |
# c.run will invoke a shell context to run the commands. | |
c.run("echo Put your first task command here.") |
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
#!python3 | |
# coding: utf-8 | |
import sys | |
from os import path | |
import tomli as toml | |
from mako.template import Template | |
def main(): | |
if len(sys.argv) != 3: |
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
# Refer to https://stackoverflow.com/questions/48343669/how-to-install-python-packages-over-ssh-port-forwarding. | |
# Login to server via following ssh command. Your computer must have permission to connect to PIP server directly. | |
ssh -R 9999 [email protected] | |
# After login to your server.host.name. Use following command to install proxy package. | |
pip install package_name --proxy socks5h:127.0.0.1:9999 | |
# The apt and yum can work with this tunnel by setting proxy. | |
# Add following line in /etc/yum.conf |
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 numpy as np | |
def linear_regression(x, y): | |
"""The input are x and y for 2D""" | |
assert isinstance(x, np.ndarray) | |
assert isinstance(y, np.ndarray) | |
w = np.sum((y - np.average(y)) * x) / np.sum((x - np.average(x))**2) | |
b = np.average(y) - w * np.average(x) | |
return w, b |
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 parse_verilog_number(s): | |
"""Parse a verilog number literal to the tuple (sign, bits, base, value). | |
sign: 1 for postive, -1 for negative. | |
bits: The bits token in the number literal. | |
base: The base of number(2, 10 or 16). | |
value: The value token. | |
""" | |
base_token = {'b': 2, 'd': 10, 'h': 16} | |
pattern = re.compile(r"""(?P<sign>[\-\+])?(?P<define>\`)?(?P<bits>[\w]+)?\'((?P<base2>[bB])(?P<value2>[01]+)|(?P<base10>[dD])(?P<value10>\d+)|(?P<base16>[hH])(?P<value16>[0-9a-fA-F]+)|(?P<value>\d+))""") | |
m = pattern.match(s) |
NewerOlder