Error near "output": syntax error, unexpected output, expecting ')' - debugging

module rc_adder4 (
input logic[2:0]a, b
output logic[2:0] s,
output logic c_out
);
logic [3:0] c;
rc_adder_slice UUT[2:0] (
.a(a),
.b(b),
.c_in(c[2:0]),
.s(s),
.c_out(c[3:1])
);
// COMPLETE USING ARRAY INSTANCING
assign c[0] = 1'b0;// COMPLETE
assign c_out = c[3];// COMPLETE
endmodule
I tried to run this part, but it said:
near "output": syntax error, unexpected output, expecting ')'
Can anyone help me please?

The simulator I use gives a more meaningful error message:
output logic[2:0] s,
|
xmvlog: *E,POLICI: Expecting a comma between adjacent port declarations.
This is telling you that you need to separate all signals with commas, and you are missing the comma between the last input and first output.
Change:
input logic[2:0]a, b
to:
input logic[2:0]a, b,
// ^
Sometimes different simulators can give you more helpful messages. You can sign up for a free account on edaplaygroud to get access to several simulators.

Related

GAMS if-else syntax

if (a(i,j) gt 0,
z(i,j) eq 0;
else
z(i,j) eq 1;
);
equations
kapasite_asker(i)
kapasite_silah(i,k)
talep_asker1(j)
talep_asker2(j)
talep_silah1(j)
talep_silah2(j)
atama_asker(i)
atama_silah(i)
agirlik(i,j)
risk
amac
;
kapasite_asker(i).. sum(j,a(i,j))=L=y(i)*c(i);
kapasite_silah(i,k).. sum(j,x(i,j,k))=L=m(i,k)*f(i);
talep_asker1(j).. sum(i,z(i,j))=E=1;
talep_asker2(j).. sum(i,a(i,j))=E=g(j);
talep_silah1(j).. sum(i,e(i,j))=E=1;
talep_silah2(j).. sum((i,k),x(i,j,k))=E=sum(k,n(j,k));
agirlik(i,j).. sum(k,x(i,j,k)*v(k))=L=t(i,j);
risk.. sum((i,j),(z(i,j)*r(i,j)+e(i,j)*r(i,j)))=L=25*sum((i,j),z(i,j)+e(i,j));
amac.. sum(i,f(i)+y(i))=E=p;
atama_asker(i).. sum(j,z(i,j))=L=11*y(i);
atama_silah(i).. sum(j,e(i,j))=L=11*f(i);
Error 143
A suffix is missing
Error 141
Symbol declared but no values have been assigned. Check for missing
data definition, assignment, data loading or implicit assignment
via a solve statement.
A wild shot: You may have spurious commas in the explanatory
text of a declaration. Check symbol reference list.
Error 149
Uncontrolled set entered as constant
Error 10
',' expected
Error 140
Unknown symbol
Error 36
'=' or '..' or ':=' or '$=' operator expected
rest of statement ignored
Error 409 in
Unrecognizable item skip to find a new statement
looking for a ';' or a key word to get started again
I'm new to GAMS. The code I wrote gives an error. 'a' in the code is an integer variable and z is a binary variable. How can I fix it? Or how do I connect these two variables? Thanks in advance.
wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
Since a and z are both variables, the if-else statement is not good to use for their assignment. You can use big-M method and add two constraints for such a logic:
-Mz <= a <= M(1-z) - eps, where M is a positive scalar, and eps is a sufficient small number by default.

SPS/ TwinCat/ Syntax Error-Code/ Declaration of TON and TOF

I am currently programming in ST (TwinCat), but two errors occured, which I do not understand at all.
Error-Code says:
(1) (TRUE AND TON_01.Q) is no valid assignment target
(2) Q is no input of TOF
I already declared Q as my Output , but TON and TOF cannot handle it. The Code and the Error is attached to the post. enter image description here
Thank you for your Help.
The problem is that you are doing an assignment of TOF_01.Q and not a check.
So instead of:
IF TOF_01.Q := TRUE ... it should be
IF TOF_01.Q = TRUE ... or simply
IF TOF_01.Q...
Same with TON_01.Q obviously.

Need an example of Record Syntax in mercury

I am new to mercury and am trying to wrap my head around Record Syntax, but the Reference Manual is the only place I have encountered it and it leaves me mystified:
Term ^ field1(Arg1) ^ field2(Arg2, Arg3) is equivalent to field2(Arg2, Arg3, field1(Arg1, Term)).
Could someone please help with a real-world example?
Record syntax is a syntax sugar, and the manual is trying to explain how the
transformation from record syntax into Mercury's normal syntax works. This
is fine if you're trying to find out how to implement record syntax, but not
very helpful if you want to learn how to use it.
I recommend ignoring the (Arg1, ...) stuff in the parenthesis - I'm not
sure if it's actually part of the syntax and I've never seen anyone use it.
Lets create a structure representing points on a Cartesian plane.
:- type point
---> point(
pt_x :: int,
pt_y :: int
).
pt_x and pt_y are field names they allow us to retrieve the values of a
point's fields. For example:
format("The point's X coordinate is: %d\n", [i(Point ^ pt_x)], !IO),
format("The point's Y coordinate is: %d\n", [i(Point ^ pt_y)], !IO),
We can retrieve a value and assign it to a new variable.
X = Point ^ pt_x,
And we can also update one field without having to write out the whole point
again.
NewPoint = OldPoint ^ pt_y := NewY,
Where things get a little bit more complicated is when this is used with
state variable notation, there's an extra syntax sugar that occurs.
move_up(D, !Point) :-
NewY = !.Point ^ pt_y + D,
!Point ^ pt_y := NewY.
Note that when we read a value we use !.Point, which is the state variable
for "the current value". And when we updated it we could have written:
!:Point = !.Point ^ pt_y := NewY.
However this extra syntax sugar allows us to write:
!Point ^ pt_y := NewY.
I hope this helps. There are many more examples throughout the Mercury
source code:
https://github.com/Mercury-Language/mercury
and ohther Mercury projects, note that the github language tagging is
broken, many Objective-C files are detected as Mercury and many Mercury
things are detected as other files:
https://github.com/search?utf8=%E2%9C%93&q=language%3AMercury&type=Repositories&ref=advsearch&l=Mercury

I have an issue: expected but identifier found and compilation aborted

I will do an exam tomorrow, but now I can't run it, can anyone help me?? Thanks!!
program v2
uses
crt;
var
t, dongia: real;
begin
clrscr;
write('nhap t='); readln(t);
if dongia >= 100000 then
t:= 70 / 100 * dongia;
writeln('in don gia:'t);
readln;
end.
Add a semi colon (;) after the program name (so v2;)
Add a comma between the string literal and "t", so ( 'in don gia:',t )
as Roy says in the comments, the logic of your program is wrong. Dongia is uninitialized before the check.
Next time, add a problem description including errormessages and show that you spent some effort/thought in finding the problem.
Put parentheses around the IF condition:
if (dongia>=100000) then
and you should also put a comma in the writeln:
writeln('in don gia:', t);

VHDL for loop type error and shift error

I'm trying to write a for loop in VHDL, but I believe there is some type issue in the loop statement. I have a block that receives a 16-bit word, A, as input that indicates the number times I should shift another input, B. The output, C, shows the shifted version of B. My code looks like this:
TEMP_C := B;
FOR I IN 1 TO UNSIGNED(A) LOOP
TEMP_C := TEMP_C(15) & TEMP_C(15 DOWNTO 1);
END LOOP;
C <= TEMP_C;
The compiler is complaining about the second line, and says "Range left bound type Integer is not the same as right bound type". Can someone explain to me why this line is wrong, and how do I fix it?
On the left side you have '1', being an 'integer'. On the right side you have 'unsigned(std_logic_vector?)', being an 'unsigned'. An unsigned is still not the same as an 'integer'. An unsigned is still a collection of bits. Here for more info about 'unsigned'.
Anyhow this solution will help you more...
FOR I IN 1 TO to_integer(UNSIGNED(A)) LOOP
An unsigned vector is not the same as an integer. This is not Verilog!

Resources