- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The issue I'm facing is that after synthesis, the comparator uses a significant amount of resources (image below) specifically, it uses 2 CARRY4 blocks and too much LUTs. My professor, who assigned this task, explicitly stated that I must not convert a and b to integer, unsigned, or any other numeric type. They must be compared as std_logic_vector.
Is there a way to implement a more resource-efficient comparator under these constraints? Any ideas or patterns to reduce the number of LUTs or avoid the use of carry chains would be appreciated.
Here is the code :
library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity comparator is Port ( clk, rst : in std_logic; a, b : in std_logic_vector (15 downto 0); max, min : out std_logic_vector (15 downto 0) ); end comparator; architecture Behavioral of comparator is signal max_int, min_int : std_logic_vector (15 downto 0); begin process (clk) begin if (rst = '1') then min_int <= (others => '0'); max_int <= (others => '0'); elsif (rising_edge(clk)) then if (a <= b) then min_int <= a; max_int <= b; else min_int <= b; max_int <= a; end if; end if;
Thanks in advance!
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Using carry chain is appropriate for fast comparator, Quartus selects it automatically as default implementation.
Most LUT are used for 32 mux output bits and have nothing to do with comparator function as such.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So, are there no alternatives? Is this the best solution?
Do you think I could write the VHDL code in a way that uses even fewer resources?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Altera provides the LPM_COMPARE IP core, which can be used for more efficient logic synthesis and device implementation compared to writing your own comparator functions. This IP core is customizable to meet specific design requirements.
Here’s the official documentation for reference:
https://www.intel.com/content/www/us/en/docs/programmable/683490/25-1/lpm-compare-comparator.html
I understand your professor may require you to implement the logic manually, but I just wanted to point out that using Altera IP cores can significantly speed up design development.
Regards,
Richard Tan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We noticed that we haven't received a response from you regarding the latest previous question/reply/answer, and will now transitioning your inquiry to our community support. We apologize for any inconvenience this may cause and we appreciate your understanding.
If you have any further questions or concerns, please don't hesitate to reach out. Please login to https://supporttickets.intel.com/s/?language=en_US, view details of the desire request, and post a feed/response within the next 15 days to allow me to continue to support you. After 15 days, this thread will be transitioned to community support. The community users will be able to help you on your follow-up questions.
The community users will be able to help you on your follow-up questions.
Thank you for reaching out to us!
Best Regards,
Richard Tan

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page