Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] unconstrained array error, need help

Status
Not open for further replies.

sed_y

Newbie level 4
Joined
Jan 25, 2009
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,355
hi,
I made simple Gray code to implement gray code increment circuit as
Code:
library ieee;
use ieee.std_logic_1164.all;

entity graycode_inc is 
generic( n:natural := 3);
port( g: in std_logic_vector(n-1 downto 0);
      gn : out std_logic_vector(n-1 downto 0)
		);
end graycode_inc;

architecture behav of graycode_inc is
begin
 with g select 
    gn <=             "001" when "000",
	                 "011" when "001",
			 "010" when "011",
			 "110" when "010",
			 "111" when "110",
			 "101" when "111",
			 "100" when "101",
			 "000" when others;
end behav;

however, i get error:
Code:
Selector (Signal 'g' of type std_logic_vector) is an unconstrained array
1) how is it unconstrained when it was constrained through generic.
2) if do something like this
Code:
port( g: in std_logic_vector(2 downto 0);
      gn : out std_logic_vector(n-1 downto 0)
		);
it works fine.but, shouldn't compiler complain for gn as being unconstrained too?
any help?
 

1. what happens when g is set to 2? 4? 16? That is why g is unconstrained. Inside the graycode_inc entity g is unconstrained. The 3 value you gave it is just a default that gets used when it is instantiated without a specific value, so n at the moment is not any specific value.

2. Yes. If it doesnt compain when its compiled, it will complain when you try and run/synthesis it when n is something other than 3.
 

hi tricky,
the same code is working now, and is synthesized properly too. I don't know why xilinx did that.

sedy
 

use this code

library ieee;
use ieee.std_logic_1164.all;

entity graycode_inc is
generic(
n :integer := 3
);
port(
g: in std_logic_vector(n-1 downto 0);
gn : out std_logic_vector(n-1 downto 0)
);
end graycode_inc;

architecture behav of graycode_inc is
begin

gn <= "001" when g = "000" else
"011" when g = "001" else
"010" when g = "011" else
"110" when g = "010" else
"111" when g = "110" else
"101" when g = "111" else
"100" when g = "101" else
"000";
end behav;
 

Hamed - your code is identical to the OP's code. Changing N to integer makes no difference, because if n is anything other than 3 the code will fail.

But with your code making n an integer, someone could set n to -1, and you'd have null arrays, and you'd get rid of the whole thing.

a natural makes more sense.
 

Hamed - your code is identical to the OP's code. Changing N to integer makes no difference, because if n is anything other than 3 the code will fail.

But with your code making n an integer, someone could set n to -1, and you'd have null arrays, and you'd get rid of the whole thing.

a natural makes more sense.

TrickyDicky - I know that but I only editted above code that can be synthesized. If some one need complete code should use for loop and compare section inside loop using parameters.
 

Naturals can be synthesised, you didnt need to change it to an integer.
 

Naturals can be synthesised, you didnt need to change it to an integer.

I didn't changed natural into integer for synthesizablity I replaced "with select" by "when else" for synthesize error that mentioned above.because I write most of my codes(some variables) with integer it was a copy paste from my modules.

---------- Post added at 06:24 ---------- Previous post was at 06:18 ----------

I didn't changed natural into integer for synthesizablity I replaced "with select" by "when else" for synthesize error that mentioned above.because I write most of my codes(some variables) with integer it was a copy paste from my modules.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top