-
Notifications
You must be signed in to change notification settings - Fork 42
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
Pragmas and Blank Line rules #1065
Comments
Afternoon @SittingDuc , I pushed an update for this to the I added the option Could you give it a try and let me know if there are any changes I need to make? Thanks, --Jeremy |
Hello, checked out the latest branch and running it on real vhdl.. Component instance (
Much thanks, |
Morning @SittingDuc , I can leave this issue open for a while if you want to spend more time validating the change. --Jeremy |
Hello, A little further review shows that all the places I have checked (entity declaration end, instantiation start/end, architecture end, process end, generate end, etc) all tolerate a pragma line after themselves, when configured to do so. However, I then note the rule now behaves like the
with What I would ideally love would be a violation with a fix of
which I guess makes the semantics "require blank line or pragma" not "unless". In an effort to be less of a say-er and more of a do-er, I tried reading the commit to see if I could work out how to write the change I want, and I must admit I am better at VHDL than Python. In summary, the code in PR#1068 does improve the behaviour, and allows me to have my pragmas snug up to the code block they are to jacket; and if technical reasons make the further feature request extension impractical, I can live with that. But if the feature could be extended to then require a blank line after the pragma (or before in the above-code cases, Thanks again, |
Morning @SittingDuc , I think there might a different method to handle the desired formatting if we create rules around pragmas. I believe we can divide pragmas into three types:
-- synthesis translate_off
-- synthesis translate_on where
-- synthesis library <my_lib> If pragmas are divided into these types then rules can be written against those types:
So now the behavior of the blank lines around For example: end component;
-- synthesis translate_off
signal debug_wr_en : std_logic;
signal debug_rd_en ; std_logic;
-- synthesis translate_on
-- synthesis translate_off
signal debug2_wr_en : std_logic;
-- synthesis translate_on
component fifo is I would think the desired formatting would be: end component;
-- synthesis translate_off
signal debug_wr_en : std_logic;
signal debug_rd_en ; std_logic;
-- synthesis translate_on
-- synthesis translate_off
signal debug2_wr_en : std_logic;
-- synthesis translate_on
component fifo is So blank line is added before every I believe this would give the compactness of pragmas you are looking for. What do think? --Jeremy |
Morning @SittingDuc , I pushed an update to the Using a slightly modified version of your code example: 1
2 architecture rtl of fifo is
3
4 begin
5
6 o_ruble <= o_betty;
7 -- synthesis translate_off
8
9 gen_fred : if true generate
10 begin
11 o_wilma <= b_pebbles;
12 end generate gen_fred;
13
14 -- synthesis translate_on
15 o_betty <= b_bam_bam;
16
17 end; and using this configuration file: 1 rule:
2 generate_004:
3 style: allow_comment
4 generate_003:
5 style: require_blank_line_unless_pragma The above example code will be fixed to: 1
2 architecture rtl of fifo is
3
4 begin
5
6 o_ruble <= o_betty;
7
8 -- synthesis translate_off
9 gen_fred : if true generate
10 begin
11 o_wilma <= b_pebbles;
12 end generate gen_fred;
13 -- synthesis translate_on
14
15 o_betty <= b_bam_bam;
16
17 end architecture rtl; Could you check out the new rules and let me know if it gives the formatting you are looking for? Thanks, --Jeremy |
Hello, The idea to allocate pragmas based on how they impact the code is a good idea. One drawback is I get python 'keyError' if I don't update my config file: Migrating existing configurations
yields
Might be possible to fix in documentation. Testing the Changes Blank lines above and below the pragmas, and testing it with the default config, all the expected rules report violations (I modified the pragma regexp for this test, purely so I can label each line with the rule name) Exceptional case
So the semantics in my head returns to "if the thing the pragma is snuggled up to expects a blank line, that blank line request passes to the pragma. If the pragma is not snuggled up to a blank-line-expector, the pragma does not request a blank line either". For this example, I can probably throw a vsg_off around the function, or just add the blank lines. It might even improve readability by making the simulation block "stand out". Conclusion Thanks once more, |
Evening @SittingDuc ,
I added some error checking on configuring pragmas. In your example the following error message will be displayed:
Yeah, implementing that logic would be complicated. The rules are designed to be independent of each other to eliminate dependences. So implementing a rule to have knowledge of another rules configuration would violate the intent of the design.
The "configuration pragmas" documentation was updated on the branch to show the Hopefully pointing users to that documentation if they followed the old format will be sufficient. Let me know if you think the error checking I implemented is sufficient. --Jeremy |
Hello, I understand the philosophy and I can live with the code as it stands. I tested the error message and it works, and is nicer than the Trackback. All the effort people put in to things that might never be seen Thanks for all the work, I am happy for this to close / merge. Happy Holidays |
Evening @SittingDuc ,
I used to complain, well...still do, about incomprehensible error messages. Now I have an appreciation for how much work really goes into creating a useful one and why it is so hard to create a useful error message. I will merge this to master. --Jeremy |
Hello again,
Getting greedy now, this request is low priority / nice-to-have only.
At present, rules like
instantiation_019
force a blank line after an instance,component_018
afterend component
, and so forth.If I put a pragma after a function, component declaration, or instance, it would be visually nicer to have it next to the end declaration, and then the blank line enforced below it.
As defined,
component_018
will try to push thevsg_on
line down, making the code less compact and a fraction less readable. Feature request then is some way to make a previously-defined pragma "not count" for the blank line rules, so it can "snug" up to the code it is disabling / modifying, and then the original whitespace rule applies after it (i.e. the blank line remains between the Catapult and the trebuchet components)Not a major concern and I can totally live with it, but if I have noticed, other people might too, now that pragmas are a thing ;)
Thanks once again!
The text was updated successfully, but these errors were encountered: