Global declarations are illegal in Verilog 2001 syntax! - syntax

I have written something small in verilog:
`define LW 6'b100011
`define SW 6'b101011
parameter [3:0]
i_fetch = 4'b0001,
decode_rr = 4'b0010,
mem_addr = 4'b0100,
alu_exec = 4'b1000;
and i am getting this error: Error: test.v(5): (vlog-2155) Global declarations are illegal in Verilog 2001 syntax.
What I am doing wrong? I am using ModelSim XE III/Starter 6.4b - Custom Xilinx Version!

Your parameter statement has to be within a module:
module a_module ();
parameter a_parameter = 4;
endmodule
In fact, most stuff in verilog has to be within a module block.

Related

Loading variable addresses into registers PowerPC inline Assembly

I am trying to put together and example of coding inline assembly code in a 'C' program. I have not had any success. I am using GCC 4.9.0. As near as I can tell my syntax is correct. However the build blows up with the following errors:
/tmp/ccqC2wtq.s:48: Error: syntax error; found `(', expected `,'
Makefile:51: recipe for target 'all' failed
/tmp/ccqC2wtq.s:48: Error: junk at end of line: `(31)'
/tmp/ccqC2wtq.s:49: Error: syntax error; found `(', expected `,'
/tmp/ccqC2wtq.s:49: Error: junk at end of line: `(9)'
These are related to the input/output/clobbers lines in the code. Anyone have an idea where I went wrong?
asm volatile("li 7, %0\n" // load destination address
"li 8, %1\n" // load source address
"li 9, 100\n" // load count
// save source address for return
"mr 3,7\n"
// prepare for loop
"subi 8,8,1\n"
"subi 9,9,1\n"
// perform copy
"1:\n"
"lbzu 10,2(8)\n"
"stbu 10,2(7)\n"
"subi 9,9,1\n" // Decrement the count
"bne 1b\n" // If zero, we've finished
"blr\n"
: // no outputs
: "m" (array), "m" (stringArray)
: "r7", "r8"
);
It's not clear what you are trying to do with the initial instructions:
li 7, %0
li 8, %1
Do you want to load the address of the variables into those registers? In general, this is not possible because the address is not representable in an immediate operand. The easiest way out is to avoid using r7 and r8, and instead use %0 and %1 directly as the register names. It seems that you want to use these registers as base addresses, so you should use the b constraint:
: "b" (array), "b" (stringArray)
Then GCC will take care of the details of materializing the address in a suitable fashion.
You cannot return using blr from inline assembler because it's not possible to tear down the stack frame GCC created. You also need to double-check the clobbers and make sure that you list all the things you clobber (including condition codes, memory, and overwritten input operands).
I was able to get this working by declaring a pair of pointers and initializing them with the addresses of the arrays. I didn't realize that the addresses wouldn't be available directly. I've used inline assembly very sparsely in the past, usually just
to raise or lower interrupt masks, not to do anything that references variables. I just
had some folks who wanted an example. And the "blr" was leftover when I copied a
snipet of a pure assembly routine to use as a starting point. Thanks for the responses.
The final code piece looks like this:
int main()
{
char * stringArrayPtr;
unsigned char * myArrayPtr;
unsigned char myArray[100];
stringArrayPtr = (char *)&stringArray;
myArrayPtr = myArray;
asm volatile(
"lwz 7,%[myArrayPtr]\n" // load destination address
"lwz 8, %[stringArrayPtr]\n" // load source address
"li 9, 100\n" // load count
"mr 3,7\n" // save source address for return
"subi 8,8,1\n" // prepare for loop
"subi 9,9,1\n"
"1:\n" // perform copy
"lbzu 10,1(8)\n"
"stbu 10,1(7)\n"
"subic. 9,9,1\n" // Decrement the count
"bne 1b\n" // If zero, we've finished
// The outputs / inputs / clobbered list
// No output variables are specified here
// See GCC documentation on extended assembly for details.
:
: [stringArrayPtr] "m" (stringArrayPtr), [myArrayPtr]"m"(myArrayPtr)
: "7","8","9","10"
);
}

Attributes was ignored by XST and synplify pro

I'm using ISE 14.7 , synplify pro 2013.03 and modelsim 10.2c; now I having a problem about keeping a signal's name after synthesis and place&route in ISE and synplify. I used attribute keep and keep_hierarchy in XST,and syn_keep in synplify pro,but some reg was modified in XST after place&route;and all of reg was modified
in synplify,It seems my attributes was ignored in these tools,my code is in follow,can you help me?
attribute keep : string;
attribute keep of wr_adr_ram_1,rd_adr_ram_1 : signal is "true";
attribute keep_hierarchy : string;
attribute keep_hierarchy of Behavioral : architecture is "true";

Fortran error #5082: Syntax error, found IDENTIFIER when expecting one of: <END-OF-STATEMENT> ;

I am "making" a code.
The compilation with make fails producing this error
mpif90 -mkl -O3 -no-prec-div -fpp -openmp -xHost -DMPI -DEFTCOSMOMC -module ReleaseEFTMPI -IReleaseEFTMPI/ -c equations_EFT.f90 -o ReleaseEFTMPI/equations_EFT.o
equations_EFT.f90(267): error #5082: Syntax error, found IDENTIFIER 'EFTCAMBINITIALCONDITIONS' when expecting one of: <END-OF-STATEMENT> ;
module subroutine EFTCAMBInitialConditions( y, EV, tau )
--------------------------^
equations_EFT.f90(267): error #5082: Syntax error, found END-OF-STATEMENT when expecting one of: ( % [ . = =>
module subroutine EFTCAMBInitialConditions( y, EV, tau )
----------------------------------------------------------------^
equations_EFT.f90(271): error #6786: This is an invalid statement; an END [MODULE] statement is required.
end subroutine EFTCAMBInitialConditions
--------^
equations_EFT.f90(271): error #6758: This name is invalid; if a name is present, it must match the corresponding interface body name. [EFTCAMBINITIALCONDITIONS]
end subroutine EFTCAMBInitialConditions
-----------------------^
equations_EFT.f90(268): error #6457: This derived type name has not been declared. [EVOLUTIONVARS]
type(EvolutionVars) EV
-----------------^
equations_EFT.f90(269): error #6683: A kind type parameter must be a compile-time constant. [DL]
real(dl) :: y(EV%nvar)
-----------------^
equations_EFT.f90(269): error #6535: This variable or component must be of a derived or structure type [EV]
real(dl) :: y(EV%nvar)
--------------------------^
equations_EFT.f90(269): error #6460: This is not a field name that is defined in the encompassing structure. [NVAR]
real(dl) :: y(EV%nvar)
-----------------------------^
equations_EFT.f90(269): error #6223: A specification expression is invalid. [NVAR]
real(dl) :: y(EV%nvar)
-----------------------------^
equations_EFT.f90(270): error #6683: A kind type parameter must be a compile-time constant. [DL]
real(dl) :: tau
-----------------^
equations_EFT.f90(269): error #6279: A specification expression object must be a dummy argument, a COMMON block object, or an object accessible through host or use association [EV]
real(dl) :: y(EV%nvar)
--------------------------^
compilation aborted for equations_EFT.f90 (code 1)
I attach the snippet from equations_EFT.f90
interface
module subroutine EFTCAMBInitialConditions( y, EV, tau )
type(EvolutionVars) EV
real(dl) :: y(EV%nvar)
real(dl) :: tau
end subroutine EFTCAMBInitialConditions
end interface
Is there something wrong in this snippet? It is strange because this is distributed software, but I have literally just followed the instruction to make the code.
The code of the question is an example of using submodules, a feature newly introduced into Fortran in the 2008 revision. To compile this code you will need a compiler which understands this concept.
The GNU and Intel compilers are examples of such, but you will need an appropriate version.

Eiffel - Don't know why I have syntax error

I'm new to Eiffel and I'm trying to create a simple class called "Monomio", I have 3 features that are attributes and a feature that's a function. The problem is that I'm getting a syntax error, I compared it to other classes I found but can't find the error here. This is my code
class
MONOMIO
create
make
feature {NONE} -- Initialization
make
-- Initialization for `Current'.
do
end;
coeficiente: INTEGER;
-- El número que será el coeficiente del monomio
exponenteX: INTEGER;
-- El exponente de la variable X
exponenteY: INTEGER;
-- El exponente de la variable Y
evaluar(valX: INTEGER; valY: INTEGER): INTEGER is
do
Result := coeficiente*(valX^expX)*(valY^expY)
end;
end
And this is the error I'm getting:
Syntax error at line 28 in class MONOMIO
evaluar(valX: INTEGER; valY: INTEGER): INTEGER is
---------------------------------------------^
do
I hope anyone can help me with this. Thanks.
I think the problem is the keyword "is". This has been deprecated, and if you are compiling with standard syntax (as you will be by default), then it is an error.
Just remove "is".
The problem of "syntax error" as an uninformative error message is one I have long been complaining about. It is entirely fixable, and no compiler should use it.

OpenMP error in Fortran

I am trying to execute the inner double loop in parallel (in serial there is no problem):
DO J=1,NY
DO I=1,NX
A2=0.0d0
A1=S(I,J)
A2=dble(S(IP(I),J)+S(IM(I),J)+S(I,JP(J))+S(I,JM(J)))
EL=0.0d0
!$OMP parallel DO SHARED(LAMDA,S,COUL) PRIVATE(I1,J1) reduction(+:EL)
DO J1=1,NY
DO I1=1,NX
IF ((J1/=J.OR.I1/=I).AND.(J1/=J.OR.I1/=IP(I)).AND.(J1/=J.OR.I1/=IM(I)).AND.(J1/=JP(J).OR.I1/=I).AND.(J1/=JM(J).OR.I1/=I)) THEN
IF (ABS(FLOAT(I)-FLOAT(I1)) <= ABS(FLOAT(I)+LEN-FLOAT(I1))) THEN
ID= INT(ABS(FLOAT(I)-FLOAT(I1)))
ELSE
ID= INT(ABS(FLOAT(I)+LEN-FLOAT(I1)))
END IF
IF (ABS(FLOAT(J)-FLOAT(J1)) <= ABS(FLOAT(J)+LEN-FLOAT(J1))) THEN
JD= INT(ABS(FLOAT(J)-FLOAT(J1)))
ELSE
JD= INT(ABS(FLOAT(J)+LEN-FLOAT(J1)))
END IF
EL=EL + LAMDA*COUL(ID,JD)*dble(S(I1,J1))
END IF
END DO
END DO
!$OMP END PARALLEL DO
....
where COUL(ID,JD) is a matrix that has been computed earlier in the code, LAMDA a parameter and the matrices S, IP etc. have all known values.
When I compile it (Intel Fortran) I get the following weird errors:
error #7655: A variable is required in this OpenMP* context. [3.0D0]
error #7656: Subobjects are not allowed in this OpenMP* clause; a named variable must be specified.
Anyone has any idea about these errors? The funny thing is that I wrote a simple program just doing these loops, and it works fine in parallel with the above OpenMP statements.

Resources