How to use the 3vl.Mem3vl function in 3vl

To help you get started, we’ve selected a few 3vl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tilk / digitaljs / src / cells / memory.js View on Github external
constructor: function(args) {
        if (!args.bits) args.bits = 1;
        if (!args.abits) args.abits = 1;
        if (!args.rdports) args.rdports = [];
        if (!args.wrports) args.wrports = [];
        if (!args.words) args.words = 1 << args.abits;
        if (!args.offset) args.offset = 0;
        if (args.memdata)
            this.memdata = Mem3vl.fromJSON(args.bits, args.memdata);
        else
            this.memdata = new Mem3vl(args.bits, args.words);
        delete args.memdata; // performance hack
        console.assert(this.memdata.words == args.words);
        this.last_clk = {};
        const markup = [];
        const lblmarkup = [];
        let num = 0;
        const portsplits = [];
        function num_y(num) { return num * 16 + 12; }
        for (const [pnum, port] of args.rdports.entries()) {
            const portname = "rd" + pnum;
            markup.push(this.addLabelledWire(args, lblmarkup, 'right', num_y(num), { id: portname + 'data', dir: 'out', bits: args.bits, label: 'data' }));
            markup.push(this.addLabelledWire(args, lblmarkup, 'left', num_y(num++), { id: portname + 'addr', dir: 'in', bits: args.abits, label: 'addr' }));
            if ('enable_polarity' in port)
                markup.push(this.addLabelledWire(args, lblmarkup, 'left', num_y(num++), { id: portname + 'en', dir: 'in', bits: 1, label: 'en', polarity: port.enable_polarity }));
            if ('clock_polarity' in port) {
                markup.push(this.addLabelledWire(args, lblmarkup, 'left', num_y(num++), { id: portname + 'clk', dir: 'in', bits: 1, label: 'clk', polarity: port.clock_polarity, clock: true }));