In SystemVerilog unpacked array dimensions, use downto indexing [N-1:0]

Regarding that a declaration of [N] for a SystemVerilog unpacked array dimension implies upto indexing [0:N-1], I noted here that by instead using the hardware-style downto indexing [N-1:0] you can split/merge dimensions more fluidly. For example,

typedef struct {int x, y;} T;

module test#(N=2,M=3)
(   output T A_2D[(2**N)-1:0][(2**M)-1:0]
,   output T A_1D[(2**(N+M))-1:0]
);

logic [N-1:0] idx_N;
logic [M-1:0] idx_M;

always_comb begin
   for (int i = 0; i < 2**N; i++) begin
     for (int j = 0; j < 2**M; j++) begin
       idx_N = i;
       idx_M = j;
       A_2D[idx_N][idx_M] = '{i,j};
       A_1D[{idx_N,idx_M}] = '{i,j};
       assert final (A_2D[idx_N][idx_M] == A_1D[{idx_N,idx_M}]);
     end
   end
end
 
endmodule:test

But with upto indexing [0:N-1] you’d need to flip the order of dimensions in the indexes, as in

typedef struct {int x, y;} T;

module test#(N=2,M=3)
(   output T A_2D[0:(2**N)-1][0:(2**M)-1]
,   output T A_1D[0:(2**(N+M))-1]
);

logic [N-1:0] idx_N;
logic [M-1:0] idx_M;

always_comb begin
   for (int i = 0; i < 2**N; i++) begin
     for (int j = 0; j < 2**M; j++) begin
       idx_N = i;
       idx_M = j;
       A_2D[idx_N][idx_M] = '{i,j};
       A_1D[{idx_M,idx_N}] = '{i,j};
      assert final (A_2D[idx_N][idx_M] == A_1D[{idx_M,idx_N}]);
     end
   end
end

endmodule:test

To win the prize, take risks

According to 2014 Nobel-prize physicist Shuji Nakamura, when asked “Why did you succeed with the blue LED when others failed?”

Nobody thought that gallium nitride would work. So it was a really crazy thing to pick gallium nitride. Luckily, it worked. The most important thing in science and technology is to take risks, like gambling in a way.

According to Nathaniel Branden in The Six Pillars of Self-Esteem

That which we call “genius” has a great deal to do with independence, courage, and daring — a great deal to do with nerve. This is one reason we admire it. In the literal sense, such “nerve” cannot be taught; but we can support the process by which it is learned. If human happiness, well-being, and progress are our goals, it is a trait we must strive to nurture — in our child-rearing practices, in our schools, in our organizations, and first of all in ourselves.

 

Cold fusion is real — independent test of Industrial Heat’s “E-Cat” nickel/lithium/hydrogen reactor

According to the preprint of Levi, et al.’s “Observation of abundant heat production from a reactor device and of isotopic changes in the fuel“,

New results are presented from an extended experimental investigation of anomalous heat production in a special type of reactor tube operating at high temperatures. The reactor, named E-Cat, is charged with a small amount of hydrogen-loaded nickel powder plus some additives, mainly Lithium. The reaction is primarily initiated by heat from resistor coils around the  reactor tube. Measurements of the radiated power from the reactor were performed with high-resolution thermal imaging  cameras. The measurements of electrical power input were performed with a large bandwidth three-phase power analyzer. Data were collected during 32 days of running in March 2014. The reactor operating point was set to about 1260 ºC in the  first half of the run, and at about 1400 °C in the second half. The measured energy balance between input and output heat yielded a COP factor of about 3.2 and 3.6 for the 1260 ºC and 1400 ºC runs, respectively. The total net energy obtained  during the 32 days run was about 1.5 MWh. This amount of energy is far more than can be obtained from any known chemical sources in the small reactor volume.
A sample of the fuel was carefully examined with respect to its isotopic composition before the run and after the run, using  several standard methods: XPS, EDS, SIMS, ICP-MS and ICP-AES. The isotope composition in Lithium and Nickel was  found to agree with the natural composition before the run, while after the run it was found to have changed substantially.  Nuclear reactions are therefore indicated to be present in the run process, which however is hard to reconcile with the fact  that no radioactivity was detected outside the reactor during the run.

Tip o’ the hat to Frank Acland.

Don’t use X assignments to make SystemVerilog case statements more pessimistic

According to Stuart Sutherland (paper, slides)

The best way to handle X problems is to detect the X as close to its original source as possible. This paper has shown how SystemVerilog assertions can be used to easily detect and isolate design bugs that result in an X. With early detection, it is not necessary to rely on X propagation to detect design problems.

and

10.3. X-assignment guidelines

Using X assignments to make if…else and case statements more pessimistic should not be used. They add overhead to simulation, and can simulate differently than the logic that is generated from synthesis. The pessimistic X propagation can lead to false failures that can take time to debug and determine that there not be a problem in actual silicon. In lieu of using pessimistic coding styles to propagate X values, problems should be trapped at the select condition, as shown in Section 9, and discussed in the following guideline.

10.4. Trapping X guidelines

All RTL models intended for synthesis should have SystemVerilog assertions detect X values on if…else and case select conditions. Other critical signals can also have X-detect assertions on them. Design engineers should be responsible for adding these assertions. Section 9 showed how easy it is to add X-detecting assertions.

USA plans to spend at least $1,000,000,000,000 on preparations for nuclear war over the next 30 years

According to Jon B. Wolfsthal, Jeffrey Lewis and Marc Quint in “The trillion dollar nuclear triad: US strategic nuclear modernization over the next thirty years”

The United States maintains a robust nuclear arsenal deployed on a triad of strategic delivery systems, including land- and submarine-based long-range ballistic missiles and nuclear-capable bombers. In addition, it also has a significant number of nonstrategic and nondeployed warheads not constrained by US-Russian arms control treaties. Over the next thirty years, the United States plans to spend approximately $1 trillion maintaining the current arsenal, buying replacement systems, and upgrading existing nuclear bombs and warheads.

and

The United States is on course to spend approximately $1 trillion dollars over the next thirty years to maintain its current nuclear arsenal and procure a new generation of nuclear-armed or nuclear-capable bombers, submarines, SLBMs, and ICBMs. While to some these costs may seem large, previous efforts to build the triad have been similarly expensive. In almost all cases, we have chosen to leave out categories of costs that could not be accurately identified, but that clearly exist and are part of the nuclear deterrent. In addition, the estimates above do not include the cost increases over the current projections provided by the DOD or DOE, Congressional Budget Office, or Government Accountability Office, even though military procurement programs often experience budget increases — sometimes significant increases over 50 percent of the original estimated cost. Most significantly, the estimate omits “legacy” costs associated with dismantling retired weapon systems and supporting retired workers and veterans — including long-term pension and healthcare costs — because these costs are not readily identifiable in budget documents.

According to USA President Dwight D. Eisenhower half a century ago

What can the world, or any nation in it, hope for if no turning is found on this dread road?

The worst to be feared and the best to be expected can be simply stated.

The worst is atomic war.

The best would be this: a life of perpetual fear and tension; a burden of arms draining the wealth and the labor of all peoples; a wasting of strength that defies the American system or the Soviet system or any system to achieve true abundance and happiness for the peoples of this earth.

Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed.

This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals.

It is some 50 miles of concrete highway. We pay for a single fighter with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people.

This, I repeat, is the best way of life to be found on the road the world has been taking.

This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron. These plain and cruel truths define the peril and point to the hope that comes with this spring of 1953.

This is one of those times in the affairs of nations when the gravest choices must be made, if there is to be a turning toward a just and lasting peace. It is a moment that calls upon the governments of the world to speak their intentions with simplicity and with honesty. It calls upon them to answer the questions that stirs the hearts of all sane men: is there no other way the world may live?

At best it’s a grotesque waste of “the sweat of its laborers, the genius of its scientists, the hopes of its children”. At worst it’s a “ton of graveyard earth”.

According to Bright Star Sound

Few people know of him … yet conceivably hundreds of millions of people are alive because of him. Stanislav Petrov, a retired Soviet military officer, is credited with preventing the start of World War III and the nuclear devastation of much of the Earth.

That’s why in 1984 the Soviet Union built a doomsday machine called Perimeter, to prevent launch on false warning.

Untitled

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++.

and

They make C++ constructs more concise.

and

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

and

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.