There are no reviews yet. Be the first to send feedback to the community and the maintainers!
Verilog Fixed point math library Original work by Sam Skalicky, originally found here: http://opencores.org/project,fixed_point_arithmetic_parameterized Extended, updated, and heavily commented by Tom Burke ([email protected]) This library includes the basic math functions for the Verilog Language, for implementation on FPGAs. All units have been simulated and synthesized for Xilinx Spartan 3E devices using the Xilinx ISE WebPack tools v14.7 These math routines use a signed magnitude Q,N format, where N is the total number of bits used, and Q is the number of fractional bits used. For instance, 15,32 would represent a 32-bit number with 15 fractional bits, 16 integer bits, and 1 sign bit as shown below: |1|<- N-Q-1 bits ->|<--- Q bits -->| |S|IIIIIIIIIIIIIIII|FFFFFFFFFFFFFFF| This library contains the following modules: qadd.v - Addition module; adds 2 numbers of any sign. qdiv.v - Division module; divides two numbers using a right-shift and subtract algorithm - requires an input clock qmult.v - Multiplication module; purely combinational for systems that will support it qmults.v - Multiplication module; uses a left-shift and add algorithm - requires an input clock (for systems that cannot support the synthesis of a combinational multiplier) Test_add.v - Test fixture for the qadd.v module Test_mult.v - Test fixture for the qmult.v module TestDiv.v - Test fixture for the qdiv.v module TestMultS.v - Test fixture for the qmults.v module These math routines default to a (Q,N) of (15,32), but are easily customizable to your application by changing their input parameters. For instance, an unmodified use of (15,32) would look something like this: qadd my_adder( .a(addend_a), .b(addend_b), .c(result) ); To change this to an (8,23) notation, for instance, the same module would be instantiated thusly: qadd #(8,23) my_adder( .a(addend_a), .b(addend_b), .c(result) ); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The following is a description of each module ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ qadd.v - A simple combinational addition module. sum = addend + addend Input format: |1|<- N-Q-1 bits ->|<--- Q bits -->| |S|IIIIIIIIIIIIIIII|FFFFFFFFFFFFFFF| Inputs: a - addend 1 b - addend 2 Output format: |1|<- N-Q-1 bits ->|<--- Q bits -->| |S|IIIIIIIIIIIIIIII|FFFFFFFFFFFFFFF| Output: c - result NOTE: There is no error detection for an overflow. It is up to the designer to ensure that an overflow cannot occur!! Example usage: qadd #(Q,N) my_adder( .a(addend_a), .b(addend_b), .c(result) ); For subtraction, set the sign bit for the negative number. (subtraction is the addition of a negative, right?) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ qmult.v - A simple combinational multiplication module. Input format: |1|<- N-Q-1 bits ->|<--- Q bits -->| |S|IIIIIIIIIIIIIIII|FFFFFFFFFFFFFFF| Inputs: i_multiplicand - multiplicand i_multiplier - multiplier Output format: |1|<- N-Q-1 bits ->|<--- Q bits -->| |S|IIIIIIIIIIIIIIII|FFFFFFFFFFFFFFF| Output: o_result - result ovr - overflow flag NOTE: This module assumes a system that supports the synthesis of combinational multipliers. If your device/synthesizer does not support this for your particular application, then use the "qmults.v" module. NOTE: Notice that the output format is identical to the input format! To properly use this module, you need to either ensure that you maximum result never exceeds the format, or incorporate the overflow flag into your design Example usage: qmult #(Q,N) my_multiplier( .i_multiplicand(multiplicand), .i_multiplier(multiplier), .o_result(result), .ovr(overflow_flag) ); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ qmults.v - A multi-clock multiplication module that uses a left-shift and add algorithm. result = multiplicand x multiplier Input format: |1|<- N-Q-1 bits ->|<--- Q bits -->| |S|IIIIIIIIIIIIIIII|FFFFFFFFFFFFFFF| Inputs: i_multiplicand - multiplicand i_multiplier - multiplier i_start - Start flag; set this bit high ("1") to start the operation when the last operation is completed. This bit is ignored until o_complete is asserted. i_clk - input clock; internal workings occur on the rising edge Output format: |1|<- N-Q-1 bits ->|<--- Q bits -->| |S|IIIIIIIIIIIIIIII|FFFFFFFFFFFFFFF| Output: o_result_out - result o_complete - computation complete flag; asserted ("1") when the operation is completed o_overflow - overflow flag; asserted ("1") to indicate that an overflow has occurred. NOTE: This module is "time deterministic ." - that is, it should always take the same number of clock cycles to complete an operation, regardless of the inputs (N+1 clocks) NOTE: Notice that the output format is identical to the input format! To properly use this module, you need to either ensure that you maximum result never exceeds the format, or incorporate the overflow flag into your design Example usage: qmults #(Q,N) my_multiplier( .i_multiplicand(multiplicand), .i_multiplier(multiplier), .i_start(start), .i_clk(clock), .o_result(result), .o_complete(done), .o_overflow(overflow_flag) ); The qmults.v module begins computation when the start conditions are met: o_complete == 1'b1; i_start == 1'b1; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ qdiv.v - A multi-clock division module that uses a right-shift and add algorithm. quotient = dividend / divisor Input format: |1|<- N-Q-1 bits ->|<--- Q bits -->| |S|IIIIIIIIIIIIIIII|FFFFFFFFFFFFFFF| Inputs: i_dividend - dividend i_divisor - divisor i_start - Start flag; set this bit high ("1") to start the operation when the last operation is completed. This bit is ignored until o_complete is asserted. i_clk - input clock; internal workings occur on the rising edge Output format: |1|<- N-Q-1 bits ->|<--- Q bits -->| |S|IIIIIIIIIIIIIIII|FFFFFFFFFFFFFFF| Output: o_quotient_out - result o_complete - computation complete flag; asserted ("1") when the operation is completed o_overflow - overflow flag; asserted ("1") to indicate that an overflow has occurred. NOTE: This module is "time deterministic ." - that is, it should always take the same number of clock cycles to complete an operation, regardless of the inputs (N+Q+1 clocks) NOTE: Notice that the output format is identical to the input format! To properly use this module, you need to either ensure that you maximum result never exceeds the format, or incorporate the overflow flag into your design Example usage: qdiv #(Q,N) my_divider( .i_dividend(dividend), .i_divisor(divisor), .i_start(start), .i_clk(clock), .o_quotient_out(result), .o_complete(done), .o_overflow(overflow_flag) ); The qdiv.v module begins computation when the start conditions are met: o_complete == 1'b1; i_start == 1'b1; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Suggestions, Kudos, or Complaints? Feel free to contact me - but remember, this stuff is free!
8051
8051 coredma_axi
AXI DMA 32 / 64 bitsethmac
Ethernet MAC 10/100 Mbpsround_robin_arbiter
round robin arbiterjpegencode
JPEG Encoder Verilogsparc64soc
OpenSPARC-based SoCxge_mac
Ethernet 10GE MACdma_ahb
AHB DMA 32 / 64 bitscan
CAN Protocol Controllervideo_stream_scaler
Video Stream Scalerapbi2c
APB to I2Carm4u
ARM4Uverilog_cordic_core
configurable cordic core in verilogturbo8051
turbo 8051i2c
I2C controller coremcs-4
4004 CPU and MCS-4 family chipsjtag
JTAG Test Access Port (TAP)dvb_s2_ldpc_decoder
DVB-S2 LDPC Decoderembedded_risc
Embedded 32-bit RISC uProcessor with SDRAM Controlleruart16550
UART 16550 coreha1588
Hardware Assisted IEEE 1588 IP Corefreecores.github.io
Freecores websitey80e
Y80e - Z80/Z180 compatible processor extended by eZ80 instructionsaxi_master
Generic AXI master stubvideo_systems
Video compression systemsmips_16
Educational 16-bit MIPS Processortheia_gpu
Theia: ray graphic processing unitddr3_sdram
DDR3 SDRAM controllermmu180
MMU for Z80 and eZ80ps2
PS2 interfacezpu
ZPU - the worlds smallest 32 bit CPU with GCC toolchainzx_ula
ULA chip for ZX Spectrumzet86
Zet - The x86 (IA-32) open implementationwb_dma
WISHBONE DMA/Bridge IP Coreuart2spi
UART To SPI1000base-x
1000BASE-X IEEE 802.3-2008 Clause 36 - Physical Coding Sublayer (PCS)usbhostslave
USB 1.1 Host and Function IP corewb_builder
WISHBONE Builderofdm
OFDM modempci
PCI bridgedouble_fpu
double_fpu_verilogsha3
SHA3 (KECCAK)nova
H.264/AVC Baseline Decoderrobust_axi2ahb
Generic AXI to AHB bridgemmuart
Simple RS232 UARTudp_ip__core
UDP/IP Corefpga-median
FPGA-based Median Filterreed_solomon_decoder
Reed Solomon Decoder (204,188)tiny_aes
AESmac_layer_switch
100 MB/s Ethernet MAC Layer Switchahb_master
Generic AHB master stubwb_z80
Wishbone High Performance Z80z80soc
Z80 System on Chiprobust_axi_fabric
Generic AXI interconnect fabricxge_ll_mac
Ethernet 10GE Low Latency MACan-fpga-implementation-of-low-latency-noc-based-mpsoc
NoC based MPSoCsimple_spi
SPI coreusb11_phy_translation
USB 1.1 PHY (VHDL)avr_core
AVR Corertf8088
rtf8088spartan6_pcie
Spartan 6 PCIexpress cardpipelined_fft_64
Pipelined FFT/IFFT 64 points processorbluespec-reedsolomon
Bluespec SystemVerilog Reed Solomon Decoderaes_decrypt_fpga
AES Decryption Core for FPGAfpu_double
FPU Double VHDLbluespec-h264
Bluespec H.264 Decoderbluespec-80211atransmitter
Bluespec 802.11a Transmitterusb_phy
USB 1.1 PHYsdram_controller
Scratch DDR SDRAM Controllerfpu
Floating Point Unitsgmii
SGMII8b10b_encdec
8b10b Encoder/Decoderpwm
PWMopenjtag-project
Open JTAG projectpid_controller
PID controllerudp_ip_stack
1G eth UDP / IP Stackaes-128_pipelined_encryption
AES-128 Encryptionwdsp
DSP WishBone Compatible Coresreed_solomon_codec_generator
Reed-Solomon Codec Generatorspacewire
SpaceWireyac
YAC - Yet Another CORDIC Corews2812
WS2812 RGB LED string driveramber
Amber ARM-compatible corecheap_ethernet
Cheap Ethernet interface6809_6309_compatible_core
6809 and 6309 Compatible corerobust_axi2apb
Generic AXI to APB bridgedivider
Hardware Division Unitsplasma
Plasma - most MIPS I(TM) opcodesrtc
No descriptioni2c_master_slave_core
I2C master/slave Coreasync_8b10b_encoder_decoder
Async 8b/10b enc/decethernet_tri_mode
10_100_1000 Mbps tri-mode ethernet MACag_6502
ag_6502 soft core with phase-level accuracyata
OCIDEC (OpenCores IDE Controller)i2cslave
I2C Slaveahb_slave
Generic AHB slave stubopenmsp430
openMSP430spacewire_light
SpaceWire Lightyadmc
Asynchronous WISHBONE-compatible SDRAM controllergenesys_ddr2
DDR2 mem controller for Digilent Genesys BoardLove Open Source and this site? Check out how you can help us