sacGOWIN•
2
bonfire_processorOP•

Funny. I already have this board. I was not able to get the Gowin DRAM IP running, but was successful with an open source SDRAM controller which I already used on Sparta-6 based designs.

I will post about my experience with the TEC0117 in my blog soon.

1
FieldProgrammableIntel User•

I've been running the Bonfire on the Trenz MAX1000 and CYC1000.

Made an Avalon wrapper for the core and stuck it in Qsys with an Intel SDRAM controller. Added a bootloader (to pull SW image from the SPI flash) and Floating point IP cores to the Bonfire local memory area. It chugs away happily at 48MHz.

The good thing about Qsys is you can easily parse the generated system (it provides an XML for this purpose) for things like peripheral base addresses, part number and component parameters. Then generate a C header file containing all of these as #defines and derived values for your program. You can even do things like look up the maximum possible size of the FPGA configuration image and use that to choose a location for placing the SW image, then generate scripts for the programmer/assembler tools based on that.

A subtle feature of the MAX1000 and CYC1000 boards is they appear as two USB devices (uses FT2232H) so you get both JTAG for programming and serial UART for talking to it at runtime. They also have an ADC/accelerometer, all in all I think they are a great deal.

Oh and I finally managed to get a DWARF parser working with the Bonfire so I can get C source output, local and global variables in ModelSim.

Regarding these Chinese FPGAs, in general I don't think I would have the patience to fight the tools.

1
bonfire_processorOP•

I've been running the Bonfire on the Trenz MAX1000 and CYC1000

Great. Is there some public repo with it?

Oh and I finally managed to get a DWARF parser working with the Bonfire so I can get C source output, local and global variables in ModelSim.

Can you elaborate a bit what you exactly what you have done?

1
FieldProgrammableIntel User•

No there's no public repo. The project is version controlled in Bazaar and there is no appetite to transfer it to GIT, it is also based on a combination of the Quartus GUI and a hierarchy of batch files calling the Quartus tools and C# programs, there are no make files used at all. What we could do is provide just the dwarf parser C# and VHDL testbench code if you wish to integrate this into your Bonfire projects.

Here is a screenshot of it in action.

How it works is roughly:

  1. Compile with -c -march=rv32im -mabi=ilp32 -Wall -Og -fomit-frame-pointer -ffreestanding -fno-builtin -I../system -I../lib -std=gnu99 -Wall -Werror=implicit-function-declaration -ffunction-sections -fdata-sections --debug=dwarf
  2. Objdump a dwarf file with -t --dwarf=info --dwarf=loc --dwarf=Ranges --dwarf=frames --dwarf=frames-interp --dwarf=decodedline main.elf, feed this output into the C# dwarf parser.
  3. The C# dwarf parser uses RegEx queries to create a dictionary of types from the debug_info section. This is currently only single pass and follows a primitive-typedef-volatile-pointer-array-union-struct hierarchy (so e.g. pointers to volatile primitives can be detected but not volatile pointers).
  4. Find all the global variables using the "variable" tag. Use the dictionary to resolve their types, write a ModelSim macro file (.do), this write virtual signals with names mapping global variable instances to names, e.g. quietly virtual signal -install /soc_tb/globals { (context /soc_tb/globals )( global(0) )} {rs232}) creates a virtual signal mapping the global(0) which is parsed by the testbench to the name rs232. Composite types with multiple members (e.g. structs) are added as wave groups.
  5. Write out a VHDL package defining arrays of size GLOBAL_COUNT. The testbench will use these arrays for storing the global variables.
  6. Parse debug_ranges section. Find the working ranges of all subprograms. Create a list of subprogram start and end addresses.
  7. Find the highest program counter value used by a subprogram. Use this to write out a VHDL package defining the program counter lookup table.
  8. Write out the function program counter lookup table "pc_lut" as a binary file. Each entry is a 16-bit line index corresponding to a unique subprogram name. Write a text file containing each unique function name, this is indexed by the pc lut. Inline functions are concatenated with their parent function name.
  9. Parse debug_line section to make dictionaries of file names. Decode each debug_line and copy the corresponding line from a source file into a list of source line objects (has members pc, filename, line number, line content). Sort the list by program counter value.
  10. Write the lines program counter lookup table "pc_lines_lut" as a binary file, each entry is a 16-bit index to an entry in the source line list.
  11. Write out text files for file names, line numbers and line contents. These are all to be indexed by pc_lines_lut.
  12. Parse the debug_loc section for local variables generate 8 indpendent PC lut files, variable name text files and DWARF op code sequence text files.
  13. Parse the debug_frame section, create a list of FrameBase objects (members program counter, stack pointer register and stack pointer offset).
  14. Write out a pc_frames_lut binary file, each entry is a 32-bit value indexed by program counter. 16-bits for Offset, 16-bits for register index.
  15. The VHDL testbench consists of 4 parts: Source line decoder, local variable deocder, global variable decoder and shadow RAM. The Bonfire program counter is extracted using VHDL 2008 external names syntax. The shadow RAM uses the same method to monitor the dbus wishbone, all writes to the memory are captured and written to a shared variable integer array. This bypasses the cache and allows an implementation independent means for the other components to access memory contents.
  16. The source line decoder contains two program counter look up tables (sourced from pc_lut and pc_lines_lut) and four text look up tables (filename, line number, subprogram, line content).
  17. The global variable decoder generates GLOBAL_COUNT "charify" components which convert raw values from memory into formatted ASCII text depending upon data type and length. E.g. 32-bit Float values are converted to real then to ASCII strings, then to 640 bit std_logic_vectors containing the ASCII string. Encoding to std_logic_vector allows the ModelSim wave colour coding to be utilised to flag invalid inputs by setting the vector to 'X', 'Z', '-', 'H', 'L' etc.
  18. The local variable decoder decodes the frame base and passes it to 8 local decoder instances. Each local decoder is a DWARF stack machine which reads op codes from its look up table and executes them before passing the content to a charify component. It can access either the shadow RAM, or register file using VHDL 2008 syntax. Here the charify's output is used to highlight when the decoder is active, 'X'/red waves show it to be inactive.
1
testmeharder•

CYC1000

The latest lite/web/free Quarus releases don't appear to include Qsys. Is there some reasonable option for hobbyists to get Qsys support for CYC1000 or MAX1000 that I'm missing?

1
FieldProgrammableIntel User•

They just renamed it Platform Designer, it's the same thing as Qsys.

In case you aren't aware of how it works. You can add custom components by following a wizard and assigning ports to either be Avalon ports or "conduits" (random stuff that needs routing outside the Qsys generated entity).

So if you are making your own wrapper for the Bonfire say, you need to make a wrapper VHDL entity that converts the Wishbone signals to two Avalon memory mapped master interfaces (instruction and data), converting a Classic Wishbone cycle to the Avalon equivalent is easy the signals are very similar. Doing the same converion for burst mode is more difficult so I suggest you start with a non-bursting Avalon master and just take the performance hit. You can map the interrupts to an Avalon interrupt sink.

Then in Qsys/Platform Designer the wizard will detect the ports in your design and try to assign them to Avalon signals, you will probably need to edit them manually to get them all right.

Finally you can add the built in Avalon SDRAM controller, UART (mapped to the USB chip's port B), GPIO (LEDs etc), interval timer and SPI (accelerometer/ADC). You can even make your own peripherals by making Avalon memory mapped slave wrappers for them.

Here are some examples of a CYC1000 in Quartus Prime 18.1 Lite Component Wizard, full Avalon system. I always put my PLL externally to the Qsys entity so that I don't have to simulate the cumbersome Intel behavioural model and you can route the locked output to the system's reset_n. The Avalon clocks source is set to 48MHz, the PLL to 12MHz in, FPGA clock = 48MHz 3ns phase shift, SDRAM clock = 48MHz 0ns phase shift.

For extra fun, try grabbing the "Intel Floating Point Hardware 2 Multi-cycle" from the IP catalog and mapping it into the Bonfire's local memory bus, now you've got an FPU!

1