library refactoring
This commit is contained in:
parent
084ebf3ee0
commit
47fd7856e2
11
bin/find.js
11
bin/find.js
@ -4,8 +4,7 @@
|
||||
const fs = require('fs-extra');
|
||||
const async = require('async');
|
||||
|
||||
const vcd = require('../lib/index.js');
|
||||
const utils = require('../lib/utils');
|
||||
const lib = require('../lib/index.js');
|
||||
|
||||
const dir = './tmp/';
|
||||
|
||||
@ -19,11 +18,11 @@ fs.readdir(dir).then(files => {
|
||||
|
||||
const t0 = Date.now();
|
||||
|
||||
let inst = vcd();
|
||||
let inst = lib.parser();
|
||||
|
||||
const loads = utils.and();
|
||||
const stores = utils.and();
|
||||
const duration = utils.activity(10);
|
||||
const loads = lib.and();
|
||||
const stores = lib.and();
|
||||
const duration = lib.activity(10);
|
||||
|
||||
inst.on('$enddefinitions', () => {
|
||||
// console.log(res);
|
||||
|
18
lib/activity.js
Normal file
18
lib/activity.js
Normal file
@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = skip => {
|
||||
let start = 0;
|
||||
let stop = 0;
|
||||
return {
|
||||
on: time => {
|
||||
if (time > skip) {
|
||||
if (start == 0) {
|
||||
start = time;
|
||||
} else {
|
||||
stop = time;
|
||||
}
|
||||
}
|
||||
},
|
||||
time: () => stop - start
|
||||
};
|
||||
};
|
13
lib/index.js
Normal file
13
lib/index.js
Normal file
@ -0,0 +1,13 @@
|
||||
'use strict';
|
||||
|
||||
const pkg = require('../package.json');
|
||||
const parser = require('./parser.js');
|
||||
const and = require('./and.js');
|
||||
const activity = require('./activity.js');
|
||||
|
||||
module.exports = {
|
||||
version: pkg.version,
|
||||
and: and,
|
||||
activity: activity,
|
||||
parser: parser
|
||||
};
|
@ -2,7 +2,6 @@
|
||||
|
||||
const stream = require('stream');
|
||||
const EventEmitter = require('events').EventEmitter;
|
||||
const pkg = require('../package.json');
|
||||
let lib = require('bindings')('vcd.node');
|
||||
|
||||
module.exports = () => {
|
||||
@ -35,8 +34,6 @@ module.exports = () => {
|
||||
}
|
||||
};
|
||||
|
||||
s.version = pkg.version;
|
||||
|
||||
s.info = info;
|
||||
|
||||
return s;
|
||||
|
@ -1,22 +1,22 @@
|
||||
'use strict';
|
||||
|
||||
const expect = require('chai').expect;
|
||||
const vcd = require('../lib/index.js');
|
||||
const lib = require('../lib/index.js');
|
||||
|
||||
describe('basic', () => {
|
||||
|
||||
it('typeof vcd', done => {
|
||||
expect(vcd).to.be.an('function');
|
||||
expect(lib.parser).to.be.an('function');
|
||||
done();
|
||||
});
|
||||
|
||||
it('typeof vcd instance', done => {
|
||||
expect(vcd()).to.be.an('object');
|
||||
expect(lib.parser()).to.be.an('object');
|
||||
done();
|
||||
});
|
||||
|
||||
it('fail: foo bar', done => {
|
||||
const inst = vcd();
|
||||
const inst = lib.parser();
|
||||
expect(inst.write(Buffer.from(' foo bar ???'))).to.eq(true);
|
||||
expect(inst.info).to.deep.eq({
|
||||
path: [],
|
||||
@ -26,7 +26,7 @@ describe('basic', () => {
|
||||
});
|
||||
|
||||
it('$comment', done => {
|
||||
const inst = vcd();
|
||||
const inst = lib.parser();
|
||||
expect(inst.write(Buffer.from(
|
||||
' \n $comment some text $end $comment more text $end ???'
|
||||
))).to.eq(true);
|
||||
@ -38,7 +38,7 @@ describe('basic', () => {
|
||||
});
|
||||
|
||||
it('$version', done => {
|
||||
const inst = vcd();
|
||||
const inst = lib.parser();
|
||||
expect(inst.write(`
|
||||
$version Generated by VerilatedVcd $end
|
||||
$date Wed Sep 18 22:59:07 2019
|
||||
|
Loading…
x
Reference in New Issue
Block a user