Skip to content

Instantly share code, notes, and snippets.

@BeMg
BeMg / spike.md
Last active August 15, 2024 04:42
spike tutorial

Spike tutorial

前言

spike 是 risc-v 的模擬器,讓 risc-v 的指令可以跑在任意的機器上,而不需要處理器有支援。本文主要在於紀錄如何在spike原有的基礎上,加上新的指令,以及如何測試新的指令。

大致上的 spike 流程為

c source code -> riscv-gcc -> riscv object code -> spike -> pk -> run on cpu

@BeMg
BeMg / opcodes
Created July 17, 2018 11:34
backup
# format of a line in this file:
# <instruction name> <args> <opcode>
#
# <opcode> is given by specifying one or more range/value pairs:
# hi..lo=value or bit=value or arg=value (e.g. 6..2=0x45 10=1 rd=0)
#
# <args> is one of rd, rs1, rs2, rs3, imm20, imm12, imm12lo, imm12hi,
# shamtw, shamt, rm
beq bimm12hi rs1 rs2 bimm12lo 14..12=0 6..2=0x18 1..0=3
@BeMg
BeMg / crawl.py
Created June 12, 2018 06:24
crawl
import asyncio
from pyppeteer import launch
import bs4
import queue
import sqlite3
import re
async def get(link):

計算機結構 作業三

  • 姓名:陳丕祐
  • 學號:403410061

題目

3.5

Reorder the instructions to improve performance of the code in Figure 3.48. Assume the two-pipe machine in Exercise 3.3 and that the out-of-order completion issues of Exercise 3.4 have been dealt with successfully. Just worry about observing true data dependences and functional unit latencies for now. How many cycles does your reordered code take?

@BeMg
BeMg / aca_ch2_cs2.c
Created April 14, 2018 11:02
computer architecture a quantitative approach source code 2.29 run in the linux by change get_seconds function
#include <stdio.h>
#include <time.h>
#define ARRAY_MIN (1024) /* 1/4 smallest cache */
#define ARRAY_MAX (4096*4096) /* 1/4 largest cache */
int x[ARRAY_MAX]; /* array going to stride through */
// double get_seconds() { /* routine to read time in seconds */
// __time64_t ltime;
// _time64( &ltime );
A435
A394
A401
A430
A399
A437
A244
A443
A434
G85
@BeMg
BeMg / main.py
Created April 11, 2018 06:31
從 好讀網站 下載 所有epub
import requests
import bs4
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import os
import re
def getsoup(url):
r = requests.get(url)
s = bs4.BeautifulSoup(r.text, 'lxml')
@BeMg
BeMg / term.txt
Created April 9, 2018 00:53
chinese term fetch from moedict
This file has been truncated, but you can view the full file.
{[8e40]}
{[8e41]}
{[8e43]}
{[8e44]}
{[8e45]}
{[8e46]}
{[8e48]}
{[8e4f]}
{[8e53]}
{[8e54]}
@BeMg
BeMg / 2dgus.m
Created January 4, 2018 02:21
2dgussian
function [y] = gaussian(x, y, mu, sigma)
y = (1/(2*pi*sigma^2))*exp(-(((x-mu).^2+(y-mu).^2)/(2*sigma^2)));
end
@BeMg
BeMg / 2d
Created December 17, 2017 10:06
CV Hw3 input data
[ 554.369 163.897;
520.323 176.470;
223.503 178.626;
539.106 253.656;
562.979 303.278;
558.897 309.487;
605.067 351.343;
516.435 167.624;
594.044 236.724;
545.960 253.500;