spike 是 risc-v 的模擬器,讓 risc-v 的指令可以跑在任意的機器上,而不需要處理器有支援。本文主要在於紀錄如何在spike原有的基礎上,加上新的指令,以及如何測試新的指令。
大致上的 spike 流程為
c source code -> riscv-gcc -> riscv object code -> spike -> pk -> run on cpu
| # 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 |
| import asyncio | |
| from pyppeteer import launch | |
| import bs4 | |
| import queue | |
| import sqlite3 | |
| import re | |
| async def get(link): |
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?
| #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( <ime ); |
| A435 | |
| A394 | |
| A401 | |
| A430 | |
| A399 | |
| A437 | |
| A244 | |
| A443 | |
| A434 | |
| G85 |
| 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') |
| {[8e40]} | |
| {[8e41]} | |
| {[8e43]} | |
| {[8e44]} | |
| {[8e45]} | |
| {[8e46]} | |
| {[8e48]} | |
| {[8e4f]} | |
| {[8e53]} | |
| {[8e54]} |
| function [y] = gaussian(x, y, mu, sigma) | |
| y = (1/(2*pi*sigma^2))*exp(-(((x-mu).^2+(y-mu).^2)/(2*sigma^2))); | |
| end |
| [ 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; |