Hello there,
Although I have been using verilog for several designs and projects lately, I have no real proper 'education' in verilog nor digital electronics, which means my code and designs often end up being quite a mess - but don't they always?
In other words, I have no idea about proper standards and design guidelines, and was wondering about those.
As an example, imagine the following code:
module how_to_comment(
//Some inputs, doesn't matter for the example
);
//Internal control signals
wire RST_wire_in, //Comment section 1
CLR_wire_in, //Comment section 1
LD_wire_in, //Comment section 1
EN_wire_in //Comment section 1
;
//Structural code
assign RST_wire_in = ....... //Comment section 2
assign CLR_wire_in =....... //Comment section 2
assign LD_wire_in = ....... //Comment section 2
assign EN_wire_in = ....... //Comment section 2
endmodule
So my question is, where in this code would I put the explanation for what each of those signals do, or at least what they are supposed to do?
Should they be in section 1 - where they are declared - or in section 2 - where the actual logic takes place?
Thanks in advance,
Leo
Wow, highschool student playing with Verilog. Nice!

. Don't worry, they don't teach you how to comment or how to code in Uni. I don't think the Professors do lots of coding themselves

. They're not very concerned about engineering's good practice.
Regarding the code comment practice, here's what useful for me when I read someone's code:
At the interface if the signals are not some standard one such as axi..wishbone... describe how they behave so that the user of your block doesnt have to dig deeper to figure out. Things like latency, what clock domain the signal is in, is it expected to be single pulse or longer... --> comment so that people can use your block.
So i would vote for commenting at the interface itself in stead of in the body where the assignment takes place. Imagine you have more complicated code, I wouldn't want to trace the signals to know how to use the block.
In the body, you don't need to comment line by line, comment to describe the idea behind the code ... not very line of codes. I can read code line by line/process by process but its hard to piece together codes to understand the whole idea. Sometimes... just a single line of comment that tells you the gist of it makes a big difference in understanding the code.
You should have a clear idea of what you are going to code ... write it down as comment first. That's when you're yourself new to your code. And your comment is useful 5 years down the road or to a new comer.
Commenting is also a bit subjective. Some people can write code nicely but they can't comment because they feel everything is obvious from the code, there's nothing to comment, the code say it all

. I haven't seen a good practice/guidelines regarding commenting HDL code. It's hard to implement in practice since it's difficult to agree on how one should read/write HDL code. Something obvious to one is not so with the other. If you guys have one at your organisation, please share.
Cheers.