Deferring architecture choice in SystemVerilog

One size may not fit all instances of a design component. For example, depending on the timing context, a fast and expensive implementation may be justified for one instance, but be overkill for another. You could try to figure out all those details, and lock them down with configurations, but it would be better to defer these choices to the tools, letting them adapt fluidly to changes in context.

In SystemVerilog one way to describe alternative implementations is with nested modules (23.4). For example, suppose the module has an output port “out” of type “T”. Then for each alternative implementation, you could declare a nested module with only one port — an output port of that same type “T” — but pick up the inputs from the surrounding module scope instead of using port connections. Suppose further that there are three nested modules named “fast”, “little” and “medium”.

T Impls[3];

fast fast(Impls[0]);
little little(Impls[1]);
medium medium(Impls[2]); always @(posedge clk) begin assert final ($size(Impls.unique) == 1); out <= Impls[0]; end

The simulator (via the assertion) would check that indeed the implementations do yield the same results, and an intelligent synthesis tool would understand this implication of the assertion and preserve all implementation options until there is enough contextual information to make an optimal choice.

Functional programming in C++14, instead of templates

According to Christoph Kohlhepp (tip o’ the hat to Greg Jaxon)

C++14 generic lambdas enable a degree of functional programming that has, until now, been impossible in C++.


They make C++ constructs more concise.


They eliminate many use cases of template syntax that has been a hallmark of C++ since the introduction of the STL.


When the C++ standard introduced template, an entire coding style of generic programming unfolded on this which made “<>” as ubiquitous as the pointer symbol “*” had been in C land. With the introduction of generic lambdas to the C++ standard, a genuine functional coding style is about to unfold and perhaps make the keyword auto just as ubiquitous.


Using Skype like a professional

IEEE-USA Today’s Engineer published a practical article by John R. Platt , “Tips for Effective Skype Job Interviews“, which is worth reading by anyone who needs to videoconference with a laptop or mobile device for professional reasons. Three takeaway messages are

  1. Practice and fine-tune your Skype setup and manner with a friend until you look professional and can hear and be heard clearly.
  2. Sit no more than an arm’s length away from the camera with your face centered on the screen and the camera at eye level in front of an uncluttered background.
  3. There’s more delay than on a voice-only phone call and it may be made worse by bandwidth issues.

Here are some excerpts from Platt’s article

The first challenge is to think about where … It should be a nice, quiet spot where you won’t be interrupted or bothered … If your house has the potential to be noisy, make sure that people know you need a good hour of quiet and privacy.
Take a few minutes to make sure the room has good lighting and lacks visual distractions. You don’t want the person on the other end of the Skype call to struggle to see your face if it is shrouded in darkness. … Bare walls or an office-like setting are best … “If nothing else, buy a screen and put it behind you,” …
Next, think about how you’re actually going to set up your device. Whether you’re calling from a desktop computer, laptop or other mobile device, you want to make sure that your camera is set up at eye level. This ensures that the video feed is captured at a natural angle (not pointing up your nose) …
Also, make sure the camera isn’t too close to you or too far away from where you’ll be sitting. … You should sit no more than an arm’s length away from the webcam … and then be centered on the screen.
Give proper consideration to the audio, too. Do you want to just use the microphone and speakers built into your device, or do you want to wear a headset? You want to make sure that the interviewer can hear you and you can hear them. …
Of course, all technology is fallible, so test everything out well before you begin your interview. “The biggest challenge I see over and over is candidates do not test their microphones before connecting,” says software engineer Sid Savara. “It is a huge, huge professional mistake in my opinion. …”
Savara suggests “showing up” 30 minutes early for the interview and trying a few test calls with a family member or friend to make sure that everything is working properly. This helps to make sure that your broadband connection is working well enough to handle the video. It also gives you a chance to make sure that the audio sounds crisp and clear and that you didn’t miss anything hiding in the background behind you. (We all go a little “blind” when we’re looking at something we see every day, so an outside set of eyes might see something that has become invisible to you.)
If you’re not a frequent Skype user, it might take more than 30 minutes of practice. Make sure you know how the chat, screen-sharing and other features work. You don’t want to be stumbling around during the interview. If you can use Skype with confidence, you’ll be more confident in your interview and be better able to showcase your skills. …
You’ve already spent some time making sure your video and audio work, so now you need to make sure you look good on camera. “Sit up straight, and don’t treat it like a regular, chilled-out Skype call with friends,” …
Figuring out exactly when and where to look at the camera can be difficult. In an in-person interview, it’s easy to make eye contact. That’s impossible on a Skype interview. Spend a good portion of your time looking directly at the camera, since that is “the best way to simulate the type of eye contact that happens in a live interview,” … On the other hand, “don’t stare at the camera, because that will make you look weird,” …
Posture and body language matter. “Sit forward in your chair so your energy is in your body,” … “Keep your feet planted on the ground to enable gesturing.” Gestures are important because they help bring you to life on the screen. “The animation will be projected into your voice and show your energy and enthusiasm,” …
Even though you have practiced, understand the limits of the technology. “You need to take artificially long pauses on Skype interviews … There is always a little more lag than you think.”



Bromley & Winkelmann’s programmer’s utility library for SystemVerilog

According to Jonathan Bromley and André Winkelmann in “svlib – a programmer’s utility library for SystemVerilog

svlib is a free, open-source library of utility functions for SystemVerilog. It includes file and string manipulation functions, full regular expression search/replace, easy reading and writing of configuration files, access to environment variables and wall-clock time, and much more.

Paper | Presentation | Download

Britain’s glorious war resisters

According to Adam Hochschild about some anti-war heroes from nearly a century ago

It was in Britain that significant numbers of war resisters first acted on their beliefs and paid the price. They did not even come close to stopping the bloodshed, but their strength of conviction remains one of the glories of a dark time. By the conflict’s end, more than 20,000 British men of military age would refuse the draft. Many, on principle, also refused the noncombatant alternative service offered to conscientious objectors, and more than 6,000 served prison terms under harsh conditions: hard labor, a bare-bones diet, and a strict “rule of silence.” This was one of the largest groups ever jailed for political reasons in a Western democracy. War opponents behind bars also included older men—and a few women—as well. If we could time-travel our way into British prisons in late 1917 and early 1918 we would meet the nation’s leading investigative journalist, a future winner of the Nobel Prize, more than half a dozen future members of Parliament, one future cabinet minister, and a former newspaper editor who was now publishing a clandestine journal for his fellow inmates on toilet paper. It would be rare to find a more distinguished array of people ever imprisoned together.

How to slice a SystemVerilog interface

A synthesizable interface coding example connecting a server to 16 clients. The server is passed a large interface with 16 pairs of request and response words, and each client is passed a small interface that gives access to only one pair. This is done by first passing the big interface to each of the small interfaces, and then passing the small interfaces to the clients using a modport that restricts access to just one pair.

localparam type requestType = byte;
localparam type responseType = int;

module testMod#(N=16);

  wire clk, rst;

  allIfc#(N) allInst(clk, rst);
  serverMod#(N) serverInst(allInst.serverMp);

  for (genvar I = 0; I < N; I++) begin:GEN
    sliceIfc#(I) sliceInst(allInst.clientMp);
    clientMod clientInst(sliceInst.clientMp);


interface automatic allIfc#(N=0)(input clk, rst);

  var requestType Requests[N];
  var responseType Responses[N];

  function requestType requestRead(int index);
    return Requests[index];

  function void responseWrite(int index, responseType response);
    Responses[index] <= response;

  modport clientMp(output Requests, input Responses,
                   input clk, rst);

  modport serverMp(input Requests, output Responses,
                   import requestRead, responseWrite,
                   input clk, rst);


interface automatic sliceIfc#(I=0)(allIfc.clientMp allInst);

  var requestType request;
  var responseType response;

  assign allInst.Requests[I] = request;
  assign response = allInst.Responses[I];

  function void requestWrite(requestType req);
    request <= req;

  function responseType responseRead();
    return response;

  wire clk = allInst.clk;
  wire rst = allInst.rst;

  modport clientMp(output request, input response,
                   import requestWrite, responseRead,
                   input clk, rst);


module clientMod(sliceIfc.clientMp sliceInst);
  // ...

module serverMod#(N=0)(allIfc.serverMp allInst);
  // ...

Copyright © 2014 Brad Pierce

In all the world there's no one like you or me


Get every new post delivered to your Inbox.

Join 68 other followers