Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Unexpected token error in a code

Status
Not open for further replies.

andrew257

Member level 2
Joined
Feb 22, 2007
Messages
42
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,648
unexpected token

what is wrong with following code? i keep getting an unexpected token error message pointing to the condition statement, something to do with '=' ?????

reg count = 16;

always @ (posedge clk)
begin

if (start)

count = (count > 0) ? count-1 : count =16;
else
count = 16;

end
 

Re: unexpected token

from definition, count can't receive other values than 0 or 1.
Try reg [4:0] count
 

Re: unexpected token

actually that was a typo in my haste to post the problem.

my code actually has it assigned as a 5 bit reg.

reg [4:0] count = 16;

always @ (posedge clk)
begin

if (start)

count = (count > 0) ? count-1 : count =16;
else
count = 16;

end

now call me stupid but i cant see anything wrong with this code. ITs indicating its the " = " on the following line.

count = (count > 0) ? count-1 : count =16;

unexpected token???????
 

Re: unexpected token

O.K., I see
count = (count > 0) ? count-1 :16;
37_1203244374.gif
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top