r/ComputerEngineering • • Dec 29 '23

Why is computer engineering getting bashed?

I’ve seen some computer science graduates belittling computer engineering in terms of pay, studies and work. Im currently in my last school year and I’m interested in computer engineering but the bashing pops up. Please help to convince me out with info on why computer engineering is good

251 Upvotes

108 comments sorted by

View all comments

Show parent comments

2

u/loaengineer0 Dec 31 '23

When I write code, it is RTL (Register Transfer Logic) in SystemVerilog. So I’m defining state elements and the transformation of state from one clock to the next. Someone else uses a suite of tools to convert that code into a list of logic gates and wires, and then figures out how to lay that out on the chip.

Architects talk to customers and come up with a list of features. They define the skeleton of a software/hardware interface, collaborating with the software team. The architects usually get really specific, but the definition changes substantially later in the process. From there, micro architects break up the feature set into clusters, then define the major state elements and general control+data flow. UArch specs are reviewed to make sure that the interfaces between clusters is clear and consistent, but these documents are not shared outside the company. That uArch definition is implemented in an RTL language. There is a continuous process of negotiating the Arch, uArch, and RTL to keep everything consistent. Ultimately, the Arch spec is used by the software team to write firmware and drivers. The final version Arch spec may also be shared with customers.

I work in the uArch/RTL layers. The software knowledge comes in a few places:

  • “big O” costs of solutions that need to scale on different dimensions. Amortized costs of infrequent operations. All that basic stuff is generally applicable. Also scheduling and queueing stuff applies a lot.

  • Arrays and queues are sufficient for the vast majority of hardware structures, but occasionally you get a case where a linked list or some kind of tree structure is warranted.

  • Recommending Arch changes that enable better performance. I’m usually familiar with the APIs/workloads we are targeting, so I can intuit what the driver will be doing. Sometimes there is an opportunity to reduce the driver overhead by making a cheap addition to a hardware capability. ML and networking classes have been very applicable for me.

  • Recommending Arch changes that enable a cheaper implementation without impacting performance. Sometimes there is a parameter the Architects threw in just because they thought it was a trivial addition. Other times there is a slight semantic change that is inconsequential to the driver but is huge for the hardware. For a trivial example, a multiplication or division circuit (big/slow) can be replaced with a bit shifter (trivial) if the second operand is guaranteed to be a power of 2.

  • Debugging tool issues. The SystemVerilog simulators and other tools we use are all super shitty compared to typical software compilers. They all implement different subsets of the SystemVerilog spec, but they don’t always throw errors when they encounter some unsupported syntax, so you just have to figure it out. I still use skills from compilers class for this.

  • Formal verification is very useful, but it is applying a sat solver to non-trivial problems. You can get a lot more out of it if you have a general intuition about sat solver algorithms.

Random math stuff also shows up occasionally. Like a “rare” performance degradation that actually happens all the time because it’s a birthday problem and no one recognized it until we got initial performance testing.

1

u/fiery_prometheus Dec 31 '23

Thanks a lot for the detailed writeup, it was very interesting to know about!

I've looked up how to program in RTL in SystemVerilog, and it makes a lot of sense when you say that computer science is so applicable. I got the impression that it is akin to another programming language, but with a different mindset for the program flow and parallelization. Almost to the point where knowing about computer science seems more useful to me since the high level concepts about computation will always be valid, but I am biased I'll admit.

So having an intuition about how digital circuits work at a lower level seems helpful, but not wholly necessary? It seems like the abstraction stops at knowing boolean gates, clocks, flip-flops etc, and everything under that is handed of to other engineers?

As a thought experiment to know where the abstraction layer is, would it for example be useful to have an intuition about hysteresis when switching states quickly when you write RTL, or is it a valid assumption to think about the circuits as discrete steps which the engineers at the lower levels have guaranteed to always hold? Such that you can never trigger weird/rare edge cases where this might become an issue?

IE, every operation is driven by a clock edge, and for all components at this abstraction level (RTL) they are always atomic and do not 'leak' concepts like analog circuit concepts, can trigger leakage or cause interference with physically neighboring components etc. if they are abused?

1

u/loaengineer0 Dec 31 '23

> So having an intuition about how digital circuits work at a lower level seems helpful, but not wholly necessary?

It is extremely helpful. As an example, a 32-bit shifter can be implemented as a 2D array of multiplexers. The first row selects either the original value or the value shifted by 16. The second row selects either the first row output or that value shifted by 8. Then 4, 2, 1. If you code this explicitly, the synthesis tool might choose to implement all muxes with a transmission-gate-mux cell (4 transistors). The problem is that the drive strength of a transmission gate output is always less than the drive strength of the input. So by the time the signal gets to the output, it will be too weak. This can be solved by putting a row of inverters after the 2nd and 4th row of muxes to re-up the drive strength. The inverters cancel out, so the circuit with inverters is logically equivalent. This is a very old example (modern synthesis tools resolve this automatically), but there are similar cases I've hit more recently.

There are also lots of optimizations that synthesis tools can do if you configure them properly. It is best if you have a plan in advance rather than letting the downstream engineer try things randomly. For example, I might know that the path before a flop may be tight, but I can keep the path after the flop short so that clock-skew can be added in synthesis (basically, put a few extra buffers on the clock so that it hits that flop late, thus expanding the time available for a signal to get to the flop and decreasing the time between that and the next flop). Clock skew can only be inserted if there is sufficient room on the output path, so you need to plan for it early.

> would it for example be useful to have an intuition about hysteresis when switching states quickly when you write RTL, or is it a valid assumption to think about the circuits as discrete steps

For pure digital logic, you can mostly think in terms of discrete steps. One of the last stages of the physical design is to verify that the schematic doesn't violate those assumptions. The physical designers do a lot of work to prevent and resolve those issues, but that doesn't impact the RTL.

There are some situations like clock-domain-crossings and IO SERDES which require significant RTL+PD co-design. Those are treated more like analog circuits. That kind of function is done in a box and the boundary of that box doesn't violate the digital assumptions.

2

u/fiery_prometheus Jan 01 '24

I see, the example of the synthesis tool choosing a solution which might not be adequate seems to be a similar problem in which you know what some code has to do, but the compiler doesn't know and thus outputs for the most common general case. At the same time, it seems even more important to have this intuition for digital circuits and the synthesis tool, as it helps preventing being caught of guard by cases where the output could be plainly error prone and not just slow (as in established compilers output slow code more often than wrong code, I hope).

So it makes a lot of sense to catch these bugs, the down stream engineers might spend a significant amount of time even trying to identify where the errors come from, but it probably depends on the size of the 'program/function/unit' being worked on and the unit testing put in place.

Thanks for the answers! I was always curious about the processes one might go through in this domain.

Might take a look at SystemVerilog to program some fpga's in the future, but that will likely just be to settle my curiosity and dabble a bit in the domain to see how it is, but I find the intersection of knowing about the hardware and at the same time, thinking about the high level functionality to be very satisfying.