Is it a bug of synplify?

K

Kot

I'm using Synplify for Actel ProASIC.
I was writing a portion of design where I just have to
put some registers that acts like some memory to CPU.
It did not work and after simplifying some section of code
to see if the synthesis tool is doing what it is supposed to do,
I found this -- look at the codes in "mypak".
when the constants are defined using plain literal, it synthesize
with no problem. But when the constant values are defined
using function provided by 1164 package then it does not work.
Is it a bug? or I misunderstood VHDL?

-- emailing your knowledge/opinion directly to me is more welcome ;-)

Jihwan
(e-mail address removed)


library ieee;
use ieee.std_logic_1164.all;

package mypak is
subtype addrword is std_logic_vector(3 downto 0);
subtype appword is std_logic;

-- it works this way
--constant aa_reg1 : addrword := "0010";
--constant aa_reg2 : addrword := "0101";
--constant aa_reg3 : addrword := "1010";

-- but not in this way. why?
constant aa_reg1 : addrword := to_x01(x"2");
constant aa_reg2 : addrword := to_x01(x"5");
constant aa_reg3 : addrword := to_x01(x"a");
end package mypak;


library ieee;
use ieee.std_logic_1164.all;
use work.mypak.all;

entity test is
port(
ad : in addrword;
nce : in std_logic;
nwr : in std_logic;
da : inout appword;
q1 : out appword;
q2 : out appword;
q3 : out appword
);
end entity test;

architecture a1 of test is

signal reg1, reg2, reg3 : appword;

begin
q1 <= reg1;
q2 <= reg2;
q3 <= reg3;
process (nce, nwr, ad)
begin
if nce = '0' then
if rising_edge(nwr) then
if ad = aa_reg1 then
reg1 <= da;
elsif ad = aa_reg2 then
reg2 <= da;
elsif ad = aa_reg3 then
reg3 <= da;
end if;
end if;
end if;
end process;
end architecture a1;
 
C

Christian Schneider

See comments below

I'm using Synplify for Actel ProASIC.
I was writing a portion of design where I just have to
put some registers that acts like some memory to CPU.
It did not work and after simplifying some section of code
to see if the synthesis tool is doing what it is supposed to do,
I found this -- look at the codes in "mypak".
when the constants are defined using plain literal, it synthesize
with no problem. But when the constant values are defined
using function provided by 1164 package then it does not work.
Is it a bug? or I misunderstood VHDL?

-- emailing your knowledge/opinion directly to me is more welcome ;-)

Jihwan
(e-mail address removed)


library ieee;
use ieee.std_logic_1164.all;

package mypak is
subtype addrword is std_logic_vector(3 downto 0);
subtype appword is std_logic;

-- it works this way
--constant aa_reg1 : addrword := "0010";
--constant aa_reg2 : addrword := "0101";
--constant aa_reg3 : addrword := "1010";

-- but not in this way. why?
constant aa_reg1 : addrword := to_x01(x"2");
constant aa_reg2 : addrword := to_x01(x"5");
constant aa_reg3 : addrword := to_x01(x"a");

Try this:

constant aa_reg1: addrword := X"2";

and so on ..
end package mypak;


library ieee;
use ieee.std_logic_1164.all;
use work.mypak.all;

entity test is
port(
ad : in addrword;
nce : in std_logic;
nwr : in std_logic;
da : inout appword;
q1 : out appword;
q2 : out appword;
q3 : out appword
);
end entity test;

architecture a1 of test is

signal reg1, reg2, reg3 : appword;

begin
q1 <= reg1;
q2 <= reg2;
q3 <= reg3;

process (nce, nwr, ad)
begin
if nce = '0' then
if rising_edge(nwr) then
if ad = aa_reg1 then
reg1 <= da;
elsif ad = aa_reg2 then
reg2 <= da;
elsif ad = aa_reg3 then
reg3 <= da;
end if;
end if;
end if;
end process;

You use the nwr as a clock signal this is ok, but what about the nce?
This may cause the problem. Because the tool may not understand what you
want, and I am also not sure. So let's suppose that the nce is the clock
enable signal or chip select:

Try this:

process (nwr)
begin
if rising_edge(nwr) then
if nce = '0' then
if ad = aa_reg1 then
reg1 <= da;
elsif ad = aa_reg2 then
reg2 <= da;
elsif ad = aa_reg3 then
reg3 <= da;
end if;
end if;
end if;
end process;

This will give you registers which are clocked with nwr and nce as
enable signal. There will generate an address decoder and a multiplexer
or priority encoder that selects the signal dependant on the address.

end architecture a1;

Chris
 
M

Mike Treseler

Kot said:
when the constants are defined using plain literal, it synthesize
with no problem. But when the constant values are defined
using function provided by 1164 package then it does not work.
Is it a bug? or I misunderstood VHDL? ....
-- but not in this way. why?
constant aa_reg1 : addrword := to_x01(x"2");

Because to_x01 is defined for multiple vector types.

There is no reason to use to_x01 to
declare a constant, so consider:

constant aa_reg1 : addrword := x"2";

If to_x01 were required, you would have to say:

constant aa_reg1 : addrword := to_x01(addrword'(x"2"));

But you don't.

Consider simulation before synthesis.

-- Mike Treseler
 
K

Kot

Thank you, Mike & Chris.

I've tried 4 different ways.
Here's result if you'd like to know.
I understand that there's no single vendor who
support full definition of VHDL language but
I guess this may be a bug even within the VHDL subset
that Simplify supports.

Jihwan Song

-- mypak
-- T10.vhd
-- going back to T1.vhd

library ieee;
use ieee.std_logic_1164.all;

package mypak is
subtype addrword is std_logic_vector(3 downto 0);
subtype appword is std_logic;

-- it works this way
--constant aa_reg1 : addrword := "0010";
--constant aa_reg2 : addrword := "0101";
--constant aa_reg3 : addrword := "1010";

-- but in this way. why?
--constant aa_reg1 : addrword := to_x01(x"2");
--constant aa_reg2 : addrword := to_x01(x"5");
--constant aa_reg3 : addrword := to_x01(x"a");

-- this works too.
constant aa_reg1 : addrword := X"2";
constant aa_reg2 : addrword := X"5";
constant aa_reg3 : addrword := X"a";

-- look at the decl. section of architecture a1 : another way around
end package mypak;


-- T10.vhd
-- going back to T1.vhd

library ieee;
use ieee.std_logic_1164.all;
use work.mypak.all;

entity test is
port(
ad : in addrword;
nce : in std_logic;
nwr : in std_logic;
da : inout appword;
q1 : out appword;
q2 : out appword;
q3 : out appword
);
end entity test;

architecture a1 of test is

signal reg1, reg2, reg3 : appword;

-- this works too!
--constant aa_reg1 : addrword := to_x01(x"2");
--constant aa_reg2 : addrword := to_x01(x"5");
--constant aa_reg3 : addrword := to_x01(x"a");

begin
q1 <= reg1;
q2 <= reg2;
q3 <= reg3;
process (nce, nwr, ad)
begin
if nce = '0' then
if rising_edge(nwr) then
if ad = aa_reg1 then
reg1 <= da;
elsif ad = aa_reg2 then
reg2 <= da;
elsif ad = aa_reg3 then
reg3 <= da;
end if;
end if;
end if;
end process;
end architecture a1;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top