Tachyon for Idiots
rjo__
Posts: 2,114
in Propeller 2
OK... so exactly how do I load Tachyon onto a P123A9?

Comments
BTW, I'm assuming you have loaded FPGA images before.
If you want the extended RAM version then you can use pnut or p2asm/loadp2 to compile and load the kernel and thereafter have that TAQOZ compile all the modules. I will post some instructions regarding this shortly.
EDIT: I dug out my CVA9 board with the latest ROM I used for testing, just to double check. Fired up minicom (I used 921600 baud) and entered > space escape and hey presto.
Then I type "lsio" at the prompt to list the I/O pin status.
The " -- " is inserted once the line is accepted when you hit enter and its sole purpose is to make it clear that what's on the left of this is user input and what's on the other side is the response, otherwise copy&paste as an example will be confusing for anyone else reading as to what was typed.
Then reinserted the card that was in it.
TAQOZ in ROM is a good place to start with learning to use TAQOZ and using it to test and explore hardware is what it is really good at.
This is the exercise which is a mix of code typed on the console and comments which is mostly copy'n'pastable.
{ SHIFTING BITS OUT SERIALLY Simple unoptimised 8-bit serial shift out using bit bashing This one simply sends lsb first Before we start let's make it easier to copy and paste code that still has the console TAQOZ# prompt which otherwise would result in an error. Just create a dummy word (definition) of the same name that does nothing } : TAQOZ# ; { good, now TAQOZ won't throw an error when the user includes the prompt itself } TAQOZ# TAQOZ# --- ok TAQOZ# { If you are using the ROM version then it won't know PIN! so we define it now } : PIN! ( data pin -- ) SWAP 1 AND IF HIGH ELSE LOW THEN ; ( COPY START ) --- define our clock and data out pins as constants 32 := CLK 33 := DATA --- define a SHIFT_OUT routine that loops through 8 bits setting the data line and pulsing the clock : SHIFT_OUT ( send -- ) CLK LOW 8 FOR DUP DATA PIN! CLK HIGH CLK LOW 2/ NEXT DROP ; ( COPY END ) { if you are using the RAM version with DECOMP.FTH loaded we can SEE the code it generated } TAQOZ# SEE SHIFT_OUT ( this next section has stack and comments added to the listing assuming we passed a value of $43 to it) STACK>TOP COMMENT $43 E04E: pub SHIFT_OUT Name in dictionary points to code at $5D86 5D86: 5D3C CLK $43 32 Just make sure clock is low before we start 5D88: 017E LOW $43 5D8A: F808 8 $43 8 5D8C: 0118 FOR $43 5D8E: 006E DUP $43 $43 5D90: 5D42 DATA $43 $43 33 5D92: 0178 PIN! $43 Write lsb of $43 to P33 (set data high or low) 5D94: 5D3C CLK $43 32 5D96: 017C HIGH $43 Set P32 (CLK) HGIH 5D98: 5D3C CLK $43 32 5D9A: 017E LOW $43 Set P32 (CLK) LOW 5D9C: 009C 2/ $21 Shift right (or unsigned /2) to position next bit 5D9E: 0127 NEXT $21 Decrement FOR counter and continue looping until count=0 (= DJNZ) 5DA0: 0065 DROP Discard used send data 5DA2: 004D ; EXIT and return 30 bytes --- ok TAQOZ# { Using the same SHIFT_OUT routine we can modify it to reveal the stack contents just before it writes the data. In this case we create a word that is specific for this that will print out the top three stack items as 16-bits To make it easier to read we start each iteration on a new line with the current loop index (not the count) Forth normally uses the word PICK to pick an indexed stack item but TAQOZ only has direct access to the top four items which are held in fixed registers, so it is easier to say 4th 3rd and rather than 2nd and 1st we use OVER and DUP since these are the standard Forth words. } ( COPY START ) TAQOZ# : REVEAL CRLF I . SPACE 3RD .W SPACE OVER .W SPACE DUP .W SPACE ; --- ok TAQOZ# : SHIFT_OUT ( send -- ) CLK LOW 8 FOR DUP DATA REVEAL PIN! CLK HIGH CLK LOW 2/ NEXT DROP ; --- ok ( COPY END ) { Now when we run it we can see the top of the stack on the right, same as the notation So it prints out the stack as 3rd 2nd 1st } TAQOZ# $43 SHIFT_OUT --- 0 $0043 $0043 $0021 1 $0021 $0021 $0021 2 $0010 $0010 $0021 3 $0008 $0008 $0021 4 $0004 $0004 $0021 5 $0002 $0002 $0021 6 $0001 $0001 $0021 7 $0000 $0000 $0021 ok TAQOZ#EDIT: fixed an error in the listing
Click the link in my sig to download the latest binary and then F11 that in via Prop tool or BST. Hookup a terminal set to 115200k and hit ^C (control+C) to get it to reset again so you can see what it says.
If you have color enabled (but not required) it should look like this: (BTW, Tachyon for the P2 is called TAQOZ but it works pretty much the same way)
Thank you. I do indeed have TAQOZ and it does work. It's a miracle.
>> CLKFREQ . 80000000
You also have a ton of stuff linked through the P2 link in your signature. Where is the full version for P123A9?
Here are my initial impressions after about two hours of looking... that's about all you'll get from your average idiot. I'm going to hang here, but by now the average idiot will already have made up his mind.
1. I don't care about stacks. When Chip starts talking about stacks, I know he isn't talking to me.
The first two hours of an idiot's time is like the first day of a Driver's ED class. I don't need to know how to design a camshaft to drive a car. If I need to know about stacks to use TAQOZ, I'm going to fail. It is just a matter of time.
Recommendation:
If you want to attract newbies, you need to treat the entire conversation about stacks as a footnote.
2. It is very clear how to generate the list of defined words... but the next question never really get's answered to my understanding:what does the word actually do. Your document is immensely helpful... but there should be a command that let's me see the inner working of a word without having to dial up a website and after two hours, I don't see it. I got close, but when I tried to follow the instructions and see the innards I ended up with "Deadbea4, Deadbea3,Deadbea2, Deadbeaf" Not sure what Deadbeaf is, but (true story) last night I went to BurgerKing and tried to order 2 Whoppers for $6 and the lady actually said... "sorry we are all out of Whopper meat." So, maybe it has something to a freezer that got hacked by the Russians.
Recommendation:
needs a better word:)
The thing is that with Forth you have to care about the stack. If you are going enforce artificial limits on your understanding you will fail.
When talking about C, your camshaft analogy may work. When talking about Forth, it's not something hidden away under the hood, but more like the road you are driving on.
The way it works is like those spring loaded plate storages you might find in a cafeteria: First in, last out with some opportunity to look at the plates near the top.
you do not want to hear about the stack ...
but want to see the inner workings of a word ??
1. as @AJL said - the stack is essential to FORTH,
like you want to program C/Basic/... and don't want to hear about variables ...
2. you can see the inner workig of a word - very simply typing ... maybe not in the ROM version ... but in the extended
but then you need to invest a little more to make sense out of it.
However, admittedly, stack maintenance in Forth can be a total pita. Another stack-oriented language, Postscript, makes this a lot easier with its mark and cleartomark words. But operators like these require type-awareness in the stack, IOW requiring a separate type stack, or at least a bit array to keep track of where the marks are.
-Phil
Propeller code is normally provided as source or as a binary or both. The thing is that as the source is updated the binary may not be because that requires a couple of extra steps to transfer the full Tachyon image as a binary back onto Dropbox since most of the code is compiled by Tachyon on the Prop itself.
But when you want to just try it out, the binary is the best way to go.
As for Spin/PASM source code, when you hit F11 it compiles it on the PC and generates a binary that is downloaded into the RAM and then EEPROM. So either way it is loaded into a Prop as a binary.
"Would be nice" rather than "should be" I would think. Developing software on a PC can spoil us and lead to high expectations. Tachyon runs totally on the Prop itself. However, both the P2 EVAL and P2D2 have micro SD as standard and I do have a mechanism both for decompiling a word and also another for viewing the original source. I started generating HELP files in Tachyon for the P1 and I have yet to do the same for the P2. Assuming that you had the HELP folder loaded on your SD card, you could type HELP HIGH for instance and it would locate and display the help file that covered this word such as this one here:
Generating and maintaining the help files is probably one of those low priority tasks but one that anyone can help generate too.
I have absolutely no idea what you were doing and how you got there, maybe a copy&paste of your terminal would help me. However DEADBEEF is normally the hex value that is used to indicate a problem, in this case an empty stack is never really empty and so the stack registers are preloaded with dummy $DEADBEEF values that substitute the last digit with 1 to 4 for debug purposes. Now I'm guessing you tried the REVEAL word I had in the exercise, but if you ran that on an empty stack rather than from the SHIFT_OUT word, then those $DEADBEEx values will print out for sure.
STACKS
One thing I will say about stacks though. As Phil said, they can be a pita, but I find if you want to stuff junk into your back pocket then that can be a pita too. Same with stacks, keep it lean, which is why Tachyon only ever worries about the top 4 stack elements and tries to avoid even having that many for any one function. Take for instance the PANEL word that draws a filled rectangle on the VGA display. Normally you would have to provide 5 parameters to it, but I only provide one. That keeps the PANEL word simple and easy to deal with. Instead I create 4 words x y w h which you can guess their function, and each one is a word that takes one parameter. How does it look? Surely anyone could figure this one out (I would hope). So while stacks can be a pita if you let them, don't let them, keep it clean and simple by factoring your code as in the case of PANEL.
BTW, since PANEL only requires a single stack parameter, that means I could follow the "red panel" with "white panel" and then "blue panel" and since the y variable is updated by h each time I draw a panel, guess what I end up with?.
Traditional Forths will feature PICK and ROLL so you can grab the 8th parameter etc. What a total pita that is. What is the 8th parameter after all this stack juggling? I don't know, and I don't want to know which is why I will NOT implement these words in my system since they encourage bad practices.
BTW, the FPGA version does not have the silicon's PLL clock circuitry and so it runs at 20Mhz or 80Mhz.
I will generate an updated P2-EVAL binary that has all the goodies loaded and update my sig with a direct link shortly.
{ VERSION USING THE LSBOUT INSTRUCTION TO OUTPUT THE DATA LSBOUT ( data pin -- data*2 pin ) TAQOZ# $43 LAP SHIFT_OUT LAP .LAP --- 3,424 cycles= 13,696ns @250MHz ok This instruction is useful for serial data that may or may not require a clock } --- data mask, setup, 8 times each bit clocked then discard : SHIFT_OUT ( send -- ) DATA CLK LOW 8 FOR LSBOUT CLK HIGH CLK LOW NEXT 2DROP ; { VERSION USING CLKOUT CLKOUT ( iobit dat -- iobit dat/2 ) REG27=iomask ) Shift msb bit out, clock high, clock low TAQOZ# $43 LAP SHIFT_OUT LAP .LAP --- 1,232 cycles= 4,928ns @250MHz ok The advantage of the CLKOUT method is the finer control that can be achieved for each bit and clock speed by setting the CLKDLY register (0=none) } --- setup clock mask, data, 8 times clock a bit, then discard : SHIFT_OUT ( send -- ) CLK CLKREG COG! DATA SWAP 8 FOR CLKOUT NEXT 2DROP ; { VERSION USING KERNEL SPI INSTRUCTION The SPI instructions are fast kernel routines that rely upon an SPI config where the CS MISO MOSI CLK are specified in a single long as 4 decimal bytes. Unused pins are written as 99 - i.e. &99.99.33.32 SPIPINS. SPIWB ( byte -- ) ' write byte msb first ' TAQOZ# $43 LAP SPIWB LAP .LAP --- 128 cycles= 512ns @250MHz ok This is the fastest way to send and receive SPI data short of a more complex smartpin mode } \ CS SI SO CK &99.99.33.32 SPIPINS \ then simply use SPIWB to write MSB first $43 SPIWB