Search code examples
recursionvhdl

VHDL: recursive n bit comparator


I have to create a n bit comparator (under respect of n = 2**k) in VHDL with recursion. Since the necassary chapter is taken after the christmasbreak, I have no lecture notes. My idea was using the generic statement like this:. I thought I could use the generic statement, like this:

entity comperator is
    generic (k: integer := 0);
    port(a, b: std_logic_vector(2**k-1 downto 0);
         c: out std_logic_vector (1 downto 0));
end;

architecture recursive of comperator is 
  signal e,d: std_logic_vector(1 downto 0);

begin
    p2: if k /= 0 generate
      d1 : entity comperator
           port map (a(2**k-1 downto 2**(k-1)), b(2**k-1 downto 2**(k-1)), d);

I made with testbench a simulation but I got strange error reports, something like this: "sem_parenthesis_name: cannot handle IIR_KIND_COMPONENT_INSTANTIATION_STATEMENT (design.vhd:19:11)"

If you need the hole code: https://www.edaplayground.com/x/2RuY

I have no idea why the code doesn't work. Has anyone an idea?

Greedings, What's in the box


Solution

  • I've found the mistake, now it works. If someone has the same or similar problem, here is the link to the working source code: https://www.edaplayground.com/x/2RuY