{"id":1596,"date":"2021-05-02T09:30:49","date_gmt":"2021-05-02T09:30:49","guid":{"rendered":"http:\/\/retroramblings.net\/?p=1596"},"modified":"2021-05-02T21:42:28","modified_gmt":"2021-05-02T21:42:28","slug":"toolchains-and-tribulations","status":"publish","type":"post","link":"https:\/\/retroramblings.net\/?p=1596","title":{"rendered":"Toolchains and tribulations"},"content":{"rendered":"\n<p><strong>2021-05-02<\/strong><\/p>\n\n\n\n<p>I&#8217;ve finally turned my attention to porting the updated version of the Megadrive\/Genesis core to the Turbo Chameleon 64.  Since I last had any input into this core it&#8217;s come on in leaps and bounds, and adding the DeMiSTify module to make it run on controllerless boards would be next to trivial.<\/p>\n\n\n\n<p>Or so I thought&#8230;<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>I generally start with the DE10-lite as a target platform since it has a nice large MAX10 FPGA of the same tech level as the Cyclone III and 10LP (i.e. counts logic elements the same way, uses RAM blocks of the same size.)<\/p>\n\n\n\n<p>The ported core works nicely on DE10-lite.<\/p>\n\n\n\n<p>I built it for Turbo Chameleon 64 V1 hardware and it works nicely there, too.<\/p>\n\n\n\n<p>I built it for Turbo Chameleon 64 V2 hardware and&#8230;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"644\" height=\"500\" src=\"http:\/\/retroramblings.net\/wp-content\/uploads\/2021\/05\/DSC_7119.jpg\" alt=\"\" class=\"wp-image-1598\" srcset=\"https:\/\/retroramblings.net\/wp-content\/uploads\/2021\/05\/DSC_7119.jpg 644w, https:\/\/retroramblings.net\/wp-content\/uploads\/2021\/05\/DSC_7119-300x233.jpg 300w, https:\/\/retroramblings.net\/wp-content\/uploads\/2021\/05\/DSC_7119-386x300.jpg 386w\" sizes=\"auto, (max-width: 644px) 100vw, 644px\" \/><\/figure>\n\n\n\n<p>Oh dear.<\/p>\n\n\n\n<p>This is the second core where I&#8217;ve encountered a corruption problem on V2, and in both cases it&#8217;s resisted all the &#8220;simple&#8221; things that would be expected to solve it &#8211; adjusting RAM phase shift, checking resets, checking initialisation, mode register setting &#8211; I&#8217;ve even clocked both cores at 5\/6 of their original speed (any slower than that and my monitor loses sync) and the problem remains.  The Megadrive core meets timing even before I slow it down &#8211; so whatever the problem is, I don&#8217;t believe it&#8217;s a typical run-of-the-mill SDRAM issue &#8211; if it were, I would expect to see the errant behaviour changing from build-to-build, and especially in response to changing frequency or phase shift.  I wondered if a multicycle constraint was masking a timing issue, but I think the symptom&#8217;s too deterministic to be caused by metastability issues.<\/p>\n\n\n\n<p>My gut feeling is that there&#8217;s a problem with the SDRAM command sequencing, and the SDRAM chips on MiST, DE10-lite and Chameleon V1 are tolerating it but Chameleon V2 isn&#8217;t.<\/p>\n\n\n\n<p>My first line of attack was to try and simplify the situation &#8211; remove as many variables as possible, and try and find the simplest possible access pattern that still fails.  To do this, I was going to need to create some kind of custom Megadrive ROM, so that I can have full control of access patterns.  That means going down the Megadrive homebrew development rabbit-hole!<\/p>\n\n\n\n<p>So I started looking for Megadrive development toolkits and tutorials.  I found a GCC-based toolkit which allows Megadrive software to be written in C, and I very quickly realised how spoiled I&#8217;ve become thanks to vbcc, vasm and vlink on the Amiga &#8211; I literally watched an entire movie while waiting for that Megadrive toolchain to build.<\/p>\n\n\n\n<p>In the end I found some ASM tutorials here: <a href=\"https:\/\/blog.bigevilcorporation.co.uk\/2012\/02\/28\/sega-megadrive-1-getting-started\/\">https:\/\/blog.bigevilcorporation.co.uk\/2012\/02\/28\/sega-megadrive-1-getting-started\/<\/a>  &#8211;  and used Vasm to assemble some examples (after search-and-replacing &#8220;0x&#8221; with &#8220;$&#8221; and &#8220;, &#8221; with &#8220;,&#8221;) &#8211; and soon had a &#8220;Hello World&#8221; example up and running.  Sadly such a simple example isn&#8217;t enough to make the problem manifest itself.<\/p>\n\n\n\n<p>So the next line of attack is to get the SDRAM controller running under simulation, to make sure there aren&#8217;t any timing subtleties I&#8217;ve missed, and if it works OK in simulation, create an actual test core that I can run on each platform and compare the output&#8230;  stay tuned!<br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>2021-05-02 I&#8217;ve finally turned my attention to porting the updated version of the Megadrive\/Genesis core to the Turbo Chameleon 64. Since I last had any input into this core it&#8217;s come on in leaps and bounds, and adding the DeMiSTify &hellip; <a href=\"https:\/\/retroramblings.net\/?p=1596\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,8,1],"tags":[],"class_list":["post-1596","post","type-post","status-publish","format-standard","hentry","category-fpga","category-hardware","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/posts\/1596","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/retroramblings.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1596"}],"version-history":[{"count":2,"href":"https:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/posts\/1596\/revisions"}],"predecessor-version":[{"id":1600,"href":"https:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/posts\/1596\/revisions\/1600"}],"wp:attachment":[{"href":"https:\/\/retroramblings.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1596"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/retroramblings.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1596"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/retroramblings.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1596"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}