# Comparing ASAP7 and sky130hd with respect to ALU operations Subcategory: Usage question ## Conversation ### oharboe The [mock-alu](https://github.com/The-OpenROAD-Project/OpenROAD-flow-scripts/tree/master/flow/designs/src/mock-alu) allows studying the speed and area of various typical ALU operations. The mock-alu has two 64 bit inputs and one 64 bit output. The inputs and outputs are registered within the mock-alu. This is to have clear boundary conditions when studying the guts of the mock-alu. The mock-alu implements a number of operations and variants of these operations to study the area and minimum clock period for these operations. The operations fall into a couple of categories: - *add, subtract and compare*: ADD, SUB, SETCC_EQ(equal), SETCC_NE (not equal), SETCC_LT (less than), SETT_LE (less than or equal), SETCC_ULT (unsigned less than), SETCC_ULE(unsigned less than or equal) - *barrel shifter*: SHR(logical shift right), SRA(arithmetic shift right), SHL(shift left) - *bitwise logic*: OR(bitwise or), AND(bitwise and), XOR(bitwise xor) - *multiplication*: 64 bit multiply. There are various algorithms used, default Han Carlson. The implementation is PDK specific and comes from https://github.com/antonblanchard/vlsiffra/ - *multiplexor*: MUX1..8. This is not really an ALU operation. All that is happening here is that bits from the input as selected using a mux and put into the output. This allows studying the performance of the mux that sits before the output of an ALU, which is selecting between the various supported operations. Next, the mock-alu allows implementing any combination of these operations. This allows implementing an ALU that only supports the shift operations, which can be labelled "SHR,SHL,SRA". This shift operation only mock-alu has a single shared barrelshifter. Similarly, a bitwise logic only mock-alu, can be labelled "OR,AND,XOR". At this point, we can plot various mock-alu implementations for ASAP7 and sky130hd: ![image](https://github.com/The-OpenROAD-Project/OpenROAD/assets/2798822/b9234684-43f4-4a74-98dd-81cf8b74f9ce) ![image](https://github.com/The-OpenROAD-Project/OpenROAD/assets/2798822/fefae238-58ed-4bfe-a307-780046acdb83) Here 8,16,32 and 64 wide ADD operations are plotted: ![image](https://github.com/The-OpenROAD-Project/OpenROAD/assets/2798822/f4a837e6-700c-4436-81ac-221bdfafdb57) Various multiplication algorithms for 64 bit multiplication, 4 pipeline stages: ![image](https://github.com/The-OpenROAD-Project/OpenROAD/assets/2798822/0a8d6518-5999-4d18-87fa-38a13857764f) Plotting Han Carlson multiply algorithm with 8, 16, 32 and 64 bit bit width: ![image](https://github.com/The-OpenROAD-Project/OpenROAD/assets/2798822/97fb01d7-e535-4578-9fe9-cdb80a4e945f) Thoughts? ### maliberty Its interesting that the various multiply algorithms have the same delay (excluding ripple). I don't see a MULT for sky130 ### oharboe Here are the `vlsi-adder` algorith, excluding ripple that was ca. 2000+ ps. It would have made the graph harder to read: ![image](https://github.com/The-OpenROAD-Project/OpenROAD/assets/2798822/07c8e764-81d1-48fe-858a-39175a1d3c68) ### maliberty Do all your runs end in negative slack at the end of the cts & the complete flow? Once we reach zero slack we stop optimizing. ### maliberty One thing worth noting is that asap7 doesn't have a full or half adder cells in the library (sky130 does). ### mithro BTW Have you seen Teo's spreadsheet @ https://docs.google.com/spreadsheets/d/1pTGzZo5XYU7iuUryxorfzJwNuE9rM3le5t44wmLohy4/edit#gid=126548956 ? ### mithro BTW I would love to get a similar spreadsheet to Teo's for GF180MCU and ASAP7 too. Sadly, Teo got distracted by the mathematical theory and then was stolen by NVIDIA before he could get to that. ### tspyrou @oharboe did you try using set_clock_uncertainty to force the slack to be negative and make the tool work harder. As @maliberty mentioned optimization will stop once timing passes. ### mithro @oharboe - Any chance you could do a write up of what you discovered? ### oharboe > There is a lot bunch of back and forth and I'm unclear what the final results are (and exactly how you produced them). > > Various questions include; > > * How do I reproduce your results and graphs? Run this script: https://github.com/The-OpenROAD-Project/OpenROAD-flow-scripts/blob/master/flow/designs/src/mock-alu/plot-area-min-clock-period.py Some tinkering required. > * What settings did you end up using and why did you end up using those settings? (Particularly around making the tool work harder?) I didn't study how to make a best possible ALU, I was only interested the relationship between the ALU operations. > * How do the various implementations compare? Do you understand why the compare this way? The various implementation of additions and multiplications? It is a mystery why there is essentially no difference between multiplication implementation clock periods... > * How do SKY130 and ASAP7 compare in the end here? The lessons learned on the relative size and speed of ALU operations appear to be much the same with SKY130 and ASAP7. Which is surprising. Ca. 15 years separate them... > * Do the relative "positions" between the implementations hold across SKY130 and ASAP7? Pretty much. > * What was the most interesting / unexpected thing you discovered? That relative size and speed of simple ALU operations are essentially unchanged across process nodes. Also, it would appear that if an ALU operation is 200ps on x86 7nm, yielding 5GHz, then one could choose to divide clock period of ASAP7+OpenROAD by 4 for simple ALU operations when one models and decide to take the lessons learned and apply them to architectural exploration. Further choose to treat the speed of ASAP7+OpenROAD as not terribly important in terms of making architctural choices as the choices will be the same if everything is optimized. By this I mean that to drive your architctural exploration, as a [first order approximation](https://en.wikipedia.org/wiki/Order_of_approximation#First-order), write the RTL in an idiomatic way, run them through ASAP7+OpenROAD and if your design is 4x the desired clock period, your design isn't completely off. Nobody who have information on commercial tools and PDKs can challenge me here. :-) Not because I'm right, but because PDKs and commercial tools are under strict NDAs... This also explains why there are a lot of unsaid things in this thread... > Writing it up as a nice coherent blog post would be pretty awesome but totally understand if you do nt have the time to do so. Agreed. At least I summarize a bit here. I'm happy to hear that there are some that are interested in this. Perhaps you would like to write a blog-post using the script above?