UNPKG

signalflip-js

Version:

[![npm version](https://badge.fury.io/js/signalflip-js.svg)](https://badge.fury.io/js/signalflip-js) [![Build Status](https://travis-ci.com/ameetgohil/signalflip-js.svg?branch=master)](https://travis-ci.com/ameetgohil/signalflip-js) [![CI](https://github.

35 lines (29 loc) 834 B
const Component = require('./Component'); const { RisingEdge } = require('../Sim'); class Driver extends Component { constructor(name, parent, intf) { super(name, parent); this.intf = intf; this.reqQ = []; this.rspQ = []; } *run() { this.log('Starting driver loop...'); while (true) { const tr = this.getNextItem(); // synchronous for now or need a way to wait if (tr) { yield* this.drive(tr); } else { yield* RisingEdge(this.intf.clk); // Wait for clock if no item // break; } } } getNextItem() { return this.reqQ.shift(); } *drive(tr) { throw new Error("drive() must be implemented by subclass"); } } module.exports = Driver;