nedoPC.org

Electronics hobbyists community established in 2002
Atom Feed | View unanswered posts | View active topics It is currently 19 Mar 2024 04:29



Reply to topic  [ 84 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next
RISC-V 
Author Message
Doomed

Joined: 08 Apr 2013 04:04
Posts: 449
Location: 213.247.249.139
Reply with quote
Для примера: openrisc, страница 36 и далее.

aav8 wrote:
погуглить "riscv-spec-v2.1.pdf"

тут такого не наблюл...

_________________
привет засранцу лавру :)


06 Dec 2016 01:41
Profile
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22383
Location: Silicon Valley
Reply with quote
Уже чипы вроде как доступны:

http://www.computerworld.com.au/article/618724/open-source-chip-mimics-linux-path-take-closed-x86-arm-cpus/

_________________
:dj: https://mastodon.social/@Shaos


06 May 2017 20:52
Profile WWW
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22383
Location: Silicon Valley
Reply with quote

SiFive поднял 50 зелёных лимонов финансирования под свою реализацию RISC-V :o
http://www.electronicdesign.com/embedded-revolution/sifive-raises-506-million-recreate-chip-prototyping

_________________
:dj: https://mastodon.social/@Shaos


08 Apr 2018 17:26
Profile WWW
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22383
Location: Silicon Valley
Reply with quote
Shaos wrote:

SiFive поднял 50 зелёных лимонов финансирования под свою реализацию RISC-V :o
http://www.electronicdesign.com/embedded-revolution/sifive-raises-506-million-recreate-chip-prototyping

Оказывается у меня есть книжка человека, который в данный момент является CEO SiFive :)

Книжка 90х годов (у меня 3я редакция 1999 года) и купил я её на амазоне в октябре 2011 за $5.33 ( включая доставку : )

Автор в те времена работал в Intel...


Attachments:
Naveed.jpg
Naveed.jpg [ 82.96 KiB | Viewed 13402 times ]

_________________
:dj: https://mastodon.social/@Shaos
29 Jul 2018 19:39
Profile WWW
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22383
Location: Silicon Valley
Reply with quote
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 (и не получили, т.к. цель не достигнута)...

_________________
:dj: https://mastodon.social/@Shaos


29 Jul 2018 19:57
Profile WWW
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22383
Location: Silicon Valley
Reply with quote
Shaos wrote:
Оказывается у меня есть книжка человека, который в данный момент является CEO SiFive :)

Книжка 90х годов (у меня 3я редакция 1999 года) и купил я её на амазоне в октябре 2011 за $5.33 ( включая доставку : )

Автор в те времена работал в Intel...

кхм - только что получил запрос через Linkedin :roll:


Attachments:
Linkedin.gif
Linkedin.gif [ 10.28 KiB | Viewed 13195 times ]

_________________
:dj: https://mastodon.social/@Shaos
03 Sep 2018 11:41
Profile WWW
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22383
Location: Silicon Valley
Reply with quote
вот есть опенсорцный эмулятор RISC-V под лицензией MIT:

https://bellard.org/tinyemu/

а вот урезанная до RV32I версия (один текстовый файл на полторы тыщи строк):

https://gist.github.com/FrankBuss/c974e59826d33e21d7cad54491ab50e8

причём которая способна проходить тесты совместимости для RISC-V 32-битной целочисленной подсистемы RV32I:

https://github.com/riscv/riscv-compliance

надо чтоли поиграться с этим...

_________________
:dj: https://mastodon.social/@Shaos


18 Nov 2018 17:19
Profile WWW
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22383
Location: Silicon Valley
Reply with quote
Ставлю на свой 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

И потом суммируются - первые три у кого больше всех очков получают призы (плюс четвёртый приз за креативность):
Quote:
1st prize: USD $6,000
2nd prize: USD $3,000 + Splash Kit + iCE40 UltraPlus MDP
3rd prize: USD $1,000 + PolarFire Evaluation Kit + iCE40 UltraPlus Breakout Board

NEW! There’s an additional USD $3,000 Creativity prize that will be awarded to the entry judged to be most creative by the judge panel (independent of the points awarded to the entry).


P.P.P.S. Неофициальная инфа по требованиям: https://github.com/micro-FPGA/riscv-contest-2018/wiki/RV32I-Compliance

_________________
:dj: https://mastodon.social/@Shaos


18 Nov 2018 18:20
Profile WWW
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22383
Location: Silicon Valley
Reply with quote
Как я понял спецификация 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".

_________________
:dj: https://mastodon.social/@Shaos


18 Nov 2018 20:39
Profile WWW
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22383
Location: Silicon Valley
Reply with quote
Shaos wrote:
Ставлю на свой 64-битный Debian Linux тулзы для RISC-V (GCC и т.д.) по инструкции отсюда:

https://riscv.org/software-tools/risc-v-gnu-compiler-toolchain/

Поставил вариант с Newlib - тесты собираются и работают :)
Code:
Compare to reference files ...

Check         I-ADD-01 ... OK
Check        I-ADDI-01 ... OK
Check         I-AND-01 ... OK
Check        I-ANDI-01 ... OK
Check       I-AUIPC-01 ... OK
Check         I-BEQ-01 ... OK
Check         I-BGE-01 ... OK
Check        I-BGEU-01 ... OK
Check         I-BLT-01 ... OK
Check        I-BLTU-01 ... OK
Check         I-BNE-01 ... OK
Check       I-CSRRC-01 ... OK
Check      I-CSRRCI-01 ... OK
Check       I-CSRRS-01 ... OK
Check      I-CSRRSI-01 ... OK
Check       I-CSRRW-01 ... OK
Check      I-CSRRWI-01 ... OK
Check I-DELAY_SLOTS-01 ... OK
Check      I-EBREAK-01 ... OK
Check       I-ECALL-01 ... OK
Check   I-ENDIANESS-01 ... OK
Check     I-FENCE.I-01 ... OK
Check             I-IO ... OK
Check         I-JAL-01 ... OK
Check        I-JALR-01 ... OK
Check          I-LB-01 ... OK
Check         I-LBU-01 ... OK
Check          I-LH-01 ... OK
Check         I-LHU-01 ... OK
Check         I-LUI-01 ... OK
Check          I-LW-01 ... OK
Check I-MISALIGN_JMP-01 ... OK
Check I-MISALIGN_LDST-01 ... OK
Check         I-NOP-01 ... OK
Check          I-OR-01 ... OK
Check         I-ORI-01 ... OK
Check     I-RF_size-01 ... OK
Check    I-RF_width-01 ... OK
Check       I-RF_x0-01 ... OK
Check          I-SB-01 ... OK
Check          I-SH-01 ... OK
Check         I-SLL-01 ... OK
Check        I-SLLI-01 ... OK
Check         I-SLT-01 ... OK
Check        I-SLTI-01 ... OK
Check       I-SLTIU-01 ... OK
Check        I-SLTU-01 ... OK
Check         I-SRA-01 ... OK
Check        I-SRAI-01 ... OK
Check         I-SRL-01 ... OK
Check        I-SRLI-01 ... OK
Check         I-SUB-01 ... OK
Check          I-SW-01 ... OK
Check         I-XOR-01 ... OK
Check        I-XORI-01 ... OK
--------------------------------
OK: 55/55


Автор урезанного эмуля даже дал мне простой пример на попробовать:
Code:
/*
 Frank Buss: compile like this riscv32-unknown-elf-gcc -O3 -nostdlib test1.c -o test1
 or
 riscv64-unknown-elf-gcc -march=rv32i -mabi=ilp32 -O3 -nostdlib test1.c -o test1
*/
void _start()
{
    volatile char* tx = (volatile char*) 0x40002000;
    const char* hello = "Hello RISC-V!\n";
    while (*hello) {
        *tx = *hello;
        hello++;
    }
}

вот дизассемблированный код:
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

_________________
:dj: https://mastodon.social/@Shaos


18 Nov 2018 23:53
Profile WWW
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22383
Location: Silicon Valley
Reply with quote
Запустил в этом эмуляторчике 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-файле):
Code:
from
lib/libc/minimal/include/sys/types.h:#elif defined(__riscv__)
to
lib/libc/minimal/include/sys/types.h:#elif defined(__riscv)

т.к. __riscv__ это макро для старых версий GCC, а теперь это __riscv

_________________
:dj: https://mastodon.social/@Shaos


19 Nov 2018 13:29
Profile WWW
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22383
Location: Silicon Valley
Reply with quote
Задумал компьютер nedoPC-5 на 32-битном целочисленном RISC-V :roll:

http://www.nedopc.org/forum/viewtopic.php?f=46&t=19179

_________________
:dj: https://mastodon.social/@Shaos


19 Nov 2018 18:36
Profile WWW
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22383
Location: Silicon Valley
Reply with quote
angry_troll wrote:
Для примера: openrisc, страница 36 и далее.

aav8 wrote:
погуглить "riscv-spec-v2.1.pdf"

тут такого не наблюл...

Вот таблица опкодов из спецификации v2.1 (как видно подсистема RV32I умещается в одну первую страницу):

Attachment:
riscv-54.jpg
riscv-54.jpg [ 139.2 KiB | Viewed 12396 times ]


Attachment:
riscv-55.jpg
riscv-55.jpg [ 131.33 KiB | Viewed 12396 times ]


Attachment:
riscv-56.jpg
riscv-56.jpg [ 122.93 KiB | Viewed 12396 times ]


Attachment:
riscv-57.jpg
riscv-57.jpg [ 128.33 KiB | Viewed 12396 times ]


Из полезного есть ещё RV32E (embedded с уменьшенным количеством регистров) и RV32C (компактное представление команд в 16 битах)

_________________
:dj: https://mastodon.social/@Shaos


19 Nov 2018 22:24
Profile WWW
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22383
Location: Silicon Valley
Reply with quote
Shaos wrote:
вот есть опенсорцный эмулятор RISC-V под лицензией MIT:

https://bellard.org/tinyemu/

а вот урезанная до RV32I версия (один текстовый файл на полторы тыщи строк):

https://gist.github.com/FrankBuss/c974e59826d33e21d7cad54491ab50e8

причём которая способна проходить тесты совместимости для RISC-V 32-битной целочисленной подсистемы RV32I:

https://github.com/riscv/riscv-compliance

надо чтоли поиграться с этим...

В этом эмуляторчике по ходу кроме базового набора инструкций из RV32I есть умножение-деление (RV32M) и атомарные операции (RV32A) - сделаю макрос, чтобы их отключить

Текущее состояние эмуля: https://gitlab.com/nedopc/npc5/blob/master/emu-rv32i.c

P.S. А ещё у RISC-V есть инструкции привелигированного режима (в микро-эмуле поддержаны все, кроме URET):


Attachments:
priv.jpg
priv.jpg [ 37.92 KiB | Viewed 12362 times ]

_________________
:dj: https://mastodon.social/@Shaos
20 Nov 2018 13:33
Profile WWW
Admin
User avatar

Joined: 08 Jan 2003 23:22
Posts: 22383
Location: Silicon Valley
Reply with quote
RISC-V имеет очень хитрый декод длины инструкции:

Attachment:
decode.jpg
decode.jpg [ 29.28 KiB | Viewed 12362 times ]

Как можно видеть в табличке чуть выше, все инструкции там представленные имеют в коде 2 младших бита "1" (если там не 11, то это - короткая инструкция из набора RV32C, который мы пока не рассматриваем)

Тип инструкции можно определить по младшему байту (который в little-endian памяти идёт первым в слове):

Attachment:
opcode.jpg
opcode.jpg [ 22.59 KiB | Viewed 12377 times ]

Правда чтобы например отличить ADD и SUB от остальных операторов (OP) придётся взять 3 бита из второго байта, а чтобы отличить ADD и SUB друг от друга ещё и битик из старшего байта слова инструкции нужен

P.S. На картинках я подсветил опкоды, которые необходимы для RV32I

_________________
:dj: https://mastodon.social/@Shaos


20 Nov 2018 14:09
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 84 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next

Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.