KMLM List
View email archives for the history of this mailing list.
|
|
|
|
systemc-forum - RE: [systemc-forum] problem of value's update...
|
Message Thread:
Previous |
Next
|
- To: <systemc-forum@xxxxxxxxxxxxxxxxx>
- From: "Timothy Fanelli" <tfanelli@xxxxxxxxxxxx>
- Date: Tue, 1 Dec 2009 09:50:39 -0500
- Send Email to systemc-forum@lists.systemc.org:
- Send new message
- Reply to this message
|
** Sorry if many of you got this twice, I replied to the wrong forum originally
(help forum) - wanted to make sure it got back to the right place **
Dhekra,
I assume here that Q2, Q1 and U2 are ports in a module? What you are seeing is
the effects of a "delayed update" - even though you appear to have written a
new value to Q2, it will retain its new value until the next delta cycle (in
other words, new values are assigned during the update cycle at the end of each
processing cycle).
There are two ways I see to work around this in your problem:
1) Assign (Q2.read() + Q1.read()) to some local variable in your method, then
write that variable to Q2 and use it in the calculation of the value written to
U2 as well. For example:
int temp = Q2.read() + Q1.read();
Q2.write( temp ) ;
U2.write(C2.read()*temp);
2) (IF you're implementing an SC_THREAD or SC_CTHREAD, this /should/ work, but
not recommended other than to learn about the delta-cycles and how they work):
Force an update-cycle delay by inserting a wait(SC_ZERO_TIME) statement in
between the two write statements. This will not advance simulation time, but
rather will cause the current thread to block and wait until an update-cycle
occurs, then pick up and execute again. There may be other unintended
consequences later depending on the complexity of your model. It is also not a
realistic thing to do if you are doing hardware design. But, for educational
purposes when I first started learning SystemC, it was interesting to play with
to get a hang for the update-cycle delays.
Thanks,
Timothy C. Fanelli
Instructor, PhD Student
Software Engineering
Department of Electrical and Computer Engineering
Clarkson University, Potsdam, NY 13699
On Dec 1, 2009, at 8:53 AM, KEDIDI DHEKRA wrote:
Hi again!
I have another problem when simulation:
When I put in my code:
Q2.write( Q2.read()+ Q1.read() ) ;
U2.write(C2.read()*Q2.read());}
in simulation the value of U2 is calculated with the previous value of Q2 not
the new value calculated in the equation:Q2.write( Q2.read()+ Q1.read() ) ;
how to solve this porblem??
thanks a lot...
best regards
Dhekra
|
|
By Date:
Previous |
Next
|
Current Thread
|
By Thread:
Previous |
Next
|
- RE: [systemc-forum] problem of value's update, Timothy Fanelli (you are here)
|
|