{"id":147,"date":"2024-06-07T11:42:25","date_gmt":"2024-06-07T09:42:25","guid":{"rendered":"https:\/\/blog.douwedevri.es\/?p=147"},"modified":"2025-02-19T00:24:41","modified_gmt":"2025-02-18T22:24:41","slug":"tang-nano-20k","status":"publish","type":"post","link":"https:\/\/blog.dbdv.nl\/?p=147","title":{"rendered":"Tang Nano 20K"},"content":{"rendered":"\n<h2 class=\"wp-block-heading is-style-default\" id=\"installation\">Installation<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The following applications are required:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>yosys<\/li>\n\n\n\n<li>nextpnr-himbaechel<\/li>\n\n\n\n<li>gowin_pack<\/li>\n\n\n\n<li>openFPGALoader<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"yosys-and-openfpgaloader\">yosys and openfpgaloader<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Install both yosys and openfpgaloader via apt.<\/p>\n\n\n\n<pre title=\"\" class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\">apt install yosys openfpgaloader<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/github.com\/yosyshq\/yosys#setup\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/github.com\/yosyshq\/yosys#setup<\/a><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"gowin-pack\">gowin_pack <\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Install via pip<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\">pip install apycula<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/github.com\/YosysHQ\/apicula\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/github.com\/YosysHQ\/apicula<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It could be that the error &#8220;error: externally-managed-environment&#8221; occurs. This can be solved by adding the flag &#8211;break-system-packages to the install command.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"nextpnr-himbaechel\">nextpnr-himbaechel<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">This one is a bit more tricky as it needs to be compiled. For dependencies please see git repository: <a href=\"https:\/\/github.com\/YosysHQ\/nextpnr?tab=readme-ov-file#prerequisites\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/github.com\/YosysHQ\/nextpnr?tab=readme-ov-file#prerequisites<\/a>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\">git clone <a href=\"https:\/\/github.com\/YosysHQ\/nextpnr#gowin\">https:\/\/github.com\/YosysHQ\/nextpnr<\/a><\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\">cmake . -DARCH=\"himbaechel\" -DHIMBAECHEL_GOWIN_DEVICES=\"all\"\nmake -j$(nproc)\nsudo make install<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"usage\">Usage<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Now lets use the system we just installed. The code needed for this can be found in my git repository: <a href=\"https:\/\/github.com\/douwedevries\/tangnano20k\">https:\/\/github.com\/douwedevries\/tangnano20k<\/a>. This includes sythesize.sh, tangnano20k.cst and topentity.v. They are all the files that are required.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"sythesize-sh\">sythesize.sh<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">This script first sets some variables to let the tools know we are working with a Tang Nano 20k. Next it goes though the tool chain. Each step should be confirmed with an enter. This allows you to read error messages. <kbd>ctrl+c<\/kbd> can be used to escape the script.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"blink-v\">blink.v<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">This file contains a simple verilog description that allow the leds to count when a button is pressed.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"tangnano20k-cst\">tangnano20k.cst<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">This file connects object name to object location. Or simply said, the verilog name to the actual hardware pin. Sipeed provides a file called Tang_Nano_20K_3921_Schematics.pdf in which the hardware is described. From you can create your custom CST file. The file in my repository only contains the system clock, leds and keys.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Installation The following applications are required: yosys and openfpgaloader Install both yosys and openfpgaloader via apt. https:\/\/github.com\/yosyshq\/yosys#setup gowin_pack Install via pip https:\/\/github.com\/YosysHQ\/apicula It could be that the error &#8220;error: externally-managed-environment&#8221; occurs. This can be solved by adding the flag &#8211;break-system-packages to the install command. nextpnr-himbaechel This one is a bit more tricky as it needs [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[18],"class_list":["post-147","post","type-post","status-publish","format-standard","hentry","category-tech","tag-fpga"],"_links":{"self":[{"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=\/wp\/v2\/posts\/147","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=147"}],"version-history":[{"count":18,"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=\/wp\/v2\/posts\/147\/revisions"}],"predecessor-version":[{"id":197,"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=\/wp\/v2\/posts\/147\/revisions\/197"}],"wp:attachment":[{"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=147"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=147"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.dbdv.nl\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=147"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}