Skip to content
/ CIC Public

HDL code for a complex multiplier with AXI stream interface

License

Notifications You must be signed in to change notification settings

catkira/CIC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Verify

CIC Decimator

Overview

This project is based on https://opencores.org/projects/cic_core_2 by Egor Ibragimov and on https://opencores.org/projects/cic_core by Vadim Kotelnikov.

The main differences are

  • added variable/programmable downsampling rate
  • added programmable pre and post scaling
  • optimized pipeline structure of comb section -> has much less delay now
  • register pruning calculation outside of hdl code -> great speed up for sim and synth if R is large
  • python model for simulation
  • unit tests using cocotb and cocotb-test

Parameters

  • INP_DW
  • OUT_DW
  • RATE_DW
  • CIC_R
  • CIC_N
  • CIC_M
  • PRUNE_BITS
  • VAR_RATE
  • EXACT_SCALING
  • PRG_SCALING
  • NUM_SHIFT

Ports

  • clk
  • reset_n
  • s_axis_in
  • s_axis_rate
  • m_axis_out

Rounding

In signal processing applications it is usually desired to have a rounding method that does not produce a dc bias, these methods are called symmetric. They work by rounding up or down to the nearest integer whether the decimal value is larger or smaller than 0.5. If the decimal value is is exactly 0.5 a tie-breaker is needed. A commonly used method is round-half-to-even, this is also the default method of the round() function in Python and in the IEEE 754 floating point standard. Xilinx and Matlab call this method convergent rounding towards even. Another possibility is to use alternate or random tie-breaking. However alternate tie-breaking needs to remember the last rounding direction and random tie-breakign needs a random source. Some DSP components like the Xilinx complex multiplier use random tie-breaking and have a separate input, for the bit that decides tie-breaking. Depending on that bit it switches between round-half-up and round-half-down. I have not yet decided whether to implement round-half-to-even or random tie-breaking for this CIC.

Rounding in Xilinx FPGAs using the DSP48 units

This document describes different rounding methods that can efficiently be implemented on a DSP48 unit. Random rounding can easily be implemented by toggling the CARRYIN bit of a correctly configured DSP48 unit randomly. The symmetric rounding methods round-to-zero and round-to-infinity can also easily be implemented by usin the CARRYIN bit as described here. Convergent rounding like round-half-to-even can also be implemented using the CARRYIN bit. But in this case the value of CARRYIN depends on the actual number, so it cannot be determined ahead of time. This calculation requires additional logic outside of the DSP48. ug193 shows an example how the pattern matching facility of the DSP48 can be used for convergent rounding. This is especially simple when doing static convergent rounding (rounding bit is always at the same decimal position).

Rounding in other CICs

The Xilinx CIC core does not specify how it performs rounding. The datasheet of the HSP43220 says that it uses symmetric rounding, but not which method exactly.

Verification

To run the unit tests install python >= 3.8 and iverilog >= 10. Then run pytest in the repo directory like this:

pip install -r requirements.txt
pytest -v --workers 10

TODO

  • add CIC interpolator
  • add rounding to last stage of decimator

References

License

GPL (for old code from opencores LGPL)