EmbDev.net

Forum: FPGA, VHDL & Verilog Verilog task yield "x" for a variable in a timestep


von Frank L. (Company: HIT) (frankli998)


Attached files:

Rate this post
useful
not useful
Hi!
In Modelsim SE 10.1a, I tried to code a counter which counts from 0 to 
118 again and again. When the counter reaches #40 and #59, port ctl_1 
and ctl_2 each delivers "1" for 4 period of clocks. Below is my 
code(also attached from files).

But when I simulate, at #40 ctl_1 becomes "x" instead of "1", meanwhile, 
the similar #59 functions just right(wave.jpg shows that). Below is my 
module code. Using tasks is just for the purpose of studying, when I 
give up using task and simply use NBA such as ctl_1 <= 1, the problem 
disappears. Can anyone give any hints? Thanks!

: Edited by User
von ElKo (Guest)


Rate this post
useful
not useful
Does it work, if you assign the values directly, without using the 
tasks?

von Frank L. (Company: HIT) (frankli998)


Rate this post
useful
not useful
Yes, it does. Without using task, use nonblocking assignment instead, 
everything works fine.

von Andy (Guest)


Rate this post
useful
not useful
Have you tried to define the tasks before you us it in the code?
Not sure if it makes any difference, but it looks like the output is 
undefined only on the first call of each task.

von Frank L. (Company: HIT) (frankli998)


Rate this post
useful
not useful
The strange thing is that I define ctl_on and ctl_off, #40 does not 
function right but #59 does, I have no idea what's going on...

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.