-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blank line before if and after end if. #291
Comments
Just to clarify, you would like the code to be formatted like this: process (clk) is
begin if (rising_edge(clk)) then
if a < 250 then
a <= a + 1;
b <= '0';
else
a <= (others => '0');
b <= '1';
end if;
end if; end process; |
Yes, but if there is some extra signal assignment on the rising edge, I would like to force following style: process (clk) is
begin
if (rising_edge(clk)) then
extra_signal <= foo;
if a < 250 then
a <= a + 1;
b <= '0';
else
a <= (others => '0');
b <= '1';
end if;
end if;
end process; Btw. How did you get colors in you snippet? |
To get the colors you wrap the code in
without the double quotes. |
It seems like there are two requests here:
Violation process (clk) is
begin
if (rising_edge(clk)) then Fix process (clk) is
begin if (rising_edge(clk)) then The second is: the first if statement inside a rising edge check should have a blank line above it: Violation if (rising_edge(clk)) then
extra_signal <= foo;
extra_sig2 <= foo2;
if a < 250 then Fix if (rising_edge(clk)) then
extra_signal <= foo;
extra_sig2 <= foo2;
if a < 250 then The thinking being the rising edge is really just checking for a clock edge while the next if is the real condition you are interested in emphasizing. Correct? |
Oh no sorry, there is a mistake I have not realized. I do not want Now lets come back to the if example,: process (clk)
begin
if rising_edge(clk) then
if condition then
d <= q;
end if;
end if;
end process; In this case I do not want to have blank lines between begin
if rising_edge(clk) then
if condition then and end if;
end if;
end process; However if there were any assignment before process (clk)
begin
if rising_edge(clk) then
a <= b;
if condition then
d <= q;
end if;
end if;
c <= f;
end process; should generate errors. Something like "Insert blank line between assignment and if block", "Insert blank line after if block, between end if and assignment. The fixed code would look like this: process (clk)
begin
if rising_edge(clk) then
a <= b;
if condition then
d <= q;
end if;
c <= f;
end if;
end process; I would like to be able to force developer to use blank lines to separate logic flow (programming logic flow, not design logic flow, although both are closely related). However it is not possible as vsg knows nothing about program logic. But I think, that with smart blank line rules behavior, one would at least stop for a while and rethink which statements should be grouped. |
I think I already added the ability to detect clock processes by checking for the 'event and I think rising_edge and falling_edge. We could add an attribute to classify the line as a programming logic versus design logic. Then we use one of the blank line rules and modify it to check for assignments. |
Hmm, I like this idea with classifying lines. However I am not sure if programming_logic and design_logic is good division. For example is |
Hey @m-kru , Are you still interested in this issue? --Jeremy |
@jeremiah-c-leary Nope. |
would it be possible to re-open/revisit this idea? I think the concept would be quite simple.
|
Hey @Bonusbartus, We can revisit this idea, we just need to define the rules. Going back to the previous example: process (clk)
begin
x <= y;
if rising_edge(clk) then
if condition then
a <= b;
if condition then
d <= q;
end if;
c <= f;
end if;
end if;
z <= x;
end process; Is this how you would like it formatted? process (clk)
begin
x <= y;
if rising_edge(clk) then
if condition then
a <= b;
if condition then
d <= q;
end if;
c <= f;
end if;
end if;
z <= x;
end process; I could also see an option for not inserting blank lines if there is a single line between the process (clk)
begin
x <= y;
if rising_edge(clk) then
if condition then
a <= b;
if condition then
d <= q;
end if;
c <= f;
end if;
end if;
z <= x;
end process; --Jeremy |
yes, that looks perfect. Although in my case I think I'd switch off the blank line insertion after the if, but that is (and should stay) a different rule. process (clk)
begin
x <= y;
if rising_edge(clk) then
if condition then
a <= b;
if condition then
d <= q;
end if;
c <= f;
end if;
end if;
z <= x;
end process; |
Hey @Bonusbartus, Just wanted a clarification on you last snippet with regards to process (clk)
begin
x <= y;
if rising_edge(clk) then
if condition then
a <= b;
if condition then
d <= q;
end if;
c <= f;
end if;
end if;
z <= x;
end process; It seems to be more consistent not having a blank line above
--Jeremy |
you are right, that looks/is better. These rules seem to be correct. thanks! |
Adding ignore_hierarchy option to rule if_030. 1) Added test 2) Added rule
Hey @Bonusbartus , I pushed an interim update for this issue to the issue-291 branch. This update exposed an issue with what constitutes a nested if statement that I need to resolve. Essentially is a nested if statement broken up by a case statement or loop still part of the nested if statement? if a = 0 then -- Hierarchy level 0
if b = 0 then -- Hierarchy level 1
case x is
when 3 =>
if c = 0 then -- Hierarchy level 0 or 2
end if;
end case;
end if;
end if; There are two new options: If you could check them out while I decide what to do with the hierarchy question I would appreciate it. Thanks, --Jeremy |
Hey @Bonusbartus, I pushed another update for this to the issue-291 branch. It includes options to adjust the blank line/no blank line depending on what follows the end if. Could you try it out and let me know what you think. I just need to go through some refactoring and it will be ready to merge to master. Thanks, --Jeremy |
Hey @jeremiah-c-leary, Seems to be working nicely. Haven't been able to verify all the possible options, but at least the base functionality, except_end_process and except_end_case seem to work! Thanks for the additions, Bart |
Hey @Bonusbartus,
How is the rule I also realized I did not update --Jeremy |
Hey @jeremiah-c-leary not sure if it is needed to handle exceptions, or if it is something to just configure in such a way that it doesn't conflict? Bart |
Hey @Bonusbartus , I apologize, but I lost track of this issue. Reading through the comments it looks like I updated rule Does that sum up the status of this issue? Thanks, --Jeremy |
Hey @Bonusbartus , I updated To enable this feature you need to use the following configuration: rule:
if_031:
ignore_hierarchy: False
except_if_statement: True
style: 'require_blank_line' When you get a chance could you give it a try and let me know how it goes? Thanks, --Jeremy |
Hey @Bonusbartus , Just wanted to ping you to see if you were able to try out the latest update. Thanks, --Jeremy |
Hi Jeremy,
I didn't have time to test it yet. I'll let you know when I had time to
test it.
Regards,
Bart
Op di 18 okt. 2022 03:25 schreef Jeremiah Leary ***@***.***>:
… Hey @Bonusbartus <https://github.com/Bonusbartus> ,
Just wanted to ping you to see if you were able to try out the latest
update.
Thanks,
--Jeremy
—
Reply to this email directly, view it on GitHub
<#291 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AIQ7TGCHX4HAVWVSIHLJD2TWDX4BFANCNFSM4JP7Y5JQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Morning @Bonusbartus , Just wanted to ping you to see if you had a change to validate the update. Thanks, --Jeremy |
Hi @jeremiah-c-leary p_example : process (clk)
begin
if (rising_edge(clk)) then
if (rst_n = '0') then
X <= '0';
y <= '0';
else
x <= '0';
y <= '0';
if (a = '0' and b = '1') then
x <= '1';
y <= '1';
end if;
if (c = '0' and d = '1') then
x <= '0';
y <= '1';
end if;
end if;
end if;
end process; correct would be (I think) p_example : process (clk)
begin
if (rising_edge(clk)) then
if (rst_n = '0') then
X <= '0';
y <= '0';
else
x <= '0';
y <= '0';
if (a = '0' and b = '1') then
x <= '1';
y <= '1';
end if;
if (c = '0' and d = '1') then
x <= '0';
y <= '1';
end if;
end if;
end if;
end process; or p_example : process (clk)
begin
if (rising_edge(clk)) then
if (rst_n = '0') then
X <= '0';
y <= '0';
else
x <= '0';
y <= '0';
if (a = '0' and b = '1') then
x <= '1';
y <= '1';
end if;
if (c = '0' and d = '1') then
x <= '0';
y <= '1';
end if;
end if;
end if;
end process; |
Good Eventing @Bonusbartus , Well....it's been awhile but I can finally come back to this issue. Just wanted to ping you check if this is still something you would want me to address before I start working on this again. Thanks, --Jeremy |
rule:
I like these rules. However, it should be possible to configure some exceptions or change how these rules works for example consider this snippet:
In such case I want
begin
line to be beforeif
andend process
line to be afterend if
.After some reflection, I think the same complaint can be made for other blank line rules.
The text was updated successfully, but these errors were encountered: