Skip to content

Instantly share code, notes, and snippets.

View taichi-ishitani's full-sized avatar
:octocat:

Taichi Ishitani taichi-ishitani

:octocat:
View GitHub Profile
@taichi-ishitani
taichi-ishitani / selection_sort.c
Last active October 25, 2016 16:06
選択ソート/Selection Sort
void selection_sort(int values[], int size) {
int i;
int j;
int min_index;
int temp;
for (i = 0;i < (size - 1);i++) {
min_index = i;
for (j = (i + 1);j < size;j++) {
if (values[min_index] > values[j]) {
@taichi-ishitani
taichi-ishitani / binary_search.c
Last active October 26, 2016 03:46
二分検索/Binary Search
int binary_search(int value, int values[], int left_index, int right_index) {
int middle_index = (right_index - left_index) / 2 + left_index;
if (left_index > right_index) {
return -1;
}
else if (value < values[middle_index]) {
return binary_search(value, values, left_index, middle_index - 1);
}
else if (value > values[middle_index]) {
return binary_search(value, values, middle_index + 1, right_index);
module top(
input logic i_clk,
input logic i_rst_n,
input logic [1:0] i_foo,
output logic [1:0] o_bar,
output logic [1:0] o_baz
);
if (1) begin : g_bar
function automatic logic [1:0] f(logic [1:0] v);
return ~v;
@taichi-ishitani
taichi-ishitani / proc_call_on.rb
Created April 13, 2019 04:47
Proc をあるコンテキスト上で実行する
class Proc
def call_on(context, *args, &block)
@__call_on__method__ ||= define_call_on_method
@__call_on__method__.bind(context).call(*args, &block)
end
private
def define_call_on_method
Module.new.module_exec(self) do |body|
@taichi-ishitani
taichi-ishitani / uvm_bug.sv
Created July 9, 2019 14:46
UVM Bug (uvm_sequence_base::kill)
package test_pkg;
timeunit 1ns;
import uvm_pkg::*;
`include "uvm_macros.svh"
class inner_sequence extends uvm_sequence;
task body();
#(1s);
endtask
@taichi-ishitani
taichi-ishitani / load_with_location_info.rb
Created August 20, 2019 07:51
[YAML] load with location info
require 'yaml'
src = <<~YAML
name: taro
age: 4
YAML
class Psych::Nodes::Node
def mapping_key?
@mapping_key
@taichi-ishitani
taichi-ishitani / mapping_marge.yml
Created August 21, 2019 03:32
[YAML] マッピングのマージ
# { foo: 1, bar:2, baz: 3 } になる
<<:
- { foo: 1, bar: 2 }
- baz: 3
@taichi-ishitani
taichi-ishitani / initial_value_assignment.sv
Created October 18, 2019 04:25
logic 変数への初期値代入
module top (
input [1:0] i_a,
input [1:0] i_b,
output [1:0] o_c
);
logic [1:0] c = i_a + i_b;
assign o_c = c;
endmodule
module top (
input logic [1:0] i_a,
input logic [1:0] i_b,
output logic [1:0] o_c
);
function automatic logic [1:0] add();
return i_a + i_b;
endfunction
always_comb begin
interface foo_types;
typedef struct packed {
logic foo;
} foo_struct;
endinterface
module sub (
foo_types types,
input logic i_clk,
input logic i_rst_n,