1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
pub static PY_APP: phf::Map<&'static str, &'static str> = phf_map! {
r#".gitignore"# => r#"/.origen
/output
/web/source/_static/build
/web/source/interbuild
/tmp
/.ref"#,
r#"app_namespace_dir\application.py"# => r#"from origen.application import Base

# This class represents this application and is automatically instantiated as `origen.app`
# It is required by Origen and should not be renamed or removed under any circumstances
class Application(Base):
    pass
"#,
r#"app_namespace_dir\blocks\.gitkeep"# => r#""#,
r#"app_namespace_dir\commands\.gitkeep"# => r#""#,
r#"app_namespace_dir\flows\.gitkeep"# => r#""#,
r#"app_namespace_dir\interface\interface.py"# => r#"from origen.interface import BaseInterface


class Interface(BaseInterface):
    pass"#,
r#"app_namespace_dir\patterns\.gitkeep"# => r#""#,
r#"app_namespace_dir\templates\.gitkeep"# => r#""#,
r#"config\application.toml"# => r#"name = "{{app_name}}"
# Define a default target/environment that will be used by a new workspace
#target = ["dut/falcon", "tester/v93k"]
# To make your application workspace run in production mode by default
#mode = "production""#,
r#"config\commands.toml"# => r#""#,
r#"config\origen.toml"# => r#"# Use this to define your application-specific Origen configuration
# Do not delete it even if you don't use it since it is also used by the Origen
# command line interface to determine when it is in an Origen application workspace

# Specify what command should be used to invoke python, if not specified
# Origen will try python, python3, python3.8, etc. until one is found that
# satisfies the minimum Python version requirement
#python_cmd = "mypython"

# If your company has an internal package server enter it here:
#pkg_server = "https://pkgs.company.net:9292"
# or here, if you need to use different urls for push and pull (write and read):
#pkg_server_push = "https://pkgs.company.net:9292"
#pkg_server_pull = "https://pkgs.company.net:9292""#,
r#"config\version.toml"# => r#"# This file will be overwritten by Origen during an app release
major = 0
minor = 1
patch = 0"#,
r#"pyproject.toml"# => r#"[tool.poetry]
name = "{{app_name}}"
version = "0.1.0"
description = ""
authors = ["{{user_info}}"]

[tool.poetry.dependencies]
python = "^3.6"
origen = "{{origen_version}}"

[tool.poetry.dev-dependencies]
pytest = "^3"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api""#,
r#"setup.cfg"# => r#"[tool:pytest]
testpaths = tests"#,
r#"targets\.gitkeep"# => r#""#,
r#"targets\tester\smt7.py"# => r#"origen.tester.target("V93KSMT7")"#,
r#"targets\tester\smt8.py"# => r#"origen.tester.target("V93KSMT8")"#,
r#"targets\tester\uflex.py"# => r#"origen.tester.target("ULTRAFLEX")"#,
r#"tests\example_test.py"# => r#"import origen
import pytest
from tests.shared import *

def test_example():
    assert 1 == 1"#,
r#"tests\README.md"# => r#"Note that the `tests` folder is the place to create tests to verify the
functionality of this Origen application, it does not refer to silicon
tests!

This is setup to use a popular Python test framework called `pytest` which
requires that following naming convention is followed:

* All files containing tests must be named `<NAME>_test.py`, e.g. `tests/example_test.py`
* Functions that define tests within such files must be named `test_<NAME>`,
  e.g. `def test_example():`

To execute the tests, run the following command from the command line:

~~~
poetry run pytest
~~~"#,
r#"tests\shared\__init__.py"# => r#"# This is a good place to add helper functions that you want to make
# available to all of your tests

import pytest
import origen"#,
r#"vendor\.gitkeep"# => r#""#,
r#"web\make.bat"# => r#"@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
	set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

if "%1" == "" goto help

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
	echo.
	echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
	echo.installed, then set the SPHINXBUILD environment variable to point
	echo.to the full path of the 'sphinx-build' executable. Alternatively you
	echo.may add the Sphinx directory to PATH.
	echo.
	echo.If you don't have Sphinx installed, grab it from
	echo.https://sphinx-doc.org/
	exit /b 1
)

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
"#,
r#"web\Makefile"# => r#"# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS    ?=
SPHINXBUILD   ?= sphinx-build
SOURCEDIR     = source
BUILDDIR      = build

# Put it first so that "make" without argument is like "make help".
help:
	@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option.  $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
	@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
"#,
r#"web\source\conf.py"# => r#"# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
import origen
import origen.web

import sys, os
sys.path.insert(0, os.path.abspath('../../'))

# -- Project information -----------------------------------------------------

project = '{{app_name}}'
copyright = '2020, Origen Core Team'
author = 'Origen Core Team'

# The full version, including alpha/beta/rc tags
release = '0.0.0'

# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
    'origen.web.origen_sphinx_extension', 'autoapi.sphinx',
    'sphinx.ext.autodoc', 'sphinx.ext.napoleon', 'sphinx.ext.autosectionlabel',
    'recommonmark', 'origen.web.shorthand'
]

autosectionlabel_prefix_document = True
autoapi_modules = {
    '{{app_name}}.application': {
        'module-members': ['undoc-members'],
        'class-members': ['members', 'undoc-members']
    }
}
autoapi_output_dir = origen.web.interbuild_dir.joinpath('autoapi')

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []

# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages.  See the documentation for
# a list of builtin themes.
#html_theme_options = {
#    'navbar_links':
#    [('Github', 'https://github.com/Origen-SDK/o2/tree/master/example', True)],
#    'logos': [{
#        'src': '_static/example_logo.png',
#        'alt': 'Example',
#        'rel_src': True,
#    }]
#}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
"#,
r#"web\source\index.rst"# => r#".. example documentation master file, created by
   sphinx-quickstart on Wed Apr 15 21:59:35 2020.
   You can adapt this file completely to your liking, but it should at least
   contain the root `toctree` directive.

Welcome to {{app_name}}'s documentation!
===================================

.. toctree::
   :maxdepth: 2
   :caption: Contents:

   interbuild/autoapi/{{app_name}}.application/{{app_name}}.application

For information on how to build documentation with Origen, see :link-to:`the documentation guides <origen~guides:documenting>`.

Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
"#,
r#"web\source\_static\.gitkeep"# => r#""#,
};

pub static PY_BLOCK: phf::Map<&'static str, &'static str> = phf_map! {
r#"attributes.py"# => r#""#,
r#"controller.py"# => r#"{% if top or nested -%}
{% if dut -%}
from origen.controller import TopLevel as BaseController
{% else -%}
from origen.controller import Base as BaseController
{% endif -%}
{% else -%}
from ...controller import Controller as Parent
{% endif -%}
import origen


{% if top or nested -%}
class Controller(BaseController):
{% else -%}
class Controller(Parent):
{% endif %}    def write_register(self, reg_or_val, size=None, address=None, **kwargs):
{% if top -%}
{% if dut %}        # Invoke your driver of choice to dispatch this write_register request, 
        # here is a JTAG example:
        #self.jtag.write_ir(0xF, size=8)
        #self.jtag.write_dr(reg_or_val, size)
        raise RuntimeError(f"A request to write a register was received by '{self.path}' ({type(self)}), however the logic to implement it has not been defined yet")
{% else %}        # All write register requests originated from within this block (or one of its children)
        # will be sent to the parent block by default, however you can intercept it here and do
        # something else if required
        self.parent.write_register(reg_or_val, size, address, **kwargs)
{% endif %}{% else %}        # All write register requests originated from within this block (or one of its children)
        # will be sent to the parent class by default, however you can intercept it here and do
        # something else if required
        super().write_register(reg_or_val, size, address, **kwargs)
{% endif %}
    def verify_register(self, reg_or_val, size=None, address=None, **kwargs):
{% if top -%}
{% if dut %}        # Invoke your driver of choice to dispatch this verify_register request, 
        # here is a JTAG example:
        #self.jtag.write_ir(0x1F, size=8)
        #self.jtag.verify_dr(reg_or_val, size)
        raise RuntimeError(f"A request to verify a register was received by '{self.path}' ({type(self)}), however the logic to implement it has not been defined yet")
{% else %}        # All verify register requests originated from within this block (or one of its children)
        # will be sent to the parent block by default, however you can intercept it here and do
        # something else if required
        self.parent.verify_register(reg_or_val, size, address, **kwargs)
{% endif %}{% else %}        # A verify register requests originated from within this block (or one of its children)
        # will be sent to the parent class by default, however you can intercept it here and do
        # something else if required
        super().verify_register(reg_or_val, size, address, **kwargs)
{% endif -%}"#,
r#"levels.py"# => r#""#,
r#"pins.py"# => r#""#,
r#"registers.py"# => r#"##########################################################################################
{% if top -%}
# Any registers defined here will be added to all DUTs in your application
{% else -%}
# Any registers defined here will be added to this DUT and all of its derivative children
{% endif -%}
##########################################################################################

# Example of a simple register definition with all bits r/w, 0x0 is the local offset address:
#
#     SimpleReg("my_reg1", 0x0, size=32)  # 32 is the default size if not specified
#
# Example of a richer definition with bitfields:
#
#     with Reg("my_reg2", 0x4):
#         Field("coco", offset=7, access="ro")
#         Field("aien", offset=6)
#         Field("diff", offset=5)
#         Field(
#             "adch",
#             offset=0,
#             width=5,
#             reset=0x1F,
#             enums={
#                 # A simple enum
#                 "val1": 3,
#                 # A more complex enum, all fields except for value are optional
#                 "val2": {
#                     "value": 5,
#                     "usage": "w",
#                     "description": "The value of something"
#                 },
#             })
#
# For more examples and full documentation see: https://origen-sdk.org/o2/guides/registers
    
"#,
r#"services.py"# => r#""#,
r#"sub_blocks.py"# => r#""#,
r#"timing.py"# => r#""#,
};