Instruction MD=D-1

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Instruction MD=D-1

Clive Barker
Hi

When running the test CPU-external.tst I get a successful run through the test script OK. However, I noticed while debugging that this instruction worked oddly.

Before the instruction, D register was at value 11111. Address register was 1001

After the instruction executed, D register changed to 11110, but 11109 was written to memory address 1001.
I think the mechanism was that the ALU was continuously calculating D-1, so that as soon as D changed, then  the new value of D-1 was presented to memory. Logically, MD=D-1 does depend on which gets executed first!

Are there any others who have stumbled on this?  
Reply | Threaded
Open this post in threaded view
|

Re: Instruction MD=D-1

cadet1620
Administrator
Clive Barker wrote
When running the test CPU-external.tst I get a successful run through the test script OK. However, I noticed while debugging that this instruction worked oddly.

Before the instruction, D register was at value 11111. Address register was 1001

After the instruction executed, D register changed to 11110, but 11109 was written to memory address 1001.
I think the mechanism was that the ALU was continuously calculating D-1, so that as soon as D changed, then  the new value of D-1 was presented to memory. Logically, MD=D-1 does depend on which gets executed first!
Did the 11109 get stored in RAM? It's OK for 11109 to appear on the outM bus in the later half of the instruction cycle after the memory write occurred that wrote 11110 to RAM.

If 11109 is being written to RAM, there is some problem with your CPU or Memory HDL. If you care to send your HDL to me I'll take a look at it.

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: Instruction MD=D-1

Clive Barker
Thankyou Mark

Yes I think it did get written because the write signal was still active at the end of the cycle. Have not implemented memory yet. I will send the HDL code later and would appreciate your having a look..having trouble registering at the moment!

Regards
Clive
Reply | Threaded
Open this post in threaded view
|

Re: Instruction MD=D-1

cadet1620
Administrator
You may email me directly at
   

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: Instruction MD=D-1

cadet1620
Administrator
In reply to this post by Clive Barker
Executing the MD=D-1 instruction multiple times gives this output from the simulator. This makes it easier to see what's happening and when.

|time| inM  |  instruction   |reset| outM  |writeM |addre| pc  |DRegiste|

|7+  |     0|1110001110011000|  0  |  11110|   1   | 1001|    7|  11110 |
|8   |     0|1110001110011000|  0  |  11109|   1   | 1001|    8|  11110 |

|8+  |     0|1110001110011000|  0  |  11109|   1   | 1001|    8|  11109 |
|9   |     0|1110001110011000|  0  |  11108|   1   | 1001|    9|  11109 |

|9+  |     0|1110001110011000|  0  |  11108|   1   | 1001|    9|  11108 |
|10  |     0|1110001110011000|  0  |  11107|   1   | 1001|   10|  11108 |

Time 7+ shows the signal values immediately before the instruction executes. outM is the value that is presented to the RAM to be stored.

The clock event occurs between times 7+ and 8, and the RAM stores the outM value since writeM is true.

Time 8 shows the signal values immediately after the instruction executes. The value on writeM does not get written to RAM.

--Mark

Reply | Threaded
Open this post in threaded view
|

Re: Instruction MD=D-1

Clive Barker
Thankyou Mark. Thats much appreciated.