Skip to content

Instantly share code, notes, and snippets.

@HungMingWu
HungMingWu / Modified V3WidthSel
Last active July 5, 2022 06:34
Verilog example
logic [32:0] des__DOT__out0;
assign des__DOT__out0[32:1] = {des__DOT__u0__DOT__S[17], {des__DOT__u0__DOT__S[26], {des__DOT__u0__DOT__S[13], {des__DOT__u0__DOT__S[12], {des__DOT__u0__DOT__S[4], {des__DOT__u0__DOT__S[21], {des__DOT__u0__DOT__S[5], {des__DOT__u0__DOT__S[16], {1'h0, {des__DOT__u0__DOT__S[18], {des__DOT__u0__DOT__S[10], {des__DOT__u0__DOT__S[7], {des__DOT__u0__DOT__S[28], {des__DOT__u0__DOT__S[15], {des__DOT__u0__DOT__S[2], {des__DOT__u0__DOT__S[23], {des__DOT__u0__DOT__S[31], {des__DOT__u0__DOT__S[25], {des__DOT__u0__DOT__S[9], {des__DOT__u0__DOT__S[19], {des__DOT__u0__DOT__S[1], {des__DOT__u0__DOT__S[6], {des__DOT__u0__DOT__S[30], {des__DOT__u0__DOT__S[24], {des__DOT__u0__DOT__S[14], {des__DOT__u0__DOT__S[20], {des__DOT__u0__DOT__S[3], {des__DOT__u0__DOT__S[27], {des__DOT__u0__DOT__S[11], {des__DOT__u0__DOT__S[22], {des__DOT__u0__DOT__S[29], des__DOT__u0__DOT__S[8]}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}};
@HungMingWu
HungMingWu / Makefile
Last active January 15, 2020 07:23
Coroutine Test
all:
clang coro.cpp -std=c++2a -stdlib=libc++ -lc++ -fcoroutines-ts -o coro
clang coro_v2.cpp -std=c++2a -stdlib=libc++ -lc++ -fcoroutines-ts -o coro_v2
@HungMingWu
HungMingWu / Allocator.h
Last active May 2, 2019 14:52
A workable C++11 Allocator
#pragma once
#include <iostream>
#include <atomic>
#include <memory>
namespace my {
std::atomic_int g_memory_used{ 0 };
template <typename T>
@HungMingWu
HungMingWu / ver3.cpp
Last active February 21, 2019 07:13
Write my own custom asio async function
#include <boost/system/error_code.hpp>
#include <boost/asio/async_result.hpp>
#include <boost/asio/detail/handler_type_requirements.hpp>
#include <boost/asio/coroutine.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/streambuf.hpp>
#include <boost/optional.hpp>
#include <boost/asio/io_context_strand.hpp>
#include <boost/asio/bind_executor.hpp>
@HungMingWu
HungMingWu / ver1.cpp
Created February 20, 2019 08:05
Write my own custom asio async function
#include <boost/system/error_code.hpp>
#include <boost/asio/async_result.hpp>
#include <boost/asio/detail/handler_type_requirements.hpp>
template<
class ReadHandler>
BOOST_ASIO_INITFN_RESULT_TYPE(
ReadHandler, void(boost::system::error_code, std::size_t))
async_read(ReadHandler&& handler)
{
@HungMingWu
HungMingWu / enumerate.cpp
Created November 26, 2018 05:49
enumerate in C++17
#include <tuple>
template <typename T,
typename TIter = decltype(std::begin(std::declval<T>())),
typename = decltype(std::end(std::declval<T>()))>
constexpr auto enumerate(T && iterable)
{
struct iterator
{
size_t i;
@HungMingWu
HungMingWu / test1.cpp
Last active November 2, 2018 09:57
Uncomplet C++ ASIO Example
#include <iostream>
#include <sstream>
#include <functional>
#include <boost/optional.hpp>
#include <boost/asio/ts/internet.hpp>
#include <boost/asio/ts/buffer.hpp>
#include <boost/asio.hpp>
// #define NETWORK_TS_ENABLED
scons arch=arm64-v8a extra_cxx_flags="-fPIC" benchmark_tests=0 validation_tests=0 opencl=1 embed_kernels=1 neon=1
./b2 link=static cxxflags=-fPIC --with-filesystem --with-test --with-log --with-program_options
./configure --host=arm-linux CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ --with-protoc=/usr/local/bin/protoc --prefix=/usr/local/arm_proto
CXX=aarch64-linux-gnu-g++ cmake -DARMCOMPUTE_ROOT=/ComputeLibrary -DARMCOMPUTE_BUILD_DIR=/ComputeLibrary/build -DBOOST_ROOT=/boost_1_64_0 -DTF_GENERATED_SOURCES=/usr/local -DBUILD_TF_PARSER=1 -DPROTOBUF_ROOT=/usr/local/arm_proto -DARMCOMPUTENEON=1 -DARMCOMPUTECL=1 ..
@HungMingWu
HungMingWu / Tensorflow-example.js
Created April 30, 2018 07:01
Minimal Tensorflow-JS Example
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]"> </script>
<script>
const model = tf.sequential();
model.add(tf.layers.dense({ units: 1, inputShape: [1] }));
model.compile({ loss: 'meanSquaredError', optimizer: 'sgd' });
const xs = tf.tensor2d([1, 2, 3, 4], [4, 1]);
#include <type_traits>
#include <iostream>
#include <experimental/coroutine>
template<typename T>
struct coreturn {
struct promise;
friend struct promise;
using handle_type = std::experimental::coroutine_handle<promise>;
coreturn(const coreturn &) = delete;