This error on quartus: formal port or parameter "N" must have actual or
default value
What does it mean?
Here is my code:
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_signed.all;
entity shrBbits is
generic (N:positive);
port( A,B: in std_logic_vector(N-1 downto 0);
OP: in std_logic_vector(2 downto 0);
RES_LO:out std_logic_vector(N-1 downto 0)
);
end entity;
I have this code:
Doing a shift to A - B times.
entity shrBbits is
generic (N:positive:=32);
port( A,B: in std_logic_vector(N-1 downto 0);
OP: in std_logic_vector(2 downto 0);
RES_LO:out std_logic_vector(N-1 downto 0)
);
end entity;
architecture behv of shrBbits is
signal temp,temp_res: std_logic_vector(N-1 downto 0);
signal num:integer:=0;
begin
process (A,B,OP,num,temp,temp_res)
begin
temp<=A;
temp_res<=A;
if (conv_integer(B)<0) then --for negative B
num<=conv_integer(not (B))+1;
else if num=0 then
temp_res<=A;
num<=conv_integer(B);
else
num<=conv_integer(B);
end if;
end if;
temp_res(N-1 downto num+1)<= temp(num-1 downto 0); -- HERE IS THE
ERROR
temp_res(num downto 0)<=temp(N-1 downto num);
RES_LO<=temp_res;
end process;
end behv;
How can it be changed?
Yes - thanks - you right
it should be:
temp_res(N-1 downto N-num)<= temp(num-1 downto 0);
temp_res(N-num-1 downto 0)<=temp(N-1 downto num);
But it still gives me the same error.
Why?
> Doing a shift to A - B times.
Really a shift?
A right shift or a left shift?
Or (as you do) a rotation?
With your name sh-r-B-bits I assume a right shift for B bits:
1
libraryIEEE;
2
useIEEE.std_logic_1164.all;
3
useIEEE.numeric_std.all;
4
5
entityshrBbitsis
6
generic(N:positive:=32);
7
port(A,B:instd_logic_vector(N-1downto0);-- why is B that big? 6 bits (0..32) would be enough!!!
8
OP:instd_logic_vector(2downto0);-- what is this OP good for?
9
RES_LO:outstd_logic_vector(N-1downto0)
10
);
11
endentity;
12
13
architecturebehvofshrBbitsis
14
signalnum:integerrange0to2*N:=0;
15
signalhlp:std_logic_vector(N*2-1downto0);
16
begin
17
-- used ressources and delay times are for a Spartan 3 AN
18
-- Number of Slices 75
19
-- Maximum combinational path delay: 10.832ns
20
process(A,B)
21
variableh:std_logic_vector(N-1downto0);
22
variablec:integerrange0toN:=0;
23
begin
24
h:=A;
25
c:=to_integer(unsigned(B));
26
foriin0toN-1loop
27
ifi<cthen
28
h:='0'&h(N-1downto1);
29
endif;
30
endloop;
31
RES_LO<=h;
32
endprocess;
33
34
-- Number of Slices 75
35
-- Maximum combinational path delay: 10.912ns
36
process(A,B)
37
variableh:std_logic_vector(N-1downto0);
38
variablec:integerrange0toN:=0;
39
begin
40
h:=A;
41
c:=to_integer(unsigned(B));
42
foriin0toN-1loop
43
ifi=cthen
44
exit;
45
endif;
46
h:='0'&h(N-1downto1);
47
endloop;
48
RES_LO<=h;
49
endprocess;
50
51
-- Number of Slices 79
52
-- Maximum combinational path delay: 11.445ns
53
process(A,B)
54
variableh:std_logic_vector(N-1downto0);
55
variablec:integerrange0toN:=0;
56
begin
57
c:=to_integer(unsigned(B));
58
h:=(others=>'0');
59
h(N-1-cdownto0):=A(N-1downtoc);
60
RES_LO<=h;
61
endprocess;
62
63
-- Number of Slices 82
64
-- Maximum combinational path delay: 11.536ns
65
num<=to_integer(unsigned(B));
66
hlp<=x"00000000"&A;
67
RES_LO<=hlp(N-1+numdowntonum);
68
69
endbehv;
The last one can easily be changed to a rotate function:
For
process (A,B)
variable h : std_logic_vector(N-1 downto 0);
variable c : integer range 0 to N:=0;
begin
c := to_integer(unsigned(B));
h := (others=>'0');
h(N-1-c downto 0) := A(N-1 downto c);
RES_LO <= h;
end process;
I still have an error "right bound of range must be constant".
What else might it be
Here is the full code:
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_signed.all;
use work.pack.all;
-- this unit shift A bits number of B times to the right
-- if B is negative or zero the result is still A
-- the result is in res_shr
entity shrBbits is
port( A: in std_logic_vector(N-1 downto 0);
B: in std_logic_vector(N-1 downto 0);
RES_SHR:out std_logic_vector(N-1 downto 0)
);
end entity;
architecture behv of shrBbits is
begin
process (A,B)
variable h : std_logic_vector(N-1 downto 0);
variable c : integer range 0 to N:=0;
begin
c := conv_integer(unsigned(B));
h := (others=>'0');
h(N-1-c downto 0) := A(N-1 downto c);
RES_SHR <= h;
end process;
end behv;
Thanks for the help,
Miri
> Here is the full code:
Lets say: except the missing definition of N...
I changed the code a little:
1
entityshrBbitsis
2
generic(N:integer:=16);
3
port(....);
4
endentity;
> I still have an error "right bound of range must be constant".
What toolchain?
EDIT: too late... :-/
> I have this error while running Quartus
With Xilinx XST this works fine...
BTW: you did see this in my code?
1
libraryIEEE;
2
useIEEE.std_logic_1164.all;
3
useIEEE.numeric_std.all;
Yes? Think about it...
A hint: the Synopsys libs are obsolete a long time ago and superseeded
by the numeric_std.
BTW2: with
[ vhdl]
and
[ /vhdl]
(but without the blanks) and you can see a little magic:
I'm not sure, but I think the problem with Quartus is:
1
h(N-1-cdownto0):=A(N-1downtoc);
ISE and Lattice Diamond can handle this, but Quartus may have a problem
with this statement.
You could try to use a 'for i in 0 to N-1 loop' and assign just bitwise
This error on quartus:Error (10346): VHDL error at accumu.vhd(18):
formal port or parameter "m" must have actual or default value
What does it mean?
Here is my code:
Amina Amin wrote:> Here is my code
Why do you not use some indetion to get a kind of readable code...
> of course each i wrote each entity in a vhdl file
You can have it in one file also, thats no problem. Or you could attach
each of the files here, so it would be easier to find that line 18 in
accumu.vhd...
However: what about simply using the same names for the port signals in
the entity and in the port list?
1
u1:adder4portmap(a=>y,b=>x0,sel=>selpm,cout=>open,z=>1);-- a,b,sel,cout and z
2
3
entityadder4is
4
port(m,n:instd_logic_vector(3downto0);-- m,n,cin,cout and p