RISC-V extensions: help!

560 views
Skip to first unread message

Ghada Dessouky

unread,
Mar 16, 2017, 7:42:51 AM3/16/17
to RISC-V ISA Dev
Hi all,

I am reading the RISC-V specifications on instruction extension and I am quite confused. I am new to this, but I think the manual is also not too clear on what is a brownfield vs greenfield extension.

I understand from chapter 9 which opcodes are custom/reserved and are available for extensions and I believe the RI5CY extensions use them already.  But chapter 10 goes on to discuss instruction set extensions and I can't seem to understand how can I add more instructions that would not conflict with the RI5CY extensions? Would I need to change the instruction length? What are brownfield and greenfield extensions?

Any help or a clearer explanation would be much appreciated.

Best,
Ghada

Bruce Hoult

unread,
Mar 21, 2017, 10:40:12 AM3/21/17
to Ghada Dessouky, RISC-V ISA Dev
Since no one has answered this, I'll have a crack at it...

It's a bit of an arbitrary distinction, but as I understand it:

- a greenfield extension uses some unique N bit "prefix" in the least significant bits of the instruction (not used by any other instruction encoding), and then has an entire 32-N bits of instruction space to play in.

- a brownfield extension uses an N bit prefix that is already used by some other (standard or non-standard) set of instructions, and fits itself into unused holes in the encoding.


--
You received this message because you are subscribed to the Google Groups "RISC-V ISA Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isa-dev+unsubscribe@groups.riscv.org.
To post to this group, send email to isa...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/isa-dev/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/isa-dev/d222bbb0-0acd-418b-ae06-d202b5ff16aa%40groups.riscv.org.

kr...@berkeley.edu

unread,
Mar 21, 2017, 10:54:03 AM3/21/17
to Bruce Hoult, Ghada Dessouky, RISC-V ISA Dev

Bingo!

Except 32 is actually N*16, where N is number of parcels in
instruction.

Krste
| email to isa-dev+u...@groups.riscv.org.
| To post to this group, send email to isa...@groups.riscv.org.
| Visit this group at https://groups.google.com/a/groups.riscv.org/group/isa-
| dev/.
| To view this discussion on the web visit https://groups.google.com/a/
| groups.riscv.org/d/msgid/isa-dev/d222bbb0-0acd-418b-ae06-
| d202b5ff16aa%40groups.riscv.org.


| --
| You received this message because you are subscribed to the Google Groups
| "RISC-V ISA Dev" group.
| To unsubscribe from this group and stop receiving emails from it, send an email
| to isa-dev+u...@groups.riscv.org.
| To post to this group, send email to isa...@groups.riscv.org.
| Visit this group at https://groups.google.com/a/groups.riscv.org/group/isa-dev/
| .
| To view this discussion on the web visit https://groups.google.com/a/
| groups.riscv.org/d/msgid/isa-dev/
| CAMU%2BEkwQhhX-WZyssgyoQuhoe80pnQjgupCV5-3yxmQB4ir8zw%40mail.gmail.com.

Ghada Dessouky

unread,
Mar 23, 2017, 9:20:09 AM3/23/17
to kr...@berkeley.edu, Bruce Hoult, RISC-V ISA Dev
Thanks for the clarification!

So if I go for greenfield and introduce a new prefix (not the "11" for base ISA) I can have all of the encoding space to play in then with all my extensions (assuming I have too many and won't make it with brownfield)?

Do I understand correctly?

Regards,
Ghada




|     To post to this group, send email to isa...@groups.riscv.org.
|     Visit this group at https://groups.google.com/a/groups.riscv.org/group/isa-
|     dev/.
|     To view this discussion on the web visit https://groups.google.com/a/
|     groups.riscv.org/d/msgid/isa-dev/d222bbb0-0acd-418b-ae06-
|     d202b5ff16aa%40groups.riscv.org.


| --
| You received this message because you are subscribed to the Google Groups
| "RISC-V ISA Dev" group.
| To unsubscribe from this group and stop receiving emails from it, send an email

| To post to this group, send email to isa...@groups.riscv.org.
| Visit this group at https://groups.google.com/a/groups.riscv.org/group/isa-dev/
| .
| To view this discussion on the web visit https://groups.google.com/a/
| groups.riscv.org/d/msgid/isa-dev/
| CAMU%2BEkwQhhX-WZyssgyoQuhoe80pnQjgupCV5-3yxmQB4ir8zw%40mail.gmail.com.

Bruce Hoult

unread,
Mar 23, 2017, 4:47:01 PM3/23/17
to Ghada Dessouky, Krste Asanovic, RISC-V ISA Dev
It's hard to give advice with no idea at all of the scope of what you want to add.

Say you want to add a "decimal mode" that make the normal add and subtract instructions work in BCD instead of binary. You'd want a SED instruction and a CLD instruction. Pretty simple ... any 1 bit hole anywhere in the instruction set will do ... some fixed 31 bit combination that says it's your extension, and then 1 bit to say whether is SED or CLD.

On the other hand, if you want to add, say, something like "count leading zeroes", with a source register and a destination register then you'll need a bit bigger hole ... but still just 10 bits to specify the registers (hopefully in the standard places) and some fixed combination of the other 22 bits that says "this ia a CLZ". Or, if you don't care if the source and destination are always a0 (convenient for a pseudo-function) then you only need to find one single 32 bit opcode -- and it's an even smaller extension (in opcode space) than the SED/CLD instead of taking up 1024 opcodes.

If you want a whole new data type, a new register file, special load/store instructions, special operations on your private register file ... you're going to want a whole lot more opcode space! Maybe in this case you'd steal the opcodes (semi-)reserved for 128 bit integer or FP and just say that your extension will only ever work with RV32 or RV64 CPUs.

If you need *really* a lot of opcode space then you can say that your extension is incompatible with the C standard extension and then you can use all the 3,221,225,472 opcodes ending in 00, 01, or 10! No problem ... just configure your copy of gcc to never generate 16 bit instructions. Everything will work fine. Your code will be a little bigger, but if you *really* need that opcode space you can use it.

So many possibilities. And we didn't even talk about 48 bit or 64 bit or bigger opcodes.


Regards,
Ghada



|     email to isa-dev+u...@groups.riscv.org.

|     To post to this group, send email to isa...@groups.riscv.org.
|     Visit this group at https://groups.google.com/a/groups.riscv.org/group/isa-
|     dev/.
|     To view this discussion on the web visit https://groups.google.com/a/
|     groups.riscv.org/d/msgid/isa-dev/d222bbb0-0acd-418b-ae06-
|     d202b5ff16aa%40groups.riscv.org.


| --
| You received this message because you are subscribed to the Google Groups
| "RISC-V ISA Dev" group.
| To unsubscribe from this group and stop receiving emails from it, send an email

| To post to this group, send email to isa...@groups.riscv.org.
| Visit this group at https://groups.google.com/a/groups.riscv.org/group/isa-dev/
| .
| To view this discussion on the web visit https://groups.google.com/a/
| groups.riscv.org/d/msgid/isa-dev/
| CAMU%2BEkwQhhX-WZyssgyoQuhoe80pnQjgupCV5-3yxmQB4ir8zw%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "RISC-V ISA Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isa-dev+unsubscribe@groups.riscv.org.
To post to this group, send email to isa...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/isa-dev/.

黃柏瑋

unread,
Apr 3, 2017, 9:41:08 AM4/3/17
to Bruce Hoult, Ghada Dessouky, Krste Asanovic, RISC-V ISA Dev
Hi all,
Extending this thread, I have two questions.
1.  There are 3 reserved in this table for the standard extension, but we get way more extensions (B extension, Security, Vector, and more).
So, we need brownfield and use the “funct3” and “func7 field for those extension if we want to R-type.
However, Is there a similar management table for funct3 or func7?


2.What do those term major opcode and minor code mean? I guess 25 bit is from " 32-2-3-2=25”, but I don’t understand where does 22 bit comes from.
I will feel appreciated for your help.
Best,
Po-wei 

Reply all
Reply to author
Forward
0 new messages