...
..
type ram_t is protected
function read(a : natural) return std_logic_vector;
procedure write(a : natural; d : std_logic_vector);
end protected type ram_t;
type ram_t is protected body
type ram_array_t is array(0 to 127) of std_logic_vector(7 downto
0);
variable ram_array : ram_array_t;
function read(a : natural) return std_logic_vector is
begin
return ram_array(a);
end function read;
procedure write(a : natural; d : std_logic_vector) is
begin
ram_array(a) := d;
end procedure write;
end protected type ram_t;
shared variable ram : ram_t;
mmmm, not sure which version of Modelsim you are using but my 6.5b version
complained bitterly and told me to get some more coffee..
After some quick hacking I changed the code into:
type ram_t is protected -- Error in PS
impure function read(a : natural) return std_logic_vector;
procedure write(a : natural; d : std_logic_vector);
end protected ram_t;
type ram_t is protected body
type ram_array_t is array(0 to 127) of std_logic_vector(7 downto 0);
variable ram_array : ram_array_t;
impure function read(a : natural) return std_logic_vector is
begin
return ram_array(a);
end function read;
procedure write(a : natural; d : std_logic_vector) is
begin
ram_array(a) := d;
end procedure write;
end protected body ram_t;
Unfortunately it didn't go through Precision although this might be due to
me screwing up the code.
[40000]: vhdlorder, Release 2009a.15
[40000]: Syntax error at or near "protected"
[40000]: VHDL file ordering failed.
Hanswww.ht-lab.com
You need to compile with the -2000 option, not -93. Protected types
were not introduced until VHDL 2000
I did and I get:
D:\test\shared_var>vcom shared_tricky.vhd -2002
Model Technology ModelSim SE vcom 6.5b Compiler 2009.05 May 21 2009
-- Loading package standard
-- Loading package std_logic_1164
-- Compiling entity test_build
-- Compiling architecture syn of test_build
** Error: shared_tricky.vhd(28): near "type": expecting ';'
** Error: shared_tricky.vhd(30): Subprogram "read" parameter name
"_impliedOperand_ram_t" does not conform bet
ween subprogram declaration and subprogram body (declaration has "a").
** Error: shared_tricky.vhd(30): Subprogram "read" parameter
"_impliedOperand_ram_t" class does not conform be
tween subprogram declaration and subprogram body.
** Error: shared_tricky.vhd(30): Subprogram "read" parameter
"_impliedOperand_ram_t" mode INOUT does not confo
rm between subprogram declaration and subprogram body (declaration has IN).
** Error: shared_tricky.vhd(30): Subprogram "read" parameter
"_impliedOperand_ram_t" type does not conform bet
ween subprogram declaration and subprogram body.
** Error: shared_tricky.vhd(34): VHDL Compiler exiting
As for the protected type - I just realised I probably meant to find
out what other synthesisors do with access types.
So, in the origional code (without protected types), replace the type/
shared variable declaration with this:
type ram_t;
type ram_t_p is access ram_t;
type ram_t is array(0 to 127) of std_logic_vector(7 downto 0);
shared variable ram : ram_t_p := new ram_t;
Then run it through precision and see what it makes of it all - as I
said quartus just ignored it - not even a warning that it's a bad idea.
Precision doesn't seem to like it and reports:
[40000]: vhdlorder, Release 2009a.15
[40000]: Files sorted successfully.
[40000]: hdl-analyze, Release RTLC-Precision 2009a.15
[42502]: Analyzing input file "D:/hdl_designs/test/shared_var/shared_var3.vhd"
....
[43156]: Shared variables must be of a protected type.
[651]: Top module of the design is set to: test_build.
[649]: Current working directory: <...>/shared_var/project_5_impl_1.
[40000]: RTLC-Driver, Release RTLC-Precision 2009a.15
[40000]: Last compiled on Mar 18 2009 18:40:36
[44512]: Initializing...
[44504]: Partitioning design ....
[40000]: RTLCompiler, Release RTLC-Precision 2009a.15
[40000]: Last compiled on Mar 18 2009 19:20:03
[44512]: Initializing...
[44522]: Root Module work.test_build(syn): Pre-processing...
[45258]: Object ram is of Non-Rtl type ram_t_p. Declaration wont be compiled.
[46831]: Object ram of Non-Rtl type ram_t_p not handled. Continuing ...
[46292]: Module work.test_build(syn) cannot be compiled because it contains
non-rtl constructs. Please check the log for warnings or errors about
non-synthesizable constructs in this module.
[44536]: No modules were compiled in this run of RTLC, please check the logs for
blackboxes or non-rtl constructs in the design.
[44856]: Total lines of RTL compiled: 70.
[47002]: RTLCompiler error... aborting compilation.
[44513]: Overall running time 1.0 secs.
[46259]: Design compilation failed, unsupported or non-rtl constructs detected
in the following modules :
[40000]: work.test_build(syn)
[40000]: Please check the log for details pertaining to unsupported or non-rtl
construct(s)
[666]: Unable to elaborate design work.test_build in vhdl.
Regards,
Hans.
www.ht-lab.com