Skip to content

Commit

Permalink
📚 Continued improving presentation
Browse files Browse the repository at this point in the history
  • Loading branch information
daquintero committed Jun 21, 2024
1 parent 29bca45 commit 4dda06d
Show file tree
Hide file tree
Showing 852 changed files with 7,417 additions and 440,857 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_static/resources/fsic_2024_presentation.odp
Binary file not shown.
290 changes: 21 additions & 269 deletions docs/examples/01_run_openlane_flow.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# * `cocotb` is mainly used for writing testbenches in Python and verification of logic.

import piel
from piel.types import TruthTable

import simple_design

Expand All @@ -19,19 +20,16 @@
verify_amaranth_truth_table,
)

# +
# Uncomment this if you want to run it for the first time.
# piel.create_empty_piel_project(
# project_name="amaranth_driven_flow", parent_directory="../designs/"
# )
# -
# # Uncomment this if you want to run it for the first time.
piel.create_empty_piel_project(
project_name="amaranth_driven_flow", parent_directory="../designs/"
)

# We can also automate the `pip` installation of our local module:

# +
# ! pip install -e ../designs/amaranth_driven_flow
# Uncomment this if you want to run it for the first time.
# piel.pip_install_local_module("../designs/amaranth_driven_flow")
# -

# We can check that this has been installed. You might need to restart your `jupyter` kernel.

Expand Down Expand Up @@ -64,15 +62,15 @@
"detector_in": ["00", "01", "10", "11"],
"phase_map_out": ["00", "10", "11", "11"],
}
detector_phase_truth_table = piel.types.TruthTable(
detector_phase_truth_table = TruthTable(
input_ports=["detector_in"],
output_ports=["phase_map_out"],
**detector_phase_truth_table_dictionary
)


our_truth_table_module = construct_amaranth_module_from_truth_table(
truth_table=detector_phase_truth_table,
truth_table=detector_phase_truth_table
)

# `amaranth` is much easier to use than other design flows like `cocotb` because it can be purely interacted with in `Python`, which means there are fewer complexities of integration. However, if you desire to use this with other digital layout tools, for example, `OpenROAD` as we have previously seen and maintain a coherent project structure with the photonics design flow, `piel` provides some helper functions to achieve this easily.
Expand All @@ -82,7 +80,7 @@
generate_verilog_from_amaranth_truth_table(
amaranth_module=our_truth_table_module,
truth_table=detector_phase_truth_table,
target_file_name="our_truth_table_module.v",
target_file_name="truth_table_module.v",
target_directory=".",
)

Expand All @@ -105,38 +103,38 @@
generate_verilog_from_amaranth_truth_table(
amaranth_module=our_truth_table_module,
truth_table=detector_phase_truth_table,
target_file_name="our_truth_table_module.v",
target_file_name="truth_table_module.v",
target_directory=amaranth_driven_flow_src_folder,
)

# ```
# Verilog file generated and written to /home/daquintero/phd/piel/docs/examples/designs/amaranth_driven_flow/amaranth_driven_flow/src/our_truth_table_module.v
# Verilog file generated and written to /home/daquintero/phd/piel/docs/examples/designs/amaranth_driven_flow/amaranth_driven_flow/src/truth_table_module.v
# ```

# Another thing we can do is verify that our implemented logic is valid. Creating a simulation is also useful in the future when we simulate our extracted place-and-route netlist in relation to the expected applied logic.

verify_amaranth_truth_table(
truth_table_amaranth_module=our_truth_table_module,
truth_table=detector_phase_truth_table,
vcd_file_name="our_truth_table_module.vcd",
vcd_file_name="truth_table_module.vcd",
target_directory=".",
)

# ```
# VCD file generated and written to /home/daquintero/phd/piel/docs/examples/02_digital_design_simulation/our_truth_table_module.vcd
# VCD file generated and written to /home/daquintero/phd/piel/docs/examples/02_digital_design_simulation/truth_table_module.vcd
# ```

# You can also use the module directory to automatically save the testbench in these functions.

verify_amaranth_truth_table(
truth_table_amaranth_module=our_truth_table_module,
truth_table=detector_phase_truth_table,
vcd_file_name="our_truth_table_module.vcd",
vcd_file_name="truth_table_module.vcd",
target_directory=amaranth_driven_flow,
)

# ```
# VCD file generated and written to /home/daquintero/phd/piel/docs/examples/designs/amaranth_driven_flow/amaranth_driven_flow/tb/our_truth_table_module.vcd
# VCD file generated and written to /home/daquintero/phd/piel/docs/examples/designs/amaranth_driven_flow/amaranth_driven_flow/tb/truth_table_module.vcd
# ```

# You can observe the design directory of the provided `amaranth_driven_flow` folder to verify that the files have been included in the other flow.
Expand All @@ -158,7 +156,36 @@
amaranth_module=our_truth_table_module,
truth_table=detector_phase_truth_table,
parent_directory=amaranth_driven_flow,
openlane_version="v1",
openlane_version="v2",
)

# +
from piel.types import TruthTable
import piel

detector_phase_truth_table = {
"detector_in": ["00", "01", "10", "11"],
"phase_map_out": ["00", "10", "11", "11"],
}
truth_table = TruthTable(
input_ports=["detector_in"],
output_ports=["phase_map_out"],
**detector_phase_truth_table
)
am_module = piel.amaranth.construct_amaranth_module_from_truth_table(
truth_table, logic_implementation_type="sequential"
)
am_module

from piel.integration.amaranth_openlane import (
layout_amaranth_truth_table_through_openlane,
)

layout_amaranth_truth_table_through_openlane(
amaranth_module=am_module,
truth_table=truth_table,
parent_directory="openlane_run",
openlane_version="v2",
)
# -

Expand Down Expand Up @@ -319,3 +346,42 @@
# This looks like this:

# ![example_simple_design_outputs](../../_static/img/examples/02_cocotb_simulation/example_simple_design_outputs.PNG)

# ## Sequential Implementation

# +
from openlane.flows import SequentialFlow
from openlane.steps import Yosys, Misc, OpenROAD, Magic, Netgen


class MyFlow(SequentialFlow):
Steps = [
Yosys.Synthesis,
OpenROAD.Floorplan,
OpenROAD.TapEndcapInsertion,
OpenROAD.GeneratePDN,
OpenROAD.IOPlacement,
OpenROAD.GlobalPlacement,
OpenROAD.DetailedPlacement,
OpenROAD.GlobalRouting,
OpenROAD.DetailedRouting,
OpenROAD.FillInsertion,
Magic.StreamOut,
Magic.DRC,
Magic.SpiceExtraction,
Netgen.LVS,
]


flow = MyFlow(
{
"PDK": "sky130A",
"DESIGN_NAME": "spm",
"VERILOG_FILES": ["./src/spm.v"],
"CLOCK_PORT": "clk",
"CLOCK_PERIOD": 10,
},
design_dir=".",
)
flow.start()
# -
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/* Generated by Yosys 0.38 (git sha1 543faed9c8c, clang++ 17.0.6 -fPIC -Os) */

(* top = 1 *)
(* generator = "Amaranth" *)
module top(phase_map_out, clk, rst, detector_in);
reg \$auto$verilog_backend.cc:2334:dump_module$1 = 0;
(* src = "/home/daquintero/.pyenv/versions/3.10.13/envs/piel_0_57/lib/python3.10/site-packages/amaranth/hdl/ir.py:508" *)
input clk;
wire clk;
(* src = "/home/daquintero/phd/piel/piel/tools/amaranth/construct.py:139" *)
input [1:0] detector_in;
wire [1:0] detector_in;
(* src = "/home/daquintero/phd/piel/piel/tools/amaranth/construct.py:160" *)
reg [1:0] next_state = 2'h0;
(* src = "/home/daquintero/phd/piel/piel/tools/amaranth/construct.py:160" *)
reg [1:0] \next_state$next ;
(* src = "/home/daquintero/phd/piel/piel/tools/amaranth/construct.py:141" *)
output [1:0] phase_map_out;
reg [1:0] phase_map_out = 2'h0;
(* src = "/home/daquintero/phd/piel/piel/tools/amaranth/construct.py:141" *)
reg [1:0] \phase_map_out$next ;
(* src = "/home/daquintero/.pyenv/versions/3.10.13/envs/piel_0_57/lib/python3.10/site-packages/amaranth/hdl/ir.py:508" *)
input rst;
wire rst;
(* src = "/home/daquintero/phd/piel/piel/tools/amaranth/construct.py:154" *)
reg [1:0] state = 2'h0;
(* src = "/home/daquintero/phd/piel/piel/tools/amaranth/construct.py:154" *)
reg [1:0] \state$next ;
always @(posedge clk)
state <= \state$next ;
always @(posedge clk)
next_state <= \next_state$next ;
always @(posedge clk)
phase_map_out <= \phase_map_out$next ;
always @* begin
if (\$auto$verilog_backend.cc:2334:dump_module$1 ) begin end
\state$next = next_state;
(* src = "/home/daquintero/.pyenv/versions/3.10.13/envs/piel_0_57/lib/python3.10/site-packages/amaranth/hdl/xfrm.py:503" *)
if (rst) begin
\state$next = 2'h0;
end
end
always @* begin
if (\$auto$verilog_backend.cc:2334:dump_module$1 ) begin end
(* full_case = 32'd1 *)
(* src = "/home/daquintero/phd/piel/piel/tools/amaranth/construct.py:165" *)
casez (detector_in)
/* src = "/home/daquintero/phd/piel/piel/tools/amaranth/construct.py:168" */
2'h0:
\next_state$next = 2'h0;
/* src = "/home/daquintero/phd/piel/piel/tools/amaranth/construct.py:168" */
2'h1:
\next_state$next = 2'h1;
/* src = "/home/daquintero/phd/piel/piel/tools/amaranth/construct.py:168" */
2'h2:
\next_state$next = 2'h2;
/* src = "/home/daquintero/phd/piel/piel/tools/amaranth/construct.py:168" */
2'h3:
\next_state$next = 2'h3;
endcase
(* src = "/home/daquintero/.pyenv/versions/3.10.13/envs/piel_0_57/lib/python3.10/site-packages/amaranth/hdl/xfrm.py:503" *)
if (rst) begin
\next_state$next = 2'h0;
end
end
always @* begin
if (\$auto$verilog_backend.cc:2334:dump_module$1 ) begin end
(* full_case = 32'd1 *)
(* src = "/home/daquintero/phd/piel/piel/tools/amaranth/construct.py:165" *)
casez (detector_in)
/* src = "/home/daquintero/phd/piel/piel/tools/amaranth/construct.py:168" */
2'h0:
\phase_map_out$next = 2'h0;
/* src = "/home/daquintero/phd/piel/piel/tools/amaranth/construct.py:168" */
2'h1:
\phase_map_out$next = 2'h2;
/* src = "/home/daquintero/phd/piel/piel/tools/amaranth/construct.py:168" */
2'h2:
\phase_map_out$next = 2'h3;
/* src = "/home/daquintero/phd/piel/piel/tools/amaranth/construct.py:168" */
2'h3:
\phase_map_out$next = 2'h3;
endcase
(* src = "/home/daquintero/.pyenv/versions/3.10.13/envs/piel_0_57/lib/python3.10/site-packages/amaranth/hdl/xfrm.py:503" *)
if (rst) begin
\phase_map_out$next = 2'h0;
end
end
endmodule
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TruthTableModule
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env python
from distutils.core import setup

setup(name="TruthTableModule",
version="0.0.1",
description="Example empty piel project."
, author="Dario Quintero",
author_email="[email protected]",
url="https://github.com/daquintero/piel",
packages=['TruthTableModule'],
)

This file was deleted.

32 changes: 32 additions & 0 deletions docs/examples/02_digital_design_simulation/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from openlane.flows import SequentialFlow
from openlane.steps import Yosys, Misc, OpenROAD, Magic, Netgen

class MyFlow(SequentialFlow):
Steps = [
Yosys.Synthesis,
OpenROAD.Floorplan,
OpenROAD.TapEndcapInsertion,
OpenROAD.GeneratePDN,
OpenROAD.IOPlacement,
OpenROAD.GlobalPlacement,
OpenROAD.DetailedPlacement,
OpenROAD.GlobalRouting,
OpenROAD.DetailedRouting,
OpenROAD.FillInsertion,
Magic.StreamOut,
Magic.DRC,
Magic.SpiceExtraction,
Netgen.LVS
]

flow = MyFlow(
{
"PDK": "sky130A",
"DESIGN_NAME": "top",
"VERILOG_FILES": ["/home/daquintero/phd/piel/docs/examples/designs/amaranth_driven_flow/amaranth_driven_flow/src/truth_table_module.v"],
"CLOCK_PORT": "clk",
"CLOCK_PERIOD": 10,
},
design_dir=".",
)
flow.start()
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
/* Generated by Amaranth Yosys 0.40 (PyPI ver 0.40.0.0.post95, git sha1 a1bb0255d) */
/* Generated by Yosys 0.38 (git sha1 543faed9c8c, clang++ 17.0.6 -fPIC -Os) */

(* top = 1 *)
(* generator = "Amaranth" *)
module top(phase_map_out, detector_in);
reg \$auto$verilog_backend.cc:2352:dump_module$1 = 0;
(* src = "/home/daquintero/phd/piel/piel/tools/amaranth/construct.py:83" *)
reg \$auto$verilog_backend.cc:2334:dump_module$1 = 0;
(* src = "/home/daquintero/phd/piel/piel/tools/amaranth/construct.py:84" *)
input [1:0] detector_in;
wire [1:0] detector_in;
(* src = "/home/daquintero/phd/piel/piel/tools/amaranth/construct.py:87" *)
(* src = "/home/daquintero/phd/piel/piel/tools/amaranth/construct.py:88" *)
output [1:0] phase_map_out;
reg [1:0] phase_map_out;
always @* begin
if (\$auto$verilog_backend.cc:2352:dump_module$1 ) begin end
if (\$auto$verilog_backend.cc:2334:dump_module$1 ) begin end
(* full_case = 32'd1 *)
(* src = "/home/daquintero/phd/piel/piel/tools/amaranth/construct.py:113" *)
(* src = "/home/daquintero/phd/piel/piel/tools/amaranth/construct.py:114" *)
casez (detector_in)
/* src = "/home/daquintero/phd/piel/piel/tools/amaranth/construct.py:116" */
/* src = "/home/daquintero/phd/piel/piel/tools/amaranth/construct.py:117" */
2'h0:
phase_map_out = 2'h0;
/* src = "/home/daquintero/phd/piel/piel/tools/amaranth/construct.py:116" */
/* src = "/home/daquintero/phd/piel/piel/tools/amaranth/construct.py:117" */
2'h1:
phase_map_out = 2'h2;
/* src = "/home/daquintero/phd/piel/piel/tools/amaranth/construct.py:116" */
/* src = "/home/daquintero/phd/piel/piel/tools/amaranth/construct.py:117" */
2'h2:
phase_map_out = 2'h3;
/* src = "/home/daquintero/phd/piel/piel/tools/amaranth/construct.py:116" */
/* src = "/home/daquintero/phd/piel/piel/tools/amaranth/construct.py:117" */
2'h3:
phase_map_out = 2'h3;
endcase
Expand Down
Loading

0 comments on commit 4dda06d

Please sign in to comment.