Skip to content

Commit

Permalink
Fix Indentation in INST
Browse files Browse the repository at this point in the history
  • Loading branch information
Teddy-van-Jerry committed Apr 11, 2024
1 parent c6295b8 commit 20ed7b7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "pytv"
description = "Python Templated Verilog"
repository = "https://github.com/autohdw/pytv"
authors = ["Teddy van Jerry <me@teddy-van-jerry.org>"]
version = "0.5.3"
version = "0.5.4"
readme = "README.md"
license = "GPL-3.0-or-later"
keywords = ["verilog", "python", "template", "generation"]
Expand Down
24 changes: 15 additions & 9 deletions src/inst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl Convert {
*within_inst = false;
self.print_inst(stream, inst_str, *inst_indent_space)?;
inst_str.clear();
writeln!(stream, "print('// END of INST')")?;
writeln!(stream, "{}print('// END of INST')", " ".repeat(*inst_indent_space))?;
*inst_indent_space = 0;
}
_ => {
Expand Down Expand Up @@ -115,7 +115,8 @@ impl Convert {
match inst_map["module"].as_str() {
Some(module) => writeln!(
stream,
"print(f'{}', end='')",
"{}print(f'{}', end='')",
" ".repeat(inst_indent_space),
self.undo_protected_brackets(module)
)?,
None => return Err("No module name found in the <INST>.".into()),
Expand All @@ -128,7 +129,8 @@ impl Convert {
if key_str.starts_with("__group_") {
writeln!(
stream,
"print(_verilog_vparams_var_map({}, {}), end='')",
"{}print(_verilog_vparams_var_map({}, {}), end='')",
" ".repeat(inst_indent_space),
value_str,
if first_vparam {
first_vparam = false;
Expand All @@ -140,7 +142,8 @@ impl Convert {
} else {
writeln!(
stream,
"print(f'{}\\n .{}({})', end='')",
"{}print(f'{}\\n .{}({})', end='')",
" ".repeat(inst_indent_space),
if first_vparam {
first_vparam = false;
"#("
Expand All @@ -161,12 +164,13 @@ impl Convert {
}
}
if !first_vparam {
writeln!(stream, "print(')')")?;
writeln!(stream, "{}print(')')", " ".repeat(inst_indent_space))?;
}
match inst_map["name"].as_str() {
Some(name) => writeln!(
stream,
"print(f' {} (')",
"{}print(f' {} (')",
" ".repeat(inst_indent_space),
self.undo_protected_brackets(name)
)?,
None => return Err("No instantiation name found in the <INST>.".into()),
Expand All @@ -179,7 +183,8 @@ impl Convert {
if key_str.starts_with("__group_") {
writeln!(
stream,
"print(_verilog_ports_var_map({}, {}), end='')",
"{}print(_verilog_ports_var_map({}, {}), end='')",
" ".repeat(inst_indent_space),
value_str,
if first_port {
first_port = false;
Expand All @@ -191,7 +196,8 @@ impl Convert {
} else {
writeln!(
stream,
"print(f'{} .{}({})', end='')",
"{}print(f'{} .{}({})', end='')",
" ".repeat(inst_indent_space),
if first_port {
first_port = false;
""
Expand All @@ -209,7 +215,7 @@ impl Convert {
}
}
}
writeln!(stream, "print(f'\\n);')")?;
writeln!(stream, "{}print(f'\\n);')", " ".repeat(inst_indent_space))?;

Ok(())
}
Expand Down

0 comments on commit 20ed7b7

Please sign in to comment.