Tips for getting a rolling cube demo working on the Tang Nano 9K

Nov 20, 2026 Last reply: 20 hours ago 4 Replies
Jump to replies (4)

I've been playing with a little 3D rolling cube demo on the Tang Nano 9K for the past couple weekends, and a few things tripped me up that I wish someone had told me upfront. The GW1NR-9 chip is tiny, so don't try to do real 3D math in fabric. Precompute your rotation tables for a fixed set of angles and store them in block RAM, then just index into them. I burned a whole evening trying to write a general multiply pipeline before realizing I only ever needed a few dozen sine values.



The other big one is timing your HDMI output. The 9K has enough PLL options but you need the pixel clock at exactly the right rate for 640x480@60 or monitors will silently refuse to sync. Use the vendor's clock wizard tool rather than hand-tweaking, and check the generated log, not just the green success tick.



For the rolling motion itself, keep a phase counter that wraps at the rotation table length and add a small velocity value each frame. When the cube face lands flat, snap the phase to zero so it doesn't drift. Simple, but it took me three tries to spot the drift. Last tip: pin constraints are where demos go to die. Copy the pinout file from the board's official repo, double check the HDMI pin pair assignments, and only then start writing Verilog. Saves hours.


I ran into the same drift problem on my cube demo and fixed it a slightly different way. Instead of snapping the phase when a face lands, I store the target angle for each face and ease the last bit of rotation toward it, so the motion looks less mechanical. Takes a bit more logic but I liked the result better than a hard snap.

That easing idea sounds nicer, might steal it. My issue ended up being the BRAM read latency messing with my table indexing. I was off by one clock cycle and the cube looked like it was wobbling. Didn't clock the output register and couldn't figure it out for ages. Check your read timing if the angles look jittery.

I'm still working thru the basics with a smaller board, so this is a bit ahead of me, but the timing thing hits home. My monitor also refused to show anything for two evenings and it turned out my clock wasn't the problem at all, I had the sync signals swapped. Is there an easy way to test the video output on a cheap little display instead of a proper monitor, or do you just hook up the real thing and hope? Also curious how much room the rotation tables actually left you, since I keep worrying about running out of memory before I even start.

I'm way behind you all, still at the stage of making a single light blink on my board. But the part about precomputing the numbers caught my eye. So you just make a big list of answers beforehand and look them up instead of doing the math live? Does the chip have enough room for a list that big, or do you keep it small by only storing every few angles and guessing the ones in between?

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required