This command-line tool converts FASM files into bitstreams, simplifying the assembly of human-readable FPGA configurations into the binary formats needed to program various FPGAs.
At this stage, it wraps most of fasm2frames and xc7frames2bit logic into a single binary. It has been tested with the Artix-7 counter example, where it produces identical frames and a working bitstream—at approximately 10 times the speed compared to the pure Python textX based parser implementation.
First, install Bazel and ensure you have a basic C/C++ toolchain set up.
Note
If you are using Nix or NixOS, ensure you have flakes enabled and enter the development shell via nix develop
.
Then run:
bazel run -c opt //fpga:fpga-as -- --prjxray_db_path=/some/path/prjxray-db/artix7 --part=xc7a35tcsg324-1 < /some/path.fasm > output.bit
Finally, load the bitstream in your FPGA using openFPGALoader
openFPGALoader -b arty output.bit
For installing the binary in your home directory (e.g., ~/bin), run the following command:
bazel build -c opt //fpga:fpga-as && install -D --strip bazel-bin/fpga/fpga-as ~/bin/fpga-as
or install in system directory that requires root-access:
sudo install -D --strip bazel-bin/fpga/fpga-as /usr/local/bin/fpga-as
In a FASM file, each line represents a sub-tile feature along with the configuration bits required to enable that feature. In other words, when a tile feature is enabled, its corresponding configuration bits must also be activated.
The diagram below illustrates the basic process for the xc7a50t
fabric:
For example, consider the FASM line:
CLBLM_R_X33Y38.SLICEM_X0.ALUT.INIT[63:32]=32'b00000000000000000000000000000100
This line instructs the system to configure the SLICEM_X0.ALUT.INIT feature of the tile named CLBLM_R_X33Y38, enabling the feature at address 34.
The next step is to locate the tile metadata in the FPGA fabric's tilegrid.json
file. The metadata provides essential information, including:
- tile_type:
"CLBLM_R"
- baseaddr:
"0x00401080
- offset:
77
Using this metadata, you can search the segbits database for the specific feature. By matching the tile_type and the FASM feature name, you can identify the correct configuration bits in the tile type segbits file (segbits_clblm_r.db
). In this case, you would look for the entry corresponding to CLBLM_R.SLICEM_X0.ALUT.INIT and find the entry for address [34]
. The value 34_06 then provides the coordinates for the word index and the specific bit index to be set.