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
/** | |
* The `UIntToOH1` method is found from rocket-chip repo at | |
* https://github.com/ucb-bar/rocket-chip/blob/dfa61bc48709a7733b73d24eb81acc2da227cfd4/src/main/scala/uncore/tilelink2/package.scala#L19 | |
* As it is hard to me to figure out what the abbreviation of OH and OH1 is, | |
* I write this standalone demo in order to find out its semnatic from the pattern output. | |
* | |
* Finally, I find that the `UIntToOH1` method will convert a UInt value to bits of 1 whose length equals to that value. | |
* | |
* To run this demo: | |
* 1. git clone https://github.com/ucb-bar/chisel-template demo |
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
/** | |
* Question: https://www.zhihu.com/question/55234202 | |
* Usage: <proc> <lines> | |
* Example: ./a.out 6 | |
* A | |
* ABA | |
* ABCBA | |
* ABCDCBA | |
* ABCDEDCBA | |
* ABCDEFEDCBA |
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 java.util.ArrayList; | |
import java.util.Scanner; | |
/** | |
* This code generate optimized accept-reject sequence to approach target frame. | |
* Background: Pokemon Sun / Moon Random Number | |
*/ | |
public class JumpFrame { | |
enum Op {Accept, Reject}; |
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
/** | |
* Input sample: | |
* | |
* TableName | |
* (1,样例,example)、(2,样例,example) | |
* ; | |
* EOF | |
* | |
* Output: | |
* insert into TableName values (1, "样例", "example"); |
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
/* | |
* U = { x1, x2, ... , xn } | |
* A, B is subset of U. A and B are disjoint, and SUM(A) > SUM(B). | |
* Ask for the minimum SUM(A) / SUM(B) | |
*/ | |
import java.util.Scanner; | |
public class Foo { | |
public static void main(String[] args) { |
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
# Usage: | |
# ruby course.rb <stu-id> <password> [category] [campus] [host] | |
# | |
# Rerequsities: | |
# # apt-get install ruby | |
# $ gem install rest-client | |
# $ gem install nokogiri | |
# | |
# Note: | |
# if a file called 'wishes' exists, then we only scout the wished |
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
#!/usr/bin/env ruby | |
def StatDump(seq_num) | |
Dir.glob('/proc/*').each do |process| | |
next if not File.directory?(process) | |
pid = process.split('/')[2] | |
next if not pid =~ /\d+/ | |
is_gem5 = false |
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
#!/usr/bin/env ruby | |
result = [] | |
File.read(ARGV[0]).each_line do |line| | |
# Match pattern "XXXXXXXX <function-name>:" | |
# and extract the function name. | |
# Note that all the symbol including '<', '>' | |
# and ':' are literal, except 'function-name', | |
# which is the variable we want. | |
matchData = /(?<=\h{8} <)\w+(?=>:$)/ .match line |
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
# Doxyfile 1.8.11 | |
# This file describes the settings to be used by the documentation system | |
# doxygen (www.doxygen.org) for a project. | |
# | |
# All text after a double hash (##) is considered a comment and is placed in | |
# front of the TAG it is preceding. | |
# | |
# All text after a single hash (#) is considered a comment and will be ignored. | |
# The format is: |
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
reg [7:0] an; | |
always @(posedge CLK100MHZ) begin | |
if (reset) begin | |
an <= 8'b1111_1110; | |
end | |
else begin | |
an <= { an[6:0], an[7] }; | |
end | |
end |