{"id":18143609,"url":"https://github.com/catkira/cic","last_synced_at":"2025-04-23T01:04:03.050Z","repository":{"id":52186428,"uuid":"328466845","full_name":"catkira/CIC","owner":"catkira","description":"HDL code for a complex multiplier with AXI stream interface","archived":false,"fork":false,"pushed_at":"2023-02-07T20:31:37.000Z","size":2059,"stargazers_count":16,"open_issues_count":0,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-29T20:43:56.329Z","etag":null,"topics":["axis","hdl","verilog"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/catkira.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-01-10T19:53:42.000Z","updated_at":"2024-10-22T18:21:29.000Z","dependencies_parsed_at":"2023-01-31T15:31:28.247Z","dependency_job_id":null,"html_url":"https://github.com/catkira/CIC","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catkira%2FCIC","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catkira%2FCIC/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catkira%2FCIC/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catkira%2FCIC/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/catkira","download_url":"https://codeload.github.com/catkira/CIC/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250349047,"owners_count":21415914,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["axis","hdl","verilog"],"created_at":"2024-11-01T19:08:13.672Z","updated_at":"2025-04-23T01:04:03.033Z","avatar_url":"https://github.com/catkira.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Verify](https://github.com/catkira/CIC/actions/workflows/verify.yml/badge.svg)](https://github.com/catkira/CIC/actions/workflows/verify.yml)\n\n# CIC Decimator\n## Overview\nThis 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.\n\nThe main differences are\n- added variable/programmable downsampling rate\n- added programmable pre and post scaling\n- optimized pipeline structure of comb section -\u003e has much less delay now\n- register pruning calculation outside of hdl code -\u003e great speed up for sim and synth if R is large\n- python model for simulation\n- unit tests using cocotb and cocotb-test\n\n## Parameters\n- INP_DW\n- OUT_DW\n- RATE_DW\n- CIC_R\n- CIC_N\n- CIC_M\n- PRUNE_BITS\n- VAR_RATE\n- EXACT_SCALING\n- PRG_SCALING\n- NUM_SHIFT\n\n## Ports\n- clk\n- reset_n\n- s_axis_in\n- s_axis_rate\n- m_axis_out\n\n## Rounding\nIn 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](https://en.wikipedia.org/wiki/Rounding#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](https://de.mathworks.com/help/fixedpoint/ug/rounding-mode-convergent.html) call this method *convergent rounding towards even*.\nAnother 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.\nI have not yet decided whether to implement round-half-to-even or random tie-breaking for this CIC.\n\n### Rounding in Xilinx FPGAs using the DSP48 units\nThis [document](https://www.xilinx.com/support/documentation/user_guides/ug193.pdf) 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](https://www.xilinx.com/support/documentation/user_guides/ug193.pdf). \nConvergent 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](https://www.xilinx.com/support/documentation/user_guides/ug193.pdf) 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).\n\n### Rounding in other CICs\nThe 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.\n\n## Verification\nTo run the unit tests install python \u003e= 3.8 and iverilog \u003e= 10.\nThen run pytest in the repo directory like this:\n```\npip install -r requirements.txt\npytest -v --workers 10\n```\n\n## TODO\n- add CIC interpolator\n- add rounding to last stage of decimator\n\n## References\n- HSP50214 datasheet\n- HSP43220 datasheet\n- https://opencores.org/projects/cic_core_2\n- https://opencores.org/projects/cic_core\n- https://en.wikipedia.org/wiki/Rounding\n- https://realpython.com/python-rounding/\n- https://zipcpu.com/dsp/2017/07/22/rounding.html\n- https://patents.google.com/patent/US20080028014A1/en\n- https://www.xilinx.com/support/documentation/user_guides/ug193.pdf\n- https://www.dsprelated.com/showarticle/1337.php\n- https://www.design-reuse.com/articles/10028/understanding-cascaded-integrator-comb-filters.html\n- https://www.dsprelated.com/showcode/269.php\n- http://www.tsdconseil.fr/log/scriptscilab/cic/cic-en.pdf\n- http://threespeedlogic.com/cic-compensation.html\n- https://www.intel.com/content/dam/www/programmable/us/en/pdfs/literature/an/an455.pdf\n- https://www.koheron.com/blog/2016/10/03/decimator-cic-filter\n- https://liquidsdr.org/blog/firdespm-invsinc/\n- http://old.myhdl.org/doku.php/projects:gcicexample\n\n## License\nGPL\n(for old code from opencores LGPL)\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcatkira%2Fcic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcatkira%2Fcic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcatkira%2Fcic/lists"}