Seems there is Hardware divide on Ch32v003? - Page 1
Forum section: electronics / general

author: Heindal
author_rank: Contributor
timestamp: December 12, 2024, 04:46:40 pm
content: Was testing ch32v003 Integer performance and i noticed the divide works as if there is a hardware divider even though ch32v003 doesnt have the "M" extension which supports divide and multiply. Just curious, could Wch have included a hardware divider even though the core is RV32EC

author: ataradov
author_rank: Super Contributor
timestamp: December 12, 2024, 05:35:44 pm
content: What do you mean by " as if there is a hardware divider"? If there is a hardware divider, there would be a corresponding instruction in the disassembly. Look in the disassembly and see what is there. You won't see one, since compiler will not issue it if you don't specify M extension in the build options.

author: Heindal
author_rank: Contributor
timestamp: December 12, 2024, 06:37:54 pm
content: it seemed like it has one because while i was getting low multiply performance , the division was a different case. It could be the compiler optimizing the code using right shift if the number is a power of 2. Changed the code to using only numbers that arent powers of 2 and its back to expected behavior from 6 MIops to 1 MIops.

author: SiliconWizard
author_rank: Super Contributor
timestamp: December 12, 2024, 10:24:37 pm
content: Yes dividing unsigned ints by powers of two are always optimized as right shifts by any reasonable compiler.The CH32V003 has a QingKe RISC-V2A core, which is RV32EC: it has only 16 registers and *not even a hardware multiplier*, as far as the docs tell anyway.Just FYI, the V2C core supports the "m" extension (hardware multiplier but no hardware divider, equivalent to Zmmul), but apparently the MCUs with such a core are these:https://github.com/openwch/ch32v002_004_005_006_007CH32V002, CH32V004, CH32V006 and CH32V007.They don't seem to be listed on WCH's website directly (although, no offense, but I think it's a bit of a mess), but you can find docs by directly looking up the references, like this:https://www.wch-ic.com/downloads/CH32V004DS0_PDF.htmlThey don't seem to be available at LCSC.

author: Heindal
author_rank: Contributor
timestamp: December 15, 2024, 12:08:40 am
content: Yeh. i was kind of looking to buy ch32v007 and other ones but havent seen anything

author: brucehoult
author_rank: Super Contributor
timestamp: December 15, 2024, 02:23:55 am
content: Have you pinged @patrick_riscv on X?

author: HwAoRrDk
author_rank: Super Contributor
timestamp: December 15, 2024, 01:56:12 pm
content: I'm confused about what WCH are doing with the '002/4/5/6/7. I looked to get some last month, but nothing to be found anywhere. Nothing on AliExpress, LCSC, even TaoBao (albeit the international site).It seems they aren't selling them outside of China? Even their actual existence is only mentioned on the Chinese website. But they have, and continue to update, English documentation.

author: SiliconWizard
author_rank: Super Contributor
timestamp: December 16, 2024, 12:14:47 am
content: Similarly with the CH32V317 (which I talk about in another thread). But as Bruce said, if you're really interested in those models, just contact Patrick from WCH.

author: Chicane
author_rank: Contributor
timestamp: December 16, 2024, 01:48:43 pm
content: Quote from: HwAoRrDk on December 15, 2024, 01:56:12 pmThey are still available on Aliexpress. I bought a full kit 2 months ago for cheap and it came to US in 8-9 days.https://www.aliexpress.us/item/3256804882924346.html

author: HwAoRrDk
author_rank: Super Contributor
timestamp: December 16, 2024, 02:19:34 pm
content: Quote from: Chicane on December 16, 2024, 01:48:43 pmThat's for the '003 (and '203). I was specifically talking about the '002/4/5/6/7. They are not the same.