Generate the single router design

118 views
Skip to first unread message

김지현

unread,
Aug 18, 2023, 3:40:05 AM8/18/23
to pymtl-users

Hello,

I am new to PyMTL and I'm interested in utilizing PyMTL3 or PyMTL3-net for my research.

To be more specific, my goal is to create a Verilog model of a single router using PyMTL3(-net), and later, evaluate the area and timing overhead using a synthesis tool.

While I've managed to modify the router design in PyMTL3-net, I found that synthesizing the entire network (such as mesh or ring) is unnecessary for my research; all I require is a model of a single router. Thus, I have two questions:

  1. 1. Is it possible to generate a Verilog model of a single router design using PyMTL3-net (or PyOCN)?


  2. 2. If this isn't possible, would it be more practical (or advisable) to create the router design using PyMTL3?

Thank you in advance!



Yanghui Ou

unread,
Aug 18, 2023, 2:24:21 PM8/18/23
to 김지현, pymtl-users
Hi,

Thank you for using pymtl3-net. Yes it is definitely possible to just generate Verilog for a router. You can simply run a router test with `--test-verilog` flag using pytest. Alternatively, you can also write a simple test for your router like this to generate the verilog:
from pymtl3.stdlib.test_utils import (run_sim,
                                      config_model_with_cmdline_opts)

def test_translate( cmdline_opts ):
  dut = MyRouter()
  dut = config_model_with_cmdline_opts( dut, cmdline_opts, duts=[] )
Then you can run this test using pytest with the `--test-verilog` flag. 

Let me know if you run into any problems.

Best,
Yanghui

--
You received this message because you are subscribed to the Google Groups "pymtl-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pymtl-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pymtl-users/2362eb57-11a2-40bb-b18c-5d3176d85514n%40googlegroups.com.

Jihyun Kim

unread,
Aug 21, 2023, 10:42:24 AM8/21/23
to pymtl-users
First of all, thanks for your response!

I actually wanted to use the router code from /pymtl3-net/router directly, perhaps configure a network that has only one router.
Maybe is this possible in pymtl3-net?

If I can't do that in pymtl3-net, I am considering using the module/class that is already in pymtl3-net, SwitchUnitRTL.py, XYZRouteUnitRTL.py, etc.
Would this approach be feasible, or should I considering made my own router from scratch?

If you could confirm my understanding or provide any additional insights, I would greatly appreciate it.

Best,
Jihyun

Yanghui Ou

unread,
Aug 23, 2023, 12:17:38 AM8/23/23
to Jihyun Kim, pymtl-users
Hi Jihyun,

You can use the router code directly. You just need to pick the corresponding router test and run it with the `--test-verilog` flag. You can also use the `-k` command to select the test you want to run. For example, you can run the following commands to generate the router for mesh network:

$ cd pymtl3_net/meshnet/test
$ mkdir build && cd build
$ pytest ../MeshRouteUnitRTLMflitXY_test.py --test-verilog -k test_1pkt

If you want to generate Verilog code for your own router or with your customized parameters, you can add an additional test case that looks like this:

from pymtl3.stdlib.test_utils import (run_sim,
                                      config_model_with_cmdline_opts)

def test_translate( cmdline_opts ):
  dut = MyRouter()
  dut = config_model_with_cmdline_opts( dut, cmdline_opts, duts=[] )

Where `MyRouter` is your customized router class.

Let me know if this answers your question.

Best,
Yanghui

Jihyun Kim

unread,
Aug 23, 2023, 4:00:46 AM8/23/23
to Yanghui Ou, pymtl-users
Yes, it is the answer that I want.

I am sorry but I still have some concerns regarding the output of the test.

I have been experimenting with generating the router code in pymtl3-net using the command sequence detailed below:

$ cd pymtl3_net/meshnet/test
$ mkdir build && cd build

$ pytest ../MeshRouterRTL_test.py --test-verilog

The output seems to indicate that the pytest did not complete successfully:
================================================================== test session starts ==================================================================
platform linux -- Python 3.7.5, pytest-7.4.0, pluggy-1.2.0
rootdir: /root/cornell-brg/cornell-brg/posh-ocn
configfile: pytest.ini
plugins: pymtl3-3.1.15, hypothesis-6.79.4
collected 5 items

../MeshRouterRTL_test.py FFFFF

Furthermore, it output the MeshRouterRTL__1c0c758909513a6e__pickled.v and MeshRouterRTL__d7ef04b1c70dfb50__pickled.v.
While there is some output, I am not sure whether these files are considered valid outputs.

Earlier, I had also looked into a GitHub issue (https://github.com/cornell-brg/pymtl3-net/issues/24) to generate the verilog file:
With this command, most of the testcase also siently fails, but some verilog files are still generated.

$ pytest ../ -v --test-verilog

But running pymtl3-net from the script directory with this command generate the mesh.v that seems normal.

$ pymtl3-net gen mesh --ncols 4 --nrows 4


In summary, I want to double check the generated file like XX__pickled.v. is still valid, or maybe there might be something wrong with my environment setting.

Thanks again,
Jihyun

Christopher Batten

unread,
Aug 23, 2023, 4:38:40 AM8/23/23
to Jihyun Kim, Yanghui Ou, pymtl-users


Hmmm ... what is the error you are seeing? you might need to use something like --tb=short so that pytest tells you more information about the error ...

Have you installed Verilator 4.036? There are instructions here on how to do that:


If everything it setup correctly when you run --test-verilog it generates the Verilog, uses Verilator to translate the Verilog into C++, then automatically generates appropriate wrappers, compiles the C++, and then rerun all of the tests ... so that is how you know the Verilog is correct ...

Hope this helps!
Chris

Jihyun Kim

unread,
Aug 23, 2023, 9:43:18 AM8/23/23
to pymtl-users
Thanks for your reply!

Yes, the problem is solved now. 
I checked the error messeage with  --tb=short flag, and it shows: 

/root/venv/lib/python3.8/site-packages/pymtl3/passes/backends/verilog/import_/VerilogVerilatorImportConfigs.py:366: in _get_all_includes
    subprocess.check_output(get_dir_cmd, stderr = subprocess.STDOUT).strip()
/usr/lib/python3.8/subprocess.py:415: in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
/usr/lib/python3.8/subprocess.py:493: in run
    with Popen(*popenargs, **kwargs) as process:
/usr/lib/python3.8/subprocess.py:858: in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
/usr/lib/python3.8/subprocess.py:1704: in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
E   FileNotFoundError: [Errno 2] No such file or directory: 'pkg-config'

So I install the pkg-config, and  all the tests are now passing without any issues.

Thank you once again for your help and the amazing work!

Best, 
Jihyun

Christopher Batten

unread,
Aug 23, 2023, 12:08:06 PM8/23/23
to Jihyun Kim, pymtl-users
Glad to hear it is working!
-c


Reply all
Reply to author
Forward
0 new messages