lowRISC / opentitan

OpenTitan: Open source silicon root of trust
https://www.opentitan.org
Apache License 2.0
2.6k stars 785 forks source link

[c++] Rewrite bits of the verilator-support infrastructure to avoid exceptions #5801

Open rswarbrick opened 3 years ago

rswarbrick commented 3 years ago

These aren't allowed by the Google style guide. Pointed out by @mcy in a recent review.

moidx commented 3 years ago

code search query:

https://cs.opensource.google/search?q=throw%20language:cc%20-file:.*vendor.*&sq=&ss=opentitan%2Fopentitan

kal-ne commented 3 years ago

Hi I'm new to open source. I would like to try and understand this issue and see if I can help. I'm currently reading OpenTitan Docs and setting up the Environment.

I just wrapped up a 6 month internship in EDA domain where I worked in functional verification and was exposed to Verilog, SystemVerilog and UVM. Worked on testing related to AXI 4 and i2c. I have some exposure to C++(from 2015), worked(first time) with python scripts and ROS last year.

rswarbrick commented 3 years ago

Sounds great. There are quite a lot of different places where we use this throw/catch style (it's idiomatic C++ and I didn't realise it was verboten until mcy pointed it out!). I'd suggest picking one and then trying to work out how to pass a failure back up the call stack with a return value in a nice way. We can probably work through things in smaller chunks.

kal-ne commented 3 years ago

Hi, I am working on reading up to understand your answer. Meanwhile, would you clarify the following things:

  1. Why is throw/catch considered idiomatic C++? (I first came across this style in a Java assignment)
  2. Why do we want to avoid idiomatic C++ in this project?
rswarbrick commented 3 years ago

I'm not sure that an OpenTitan bug report is the best place to find this sort of thing out. For (1), see a C++ tutorial. For (2), see the Google C++ style guide, which we signed up to (for better or for worse...)