tag:blogger.com,1999:blog-56343933123070533862024-02-21T00:02:22.918-08:00Edmond Cote's BlogEdmond Cotehttp://www.blogger.com/profile/05053350465895562853noreply@blogger.comBlogger91125tag:blogger.com,1999:blog-5634393312307053386.post-39342242986537981432022-12-31T23:25:00.000-08:002022-12-31T23:25:17.469-08:00Happy New Year! Welcome 2023.I have been tremendously fortunate this year (and past several years). At work, no big moves, have landed into a routine over at Google. Not a bad thing and no complaints. For Tensor G2 announced earlier this year, my primary focus was on its <a href="https://store.google.com/intl/en/ideas/articles/what-is-an-ai-camera/" target="_blank">camera hardware</a>.<div><br /></div><div>Post-COVID, I needed to get back into the world. I traveled to Belgium on a whim. For Fall 2022 semester, I volunteered as a Leadership Coach at <a href="https://www.sjsu.edu/braven/" target="_blank">SJSU</a> UNVS 101 on behalf of <a href="http://bebraven.org">Braven</a> non-profit. My role was to facilitate weekly sessions of the <a href="https://bebraven.org/the-accelerator-course/" target="_blank">Braven Accelerator course</a>. It was a great experience, great people all around. I am thinking of returning next fall. Looking forward to further community engagement next year.</div>Edmond Cotehttp://www.blogger.com/profile/05053350465895562853noreply@blogger.com0tag:blogger.com,1999:blog-5634393312307053386.post-65373561989608996932022-12-11T22:17:00.001-08:002022-12-11T22:17:53.065-08:00Back online and VSCode!A kind individual reached out to inform me my blog went down. To myself, I said, I have a blog? 😃 Quick fix to DNS records and we're back online.<div><br /></div><div>I've jumped on the VS Code bandwagon. I was skeptical at first. The desktop front end is sufficiently lightweight and responsive. Working with web alternative <a href="https://code.visualstudio.com/docs/remote/vscode-server" target="_blank">VS Code Server</a> is convenient and provides the same (or virtually the same?) experience as the desktop version. So far, I've been impressed with available extensions and the growing community. On the daily, I use Python extension for VS Code, Prettier, and VS Code Vim.</div><div><br /></div><div>The cherry on top and what sealed the deal for me are the json-based, revision control friendly configuration files. I shared mine in my <a href="http://chezmoi.io" target="_blank">chezmoi</a> <a href="https://github.com/edcote/dotfiles" target="_blank">dotfiles repo</a>.</div><div><br /></div><div>One problem I faced was sharing my config files between VS Code and VS Code Server. Assuming the default location of <span style="font-family: courier;">${HOME}/.config/Code/User/settings.json</span> in Linux. You can start VS Code Server with the following to pick up the shared settings:</div><div><br /></div><div><span style="font-family: courier;">code-server --user-data-dir ${HOME}/.config/Code</span></div>Edmond Cotehttp://www.blogger.com/profile/05053350465895562853noreply@blogger.com0tag:blogger.com,1999:blog-5634393312307053386.post-69401024648230061542021-10-31T22:30:00.029-07:002022-12-31T22:58:13.244-08:00What's Been Up?<p>I can finally broadcast what I've been working on since I <a href="http://blog.edmondcote.com/2018/12/goodbye-company.html" target="_blank">shut down my company</a> at the end of 2018. I have been at <b><span style="color: #4285f4;">G</span><span style="color: #db4437;">o</span><span style="color: #f4b400;">o</span><span style="color: #4285f4;">g</span><span style="color: #0f9d58;">l</span><span style="color: #db4437;">e</span></b> working on:</p><p><a href="https://blog.google/products/pixel/introducing-google-tensor/" target="_blank">https://blog.google/products/pixel/introducing-google-tensor/</a></p><div class="separator" style="clear: both; text-align: center;"><a href="https://storage.googleapis.com/gweb-uniblog-publish-prod/images/Google_Tensor_Photo_3_DQt1yAw.max-1000x1000.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="450" data-original-width="800" height="360" src="https://storage.googleapis.com/gweb-uniblog-publish-prod/images/Google_Tensor_Photo_3_DQt1yAw.max-1000x1000.png" width="640" /></a></div><br /><p>For Tensor GS101, I primarily worked behind the scenes as lead, then manager, of a design verification CAD team. I later switched to a design verification lead role for YouTube's <a href="https://arstechnica.com/gadgets/2021/04/youtube-is-now-building-its-own-video-transcoding-chips/" target="_blank">Argos ASIC</a>, specifically on the video codec IP written using C++ and synthesized using <a href="https://en.wikipedia.org/wiki/High-level_synthesis" target="_blank">HLS</a>. Following some reshuffling, I continue doing the same, but for something different, still 100% confidential. Hope to talk about it soon!</p>Edmond Cotehttp://www.blogger.com/profile/05053350465895562853noreply@blogger.com0tag:blogger.com,1999:blog-5634393312307053386.post-27041604690277593312021-02-02T16:44:00.002-08:002021-02-02T16:44:26.840-08:00Technical paper review #1<p></p><div _ngcontent-tfx-c23="" class="u-mb-1 u-mt-05 cite-this-btn-wrapper" style="-webkit-text-stroke-width: 0px; background-color: white; color: #333333; display: flex; font-family: sans-serif; font-size: 15px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; margin-bottom: 1em !important; margin-top: 0.5em !important; orphans: 2; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"></div><p></p><b>Marvell ThunderX3: Next Generation Arm-based Server Processor</b><br /><br /><a href="https://ieeexplore.ieee.org/document/9340376"> https://ieeexplore.ieee.org/document/9340376<br /></a><br /><div>Authors describe implementation of ThunderX3 CPU. Here are the key points that stood out for me.</div><div><br /></div><div>ThunderX2 was derived from an earlier MIPS based architecture (which I was privileged to work on for a short while). ARM instructions that did not directly map to MIPS were expanded into micro-ops. A 6% gain in SPECint was achieved by reducing micro-op expansion.</div><div><br /></div><div>Details on arbitration policies for hardware threads inside the OOO pipeline are presented. Arbitration decisions are made, for example, based on number of micro-ops in flight further down the pipe or the most micro-ops to retire.</div><div><br /></div><div>The paper described the rational for choosing a ring topology over mesh: memory bandwidth not increasing dramatically over next generation.</div>Edmond Cotehttp://www.blogger.com/profile/05053350465895562853noreply@blogger.com0tag:blogger.com,1999:blog-5634393312307053386.post-87102181045230256772018-12-17T11:36:00.000-08:002018-12-17T11:38:26.934-08:00Goodbye CompanyIt with a fair amount of sadness to announce that, last month, I shut down my company: P&L Systems, Inc.<br />
<br />
These past 16 months have been quite the experience.<br />
<br />
I recognize the importance of acknowledging (and honoring) the feelings that came up throughout the adventure. To shut down any company is a loss, and with loss comes grief. I cannot precisely identify with all of the five stages of grief (denial, anger, bargaining, depression, acceptance).<br />
<br />
Denial and anger do not resonate at the moment, but bargaining, however. "What if I did ..." or "If only this happened ..." statements are at the forefront of my consciousness. Relating the loss of a company to the loss of a loved one is sobering, quoting: "We want life returned to what it was; we want our loved one restored. We want to go back in time, find the tumor sooner, recognize the illness more quickly, recognize the illness more quickly, stop the accident from happening... if only, if only." The author of the quote goes on to explain that the "if onlys" cause us to find fault in ourselves and what we "think" we could have done differently. Depression set in, somewhat unconsciously, during the final weeks of the company. It showed up as a more-relaxed and scattered attitude to my daily routine. Finally, with acceptance, I accept that this company has been my greatest failure so far. I do not accept that this was my last.<br />
<br />
I am so incredibly grateful for the individuals that helped make the company possible. Money was lost, and that is the painful truth. I do not regret the financial consequence. I could have purchased a Telsa; instead, I invested in myself. If continuing to drive a 10-year-old vehicle is the consequence of failure, so be it, I will retake that consequence over and over again.<br />
<br />
I cannot imagine that it will be possible to list all the lessons learned. The two lessons that most resonate with me are (1) that I underestimated the effort required to adequately cover non-technical responsibilities (i.e., networking, sales, marketing, business development, etc.) and (2) that I underestimated the complexity of building a non-trivial machine learning system (i.e., choosing the correct features, massaging input data, effectively using the results of trained models, etc.). More specifically, I should have prototyped the core technology (hard) before building the supporting infrastructure (should have been easy).<br />
<br />
Luck (or, Karma?). That's the only way I can describe what's next for me. I am starting a new role at Google beginning January 7th. I am so incredibly humbled and grateful. Much of the specifics of the position remain unknown, but I am confident that it is a fit (short- to medium-term, at least). I plan nothing short of making an impact at the company.<br />
<br />Edmond Cotehttp://www.blogger.com/profile/05053350465895562853noreply@blogger.com0tag:blogger.com,1999:blog-5634393312307053386.post-18666627868353788222018-11-15T10:01:00.005-08:002018-11-15T10:02:57.320-08:00Three small projectsI recently released three small projects on my personal github:<br />
<br />
<ul>
<li><a href="https://github.com/edcote/romfilter">MAME ROM filter tool</a></li>
<li><a href="https://github.com/edcote/edaplayground-cli">Command line interface for edaplayground.com</a> </li>
<li><a href="https://github.com/edcote/uvmgen">UVM verification component and testbench generator</a> </li>
</ul>
Edmond Cotehttp://www.blogger.com/profile/05053350465895562853noreply@blogger.com0tag:blogger.com,1999:blog-5634393312307053386.post-73343021447888682018-11-15T08:33:00.000-08:002018-11-15T08:34:01.393-08:00Kudos to Edaphic StudioI have previously talked about my use of IntelliJ as my primary development environment for Scala, C++ (CLion), JavaScript (Webstorm), and Python (PyCharm). I cannot recommend it enough. As luck would have it, a company is developing an IntelliJ plugin for Verilog and SystemVerilog. The plugin is in beta phase but remains exceptionally usable. The author is responsive in addressing my bug reports. Most refreshing is the tools' transparent pricing structure. No EDA sales representatives to deal with!<br />
<br />
In summary, I wholeheartedly recommend hardware developers check out: <a href="https://www.edaphic.studio/">https://www.edaphic.studio/</a>.<br />
<br />Edmond Cotehttp://www.blogger.com/profile/05053350465895562853noreply@blogger.com0tag:blogger.com,1999:blog-5634393312307053386.post-92070013114743948742018-09-06T10:56:00.003-07:002018-09-06T11:02:39.991-07:00Register a bundle in Chisel3A quick update to a previous post that I made: <a href="http://blog.edmondcote.com/2017/03/register-bundle-in-chisel.html">http://blog.edmondcote.com/2017/03/register-bundle-in-chisel.html</a>. Here is how I now create a register (sequential storage element) of a bundle in Chisel3. The benefit is the elimination of the previously-necessary wire declaration.<br />
<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #272822; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #66d9ef;">val</span> <span style="color: #f8f8f2;">pageReg</span><span style="color: #66d9ef;">:</span> <span style="color: #66d9ef;">Page</span> <span style="color: #f92672;">=</span> <span style="color: #a6e22e;">RegInit</span><span style="color: #f92672;">({</span>
<span style="color: #66d9ef;">val</span> <span style="color: #f8f8f2;">page</span> <span style="color: #66d9ef;">=</span> <span style="color: #a6e22e;">Wire</span><span style="color: #f92672;">(</span><span style="color: #66d9ef;">new</span> <span style="color: #a6e22e;">Page</span><span style="color: #f92672;">())</span>
<span style="color: #f8f8f2;">page</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">initialize</span><span style="color: #f92672;">()</span>
<span style="color: #f8f8f2;">page</span>
<span style="color: #f92672;">})</span>
</pre>
</div>
Edmond Cotehttp://www.blogger.com/profile/05053350465895562853noreply@blogger.com0tag:blogger.com,1999:blog-5634393312307053386.post-9215744435558502952018-08-02T11:57:00.002-07:002023-01-01T10:31:36.249-08:00Cramming and (Re-)LearningI remember "ignoring" my statistics class in undergrad. What I mean by that is I never attached real importance to the subject matter. I did enough work to get through midterm and final exams, but not much else. The result is that none of the content ever stuck. I felt lucky that I was able to cram sufficiently and pull off B+ or A- grades. In retrospect, I recognize that I could have done a much better job in absorbing the material. Not only in statistics but in other subjects as well...<div><br /></div><div>Back to re-learning.</div>Edmond Cotehttp://www.blogger.com/profile/05053350465895562853noreply@blogger.com0tag:blogger.com,1999:blog-5634393312307053386.post-45757482593415680092018-07-07T11:04:00.001-07:002018-07-08T08:00:15.561-07:00Fix journalling issue older generation SSD performance in LinuxI found a solution to an issue that has been hampering my development efficiency for months. The symptom of the problem was any large file I/O operations on my secondary SSD stalled my Linux system. The drive only contains applications and it is not a working volume.<br />
<div>
<br /></div>
<div>
My initial guess was a failing SSD. SMART values did not indicate as such. The drive was only a few years old and was from some obscure brand (PNY).</div>
<div>
<br /></div>
<div>
IO profiling indicated that process [jdb2/sdd1-8] had high IO write wait times while the system was "stalled". I reproduced the behavior by writing a large random file to the disk.</div>
<div>
<br /></div>
<div>
Fast forward a few hours of research and unsuccessful attempts at modifying filesystem settings. The solution was to disable journaling for this "previous generation" SSD drive. It is work noting that the problem does not occur on my "newer generation" Samsung 840 root drive.</div>
<div>
<br /></div>
<div>
Lesson learned? It would have been nice to "call IT" and have them fix it. Not much else. I guess that learned about IO system profiling and file system journalling. It's time to get back to real work.</div>
<div>
<br /></div>
<pre># monitor journalling process
sudo iotop -obtqqq | grep "jbd2"
# write large random file
head -c 10G < /dev/urandom > tmp
# disable journaling, need to unmount first
sudo tune2fs -O ^has_journal /dev/sdd1
# drive information
=== START OF INFORMATION SECTION ===
Device Model: SSD2SC120G3LA726B087-327
Firmware Version: 560ABBF0
</pre>
<pre>
</pre>
<pre></pre>
<pre><a href="https://www.harddrivebenchmark.net/hdd.php?hdd=SSD2SC120G3LA726B087-327" style="font-family: "Times New Roman"; white-space: normal;">https://www.harddrivebenchmark.net/hdd.php?hdd=SSD2SC120G3LA726B087-327</a></pre>
Edmond Cotehttp://www.blogger.com/profile/05053350465895562853noreply@blogger.com0tag:blogger.com,1999:blog-5634393312307053386.post-79156825131569181202018-05-10T14:48:00.001-07:002018-05-10T15:01:00.395-07:00Another Scala CheatsheetI recently wrote up a "cheat sheet" for Scala.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5Z8JuTWTKd5cGlJlXWpriFBCIaIED3FMInVzf1qHO0TXO-uVAYlD_qZ93QULVkgF_3DSn1oGQfkuR6MgR1-EpMkcQrWRCl6sRv0nPLLB3FoDit8_M7elBoaVnjbXTOW9tBfeKm58uwoQ/s1600/anotherscala.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="780" data-original-width="1032" height="241" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5Z8JuTWTKd5cGlJlXWpriFBCIaIED3FMInVzf1qHO0TXO-uVAYlD_qZ93QULVkgF_3DSn1oGQfkuR6MgR1-EpMkcQrWRCl6sRv0nPLLB3FoDit8_M7elBoaVnjbXTOW9tBfeKm58uwoQ/s320/anotherscala.png" width="320" /></a></div>
<br />
<br />
You can download a .pdf copy of the file <a href="https://drive.google.com/file/d/1H7gb2CIzd3QgYantEQBC5s4WKfkVjg5q/view?usp=sharing">here</a>.<br />
<br />
My office is coming together nicely thanks to "decorations" as such.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgr4Y4E1MsK0FLmNf06s_YEKkVPewjMP8RKQp4eUmerMMvwpdWd7GPn8EnKCIR65AE5wkoVYrrkaX6aXIFTDmSavct0dKjiY7zdNX4ArNbb9YDZw1brYzRPzpRmry_svS6-9kw7sdPwhfM/s1600/office_20180510.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="921" data-original-width="1228" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgr4Y4E1MsK0FLmNf06s_YEKkVPewjMP8RKQp4eUmerMMvwpdWd7GPn8EnKCIR65AE5wkoVYrrkaX6aXIFTDmSavct0dKjiY7zdNX4ArNbb9YDZw1brYzRPzpRmry_svS6-9kw7sdPwhfM/s320/office_20180510.jpg" width="320" /></a></div>
<br />
<br />
<br />
<b>References</b><br />
<b><br /></b> <a href="https://alvinalexander.com/downloads/scala/Scala-Cheat-Sheet-devdaily.pdf%E2%80%8B">https://alvinalexander.com/downloads/scala/Scala-Cheat-Sheet-devdaily.pdf </a> (75% “copied” from his material)<br />
<a href="https://alvinalexander.com/scala/how-to-define-use-partial-functions-in-scala-syntax-examples">https://alvinalexander.com/scala/how-to-define-use-partial-functions-in-scala-syntax-examples</a><br />
<a href="http://blog.originate.com/blog/2014/06/15/idiomatic-scala-your-options-do-not-match/%E2%80%8B">http://blog.originate.com/blog/2014/06/15/idiomatic-scala-your-options-do-not-match/ </a> (see: The Ultimate Scala Option Cheat Sheet)Edmond Cotehttp://www.blogger.com/profile/05053350465895562853noreply@blogger.com0tag:blogger.com,1999:blog-5634393312307053386.post-89057621091005552752018-05-08T08:42:00.004-07:002018-05-08T08:52:22.056-07:00Trying to gain tractionFew updates this time. The company is still in "stealth" mode and trying to gain market traction. The target market is quite small, and that is OK. The original business plan calls for developing partnerships with other businesses. Unfortunately, one potential opportunity is on hold for reasons outside of my control. I have not spent sufficient time on marketing over the past 4-5 months. This does not mean going out of "stealth" mode. I expect it will happen before 2019. Personal cash flow is not yet an issue. However, I am slowly beginning to look for suitable (i.e., interesting) short-term contracting opportunities. The timing of the search is arguably premature but I do not have a good sense of what the market for shorter-term contract work is like. Therefore, some caution is necessary.<br />
<br />
I have been updating my gist repository on GitHub several times per week. Check it out <a href="https://gist.github.com/edcote">here</a>.<br />
<br />Edmond Cotehttp://www.blogger.com/profile/05053350465895562853noreply@blogger.com0tag:blogger.com,1999:blog-5634393312307053386.post-12624722773735913252018-04-10T09:02:00.002-07:002022-12-11T22:28:37.999-08:00Using IntelliJ as RocketChip IDE<div>
• Checkout the code according to instructions <a href="https://github.com/freechipsproject/rocket-chip/blob/master/README.md">here</a>.</div>
<div>
<br /></div>
<div>
<span style="font-family: courier;">$ git clone https://github.com/ucb-bar/rocket-chip.git</span></div>
<div>
<span style="font-family: courier;">$ cd rocket-chip</span></div>
<div>
<span style="font-family: courier;">$ git submodule update --init</span></div>
<div>
<span style="font-family: courier;">$ export ROCKET_CHIP=`realpath ./rocket-chip`</span></div>
<div>
<br /></div>
<div>
• Build and publish FIRRTL, as usual:</div>
<div>
<br /></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">$ cd $ROCKET_CHIP/firrtl</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">$ sbt clean publishLocal</span></div>
<div>
<br /></div>
<div>
• Verify that Rocket Chip can be compiled outside of IDE:</div>
<div>
<br /></div>
<div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">$ cd $ROCKET_CHIP</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">$ sbt clean publishLocal</span></div>
</div>
<div>
<br /></div>
<div>
• Wipe existing IDE configuration .idea, if necessary:</div>
<div>
<br /></div>
<div>
<div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">$ rm -rf $ROCKET_CHIP/.idea</span></div>
</div>
<div>
<br /></div>
<div>
• Import project into IntelliJ</div>
</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1O3ZsDPbmUl3ToZfwBwxfitnZJmWa7v1K07U3euJMhyphenhyphenSXpVSoowoR73Dug6RWtpwM0s-2u28Hw5xOZ8ZfrIKila-xIbVZSlt0IjFW17KbudcSxPqGY3cHebVx8CP6PnyXOBNg2YpF6BY/s1600/step1.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="460" data-original-width="777" height="189" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1O3ZsDPbmUl3ToZfwBwxfitnZJmWa7v1K07U3euJMhyphenhyphenSXpVSoowoR73Dug6RWtpwM0s-2u28Hw5xOZ8ZfrIKila-xIbVZSlt0IjFW17KbudcSxPqGY3cHebVx8CP6PnyXOBNg2YpF6BY/s320/step1.png" width="320" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
Navigate to build.sbt, select default settings.</div>
<div>
<br /></div>
<div>
• (Optional) Attempt to compile using sbt, within IntelliJ:</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJu3A_gQ0nZkNnQl7mmldEg2C6prKzxN78V4Dv9zXQKb85pR4njyuM14TyVgKQzNoyaU_7QOxRCCRqhyphenhyphenz4Ifl4P9Lm6z_UdCQqWsTtC_EQd3R0BJijI658XC1ytHIyZxARrnapDOzAUcM/s1600/step3.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="708" data-original-width="966" height="234" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJu3A_gQ0nZkNnQl7mmldEg2C6prKzxN78V4Dv9zXQKb85pR4njyuM14TyVgKQzNoyaU_7QOxRCCRqhyphenhyphenz4Ifl4P9Lm6z_UdCQqWsTtC_EQd3R0BJijI658XC1ytHIyZxARrnapDOzAUcM/s320/step3.png" width="320" /></a></div>
<div>
<br /></div>
<div>
• Rebuild project using IntelliJ</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjilViuyY58xfvwoZC-Zp3F0E9xTN7kUAAthnsOR0Ueuj_6DrBukSstaTRaYnlJpmslOO2KSUW3QBBHS_57jje8ncJTRvmD7nBbxzKH0EAiXxviv8gWzIGUl0ZWyJhH73CA2J0b7jGjUX4/s1600/step5.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="488" data-original-width="943" height="165" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjilViuyY58xfvwoZC-Zp3F0E9xTN7kUAAthnsOR0Ueuj_6DrBukSstaTRaYnlJpmslOO2KSUW3QBBHS_57jje8ncJTRvmD7nBbxzKH0EAiXxviv8gWzIGUl0ZWyJhH73CA2J0b7jGjUX4/s320/step5.png" width="320" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
• Now for the secret sauce, write your generator object:</div>
<div>
<br /></div>
<div>
Start with running freechips.rocketchip.groundtest.Generator.</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkuiFXhA2i5IMlzkOtLy-FWxSDX5s6FhY0CKD3efVWrY4_p2UKKXqqqkd11tGOSdxmvIygihWC4WpPRrZnN1TXeeN44Dx-9mL0WLSujpY5B101SDkK_fYzO1nsHvCAkNGVmoNmUOO1Ldg/s1600/step6.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="675" data-original-width="876" height="246" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkuiFXhA2i5IMlzkOtLy-FWxSDX5s6FhY0CKD3efVWrY4_p2UKKXqqqkd11tGOSdxmvIygihWC4WpPRrZnN1TXeeN44Dx-9mL0WLSujpY5B101SDkK_fYzO1nsHvCAkNGVmoNmUOO1Ldg/s320/step6.png" width="320" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
It will <span style="color: red;">fail. </span>That is good.</div>
<div>
<br /></div>
<div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">Exception in thread "main" java.lang.IllegalArgumentException: requirement failed: Usage: <span style="background-color: #fff2cc;">sbt> run TargetDir TopModuleProjectName TopModuleName ConfigProjectName ConfigNameString</span></span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><span style="white-space: pre;"> </span>at scala.Predef$.require(Predef.scala:224)</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><span style="white-space: pre;"> </span>at freechips.rocketchip.util.GeneratorApp$class.names(GeneratorUtils.scala:76)</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><span style="white-space: pre;"> </span>at freechips.rocketchip.groundtest.Generator$.names$lzycompute(Generator.scala:7)</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><span style="white-space: pre;"> </span>at freechips.rocketchip.groundtest.Generator$.names(Generator.scala:7)</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><span style="white-space: pre;"> </span>at freechips.rocketchip.groundtest.Generator$.delayedEndpoint$freechips$rocketchip$groundtest$Generator$1(Generator.scala:8)</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><span style="white-space: pre;"> </span>at freechips.rocketchip.groundtest.Generator$delayedInit$body.apply(Generator.scala:7)</span></div>
</div>
<div>
<br /></div>
<div>
Fixing this is left as an exercise to the reader, but I will provide this simple (and, oh so powerful, tip).</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjncnjFaaxWHPD7kgmLZLnkyUIBnu5FPjQn0jjKDGsFlgMkWmp4Z7LpWApabbjET2iOAF10pwL9fQqPKky9O_DTAq9PdCFwuNjDFtL_Gbkn_ISrm5rIFGrqpf8VSmzfe4UkZsEpRPAtFEs/s1600/step7.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="553" data-original-width="1505" height="117" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjncnjFaaxWHPD7kgmLZLnkyUIBnu5FPjQn0jjKDGsFlgMkWmp4Z7LpWApabbjET2iOAF10pwL9fQqPKky9O_DTAq9PdCFwuNjDFtL_Gbkn_ISrm5rIFGrqpf8VSmzfe4UkZsEpRPAtFEs/s320/step7.png" width="320" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
Right click on 'GeneratorApp' from line 'object Generator extends App' and click 'Go To'. This will bring you the definition of the GeneratorApp trait.</div>
<div>
<br /></div>
<div>
So, why not add a breakpoint and debug yourself? The process is outside of the scope of this post.</div>
<div>
<br /></div>
<div>
<div>
• Tips for advanced users:</div>
</div>
<div>
<br /></div>
<div>
I typically do not do work inside the rocket-chip repo. Similar to the firrtl publishLocal step, I do a publishLocal of rocketchip and import the jar into my project. My generator function is highly customized.</div>
<div>
<br /></div>
<div>
See the following for more information:</div>
<div>
<br /></div>
<div><a href="https://github.com/freechipsproject/rocket-chip/pull/1319" target="_blank">
https://github.com/freechipsproject/rocket-chip/pull/1319</a></div>
Edmond Cotehttp://www.blogger.com/profile/05053350465895562853noreply@blogger.com1tag:blogger.com,1999:blog-5634393312307053386.post-40307341514472391982018-03-04T11:46:00.001-08:002018-03-04T11:46:36.205-08:00Super! Busy!I am always working. It is a good thing and a bad thing.<br />
<br />
It took me a long time, but I officially made the Red Hat to Ubuntu switch. I have been a Red Hat/Fedora user since version 6 (nope, not RHEL 6). That is nearly twenty years. Why? It is nothing against Red Hat. Ubuntu simply has a <i>stronger</i> community.Edmond Cotehttp://www.blogger.com/profile/05053350465895562853noreply@blogger.com0tag:blogger.com,1999:blog-5634393312307053386.post-2258773947768262532018-01-21T13:35:00.001-08:002018-03-04T09:43:35.931-08:00Publishing my gists (i.e., ramp up notes)Detailed notes are important when ramping on new technologies. I recently decided to publish these notes at: <a href="https://github.com/edcote/gists">https://gist.github.com/edcote</a><br />
<br />Edmond Cotehttp://www.blogger.com/profile/05053350465895562853noreply@blogger.com0tag:blogger.com,1999:blog-5634393312307053386.post-17976018097768388582018-01-12T12:05:00.004-08:002018-01-12T12:06:07.157-08:00Address Masking for RAM DevicesI found the problem of generating the correct address for a memory operation confusing and decided that it would be of value to me (and others) to take notes. <br />
<br />
Assume we have an implementation of a slave device on a TileLink2 bus. It can receive either read (Get) or write (PutFullData) messages on channel A and correctly return the response on channel D. More information about this in the <a href="https://static.dev.sifive.com/docs/tilelink/tilelink-spec-1.7-draft.pdf">spec</a>.<br />
<br />
The following covers the implementation of the module, specifically on the mask generation, nothing more.<br />
<div>
<br /></div>
<div>
<u>Assumptions</u>. The slave device covers address range 0x2000000, size 0x1FFF (or 8KB). The system bus uses 8 bytes per beat (matching the 64 bit bus). The memory width matches the bus width. Number of memory words is 1024 and address width is 10 bits.</div>
<div>
<br /></div>
<div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><b>val address = in.a.bits.address // receive the full 64-bit physical address</b></span></div>
<div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><b>val size = 0x1FFF // 8KB size, get using addressSet.mask</b></span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><b>val size = in.a.size // log2(bytes) of total amount of the data requested, e.g., 8B cache line == 1</b></span></div>
<div>
<br /></div>
<div>
<div>
<u>Problem</u>. To compute the word-aligned address, you need a mask. Here is an example worked out by hand.</div>
<div>
<br /></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><b>2000_1000 ^ (0x2000_1000 & ~mask-1) = 0x1000 (byte aligned) // where mask = 0x2000</b></span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><b>1000 / 8 = 0x200 (8B word aligned)</b></span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><b>addr[9:0] = 0x200</b></span></div>
</div>
<div>
<br /></div>
<div>
That was the easy part. I got confused by the operation of the circuit generator. Isn't the following great ;)</div>
<div>
<br /></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><b>val a_address = Cat((mask zip (in.haddr >> log2Ceil(beatBytes)).toBools).filter(_._1).map(_._2).reverse)</b></span></div>
<div>
<br /></div>
<div>
This is definitely one the least appealing parts of functional programming. It would take me a few hours to reverse engineer this. How this should work is any non-trivial function should be placed in its own container and unit tested. The unit tests are commented and serve as a description of the functional algorithm. But, I digress ...</div>
<div>
<br /></div>
<div>
There is a helper object in the util package. Moral of the story. Use it.</div>
<div>
<br /></div>
<div>
<div>
<div>
<div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><b>// This gets used everywhere, so make the smallest circuit possible ...</b></span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><b>// Given an address and size, create a mask of beatBytes size</b></span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><b>// eg: (0x3, 0, 4) => 0001, (0x3, 1, 4) => 0011, (0x3, 2, 4) => 1111</b></span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><b>// groupBy applies an interleaved OR reduction; groupBy=2 take 0010 => 01</b></span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><b>object MaskGen {</b></span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><b> def apply(addr_lo: UInt, lgSize: UInt, beatBytes: Int, groupBy: Int = 1): UInt = {</b></span></div>
<span style="font-family: "courier new" , "courier" , monospace;"><b>[..]</b></span></div>
<div>
<br />
<br />
<br />
<br /></div>
</div>
</div>
</div>
</div>
</div>
Edmond Cotehttp://www.blogger.com/profile/05053350465895562853noreply@blogger.com0tag:blogger.com,1999:blog-5634393312307053386.post-59234319836102971992018-01-12T08:16:00.001-08:002018-01-12T08:16:17.935-08:00Mid-January Update<div>
November was mostly about writing a grant proposal for DARPA. It has been 110% technical work since then. Beginning in February, I will shift to writing pretty PowerPoint slides for the company. I should have a minimum viable prototype by then.</div>
<div>
<br /></div>
<div>
I worked on an experiment to build a continuous integration environment for the software assets of the RISC-V Foundation; learning <a href="http://groovy-lang.org/">Groovy</a> and <a href="https://gradle.org/">Gradle</a> the process. The prototype uses Jenkins2 for which I have been pleasantly surprised. My previous experience was Jenkins 1.x. I published source code for the prototype <a href="https://github.com/edcote/riscv-ci">here</a>. I plan to volunteer some time to help coordinate some this activity. It is a small <5%-of-week commitment.</div>
<div>
<br /></div>
<div>
I began to move parts of my internal wiki to <a href="https://gist.github.com/edcote">GitHub gists</a>. I plan to add more over time.</div>
<div>
<br /></div>
<div>
Finally, I am accumulating notes on how to bootstrap RocketChip. You can find the notes <a href="https://gist.github.com/edcote/f30f5c994d60f493fd32f8f9a3674b11">here</a>. </div>
<div>
<br /></div>
<div>
Also, compared to six months ago, I am beginning to feel very comfortable writing functional code using Scala. I struggle a bit here and there (i.e., when recursion comes into play), but overall it is a positive experience. If I had time, I would love to take an advanced class. It would be interesting to re-learn data structures, algorithms through a functional lense.</div>
<div>
<br /></div>
<div>
</div>
Edmond Cotehttp://www.blogger.com/profile/05053350465895562853noreply@blogger.com0tag:blogger.com,1999:blog-5634393312307053386.post-66820139260370906422017-12-14T12:01:00.001-08:002017-12-14T12:01:28.654-08:00Debugging Spike with CLion/CMakeAnother quick entry. I released a template project on GitHub that allows you to build, run, and debug <a href="https://github.com/riscv/riscv-isa-sim">spike</a>, the RISC-V ISA simulation, using CLion.<br />
<br />
<a href="https://github.com/edcote/spike-cmake">https://github.com/edcote/spike-cmake</a><br />
<br />
Clone, import the template, and enjoy!<br />
<br />
<br />Edmond Cotehttp://www.blogger.com/profile/05053350465895562853noreply@blogger.com0tag:blogger.com,1999:blog-5634393312307053386.post-7237571752966008692017-12-13T10:27:00.000-08:002017-12-13T10:27:03.986-08:00CLion Kool-AidDoesn't it feel good to purchase a product/service from a company and be <i>damn</i> happy?<br />
I have been resisting purchasing this product for a few years, heck; I even tried to pirate it (for personal use) at some point.<br />
<br />
CLion!<br />
<br />
<a href="https://www.jetbrains.com/clion/">https://www.jetbrains.com/clion/</a><br />
<br />
That's all. CLion is an incredible tool for C++ development, and you too should buy it. Integration is seamless with Linux/Unix development tools: git, gdb, cmake, clang, etc. Most importantly, use of the product doesn't interfere with others that choose more-traditional development styles.Edmond Cotehttp://www.blogger.com/profile/05053350465895562853noreply@blogger.com0tag:blogger.com,1999:blog-5634393312307053386.post-67238734936130265532017-11-27T09:07:00.001-08:002017-12-04T13:33:08.628-08:00Happy Thanksgiving and GratefulsHappy belated Thanksgiving!<br />
<br />
I am very thankful and happy this year. Grateful for the courage of temporarily leaving corporate life to work on my projects with the aim to launch a business. I have spent the bulk of my career at Fortune 100 companies and, frankly, <u>do not</u> hate it. It is incredibly rewarding to work alongside top engineers and management teams. I arrive at work this morning grateful to have hit "soft reset" on my career. The next year, or so, will be about collaboration and my gradual re-introduction into the corporate world.Edmond Cotehttp://www.blogger.com/profile/05053350465895562853noreply@blogger.com0tag:blogger.com,1999:blog-5634393312307053386.post-22496305582285594942017-11-22T09:42:00.000-08:002017-11-22T09:42:14.068-08:00Connecting Zeppelin, Spark, and MongoDB<div>
It took me a few hours to connect Zeppelin, Spark, and MongoDB. I didn't find a solution to this problem online; thus the short entry.</div>
<div>
<br /></div>
<div>
First, I added a dependency to the <a href="https://docs.mongodb.com/spark-connector/master/">MongoDB Connector for Spark</a> in my Zeppelin notebook.</div>
<div>
<br /></div>
<!-- HTML generated using hilite.me --><br />
<div style="background: #272822; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #f92672;">%</span><span style="color: #f8f8f2;">dep</span>
<span style="color: #f8f8f2;">z</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">reset</span><span style="color: #f92672;">()</span>
<span style="color: #f8f8f2;">z</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">load</span><span style="color: #f92672;">(</span><span style="color: #e6db74;">"org.mongodb.spark:mongo-spark-connector_2.10:2.2.0"</span><span style="color: #f92672;">)</span>
<span style="color: #f92672;">%</span><span style="color: #f8f8f2;">spark</span>
<span style="color: #66d9ef;">import</span> <span style="color: #f8f8f2;">com.mongodb.spark._</span>
<span style="color: #66d9ef;">import</span> <span style="color: #f8f8f2;">com.mongodb.spark.rdd.MongoRDD</span>
<span style="color: #66d9ef;">val</span> <span style="color: #f8f8f2;">rdd</span> <span style="color: #66d9ef;">=</span> <span style="color: #a6e22e;">MongoSpark</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">load</span><span style="color: #f92672;">(</span><span style="color: #f8f8f2;">sc</span><span style="color: #f92672;">)</span>
</pre>
</div>
<div>
<br /></div>
<div>
<div>
This gave :</div>
<div>
<br /></div>
<div>
<div>
<span style="font-family: Courier New, Courier, monospace;">java.lang.IllegalArgumentException: Missing database name. Set via the 'spark.mongodb.input.uri' or 'spark.mongodb.input.database' property</span></div>
</div>
<div>
<br /></div>
<div>
Then, after realizing, that you cannot dynamically reconfigure the SparkContext. I used the GUI to set the property.</div>
<div>
<br /></div>
</div>
<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-JFYLb2kVuAhmb41U4YcoehOF35YmR5ixp0x8sGtQxA4ewVjXTSn3Fibn8Gh31MYmTPfpxwiAaH2BSMOwhcBEe771iwgnux-KWYYRN3ZFJA0BTknXsYorL8ZlijkzSNmHbbrZNo95_g4/s1600/aa.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="449" data-original-width="978" height="146" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-JFYLb2kVuAhmb41U4YcoehOF35YmR5ixp0x8sGtQxA4ewVjXTSn3Fibn8Gh31MYmTPfpxwiAaH2BSMOwhcBEe771iwgnux-KWYYRN3ZFJA0BTknXsYorL8ZlijkzSNmHbbrZNo95_g4/s320/aa.png" width="320" /></a></div>
</div>
<div>
<br /></div>
<div>
It is working well now!</div>
<div>
<br />
<span style="font-family: Courier New, Courier, monospace;">rdd: com.mongodb.spark.rdd.MongoRDD[org.bson.Document] = MongoRDD[0] at RDD at MongoRDD.scala:47</span></div>
<div>
<br /></div>
Edmond Cotehttp://www.blogger.com/profile/05053350465895562853noreply@blogger.com0tag:blogger.com,1999:blog-5634393312307053386.post-29408442555629957752017-11-07T09:21:00.004-08:002017-11-07T09:21:58.472-08:00Early November update: DARPA, GCE, open source releaseIt has been a busy few weeks, and it is not going to get better in November. No big deal because I am enjoying startup life. My biggest challenge is to not work too much. I am in the process of applying for a DARPA research grant for the company<br />
<br />
I have been looking to scale my design environment to the cloud. I followed a friend's recommendation and eval'ed <a href="https://cloud.google.com/compute/">Google Compute Engine</a>. Wow! I was up and running in seconds. I intended to buy an additional workstation to serve as a build server, but the $20,000 in free startup credits have me thinking otherwise.<br />
<br />
I open sourced my design environment to support the effort. Here is a link to the public repository <a href="https://bitbucket.org/ecote/nade">https://bitbucket.org/ecote/nade</a>.<br />
<br />
Here is a picture of an FPGA that I produced.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEYyu5QqYFYZq0Jb6xGD0p-NUjmj3fpT5bHwyUcHYXAfsh5O2ZDL7scsZULwn3kLgvoINIpJZ6xe70rC1gJtd0vm86AxHEl6qqm8r4qrIgLQQEysh2Meq4zRLRUuQIZF6S87Fc_iM0NFg/s1600/hello.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="700" data-original-width="890" height="249" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEYyu5QqYFYZq0Jb6xGD0p-NUjmj3fpT5bHwyUcHYXAfsh5O2ZDL7scsZULwn3kLgvoINIpJZ6xe70rC1gJtd0vm86AxHEl6qqm8r4qrIgLQQEysh2Meq4zRLRUuQIZF6S87Fc_iM0NFg/s320/hello.png" width="320" /></a></div>
<br />
I also recently subscribed to <a href="http://www.grammarly.com/">Grammarly</a>. I am incredibly impressed.<br />
<br />Edmond Cotehttp://www.blogger.com/profile/05053350465895562853noreply@blogger.com0tag:blogger.com,1999:blog-5634393312307053386.post-13795859087917201372017-10-21T11:48:00.002-07:002017-10-21T11:53:39.324-07:00Script to generate Verilog ports from Chisel sourceHere's a script I wrote that will (naively) parse a Verilog file and output it's corresponding ports in Chisel format. This is useful to import a Verilog module as a <a href="https://github.com/freechipsproject/chisel3/wiki/BlackBoxes">blackbox</a> in a Chisel design.<br />
<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #272822; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #f92672;">#!/</span><span style="color: #f8f8f2;">bin</span><span style="color: #f92672;">/</span><span style="color: #f8f8f2;">sh</span>
<span style="color: #f8f8f2;">exec</span> <span style="color: #f8f8f2;">scala</span> <span style="color: #e6db74;">"$0"</span> <span style="color: #e6db74;">"$@"</span>
<span style="color: #f92672;">!</span><span style="color: #66d9ef;">#</span>
<span style="color: #66d9ef;">import</span> <span style="color: #f8f8f2;">scala.util.</span><span style="color: #f92672;">{</span><span style="color: #a6e22e;">Success</span><span style="color: #f92672;">,</span> <span style="color: #a6e22e;">Try</span><span style="color: #f92672;">}</span>
<span style="color: #66d9ef;">import</span> <span style="color: #f8f8f2;">scala.util.matching.Regex</span>
<span style="color: #66d9ef;">val</span> <span style="color: #f8f8f2;">port</span> <span style="color: #66d9ef;">=</span> <span style="color: #f8f8f2;">raw</span><span style="color: #e6db74;">"\s*(input|output|inout)\s+(wire\s*|reg\s*)?\s*(\[(\d+):(\d+)\])?\s*(\w+)?\s*;?"</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">r</span>
<span style="color: #66d9ef;">val</span> <span style="color: #f8f8f2;">p</span> <span style="color: #66d9ef;">=</span> <span style="color: #f8f8f2;">scala</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">io</span><span style="color: #f92672;">.</span><span style="color: #a6e22e;">Source</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">fromFile</span><span style="color: #f92672;">(</span><span style="color: #f8f8f2;">args</span><span style="color: #f92672;">(</span><span style="color: #ae81ff;">0</span><span style="color: #f92672;">)).</span><span style="color: #f8f8f2;">getLines</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">foreach</span> <span style="color: #f92672;">{</span> <span style="color: #f8f8f2;">f</span><span style="color: #66d9ef;">:</span> <span style="color: #66d9ef;">String</span> <span style="color: #f92672;">=></span>
<span style="color: #66d9ef;">val</span> <span style="color: #f8f8f2;">b</span> <span style="color: #66d9ef;">=</span> <span style="color: #f8f8f2;">f</span> <span style="color: #66d9ef;">match</span> <span style="color: #f92672;">{</span>
<span style="color: #66d9ef;">case</span> <span style="color: #f8f8f2;">port</span><span style="color: #f92672;">(</span><span style="color: #f8f8f2;">d</span><span style="color: #f92672;">,</span> <span style="color: #f8f8f2;">tzpe</span><span style="color: #f92672;">,</span> <span style="color: #66d9ef;">_</span><span style="color: #f92672;">,</span> <span style="color: #f8f8f2;">msb</span><span style="color: #f92672;">,</span> <span style="color: #f8f8f2;">lsb</span><span style="color: #f92672;">,</span> <span style="color: #f8f8f2;">name</span><span style="color: #f92672;">)</span> <span style="color: #66d9ef;">=></span>
<span style="color: #66d9ef;">val</span> <span style="color: #f8f8f2;">dir</span> <span style="color: #66d9ef;">=</span> <span style="color: #f8f8f2;">d</span> <span style="color: #66d9ef;">match</span> <span style="color: #f92672;">{</span>
<span style="color: #66d9ef;">case</span> <span style="color: #e6db74;">"input"</span> <span style="color: #66d9ef;">=></span> <span style="color: #e6db74;">"Input"</span>
<span style="color: #66d9ef;">case</span> <span style="color: #e6db74;">"output"</span> <span style="color: #66d9ef;">=></span> <span style="color: #e6db74;">"Output"</span>
<span style="color: #66d9ef;">case</span> <span style="color: #e6db74;">"inout"</span> <span style="color: #66d9ef;">=></span> <span style="color: #e6db74;">"Analog"</span>
<span style="color: #66d9ef;">case</span> <span style="color: #66d9ef;">_</span> <span style="color: #66d9ef;">=></span>
<span style="color: #f92672;">}</span>
<span style="color: #66d9ef;">val</span> <span style="color: #f8f8f2;">w</span> <span style="color: #66d9ef;">=</span> <span style="color: #a6e22e;">Try</span><span style="color: #f92672;">({</span><span style="color: #f8f8f2;">msb</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">toInt</span> <span style="color: #f92672;">-</span> <span style="color: #f8f8f2;">lsb</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">toInt</span> <span style="color: #f92672;">+</span> <span style="color: #ae81ff;">1</span><span style="color: #f92672;">})</span> <span style="color: #66d9ef;">match</span> <span style="color: #f92672;">{</span>
<span style="color: #66d9ef;">case</span> <span style="color: #a6e22e;">Success</span><span style="color: #f92672;">(</span><span style="color: #f8f8f2;">s</span><span style="color: #f92672;">)</span> <span style="color: #66d9ef;">=></span> <span style="color: #f8f8f2;">s</span><span style="color: #e6db74;">"%d".W</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">format</span><span style="color: #f92672;">(</span><span style="color: #f8f8f2;">s</span><span style="color: #f92672;">)</span>
<span style="color: #66d9ef;">case</span> <span style="color: #66d9ef;">_</span> <span style="color: #66d9ef;">=></span> <span style="color: #e6db74;">"1.W"</span>
<span style="color: #f92672;">}</span>
<span style="color: #f8f8f2;">s</span><span style="color: #e6db74;">"val $name = $dir(UInt($w))"</span>
<span style="color: #66d9ef;">case</span> <span style="color: #66d9ef;">_</span> <span style="color: #66d9ef;">=></span> <span style="color: #e6db74;">""</span>
<span style="color: #f92672;">}</span>
<span style="color: #66d9ef;">if</span> <span style="color: #f92672;">(</span><span style="color: #f8f8f2;">b</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">nonEmpty</span><span style="color: #f92672;">)</span> <span style="color: #f8f8f2;">println</span><span style="color: #f92672;">(</span><span style="color: #f8f8f2;">b</span><span style="color: #f92672;">)</span>
<span style="color: #f92672;">}</span>
</pre>
</div>
<br />
The chosen <a href="https://regex101.com/r/Oo9Wv2/1">regular expression</a> was testing using <a href="http://regex101.com/">regex101.com</a>, a populate online regular expression tester.<br />
<br />Edmond Cotehttp://www.blogger.com/profile/05053350465895562853noreply@blogger.com0tag:blogger.com,1999:blog-5634393312307053386.post-47563033791551854792017-10-16T09:19:00.000-07:002017-10-16T09:19:04.710-07:00My Clocking and Reset Strategy with RawModuleThis post is originally a reply to: <a href="https://groups.google.com/forum/#!topic/chisel-users/LTujWW6DtI4">https://groups.google.com/forum/#!topic/chisel-users/LTujWW6DtI4</a><br />
<br />
The following snippet of code illustrates my top level clocking and reset strategy. I opt to use LazyRawModuleImp and explicitly specify the clocks and reset.<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #272822; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #66d9ef;">class</span> <span style="color: #a6e22e;">LazyTop</span><span style="color: #f92672;">(</span><span style="color: #66d9ef;">implicit</span> <span style="color: #f8f8f2;">p</span><span style="color: #66d9ef;">:</span> <span style="color: #66d9ef;">Parameters</span><span style="color: #f92672;">)</span> <span style="color: #66d9ef;">extends</span> <span style="color: #a6e22e;">LazyModule</span> <span style="color: #f92672;">{</span>
<span style="color: #66d9ef;">lazy</span> <span style="color: #66d9ef;">val</span> <span style="color: #f8f8f2;">module</span> <span style="color: #66d9ef;">=</span> <span style="color: #66d9ef;">new</span> <span style="color: #a6e22e;">LazyRawModuleImp</span><span style="color: #f92672;">(</span><span style="color: #66d9ef;">this</span><span style="color: #f92672;">)</span> <span style="color: #f92672;">{</span>
<span style="color: #66d9ef;">val</span> <span style="color: #f8f8f2;">io</span> <span style="color: #66d9ef;">=</span> <span style="color: #a6e22e;">IO</span><span style="color: #f92672;">(</span><span style="color: #66d9ef;">new</span> <span style="color: #a6e22e;">Bundle</span> <span style="color: #f92672;">{</span>
<span style="color: #66d9ef;">val</span> <span style="color: #f8f8f2;">ref_clk_p</span> <span style="color: #66d9ef;">=</span> <span style="color: #a6e22e;">Input</span><span style="color: #f92672;">(</span><span style="color: #a6e22e;">Clock</span><span style="color: #f92672;">())</span>
<span style="color: #66d9ef;">val</span> <span style="color: #f8f8f2;">rst_sw_n</span> <span style="color: #66d9ef;">=</span> <span style="color: #a6e22e;">Input</span><span style="color: #f92672;">(</span><span style="color: #a6e22e;">Bool</span><span style="color: #f92672;">())</span> <span style="color: #75715e;">// async reset, debounced on board?</span>
<span style="color: #66d9ef;">val</span> <span style="color: #f8f8f2;">led_n</span> <span style="color: #66d9ef;">=</span> <span style="color: #a6e22e;">Output</span><span style="color: #f92672;">(</span><span style="color: #a6e22e;">Bits</span><span style="color: #f92672;">(</span><span style="color: #ae81ff;">8.</span><span style="color: #f8f8f2;">W</span><span style="color: #f92672;">))</span>
<span style="color: #f92672;">})</span>
<span style="color: #66d9ef;">val</span> <span style="color: #a6e22e;">GSR_INST</span> <span style="color: #66d9ef;">=</span> <span style="color: #a6e22e;">Module</span><span style="color: #f92672;">(</span><span style="color: #66d9ef;">new</span> <span style="color: #a6e22e;">GSR</span><span style="color: #f92672;">())</span> <span style="color: #75715e;">// this is blackbox module</span>
<span style="color: #a6e22e;">GSR_INST</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">io</span><span style="color: #f92672;">.</span><span style="color: #a6e22e;">GSR</span> <span style="color: #f92672;">:=</span> <span style="color: #f8f8f2;">io</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">rst_sw_n</span>
<span style="color: #66d9ef;">val</span> <span style="color: #f8f8f2;">global_reset</span> <span style="color: #66d9ef;">=</span> <span style="color: #a6e22e;">Wire</span><span style="color: #f92672;">(</span><span style="color: #a6e22e;">Bool</span><span style="color: #f92672;">())</span>
<span style="color: #66d9ef;">val</span> <span style="color: #f8f8f2;">global_reset_n</span> <span style="color: #66d9ef;">=</span> <span style="color: #a6e22e;">Wire</span><span style="color: #f92672;">(</span><span style="color: #a6e22e;">Bool</span><span style="color: #f92672;">())</span>
<span style="color: #f8f8f2;">global_reset_n</span> <span style="color: #f92672;">:=</span> <span style="color: #a6e22e;">GSR_INST</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">io</span><span style="color: #f92672;">.</span><span style="color: #a6e22e;">GSR</span> <span style="color: #75715e;">// appears GSR is active low</span>
<span style="color: #f8f8f2;">global_reset</span> <span style="color: #f92672;">:=</span> <span style="color: #f92672;">!</span><span style="color: #a6e22e;">GSR_INST</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">io</span><span style="color: #f92672;">.</span><span style="color: #a6e22e;">GSR</span>
<span style="color: #75715e;">// use active high clock</span>
<span style="color: #f8f8f2;">withClockAndReset</span><span style="color: #f92672;">(</span><span style="color: #f8f8f2;">ref_clk_p</span><span style="color: #f92672;">,</span> <span style="color: #f8f8f2;">global_reset</span><span style="color: #f92672;">)</span> <span style="color: #f92672;">{</span>
<span style="color: #f8f8f2;">io</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">led_n</span> <span style="color: #f92672;">:=</span> <span style="color: #a6e22e;">RegNext</span><span style="color: #f92672;">(</span><span style="color: #e6db74;">"h5A"</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">asUInt</span><span style="color: #f92672;">(</span><span style="color: #ae81ff;">8.</span><span style="color: #f8f8f2;">W</span><span style="color: #f92672;">),</span> <span style="color: #f8f8f2;">init</span> <span style="color: #66d9ef;">=</span> <span style="color: #ae81ff;">0.</span><span style="color: #f8f8f2;">U</span><span style="color: #f92672;">)</span>
<span style="color: #f92672;">}</span>
<span style="color: #f92672;">}</span>
<span style="color: #f92672;">}</span>
</pre>
</div>
<br />
Module GSR is a Chisel BlackBox for my FPGA's GSR (global set reset) library cell.<br />
<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #272822; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"><span style="color: #66d9ef;">class</span> <span style="color: #a6e22e;">GSR</span> <span style="color: #66d9ef;">extends</span> <span style="color: #a6e22e;">BlackBox</span> <span style="color: #f92672;">{</span>
<span style="color: #66d9ef;">val</span> <span style="color: #f8f8f2;">io</span> <span style="color: #66d9ef;">=</span> <span style="color: #a6e22e;">IO</span><span style="color: #f92672;">(</span><span style="color: #66d9ef;">new</span> <span style="color: #a6e22e;">Bundle</span> <span style="color: #f92672;">{</span>
<span style="color: #66d9ef;">val</span> <span style="color: #a6e22e;">GSR</span> <span style="color: #66d9ef;">=</span> <span style="color: #a6e22e;">Input</span><span style="color: #f92672;">(</span><span style="color: #a6e22e;">Bool</span><span style="color: #f92672;">())</span>
<span style="color: #f92672;">})</span>
<span style="color: #f92672;">}</span>
</pre>
</div>
<br />Edmond Cotehttp://www.blogger.com/profile/05053350465895562853noreply@blogger.com0tag:blogger.com,1999:blog-5634393312307053386.post-5524870242867581112017-10-04T13:48:00.001-07:002017-10-04T13:48:44.285-07:00To link Chisel annotations and circuit infoHere's another snippet of Chisel code. It was well worth the (ashamed to admit) 4+ hrs to write. Admittedly, I am still getting a hand of functional programming. I am particularly proud of the recursive function call to populate an immutable val. The function's use case is to return Chisel circuit level information from an Annotation object. It is necessary because Annotation does not contain (do best of my knowledge) a reference to a Data object.<br />
<br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #272822; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<pre style="line-height: 125%; margin: 0;"> <span style="color: #66d9ef;">private</span> <span style="color: #66d9ef;">def</span> <span style="color: #f8f8f2;">getDirection</span><span style="color: #f92672;">(</span><span style="color: #f8f8f2;">circuit</span><span style="color: #66d9ef;">:</span> <span style="color: #66d9ef;">Circuit</span><span style="color: #f92672;">,</span> <span style="color: #f8f8f2;">a</span><span style="color: #66d9ef;">:</span> <span style="color: #66d9ef;">Annotation</span><span style="color: #f92672;">)</span><span style="color: #66d9ef;">:</span> <span style="color: #66d9ef;">ActualDirection</span> <span style="color: #f92672;">=</span> <span style="color: #f92672;">{</span>
<span style="color: #75715e;">// get net info from annotation object</span>
<span style="color: #66d9ef;">val</span> <span style="color: #f8f8f2;">thisModName</span> <span style="color: #66d9ef;">=</span> <span style="color: #f8f8f2;">a</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">target</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">asInstanceOf</span><span style="color: #f92672;">[</span><span style="color: #66d9ef;">ComponentName</span><span style="color: #f92672;">].</span><span style="color: #f8f8f2;">module</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">name</span>
<span style="color: #66d9ef;">val</span> <span style="color: #f8f8f2;">thisPortName</span> <span style="color: #66d9ef;">=</span> <span style="color: #f8f8f2;">a</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">target</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">name</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">replace</span><span style="color: #f92672;">(</span><span style="color: #e6db74;">"io."</span><span style="color: #f92672;">,</span> <span style="color: #e6db74;">""</span><span style="color: #f92672;">)</span> <span style="color: #75715e;">// FIXME: this is a HACK ..</span>
<span style="color: #75715e;">// find matching module in Chisel circuit</span>
<span style="color: #66d9ef;">val</span> <span style="color: #f8f8f2;">module</span> <span style="color: #66d9ef;">=</span> <span style="color: #f8f8f2;">circuit</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">components</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">flatMap</span> <span style="color: #f92672;">{</span>
<span style="color: #66d9ef;">case</span> <span style="color: #f8f8f2;">m</span><span style="color: #66d9ef;">:</span> <span style="color: #66d9ef;">DefModule</span> <span style="color: #f92672;">=></span> <span style="color: #a6e22e;">Some</span><span style="color: #f92672;">(</span><span style="color: #f8f8f2;">m</span><span style="color: #f92672;">)</span>
<span style="color: #66d9ef;">case</span> <span style="color: #f8f8f2;">b</span><span style="color: #66d9ef;">:</span> <span style="color: #66d9ef;">DefBlackBox</span> <span style="color: #f92672;">=></span> <span style="color: #a6e22e;">None</span>
<span style="color: #f92672;">}.</span><span style="color: #f8f8f2;">find</span> <span style="color: #f92672;">{</span>
<span style="color: #66d9ef;">_</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">name</span> <span style="color: #f92672;">==</span> <span style="color: #f8f8f2;">thisModName</span>
<span style="color: #f92672;">}.</span><span style="color: #f8f8f2;">head</span>
<span style="color: #75715e;">// recursively return Element objects</span>
<span style="color: #66d9ef;">def</span> <span style="color: #f8f8f2;">elemsFromData</span><span style="color: #f92672;">(</span><span style="color: #f8f8f2;">d</span><span style="color: #66d9ef;">:</span> <span style="color: #66d9ef;">Data</span><span style="color: #f92672;">)</span><span style="color: #66d9ef;">:</span> <span style="color: #66d9ef;">Seq</span><span style="color: #f92672;">[</span><span style="color: #66d9ef;">Element</span><span style="color: #f92672;">]</span> <span style="color: #66d9ef;">=</span> <span style="color: #f8f8f2;">d</span> <span style="color: #66d9ef;">match</span> <span style="color: #f92672;">{</span>
<span style="color: #66d9ef;">case</span> <span style="color: #f8f8f2;">e</span><span style="color: #66d9ef;">:</span> <span style="color: #66d9ef;">Element</span> <span style="color: #f92672;">=></span> <span style="color: #a6e22e;">Seq</span><span style="color: #f92672;">(</span><span style="color: #f8f8f2;">e</span><span style="color: #f92672;">)</span>
<span style="color: #66d9ef;">case</span> <span style="color: #f8f8f2;">r</span><span style="color: #66d9ef;">:</span> <span style="color: #66d9ef;">Record</span> <span style="color: #f92672;">=></span>
<span style="color: #f8f8f2;">r</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">elements</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">flatMap</span><span style="color: #f92672;">((</span><span style="color: #f8f8f2;">e</span><span style="color: #66d9ef;">:</span> <span style="color: #f92672;">(</span><span style="color: #66d9ef;">String</span><span style="color: #f92672;">,</span> <span style="color: #66d9ef;">Data</span><span style="color: #f92672;">))</span> <span style="color: #66d9ef;">=></span> <span style="color: #f92672;">{</span>
<span style="color: #f8f8f2;">elemsFromData</span><span style="color: #f92672;">(</span><span style="color: #f8f8f2;">e</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">_2</span><span style="color: #f92672;">)</span>
<span style="color: #f92672;">}).</span><span style="color: #f8f8f2;">toSeq</span>
<span style="color: #f92672;">}</span>
<span style="color: #75715e;">// all elements for all module port</span>
<span style="color: #66d9ef;">val</span> <span style="color: #f8f8f2;">elems</span><span style="color: #66d9ef;">:</span> <span style="color: #66d9ef;">Seq</span><span style="color: #f92672;">[</span><span style="color: #66d9ef;">Element</span><span style="color: #f92672;">]</span> <span style="color: #66d9ef;">=</span> <span style="color: #f8f8f2;">module</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">ports</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">flatMap</span><span style="color: #f92672;">((</span><span style="color: #f8f8f2;">p</span><span style="color: #66d9ef;">:</span> <span style="color: #66d9ef;">Port</span><span style="color: #f92672;">)</span> <span style="color: #66d9ef;">=></span> <span style="color: #f92672;">{</span>
<span style="color: #f8f8f2;">elemsFromData</span><span style="color: #f92672;">(</span><span style="color: #f8f8f2;">p</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">id</span><span style="color: #f92672;">)</span>
<span style="color: #f92672;">})</span>
<span style="color: #75715e;">// use DataMirror to find direction, have yet to test whether fully accurate</span>
<span style="color: #75715e;">// FIXME: obviously not optimal, should filter above</span>
<span style="color: #66d9ef;">val</span> <span style="color: #f8f8f2;">dir</span> <span style="color: #66d9ef;">=</span> <span style="color: #a6e22e;">DataMirror</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">directionOf</span><span style="color: #f92672;">(</span><span style="color: #f8f8f2;">elems</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">find</span><span style="color: #f92672;">(</span><span style="color: #66d9ef;">_</span><span style="color: #f92672;">.</span><span style="color: #f8f8f2;">name</span> <span style="color: #f92672;">==</span> <span style="color: #f8f8f2;">thisPortName</span><span style="color: #f92672;">).</span><span style="color: #f8f8f2;">head</span><span style="color: #f92672;">)</span>
<span style="color: #f8f8f2;">dir</span>
<span style="color: #f92672;">}</span>
</pre>
</div>
Edmond Cotehttp://www.blogger.com/profile/05053350465895562853noreply@blogger.com0