Subscribe to EDN

How languages influence design, and why we should care: a tale of C, Verilog, and trouble

January 8, 2009

Most of us don’t have the luxury to stop and reflect very often, especially about design language theory. In this writer’s case that is probably just as well, as my theoretical speculations tend to wander into quicksand with improbable regularity. But a recent conversation with Steve Teig, EDA industry luminary, currently president and CTO of stealth start-up Tabula, and someone whose speculations are very much worth following, set me to thinking on the subject.

Teig was talking about the relationship between the language in which an algorithm is coded, the target architecture, and the results. Much of his thinking he anchored in a very important distinction: between languages that describe algorithms and languages that describe implementations. (He uses other, more precise terms, but I think that captures the distinction adequately for our purposes here.) If you think about languages in these terms, it becomes clear that trying to describe an algorithm in an implementation language may limit the range of concepts you can capture and restrict the range of target implementation architectures you can serve well.

For example, contrast two programming languages, one obscure and one inescapable: APL and C. APL (see here, for instance) was created to express algorithms that had two key characteristics: their variables were often multidimensional arrays or lists, and their transformations could be defined as recursive processes. APL can express such algorithms with concise, precise elegance. I think—I’m not sure I ever really learned to read it. But an APL interpreter for any known computer had to be a masterpiece of coding skill. It had to be a self-contained environment that compensated for the differences between the sort of linear-algebra world in which the great turn-of-century mathematicians lived and the sort of resource-starved clockwork that passed for a computer in the 1970s.

C could not be more different. At the risk of offending anyone who learned programming after about 1975, C is extraordinarily implementation-specific for a text-based language. It is little more than a short-hand for PDP-11 assembly code. It is an indelible tribute to Gordon Bell that his instruction set architecture was so splendid that it could be used to adequately describe a wide range of sequential algorithms.

Writing a C compiler for the register-based, indexed-addressing, single-ALU machines that most microprocessors became—in their efforts to mimic the PDP-11 to greater or lesser extent—was not a great intellectual exercise. It was just work. But expressing an algorithm in C pretty much requires that the algorithm have been conceived to execute on such a machine in the first place. We don’t recognize this because we have become so used to C that we have forgotten that the domain of algorithms is actually much broader than that.

Conversely, getting a C program to execute efficiently on anything that doesn’t look very like a PDP-11 is an exercise in futility. The programming language has already eliminated much of the information we would need to efficiently use a memory-to-memory architecture, say, or a list processor, or—more to the point these days—a multiprocessing cluster. About all we can do in the latter case is ignore the code and go looking for data parallelism.

My point isn’t to poke fun at C, but to draw a parallel. The same distinction exists in hardware description languages. Verilog and VHDL are hardware description languages—but descriptions of a particular set of hardware. They have virtually no way of describing an algorithm except as an implementation in these particular structures. Start with a system of linear differential equations or a collection of matrix algebra, and there is no reasonable way to describe them. You can only—after huge leaps of domain-constraining assumptions—describe datapaths that might implement such algorithms.

So what? Today, just as the programming folks are running into a brick wall trying to parallelize C programs, hardware architects are running into a brick wall trying to capture design specifications and reduce them to synthesizable code. We can do the job just fine if the algorithm happens to be an instance of something RTL code naturally describes—that is, a data path or a synchronous state machine. Otherwise, we are in for a difficult, manual translation process with no guarantee of a positive result.

And just as many programmers tend to think of algorithms in terms of C programs, many architects and designers tend to think of algorithms in terms of a sequence of synchronous registers separated by clouds of asynchronous logic. We’ve forgotten—if we ever knew—that such structures are one set of constructs that was once particularly useful to the computer industry, not a general description of the class of all algorithms. And that is severely hampering our attempts to elevate design to a level of abstraction above RTL. The problem is too hard because the implementation language is too specific, or perhaps because it is specific to the wrong constructs. It’s an interesting view of the issue.

Posted by Ron Wilson on January 8, 2009 | Comments (10)

January 26, 2009
In response to: How languages influence design, and why we should care: a tale of C, Verilog, and trouble
nikhil commented:

In theory languages do not restrict what you can conceptualize and create, since they are all generally Turing-complete, but in practice they might, if the sheer volume of detail that you need to attend to overwhelms you. This is one reason why assembly language and RTL are so low-level. I would also like strongly to underline Rodney's second point, "What can make a difference is the target processor". Exactly! To put it another way, algorithms are designed with a particular cost model in mind--different architectures have different cost models and require different algorithms. This is one reason why C/C++ is so inappropriate for HW design, because the language assumes a certain cost model that is very restricted and often irrelevant from the point of view of HW design, and so you may start with an inappropriate algorithm. Another observation: when designing algorithms for SW, even a vector machine, you are typically given a certain fixed cost model relative to which you design your algorithm. When designing HW, on the other hand the cost model (architecture) is an OUTPUT of the design process, not a fixed given input.


January 24, 2009
In response to: How languages influence design, and why we should care: a tale of C, Verilog, and trouble
Rodney commented:

Does the language really restrict what you can conceptualize and do, or does it just make the job easier or more difficult?

For example, a Sudoku puzzle solver written in Python (a slow interpretive language) is relatively easy to write using sets and lists. Doing the same thing in C++ doesn''t alter the set manipulations in algorithms, but it does require a comparatively slow process of manually creating the required set and list objects.

Testing a RADAR processing algorithm in MATLAB/Octave using the native matrix operations facilitates implementing the mathematically derived functions, but practical implementation is done in languages such as C/C++ or Verilog/VHDL that are slower to code but ultimately provide superior system throughput.

What can make a difference is the target processor. Algorithms designed for a vector processor such as a Cray can be substantially different than algorithms designed for serial processors. An algorithm designed for an FPGA with scads of MACs can be substantially different, and 100 times faster, than an algorithm designed for a serial processor.


January 13, 2009
In response to: How languages influence design, and why we should care: a tale of C, Verilog, and trouble
nikhil commented:

I very much agree with the sentiment expressed, namely that languages often constrain our thinking. Sometimes this constraint is good (e.g., structured programming vs. spaghetti control flow), but at other times it can be debilitating. You may be interested in the following quote from the great mathematician/philosopher Alfred North Whitehead in his book "Introduction to Mathematics": ?By relieving the brain of all unnecessary work, a good notation sets it free to concentrate on more advanced problems, and, in effect, increases the mental power of the race. Before the introduction of the Arabic notation, multiplication was difficult, and the division even of integers called into play the highest mathematical faculties. Probably nothing in the modern world would have more astonished a Greek mathematician than to learn that ... a large proportion of the population of Western Europe could perform the operation of division for the largest numbers. This fact would have seemed to him a sheer impossibility ... Our modern power of easy reckoning with decimal fractions is the almost miraculous result of the gradual discovery of a perfect notation. [...] By the aid of symbolism, we can make transitions in reasoning almost mechanically, by the eye, which otherwise would call into play the higher faculties of the brain.? This is my main concern about the use of C for hardware specification. Both key features of its abstract computational model: - Sequentiality - Cost model (unit time access to all state) hardly seem to be good abstractions for hardware at all! Many researchers seem to have independently gravitated towards a common consensus about the best way to describe systems with complex, heterogeneous, reactive concurrency: parallel rewrite rules with atomic semantics. Examples include: - TLA+ (Leslie Lamport) - UNITY (Chandy and Mishra) - EventB (J-R. Abrial et. al) In fact, the name UNITY is coined from a description of this computation model: "Unbounded Nondeterministic Iterative Transformations" This is exactly the computation model we use in BSV (Bluespec SystemVerilog), from which high level descriptions we synthesize hardware.


January 12, 2009
In response to: How languages influence design, and why we should care: a tale of C, Verilog, and trouble
ron commented:

A Problematic: That sounds like an apt desciption to me. APL is the only language I've encountered in which you don't read code, you reverse-engineer it. But what fun if you succeed! ron


January 11, 2009
In response to: How languages influence design, and why we should care: a tale of C, Verilog, and trouble
Basic Personality commented:

Some years ago, when DOS machines were common, I would write control software for semiconductor manufacturing equipment using Basic. Yes, Basic! Features included real-time process conditions on a system display graphic, process recipe capture, storage and implementation, and alarm monitoring, annunciation and data logging. The usual negative reaction to hearing that the control software was written in Basic led us to instead use the term "proprietary software." Perhaps this is less about the language than who speaks it.


January 11, 2009
In response to: How languages influence design, and why we should care: a tale of C, Verilog, and trouble
A Problematic Language commented:

APL has been correctly described as a write-only language!


January 11, 2009
In response to: How languages influence design, and why we should care: a tale of C, Verilog, and trouble
Dick Selwood commented:

I think that this skates around a major issue, which was addressed by mid 20th century philosophers, "How can we think about something if we don't have a language to describe it?" Someone brought up on C and the PDP-11 derived architectures will address problems in a particular way - it is hard not to. If they also know APL, they may address a problem differently. If they ever learned occam, they will have a third possible approach. Not that any of these are right or wrong butsome approaches are more appropriate for certain problem classes than others. But as long as universities teach only C or Java, then the products of the universities are going to be deprived of the alternatives that might make problem solving easier.


January 9, 2009
In response to: How languages influence design, and why we should care: a tale of C, Verilog, and trouble
ron commented:

Policebox: I have to differ with you on one point. There was a much wider variety of macroarchitectures in the computer world before the advent of minicomputers forced everything to an LSI-based least common denominator. There were memory-to-memory machines with no registers. There were list-processing machines. There were machines optimized to execute compiled COBOL. There were even hybrid analog/digital computers. We lost all of that with the triumph, however well-deserved, of Bell's baby. ron


January 9, 2009
In response to: How languages influence design, and why we should care: a tale of C, Verilog, and trouble
Policebox commented:

Huh? Where in this debate did the concept of hardware abstraction get lost? The whole idea of a "high level" language (such as C) is to allow the programmer to specify the steps while not getting bogged down in hardware details. The characterization of C as shorthand for PDP-11 assembly code is also not fair. The fact is that the PDP-11 was a nice clean implementation of every other processor developed to that date. I know, I programmed several of them in Assembly Language (including the PDP-11). In fact all computers to date can be looked at as a co-operating cluster of PDP like processors. It is not that C is inappropriate to describing algorthms for them, it is that you have to take the interaction between the processors into account explicitly. As near as I have been able to tell, nobody has been able to come up with a general and automatable way of doing that, so asking for a language to do it is futile. Finally, about the robot programmer''s comments on an abstraction for time. C (and C like languages) doesn''t have one, because it doesn''t need one. When you are describing the STEPS OF A PROCESS, the only effect time has can be summed up by "find out how long that took" or "wait for this long". Please remember that there are two ways of looking at a process. One is as a series of steps that must be executed to acheive it. Languages like C have been mathematically proven to cover this territory completely. If it can be done, C can be used to describe the steps to do it. However, a step by step process isn''t necessarily the best way to describe an integrated circuit. The other is as a quasi-static system that changes state based on the environment. Data flow diagrams (such as LabView) can handle a class of this, but nobody has come up with an abstraction above the gate level that handles everything. So we are stuck with special purpose tools for now.


January 9, 2009
In response to: How languages influence design, and why we should care: a tale of C, Verilog, and trouble
DaveW commented:

Well said! We see this problem in the world of robotics, in the description of motion control. Neither C nor Verilog/VHDL contains abstractions for the Newtonian concept of time, which is fundamental to motion control. The usual reply in both cases is that you "just code for it" as though time was a peculiarity of your unique application, to be handled by a one-time, do-it-yourself subroutine library. The equivalent statement is that you can program anything in assembly language. Which begs the question of the value of a "high level" language in these cases.

POST A COMMENT
Display Name
captcha

Before submitting this form, please type the characters displayed above. Note the letters are case sensitive:

Advertisement
Advertisement
Advertisement
About EDN   |   Site Map   |   Contact Us   |   Subscription   |   RSS
© 2012 UBM Electronics. All rights reserved.
Use of this Web site is subject to its Terms of Use | Privacy Policy

Please visit these other UBM Canon sites

UBM Canon | Design News | Test & Measurement World | Packaging Digest | EDN | Qmed | Pharmalive | Appliance Magazine | Plastics Today | Powder Bulk Solids | Canon Trade Shows