hardware accelerated approach for floating-point ... · pdf filehardware accelerated approach...

6
Hardware accelerated approach for floating-point multiplication on 32-bit pipelined RISC-V processor Udit Khanna* Manoj Sharma** Ankita Saxena*** Abstract : Implementing hardware support for all extensions of the RISC-V Instruction Set Architecture inside a processor would lead to avoidable area and power consumption for applications that rarely utilize a particular extension. In this paper, authors have first suggested a modified 3-stage pipeline alternative to the ZSCALE processor (32-bit) by UC Berkeley. Subsequently a hardware-accelerated approach for implementing the single-precision floating-point extension (‘F’) on programmable logic interfaced with the processor is implemented. For clear demonstration of the suggested approach, an IEEE 745-2008 compliant multiplication unit, optimized for performance and area using ancient Vedic Mathematics techniques, has been used. Adducing this, the proposed processor and the accelerator units have been implemented as a system on Xilinx Virtex-6 ‘xc6vlx75t-3ff 484’ FPGA platform. A maximum operating-frequency of 335 MHz has been observed for the modified standalone processor. Keywords : RISC-V Instruction Set, Hardware Acceleration, IEEE 754-2008 Floating point standard, Vedic Mathematics, Pipelined processors. IJCTA, 9(23), 2016, pp. 271-276 International Science Press * Department of Electronics and Communication Engineering BVCOE, New Delhi, Delhi, India Email- [email protected] ** Department of Electronics and Communication Engineering BVCOE, New Delhi, Delhi, India Email- [email protected] *** Department of Electrical and Electronics Engineering HMRITM, New Delhi, Delhi, India Email- [email protected] 1. INTRODUCTION Initiatives to produce open-source industry-competitive processors have been gaining momentum since the OpenRISC platform came into existence. The recent introduction of the open-source RISC-V instruction set by UC Berkeley has further boosted the efforts in this direction. In one such effort, UC Berkeley has released a 32- bit single-issue in-order core by the name of Z-Scale, which is similar in spirit to the ARM Cortex M0 core [1]. Another development is the PULP (Parallel Ultra Low Power) project led by ETH Professors, which is a quad- core RISC-V compatible processor designed for battery-powered IoT applications [2]. A noteworthy mention is deserved by the SHAKTI project at Indian Institute of Technology, Madras, aimed at breaking the barrier between industry and Academia in the field of state-of-the-art processor designs [3]. Since the RISC-V instruction set includes optional extensions for single-precision and double-precision floating point arithmetic, processors based on this ISA can make use of hardware acceleration. In this approach, the support for the optional extension is implemented on specialized hardware such as programmable logic or FPGA that can speed up the computation and can be powered when required, and thus offload the processor pipeline. The second section of the paper detailed the proposed processor architecture. The interfacing and implementation of hardware accelerator for the RISC-V floating-point multiplication instruction is discussed in third section.

Upload: trinhthuy

Post on 07-Feb-2018

237 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Hardware accelerated approach for floating-point ... · PDF fileHardware accelerated approach for floating-point multiplication on 32-bit pipelined RISC-V processor 271 Hardware accelerated

271Hardware accelerated approach for floating-point multiplication on 32-bit pipelined RISC-V processor

Hardware accelerated approach forfloating-point multiplication on 32-bitpipelined RISC-V processorUdit Khanna* Manoj Sharma** Ankita Saxena***

Abstract : Implementing hardware support for all extensions of the RISC-V Instruction Set Architectureinside a processor would lead to avoidable area and power consumption for applications that rarely utilize aparticular extension. In this paper, authors have first suggested a modified 3-stage pipeline alternative to theZSCALE processor (32-bit) by UC Berkeley. Subsequently a hardware-accelerated approach forimplementing the single-precision floating-point extension (‘F’) on programmable logic interfaced with theprocessor is implemented. For clear demonstration of the suggested approach, an IEEE 745-2008 compliantmultiplication unit, optimized for performance and area using ancient Vedic Mathematics techniques, hasbeen used. Adducing this, the proposed processor and the accelerator units have been implemented as asystem on Xilinx Virtex-6 ‘xc6vlx75t-3ff484’ FPGA platform. A maximum operating-frequency of 335 MHzhas been observed for the modified standalone processor.

Keywords : RISC-V Instruction Set, Hardware Acceleration, IEEE 754-2008 Floating point standard, VedicMathematics, Pipelined processors.

IJCTA, 9(23), 2016, pp. 271-276��International Science Press

* Department of Electronics and Communication Engineering BVCOE, New Delhi, Delhi, India Email- [email protected]

** Department of Electronics and Communication Engineering BVCOE, New Delhi, Delhi, India Email- [email protected]

*** Department of Electrical and Electronics Engineering HMRITM, New Delhi, Delhi, India Email- [email protected]

1. INTRODUCTION

Initiatives to produce open-source industry-competitive processors have been gaining momentum since theOpenRISC platform came into existence. The recent introduction of the open-source RISC-V instruction set byUC Berkeley has further boosted the efforts in this direction. In one such effort, UC Berkeley has released a 32-bit single-issue in-order core by the name of Z-Scale, which is similar in spirit to the ARM Cortex M0 core [1].Another development is the PULP (Parallel Ultra Low Power) project led by ETH Professors, which is a quad-core RISC-V compatible processor designed for battery-powered IoT applications [2]. A noteworthy mention isdeserved by the SHAKTI project at Indian Institute of Technology, Madras, aimed at breaking the barrier betweenindustry and Academia in the field of state-of-the-art processor designs [3].

Since the RISC-V instruction set includes optional extensions for single-precision and double-precision floatingpoint arithmetic, processors based on this ISA can make use of hardware acceleration. In this approach, thesupport for the optional extension is implemented on specialized hardware such as programmable logic or FPGAthat can speed up the computation and can be powered when required, and thus offload the processor pipeline.The second section of the paper detailed the proposed processor architecture. The interfacing and implementationof hardware accelerator for the RISC-V floating-point multiplication instruction is discussed in third section.

Page 2: Hardware accelerated approach for floating-point ... · PDF fileHardware accelerated approach for floating-point multiplication on 32-bit pipelined RISC-V processor 271 Hardware accelerated

272 Udit Khanna, Manoj Sharma and Ankita Saxena

2. PROPOSED PROCESSOR ARCHITECTURE

The proposed architecture is a modification of the Z-Scale processor, leading to a simpler implantation.Fig. 1 shows the 3-stage pipeline of Z-Scale processor, consisting of the PC Generation coupled with InstructionFetch stage, followed by the coupled Instruction Decode and Execute stage, and finally the Data Memory coupledwith Write-back stage. Currently, the Z-Scale processor does not include on-chip support for the F-extension ofRISC-V ISA which consists of floating-point instructions.

Fig. 1. The Zscale Pipeline[1]

Since the RISC-V is a Load/Store instruction set, a modified architecture is proposed in which the Executeunit and Memory unit form a single stage in parallel because an instruction could either use the ALU or it could usethe Data Memory while traversing the pipeline. Thus, the unnecessary passing of arithmetic and logical instructionsthrough the data-memory memory stage is avoided. However, in order to calculate the effective address for Load/Store operations, there arises the need to put an extra 32-bit adder in the decode stage.

Fig. 2. The proposed pipeline.

Further, in order to avoid the area and power used by control-hazard detection logic, it is proposed to couplethe Instruction Fetch and Decode into a single pipeline stage. In this manner, a simpler design is created that avoidspipeline stalls related to various Branch and Jump instructions.

Next, in order to be able to extend support for floating-point instructions in an efficient manner, an optionalgeneric accelerator-interface is proposed. In case of a soft-core implementation of the processor on FPGA, theinterface can be generated at the time of synthesis if support for floating point instructions is required.

3. HARDWARE ACCELERATED FLOATING POINT MULTIPLIER

3.1. RISC-V Floating Point Multiplication Instruction

The F-extension of RISC-V mandates a stack of 32 floating-point registers, separate from the integer registerstack, and a dedicated control & status register ‘fcsr’. For single-precision mode, each of these registers is 32 bitswide. Transfer of floating-point values between memory and registers takes place through dedicated load andstore instructions. Fig.3 summarizes the floating-point arithmetic instructions in the RISC-V ISA.

FMUL is the multiplication instruction, which consists of the 7-bit ‘opcode’ for floating point instructions, 5-bitdestination register ‘rd’, source registers ‘rs1’ and ‘rs2’, 3-bit rounding-mode ‘rm’, another 5-bit field funct5 tospecify the arithmetic operation and a 2-bit field ‘S’ to specify the mode of operation (single- or double-precision).

Page 3: Hardware accelerated approach for floating-point ... · PDF fileHardware accelerated approach for floating-point multiplication on 32-bit pipelined RISC-V processor 271 Hardware accelerated

273Hardware accelerated approach for floating-point multiplication on 32-bit pipelined RISC-V processor

Fig. 3. Floating Point arithmetic instructions [4].

3.2. Interfacing the processor with the accelerator

The floating-point multiplication logic on FPGA is connected to the RISC-V processor through the accelerator-interface depicted in Fig.4.

Fig. 4. Generic Accelerator-Interface.

When an instruction that requires an application-specific accelerator is detected in the Decode unit of theprocessor, the Enable signal on the accelerator-interface is asserted and the complete 32-bit instruction-word ispassed to the accelerator for further decoding. Along with the instruction-word, the two 32-bit operands are alsopassed. In the case of floating-point multiplication, the operands are fetched from the floating-point register stackresiding inside the processor.

Once the instruction is successfully decoded in the accelerator, it asserts the ‘Busy’ signal that stalls theprocessor pipeline until the accelerator operation is complete and/or an anomaly is raised in form of a 4-bit‘exception’ signal that may be interpreted differently for each instruction. The RISC-V ISA supports the followingfloating-point exceptions:

Table 1. RISC-V Floating Point Exceptions

Exception Meaning

NV Invalid Operation

DZ Divide by Zero

OF Overflow

UF Underflow

NX Inexact

Page 4: Hardware accelerated approach for floating-point ... · PDF fileHardware accelerated approach for floating-point multiplication on 32-bit pipelined RISC-V processor 271 Hardware accelerated

274 Udit Khanna, Manoj Sharma and Ankita Saxena

On completion of operation, the accelerator outputs the 32-bit result and asserts the ‘Complete’ signal,following which the processor can continue to write the result in the correct destination register. Exceptions inRISC-V ISA are to be written to the ‘fcsr’ register. Figure 5 summarizes the processor pipeline stages including theaccelerator operation.

Fig. 5. Flowchart for processor pipeline and accelerator operation.

3.3. Multiplication Algorithm

Based on the Urdhwa-Triyagbhyam sutra, also known as vertical and crosswise method, adopted from ancientVedic-Mathematics, a 32-bit single precision Floating-Point multiplier has been adopted from the work of Kumarand Lall [5] to implement the arithmetic function of hardware accelerator. The use of this multiplier results in anaverage pipeline-stall of 6-cycles.

4. EXPERIMENTAL RESULTS

The proposed processor has been designed using Verilog HDL on Questasim HDL Simulator by MentorGraphics and synthesized on Xilinx Virtex-6 ‘xc6vlx75t-3ff484’ FPGA. Synthesis results yield a clock period of2.985 ns for the standalone processor, conversely a 335 MHz frequency of operation. The device utilizationsummary after synthesis of the entire system is tabulated in Table 2 and the RTL Schematic of the pipelinedprocessor is shown in Figure 6.

Table 2. FPGA Device Utilization Summary.

Logic Utilization Used Available Utilization

Number of Slice Registers 142 93120 ~0%

Number of Slice LUTs 502 46560 1%

Number of fully used LUT-FF pairs 122 522 23%

Number of bonded IOBs 185 240 77%

Number of BUFG/BUFGCTRLs 2 32 6%

Page 5: Hardware accelerated approach for floating-point ... · PDF fileHardware accelerated approach for floating-point multiplication on 32-bit pipelined RISC-V processor 271 Hardware accelerated

275Hardware accelerated approach for floating-point multiplication on 32-bit pipelined RISC-V processor

Fig. 6. RTL Schematic of synthesized processor.

5. LIMITATIONS AND FUTURE SCOPE

The proposed system for hardware acceleration is currently based on a pipeline-stall method. Although thismethod consumes less area than an on-chip execution unit and is also less complex than a diversified pipeline, itnegatively impacts the Cycles per Instruction (CPI) metric of performance. A better system may be designed usinghardware-interrupts wherein the processor can continue to do other useful work while the accelerator completesits operation. Some improvement in throughput may also be achieved with an out-of-order execution pipeline,similar to the RISC-V Berkeley Out-of-Order Machine (BOOM).

In future, the accelerator may be used for other custom-extensions to the RISC-V ISA, such as dedicatedinstructions for Digital Signal Processing. For instance, a RISC-V core in a wearable camera based device couldinterface with an accelerator on configurable logic for image processing applications and for Fast Fourier transformcomputation. Additionally, the accelerator could be used in security or ciphering applications such as AES encryptionand decryption.

6. CONCLUSION

In the current paper authors have presented a novel architecture for a simpler implementation of the Z-Scalepipeline along with a generic accelerator-interface for offloading certain tasks from the processor execution-unit.Based upon this new design-paradigm, various compute-intensive tasks can be performed on programmable logicattached to the processor. This would be particularly useful in emerging IoT applications that would require extensionof the RISC-V instruction set.

Page 6: Hardware accelerated approach for floating-point ... · PDF fileHardware accelerated approach for floating-point multiplication on 32-bit pipelined RISC-V processor 271 Hardware accelerated

276 Udit Khanna, Manoj Sharma and Ankita Saxena

7. REFERENCES

1. Yunsup Lee, Albert Ou, Albert Magyar, “RISC-V Z-scale Tiny 32-bit RISC-V systems with updates to Rocket ChipGenerator” 2nd RISC-V Workshop, 6/30/2015

2. Peter Clarke, “Open-Source Processor Core Ready For IoT”, design lines Internet of Things, News and Analysis, EETimes, 3/31/2016

3. Neel Gala, Arjun Menon ; Rahul Bodduna ; G. S. Madhusudan ; V. Kamakoti, “SHAKTI Processors: An Open-SourceHardware Initiative”, 2016 29th International Conference on VLSI Design and 2016 15th International Conferenceon Embedded Systems (VLSID), 4-8 Jan. 2016, DOI: 10.1109/VLSID.2016.130

4. Andrew Waterman; Yunsup Lee ; Rimas Avizienis ; Henry Cook ; David Patterson ; Krste Asanovic, “The RISC-Vinstruction set”, 2013 IEEE Hot Chips 25 Symposium (HCS), 25-27 Aug. 2013, DOI: 10.1109/HOTCHIPS.2013.7478332,

5. Dinesh Kumar, Girish Chander Lall, “SIMULATION AND SYNTHESIS OF 32-BIT MULTIPLIER USING CONFIGURABLEDEVICES”, International Journal of Advances in Engineering & Technology, Jan. 2013, Vol. 5, Issue 2, pp. 216-223

6. Rui Jia, Colin Yu Lin ; Zhenhong Guo ; Rui Chen ; Fei Wang ; Tongqiang Gao ; Haigang Yang, “A survey of opensource processors for FPGAs”, 2014 24th International Conference on Field Programmable Logic and Applications(FPL), 2-4 Sept. 2014, Page(s): 1 – 6, DOI: 10.1109/FPL.2014.6927482

7. Ahmad Jamal Salim, Sani Irwan Salim ; Nur Raihana Samsudin ; Yewguan Soo, “Educational Development Tools forSoftware and Hardware Processor Design”, Modelling and Simulation (EUROSIM), 2013 8th EUROSIM Congresson, 10-13 Sept. 2013, Page(s): 622 – 627, DOI: 10.1109/EUROSIM.2013.108

8. Dmitrij Kissler , Frank Hannig ; Alexey Kupriyanov ; Jurgen Teich, “Hardware Cost Analysis for Weakly ProgrammableProcessor Arrays, 2006 International Symposium on System-on-Chip, 13-16 Nov. 2006, Page(s): 1 – 4, DOI: 10.1109/ISSOC.2006.321996