NeerjaK commited on
Commit
adceaef
·
verified ·
1 Parent(s): f334838

Upload folder using huggingface_hub

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +6 -0
  2. Dockerfile +22 -5
  3. README.md +35 -15
  4. client.py +1 -1
  5. inference.py +25 -25
  6. openenv.yaml +4 -4
  7. requirements.txt +12 -0
  8. server/app.py +5 -5
  9. server/graders.py +103 -19
  10. server/rtl_debugger_environment.py +10 -7
  11. tasks/task1/design_active.v +3 -5
  12. tasks/task1/results.xml +2 -2
  13. tasks/task1/sim_build/Vtop +3 -0
  14. tasks/task1/sim_build/Vtop.cpp +99 -0
  15. tasks/task1/sim_build/Vtop.h +92 -0
  16. tasks/task1/sim_build/Vtop.mk +72 -0
  17. tasks/task1/sim_build/Vtop__ALL.a +0 -0
  18. tasks/task1/sim_build/Vtop__ALL.cpp +10 -0
  19. tasks/task1/sim_build/Vtop__ALL.d +14 -0
  20. tasks/task1/sim_build/Vtop__ALL.o +0 -0
  21. tasks/task1/sim_build/Vtop__Dpi.cpp +16 -0
  22. tasks/task1/sim_build/Vtop__Dpi.h +22 -0
  23. tasks/task1/sim_build/Vtop__Syms.cpp +50 -0
  24. tasks/task1/sim_build/Vtop__Syms.h +47 -0
  25. tasks/task1/sim_build/Vtop___024root.h +47 -0
  26. tasks/task1/sim_build/Vtop___024root__DepSet_h84412442__0.cpp +40 -0
  27. tasks/task1/sim_build/Vtop___024root__DepSet_h84412442__0__Slow.cpp +24 -0
  28. tasks/task1/sim_build/Vtop___024root__DepSet_heccd7ead__0.cpp +179 -0
  29. tasks/task1/sim_build/Vtop___024root__DepSet_heccd7ead__0__Slow.cpp +154 -0
  30. tasks/task1/sim_build/Vtop___024root__Slow.cpp +24 -0
  31. tasks/task1/sim_build/Vtop__pch.h +29 -0
  32. tasks/task1/sim_build/Vtop__ver.d +1 -0
  33. tasks/task1/sim_build/Vtop__verFiles.dat +23 -0
  34. tasks/task1/sim_build/Vtop_classes.mk +57 -0
  35. tasks/task1/sim_build/sim.vvp +10 -10
  36. tasks/task1/sim_build/verilated.d +12 -0
  37. tasks/task1/sim_build/verilated.o +3 -0
  38. tasks/task1/sim_build/verilated_dpi.d +12 -0
  39. tasks/task1/sim_build/verilated_dpi.o +0 -0
  40. tasks/task1/sim_build/verilated_threads.d +8 -0
  41. tasks/task1/sim_build/verilated_threads.o +0 -0
  42. tasks/task1/sim_build/verilated_vpi.d +13 -0
  43. tasks/task1/sim_build/verilated_vpi.o +3 -0
  44. tasks/task1/sim_build/verilator.d +14 -0
  45. tasks/task1/sim_build/verilator.o +0 -0
  46. tasks/task2/design_active.v +15 -18
  47. tasks/task2/result.json +24 -24
  48. tasks/task2/results.xml +4 -2
  49. tasks/task2/sim_build/sim.vvp +19 -42
  50. tasks/task3/design_active.v +37 -37
.gitattributes CHANGED
@@ -33,3 +33,9 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tasks/task1/sim_build/Vtop filter=lfs diff=lfs merge=lfs -text
37
+ tasks/task1/sim_build/verilated.o filter=lfs diff=lfs merge=lfs -text
38
+ tasks/task1/sim_build/verilated_vpi.o filter=lfs diff=lfs merge=lfs -text
39
+ tasks/task3/sim_build/Vtop filter=lfs diff=lfs merge=lfs -text
40
+ tasks/task3/sim_build/verilated.o filter=lfs diff=lfs merge=lfs -text
41
+ tasks/task3/sim_build/verilated_vpi.o filter=lfs diff=lfs merge=lfs -text
Dockerfile CHANGED
@@ -16,11 +16,24 @@ FROM ${BASE_IMAGE} AS builder
16
  WORKDIR /app
17
 
18
  # Ensure git, iverilog, and make are available
19
- ARG DEBIAN_FRONTEND=noninteractive
20
  RUN apt-get update && \
21
- apt-get install -y --no-install-recommends git iverilog make && \
 
 
 
22
  rm -rf /var/lib/apt/lists/*
23
 
 
 
 
 
 
 
 
 
 
 
 
24
  # Build argument to control whether we're building standalone or in-repo
25
  ARG BUILD_MODE=in-repo
26
  ARG ENV_NAME=rtl_debugger
@@ -61,7 +74,9 @@ FROM ${BASE_IMAGE}
61
  # Install runtime dependencies (iverilog and make)
62
  ARG DEBIAN_FRONTEND=noninteractive
63
  RUN apt-get update && \
64
- apt-get install -y --no-install-recommends iverilog make && \
 
 
65
  rm -rf /var/lib/apt/lists/*
66
 
67
  WORKDIR /app
@@ -72,6 +87,8 @@ COPY --from=builder /app/env/.venv /app/.venv
72
  # Copy the environment code
73
  COPY --from=builder /app/env /app/env
74
 
 
 
75
  # Set PATH to use the virtual environment
76
  ENV PATH="/app/.venv/bin:$PATH"
77
 
@@ -82,8 +99,8 @@ ENV ENABLE_WEB_INTERFACE=true
82
 
83
  # Health check
84
  HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
85
- CMD curl -f http://localhost:8000/health || exit 1
86
 
87
  # Run the FastAPI server
88
  # The module path is constructed to work with the /app/env structure
89
- CMD ["sh", "-c", "cd /app/env && uvicorn server.app:app --host 0.0.0.0 --port 8000"]
 
16
  WORKDIR /app
17
 
18
  # Ensure git, iverilog, and make are available
 
19
  RUN apt-get update && \
20
+ apt-get install -y --no-install-recommends \
21
+ git make autoconf g++ flex bison help2man \
22
+ libfl-dev zlib1g-dev python3 \
23
+ iverilog && \
24
  rm -rf /var/lib/apt/lists/*
25
 
26
+ # Install Verilator (required version)
27
+ RUN git clone https://github.com/verilator/verilator && \
28
+ cd verilator && \
29
+ git checkout v5.036 && \
30
+ autoconf && \
31
+ ./configure && \
32
+ make -j$(nproc) && \
33
+ make install && \
34
+ cd .. && \
35
+ rm -rf verilator
36
+
37
  # Build argument to control whether we're building standalone or in-repo
38
  ARG BUILD_MODE=in-repo
39
  ARG ENV_NAME=rtl_debugger
 
74
  # Install runtime dependencies (iverilog and make)
75
  ARG DEBIAN_FRONTEND=noninteractive
76
  RUN apt-get update && \
77
+ apt-get install -y --no-install-recommends \
78
+ git make \
79
+ iverilog && \
80
  rm -rf /var/lib/apt/lists/*
81
 
82
  WORKDIR /app
 
87
  # Copy the environment code
88
  COPY --from=builder /app/env /app/env
89
 
90
+ COPY --from=builder /usr/local/bin/verilator /usr/local/bin/verilator
91
+ COPY --from=builder /usr/local/share/verilator /usr/local/share/verilator
92
  # Set PATH to use the virtual environment
93
  ENV PATH="/app/.venv/bin:$PATH"
94
 
 
99
 
100
  # Health check
101
  HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
102
+ CMD curl -f http://localhost:7860/health || exit 1
103
 
104
  # Run the FastAPI server
105
  # The module path is constructed to work with the /app/env structure
106
+ CMD ["sh", "-c", "cd /app/env && uvicorn server.app:app --host 0.0.0.0 --port 7860"]
README.md CHANGED
@@ -5,7 +5,7 @@ colorFrom: blue
5
  colorTo: green
6
  sdk: docker
7
  pinned: false
8
- app_port: 8000
9
  base_path: /web
10
  tags:
11
  - openenv
@@ -16,7 +16,16 @@ tags:
16
 
17
  # RTL Debugger Environment
18
 
19
- The **RTL Debugger** is a Reinforcement Learning environment designed for automated hardware design fixing. It enables LLM-based agents to iteratively debug Verilog code.
 
 
 
 
 
 
 
 
 
20
 
21
  ## Quick Start
22
 
@@ -30,9 +39,9 @@ docker build -t rtl_debugger-env:latest .
30
 
31
  ### 2. Launch the Environment Server
32
  ```bash
33
- docker run -p 8000:8000 --rm rtl_debugger-env:latest
34
  ```
35
- Access the interactive web-playground at: [http://localhost:8000/web](http://localhost:8000/web)
36
 
37
  ### 3. Run the Inference Agent
38
  We provide a reference inference script that uses LLM to play the environment:
@@ -48,20 +57,31 @@ uv run python inference.py
48
 
49
  ## Environment Details
50
 
51
- ### Action Model (`RtlDebuggerAction`)
52
- Agents submit their corrected Verilog module:
53
- - `fixed_code` (str): The full Verilog module source.
 
 
 
54
 
55
- ### Observation: `RtlDebuggerObservation`
56
  | Field | Type | Description |
57
  | :--- | :--- | :--- |
58
- | `task_id` | `str` | Name of the selected task (e.g., `task0`). |
59
- | `feedback` | `str` | Combined compiler errors and testbench results. |
60
- | `pass_rate` | `float` | Percent of testcases passed [0.0 - 1.0]. |
61
- | `progress_ratio` | `float` | Percent of simulation sequence completed before the first failure. |
62
- | `compiled` | `bool` | Whether the Verilog code is syntactically valid. |
63
- | `lev_distance` | `int` | Number of modified lines compared to the previous attempt. |
64
- | `score` | `float` | Final normalized grader score [0.0 - 1.0]. |
 
 
 
 
 
 
 
 
 
65
 
66
  ---
67
 
 
5
  colorTo: green
6
  sdk: docker
7
  pinned: false
8
+ app_port: 7860
9
  base_path: /web
10
  tags:
11
  - openenv
 
16
 
17
  # RTL Debugger Environment
18
 
19
+ The **RTL Debugger** is a Reinforcement Learning environment designed for automated hardware design fixing. It enables LLM-based agents to iteratively debug Verilog code through high-fidelity simulation feedback.
20
+
21
+ ## 🚀 Motivation
22
+ Hardware debugging is a high-cost, iterative process. While LLMs are proficient at syntax-level code generation, fixing semantic bugs in RTL (Register Transfer Level) designs requires a deep understanding of timing, cycle-by-cycle logic, and state transitions. This environment provides a standardized sandbox for training and evaluating agents capable of interprets complex simulation logs and autonomously resolving hardware logic flaws.
23
+
24
+ ## 🛠️ Environment Description
25
+ The RTL Debugger is an OpenEnv-compliant environment that wraps industry-standard hardware tools:
26
+ - **Simulation Engines**: Supports both **Icarus Verilog** and **Verilator** for fast, cycle-accurate simulation.
27
+ - **Feedback Loop**: For every submitted design, the environment provides a detailed diagnostic report, including compilation errors, failed test cycles, and FSM transition mismatches.
28
+ - **Iterative Debugging**: Agents can build upon their previous attempts, utilizing line-based edit distance (Levenshtein) and pass-rate progress to guide their refinement.
29
 
30
  ## Quick Start
31
 
 
39
 
40
  ### 2. Launch the Environment Server
41
  ```bash
42
+ docker run -p 7860:7860 --rm rtl_debugger-env:latest
43
  ```
44
+ Access the interactive web-playground at: [http://localhost:7860/web](http://localhost:7860/web)
45
 
46
  ### 3. Run the Inference Agent
47
  We provide a reference inference script that uses LLM to play the environment:
 
57
 
58
  ## Environment Details
59
 
60
+ ### Action Space (`RtlDebuggerAction`)
61
+ The action space is **unstructured text** representing the revised hardware design:
62
+ - `fixed_code` (str): The full Verilog module source intended to replace the current `design_active.v`.
63
+
64
+ ### Observation Space: `RtlDebuggerObservation`
65
+ Agents receive a rich observation after every edit, containing both raw technical feedback and normalized metrics:
66
 
 
67
  | Field | Type | Description |
68
  | :--- | :--- | :--- |
69
+ | `task_id` | `str` | Name of the selected task (e.g., `task1`). |
70
+ | `feedback` | `str` | Human-readable diagnostics: compiler logs or a cycle-by-cycle breakdown of test failures. |
71
+ | `pass_rate` | `float` | Continuous metric [0.0 - 1.0] representing the percentage of test cases passed. |
72
+ | `progress_ratio` | `float` | Percent of the test sequence completed before the first failure (measures sequential depth). |
73
+ | `compiled` | `bool` | Boolean flag indicating if the Verilog code is syntactically valid and compilation succeeded. |
74
+ | `lev_distance` | `int` | Line-based edit distance from the *previous* attempt, encouraging minimal, targeted fixes. |
75
+ | `score` | `float` | The final grading metric [0.0 - 1.0]. High scores reward both correctness and minimal steps. |
76
+
77
+ ## 🎯 Tasks and Difficulty
78
+ The environment features curated hardware modules designed to test specific debugging capabilities:
79
+
80
+ | Task Tier | Name | Description | Grading Focus |
81
+ | :--- | :--- | :--- | :--- |
82
+ | **Easy** | Task 1 | Syntax & Compilation: Fixing basic wiring or keyword errors. | Compilation OK, Step Count |
83
+ | **Medium** | Task 2 | Combinational Logic: Fixing XOR maps, Decoders, or Binary-to-Gray logic. | Test Case Pass Rate |
84
+ | **Hard** | Task 3 | Sequential Logic: Debugging FSMs (e.g., Moore/Mealy sequence detectors). | Transition Accuracy, Reset Logic |
85
 
86
  ---
87
 
client.py CHANGED
@@ -30,7 +30,7 @@ class RtlDebuggerEnv(
30
 
31
  Example:
32
  >>> # Connect to a running server
33
- >>> with RtlDebuggerEnv(base_url="http://localhost:8000") as client:
34
  ... result = client.reset()
35
  ... print(result.observation.echoed_message)
36
  ...
 
30
 
31
  Example:
32
  >>> # Connect to a running server
33
+ >>> with RtlDebuggerEnv(base_url="http://localhost:7860") as client:
34
  ... result = client.reset()
35
  ... print(result.observation.echoed_message)
36
  ...
inference.py CHANGED
@@ -36,30 +36,30 @@ except ImportError:
36
  from models import RtlDebuggerAction # type: ignore
37
 
38
  # --- Configuration -------------------------------------------------------------
39
- OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
40
- GEMINI_API_KEY = os.getenv("GEMINI_API_KEY")
41
- HF_TOKEN = os.getenv("HF_TOKEN")
42
-
43
- if OPENAI_API_KEY:
44
- # Use OpenAI directly
45
- API_BASE_URL = os.getenv("API_BASE_URL") # use default (None) for OpenAI
46
- API_KEY = OPENAI_API_KEY
47
- MODEL_NAME = "gpt-4o"
48
- elif GEMINI_API_KEY:
49
- # Set defaults for Gemini (which uses an OpenAI-compatible endpoint)
50
- API_BASE_URL = "https://generativelanguage.googleapis.com/v1beta/openai/"
51
- API_KEY = GEMINI_API_KEY
52
- MODEL_NAME = "gemini-2.5-flash"
53
- else:
54
- # Fall back to Hugging Face router
55
- API_BASE_URL = "https://router.huggingface.co/v1"
56
- API_KEY = HF_TOKEN or os.getenv("API_KEY")
57
- MODEL_NAME = os.getenv("MODEL_NAME") or "Qwen/Qwen2.5-72B-Instruct:novita"
58
-
59
-
60
- # API_BASE_URL = os.getenv("API_BASE_URL") or "https://router.huggingface.co/v1"
61
- # API_KEY = os.getenv("API_KEY") or os.getenv("HF_TOKEN")
62
- # MODEL_NAME = os.getenv("MODEL_NAME") or "Qwen/Qwen2.5-72B-Instruct:novita"
63
 
64
  TASK_NAME = os.getenv("RTL_DEBUGGER_TASK_NAME", "unknown-task")
65
  IMAGE_NAME = os.getenv("LOCAL_IMAGE_NAME")
@@ -70,7 +70,7 @@ MAX_TOKENS = 8192
70
 
71
  SUCCESS_SCORE_THRESHOLD = 0.1
72
 
73
- ENV_BASE_URL = os.getenv("ENV_BASE_URL ", "http://localhost:8000")
74
 
75
 
76
  # --- Prompts -------------------------------------------------------------------
 
36
  from models import RtlDebuggerAction # type: ignore
37
 
38
  # --- Configuration -------------------------------------------------------------
39
+ # OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
40
+ # GEMINI_API_KEY = os.getenv("GEMINI_API_KEY")
41
+ # HF_TOKEN = os.getenv("HF_TOKEN")
42
+
43
+ # if OPENAI_API_KEY:
44
+ # # Use OpenAI directly
45
+ # API_BASE_URL = os.getenv("API_BASE_URL") # use default (None) for OpenAI
46
+ # API_KEY = OPENAI_API_KEY
47
+ # MODEL_NAME = "gpt-4o"
48
+ # elif GEMINI_API_KEY:
49
+ # # Set defaults for Gemini (which uses an OpenAI-compatible endpoint)
50
+ # API_BASE_URL = "https://generativelanguage.googleapis.com/v1beta/openai/"
51
+ # API_KEY = GEMINI_API_KEY
52
+ # MODEL_NAME = "gemini-2.5-flash"
53
+ # else:
54
+ # # Fall back to Hugging Face router
55
+ # API_BASE_URL = "https://router.huggingface.co/v1"
56
+ # API_KEY = HF_TOKEN or os.getenv("API_KEY")
57
+ # MODEL_NAME = os.getenv("MODEL_NAME") or "Qwen/Qwen2.5-72B-Instruct:novita"
58
+
59
+
60
+ API_BASE_URL = os.getenv("API_BASE_URL") or "https://router.huggingface.co/v1"
61
+ API_KEY = os.getenv("API_KEY") or os.getenv("HF_TOKEN")
62
+ MODEL_NAME = os.getenv("MODEL_NAME") or "Qwen/Qwen2.5-72B-Instruct:novita"
63
 
64
  TASK_NAME = os.getenv("RTL_DEBUGGER_TASK_NAME", "unknown-task")
65
  IMAGE_NAME = os.getenv("LOCAL_IMAGE_NAME")
 
70
 
71
  SUCCESS_SCORE_THRESHOLD = 0.1
72
 
73
+ ENV_BASE_URL = os.getenv("ENV_BASE_URL", "http://localhost:7860")
74
 
75
 
76
  # --- Prompts -------------------------------------------------------------------
openenv.yaml CHANGED
@@ -3,23 +3,23 @@ name: RTL Code Debugging Environment
3
  type: space
4
  runtime: fastapi
5
  app: server.app:app
6
- port: 8000
7
  tasks:
8
  - id: task1
9
  description: "Easy — syntax/compilation errors"
10
  difficulty: easy
11
  max_steps: 10
12
- grader: server.graders:RtlGrader
13
  - id: task2
14
  description: "Medium — logic errors in combinational circuit"
15
  difficulty: medium
16
  max_steps: 10
17
- grader: server.graders:RtlGrader
18
  - id: task3
19
  description: "Hard — logic errors in sequential circuit"
20
  difficulty: hard
21
  max_steps: 10
22
- grader: server.graders:RtlGrader
23
 
24
  constraints:
25
  max_runtime_seconds: 1200
 
3
  type: space
4
  runtime: fastapi
5
  app: server.app:app
6
+ port: 7860
7
  tasks:
8
  - id: task1
9
  description: "Easy — syntax/compilation errors"
10
  difficulty: easy
11
  max_steps: 10
12
+ grader: server.graders:Task1Grader
13
  - id: task2
14
  description: "Medium — logic errors in combinational circuit"
15
  difficulty: medium
16
  max_steps: 10
17
+ grader: server.graders:Task2Grader
18
  - id: task3
19
  description: "Hard — logic errors in sequential circuit"
20
  difficulty: hard
21
  max_steps: 10
22
+ grader: server.graders:Task3Grader
23
 
24
  constraints:
25
  max_runtime_seconds: 1200
requirements.txt ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ cocotb>=2.0.1
2
+ fastapi>=0.135.2
3
+ openai>=2.30.0
4
+ openenv-core[core]>=0.2.3
5
+ pydantic>=2.12.5
6
+ uvicorn>=0.42.0
7
+ python-dotenv
8
+
9
+ # System dependencies (installed in Docker but listed here for context):
10
+ # iverilog
11
+ # make
12
+ # verilator (v5.036)
server/app.py CHANGED
@@ -19,10 +19,10 @@ Endpoints:
19
 
20
  Usage:
21
  # Development (with auto-reload):
22
- uvicorn server.app:app --reload --host 0.0.0.0 --port 8000
23
 
24
  # Production:
25
- uvicorn server.app:app --host 0.0.0.0 --port 8000 --workers 4
26
 
27
  # Or run directly:
28
  python -m server.app
@@ -69,11 +69,11 @@ app = create_app(
69
  RtlDebuggerAction,
70
  RtlDebuggerObservation,
71
  env_name="rtl_debugger",
72
- max_concurrent_envs=1, # increase this number to allow more concurrent WebSocket sessions
73
  )
74
 
75
 
76
- def main(host: str = "0.0.0.0", port: int = 8000):
77
  """
78
  Entry point for direct execution via uv run or python -m.
79
 
@@ -84,7 +84,7 @@ def main(host: str = "0.0.0.0", port: int = 8000):
84
 
85
  Args:
86
  host: Host address to bind to (default: "0.0.0.0")
87
- port: Port number to listen on (default: 8000)
88
 
89
  For production deployments, consider using uvicorn directly with
90
  multiple workers:
 
19
 
20
  Usage:
21
  # Development (with auto-reload):
22
+ uvicorn server.app:app --reload --host 0.0.0.0 --port 7860
23
 
24
  # Production:
25
+ uvicorn server.app:app --host 0.0.0.0 --port 7860 --workers 4
26
 
27
  # Or run directly:
28
  python -m server.app
 
69
  RtlDebuggerAction,
70
  RtlDebuggerObservation,
71
  env_name="rtl_debugger",
72
+ max_concurrent_envs=10, # increase this number to allow more concurrent WebSocket sessions
73
  )
74
 
75
 
76
+ def main(host: str = "0.0.0.0", port: int = 7860):
77
  """
78
  Entry point for direct execution via uv run or python -m.
79
 
 
84
 
85
  Args:
86
  host: Host address to bind to (default: "0.0.0.0")
87
+ port: Port number to listen on (default: 7860)
88
 
89
  For production deployments, consider using uvicorn directly with
90
  multiple workers:
server/graders.py CHANGED
@@ -2,20 +2,46 @@ import json
2
  import os
3
  from openenv.core.env_server.types import State
4
 
5
- class RtlGrader:
6
  """
7
- External Grader for the RTL Debugger Environment.
8
- Evaluates the final state of the environment after the episode finishes.
 
 
9
  """
10
-
 
 
11
  def __call__(self, state: State, env: "RtlDebuggerEnvironment") -> float:
12
- """
13
- OpenEnv interface for grading.
14
- Reads the final result.json from the active task directory and computes the score.
15
- """
16
  result_path = os.path.join(env._task_dir, "result.json")
 
 
 
 
 
 
 
 
 
 
 
17
 
18
- # If no result.json exists, the simulation crashed or failed to compile
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  if not os.path.exists(result_path):
20
  return 0.01
21
 
@@ -25,20 +51,78 @@ class RtlGrader:
25
  except json.JSONDecodeError:
26
  return 0.01
27
 
28
- num_tests = result_json.get("num_tests", 1)
29
  num_passed = result_json.get("num_passed", 0)
 
30
  passed_all = result_json.get("passed", False)
31
-
32
- pass_rate = num_passed / num_tests if num_tests > 0 else 0.0
33
- max_steps = 8
34
- step_efficiency = (state.step_count / max_steps)
35
 
36
  if passed_all:
37
- # Solved — difficulty determined by how many steps it needed
38
- score = 1.0 - step_efficiency
39
  else:
40
- # Not solved — difficulty = how far it got from a full solution
41
- score = (pass_rate * 0.7)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
 
43
- # Clamp to (0, 1) range strictly
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  return max(0.01, min(0.99, score))
 
 
 
 
 
 
 
 
 
 
 
 
2
  import os
3
  from openenv.core.env_server.types import State
4
 
5
+ class Task1Grader:
6
  """
7
+ Grader for Task 1 (Syntax/Compilation Errors).
8
+ Evaluates based on:
9
+ - Linting and Compilation passed.
10
+ - Number of steps needed.
11
  """
12
+ def __init__(self, max_steps: int = 10):
13
+ self.max_steps = max_steps
14
+
15
  def __call__(self, state: State, env: "RtlDebuggerEnvironment") -> float:
 
 
 
 
16
  result_path = os.path.join(env._task_dir, "result.json")
17
+ if not os.path.exists(result_path):
18
+ return 0.01
19
+
20
+ try:
21
+ with open(result_path, "r") as f:
22
+ result_json = json.load(f)
23
+ except json.JSONDecodeError:
24
+ return 0.01
25
+
26
+ step_efficiency = (state.step_count / self.max_steps)
27
+ score = 1.0 - step_efficiency
28
 
29
+
30
+ return max(0.01, min(0.99, score))
31
+
32
+
33
+ class Task2Grader:
34
+ """
35
+ Grader for Task 2 (Combinational Logic).
36
+ Evaluates based on:
37
+ - Number of test cases passed.
38
+ - Number of steps needed.
39
+ """
40
+ def __init__(self, max_steps: int = 10):
41
+ self.max_steps = max_steps
42
+
43
+ def __call__(self, state: State, env: "RtlDebuggerEnvironment") -> float:
44
+ result_path = os.path.join(env._task_dir, "result.json")
45
  if not os.path.exists(result_path):
46
  return 0.01
47
 
 
51
  except json.JSONDecodeError:
52
  return 0.01
53
 
 
54
  num_passed = result_json.get("num_passed", 0)
55
+ num_tests = result_json.get("num_tests", 1)
56
  passed_all = result_json.get("passed", False)
57
+ pass_rate = num_passed / num_tests if num_tests > 0 else 0.0
 
 
 
58
 
59
  if passed_all:
60
+ step_efficiency = (state.step_count / self.max_steps)
61
+ score = 1.0 - step_efficiency
62
  else:
63
+ score = pass_rate * 0.7
64
+
65
+ return max(0.01, min(0.99, score))
66
+
67
+
68
+ class Task3Grader:
69
+ """
70
+ Grader for Task 3 (Sequential Logic).
71
+ Evaluates based on:
72
+ - Sequence correctness
73
+ - Transition correctness
74
+ - Penalties for deadlock, oscillation, wrong encoding
75
+ - Reset working
76
+ """
77
+ def __init__(self, max_steps: int = 10):
78
+ self.max_steps = max_steps
79
+
80
+ def __call__(self, state: State, env: "RtlDebuggerEnvironment") -> float:
81
+ result_path = os.path.join(env._task_dir, "result.json")
82
+ if not os.path.exists(result_path):
83
+ # No result.json usually means compilation error or simulation timeout (deadlock/oscillation)
84
+ return 0.01
85
+
86
+ try:
87
+ with open(result_path, "r") as f:
88
+ result_json = json.load(f)
89
+ except json.JSONDecodeError:
90
+ return 0.01
91
 
92
+ seq_count = result_json.get("sequence_correctness", 0)
93
+ trans_count = result_json.get("transition_correctness", 0)
94
+
95
+ num_passed = result_json.get("num_passed", 0)
96
+ num_tests = result_json.get("num_tests", 1)
97
+
98
+ seq_rate = seq_count / num_tests if num_tests > 0 else 0.0
99
+ trans_rate = trans_count / num_tests if num_tests > 0 else 0.0
100
+ pass_rate = num_passed / num_tests if num_tests > 0 else 0.0
101
+
102
+ passed_all = result_json.get("passed", False)
103
+
104
+ score = 0.0
105
+ # Partial credit based on sequential milestones
106
+ score += seq_rate * 0.4
107
+ score += trans_rate * 0.4
108
+ # Note: reset_working was removed from testbench or ignored for now,
109
+ # but we could add it back if needed. For now let's use the remaining 0.2
110
+ # as a bonus for passing everything.
111
+
112
+ if passed_all:
113
+ score += 0.2
114
+ step_efficiency = (state.step_count / self.max_steps)
115
+ score = 1.0 - step_efficiency
116
+
117
  return max(0.01, min(0.99, score))
118
+
119
+
120
+ def get_grader(task_id: str):
121
+ """Factory function to retrieve the appropriate grader for a task."""
122
+ graders = {
123
+ "task1": Task1Grader(),
124
+ "task2": Task2Grader(),
125
+ "task3": Task3Grader(),
126
+ }
127
+ return graders.get(task_id, Task1Grader())
128
+
server/rtl_debugger_environment.py CHANGED
@@ -35,8 +35,7 @@ try:
35
  except ImportError:
36
  from models import RtlDebuggerAction, RtlDebuggerObservation
37
 
38
- from .graders import RtlGrader
39
- _rtl_grader_instance = RtlGrader()
40
 
41
  # Tasks directory is usually at the project root.
42
  # We first try the current working directory (e.g. /app/env in Docker),
@@ -307,8 +306,11 @@ class RtlDebuggerEnvironment(Environment):
307
  if passed_all:
308
  reward += 20.0
309
 
 
 
 
310
  feedback_lines = [
311
- f"Compiled: OK | Tests: {num_passed}/{num_tests} passed | First failure after: {progress_ratio:.2f} of sequence | Levenshtein distance: {lev_distance}"
312
  ]
313
 
314
  # Parse failed test cases from result.json
@@ -320,11 +322,11 @@ class RtlDebuggerEnvironment(Environment):
320
  inp = ft.get("inputs") or ft.get("input", {})
321
  inputs_str = ", ".join(f"{k}={v}" for k, v in inp.items()) if isinstance(inp, dict) else str(inp)
322
  cycle = ft.get("test_id", "?")
323
- expected = ft.get("expected_output", ft.get("expected_next_state", ft.get("expected", "?")))
324
- actual = ft.get("actual_output", ft.get("actual", "?"))
325
 
326
  state_info = ""
327
- if "actual_state" in ft or "transition_to" in ft:
328
  was_s = ft.get("actual_state_meaning", ft.get("actual_state", "?"))
329
  went_s = ft.get("transition_to_meaning", ft.get("transition_to", "?"))
330
  exp_s = ft.get("expected_next_state_meaning", ft.get("expected_next_state", "?"))
@@ -333,7 +335,8 @@ class RtlDebuggerEnvironment(Environment):
333
  feedback_lines.append(f"- Cycle {cycle}: [{inputs_str}] -> Expected: {expected}, Got: {actual}{state_info}")
334
 
335
  feedback = "\n".join(filter(None, feedback_lines))
336
- final_score = _rtl_grader_instance(self._state, self)
 
337
 
338
  return RtlDebuggerObservation(
339
  task_id=self._task_name,
 
35
  except ImportError:
36
  from models import RtlDebuggerAction, RtlDebuggerObservation
37
 
38
+ from .graders import get_grader
 
39
 
40
  # Tasks directory is usually at the project root.
41
  # We first try the current working directory (e.g. /app/env in Docker),
 
306
  if passed_all:
307
  reward += 20.0
308
 
309
+ seq_count = result_data.get("sequence_correctness", "?")
310
+ trans_count = result_data.get("transition_correctness", "?")
311
+
312
  feedback_lines = [
313
+ f"Compiled: OK | Tests: {num_passed}/{num_tests} passed | Seq: {seq_count}/{num_tests} | Trans: {trans_count}/{num_tests} | First failure after: {progress_ratio:.2f} of sequence"
314
  ]
315
 
316
  # Parse failed test cases from result.json
 
322
  inp = ft.get("inputs") or ft.get("input", {})
323
  inputs_str = ", ".join(f"{k}={v}" for k, v in inp.items()) if isinstance(inp, dict) else str(inp)
324
  cycle = ft.get("test_id", "?")
325
+ expected = ft.get("expected_output", "?")
326
+ actual = ft.get("actual_output", "?")
327
 
328
  state_info = ""
329
+ if "transition_to" in ft:
330
  was_s = ft.get("actual_state_meaning", ft.get("actual_state", "?"))
331
  went_s = ft.get("transition_to_meaning", ft.get("transition_to", "?"))
332
  exp_s = ft.get("expected_next_state_meaning", ft.get("expected_next_state", "?"))
 
335
  feedback_lines.append(f"- Cycle {cycle}: [{inputs_str}] -> Expected: {expected}, Got: {actual}{state_info}")
336
 
337
  feedback = "\n".join(filter(None, feedback_lines))
338
+ grader = get_grader(self._task_name)
339
+ final_score = grader(self._state, self)
340
 
341
  return RtlDebuggerObservation(
342
  task_id=self._task_name,
tasks/task1/design_active.v CHANGED
@@ -1,9 +1,7 @@
1
  module half_adder(
2
- input a,
3
- input b,
4
- output sum,
5
- output carry
6
  );
7
  assign sum = a ^ b;
8
- assign carry = a & b;
9
  endmodule
 
1
  module half_adder(
2
+ input a, b,
3
+ output sum, carry
 
 
4
  );
5
  assign sum = a ^ b;
6
+ assign carry = a & b;
7
  endmodule
tasks/task1/results.xml CHANGED
@@ -1,6 +1,6 @@
1
  <testsuites name="results">
2
  <testsuite name="all" package="all">
3
- <property name="random_seed" value="1775630252" />
4
- <testcase name="test_half_adder" classname="test_half_adder" file="/mnt/c/Users/npkas/Agentic-RL/rtl_debugger/tasks/task0/test_half_adder.py" lineno="1" time="0.01133418083190918" sim_time_ns="4.0" ratio_time="352.91478575485394" />
5
  </testsuite>
6
  </testsuites>
 
1
  <testsuites name="results">
2
  <testsuite name="all" package="all">
3
+ <property name="random_seed" value="1775636841" />
4
+ <testcase name="test_half_adder" classname="test_half_adder" file="/mnt/c/Users/npkas/Agentic-RL/rtl_debugger/tasks/task0/test_half_adder.py" lineno="1" time="0.0024442672729492188" sim_time_ns="4.0" ratio_time="1636.4822473663676" />
5
  </testsuite>
6
  </testsuites>
tasks/task1/sim_build/Vtop ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:790e2bb6d9bf1dac2b0fdd8304ef96f7bc47313da65fc484139a5335e6105db7
3
+ size 320920
tasks/task1/sim_build/Vtop.cpp ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Verilated -*- C++ -*-
2
+ // DESCRIPTION: Verilator output: Model implementation (design independent parts)
3
+
4
+ #include "Vtop__pch.h"
5
+
6
+ //============================================================
7
+ // Constructors
8
+
9
+ Vtop::Vtop(VerilatedContext* _vcontextp__, const char* _vcname__)
10
+ : VerilatedModel{*_vcontextp__}
11
+ , vlSymsp{new Vtop__Syms(contextp(), _vcname__, this)}
12
+ , a{vlSymsp->TOP.a}
13
+ , b{vlSymsp->TOP.b}
14
+ , sum{vlSymsp->TOP.sum}
15
+ , carry{vlSymsp->TOP.carry}
16
+ , rootp{&(vlSymsp->TOP)}
17
+ {
18
+ // Register model with the context
19
+ contextp()->addModel(this);
20
+ }
21
+
22
+ Vtop::Vtop(const char* _vcname__)
23
+ : Vtop(Verilated::threadContextp(), _vcname__)
24
+ {
25
+ }
26
+
27
+ //============================================================
28
+ // Destructor
29
+
30
+ Vtop::~Vtop() {
31
+ delete vlSymsp;
32
+ }
33
+
34
+ //============================================================
35
+ // Evaluation function
36
+
37
+ #ifdef VL_DEBUG
38
+ void Vtop___024root___eval_debug_assertions(Vtop___024root* vlSelf);
39
+ #endif // VL_DEBUG
40
+ void Vtop___024root___eval_static(Vtop___024root* vlSelf);
41
+ void Vtop___024root___eval_initial(Vtop___024root* vlSelf);
42
+ void Vtop___024root___eval_settle(Vtop___024root* vlSelf);
43
+ void Vtop___024root___eval(Vtop___024root* vlSelf);
44
+
45
+ void Vtop::eval_step() {
46
+ VL_DEBUG_IF(VL_DBG_MSGF("+++++TOP Evaluate Vtop::eval_step\n"); );
47
+ #ifdef VL_DEBUG
48
+ // Debug assertions
49
+ Vtop___024root___eval_debug_assertions(&(vlSymsp->TOP));
50
+ #endif // VL_DEBUG
51
+ vlSymsp->__Vm_deleter.deleteAll();
52
+ if (VL_UNLIKELY(!vlSymsp->__Vm_didInit)) {
53
+ vlSymsp->__Vm_didInit = true;
54
+ VL_DEBUG_IF(VL_DBG_MSGF("+ Initial\n"););
55
+ Vtop___024root___eval_static(&(vlSymsp->TOP));
56
+ Vtop___024root___eval_initial(&(vlSymsp->TOP));
57
+ Vtop___024root___eval_settle(&(vlSymsp->TOP));
58
+ }
59
+ VL_DEBUG_IF(VL_DBG_MSGF("+ Eval\n"););
60
+ Vtop___024root___eval(&(vlSymsp->TOP));
61
+ // Evaluate cleanup
62
+ Verilated::endOfEval(vlSymsp->__Vm_evalMsgQp);
63
+ }
64
+
65
+ //============================================================
66
+ // Events and timing
67
+ bool Vtop::eventsPending() { return false; }
68
+
69
+ uint64_t Vtop::nextTimeSlot() {
70
+ VL_FATAL_MT(__FILE__, __LINE__, "", "No delays in the design");
71
+ return 0;
72
+ }
73
+
74
+ //============================================================
75
+ // Utilities
76
+
77
+ const char* Vtop::name() const {
78
+ return vlSymsp->name();
79
+ }
80
+
81
+ //============================================================
82
+ // Invoke final blocks
83
+
84
+ void Vtop___024root___eval_final(Vtop___024root* vlSelf);
85
+
86
+ VL_ATTR_COLD void Vtop::final() {
87
+ Vtop___024root___eval_final(&(vlSymsp->TOP));
88
+ }
89
+
90
+ //============================================================
91
+ // Implementations of abstract methods from VerilatedModel
92
+
93
+ const char* Vtop::hierName() const { return vlSymsp->name(); }
94
+ const char* Vtop::modelName() const { return "Vtop"; }
95
+ unsigned Vtop::threads() const { return 1; }
96
+ void Vtop::prepareClone() const { contextp()->prepareClone(); }
97
+ void Vtop::atClone() const {
98
+ contextp()->threadPoolpOnClone();
99
+ }
tasks/task1/sim_build/Vtop.h ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Verilated -*- C++ -*-
2
+ // DESCRIPTION: Verilator output: Primary model header
3
+ //
4
+ // This header should be included by all source files instantiating the design.
5
+ // The class here is then constructed to instantiate the design.
6
+ // See the Verilator manual for examples.
7
+
8
+ #ifndef VERILATED_VTOP_H_
9
+ #define VERILATED_VTOP_H_ // guard
10
+
11
+ #include "verilated.h"
12
+ #include "svdpi.h"
13
+
14
+ class Vtop__Syms;
15
+ class Vtop___024root;
16
+
17
+ // This class is the main interface to the Verilated model
18
+ class alignas(VL_CACHE_LINE_BYTES) Vtop VL_NOT_FINAL : public VerilatedModel {
19
+ private:
20
+ // Symbol table holding complete model state (owned by this class)
21
+ Vtop__Syms* const vlSymsp;
22
+
23
+ public:
24
+
25
+ // CONSTEXPR CAPABILITIES
26
+ // Verilated with --trace?
27
+ static constexpr bool traceCapable = false;
28
+
29
+ // PORTS
30
+ // The application code writes and reads these signals to
31
+ // propagate new values into/out from the Verilated model.
32
+ VL_IN8(&a,0,0);
33
+ VL_IN8(&b,0,0);
34
+ VL_OUT8(&sum,0,0);
35
+ VL_OUT8(&carry,0,0);
36
+
37
+ // CELLS
38
+ // Public to allow access to /* verilator public */ items.
39
+ // Otherwise the application code can consider these internals.
40
+
41
+ // Root instance pointer to allow access to model internals,
42
+ // including inlined /* verilator public_flat_* */ items.
43
+ Vtop___024root* const rootp;
44
+
45
+ // CONSTRUCTORS
46
+ /// Construct the model; called by application code
47
+ /// If contextp is null, then the model will use the default global context
48
+ /// If name is "", then makes a wrapper with a
49
+ /// single model invisible with respect to DPI scope names.
50
+ explicit Vtop(VerilatedContext* contextp, const char* name = "TOP");
51
+ explicit Vtop(const char* name = "TOP");
52
+ /// Destroy the model; called (often implicitly) by application code
53
+ virtual ~Vtop();
54
+ private:
55
+ VL_UNCOPYABLE(Vtop); ///< Copying not allowed
56
+
57
+ public:
58
+ // API METHODS
59
+ /// Evaluate the model. Application must call when inputs change.
60
+ void eval() { eval_step(); }
61
+ /// Evaluate when calling multiple units/models per time step.
62
+ void eval_step();
63
+ /// Evaluate at end of a timestep for tracing, when using eval_step().
64
+ /// Application must call after all eval() and before time changes.
65
+ void eval_end_step() {}
66
+ /// Simulation complete, run final blocks. Application must call on completion.
67
+ void final();
68
+ /// Are there scheduled events to handle?
69
+ bool eventsPending();
70
+ /// Returns time at next time slot. Aborts if !eventsPending()
71
+ uint64_t nextTimeSlot();
72
+ /// Trace signals in the model; called by application code
73
+ void trace(VerilatedTraceBaseC* tfp, int levels, int options = 0) { contextp()->trace(tfp, levels, options); }
74
+ /// Retrieve name of this model instance (as passed to constructor).
75
+ const char* name() const;
76
+
77
+ // Abstract methods from VerilatedModel
78
+ const char* hierName() const override final;
79
+ const char* modelName() const override final;
80
+ unsigned threads() const override final;
81
+ /// Prepare for cloning the model at the process level (e.g. fork in Linux)
82
+ /// Release necessary resources. Called before cloning.
83
+ void prepareClone() const;
84
+ /// Re-init after cloning the model at the process level (e.g. fork in Linux)
85
+ /// Re-allocate necessary resources. Called after cloning.
86
+ void atClone() const;
87
+ private:
88
+ // Internal functions - trace registration
89
+ void traceBaseModel(VerilatedTraceBaseC* tfp, int levels, int options);
90
+ };
91
+
92
+ #endif // guard
tasks/task1/sim_build/Vtop.mk ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Verilated -*- Makefile -*-
2
+ # DESCRIPTION: Verilator output: Makefile for building Verilated archive or executable
3
+ #
4
+ # Execute this makefile from the object directory:
5
+ # make -f Vtop.mk
6
+
7
+ default: Vtop
8
+
9
+ ### Constants...
10
+ # Perl executable (from $PERL, defaults to 'perl' if not set)
11
+ PERL = perl
12
+ # Python3 executable (from $PYTHON3, defaults to 'python3' if not set)
13
+ PYTHON3 = python3
14
+ # Path to Verilator kit (from $VERILATOR_ROOT)
15
+ VERILATOR_ROOT = /usr/local/share/verilator
16
+ # SystemC include directory with systemc.h (from $SYSTEMC_INCLUDE)
17
+ SYSTEMC_INCLUDE ?=
18
+ # SystemC library directory with libsystemc.a (from $SYSTEMC_LIBDIR)
19
+ SYSTEMC_LIBDIR ?=
20
+
21
+ ### Switches...
22
+ # C++ code coverage 0/1 (from --prof-c)
23
+ VM_PROFC = 0
24
+ # SystemC output mode? 0/1 (from --sc)
25
+ VM_SC = 0
26
+ # Legacy or SystemC output mode? 0/1 (from --sc)
27
+ VM_SP_OR_SC = $(VM_SC)
28
+ # Deprecated
29
+ VM_PCLI = 1
30
+ # Deprecated: SystemC architecture to find link library path (from $SYSTEMC_ARCH)
31
+ VM_SC_TARGET_ARCH = linux
32
+
33
+ ### Vars...
34
+ # Design prefix (from --prefix)
35
+ VM_PREFIX = Vtop
36
+ # Module prefix (from --prefix)
37
+ VM_MODPREFIX = Vtop
38
+ # User CFLAGS (from -CFLAGS on Verilator command line)
39
+ VM_USER_CFLAGS = \
40
+
41
+ # User LDLIBS (from -LDFLAGS on Verilator command line)
42
+ VM_USER_LDLIBS = \
43
+ -Wl,-rpath,/mnt/c/Users/npkas/Agentic-RL/open_venv/lib/python3.12/site-packages/cocotb/libs -L/mnt/c/Users/npkas/Agentic-RL/open_venv/lib/python3.12/site-packages/cocotb/libs -lcocotbvpi_verilator \
44
+
45
+ # User .cpp files (from .cpp's on Verilator command line)
46
+ VM_USER_CLASSES = \
47
+ verilator \
48
+
49
+ # User .cpp directories (from .cpp's on Verilator command line)
50
+ VM_USER_DIR = \
51
+ .. \
52
+ ../../../../open_venv/lib/python3.12/site-packages/cocotb/share/lib/verilator \
53
+
54
+
55
+ ### Default rules...
56
+ # Include list of all generated classes
57
+ include Vtop_classes.mk
58
+ # Include global rules
59
+ include $(VERILATOR_ROOT)/include/verilated.mk
60
+
61
+ ### Executable rules... (from --exe)
62
+ VPATH += $(VM_USER_DIR)
63
+
64
+ verilator.o: /mnt/c/Users/npkas/Agentic-RL/open_venv/lib/python3.12/site-packages/cocotb/share/lib/verilator/verilator.cpp
65
+ $(OBJCACHE) $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(OPT_FAST) -c -o $@ $<
66
+
67
+ ### Link rules... (from --exe)
68
+ Vtop: $(VK_USER_OBJS) $(VK_GLOBAL_OBJS) $(VM_PREFIX)__ALL.a $(VM_HIER_LIBS)
69
+ $(LINK) $(LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) $(LIBS) $(SC_LIBS) -o $@
70
+
71
+
72
+ # Verilated -*- Makefile -*-
tasks/task1/sim_build/Vtop__ALL.a ADDED
Binary file (20 kB). View file
 
tasks/task1/sim_build/Vtop__ALL.cpp ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ // DESCRIPTION: Generated by verilator_includer via makefile
2
+ #define VL_INCLUDE_OPT include
3
+ #include "Vtop.cpp"
4
+ #include "Vtop___024root__DepSet_h84412442__0.cpp"
5
+ #include "Vtop___024root__DepSet_heccd7ead__0.cpp"
6
+ #include "Vtop__Dpi.cpp"
7
+ #include "Vtop___024root__Slow.cpp"
8
+ #include "Vtop___024root__DepSet_h84412442__0__Slow.cpp"
9
+ #include "Vtop___024root__DepSet_heccd7ead__0__Slow.cpp"
10
+ #include "Vtop__Syms.cpp"
tasks/task1/sim_build/Vtop__ALL.d ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Vtop__ALL.o: Vtop__ALL.cpp Vtop.cpp Vtop__pch.h \
2
+ /usr/local/share/verilator/include/verilated.h \
3
+ /usr/local/share/verilator/include/verilatedos.h \
4
+ /usr/local/share/verilator/include/verilated_config.h \
5
+ /usr/local/share/verilator/include/verilated_types.h \
6
+ /usr/local/share/verilator/include/verilated_funcs.h \
7
+ /usr/local/share/verilator/include/verilated_dpi.h \
8
+ /usr/local/share/verilator/include/verilated.h \
9
+ /usr/local/share/verilator/include/verilated_sym_props.h \
10
+ /usr/local/share/verilator/include/vltstd/svdpi.h Vtop__Syms.h Vtop.h \
11
+ Vtop___024root.h Vtop___024root__DepSet_h84412442__0.cpp \
12
+ Vtop___024root__DepSet_heccd7ead__0.cpp Vtop__Dpi.cpp Vtop__Dpi.h \
13
+ Vtop___024root__Slow.cpp Vtop___024root__DepSet_h84412442__0__Slow.cpp \
14
+ Vtop___024root__DepSet_heccd7ead__0__Slow.cpp Vtop__Syms.cpp
tasks/task1/sim_build/Vtop__ALL.o ADDED
Binary file (17.7 kB). View file
 
tasks/task1/sim_build/Vtop__Dpi.cpp ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Verilated -*- C++ -*-
2
+ // DESCRIPTION: Verilator output: Implementation of DPI export functions.
3
+ //
4
+ // Verilator compiles this file in when DPI functions are used.
5
+ // If you have multiple Verilated designs with the same DPI exported
6
+ // function names, you will get multiple definition link errors from here.
7
+ // This is an unfortunate result of the DPI specification.
8
+ // To solve this, either
9
+ // 1. Call Vtop::{export_function} instead,
10
+ // and do not even bother to compile this file
11
+ // or 2. Compile all __Dpi.cpp files in the same compiler run,
12
+ // and #ifdefs already inserted here will sort everything out.
13
+
14
+ #include "Vtop__Dpi.h"
15
+ #include "Vtop.h"
16
+
tasks/task1/sim_build/Vtop__Dpi.h ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Verilated -*- C++ -*-
2
+ // DESCRIPTION: Verilator output: Prototypes for DPI import and export functions.
3
+ //
4
+ // Verilator includes this file in all generated .cpp files that use DPI functions.
5
+ // Manually include this file where DPI .c import functions are declared to ensure
6
+ // the C functions match the expectations of the DPI imports.
7
+
8
+ #ifndef VERILATED_VTOP__DPI_H_
9
+ #define VERILATED_VTOP__DPI_H_ // guard
10
+
11
+ #include "svdpi.h"
12
+
13
+ #ifdef __cplusplus
14
+ extern "C" {
15
+ #endif
16
+
17
+
18
+ #ifdef __cplusplus
19
+ }
20
+ #endif
21
+
22
+ #endif // guard
tasks/task1/sim_build/Vtop__Syms.cpp ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Verilated -*- C++ -*-
2
+ // DESCRIPTION: Verilator output: Symbol table implementation internals
3
+
4
+ #include "Vtop__pch.h"
5
+ #include "Vtop.h"
6
+ #include "Vtop___024root.h"
7
+
8
+ // FUNCTIONS
9
+ Vtop__Syms::~Vtop__Syms()
10
+ {
11
+
12
+ // Tear down scope hierarchy
13
+ __Vhier.remove(0, &__Vscope_half_adder);
14
+
15
+ }
16
+
17
+ Vtop__Syms::Vtop__Syms(VerilatedContext* contextp, const char* namep, Vtop* modelp)
18
+ : VerilatedSyms{contextp}
19
+ // Setup internal state of the Syms class
20
+ , __Vm_modelp{modelp}
21
+ // Setup module instances
22
+ , TOP{this, namep}
23
+ {
24
+ // Check resources
25
+ Verilated::stackCheck(25);
26
+ // Configure time unit / time precision
27
+ _vm_contextp__->timeunit(-9);
28
+ _vm_contextp__->timeprecision(-12);
29
+ // Setup each module's pointers to their submodules
30
+ // Setup each module's pointer back to symbol table (for public functions)
31
+ TOP.__Vconfigure(true);
32
+ // Setup scopes
33
+ __Vscope_TOP.configure(this, name(), "TOP", "TOP", "<null>", 0, VerilatedScope::SCOPE_OTHER);
34
+ __Vscope_half_adder.configure(this, name(), "half_adder", "half_adder", "half_adder", -9, VerilatedScope::SCOPE_MODULE);
35
+
36
+ // Set up scope hierarchy
37
+ __Vhier.add(0, &__Vscope_half_adder);
38
+
39
+ // Setup export functions
40
+ for (int __Vfinal = 0; __Vfinal < 2; ++__Vfinal) {
41
+ __Vscope_TOP.varInsert(__Vfinal,"a", &(TOP.a), false, VLVT_UINT8,VLVD_IN|VLVF_PUB_RW,0,0);
42
+ __Vscope_TOP.varInsert(__Vfinal,"b", &(TOP.b), false, VLVT_UINT8,VLVD_IN|VLVF_PUB_RW,0,0);
43
+ __Vscope_TOP.varInsert(__Vfinal,"carry", &(TOP.carry), false, VLVT_UINT8,VLVD_OUT|VLVF_PUB_RW,0,0);
44
+ __Vscope_TOP.varInsert(__Vfinal,"sum", &(TOP.sum), false, VLVT_UINT8,VLVD_OUT|VLVF_PUB_RW,0,0);
45
+ __Vscope_half_adder.varInsert(__Vfinal,"a", &(TOP.half_adder__DOT__a), false, VLVT_UINT8,VLVD_NODIR|VLVF_PUB_RW,0,0);
46
+ __Vscope_half_adder.varInsert(__Vfinal,"b", &(TOP.half_adder__DOT__b), false, VLVT_UINT8,VLVD_NODIR|VLVF_PUB_RW,0,0);
47
+ __Vscope_half_adder.varInsert(__Vfinal,"carry", &(TOP.half_adder__DOT__carry), false, VLVT_UINT8,VLVD_NODIR|VLVF_PUB_RW,0,0);
48
+ __Vscope_half_adder.varInsert(__Vfinal,"sum", &(TOP.half_adder__DOT__sum), false, VLVT_UINT8,VLVD_NODIR|VLVF_PUB_RW,0,0);
49
+ }
50
+ }
tasks/task1/sim_build/Vtop__Syms.h ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Verilated -*- C++ -*-
2
+ // DESCRIPTION: Verilator output: Symbol table internal header
3
+ //
4
+ // Internal details; most calling programs do not need this header,
5
+ // unless using verilator public meta comments.
6
+
7
+ #ifndef VERILATED_VTOP__SYMS_H_
8
+ #define VERILATED_VTOP__SYMS_H_ // guard
9
+
10
+ #include "verilated.h"
11
+
12
+ // INCLUDE MODEL CLASS
13
+
14
+ #include "Vtop.h"
15
+
16
+ // INCLUDE MODULE CLASSES
17
+ #include "Vtop___024root.h"
18
+
19
+ // DPI TYPES for DPI Export callbacks (Internal use)
20
+
21
+ // SYMS CLASS (contains all model state)
22
+ class alignas(VL_CACHE_LINE_BYTES)Vtop__Syms final : public VerilatedSyms {
23
+ public:
24
+ // INTERNAL STATE
25
+ Vtop* const __Vm_modelp;
26
+ VlDeleter __Vm_deleter;
27
+ bool __Vm_didInit = false;
28
+
29
+ // MODULE INSTANCE STATE
30
+ Vtop___024root TOP;
31
+
32
+ // SCOPE NAMES
33
+ VerilatedScope __Vscope_TOP;
34
+ VerilatedScope __Vscope_half_adder;
35
+
36
+ // SCOPE HIERARCHY
37
+ VerilatedHierarchy __Vhier;
38
+
39
+ // CONSTRUCTORS
40
+ Vtop__Syms(VerilatedContext* contextp, const char* namep, Vtop* modelp);
41
+ ~Vtop__Syms();
42
+
43
+ // METHODS
44
+ const char* name() { return TOP.name(); }
45
+ };
46
+
47
+ #endif // guard
tasks/task1/sim_build/Vtop___024root.h ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Verilated -*- C++ -*-
2
+ // DESCRIPTION: Verilator output: Design internal header
3
+ // See Vtop.h for the primary calling header
4
+
5
+ #ifndef VERILATED_VTOP___024ROOT_H_
6
+ #define VERILATED_VTOP___024ROOT_H_ // guard
7
+
8
+ #include "verilated.h"
9
+
10
+
11
+ class Vtop__Syms;
12
+
13
+ class alignas(VL_CACHE_LINE_BYTES) Vtop___024root final : public VerilatedModule {
14
+ public:
15
+
16
+ // DESIGN SPECIFIC STATE
17
+ VL_IN8(a,0,0);
18
+ VL_IN8(b,0,0);
19
+ VL_OUT8(sum,0,0);
20
+ VL_OUT8(carry,0,0);
21
+ CData/*0:0*/ half_adder__DOT__a;
22
+ CData/*0:0*/ half_adder__DOT__b;
23
+ CData/*0:0*/ half_adder__DOT__sum;
24
+ CData/*0:0*/ half_adder__DOT__carry;
25
+ CData/*0:0*/ __VstlFirstIteration;
26
+ CData/*0:0*/ __VicoFirstIteration;
27
+ CData/*0:0*/ __VactContinue;
28
+ IData/*31:0*/ __VactIterCount;
29
+ VlTriggerVec<1> __VstlTriggered;
30
+ VlTriggerVec<1> __VicoTriggered;
31
+ VlTriggerVec<0> __VactTriggered;
32
+ VlTriggerVec<0> __VnbaTriggered;
33
+
34
+ // INTERNAL VARIABLES
35
+ Vtop__Syms* const vlSymsp;
36
+
37
+ // CONSTRUCTORS
38
+ Vtop___024root(Vtop__Syms* symsp, const char* v__name);
39
+ ~Vtop___024root();
40
+ VL_UNCOPYABLE(Vtop___024root);
41
+
42
+ // INTERNAL METHODS
43
+ void __Vconfigure(bool first);
44
+ };
45
+
46
+
47
+ #endif // guard
tasks/task1/sim_build/Vtop___024root__DepSet_h84412442__0.cpp ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Verilated -*- C++ -*-
2
+ // DESCRIPTION: Verilator output: Design implementation internals
3
+ // See Vtop.h for the primary calling header
4
+
5
+ #include "Vtop__pch.h"
6
+ #include "Vtop__Syms.h"
7
+ #include "Vtop___024root.h"
8
+
9
+ #ifdef VL_DEBUG
10
+ VL_ATTR_COLD void Vtop___024root___dump_triggers__ico(Vtop___024root* vlSelf);
11
+ #endif // VL_DEBUG
12
+
13
+ void Vtop___024root___eval_triggers__ico(Vtop___024root* vlSelf) {
14
+ VL_DEBUG_IF(VL_DBG_MSGF("+ Vtop___024root___eval_triggers__ico\n"); );
15
+ Vtop__Syms* const __restrict vlSymsp VL_ATTR_UNUSED = vlSelf->vlSymsp;
16
+ auto& vlSelfRef = std::ref(*vlSelf).get();
17
+ // Body
18
+ vlSelfRef.__VicoTriggered.setBit(0U, (IData)(vlSelfRef.__VicoFirstIteration));
19
+ #ifdef VL_DEBUG
20
+ if (VL_UNLIKELY(vlSymsp->_vm_contextp__->debug())) {
21
+ Vtop___024root___dump_triggers__ico(vlSelf);
22
+ }
23
+ #endif
24
+ }
25
+
26
+ #ifdef VL_DEBUG
27
+ VL_ATTR_COLD void Vtop___024root___dump_triggers__act(Vtop___024root* vlSelf);
28
+ #endif // VL_DEBUG
29
+
30
+ void Vtop___024root___eval_triggers__act(Vtop___024root* vlSelf) {
31
+ VL_DEBUG_IF(VL_DBG_MSGF("+ Vtop___024root___eval_triggers__act\n"); );
32
+ Vtop__Syms* const __restrict vlSymsp VL_ATTR_UNUSED = vlSelf->vlSymsp;
33
+ auto& vlSelfRef = std::ref(*vlSelf).get();
34
+ // Body
35
+ #ifdef VL_DEBUG
36
+ if (VL_UNLIKELY(vlSymsp->_vm_contextp__->debug())) {
37
+ Vtop___024root___dump_triggers__act(vlSelf);
38
+ }
39
+ #endif
40
+ }
tasks/task1/sim_build/Vtop___024root__DepSet_h84412442__0__Slow.cpp ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Verilated -*- C++ -*-
2
+ // DESCRIPTION: Verilator output: Design implementation internals
3
+ // See Vtop.h for the primary calling header
4
+
5
+ #include "Vtop__pch.h"
6
+ #include "Vtop__Syms.h"
7
+ #include "Vtop___024root.h"
8
+
9
+ #ifdef VL_DEBUG
10
+ VL_ATTR_COLD void Vtop___024root___dump_triggers__stl(Vtop___024root* vlSelf);
11
+ #endif // VL_DEBUG
12
+
13
+ VL_ATTR_COLD void Vtop___024root___eval_triggers__stl(Vtop___024root* vlSelf) {
14
+ VL_DEBUG_IF(VL_DBG_MSGF("+ Vtop___024root___eval_triggers__stl\n"); );
15
+ Vtop__Syms* const __restrict vlSymsp VL_ATTR_UNUSED = vlSelf->vlSymsp;
16
+ auto& vlSelfRef = std::ref(*vlSelf).get();
17
+ // Body
18
+ vlSelfRef.__VstlTriggered.setBit(0U, (IData)(vlSelfRef.__VstlFirstIteration));
19
+ #ifdef VL_DEBUG
20
+ if (VL_UNLIKELY(vlSymsp->_vm_contextp__->debug())) {
21
+ Vtop___024root___dump_triggers__stl(vlSelf);
22
+ }
23
+ #endif
24
+ }
tasks/task1/sim_build/Vtop___024root__DepSet_heccd7ead__0.cpp ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Verilated -*- C++ -*-
2
+ // DESCRIPTION: Verilator output: Design implementation internals
3
+ // See Vtop.h for the primary calling header
4
+
5
+ #include "Vtop__pch.h"
6
+ #include "Vtop___024root.h"
7
+
8
+ void Vtop___024root___ico_sequent__TOP__0(Vtop___024root* vlSelf);
9
+
10
+ void Vtop___024root___eval_ico(Vtop___024root* vlSelf) {
11
+ VL_DEBUG_IF(VL_DBG_MSGF("+ Vtop___024root___eval_ico\n"); );
12
+ Vtop__Syms* const __restrict vlSymsp VL_ATTR_UNUSED = vlSelf->vlSymsp;
13
+ auto& vlSelfRef = std::ref(*vlSelf).get();
14
+ // Body
15
+ if ((1ULL & vlSelfRef.__VicoTriggered.word(0U))) {
16
+ Vtop___024root___ico_sequent__TOP__0(vlSelf);
17
+ }
18
+ }
19
+
20
+ VL_INLINE_OPT void Vtop___024root___ico_sequent__TOP__0(Vtop___024root* vlSelf) {
21
+ VL_DEBUG_IF(VL_DBG_MSGF("+ Vtop___024root___ico_sequent__TOP__0\n"); );
22
+ Vtop__Syms* const __restrict vlSymsp VL_ATTR_UNUSED = vlSelf->vlSymsp;
23
+ auto& vlSelfRef = std::ref(*vlSelf).get();
24
+ // Body
25
+ vlSelfRef.half_adder__DOT__a = vlSelfRef.a;
26
+ vlSelfRef.half_adder__DOT__b = vlSelfRef.b;
27
+ vlSelfRef.carry = ((IData)(vlSelfRef.a) & (IData)(vlSelfRef.b));
28
+ vlSelfRef.half_adder__DOT__sum = ((IData)(vlSelfRef.a)
29
+ ^ (IData)(vlSelfRef.b));
30
+ vlSelfRef.half_adder__DOT__carry = vlSelfRef.carry;
31
+ vlSelfRef.sum = vlSelfRef.half_adder__DOT__sum;
32
+ }
33
+
34
+ void Vtop___024root___eval_triggers__ico(Vtop___024root* vlSelf);
35
+
36
+ bool Vtop___024root___eval_phase__ico(Vtop___024root* vlSelf) {
37
+ VL_DEBUG_IF(VL_DBG_MSGF("+ Vtop___024root___eval_phase__ico\n"); );
38
+ Vtop__Syms* const __restrict vlSymsp VL_ATTR_UNUSED = vlSelf->vlSymsp;
39
+ auto& vlSelfRef = std::ref(*vlSelf).get();
40
+ // Init
41
+ CData/*0:0*/ __VicoExecute;
42
+ // Body
43
+ Vtop___024root___eval_triggers__ico(vlSelf);
44
+ __VicoExecute = vlSelfRef.__VicoTriggered.any();
45
+ if (__VicoExecute) {
46
+ Vtop___024root___eval_ico(vlSelf);
47
+ }
48
+ return (__VicoExecute);
49
+ }
50
+
51
+ void Vtop___024root___eval_act(Vtop___024root* vlSelf) {
52
+ VL_DEBUG_IF(VL_DBG_MSGF("+ Vtop___024root___eval_act\n"); );
53
+ Vtop__Syms* const __restrict vlSymsp VL_ATTR_UNUSED = vlSelf->vlSymsp;
54
+ auto& vlSelfRef = std::ref(*vlSelf).get();
55
+ }
56
+
57
+ void Vtop___024root___eval_nba(Vtop___024root* vlSelf) {
58
+ VL_DEBUG_IF(VL_DBG_MSGF("+ Vtop___024root___eval_nba\n"); );
59
+ Vtop__Syms* const __restrict vlSymsp VL_ATTR_UNUSED = vlSelf->vlSymsp;
60
+ auto& vlSelfRef = std::ref(*vlSelf).get();
61
+ }
62
+
63
+ void Vtop___024root___eval_triggers__act(Vtop___024root* vlSelf);
64
+
65
+ bool Vtop___024root___eval_phase__act(Vtop___024root* vlSelf) {
66
+ VL_DEBUG_IF(VL_DBG_MSGF("+ Vtop___024root___eval_phase__act\n"); );
67
+ Vtop__Syms* const __restrict vlSymsp VL_ATTR_UNUSED = vlSelf->vlSymsp;
68
+ auto& vlSelfRef = std::ref(*vlSelf).get();
69
+ // Init
70
+ VlTriggerVec<0> __VpreTriggered;
71
+ CData/*0:0*/ __VactExecute;
72
+ // Body
73
+ Vtop___024root___eval_triggers__act(vlSelf);
74
+ __VactExecute = vlSelfRef.__VactTriggered.any();
75
+ if (__VactExecute) {
76
+ __VpreTriggered.andNot(vlSelfRef.__VactTriggered, vlSelfRef.__VnbaTriggered);
77
+ vlSelfRef.__VnbaTriggered.thisOr(vlSelfRef.__VactTriggered);
78
+ Vtop___024root___eval_act(vlSelf);
79
+ }
80
+ return (__VactExecute);
81
+ }
82
+
83
+ bool Vtop___024root___eval_phase__nba(Vtop___024root* vlSelf) {
84
+ VL_DEBUG_IF(VL_DBG_MSGF("+ Vtop___024root___eval_phase__nba\n"); );
85
+ Vtop__Syms* const __restrict vlSymsp VL_ATTR_UNUSED = vlSelf->vlSymsp;
86
+ auto& vlSelfRef = std::ref(*vlSelf).get();
87
+ // Init
88
+ CData/*0:0*/ __VnbaExecute;
89
+ // Body
90
+ __VnbaExecute = vlSelfRef.__VnbaTriggered.any();
91
+ if (__VnbaExecute) {
92
+ Vtop___024root___eval_nba(vlSelf);
93
+ vlSelfRef.__VnbaTriggered.clear();
94
+ }
95
+ return (__VnbaExecute);
96
+ }
97
+
98
+ #ifdef VL_DEBUG
99
+ VL_ATTR_COLD void Vtop___024root___dump_triggers__ico(Vtop___024root* vlSelf);
100
+ #endif // VL_DEBUG
101
+ #ifdef VL_DEBUG
102
+ VL_ATTR_COLD void Vtop___024root___dump_triggers__nba(Vtop___024root* vlSelf);
103
+ #endif // VL_DEBUG
104
+ #ifdef VL_DEBUG
105
+ VL_ATTR_COLD void Vtop___024root___dump_triggers__act(Vtop___024root* vlSelf);
106
+ #endif // VL_DEBUG
107
+
108
+ void Vtop___024root___eval(Vtop___024root* vlSelf) {
109
+ VL_DEBUG_IF(VL_DBG_MSGF("+ Vtop___024root___eval\n"); );
110
+ Vtop__Syms* const __restrict vlSymsp VL_ATTR_UNUSED = vlSelf->vlSymsp;
111
+ auto& vlSelfRef = std::ref(*vlSelf).get();
112
+ // Init
113
+ IData/*31:0*/ __VicoIterCount;
114
+ CData/*0:0*/ __VicoContinue;
115
+ IData/*31:0*/ __VnbaIterCount;
116
+ CData/*0:0*/ __VnbaContinue;
117
+ // Body
118
+ __VicoIterCount = 0U;
119
+ vlSelfRef.__VicoFirstIteration = 1U;
120
+ __VicoContinue = 1U;
121
+ while (__VicoContinue) {
122
+ if (VL_UNLIKELY(((0x64U < __VicoIterCount)))) {
123
+ #ifdef VL_DEBUG
124
+ Vtop___024root___dump_triggers__ico(vlSelf);
125
+ #endif
126
+ VL_FATAL_MT("design_active.v", 1, "", "Input combinational region did not converge.");
127
+ }
128
+ __VicoIterCount = ((IData)(1U) + __VicoIterCount);
129
+ __VicoContinue = 0U;
130
+ if (Vtop___024root___eval_phase__ico(vlSelf)) {
131
+ __VicoContinue = 1U;
132
+ }
133
+ vlSelfRef.__VicoFirstIteration = 0U;
134
+ }
135
+ __VnbaIterCount = 0U;
136
+ __VnbaContinue = 1U;
137
+ while (__VnbaContinue) {
138
+ if (VL_UNLIKELY(((0x64U < __VnbaIterCount)))) {
139
+ #ifdef VL_DEBUG
140
+ Vtop___024root___dump_triggers__nba(vlSelf);
141
+ #endif
142
+ VL_FATAL_MT("design_active.v", 1, "", "NBA region did not converge.");
143
+ }
144
+ __VnbaIterCount = ((IData)(1U) + __VnbaIterCount);
145
+ __VnbaContinue = 0U;
146
+ vlSelfRef.__VactIterCount = 0U;
147
+ vlSelfRef.__VactContinue = 1U;
148
+ while (vlSelfRef.__VactContinue) {
149
+ if (VL_UNLIKELY(((0x64U < vlSelfRef.__VactIterCount)))) {
150
+ #ifdef VL_DEBUG
151
+ Vtop___024root___dump_triggers__act(vlSelf);
152
+ #endif
153
+ VL_FATAL_MT("design_active.v", 1, "", "Active region did not converge.");
154
+ }
155
+ vlSelfRef.__VactIterCount = ((IData)(1U)
156
+ + vlSelfRef.__VactIterCount);
157
+ vlSelfRef.__VactContinue = 0U;
158
+ if (Vtop___024root___eval_phase__act(vlSelf)) {
159
+ vlSelfRef.__VactContinue = 1U;
160
+ }
161
+ }
162
+ if (Vtop___024root___eval_phase__nba(vlSelf)) {
163
+ __VnbaContinue = 1U;
164
+ }
165
+ }
166
+ }
167
+
168
+ #ifdef VL_DEBUG
169
+ void Vtop___024root___eval_debug_assertions(Vtop___024root* vlSelf) {
170
+ VL_DEBUG_IF(VL_DBG_MSGF("+ Vtop___024root___eval_debug_assertions\n"); );
171
+ Vtop__Syms* const __restrict vlSymsp VL_ATTR_UNUSED = vlSelf->vlSymsp;
172
+ auto& vlSelfRef = std::ref(*vlSelf).get();
173
+ // Body
174
+ if (VL_UNLIKELY(((vlSelfRef.a & 0xfeU)))) {
175
+ Verilated::overWidthError("a");}
176
+ if (VL_UNLIKELY(((vlSelfRef.b & 0xfeU)))) {
177
+ Verilated::overWidthError("b");}
178
+ }
179
+ #endif // VL_DEBUG
tasks/task1/sim_build/Vtop___024root__DepSet_heccd7ead__0__Slow.cpp ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Verilated -*- C++ -*-
2
+ // DESCRIPTION: Verilator output: Design implementation internals
3
+ // See Vtop.h for the primary calling header
4
+
5
+ #include "Vtop__pch.h"
6
+ #include "Vtop___024root.h"
7
+
8
+ VL_ATTR_COLD void Vtop___024root___eval_static(Vtop___024root* vlSelf) {
9
+ VL_DEBUG_IF(VL_DBG_MSGF("+ Vtop___024root___eval_static\n"); );
10
+ Vtop__Syms* const __restrict vlSymsp VL_ATTR_UNUSED = vlSelf->vlSymsp;
11
+ auto& vlSelfRef = std::ref(*vlSelf).get();
12
+ }
13
+
14
+ VL_ATTR_COLD void Vtop___024root___eval_initial(Vtop___024root* vlSelf) {
15
+ VL_DEBUG_IF(VL_DBG_MSGF("+ Vtop___024root___eval_initial\n"); );
16
+ Vtop__Syms* const __restrict vlSymsp VL_ATTR_UNUSED = vlSelf->vlSymsp;
17
+ auto& vlSelfRef = std::ref(*vlSelf).get();
18
+ }
19
+
20
+ VL_ATTR_COLD void Vtop___024root___eval_final(Vtop___024root* vlSelf) {
21
+ VL_DEBUG_IF(VL_DBG_MSGF("+ Vtop___024root___eval_final\n"); );
22
+ Vtop__Syms* const __restrict vlSymsp VL_ATTR_UNUSED = vlSelf->vlSymsp;
23
+ auto& vlSelfRef = std::ref(*vlSelf).get();
24
+ }
25
+
26
+ #ifdef VL_DEBUG
27
+ VL_ATTR_COLD void Vtop___024root___dump_triggers__stl(Vtop___024root* vlSelf);
28
+ #endif // VL_DEBUG
29
+ VL_ATTR_COLD bool Vtop___024root___eval_phase__stl(Vtop___024root* vlSelf);
30
+
31
+ VL_ATTR_COLD void Vtop___024root___eval_settle(Vtop___024root* vlSelf) {
32
+ VL_DEBUG_IF(VL_DBG_MSGF("+ Vtop___024root___eval_settle\n"); );
33
+ Vtop__Syms* const __restrict vlSymsp VL_ATTR_UNUSED = vlSelf->vlSymsp;
34
+ auto& vlSelfRef = std::ref(*vlSelf).get();
35
+ // Init
36
+ IData/*31:0*/ __VstlIterCount;
37
+ CData/*0:0*/ __VstlContinue;
38
+ // Body
39
+ __VstlIterCount = 0U;
40
+ vlSelfRef.__VstlFirstIteration = 1U;
41
+ __VstlContinue = 1U;
42
+ while (__VstlContinue) {
43
+ if (VL_UNLIKELY(((0x64U < __VstlIterCount)))) {
44
+ #ifdef VL_DEBUG
45
+ Vtop___024root___dump_triggers__stl(vlSelf);
46
+ #endif
47
+ VL_FATAL_MT("design_active.v", 1, "", "Settle region did not converge.");
48
+ }
49
+ __VstlIterCount = ((IData)(1U) + __VstlIterCount);
50
+ __VstlContinue = 0U;
51
+ if (Vtop___024root___eval_phase__stl(vlSelf)) {
52
+ __VstlContinue = 1U;
53
+ }
54
+ vlSelfRef.__VstlFirstIteration = 0U;
55
+ }
56
+ }
57
+
58
+ #ifdef VL_DEBUG
59
+ VL_ATTR_COLD void Vtop___024root___dump_triggers__stl(Vtop___024root* vlSelf) {
60
+ VL_DEBUG_IF(VL_DBG_MSGF("+ Vtop___024root___dump_triggers__stl\n"); );
61
+ Vtop__Syms* const __restrict vlSymsp VL_ATTR_UNUSED = vlSelf->vlSymsp;
62
+ auto& vlSelfRef = std::ref(*vlSelf).get();
63
+ // Body
64
+ if ((1U & (~ vlSelfRef.__VstlTriggered.any()))) {
65
+ VL_DBG_MSGF(" No triggers active\n");
66
+ }
67
+ if ((1ULL & vlSelfRef.__VstlTriggered.word(0U))) {
68
+ VL_DBG_MSGF(" 'stl' region trigger index 0 is active: Internal 'stl' trigger - first iteration\n");
69
+ }
70
+ }
71
+ #endif // VL_DEBUG
72
+
73
+ void Vtop___024root___ico_sequent__TOP__0(Vtop___024root* vlSelf);
74
+
75
+ VL_ATTR_COLD void Vtop___024root___eval_stl(Vtop___024root* vlSelf) {
76
+ VL_DEBUG_IF(VL_DBG_MSGF("+ Vtop___024root___eval_stl\n"); );
77
+ Vtop__Syms* const __restrict vlSymsp VL_ATTR_UNUSED = vlSelf->vlSymsp;
78
+ auto& vlSelfRef = std::ref(*vlSelf).get();
79
+ // Body
80
+ if ((1ULL & vlSelfRef.__VstlTriggered.word(0U))) {
81
+ Vtop___024root___ico_sequent__TOP__0(vlSelf);
82
+ }
83
+ }
84
+
85
+ VL_ATTR_COLD void Vtop___024root___eval_triggers__stl(Vtop___024root* vlSelf);
86
+
87
+ VL_ATTR_COLD bool Vtop___024root___eval_phase__stl(Vtop___024root* vlSelf) {
88
+ VL_DEBUG_IF(VL_DBG_MSGF("+ Vtop___024root___eval_phase__stl\n"); );
89
+ Vtop__Syms* const __restrict vlSymsp VL_ATTR_UNUSED = vlSelf->vlSymsp;
90
+ auto& vlSelfRef = std::ref(*vlSelf).get();
91
+ // Init
92
+ CData/*0:0*/ __VstlExecute;
93
+ // Body
94
+ Vtop___024root___eval_triggers__stl(vlSelf);
95
+ __VstlExecute = vlSelfRef.__VstlTriggered.any();
96
+ if (__VstlExecute) {
97
+ Vtop___024root___eval_stl(vlSelf);
98
+ }
99
+ return (__VstlExecute);
100
+ }
101
+
102
+ #ifdef VL_DEBUG
103
+ VL_ATTR_COLD void Vtop___024root___dump_triggers__ico(Vtop___024root* vlSelf) {
104
+ VL_DEBUG_IF(VL_DBG_MSGF("+ Vtop___024root___dump_triggers__ico\n"); );
105
+ Vtop__Syms* const __restrict vlSymsp VL_ATTR_UNUSED = vlSelf->vlSymsp;
106
+ auto& vlSelfRef = std::ref(*vlSelf).get();
107
+ // Body
108
+ if ((1U & (~ vlSelfRef.__VicoTriggered.any()))) {
109
+ VL_DBG_MSGF(" No triggers active\n");
110
+ }
111
+ if ((1ULL & vlSelfRef.__VicoTriggered.word(0U))) {
112
+ VL_DBG_MSGF(" 'ico' region trigger index 0 is active: Internal 'ico' trigger - first iteration\n");
113
+ }
114
+ }
115
+ #endif // VL_DEBUG
116
+
117
+ #ifdef VL_DEBUG
118
+ VL_ATTR_COLD void Vtop___024root___dump_triggers__act(Vtop___024root* vlSelf) {
119
+ VL_DEBUG_IF(VL_DBG_MSGF("+ Vtop___024root___dump_triggers__act\n"); );
120
+ Vtop__Syms* const __restrict vlSymsp VL_ATTR_UNUSED = vlSelf->vlSymsp;
121
+ auto& vlSelfRef = std::ref(*vlSelf).get();
122
+ // Body
123
+ if ((1U & (~ vlSelfRef.__VactTriggered.any()))) {
124
+ VL_DBG_MSGF(" No triggers active\n");
125
+ }
126
+ }
127
+ #endif // VL_DEBUG
128
+
129
+ #ifdef VL_DEBUG
130
+ VL_ATTR_COLD void Vtop___024root___dump_triggers__nba(Vtop___024root* vlSelf) {
131
+ VL_DEBUG_IF(VL_DBG_MSGF("+ Vtop___024root___dump_triggers__nba\n"); );
132
+ Vtop__Syms* const __restrict vlSymsp VL_ATTR_UNUSED = vlSelf->vlSymsp;
133
+ auto& vlSelfRef = std::ref(*vlSelf).get();
134
+ // Body
135
+ if ((1U & (~ vlSelfRef.__VnbaTriggered.any()))) {
136
+ VL_DBG_MSGF(" No triggers active\n");
137
+ }
138
+ }
139
+ #endif // VL_DEBUG
140
+
141
+ VL_ATTR_COLD void Vtop___024root___ctor_var_reset(Vtop___024root* vlSelf) {
142
+ VL_DEBUG_IF(VL_DBG_MSGF("+ Vtop___024root___ctor_var_reset\n"); );
143
+ Vtop__Syms* const __restrict vlSymsp VL_ATTR_UNUSED = vlSelf->vlSymsp;
144
+ auto& vlSelfRef = std::ref(*vlSelf).get();
145
+ // Body
146
+ vlSelf->a = VL_RAND_RESET_I(1);
147
+ vlSelf->b = VL_RAND_RESET_I(1);
148
+ vlSelf->sum = VL_RAND_RESET_I(1);
149
+ vlSelf->carry = VL_RAND_RESET_I(1);
150
+ vlSelf->half_adder__DOT__a = VL_RAND_RESET_I(1);
151
+ vlSelf->half_adder__DOT__b = VL_RAND_RESET_I(1);
152
+ vlSelf->half_adder__DOT__sum = VL_RAND_RESET_I(1);
153
+ vlSelf->half_adder__DOT__carry = VL_RAND_RESET_I(1);
154
+ }
tasks/task1/sim_build/Vtop___024root__Slow.cpp ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Verilated -*- C++ -*-
2
+ // DESCRIPTION: Verilator output: Design implementation internals
3
+ // See Vtop.h for the primary calling header
4
+
5
+ #include "Vtop__pch.h"
6
+ #include "Vtop__Syms.h"
7
+ #include "Vtop___024root.h"
8
+
9
+ void Vtop___024root___ctor_var_reset(Vtop___024root* vlSelf);
10
+
11
+ Vtop___024root::Vtop___024root(Vtop__Syms* symsp, const char* v__name)
12
+ : VerilatedModule{v__name}
13
+ , vlSymsp{symsp}
14
+ {
15
+ // Reset structure values
16
+ Vtop___024root___ctor_var_reset(this);
17
+ }
18
+
19
+ void Vtop___024root::__Vconfigure(bool first) {
20
+ (void)first; // Prevent unused variable warning
21
+ }
22
+
23
+ Vtop___024root::~Vtop___024root() {
24
+ }
tasks/task1/sim_build/Vtop__pch.h ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Verilated -*- C++ -*-
2
+ // DESCRIPTION: Verilator output: Precompiled header
3
+ //
4
+ // Internal details; most user sources do not need this header,
5
+ // unless using verilator public meta comments.
6
+ // Suggest use Vtop.h instead.
7
+
8
+
9
+ #ifndef VERILATED_VTOP__PCH_H_
10
+ #define VERILATED_VTOP__PCH_H_ // guard
11
+
12
+ // GCC and Clang only will precompile headers (PCH) for the first header.
13
+ // So, make sure this is the one and only PCH.
14
+ // If multiple module's includes are needed, use individual includes.
15
+ #ifdef VL_PCH_INCLUDED
16
+ # error "Including multiple precompiled header files"
17
+ #endif
18
+ #define VL_PCH_INCLUDED
19
+
20
+
21
+ #include "verilated.h"
22
+ #include "verilated_dpi.h"
23
+
24
+ #include "Vtop__Syms.h"
25
+ #include "Vtop.h"
26
+
27
+ // Additional include files added using '--compiler-include'
28
+
29
+ #endif // guard
tasks/task1/sim_build/Vtop__ver.d ADDED
@@ -0,0 +1 @@
 
 
1
+ sim_build/Vtop.cpp sim_build/Vtop.h sim_build/Vtop.mk sim_build/Vtop__Dpi.cpp sim_build/Vtop__Dpi.h sim_build/Vtop__Syms.cpp sim_build/Vtop__Syms.h sim_build/Vtop___024root.h sim_build/Vtop___024root__DepSet_h84412442__0.cpp sim_build/Vtop___024root__DepSet_h84412442__0__Slow.cpp sim_build/Vtop___024root__DepSet_heccd7ead__0.cpp sim_build/Vtop___024root__DepSet_heccd7ead__0__Slow.cpp sim_build/Vtop___024root__Slow.cpp sim_build/Vtop__pch.h sim_build/Vtop__ver.d sim_build/Vtop_classes.mk : /usr/local/bin/verilator_bin /usr/local/bin/verilator_bin /usr/local/share/verilator/include/verilated_std.sv /usr/local/share/verilator/include/verilated_std_waiver.vlt design_active.v
tasks/task1/sim_build/Vtop__verFiles.dat ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # DESCRIPTION: Verilator output: Timestamp data for --skip-identical. Delete at will.
2
+ C "-cc --exe -Mdir sim_build --top-module half_adder --timescale 1ns/1ps --vpi --public-flat-rw --prefix Vtop -o Vtop -LDFLAGS -Wl,-rpath,/mnt/c/Users/npkas/Agentic-RL/open_venv/lib/python3.12/site-packages/cocotb/libs -L/mnt/c/Users/npkas/Agentic-RL/open_venv/lib/python3.12/site-packages/cocotb/libs -lcocotbvpi_verilator design_active.v /mnt/c/Users/npkas/Agentic-RL/open_venv/lib/python3.12/site-packages/cocotb/share/lib/verilator/verilator.cpp"
3
+ S 15982304 152497 1775633558 952547019 1775633558 952547019 "/usr/local/bin/verilator_bin"
4
+ S 6525 152673 1775633559 122559598 1775633559 122559598 "/usr/local/share/verilator/include/verilated_std.sv"
5
+ S 2787 152655 1775633559 112558860 1775633559 112558860 "/usr/local/share/verilator/include/verilated_std_waiver.vlt"
6
+ S 281 7036874417799606 1775634224 763642000 1775634224 763642000 "design_active.v"
7
+ T 2984 3096224745706922 1775634226 861395500 1775634226 861395500 "sim_build/Vtop.cpp"
8
+ T 3505 5066549582681425 1775634226 857854000 1775634226 857854000 "sim_build/Vtop.h"
9
+ T 2326 2814749768996448 1775634226 886766700 1775634226 886766700 "sim_build/Vtop.mk"
10
+ T 669 4503599629259776 1775634226 855839700 1775634226 855839700 "sim_build/Vtop__Dpi.cpp"
11
+ T 520 18858823441462464 1775634226 853826700 1775634226 853826700 "sim_build/Vtop__Dpi.h"
12
+ T 2212 30117822508124560 1775634226 850045500 1775634226 850045500 "sim_build/Vtop__Syms.cpp"
13
+ T 1115 16325548650952681 1775634226 850556400 1775634226 850556400 "sim_build/Vtop__Syms.h"
14
+ T 1189 2533274792285651 1775634226 866813600 1775634226 866813600 "sim_build/Vtop___024root.h"
15
+ T 1369 3096224745707037 1775634226 875505300 1775634226 875505300 "sim_build/Vtop___024root__DepSet_h84412442__0.cpp"
16
+ T 845 2533274792285659 1775634226 871423000 1775634226 871423000 "sim_build/Vtop___024root__DepSet_h84412442__0__Slow.cpp"
17
+ T 6754 2814749768996437 1775634226 880370400 1775634226 880370400 "sim_build/Vtop___024root__DepSet_heccd7ead__0.cpp"
18
+ T 6003 2533274792285689 1775634226 873486000 1775634226 873486000 "sim_build/Vtop___024root__DepSet_heccd7ead__0__Slow.cpp"
19
+ T 620 2533274792285653 1775634226 868852200 1775634226 868852200 "sim_build/Vtop___024root__Slow.cpp"
20
+ T 773 2814749768996274 1775634226 863436900 1775634226 863436900 "sim_build/Vtop__pch.h"
21
+ T 682 3940649675839252 1775634226 890540100 1775634226 890540100 "sim_build/Vtop__ver.d"
22
+ T 0 0 1775634226 892089400 1775634226 892089400 "sim_build/Vtop__verFiles.dat"
23
+ T 1770 2814749768996438 1775634226 881448700 1775634226 881448700 "sim_build/Vtop_classes.mk"
tasks/task1/sim_build/Vtop_classes.mk ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Verilated -*- Makefile -*-
2
+ # DESCRIPTION: Verilator output: Make include file with class lists
3
+ #
4
+ # This file lists generated Verilated files, for including in higher level makefiles.
5
+ # See Vtop.mk for the caller.
6
+
7
+ ### Switches...
8
+ # C11 constructs required? 0/1 (always on now)
9
+ VM_C11 = 1
10
+ # Timing enabled? 0/1
11
+ VM_TIMING = 0
12
+ # Coverage output mode? 0/1 (from --coverage)
13
+ VM_COVERAGE = 0
14
+ # Parallel builds? 0/1 (from --output-split)
15
+ VM_PARALLEL_BUILDS = 0
16
+ # Tracing output mode? 0/1 (from --trace-fst/--trace-saif/--trace-vcd)
17
+ VM_TRACE = 0
18
+ # Tracing output mode in FST format? 0/1 (from --trace-fst)
19
+ VM_TRACE_FST = 0
20
+ # Tracing output mode in SAIF format? 0/1 (from --trace-saif)
21
+ VM_TRACE_SAIF = 0
22
+ # Tracing output mode in VCD format? 0/1 (from --trace-vcd)
23
+ VM_TRACE_VCD = 0
24
+
25
+ ### Object file lists...
26
+ # Generated module classes, fast-path, compile with highest optimization
27
+ VM_CLASSES_FAST += \
28
+ Vtop \
29
+ Vtop___024root__DepSet_h84412442__0 \
30
+ Vtop___024root__DepSet_heccd7ead__0 \
31
+
32
+ # Generated module classes, non-fast-path, compile with low/medium optimization
33
+ VM_CLASSES_SLOW += \
34
+ Vtop___024root__Slow \
35
+ Vtop___024root__DepSet_h84412442__0__Slow \
36
+ Vtop___024root__DepSet_heccd7ead__0__Slow \
37
+
38
+ # Generated support classes, fast-path, compile with highest optimization
39
+ VM_SUPPORT_FAST += \
40
+ Vtop__Dpi \
41
+
42
+ # Generated support classes, non-fast-path, compile with low/medium optimization
43
+ VM_SUPPORT_SLOW += \
44
+ Vtop__Syms \
45
+
46
+ # Global classes, need linked once per executable, fast-path, compile with highest optimization
47
+ VM_GLOBAL_FAST += \
48
+ verilated \
49
+ verilated_dpi \
50
+ verilated_vpi \
51
+ verilated_threads \
52
+
53
+ # Global classes, need linked once per executable, non-fast-path, compile with low/medium optimization
54
+ VM_GLOBAL_SLOW += \
55
+
56
+
57
+ # Verilated -*- Makefile -*-
tasks/task1/sim_build/sim.vvp CHANGED
@@ -8,22 +8,22 @@
8
  :vpi_module "/usr/lib/x86_64-linux-gnu/ivl/v2005_math.vpi";
9
  :vpi_module "/usr/lib/x86_64-linux-gnu/ivl/va_math.vpi";
10
  :vpi_module "/usr/lib/x86_64-linux-gnu/ivl/v2009.vpi";
11
- S_0x55f0dc01f510 .scope package, "$unit" "$unit" 2 1;
12
  .timescale -9 -12;
13
- S_0x55f0dc01f6a0 .scope module, "half_adder" "half_adder" 3 1;
14
  .timescale -9 -12;
15
  .port_info 0 /INPUT 1 "a";
16
  .port_info 1 /INPUT 1 "b";
17
  .port_info 2 /OUTPUT 1 "sum";
18
  .port_info 3 /OUTPUT 1 "carry";
19
- o0x7fa1802ff018 .functor BUFZ 1, C4<z>; HiZ drive
20
- o0x7fa1802ff048 .functor BUFZ 1, C4<z>; HiZ drive
21
- L_0x55f0dc066d00 .functor XOR 1, o0x7fa1802ff018, o0x7fa1802ff048, C4<0>, C4<0>;
22
- L_0x55f0dc066df0 .functor AND 1, o0x7fa1802ff018, o0x7fa1802ff048, C4<1>, C4<1>;
23
- v0x55f0dc031430_0 .net "a", 0 0, o0x7fa1802ff018; 0 drivers
24
- v0x55f0dc066a00_0 .net "b", 0 0, o0x7fa1802ff048; 0 drivers
25
- v0x55f0dc066ac0_0 .net "carry", 0 0, L_0x55f0dc066df0; 1 drivers
26
- v0x55f0dc066b90_0 .net "sum", 0 0, L_0x55f0dc066d00; 1 drivers
27
  # The file index is used to find the file name in the following table.
28
  :file_names 4;
29
  "N/A";
 
8
  :vpi_module "/usr/lib/x86_64-linux-gnu/ivl/v2005_math.vpi";
9
  :vpi_module "/usr/lib/x86_64-linux-gnu/ivl/va_math.vpi";
10
  :vpi_module "/usr/lib/x86_64-linux-gnu/ivl/v2009.vpi";
11
+ S_0x56539094a510 .scope package, "$unit" "$unit" 2 1;
12
  .timescale -9 -12;
13
+ S_0x56539094a6a0 .scope module, "half_adder" "half_adder" 3 1;
14
  .timescale -9 -12;
15
  .port_info 0 /INPUT 1 "a";
16
  .port_info 1 /INPUT 1 "b";
17
  .port_info 2 /OUTPUT 1 "sum";
18
  .port_info 3 /OUTPUT 1 "carry";
19
+ o0x7fab61caa018 .functor BUFZ 1, C4<z>; HiZ drive
20
+ o0x7fab61caa048 .functor BUFZ 1, C4<z>; HiZ drive
21
+ L_0x565390991d00 .functor XOR 1, o0x7fab61caa018, o0x7fab61caa048, C4<0>, C4<0>;
22
+ L_0x565390991df0 .functor AND 1, o0x7fab61caa018, o0x7fab61caa048, C4<1>, C4<1>;
23
+ v0x56539095c430_0 .net "a", 0 0, o0x7fab61caa018; 0 drivers
24
+ v0x565390991a00_0 .net "b", 0 0, o0x7fab61caa048; 0 drivers
25
+ v0x565390991ac0_0 .net "carry", 0 0, L_0x565390991df0; 1 drivers
26
+ v0x565390991b90_0 .net "sum", 0 0, L_0x565390991d00; 1 drivers
27
  # The file index is used to find the file name in the following table.
28
  :file_names 4;
29
  "N/A";
tasks/task1/sim_build/verilated.d ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ verilated.o: /usr/local/share/verilator/include/verilated.cpp \
2
+ /usr/local/share/verilator/include/verilated_config.h \
3
+ /usr/local/share/verilator/include/verilatedos.h \
4
+ /usr/local/share/verilator/include/verilated_imp.h \
5
+ /usr/local/share/verilator/include/verilated.h \
6
+ /usr/local/share/verilator/include/verilated_types.h \
7
+ /usr/local/share/verilator/include/verilated_funcs.h \
8
+ /usr/local/share/verilator/include/verilated_syms.h \
9
+ /usr/local/share/verilator/include/verilated_sym_props.h \
10
+ /usr/local/share/verilator/include/verilated_threads.h \
11
+ /usr/local/share/verilator/include/verilated_trace.h \
12
+ /usr/local/share/verilator/include/verilatedos_c.h
tasks/task1/sim_build/verilated.o ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1d2edda4f644db03fd038b6221b9ce178237c0885957111ee515d6473fd895b7
3
+ size 233592
tasks/task1/sim_build/verilated_dpi.d ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ verilated_dpi.o: /usr/local/share/verilator/include/verilated_dpi.cpp \
2
+ /usr/local/share/verilator/include/verilatedos.h \
3
+ /usr/local/share/verilator/include/verilated_dpi.h \
4
+ /usr/local/share/verilator/include/verilated.h \
5
+ /usr/local/share/verilator/include/verilated_config.h \
6
+ /usr/local/share/verilator/include/verilated_types.h \
7
+ /usr/local/share/verilator/include/verilated_funcs.h \
8
+ /usr/local/share/verilator/include/verilated_sym_props.h \
9
+ /usr/local/share/verilator/include/vltstd/svdpi.h \
10
+ /usr/local/share/verilator/include/verilated_imp.h \
11
+ /usr/local/share/verilator/include/verilated_syms.h \
12
+ /usr/local/share/verilator/include/vltstd/svdpi.h
tasks/task1/sim_build/verilated_dpi.o ADDED
Binary file (30.9 kB). View file
 
tasks/task1/sim_build/verilated_threads.d ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ verilated_threads.o: \
2
+ /usr/local/share/verilator/include/verilated_threads.cpp \
3
+ /usr/local/share/verilator/include/verilatedos.h \
4
+ /usr/local/share/verilator/include/verilated_threads.h \
5
+ /usr/local/share/verilator/include/verilated.h \
6
+ /usr/local/share/verilator/include/verilated_config.h \
7
+ /usr/local/share/verilator/include/verilated_types.h \
8
+ /usr/local/share/verilator/include/verilated_funcs.h
tasks/task1/sim_build/verilated_threads.o ADDED
Binary file (61.3 kB). View file
 
tasks/task1/sim_build/verilated_vpi.d ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ verilated_vpi.o: /usr/local/share/verilator/include/verilated_vpi.cpp \
2
+ /usr/local/share/verilator/include/verilated_vpi.h \
3
+ /usr/local/share/verilator/include/verilatedos.h \
4
+ /usr/local/share/verilator/include/verilated.h \
5
+ /usr/local/share/verilator/include/verilated_config.h \
6
+ /usr/local/share/verilator/include/verilated_types.h \
7
+ /usr/local/share/verilator/include/verilated_funcs.h \
8
+ /usr/local/share/verilator/include/verilated_syms.h \
9
+ /usr/local/share/verilator/include/verilated_sym_props.h \
10
+ /usr/local/share/verilator/include/vltstd/sv_vpi_user.h \
11
+ /usr/local/share/verilator/include/vltstd/vpi_user.h \
12
+ /usr/local/share/verilator/include/verilated_imp.h \
13
+ /usr/local/share/verilator/include/vltstd/vpi_user.h
tasks/task1/sim_build/verilated_vpi.o ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:68715e90d84a5a87f2765d14b91e0cfb3231b20adf84d426d7e0d92aa0b03e0a
3
+ size 217616
tasks/task1/sim_build/verilator.d ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ verilator.o: \
2
+ /mnt/c/Users/npkas/Agentic-RL/open_venv/lib/python3.12/site-packages/cocotb/share/lib/verilator/verilator.cpp \
3
+ Vtop.h /usr/local/share/verilator/include/verilated.h \
4
+ /usr/local/share/verilator/include/verilatedos.h \
5
+ /usr/local/share/verilator/include/verilated_config.h \
6
+ /usr/local/share/verilator/include/verilated_types.h \
7
+ /usr/local/share/verilator/include/verilated_funcs.h \
8
+ /usr/local/share/verilator/include/vltstd/svdpi.h \
9
+ /usr/local/share/verilator/include/verilated_vpi.h \
10
+ /usr/local/share/verilator/include/verilated.h \
11
+ /usr/local/share/verilator/include/verilated_syms.h \
12
+ /usr/local/share/verilator/include/verilated_sym_props.h \
13
+ /usr/local/share/verilator/include/vltstd/sv_vpi_user.h \
14
+ /usr/local/share/verilator/include/vltstd/vpi_user.h
tasks/task1/sim_build/verilator.o ADDED
Binary file (10.7 kB). View file
 
tasks/task2/design_active.v CHANGED
@@ -1,19 +1,16 @@
1
- module bin_gry #(parameter N = 8)
2
- (
3
- input [N-1:0] binary,
4
- output reg [N-1:0] gray
5
- );
6
-
7
- always @ (*) // Use '*' for combinational logic sensitivity list
8
- begin
9
- // The most significant bit (MSB) of the Gray code is the same as the MSB of the binary code.
10
- gray[N-1] = binary[N-1];
11
-
12
- // For all other bits, the i-th Gray code bit is the XOR of the i-th binary bit and the (i+1)-th binary bit.
13
- // gray[i] = binary[i+1] ^ binary[i]
14
- for (integer i = 0; i < N - 1; i = i + 1) begin
15
- gray[i] = binary[i+1] ^ binary[i];
16
- end
17
- end
18
-
19
  endmodule
 
1
+ module bin_gry #(parameter N = 8)
2
+ (
3
+ binary ,
4
+ gray
5
+ ) ;
6
+
7
+ input [N-1:0] binary ;
8
+ output reg [N-1:0] gray ;
9
+
10
+ always @ (binary)
11
+ begin
12
+ gray[N-1] = binary[N-1] ;
13
+ gray[N-2:0] = binary[N-1:1] & binary[N-2:0] ;
14
+ end
15
+
 
 
 
16
  endmodule
tasks/task2/result.json CHANGED
@@ -1,7 +1,7 @@
1
  {
2
- "passed": true,
3
  "num_tests": 12,
4
- "num_passed": 12,
5
  "simulation_time": 12.0,
6
  "results": [
7
  {
@@ -19,8 +19,8 @@
19
  "binary": 1
20
  },
21
  "expected_output": 1,
22
- "actual_output": 1,
23
- "pass": true
24
  },
25
  {
26
  "test_id": 2,
@@ -28,8 +28,8 @@
28
  "binary": 2
29
  },
30
  "expected_output": 3,
31
- "actual_output": 3,
32
- "pass": true
33
  },
34
  {
35
  "test_id": 3,
@@ -37,8 +37,8 @@
37
  "binary": 3
38
  },
39
  "expected_output": 2,
40
- "actual_output": 2,
41
- "pass": true
42
  },
43
  {
44
  "test_id": 4,
@@ -46,8 +46,8 @@
46
  "binary": 127
47
  },
48
  "expected_output": 64,
49
- "actual_output": 64,
50
- "pass": true
51
  },
52
  {
53
  "test_id": 5,
@@ -55,8 +55,8 @@
55
  "binary": 255
56
  },
57
  "expected_output": 128,
58
- "actual_output": 128,
59
- "pass": true
60
  },
61
  {
62
  "test_id": 6,
@@ -64,8 +64,8 @@
64
  "binary": 254
65
  },
66
  "expected_output": 129,
67
- "actual_output": 129,
68
- "pass": true
69
  },
70
  {
71
  "test_id": 7,
@@ -73,8 +73,8 @@
73
  "binary": 5
74
  },
75
  "expected_output": 7,
76
- "actual_output": 7,
77
- "pass": true
78
  },
79
  {
80
  "test_id": 8,
@@ -82,8 +82,8 @@
82
  "binary": 10
83
  },
84
  "expected_output": 15,
85
- "actual_output": 15,
86
- "pass": true
87
  },
88
  {
89
  "test_id": 9,
@@ -91,8 +91,8 @@
91
  "binary": 15
92
  },
93
  "expected_output": 8,
94
- "actual_output": 8,
95
- "pass": true
96
  },
97
  {
98
  "test_id": 10,
@@ -100,8 +100,8 @@
100
  "binary": 128
101
  },
102
  "expected_output": 192,
103
- "actual_output": 192,
104
- "pass": true
105
  },
106
  {
107
  "test_id": 11,
@@ -109,8 +109,8 @@
109
  "binary": 127
110
  },
111
  "expected_output": 64,
112
- "actual_output": 64,
113
- "pass": true
114
  }
115
  ]
116
  }
 
1
  {
2
+ "passed": false,
3
  "num_tests": 12,
4
+ "num_passed": 1,
5
  "simulation_time": 12.0,
6
  "results": [
7
  {
 
19
  "binary": 1
20
  },
21
  "expected_output": 1,
22
+ "actual_output": 0,
23
+ "pass": false
24
  },
25
  {
26
  "test_id": 2,
 
28
  "binary": 2
29
  },
30
  "expected_output": 3,
31
+ "actual_output": 0,
32
+ "pass": false
33
  },
34
  {
35
  "test_id": 3,
 
37
  "binary": 3
38
  },
39
  "expected_output": 2,
40
+ "actual_output": 1,
41
+ "pass": false
42
  },
43
  {
44
  "test_id": 4,
 
46
  "binary": 127
47
  },
48
  "expected_output": 64,
49
+ "actual_output": 63,
50
+ "pass": false
51
  },
52
  {
53
  "test_id": 5,
 
55
  "binary": 255
56
  },
57
  "expected_output": 128,
58
+ "actual_output": 255,
59
+ "pass": false
60
  },
61
  {
62
  "test_id": 6,
 
64
  "binary": 254
65
  },
66
  "expected_output": 129,
67
+ "actual_output": 254,
68
+ "pass": false
69
  },
70
  {
71
  "test_id": 7,
 
73
  "binary": 5
74
  },
75
  "expected_output": 7,
76
+ "actual_output": 0,
77
+ "pass": false
78
  },
79
  {
80
  "test_id": 8,
 
82
  "binary": 10
83
  },
84
  "expected_output": 15,
85
+ "actual_output": 0,
86
+ "pass": false
87
  },
88
  {
89
  "test_id": 9,
 
91
  "binary": 15
92
  },
93
  "expected_output": 8,
94
+ "actual_output": 7,
95
+ "pass": false
96
  },
97
  {
98
  "test_id": 10,
 
100
  "binary": 128
101
  },
102
  "expected_output": 192,
103
+ "actual_output": 128,
104
+ "pass": false
105
  },
106
  {
107
  "test_id": 11,
 
109
  "binary": 127
110
  },
111
  "expected_output": 64,
112
+ "actual_output": 63,
113
+ "pass": false
114
  }
115
  ]
116
  }
tasks/task2/results.xml CHANGED
@@ -1,6 +1,8 @@
1
  <testsuites name="results">
2
  <testsuite name="all" package="all">
3
- <property name="random_seed" value="1775630292" />
4
- <testcase name="test_bin_to_gray" classname="test_bin_to_gray" file="/mnt/c/Users/npkas/Agentic-RL/rtl_debugger/tasks/task2/test_bin_to_gray.py" lineno="20" time="0.021413326263427734" sim_time_ns="12.0" ratio_time="560.3986906272964" />
 
 
5
  </testsuite>
6
  </testsuites>
 
1
  <testsuites name="results">
2
  <testsuite name="all" package="all">
3
+ <property name="random_seed" value="1775636844" />
4
+ <testcase name="test_bin_to_gray" classname="test_bin_to_gray" file="/mnt/c/Users/npkas/Agentic-RL/rtl_debugger/tasks/task2/test_bin_to_gray.py" lineno="20" time="0.005563259124755859" sim_time_ns="12.0" ratio_time="2157.0089997428645">
5
+ <failure error_type="AssertionError" error_msg="Some test cases failed&#10;assert False" />
6
+ </testcase>
7
  </testsuite>
8
  </testsuites>
tasks/task2/sim_build/sim.vvp CHANGED
@@ -8,56 +8,33 @@
8
  :vpi_module "/usr/lib/x86_64-linux-gnu/ivl/v2005_math.vpi";
9
  :vpi_module "/usr/lib/x86_64-linux-gnu/ivl/va_math.vpi";
10
  :vpi_module "/usr/lib/x86_64-linux-gnu/ivl/v2009.vpi";
11
- S_0x55b47534e490 .scope package, "$unit" "$unit" 2 1;
12
  .timescale -9 -12;
13
- S_0x55b47534e620 .scope module, "bin_gry" "bin_gry" 3 1;
14
  .timescale -9 -12;
15
  .port_info 0 /INPUT 8 "binary";
16
  .port_info 1 /OUTPUT 8 "gray";
17
- P_0x55b47534e7b0 .param/l "N" 0 3 1, +C4<00000000000000000000000000001000>;
18
- o0x7fe4c9e7a048 .functor BUFZ 8, C4<zzzzzzzz>; HiZ drive
19
- v0x55b475360430_0 .net "binary", 7 0, o0x7fe4c9e7a048; 0 drivers
20
- v0x55b4753987b0_0 .var "gray", 7 0;
21
- E_0x55b475387890 .event anyedge, v0x55b475360430_0;
22
- S_0x55b475375940 .scope begin, "$ivl_for_loop0" "$ivl_for_loop0" 3 14, 3 14 0, S_0x55b47534e620;
23
- .timescale -9 -12;
24
- v0x55b47535fd50_0 .var/i "i", 31 0;
25
- .scope S_0x55b47534e620;
26
  T_0 ;
27
- %wait E_0x55b475387890;
28
- %load/vec4 v0x55b475360430_0;
29
  %parti/s 1, 7, 4;
30
  %ix/load 4, 7, 0;
31
  %flag_set/imm 4, 0;
32
- %store/vec4 v0x55b4753987b0_0, 4, 1;
33
- %fork t_1, S_0x55b475375940;
34
- %jmp t_0;
35
- .scope S_0x55b475375940;
36
- t_1 ;
37
- %pushi/vec4 0, 0, 32;
38
- %store/vec4 v0x55b47535fd50_0, 0, 32;
39
- T_0.0 ;
40
- %load/vec4 v0x55b47535fd50_0;
41
- %cmpi/s 7, 0, 32;
42
- %jmp/0xz T_0.1, 5;
43
- %load/vec4 v0x55b475360430_0;
44
- %load/vec4 v0x55b47535fd50_0;
45
- %addi 1, 0, 32;
46
- %part/s 1;
47
- %load/vec4 v0x55b475360430_0;
48
- %load/vec4 v0x55b47535fd50_0;
49
- %part/s 1;
50
- %xor;
51
- %ix/getv/s 4, v0x55b47535fd50_0;
52
- %store/vec4 v0x55b4753987b0_0, 4, 1;
53
- %load/vec4 v0x55b47535fd50_0;
54
- %addi 1, 0, 32;
55
- %store/vec4 v0x55b47535fd50_0, 0, 32;
56
- %jmp T_0.0;
57
- T_0.1 ;
58
- %end;
59
- .scope S_0x55b47534e620;
60
- t_0 %join;
61
  %jmp T_0;
62
  .thread T_0, $push;
63
  # The file index is used to find the file name in the following table.
 
8
  :vpi_module "/usr/lib/x86_64-linux-gnu/ivl/v2005_math.vpi";
9
  :vpi_module "/usr/lib/x86_64-linux-gnu/ivl/va_math.vpi";
10
  :vpi_module "/usr/lib/x86_64-linux-gnu/ivl/v2009.vpi";
11
+ S_0x55f98416c570 .scope package, "$unit" "$unit" 2 1;
12
  .timescale -9 -12;
13
+ S_0x55f98416c700 .scope module, "bin_gry" "bin_gry" 3 1;
14
  .timescale -9 -12;
15
  .port_info 0 /INPUT 8 "binary";
16
  .port_info 1 /OUTPUT 8 "gray";
17
+ P_0x55f98416c890 .param/l "N" 0 3 1, +C4<00000000000000000000000000001000>;
18
+ o0x7f3e501fc018 .functor BUFZ 8, C4<zzzzzzzz>; HiZ drive
19
+ v0x55f98417dd50_0 .net "binary", 7 0, o0x7f3e501fc018; 0 drivers
20
+ v0x55f98417e430_0 .var "gray", 7 0;
21
+ E_0x55f98416d080 .event anyedge, v0x55f98417dd50_0;
22
+ .scope S_0x55f98416c700;
 
 
 
23
  T_0 ;
24
+ %wait E_0x55f98416d080;
25
+ %load/vec4 v0x55f98417dd50_0;
26
  %parti/s 1, 7, 4;
27
  %ix/load 4, 7, 0;
28
  %flag_set/imm 4, 0;
29
+ %store/vec4 v0x55f98417e430_0, 4, 1;
30
+ %load/vec4 v0x55f98417dd50_0;
31
+ %parti/s 7, 1, 2;
32
+ %load/vec4 v0x55f98417dd50_0;
33
+ %parti/s 7, 0, 2;
34
+ %and;
35
+ %ix/load 4, 0, 0;
36
+ %flag_set/imm 4, 0;
37
+ %store/vec4 v0x55f98417e430_0, 4, 7;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  %jmp T_0;
39
  .thread T_0, $push;
40
  # The file index is used to find the file name in the following table.
tasks/task3/design_active.v CHANGED
@@ -1,62 +1,62 @@
1
  module moore_ol(
2
- inp,
3
- clk,
4
- reset,
5
- out
6
- );
7
 
8
  input inp, clk, reset;
9
  output reg out;
10
- parameter S0 = 0 , S1 = 1 , S2 = 2 , S3 = 3, S4 = 4;
11
  reg [2:0] present_state, next_state;
12
 
13
  always @ (posedge clk or posedge reset)
14
- begin
15
- if(reset)
16
- present_state <= S0;
17
- else
18
- present_state <= next_state;
19
- end
20
 
21
  always @ (present_state or inp)
22
- begin
23
- case(present_state)
24
- S0 : begin
25
  if (inp)
26
- next_state = S1;
27
  else
28
- next_state = S0;
29
  out = 0;
30
- end
31
- S1 : begin
32
  if (inp)
33
- next_state = S2;
34
  else
35
- next_state = S0;
36
  out = 0;
37
- end
38
- S2 : begin
39
  if (inp)
40
- next_state = S2; // FIX: If current state is S2 (seen '11') and input is '1', the sequence becomes '111'. The longest suffix of '111' that is also a prefix of '1101' is '11'. So, the FSM should remain in S2. It was incorrectly transitioning to S1.
41
  else
42
- next_state = S3;
43
  out = 0;
44
- end
45
- S3 : begin
46
  if (inp)
47
- next_state = S4;
48
  else
49
- next_state = S0;
50
  out = 0;
51
- end
52
- S4 : begin
53
  if (inp)
54
- next_state = S2;
55
  else
56
- next_state = S0;
57
  out = 1;
58
- end
59
- default: next_state = S0;
60
- endcase
61
- end
62
  endmodule
 
1
  module moore_ol(
2
+ inp,
3
+ clk,
4
+ reset,
5
+ out
6
+ );
7
 
8
  input inp, clk, reset;
9
  output reg out;
10
+ parameter S0 = 0, S1 = 1, S2 = 2, S3 = 3, S4 = 4;
11
  reg [2:0] present_state, next_state;
12
 
13
  always @ (posedge clk or posedge reset)
14
+ begin
15
+ if (reset)
16
+ present_state <= S0;
17
+ else
18
+ present_state <= next_state;
19
+ end
20
 
21
  always @ (present_state or inp)
22
+ begin
23
+ case(present_state)
24
+ S0 : begin
25
  if (inp)
26
+ next_state = S1;
27
  else
28
+ next_state = S0;
29
  out = 0;
30
+ end
31
+ S1 : begin
32
  if (inp)
33
+ next_state = S2;
34
  else
35
+ next_state = S0;
36
  out = 0;
37
+ end
38
+ S2 : begin
39
  if (inp)
40
+ next_state = S3;
41
  else
42
+ next_state = S0;
43
  out = 0;
44
+ end
45
+ S3 : begin
46
  if (inp)
47
+ next_state = S4;
48
  else
49
+ next_state = S0;
50
  out = 0;
51
+ end
52
+ S4 : begin
53
  if (inp)
54
+ next_state = S2;
55
  else
56
+ next_state = S0;
57
  out = 1;
58
+ end
59
+ default: next_state = S0;
60
+ endcase
61
+ end
62
  endmodule