The FPGA At Home microblogging thread

Starting a separate thread for FPGA hacking, rather than continuing the near-to-full SBC topic

The iCE40-HX8K has 16kB of on-chip SRAM... that won't be enough for 8-bit micro emulation. So I made a RAM expansion board, using up all the available pins on the BANK3 breakout connector-- giving me 128kB of delicious RAM! Construction was done with wire-wrap as you can see.

It took a few days to get a correctly-operating sram-controller module written, but now I can make the 128kB appear as 64kB of 16 bit memory.

Other urls found in this thread:

au.element14.com/texas-instruments/msp-exp430g2/g2xx-launchpad-dev-kit/dp/1853793
savannah.gnu.org/task/?14069
github.com/SubProto/icestick-vga-test
stackoverflow.com/questions/36633819/iceprog-cant-find-ice-ftdi-usb-device-linux-permission-issue
kildall.apana.org.au/~cjb/FPGA/sharplcdgrey-icestick.tar.gz
excamera.com/sphinx/article-j1a-swapforth.html
sbc.rictor.org/vid3.html
sbc.rictor.org/vid2c.html)
engbedded.com/fusecalc/
twitter.com/SFWRedditImages

Those two wires in the first pic-- a serial link for downloading into the SRAM when the iCE40 starts up. Does about 280 kB/s.

What synthesis tools are you using OP?

icestorm/yosys ..the only thing I can get on my oddball NetBSD box.

...been waiting 15 fucking years for something like it.

spartan 6 lx25 is the niggest

Nice. I've read about that, but I've not actually tried it. Is it any fun, or just a huge pain in the ass to work with?

Last time I personally worked with anything HDL related was back in school about 5 years ago. We were using some Xilinx suite, and it was a huge pain in the ass (but to their credit, I am absolutely horrible at Verilog).

Great work. What would you say the hardest parts have been?

As someone brought up on makefiles, not bad as a workflow goes-- that is, it's just like I've always written code. It took a bit to understand what all the cruft in the GNU Make-styled makefile did (what's the fucking use of .PHONY anyway?)

Being a reversed-engineered effort, there's gaps in its knowledge of the iCE40 hardware (something about a cascading/FIFO BRAM feature?), but I'm not at the stage of needing anything of that yet. I gather that yosys was cwolf's postgrad work, but it's quite usable in that regard, pretty-much 'out of beta' code. Some things in the iCE40 aren't properly handled by the compiler (tristates..), but you can still manually instantiate the chip-level features with a SB_IO declaration.

It's fast, too-- from source to bitstream takes 6.5 seconds with what I'm working on at the moment.

The drawback is, though, is it only supports a few recently iCE40 chips-- the LP/HX1K, 4K, and 8K.

Hardest part: finding good examples to learn from. Try using Google? Don't bother. Shitsites like edaboard & stackoverflow have SEO'd their millions of worthless posts and "stop using a fork, get a spoon!" answers, so that it's impossible to find actual solutions. grepping through cwolf's github has more often than not find what I was after, though.

I don't have a clue about how HDLs actually work, and my mental theory of what it is is always been misproven with the next project. If I were learning this at Uni, I could harass the Lab supervisor for clues. I've no idea why a simple-ish circuit, that would be reasonably straight-forward to actually build (with like 74-series ICs), ends up needing 7000+ wires. Obviously I've violated some basic verilog design rule... but because of the above I can't find out why.

Also, gtkwave has been surprising useful. An actual Gtk application written that was more practical than I was expecting...

(I don't intend this thread to be just about my stuff. Anyone else playing with FPGAs should post as well..)

Latest work: getting a faux-I2C TM1687 LED driver IC working.

It took several days-- I originally had this nice & simple/smaller state-machine... that I couldn't get working. In the end, I resorted to redoing the whole thing based on what an Arduino library did, rather than what the datasheet said ...which probably makes me only the 3rd person in the world to have written an TM1687 driver (everyone else just cut&pastes the C++ code from a guy at Intel.com)

..and after, I got the verilog controller even simpler by going further off from the manufacturer's datasheet. And just for giggles, I tied overclocking the 100kHz i2c chip, which the manufacturer says is limited to 250kHz ...up to 6 MHz .. That makes an entire display refresh only take 34 microseconds. Nice desu ne.

What board would you recommend from someone wanting to delve into assembly and bare metal programming?


I saw in that other thread you were doing some cool stuff with the Z80 code.

I'd say the original MSP430 Launchpad: au.element14.com/texas-instruments/msp-exp430g2/g2xx-launchpad-dev-kit/dp/1853793

It's cheap, it's an actual 'real' 16-bit CPU, 68000-esque assembler (but RISC-- that's all of it in the second image), it works well with StallmanOS, and has a Arduino-wannabe GUI IDE (Energia) for when grovelling over busted machine code isn't on the day's plan.

Did you ever try the BareMetalC framework ?

Never heard of it...

I'm Just asking seeing that you have experience I thought you had some with it since this project is 20+ years old
currently in the list for being integrated in the gnu project
savannah.gnu.org/task/?14069

Awesome user, thanks. I have a BeagleBone as it is, but I've been using it more for high level stuff. I was inclined towards the Launchpads because they're TI, like the BBB processor, but heard they're kinda shit in comparison to (ret)Arduinos as far as specs go

but if you say so :^)

You're learning assembler. The 16kB of Flash in the G2553 is going to take a long fucking time to fill with code...

This is pretty cool OP. I'm more into ai and robotics but this embedded stuff always impresses me. I wish I could gitgud at it but I can never find the time and then you fpga posters make a thread and it shows me how far I really have to go. Cool stuff.

The guy who actually got me onto the HX8K and Yosys is a 'mechatronics' engineer at the CSIRO, and he's been using FPGAs for all the motor control work now-- part of the chip is a softcore CPU, and the other for hard real-time motor control.

Dear Diary,
Today I finally managed to glue the Verilog modules I've been working on recently to the SUBLEQ CPU I did earlier. It was a fucking PITA! Modules that worked separately needed ugly hacks to work together. The SPI-download stuff took several hours to get working properly: for some reason the writes to the memory expansion were appearing two byte locations further up than they should have (i.e: location 0x001 appearing/being written at 0x003), yet the RAM is latched to the 12MHz system clock, and not the much slower download circuit, so the address register can't be changing while the RAM write happens.
The people on Twitter loved it, though, and someone's offered a freebie of a iCE40-HZ8K hobbyist board he's designed. (I won't take it. I'd rather his freebies went towards someone writing decent write-ups for Veriloging on Yosys.)

With a bit of a push, the board now takes the output from the 'Higher Subleq' compiler and runs it!
With the system clock at "watchable" (~4 Hz), the test program took 18 minutes to run, but that's just what you get trying to use printf on an embedded system.

Forgot to mention: that subleq code is being run from the SRAM expansion, so there's now a 65536 word memory that should run up to medium-sized compiled programs.

Got to say, this is all very nice stuff. Do you have a git repository or anything similar?

This thread is inspiring, to me at least, I went ahead and ordered the ice40-hx1k evaluation stick. I figure, if yosys is stable enough where I'm now seeing threads about it on Holla Forums, I need to get off my ass and use it. (I'm mentally prepared for it to be very unpolished experience still, there's only so much the developer(s) can do with such limited resources and information).

I don't expect I'm going to make anything very useful with only 1k LUT's, but I'm so out of practice that I just need to something to practice the very basics of Verilog.

The HX1K used by the Icestick can do things like VGA generation easily: github.com/SubProto/icestick-vga-test .. All of my projects on the HX8K are only using ~200 LUTs, as well. (And the J1a swapforth softcore is 156 LUTs..) The only real issue would be the small number of IO pins.

Using the Higher Subleq compiler and some old Usenet code, the system can now calculate Pi!

Running at its (currently) fastest rate it took just over 7 minutes, or about 80,300,000 executed instructions, to get ~100 digits of pi down. (To do 1000 digits I'd estimate would take about 10 hours...)

I need to look into why it can't go any faster than /8 of the system clock..

Anyone know of any free open source software for programming xilinx fpgas?
I had to buy one for class, but I dont want to use their shitty first party software.
I found something that might be able to write binaries to it, but nothing that will compile the required binaries from vhdl.

I'm not thinking so, and from people's excitement over icestorm it's probably the case of it really being the first.

Current project-- my SUBLEQ (and future projects) will need a keyboard. The SPI protocol used by PS/2 PC keyboards is simple enough, however they require more Vcc power than the FPGA can source, and probably 5VDC at that. I could /make/ one with a shift register IC (to save GPIO on the HX8K), although the keyboard out of it would be small (1st pic), or I could salvage a matrix keyboard from a microcomputer (Apple][ or Commodore would work), but that's... work.

However, I do have an old infrared keyboard for a Palm Pilot, and if I could reverse-engineer its transmission protocol I'd be set.

I've got working code already-- an unprecedented case of completing a Verilog project in a single day.. woohoo

I tried a trick that would let me leave out managing all the sync-bits preamble (..which is spread out over 21 milliseconds--256000 clock cycles) by just syncing the serial bits to any negedge transition it finds and assuming all bits thereafter occur every 200 microseconds, using a shift-register to detect when the start and stop sequences have happened.

Unfortunately the keycodes aren't anything standard, but it works well. At a cold start, it needs a few keys pressed before a sync happens (several presses of a shift key..), but then it's all good.

For the love of god what is the font

"-adobe-courier-medium-r-normal-*-12-120-75-75-m-70-iso8859-1" is what X calls it.

These are the Emacs-related .Xresources lines

Emacs*toolBar: 0Emacs*Font: -adobe-courier-medium-r-normal-*-12-120-75-75-m-70-iso8859-1Emacs*Geometry: 80x80+580+0Emacs*background: blackEmacs*foreground: goldEmacs*cursorColor: WhiteEmacs*pointerColor: White

This weekend's accomplishment was getting this 3.3V Sharp LCD working.

I originally thought about the Nokia PCD8544 (96x48) LCD display, but then I remembered I already had one of these Sharp LS013B4DN04 from my MSP430 Launchpad gear, and a squiz at the datasheet made me think "oh, that could all be controlled with a single binary counter!"-- much like the Video generator I did before, and that sending a line of LCD data fit perfectly into 128 bits...

...hours later, I noticed that wasn't the case, with only 112 bits used when writing multiple lines. The Sharp was also weird in that it addresses lines from 1, rather than 0 like you would assume .....which needed a few hacks on my otherwise elegant counter-based SPI generator. ;_;

Okay, so I finally got my ice40hx1k stick in the mail, and I tried out yosys for the first time. I used it to load the "rot" module that comes in the example directory of arachne-pnr.

I got to say, I'm impressed. The only hiccup I ran into the whole way was a permissions problem that's solved here

stackoverflow.com/questions/36633819/iceprog-cant-find-ice-ftdi-usb-device-linux-permission-issue

I modified the rot.v file so that all the LED's light up at once, and this picture is the result of that. Of course, that is not a complex procedure whatsoever, but I'm still wowed that it worked at all. I figured that I might have issues with USB detection, or generating a bad bitstream, or etc.

Now I need to start looking at what other people have made with this FPGA and experiment with it. Maybe I'll copy the one guy who's been keeping this thread alive...

This LCD is 96x96x1, however I've been able to update it at about 180 fps with the HX8K's default clocking speed, and the idea came to me that it could get a false-greyscale happening by PWM the pixels. I found a simple way to do it (have 4 screen in memory, and cycle through them), and it worked!

(more pics)


I've just ordered an Icestick as well. A few other people had asked if my code would work on it-- but it can also can run 8 times faster than the HX8K.

got!

I expect not many here already have the Sharp LCD Boosterpack that I've been using (let alone built the breakout board to get those five wires out conveniently), but here's a port of my greyscale LCD code to the ICEstick: kildall.apana.org.au/~cjb/FPGA/sharplcdgrey-icestick.tar.gz

You can see from the last image that the stuff I've been doing easily fits into the ICEstick (# of LCs, PLBs, BRAMs, etc.)

Source code in the same directory...

Mechatronics at CSIRO? Sounds like someone I knew once... He isn't a gifted young South African by any chance?

The guy I know is Remy..

Should mention that the manual for getting swapforth running on the icestick is at: excamera.com/sphinx/article-j1a-swapforth.html

(CSIRO dude actually uses swapforth as a component of most of his code now.)

Very nicely done; the code is surprisingly short for what it accomplishes.

are you a millionaire or a corporate fag ?

Probably the first website I read about using microcontrollers to bit-bang video was sbc.rictor.org/vid3.html way back on the pre-4chan Internet, and had always wanted to try it. A few years ago the guy (prompted by a discussion on the 6502.org forum) updated it to the atmega88 (sbc.rictor.org/vid2c.html) and gave it an SPI interface for single-board 6502+6522 projects.

Recently I inherited an AVR programmer and scrounged up the mcu so I was finally able to get around to it. (Yes, I could've used an Arduino to program the chip... but that was too much bother, and too mundane..)

The big advantage of having this instead of getting the iCE40 boards to generate the video themselves, is it's a 'smart' ASCII terminal. I can just throw characters at it, and the atmega88 handles everything like scrolling the screen. It even runs off 3.3vdc with no hassles.

The big hassle was figuring out Atmel AVR fuse programming... Daryl's original design used a full-swing all-in-one oscillator.. which I didn't have in 16MHz, so I had to use a simple crystal oscillator instead, but you can't just chuck one of those in without figuring out the new 'fuse' values. One wrong value can brick the atmega chip irrecoverably, and I only had two of them. I used engbedded.com/fusecalc/ to eventually work out what to set with avrdude.

how difficult do you think it would be to get a device like this acting as a partially vt100-compliant serial terminal?

A hardware terminal is relatively easy, because you have the luxury of being insulated from the clusterfuck OS on the other end via the RS232 interface.

It looks like the code uses up most of the 8kB just for the 'VT52' level terminal... so using an atmega168 at least (with 16kB flash) would probably be the go. I wouldn't be surprised if it's already been done.

bump. we need more hardware threads like this

I bought a PS4 recently, and my productivity has gone to shit.

What I'm supposed to be doing is getting the iCEstick and ATmega88 talking to each other-- a simple enough job, not much different from a UART controller, ...but I'm busy giving mugging communists in Afghanistan.

I've been after a portable CRT TV for a while, and I found one being sold 2nd-hand locally... but it's kind of faulty. :/

Buy a vacuum pump, learn some rudimentary glassblowing, and make one. I'm only half joking

I just realized what the problem was-- I was using an unregulated DC power supply (with all its high-frequency AC noise) for something that's intended to run from a (car) battery.

It's still not going to be very useful. :/ (It's "Half SD" resolution? crap what it is..)

You seriously can't get a free TV off craigslist?

I have a Commodore 1084 monitor that literally shits over anything else CRT.

...but it uses up bench space, so I've been after something like a Sony KV-9PT50 but in PAL. As the above shows, Normie junk sets from Gumtree/Craigslist/et.al. can't cut it.