Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B-ASIC - Better ASIC Toolbox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Computer Engineering
B-ASIC - Better ASIC Toolbox
Merge requests
!397
Fix typing, spelling errors and minor tests
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Fix typing, spelling errors and minor tests
cleanups3
into
master
Overview
0
Commits
1
Pipelines
4
Changes
9
Merged
Oscar Gustafsson
requested to merge
cleanups3
into
master
2 years ago
Overview
0
Commits
1
Pipelines
4
Changes
9
Expand
0
0
Merge request reports
Compare
master
version 3
61abfb83
2 years ago
version 2
40048d5c
2 years ago
version 1
7cd95a1d
2 years ago
master (base)
and
latest version
latest version
39efd629
1 commit,
2 years ago
version 3
61abfb83
1 commit,
2 years ago
version 2
40048d5c
1 commit,
2 years ago
version 1
7cd95a1d
1 commit,
2 years ago
9 files
+
122
−
100
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
9
Search (e.g. *.vue) (Ctrl+P)
b_asic/codegen/vhdl/__init__.py
+
14
−
17
Options
@@ -2,15 +2,14 @@
@@ -2,15 +2,14 @@
Module for basic VHDL code generation.
Module for basic VHDL code generation.
"""
"""
from
io
import
TextIOWrapper
from
typing
import
List
,
Optional
,
TextIO
,
Tuple
,
Union
from
typing
import
List
,
Optional
,
Tuple
,
Union
# VHDL code generation tab length
# VHDL code generation tab length
VHDL_TAB
=
r
"
"
VHDL_TAB
=
r
"
"
def
write
(
def
write
(
f
:
TextIO
Wrapper
,
f
:
TextIO
,
indent_level
:
int
,
indent_level
:
int
,
text
:
str
,
text
:
str
,
*
,
*
,
@@ -20,13 +19,13 @@ def write(
@@ -20,13 +19,13 @@ def write(
"""
"""
Base VHDL code generation utility.
Base VHDL code generation utility.
`f
'
{VHDL_TAB*indent_level}
'
` is first written to the
:class:`io.TextIOWrapper`
`
`f
'
{VHDL_TAB*indent_level}
'
`
`
is first written to the
TextIO
object
`f`
. Immediately after the indentation,
`
text
`
is written to
`f`
. Finally,
object
*f*
. Immediately after the indentation,
*
text
*
is written to
*f*
. Finally,
`
text
`
is also written to
`f`
.
*
text
*
is also written to
*f*
.
Parameters
Parameters
----------
----------
f :
:class:`io.TextIOWrapper`
f :
TextIO
The file object to emit VHDL code to.
The file object to emit VHDL code to.
indent_level : int
indent_level : int
Indentation level to use. Exactly ``f
'
{VHDL_TAB*indent_level}`` is written
Indentation level to use. Exactly ``f
'
{VHDL_TAB*indent_level}`` is written
@@ -43,24 +42,22 @@ def write(
@@ -43,24 +42,22 @@ def write(
f
.
write
(
f
'
{
VHDL_TAB
*
indent_level
}{
text
}{
end
}
'
)
f
.
write
(
f
'
{
VHDL_TAB
*
indent_level
}{
text
}{
end
}
'
)
def
write_lines
(
def
write_lines
(
f
:
TextIO
,
lines
:
List
[
Union
[
Tuple
[
int
,
str
],
Tuple
[
int
,
str
,
str
]]]):
f
:
TextIOWrapper
,
lines
:
List
[
Union
[
Tuple
[
int
,
str
],
Tuple
[
int
,
str
,
str
]]]
):
"""
"""
Multiline VHDL code generation utility.
Multiline VHDL code generation utility.
Each tuple (int, str, [int]) in the list
`
lines
`
is written to the
Each tuple
``
(int, str, [int])
``
in the list
*
lines
*
is written to the
:class:`io.TextIOWrapper`
object
`f`
using the :function:`vhdl.write` function.
TextIO
object
*f*
using the :function:`vhdl.write` function.
Parameters
Parameters
----------
----------
f :
:class:`io.TextIOWrapper`
f :
TextIO
The file object to emit VHDL code to.
The file object to emit VHDL code to.
lines : list of tuple (int,str) [1], or list of tuple (int,str,str) [2]
lines : list of tuple (int,str) [1], or list of tuple (int,str,str) [2]
[1]: The first `int` of the tuple is used as indentation level for the line
and
[1]: The first
`
`int`
`
of the tuple is used as indentation level for the line
the second `str` of the tuple is the content of the line.
and
the second
`
`str`
`
of the tuple is the content of the line.
[2]: Same as [1], but the third `str` of the tuple is passed to parameter
`end`
[2]: Same as [1], but the third
`
`str`
`
of the tuple is passed to parameter
when calling :function:`vhdl.write`.
*end*
when calling :function:`vhdl.write`.
"""
"""
for
tpl
in
lines
:
for
tpl
in
lines
:
if
len
(
tpl
)
==
2
:
if
len
(
tpl
)
==
2
:
Loading