Posts

Showing posts from June, 2013

Git Branches Are Not Branches

Git branches have confused me (someone who uses mercurial a lot and git a little) for a while, I have finally realized why. The problem is that git branch is a poorly chosen name for the thing that they really are. You see, all the changeset history in git is stored as a Directed Acyclic Graph (DAG). The code history might be simple and linear which will make the DAG have a simple path like so (o's are nodes in the graph, called changesets, -'s are references from one node to another, with time progressing from left to right): o-o-o-o-o Or the code history and corresponding DAG could be more complicated: o-o-o / o-o-o o-o-o-o-o / \ / \ o-o-o-o-o-o-o-o-o-o-----o-o Most English language speakers would agree that those parts of the DAG (code history) where a node has two children (representing two parallel lines of development) are called, branches. The above example has four branches in the history, four branche...

SystemVerilog Constraint Gotcha

I found another one (I guess I still need to order that book ). In using the UVM, I have some sequences randomizing other sub sequences. I really want it to work like this (simplified, non-UVM) example: class Foo; rand int bar; function void display (); $display ( "bar: %0d" , bar); endfunction endclass class Bar; int bar; function void body (); Foo foo = new (); bar = 3; foo. display (); assert (foo. randomize () with {bar == this .bar;}); foo. display (); endfunction endclass module top; Bar bar; initial begin bar = new (); bar. body (); end endmodule See the problem there? Here's what prints out when you run the above: bar: 0 bar: -1647275392 foo.bar is not constrained to be 3 like you might expect. That's because this.bar refers to bar that is a member of class Foo, not bar that's a member of class Bar. As far as I can tell, there is no way to refer to ba...