<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Alexandre Rusev</title>
    <description>The latest articles on DEV Community by Alexandre Rusev (@alexandre_rusev_7c8e1c1b6).</description>
    <link>https://dev.to/alexandre_rusev_7c8e1c1b6</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3887448%2Fa1f88038-7b76-4d3c-b012-244d041d5e73.png</url>
      <title>DEV Community: Alexandre Rusev</title>
      <link>https://dev.to/alexandre_rusev_7c8e1c1b6</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/alexandre_rusev_7c8e1c1b6"/>
    <language>en</language>
    <item>
      <title>Mixed co-simulation with IcarusVerilog and NGSpice using "MixFighter" bridge.</title>
      <dc:creator>Alexandre Rusev</dc:creator>
      <pubDate>Sun, 19 Apr 2026 16:08:27 +0000</pubDate>
      <link>https://dev.to/alexandre_rusev_7c8e1c1b6/mixed-co-simulation-with-icarusverilog-and-ngspice-using-mixfighter-bridge-309e</link>
      <guid>https://dev.to/alexandre_rusev_7c8e1c1b6/mixed-co-simulation-with-icarusverilog-and-ngspice-using-mixfighter-bridge-309e</guid>
      <description>&lt;p&gt;&lt;strong&gt;Bridge for Co‑simulation in Icarus Verilog and NGSpice&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Author: Cyberflex (based on the real development "MixFighter")&lt;/p&gt;

&lt;p&gt;How We Built a Bridge Between Icarus Verilog and NGSpice: Two Different Architecture Implementations, their advantages and drawbacks, and why the ideal solution is not yet achieved&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What Are Event‑Driven and Continuous Simulation?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the world of electronic system simulation, there are two fundamentally different approaches.&lt;br&gt;
&lt;strong&gt;&lt;em&gt;Event‑driven simulation&lt;/em&gt;&lt;/strong&gt; is used for digital circuits. Logic elements change their state only at moments when changes occur at their inputs – clock edges, flip‑flop toggles, gate delays. Between these events, nothing happens; the simulator "sleeps" and does not consume resources. This is exactly how Icarus Verilog, Modelsim, VCS, and other digital simulators work. This is fast and efficient because digital signals have only two (or a few discrete) states.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Continuous simulation&lt;/em&gt;&lt;/strong&gt; (or pseudo‑continuous) is used for analog circuits. Current through a transistor, voltage on a capacitor, generator phase – everything changes smoothly according to differential equations. The simulator (SPICE, NGSpice, Spectre) divides time into very small steps, solves systems of equations at each step, and produces results as curves. Accuracy requires the smallest steps, especially during sharp edges or feedback loops. This is slow, but there is no other way to obtain "almost real‑life" analog behavior.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Problem of Mixed‑Mode Modeling&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Sometimes there is a need for &lt;strong&gt;&lt;em&gt;co‑simulation&lt;/em&gt;&lt;/strong&gt; of interacting analog and digital systems. Imagine you are developing a SAR ADC. The analog part – comparator, capacitor DAC, input buffer – requires SPICE modeling with microvolt and picosecond accuracy. The digital part – control logic, calibration, interface – is perfectly simulated in Icarus Verilog. How do you make them work together? You can use ready‑made commercial solvers (Cadence, Synopsys), but they are expensive and not always available. Or you can write your own bridge – a VPI module that connects Icarus and NGSpice via shared memory and semaphores. That is exactly what I did.&lt;/p&gt;

&lt;p&gt;This can be solved by harnessing two different simulators in the same team, controlling them alternately and exchanging data between them. We took a pair of such standard simulators – &lt;strong&gt;Icarus Verilog&lt;/strong&gt; and &lt;strong&gt;NGSpice&lt;/strong&gt; – and built a controlling bridge. The process gave rise to two implementations: &lt;em&gt;"Classic"&lt;/em&gt; – simple, synchronous, where Verilog explicitly requests analog data ("digital oversampling"). &lt;em&gt;"Alternative"&lt;/em&gt; – with lookahead and injection of events from SPICE into Verilog.&lt;br&gt;
It would seem that the second is an evolution of the first. But in reality, each has fundamental architectural drawbacks that cannot be fixed with cosmetic patches. In this article, I will analyze both implementations, their compromises, and show why an ideal open‑source solution for mixed‑mode modeling does not yet exist. &lt;strong&gt;Spoiler: &lt;em&gt;despite all the drawbacks, the tool is already quite suitable for real tasks – from formal verification of digital blocks in conjunction with analog IP to counting pulses of sigma‑delta ADCs.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F14viojcz6j4mzd2fjoy1.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F14viojcz6j4mzd2fjoy1.jpg" alt=" " width="800" height="656"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Figure 1&lt;/strong&gt;: GTKWave (digital + analog) and built‑in &lt;strong&gt;NGSpic&lt;/strong&gt;e /gnuplot. Merged time scales, same signals.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How the Bridge Works: Common Architecture&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Both implementations are based on the same set of technologies: VPI (Verilog Procedural Interface) of Icarus, libngspice.so, pipe semaphores, and a separate NGSpice thread. The workflow (simplified):&lt;/p&gt;

&lt;p&gt;Icarus (main thread)          NGSpice (thread)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$spice_sync() (or $get_...)
| state.target = t_now
| wait(analog_done)  &amp;lt;----------------+ post(analog_done)
|                                 update real variables
|                                 apply alter (DAC)
|                                 post(digital_done)
| -------------&amp;gt; wait(digital_done)
| return control
| (continues simulation)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The problem is that SPICE produces results only at the moments of its internal time steps. And Verilog operates by events that can occur at any (planned) time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Important Simplification for Testbench:&lt;/strong&gt; &lt;em&gt;$spice_sync()&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Both implementations include the system task &lt;em&gt;$spice_sync()&lt;/em&gt;. Its call (e.g., on each fast clock edge) performs a full exchange cycle: transfers the current digital values to SPICE (via alter), requests fresh analog voltages, and updates real variables in Verilog. There is no need to manually call &lt;em&gt;$get_analog_voltage()&lt;/em&gt; for each signal.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight verilog"&gt;&lt;code&gt;&lt;span class="k"&gt;always&lt;/span&gt; &lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;posedge&lt;/span&gt; &lt;span class="n"&gt;clk_fast&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;begin&lt;/span&gt;
    &lt;span class="p"&gt;$&lt;/span&gt;&lt;span class="n"&gt;spice_sync&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// synchronization and update of all exposed variables&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Vcmp&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;vref_th&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;begin&lt;/span&gt;
        &lt;span class="c1"&gt;// digital reaction on event&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Thanks to expose_analog_N (config file for co-simulation of specific project), real variables are automatically updated and visible in GTKWave on the same time axis as digital signals.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Modeling Delays and Edges&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Often in mixed‑mode circuits, not only static levels are important but also the settling time of the digital signal and the slew rate of the analog edge. In both implementations, this is easily modeled using "wrapper" objects on the Verilog and SPICE sides.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Classic Implementation: Synchronous Polling&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Every time Verilog needs fresh analog data, the bridge finds out the current time of Icarus, blocks on a semaphore, SPICE simulates up to that time and returns the values. Pros: simplicity, determinism, predictable performance. Cons (major drawback): analog events that occur between Verilog clock ticks are completely ignored. Example: the comparator switches at 5.2 ns, but the next positive clock edge is at 10.0 ns. Verilog learns about this only at 10 ns, which breaks the feedback logic in SAR ADCs, DC‑DC converters. You have to oversample the data exchange between the two simulators by increasing the frequency of the clk_fast system task. Finding appropriate oversampling rate makes the model to work properly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Alternative Implementation: Lookahead&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The idea&lt;/em&gt;: allow SPICE to run ahead for a small interval, monitor analog triggers (thresholds, windows, durations, peaks) and, if something happens, stop and call Verilog earlier. Example of line in configuration file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;analog_event_1 = duration outp above 0.8V for 10ns energy 1e-12
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Pros&lt;/strong&gt;: SPICE can initiate an event, accuracy under ideal conditions, flexibility. &lt;br&gt;
&lt;strong&gt;Cons&lt;/strong&gt; (fundamental): Sentinels are checked only at SPICE steps – an event between steps may be missed. The window length heuristic can fail (too little – late, too much – performance drop). Causality violation for DAC: the alter command will only be executed in the next phase A, after SPICE has already passed the moment of the event. Only one event per window. Non‑determinism due to heuristics.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcfeiw57q19ejrv8pvujd.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcfeiw57q19ejrv8pvujd.jpg" alt=" " width="800" height="509"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Figure 2&lt;/strong&gt;: &lt;strong&gt;gwave&lt;/strong&gt;: viewing analog signals of a Sigma Delta modulator (same vbuck, vbucki, &lt;strong&gt;Qbar&lt;/strong&gt; as in GTKWave)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Comparison Table&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;            Characteristic                  Classic Alternative
Detection of analog events between          ❌ No          ⚠️ Partial  
clock ticks                                           (with misses)
Injection of events from SPICE into Verilog ❌ Impossible  ✅                                                                  
Performance                                 ✅ Predictable ⚠️ May spike (but maxstep helps)
Determinism                                 ✅ Complete    ⚠️ Depends on heuristics
DAC→Analog causality                        ✅ Correct     ❌ Violated
                                                        during phase B
Support for multiple events                 ❌ No          ❌ Only 
                                                       one per window
Code size (lines)                          ~2000       ~3500                 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F00uwh3fncwp0wyrk21pn.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F00uwh3fncwp0wyrk21pn.jpg" alt=" " width="800" height="516"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Figure 3&lt;/strong&gt;: &lt;strong&gt;JavaElectric EDA&lt;/strong&gt;: &lt;em&gt;&lt;strong&gt;schematics&lt;/strong&gt;&lt;/em&gt; of a mixed‑mode device (Sigma Delta modulator ADC + digital counter) and a fragment of the SPICE netlist describing analog events.&lt;br&gt;
(see &lt;a href="https://www.staticfreesoft.com/index.html" rel="noopener noreferrer"&gt;https://www.staticfreesoft.com/index.html&lt;/a&gt; about JavaElecric project)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Despite Everything: It Works (Mostly)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Neither implementation is perfect, but both have been successfully used in real projects: SAR ADC verification, sigma‑delta modulator modeling, and digital PLL calibration. The code is available on GitHub (search for "MixFighter" or "iverilog-ngspice-bridge"). If you need mixed‑signal simulation today and don't have access to commercial tools, this bridge will get you 80% of the way there – just be aware of the limitations described above.&lt;br&gt;
Following Verilog code count sigma delta modulator pulses (Fig.1, Fig.2 &lt;em&gt;&lt;strong&gt;Qbar&lt;/strong&gt; signal&lt;/em&gt;) during specified period and reports resulted value as output.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight verilog"&gt;&lt;code&gt;&lt;span class="c1"&gt;//// This module count impulses from sigma delta modulator&lt;/span&gt;
&lt;span class="c1"&gt;//// generated during  CNT_CLK periods of functional clock&lt;/span&gt;
&lt;span class="k"&gt;module&lt;/span&gt; &lt;span class="n"&gt;DSMCounter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="kt"&gt;input&lt;/span&gt; &lt;span class="n"&gt;i_clk&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="kt"&gt;input&lt;/span&gt; &lt;span class="n"&gt;i_rst&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="kt"&gt;input&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;i_Qbar&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="kt"&gt;output&lt;/span&gt; &lt;span class="kt"&gt;reg&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;31&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;o_cntQbar&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="kt"&gt;output&lt;/span&gt; &lt;span class="kt"&gt;reg&lt;/span&gt; &lt;span class="n"&gt;o_ready&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;parameter&lt;/span&gt; &lt;span class="n"&gt;CNT_CLK&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;22&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kt"&gt;reg&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;31&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="n"&gt;cnt&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kt"&gt;reg&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;31&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="n"&gt;cntQbar&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kt"&gt;reg&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;31&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="n"&gt;cntTotal&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;always&lt;/span&gt; &lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;posedge&lt;/span&gt; &lt;span class="n"&gt;i_clk&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;begin&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i_rst&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;begin&lt;/span&gt;
        &lt;span class="n"&gt;cnt&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;cntQbar&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;o_cntQbar&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;o_ready&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;cntTotal&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;begin&lt;/span&gt;
        &lt;span class="n"&gt;o_ready&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;cntTotal&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;cntTotal&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i_Qbar&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;begin&lt;/span&gt;
            &lt;span class="n"&gt;cntQbar&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;cntQbar&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;end&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cnt&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;CNT_CLK&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;begin&lt;/span&gt;
            &lt;span class="n"&gt;o_cntQbar&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;cntQbar&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="n"&gt;o_ready&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="n"&gt;cnt&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="n"&gt;cntQbar&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;end&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;begin&lt;/span&gt;
            &lt;span class="n"&gt;cnt&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;cnt&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;end&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;endmodule&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Source code available here &lt;a href="https://github.com/cyberflex/MixFighter" rel="noopener noreferrer"&gt;https://github.com/cyberflex/MixFighter&lt;/a&gt; + scripts and example simulation projects.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NGSpice&lt;/strong&gt; needs to be built with support of  &lt;strong&gt;libngspice.so&lt;/strong&gt; (&lt;strong&gt;./configure --with-ngshared&lt;/strong&gt;). Configuration of co-simulatin is set in mixed_bridge.cfg, this file is also available in simulation example projects.&lt;/p&gt;

&lt;p&gt;Tags: verilog, spice, opensource, mixed-signal, icarusverilog, ngspice&lt;/p&gt;

&lt;p&gt;Original publication: [&lt;a href="https://habr.com/ru/articles/1023270/" rel="noopener noreferrer"&gt;https://habr.com/ru/articles/1023270/&lt;/a&gt;]&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>tooling</category>
      <category>cosimulation</category>
      <category>mixedcircuit</category>
    </item>
  </channel>
</rss>
