agentic-ic 3.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. agentic/__init__.py +4 -0
  2. agentic/agents/__init__.py +0 -0
  3. agentic/agents/architect.py +19 -0
  4. agentic/agents/designer.py +106 -0
  5. agentic/agents/doc_agent.py +25 -0
  6. agentic/agents/sdc_agent.py +31 -0
  7. agentic/agents/testbench_designer.py +124 -0
  8. agentic/agents/verifier.py +84 -0
  9. agentic/cli.py +1079 -0
  10. agentic/config.py +307 -0
  11. agentic/contracts.py +158 -0
  12. agentic/core/__init__.py +43 -0
  13. agentic/core/architect.py +424 -0
  14. agentic/core/cdc_analyzer.py +1100 -0
  15. agentic/core/deep_debugger.py +820 -0
  16. agentic/core/feasibility_checker.py +830 -0
  17. agentic/core/graph_builder.py +80 -0
  18. agentic/core/hierarchy_expander.py +821 -0
  19. agentic/core/react_agent.py +447 -0
  20. agentic/core/self_reflect.py +522 -0
  21. agentic/core/spec_generator.py +1003 -0
  22. agentic/core/verification_planner.py +925 -0
  23. agentic/core/waveform_expert.py +680 -0
  24. agentic/golden_lib/__init__.py +9 -0
  25. agentic/golden_lib/template_matcher.py +236 -0
  26. agentic/golden_lib/templates/counter.v +52 -0
  27. agentic/golden_lib/templates/counter_tb.v +89 -0
  28. agentic/golden_lib/templates/fifo.v +70 -0
  29. agentic/golden_lib/templates/fifo_tb.v +85 -0
  30. agentic/golden_lib/templates/fsm.v +102 -0
  31. agentic/golden_lib/templates/fsm_tb.v +50 -0
  32. agentic/golden_lib/templates/pwm.v +36 -0
  33. agentic/golden_lib/templates/pwm_tb.v +69 -0
  34. agentic/golden_lib/templates/shift_register.v +33 -0
  35. agentic/golden_lib/templates/shift_register_tb.v +52 -0
  36. agentic/golden_lib/templates/spi_master.v +131 -0
  37. agentic/golden_lib/templates/spi_master_tb.v +56 -0
  38. agentic/golden_lib/templates/timer.v +60 -0
  39. agentic/golden_lib/templates/timer_tb.v +52 -0
  40. agentic/golden_lib/templates/uart_tx.v +101 -0
  41. agentic/golden_lib/templates/uart_tx_tb.v +67 -0
  42. agentic/install_tools.py +103 -0
  43. agentic/orchestrator.py +5248 -0
  44. agentic/tools/__init__.py +0 -0
  45. agentic/tools/vlsi_tools.py +4236 -0
  46. agentic_ic-3.0.0.dist-info/METADATA +168 -0
  47. agentic_ic-3.0.0.dist-info/RECORD +50 -0
  48. agentic_ic-3.0.0.dist-info/WHEEL +4 -0
  49. agentic_ic-3.0.0.dist-info/entry_points.txt +2 -0
  50. agentic_ic-3.0.0.dist-info/licenses/LICENSE +7 -0
agentic/__init__.py ADDED
@@ -0,0 +1,4 @@
1
+ """
2
+ AgentIC - AI-Driven Chip Design Framework
3
+ """
4
+ __version__ = "3.0.0"
File without changes
@@ -0,0 +1,19 @@
1
+ import os
2
+ from crewai import Agent
3
+ from langchain_openai import ChatOpenAI
4
+
5
+ def get_architect_agent(llm, tools, verbose=False):
6
+ return Agent(
7
+ role='Principal VLSI Architect',
8
+ goal='Resolve complex, cross-file architectural and syntax failures that automated loops cannot fix.',
9
+ backstory="""You are a world-class chip designer and system architect.
10
+ You act as a "Super Agent" when the standard scripted repair loops fail.
11
+ Unlike junior designers, you don't just fix one file; you investigate the entire 'src/' directory.
12
+ You actively use tools like `codebase_explorer` to see what files exist, `global_search` to find missing instantiations or interfaces, and `read_file_tool` to understand context.
13
+ You fix structural naming mismatches, missing include files, missing module definitions, and assure the entire codebase is structurally sound.
14
+ You write fixes back using the write_verilog tools.""",
15
+ tools=tools,
16
+ llm=llm,
17
+ verbose=verbose,
18
+ allow_delegation=False
19
+ )
@@ -0,0 +1,106 @@
1
+ # agents/designer.py
2
+ from crewai import Agent
3
+ from ..tools.vlsi_tools import syntax_check_tool, read_file_tool
4
+
5
+ # Universal chip support: complete list of chip families the LLM must handle
6
+ CHIP_FAMILIES = """
7
+ SUPPORTED CHIP FAMILIES (you must be able to design ANY of these):
8
+ Digital Logic : counters, adders, ALUs, shift registers, multiplexers, decoders
9
+ State Machines : Mealy/Moore FSMs, traffic controllers, sequence detectors
10
+ Memory : FIFOs, RAMs, ROMs, register files, cache controllers
11
+ Arithmetic : multipliers, dividers, FP units, MAC units, FFT butterflies
12
+ Interfaces : UART, SPI, I2C, APB, AHB, AXI4-Lite, AXI4-Stream, PCIe TLP
13
+ Control : PWM, timers, watchdog, interrupt controllers, DMA engines
14
+ Crypto : AES, SHA, HMAC, RSA datapaths, PRNG/LFSR
15
+ Processors : RISC pipelines, microcontrollers, DSP cores, VLIW slices
16
+ Signal Proc. : FIR/IIR filters, decimators, NCOs, CORDICs
17
+ Mixed : SoC peripherals, bridge adapters, CDC synchronizers
18
+ """
19
+
20
+ # Hard rules that prevent the most common LLM RTL failures
21
+ RTL_HARD_RULES = """
22
+ MANDATORY RTL RULES (violations will cause synthesis errors — never break these):
23
+
24
+ MODULE NAMING (CRITICAL):
25
+ ─────────────────────────
26
+ • Module name MUST match the design_name exactly as given to you.
27
+ • Module name MUST start with a letter (a-z/A-Z) or underscore.
28
+ • If design_name starts with a digit, prepend 'chip_': e.g. '8bit_cpu' → 'chip_8bit_cpu'.
29
+ • NEVER use spaces, hyphens, or special characters in module/signal names.
30
+ • Testbench module name MUST be <module_name>_tb (same naming rules apply).
31
+
32
+ PORT & SIGNAL RULES:
33
+ ─────────────────────
34
+ • Always declare clk (input) and rst_n (active-low reset, input) on every sequential module.
35
+ • NEVER redeclare a port name as an internal signal (no port shadowing).
36
+ • Bus widths MUST match exactly on every LHS and RHS: 16-bit PC cannot receive an 8-bit value.
37
+ • Every 'output logic' port must be driven by EXACTLY one source: either 'assign' OR 'always' — NEVER both.
38
+ • Arrays (logic [N-1:0] mem [0:D-1]) are initialized with '= {...}' not '= begin...end'.
39
+
40
+ VERILATOR COMPATIBILITY:
41
+ ─────────────────────────
42
+ • 'always_ff' blocks may only contain non-blocking assignments (<=).
43
+ • 'always_comb' blocks may only contain blocking assignments (=).
44
+ • Every variable read in 'always_comb' must be assigned in ALL branches (no latches).
45
+ • Do NOT mix blocking and non-blocking assignments in the same 'always' block.
46
+ • ROM/RAM initialization: use parameter/localparam or $readmemh, not inline '= {}' in 'always_ff'.
47
+
48
+ RESET RULES:
49
+ ─────────────
50
+ • All registers must be explicitly reset to a defined value in the reset branch.
51
+ • Use synchronous reset (if !rst_n inside posedge clk) OR asynchronous (negedge rst_n), not both.
52
+ • Pick ONE style and be consistent throughout the entire module.
53
+
54
+ WIDTH ARITHMETIC:
55
+ ──────────────────
56
+ • When adding signals of width W, the result can be W+1 bits — declare accordingly.
57
+ • Index into arrays with the minimum-width signal: for 16-entry ROM use [3:0], not [15:0].
58
+ """
59
+
60
+ def get_designer_agent(llm, goal, verbose=False, strategy="SV_MODULAR"):
61
+ """
62
+ Returns a designer agent for ANY chip type, with hard RTL rules baked in.
63
+
64
+ Args:
65
+ strategy: "SV_MODULAR" (Modern SystemVerilog) or "VERILOG_CLASSIC" (Verilog-2005).
66
+ """
67
+
68
+ if strategy == "VERILOG_CLASSIC":
69
+ role = "Legacy Verilog Engineer"
70
+ backstory = f"""You are a veteran chip designer who prioritizes maximum tool compatibility.
71
+ You write rock-solid Verilog-2005 code that works on any simulator (Icarus, Verilator, commercial).
72
+ You use 'reg', 'wire', 'always @(posedge clk)', and 'localparam'. Never use 'logic', 'always_ff', or 'enum'.
73
+ Your code is complete, flat, and robust.
74
+ Before returning any Verilog, mentally simulate Verilator strict width checking on every signal assignment, port connection, arithmetic operation, and parameter comparison. Resolve all width mismatches proactively. Every signal must be explicitly sized.
75
+
76
+ {CHIP_FAMILIES}
77
+
78
+ {RTL_HARD_RULES}
79
+ """
80
+ else:
81
+ role = "SystemVerilog Architect"
82
+ backstory = f"""You are a Principal ASIC Architect at a top-tier semiconductor company (NVIDIA/Intel).
83
+ You write PRODUCTION-READY RTL — never toy code or placeholders.
84
+
85
+ Your Principles:
86
+ 1. **Completeness**: NEVER use placeholders. If a NPU has 4×4 cells, implement ALL 16.
87
+ 2. **Scalability**: Always use 'parameter' for dimensions (DATA_WIDTH, FIFO_DEPTH, etc.).
88
+ 3. **Standard Interfaces**: Use AXI-Stream (tvalid/tready/tdata) or APB/AHB for control.
89
+ 4. **Modern SystemVerilog**: Use 'logic', 'always_ff', 'always_comb', 'enum', 'struct'.
90
+ 5. **Universal Chip Coverage**: You can implement ANY chip family listed below.
91
+ 6. **Width Correctness**: Before returning any Verilog, mentally simulate Verilator strict width checking on every signal assignment, port connection, arithmetic operation, and parameter comparison. Resolve all width mismatches proactively. Every signal must be explicitly sized.
92
+
93
+ {CHIP_FAMILIES}
94
+
95
+ {RTL_HARD_RULES}
96
+ """
97
+
98
+ return Agent(
99
+ role=role,
100
+ goal=goal,
101
+ backstory=backstory,
102
+ llm=llm,
103
+ verbose=verbose,
104
+ allow_delegation=False,
105
+ tools=[syntax_check_tool, read_file_tool]
106
+ )
@@ -0,0 +1,25 @@
1
+ # agents/doc_agent.py
2
+ from crewai import Agent
3
+
4
+
5
+ def get_doc_agent(llm, verbose=False):
6
+ """Returns an agent specialized in generating design documentation.
7
+
8
+ This agent creates datasheets, register maps, timing diagrams (text-based),
9
+ and integration guides from RTL code and architecture specifications.
10
+ """
11
+ return Agent(
12
+ role='Technical Documentation Engineer',
13
+ goal='Generate comprehensive, industry-standard design documentation from RTL and specifications.',
14
+ backstory="""You are a senior technical writer specializing in ASIC/FPGA documentation.
15
+ You create clear, concise datasheets that include:
16
+ - Pin descriptions with timing requirements
17
+ - Register maps with field-level detail
18
+ - Functional descriptions with state diagrams
19
+ - Integration guidelines for SoC teams
20
+ - Timing diagrams in ASCII/text format
21
+ Your documentation follows IEEE and company datasheet standards.""",
22
+ llm=llm,
23
+ verbose=verbose,
24
+ allow_delegation=False
25
+ )
@@ -0,0 +1,31 @@
1
+ # agents/sdc_agent.py
2
+ from crewai import Agent
3
+
4
+ def get_sdc_agent(llm, goal, verbose=False):
5
+ """
6
+ Returns an agent tailored for Synopsys Design Constraints (SDC) generation.
7
+ """
8
+ role = "Timing Constraint Engineer"
9
+ backstory = """You are a Senior Physical Design (PD) Engineer responsible for timing closure.
10
+ You write high-quality Synthesizable Design Constraints (SDC) files for ASIC flow (e.g., OpenLane, Yosys, OpenSTA).
11
+
12
+ Your Methodology:
13
+ 1. Read the provided Architecture Specification.
14
+ 2. Identify the primary clock port (usually 'clk') and its target frequency/period.
15
+ 3. Generate a standard SDC file implementing:
16
+ - create_clock
17
+ - set_input_delay (usually 20% of clock period)
18
+ - set_output_delay (usually 20% of clock period)
19
+ - set_driving_cell (optional/default)
20
+ - set_load (optional/default)
21
+ 4. Only output valid SDC commands, no markdown wrappers, no explanations in the final block.
22
+ """
23
+
24
+ return Agent(
25
+ role=role,
26
+ goal=goal,
27
+ backstory=backstory,
28
+ llm=llm,
29
+ verbose=verbose,
30
+ allow_delegation=False
31
+ )
@@ -0,0 +1,124 @@
1
+ # agents/testbench_designer.py
2
+ from crewai import Agent
3
+ from ..tools.vlsi_tools import syntax_check_tool, read_file_tool
4
+
5
+ TB_UNIVERSAL_RULES = """
6
+ TESTBENCH UNIVERSAL RULES (must follow for ANY chip type):
7
+
8
+ MODULE NAMING (CRITICAL — same rule as RTL):
9
+ ─────────────────────────────────────────────
10
+ • The testbench top-level module MUST be named: <design_name>_tb
11
+ • <design_name> starts with a letter. If the RTL module is 'chip_8bit_cpu', TB is 'chip_8bit_cpu_tb'.
12
+ • NEVER start a module name with a digit.
13
+
14
+ SIGNAL DIRECTION CONTRACT:
15
+ ───────────────────────────
16
+ • DUT 'output' ports → wire/logic in TB (read-only, never drive them)
17
+ • DUT 'input' ports → reg/logic in TB (write only, drive them from stimulus)
18
+ • Violating this causes "assign to unresolved wire" errors.
19
+
20
+ PASS/FAIL CONTRACT (mandatory):
21
+ ─────────────────────────────────
22
+ • The TB MUST print exactly "TEST PASSED" when all checks pass.
23
+ • The TB MUST print exactly "TEST FAILED" when any check fails.
24
+ • Do NOT rely on waveforms. All checking must be in-code with $display.
25
+
26
+ TIMING RULES:
27
+ ──────────────
28
+ • Hold reset for at least 4 clock cycles before applying stimulus.
29
+ • Wait at least 2 cycles AFTER driving inputs before sampling outputs.
30
+ • For FSM designs: wait (number_of_states + 5) cycles before checking final output.
31
+ • Use #1 delays after clock edges to avoid race conditions when sampling signals.
32
+
33
+ VERILATOR COMPATIBILITY:
34
+ ─────────────────────────
35
+ • Class interface handles MUST be declared as 'virtual <if_name>'.
36
+ • Constructor and task arguments using interfaces: 'virtual <if_name>'.
37
+ • No 'program' blocks, no DPI-C, no $system() calls.
38
+ • No 'interface' instantiated with positional connections.
39
+
40
+ UNIVERSAL CHIP STIMULUS:
41
+ ─────────────────────────
42
+ For any of these chip families, apply appropriate default stimulus:
43
+ • Counter/Shift Reg : apply enable, observe count/shift progression
44
+ • ALU/Arith unit : drive op1, op2, opcode; check result and flags
45
+ • FIFO/Memory : write then read back, verify data integrity and flags
46
+ • FSM controller : drive input sequences, check state outputs
47
+ • UART/SPI/I2C : drive byte stream, check start/stop, verify loopback
48
+ • AXI/APB device : send valid transactions, check ready/resp signals
49
+ • CPU core : load NOP/ADD/BR instructions, check PC progression
50
+
51
+ DATA INTEGRITY VERIFICATION (CRITICAL):
52
+ ─────────────────────────────────────────
53
+ When verifying data integrity, always store all stimulus values before applying
54
+ them to the DUT, then compare DUT outputs against those stored values.
55
+ Never generate a new random value during the checking phase — the checking
56
+ phase must only read values that were stored during the stimulus phase.
57
+ Example for FIFO / memory:
58
+ reg [7:0] stim_array [0:DEPTH-1];
59
+ // Stimulus phase — store then drive
60
+ for (i = 0; i < DEPTH; i++) begin
61
+ stim_array[i] = $urandom;
62
+ data_in = stim_array[i];
63
+ push = 1; #10; push = 0;
64
+ end
65
+ // Checking phase — compare against stored values
66
+ for (i = 0; i < DEPTH; i++) begin
67
+ pop = 1; #10; pop = 0;
68
+ if (data_out !== stim_array[i]) begin
69
+ $display("MISMATCH at %0d: expected %h got %h", i, stim_array[i], data_out);
70
+ fail_count = fail_count + 1;
71
+ end
72
+ end
73
+ """
74
+
75
+ def get_testbench_agent(llm, goal, verbose=False, strategy="SV_MODULAR"):
76
+ """
77
+ Returns a verification agent for ANY chip type with strict TB rules.
78
+
79
+ Args:
80
+ strategy: "SV_MODULAR" (Class-based SV) or "VERILOG_CLASSIC" (Procedural).
81
+ """
82
+
83
+ if strategy == "VERILOG_CLASSIC":
84
+ role = "Legacy Validation Engineer"
85
+ backstory = f"""You are an experienced validation engineer.
86
+ You write simple, procedural Verilog testbenches using 'initial' blocks.
87
+ You use $monitor, $display, and direct signal manipulation.
88
+ Your goal is to verify functional correctness with minimal complexity.
89
+
90
+ {TB_UNIVERSAL_RULES}
91
+ """
92
+ else:
93
+ role = "UVM Verification Lead"
94
+ backstory = f"""You are a Senior Verification Engineer at a top semiconductor firm.
95
+ Your goal is 100% Functional Coverage with Verilator-compatible output.
96
+
97
+ CRITICAL: Your target compiler is Verilator 5.0+.
98
+ Verilator does NOT support: classes, interfaces, covergroups, program blocks, virtual, new(), rand.
99
+ You MUST use FLAT PROCEDURAL SystemVerilog only.
100
+
101
+ Your Methodology:
102
+ 1. **Flat Procedural TB**: Use reg/wire declarations, initial blocks, and direct signal driving.
103
+ 2. **Randomized Stimulus**: Use $urandom for random data generation (Verilator-safe).
104
+ 3. **Self-Checking**: Compare DUT outputs against expected values with if-statements.
105
+ 4. **Error Tracking**: Use `integer fail_count;` — increment on each check failure.
106
+ 5. **PASS/FAIL**: Print "TEST PASSED" if fail_count==0, "TEST FAILED" otherwise.
107
+ 6. **Timeout Watchdog**: Always add `initial begin #100000; $display("TEST FAILED: Timeout"); $finish; end`
108
+ 7. **Waveform Dump**: Always add $dumpfile/$dumpvars.
109
+
110
+ NEVER USE: interface, class, virtual, covergroup, coverpoint, program, new(), rand, constraint.
111
+ These are NOT supported by Verilator and will cause immediate compile failure.
112
+
113
+ {TB_UNIVERSAL_RULES}
114
+ """
115
+
116
+ return Agent(
117
+ role=role,
118
+ goal=goal,
119
+ backstory=backstory,
120
+ llm=llm,
121
+ verbose=verbose,
122
+ allow_delegation=False,
123
+ tools=[syntax_check_tool, read_file_tool]
124
+ )
@@ -0,0 +1,84 @@
1
+ from crewai import Agent
2
+ from ..tools.vlsi_tools import syntax_check_tool, read_file_tool
3
+
4
+ def get_verification_agent(llm, verbose=False):
5
+ return Agent(
6
+ role='Formal Verification Engineer',
7
+ goal='Ensure chip correctness using SVA-style inline assertions and rigorous log analysis.',
8
+ backstory="""Senior Verification Engineer targeting Verilator 5 simulation flow.
9
+ IMPORTANT CONSTRAINTS (Verilator compatibility):
10
+ - NEVER use: class, interface (inside modules), covergroup, program, rand, virtual
11
+ - Use inline SVA: assert property (@(posedge clk) condition);
12
+ - Use immediate assertions: assert(condition) else $error("...");
13
+ - All verification constructs must be Verilator 5 compatible
14
+ - Use flat procedural testbenches with reg/wire declarations
15
+ You have tools to read files and check syntax — USE THEM to verify your output compiles.""",
16
+ llm=llm,
17
+ verbose=verbose,
18
+ tools=[syntax_check_tool, read_file_tool],
19
+ allow_delegation=False
20
+ )
21
+
22
+ def get_error_analyst_agent(llm, verbose=False):
23
+ return Agent(
24
+ role='EDA Log Analyst',
25
+ goal='Produce signal-level root cause analysis of simulation and compilation failures.',
26
+ backstory="""Expert in parsing EDA tool error messages (Icarus Verilog, Verilator, Yosys).
27
+ You have access to file reading tools — USE THEM to read the actual RTL and TB source
28
+ files when analyzing errors. Don't guess at the code — read it.
29
+
30
+ DIAGNOSTIC METHODOLOGY (mandatory):
31
+ 1. Read the simulation output line by line. Identify the EXACT $display message that
32
+ indicates failure (e.g. "Data mismatch at pop 0", "Full flag error").
33
+ 2. Trace the failing signal back through the RTL: which always_ff, always_comb, or
34
+ assign statement drives it? Cite the specific line number.
35
+ 3. Determine expected vs actual value if the simulation output contains that info.
36
+ 4. Write a surgical fix instruction that names the specific signal and construct.
37
+
38
+ You must NEVER produce a diagnosis that only says "review module X" or
39
+ "incorrect handling of Y". Every diagnosis must identify the specific RTL
40
+ construct (always block, assign, expression) that is wrong.
41
+
42
+ Key diagnostic patterns:
43
+ - "Cannot find interface" = code uses interface but Verilator doesn't support it inside modules
44
+ - "Unsupported: class" = code uses SystemVerilog classes which Verilator rejects
45
+ - Port mismatch = TB instantiates ports not in RTL module declaration
46
+ - Undeclared identifier = signal used but not declared as reg/wire
47
+ Always recommend Verilator-compatible fixes (no classes, no interfaces inside modules).""",
48
+ llm=llm,
49
+ verbose=verbose,
50
+ tools=[syntax_check_tool, read_file_tool],
51
+ allow_delegation=False
52
+ )
53
+
54
+
55
+ def get_regression_agent(llm, goal, verbose=False):
56
+ """Returns an agent that generates multiple directed test scenarios for regression.
57
+
58
+ This agent analyzes the RTL spec and creates corner-case, edge-case,
59
+ and stress tests to achieve broader coverage.
60
+ """
61
+ return Agent(
62
+ role='Regression Test Architect',
63
+ goal=goal,
64
+ backstory="""You are a senior verification lead who specializes in test planning.
65
+ You analyze RTL specifications and create comprehensive test plans covering:
66
+ - Corner cases (min/max values, overflow/underflow)
67
+ - Reset behavior (async reset during operation, double-reset)
68
+ - Edge cases (back-to-back operations, simultaneous events)
69
+ - Boundary conditions (full FIFO, empty buffer, max count)
70
+ - Stress tests (rapid toggling, sustained load)
71
+
72
+ VERILATOR COMPATIBILITY (MANDATORY):
73
+ - NEVER use: class, interface, covergroup, program, rand, virtual, new()
74
+ - Use flat procedural testbenches with reg/wire declarations
75
+ - Use initial/always blocks for stimulus and checking
76
+ - Instantiate DUT with positional or named port connections
77
+
78
+ You output self-checking Verilog testbenches with clear PASS/FAIL markers.
79
+ Each test must print "TEST PASSED" on success or "TEST FAILED" on failure.""",
80
+ llm=llm,
81
+ verbose=verbose,
82
+ tools=[syntax_check_tool, read_file_tool],
83
+ allow_delegation=False
84
+ )