Author |
Message |
angry_troll
Doomed
Joined: 08 Apr 2013 04:04 Posts: 449 Location: 213.247.249.139
|
Для примера: openrisc, страница 36 и далее. тут такого не наблюл...
_________________ привет засранцу лавру :)
|
06 Dec 2016 01:41 |
|
|
Shaos
Admin
Joined: 08 Jan 2003 23:22 Posts: 22716 Location: Silicon Valley
|
|
06 May 2017 20:52 |
|
|
Shaos
Admin
Joined: 08 Jan 2003 23:22 Posts: 22716 Location: Silicon Valley
|
|
08 Apr 2018 17:26 |
|
|
Shaos
Admin
Joined: 08 Jan 2003 23:22 Posts: 22716 Location: Silicon Valley
|
Оказывается у меня есть книжка человека, который в данный момент является CEO SiFive Книжка 90х годов (у меня 3я редакция 1999 года) и купил я её на амазоне в октябре 2011 за $5.33 ( включая доставку : ) Автор в те времена работал в Intel...
|
29 Jul 2018 19:39 |
|
|
Shaos
Admin
Joined: 08 Jan 2003 23:22 Posts: 22716 Location: Silicon Valley
|
SiFive имеет 2 успешные компании по финансированию RISC-V плат на CrowdSupply ( правда у них была цель $1 - в эту цель сложно не попасть ; ) https://www.crowdsupply.com/sifive/hifive1 - ардуино совместимая плата с RISC-V (собрали $104976) https://www.crowdsupply.com/sifive/hifive-unleashed - линукс совместимая плата с RISC-V (собрали $179664) А вот колумбийская OnChip свою компанию по финансированию ихнего RISC-V микроконтроллера на том же сайте провалила: https://www.crowdsupply.com/onchip/open-vони правда хотели собрать $400000 а собрали только $44641 (и не получили, т.к. цель не достигнута)...
|
29 Jul 2018 19:57 |
|
|
Shaos
Admin
Joined: 08 Jan 2003 23:22 Posts: 22716 Location: Silicon Valley
|
кхм - только что получил запрос через Linkedin
|
03 Sep 2018 11:41 |
|
|
Shaos
Admin
Joined: 08 Jan 2003 23:22 Posts: 22716 Location: Silicon Valley
|
вот есть опенсорцный эмулятор RISC-V под лицензией MIT: https://bellard.org/tinyemu/а вот урезанная до RV32I версия (один текстовый файл на полторы тыщи строк): https://gist.github.com/FrankBuss/c974e59826d33e21d7cad54491ab50e8причём которая способна проходить тесты совместимости для RISC-V 32-битной целочисленной подсистемы RV32I: https://github.com/riscv/riscv-complianceнадо чтоли поиграться с этим...
|
18 Nov 2018 17:19 |
|
|
Shaos
Admin
Joined: 08 Jan 2003 23:22 Posts: 22716 Location: Silicon Valley
|
Ставлю на свой 64-битный Debian Linux тулзы для RISC-V (GCC и т.д.) по инструкции отсюда: https://riscv.org/software-tools/risc-v-gnu-compiler-toolchain/P.S. Вот такой конкурс до 26 ноября проводится на самодельную реализацию RISC-V в FPGA: https://riscv.org/2018contest/P.P.S. Там очки набираются в четырёх категориях: - Smallest Microsemi SmartFusion®2 or IGLOO®2 implementation
- Smallest Lattice iCE40 UltraPlus™ implementation
- Highest-performance Microsemi SmartFusion®2 or IGLOO®2 implementation
- Highest-performance Lattice iCE40 UltraPlus™ implementation
И потом суммируются - первые три у кого больше всех очков получают призы (плюс четвёртый приз за креативность): P.P.P.S. Неофициальная инфа по требованиям: https://github.com/micro-FPGA/riscv-contest-2018/wiki/RV32I-Compliance
|
18 Nov 2018 18:20 |
|
|
Shaos
Admin
Joined: 08 Jan 2003 23:22 Posts: 22716 Location: Silicon Valley
|
Как я понял спецификация RISC-V очень запутана - вот например что подытожил на тему прерываний автор урезанного эмулятора 32-битного целочисленного варанта в 1.5 тыщу сишных строк (ссылку на который я привёл чуть выше): https://groups.google.com/a/groups.riscv.org/d/msg/isa-dev/kXgfFqgBv-c/V_midA9GAgAJ | | | | Quote: Chapter 1.5, "Exceptions, Traps, and Interrupts" is a bit better than the last official release, but I'm still missing a global overview how program flow works. By reading both specs carefully, the user level and privileged spec, I think I understand it now, but it wasn't easy for me. I needed both specs, because e.g. in the user level spec the description for ECALL doesn't say that the mpec register is set to the address of the ECALL instruction, this is only written in the privileged spec, where the ECALL description is mostly duplicated.
For reference, I think this is how it works, if I understood it correctly, and which might be a starting point for a general description:
ECALL: raises and exception:
- CSR register cause is set to 8, environment call - CSR register mpec is set to the address of the ECALL instruction - CSR register mtval is set to 0 - PC is loaded with CSR register mtvec
exception, e.g. illegal instruction etc.:
- CSR register cause: depends on the exception - CSR register mpec is set to the address of the instruction that caused the exception - CSR register mtval: depends on the exception, e.g. the instruction opcode for illegal instruction, or the target address for misaligned memory access - PC is loaded with CSR register mtvec
mtime interrupt:
This interrupt is executed before the next normal instruction flow, if the following 3 bits are set: - the global interrupt enable bit: MIE bit in mstatus register - the timer interrupt enable bit: MTIE bit in the CSR register mie - the timer interrupt pending bit: MTIP bit in the CSR register mip
The MTIP bit is set, whenever the CSR register mtimecmp is equal or greater than the CSR register mtime. When the IRQ is raised, the MIE bit is cleared, otherwise the interrupt would be raised in an infinite loop, because it is level triggered, not edge triggered. The MTIP is cleared, when writing to the CSR register mtimecmp. So in the interrupt routine, you have to first write to mtimecmp to clear the MTIP bit, otherwise the interrupt would be raised again after setting the MIE bit and leaving the interrupt. And after this, you have to set the MIE bit again, to re-enable global interrupts.
This happens when a timer interrupt is raised:
- CSR register cause: bit 31 is set to 1, to indicate an interrupt, bits 30 to 0 is set to 7, to indicate a machine timer interrupt. In case you are wondering why "7": Because the machine timer interrupt is signaled with bit 7, MTIP, in the mip register, if I understand this correctly. - CSR register mpec is set to the address of the instruction that is going to be executed on interrupt exit. Note the difference compared to the previous ECALL and exception cases. - CSR register mtval = 0 - MIE bit of CSR register status is cleared - PC = CSR register mtvec
I didn't write all the details about the privileges and the additional complications with PLIC and vectored interrupts, just a first overview (enough for a working RISCV contest implementation of RV32I). Don't know if the spec would be the right place for it, maybe another document with examples would be nice. And it doesn't help, that there is a bit named "MIE", and a CSR register named "mie".
| | | | |
|
18 Nov 2018 20:39 |
|
|
Shaos
Admin
Joined: 08 Jan 2003 23:22 Posts: 22716 Location: Silicon Valley
|
Поставил вариант с Newlib - тесты собираются и работают Автор урезанного эмуля даже дал мне простой пример на попробовать: вот дизассемблированный код: | | | | Code: test1: file format elf32-littleriscv
Disassembly of section .text:
00010054 <_start>: 10054: 000107b7 lui a5,0x10 10058: 07878793 addi a5,a5,120 # 10078 <_start+0x24> 1005c: 04800713 li a4,72 10060: 400026b7 lui a3,0x40002 10064: 00e68023 sb a4,0(a3) # 40002000 <__global_pointer$+0x3fff0778> 10068: 00178793 addi a5,a5,1 1006c: 0007c703 lbu a4,0(a5) 10070: fe071ae3 bnez a4,10064 <_start+0x10> 10074: 00008067 ret
| | | | |
|
18 Nov 2018 23:53 |
|
|
Shaos
Admin
Joined: 08 Jan 2003 23:22 Posts: 22716 Location: Silicon Valley
|
Запустил в этом эмуляторчике RTOS (операционную систему реального времени) Zephyr ( Зефир : ) https://github.com/zephyrproject-rtos/zephyr/Точнее 2 мультитредных примера, необходимых для прохождения на конкурс RISC-V Зефирное ядро прилинковывается прямо к примеру и надо пускать получаемый файл zephyr.elf Проблема в том, что для успешной работы нужен не совсем последний набор исходников: https://github.com/zephyrproject-rtos/zephyr/releases/tag/zephyr-v1.13.0Ну и с последним GCC 8.2.0 от RISC-V оно завелось с полпинка (одну строчку пришлось поправить в одном h-файле): т.к. __riscv__ это макро для старых версий GCC, а теперь это __riscv
|
19 Nov 2018 13:29 |
|
|
Shaos
Admin
Joined: 08 Jan 2003 23:22 Posts: 22716 Location: Silicon Valley
|
Задумал компьютер nedoPC-5 на 32-битном целочисленном RISC-V http://www.nedopc.org/forum/viewtopic.php?f=46&t=19179
|
19 Nov 2018 18:36 |
|
|
Shaos
Admin
Joined: 08 Jan 2003 23:22 Posts: 22716 Location: Silicon Valley
|
Вот таблица опкодов из спецификации v2.1 (как видно подсистема RV32I умещается в одну первую страницу): Из полезного есть ещё RV32E (embedded с уменьшенным количеством регистров) и RV32C (компактное представление команд в 16 битах)
|
19 Nov 2018 22:24 |
|
|
Shaos
Admin
Joined: 08 Jan 2003 23:22 Posts: 22716 Location: Silicon Valley
|
В этом эмуляторчике по ходу кроме базового набора инструкций из RV32I есть умножение-деление (RV32M) и атомарные операции (RV32A) - сделаю макрос, чтобы их отключить Текущее состояние эмуля: https://gitlab.com/nedopc/npc5/blob/master/emu-rv32i.cP.S. А ещё у RISC-V есть инструкции привелигированного режима (в микро-эмуле поддержаны все, кроме URET):
|
20 Nov 2018 13:33 |
|
|
Shaos
Admin
Joined: 08 Jan 2003 23:22 Posts: 22716 Location: Silicon Valley
|
RISC-V имеет очень хитрый декод длины инструкции: Как можно видеть в табличке чуть выше, все инструкции там представленные имеют в коде 2 младших бита "1" (если там не 11, то это - короткая инструкция из набора RV32C, который мы пока не рассматриваем) Тип инструкции можно определить по младшему байту (который в little-endian памяти идёт первым в слове): Правда чтобы например отличить ADD и SUB от остальных операторов (OP) придётся взять 3 бита из второго байта, а чтобы отличить ADD и SUB друг от друга ещё и битик из старшего байта слова инструкции нужен P.S. На картинках я подсветил опкоды, которые необходимы для RV32I
|
20 Nov 2018 14:09 |
|
|