Posts

No More Ads, Send Tips with Bitcoin

Summary: ads are gone, send me bitcoin to say thanks instead. I have always kept notes for myself to remind myself how to do various things. I have also kept a journal since a very young age where I often include opinions and thoughts on various matters. At some point, years ago, I got the idea that I should post some of the notes and thoughts in case they would help someone else. That requires a lot more work than just typing stuff quickly into a text file, though, so I needed a little more motivation. I mean, sharing and helping others is great motivation, but when I read about Adsense from Google, and how Google could show people links to products and services related to my posts, and I could make a few bucks if people thought those links were useful and clicked on them, and how it could help out the people providing those products and services as well, it felt like this great intertwined synergy of helping people out and possibly even gaining some monetary reward as well. An...

List Foreign Keys in Your Postgresql Database

I wanted to know which tables referenced a certain other table in my database, but being a very occasional user of SQL, I didn't know where to begin to find that. Fortunately, the internet had the answer , from Tom Lane himself actually. Just run this query on your Postgresql database: select confrelid::regclass, af.attname as fcol, conrelid::regclass, a.attname as col from pg_attribute af, pg_attribute a, (select conrelid,confrelid,conkey[i] as conkey, confkey[i] as confkey from (select conrelid,confrelid,conkey,confkey, generate_series(1,array_upper(conkey,1)) as i from pg_constraint where contype = 'f') ss) ss2 where af.attnum = confkey and af.attrelid = confrelid and a.attnum = conkey and a.attrelid = conrelid; That shows all foreign key relationships in your database. If you just want to see which tables reference a particular table, do this (replace my_table and my_referenced_column with the table column you want to see t...

Free Verilog Simulators

At DVCon 2013 I asked JL Gray 's panel if we would ever have Free tools, like the software world. None of panelists seemed to think so, one of the panelists, a Mentor employee, scoffed, "you get what you pay for with free tools." Never mind that their (and Cadence's and Synopsys's) products are very likely developed with tools that contain millions of lines of Free software. So, to work towards answering my own question, I spent a little time and looked for Free/Open Source verilog simulators. Here's what I found: Icarus Verilog GPL Cver PVSim Verilog Simulator VeriWell Verilog Simulator I have personally used Icarus and Cver before, but not very extensively.  They were usable and seemed pretty complete, for Verilog.  None of the above claim any support of SystemVerilog except for Icarus.  The Icarus developer at one point expressed abhorrence at SystemVerilog but it seems support for some parts of the language have been added. PVSim and Veri...

SystemVerilog String Literal "Gotcha"

I just ran into another fun SystemVerilog Gotcha. Look this code over and see what you think should happen: module top; string foo[ byte ]; byte bar; initial begin $display ( "%0d" , "a string" == foo[ "not a byte" ]); foo[ "e" ] = "a string" ; $display ( "%0d" , "a string" == foo[ "not a byte" ]); bar = "not a byte" ; $display ( "bar: %0s" , bar); end endmodule Compile error, right? You can't index into an associative array with a string when it is declared to take a byte, can you? And you can't assign a string to a variable of type byte, right? Ha! This actually compiles and runs without any errors or warnings. String literals are packed arrays of bytes and they are automatically truncated to the width of the thing they are being assigned to. Here's the output from running the above code: 0 1 bar: e After my last...

SystemVerilog Fork Disable "Gotchas"

This is a long post with a lot of SystemVerilog code. The purpose of this entry is to hopefully save you from beating your head against the wall trying to figure out some of the subtleties of SystemVerilog processes (basically, threads). Subtleties like these are commonly referred to in the industry as "Gotchas" which makes them sound so playful and fun, but they really aren't either. I encourage you to run these examples with your simulator (if you have access to one) so that a) you can see the results first hand and better internalize what's going on, and b) you can tell me in the comments if this code works fine for you and I'll know I should go complain to my simulator vendor. OK, I'll start with a warm-up that everyone who writes any Verilog or SystemVerilog at all should be aware of, tasks are static by default. If you do this: module top; task do_stuff ( int wait_time); #wait_time $display ( "waited %0d, then did stuff" , wa...

EDA Marketing Problem

I started out trying to write an eloquent essay on the merits of different ways of sharing new ideas and information in order to further the art of digital design verification (in other words, how to market this stuff), but I couldn't make it sound right. Instead, let me just point to some recent examples: Good examples Namespaces, Build Order, and Chickens Cadence's UVM video series These are brief and to-the-point. If you have a question, they quickly give you answer. If you are taking 2 or 3 minutes to browse the internet while waiting for a simulation to finish, maybe even on your phone while you take a little time away from your desk, you can get all the info in that time. Perfect. Examples of Ideas That Could be Marketed Better Monitoring signals by name, for the UVM register package and more and: A 30 Minute Project Makeover Using Continuous Integration First of all, kudos to Verilab for sharing ideas, knowledge, and source code as much they do. The...

Environment Manager for More than Just Python

This whole virtualenv thing is pretty cool, but it has always seemed too specific to Python for me. Let me see if I can explain. At first I had no use for virtualenv whatsoever, I could just sudo apt-get install python-whatever and get what I needed. As my distro got older and I didn't want to update my whole system, I started using virtualenv and pip to install and manage python packages instead of apt. It's great, except that the postgresql packages that came with my distro were getting crusty too. Because postgresql is not a python package, I get no help from virtualenv. Does anyone else have this problem? How do you deal with it? This reminds me of a very old problem from the chip design (EDA, ASIC design, whatever you want to call it) world. To design chips you buy licenses for expensive simulators and synthesis tools, and those tools are constantly being revved, fixing old bugs, introducing new features, and unfortunately, introducing new bugs. Because of that...