Running in LUT exec mode
Seairth
Posts: 2,474
in Propeller 2
Suppose I want to run code exclusively in LUT exec mode. How would I go about bootstrapping the LUT code efficiently? I only see WRLUT, which would require hub memory to first be copied to cog ram. I know there's some other method for quickly filling a LUT, but I'm not sure which instructions do that.
Comments
Edit: Oops! Presseed submit instead of preview
I don't completely understand all this yet but it does appear to work.
Since I don't have a scope, I changed Chip's program to output on PortB so you can at least see some blinky lights. For all the toggle instructions,
becomes
I'm still not sure about any way to really tell you are running in COGEXEC, LUTEXEC or HUBEXEC except looking at the code addresses, where you put the code. If all that looks like it makes sense to your abstraction of the P2 memory models and if something appears to be running, you're good to go!
P.S. Don't ask PNUT to load something to your FPGA until you are sure the P2 is loaded. I just did this to run the above program and PNUT is horrible, miserably hung up on Win10. Task Manager won;t even get rid of it.
*doink* I forgot that there was sample code for this! SETQ2 seems to be the thing you need. I wish there were a more meaningful name for this, even if it was just an alias for SETQ2.
Was it masked to 9 bits and loaded in cog.
Code ran Ok.
Not with my P2 at the moment so can't check it.
From what I've learned (or mislearned) so far, my guess is that your code ended up in COGRAM because you used the SETQ. As far as any of the labels you referred to in the code after the org $200, the would have lost that upper bit but since they are all 9 bit S and D values anyway, it probably didn't matter. if the 10th bit was there or not.
I would also think any of the branches you did were OK because you essentially wrote COG (9 bit) code.
I have my P2, I'll try your test program skeleton with an org $200
(all of the above is speculation and black magic and most likely has little basis in any actual understanding of the P2)
This little program is an extension of Brian's test routine. It loads its data into COGRAM and it's code into LUT, zeroes out the HUBRAM where the code was (just to prove we are really running in LUTEXEC) and then jumps to $200 to start running code in LUT.
I tried to fix the tab issues with the code - It does compile but you may need to fix some spaces.
load it, enable PST and hit a key, you should see the value of regx displayed and also contents of LUT0
The only thing I really don't understand is my rdlut isn't getting the value I think it should be getting - I expect $0FFFFFFF.
The org and address manipulations are rather ugly to get to the point where you have code in LUT to execute but it does work.
Was it fun? Sure....just like an adventure game!!
Need to try when back at P2.
SETQ is used to set a count 1-256 whereby the following RD/WRLONG instruction is repeated "n" times, incrementing hub and cog each time. ie used to load cog up to 256 longs in one operation at full clock speed.
SETQ2 is/ws used as an equivalent to SETQ, but replaces cog with LUT RAM. Not sure if this is still required.
Hope this helps David.
If this always has to be paired, it is probably better wrapped in the Assembler as one 64b opcode ?
A BlockMove type name would avoid it ever being accidently split.
I tried running your code and got no output at all.
It seems Pnut does not like pasm instruction following directly after RES directives.
I changed these to longs and established comms again.
Now to try and work out this LUT stuff.
I'll report back after I get some P2 time.
**Edit: Brian, very strange. I changed my RES to LONG and it started working. I ran it all afternoon with the RES in there wondering how it was doing that because res usually need to be the last thing under the current org.
It still isn't doing what I expected (displaying $0FFFFFFF as the contents of LUT[0].
I thought maybe I had "old code" stuck in the LUT since it doesn't get zeroed on reset but I was changing the code between lut_start and newline, and those changes were faithfully reproduced.
Much more that I don't understand than I do understand. I'm done for the day, time for the other half of the world to play!
P.S. The position of the SETQ2 doesn't appear to matter, it works both ways.
Here is a link to what I started:
https://docs.google.com/document/d/10qQn_-B7avY2ce0N1MDDdzOF1lACPNWUJkjHFyzITiY/edit?usp=sharing
Look at the end.
Quota? Short for Hub Read Write Quota Enforcement Register but a SETHRWQER mnemonic was a bit awkward. :0)
I made the following change to your code. and the result was
:cool:
Edit: As well as these changes mentioned earlier
Hmm...
Just removed DE2-115 and powered up Prop123-A7 ,Hit F11 and code failed??
This memory stuff is starting to stress me out!
Hopefully, Chip's next image drop will make some of this stuff a bit easier to write.
Good, it's not just me, we're both crazy!!!
I'll try your changes (I've been doing everything on the A7 lately)
I've dumped SETQ2 for now and dropped this in.
This worked on both DE2-115 and Prop123-A7 after a power up.
I'm more confused now....
There's been so many changes, it'd good to get grounded with some facts...
What does
Mov ptrb,#@lut_start
Do? The #@ has me confused.
FWIW only 511 longs are loaded into LUT RAM.