Code Monkey home page Code Monkey logo

vector-test's Introduction

vector-test Download

vector-test is a library for programmatically generating test vector files for Logisim.

Usage

vector-test has its own DSL/Builder implemented.

val table = buildTable {
    header {
        item("A")       // one width column.
        item("B", 15)   // 31 bit wide column.
        item("C", 16)   // 32 bit wide column.
    }

    row(0, 0, 0) // A row can be described in multiple ways.
    row {
        entry(0)
        entry(EntryType.HEXADECIMAL, "0x00000000000000F") // 15
        entry(EntryType.BINARY, "0000000000001111")
    }
}

// the table is modeled like this.
// NOTE: the below table is far prettier than the actual result when printing.
/*
A B[15]             C[16]
0 0                 0
0 0x00000000000000F 0000000000001111
*/

val file = table.exportToFile("crudely-tested-addition.txt")

There is also a function type used to mass create rows.

val addFunction = object : Function<Int> {
    override fun eval(fields: IntArray): Array<Int> {
        require(fields.size == 2) {
            "The add function requires exactly two parameters."
        }
    
        val a = field[0]
        val b = field[1]
        
        return arrayOf(a + b)
    }
}

val exportFileName = "function-generated.txt"

// A pair can be passed to this function to handle easy writing.
// The first value in the pair is the name of the file to export.
// The second value in the pair controls if file writing happens as we go, or at the end.
val table = buildTable(exportFileName to true) {
    header {
        item("A", 32)
        item("B", 32)
        item("C", 32)
    }

    val aRange = (0..1000 step 5).toList()
    val bRange = setOf(1, 3, 8, 2020).toList()
    functionPermutations(addFunction, aRange, bRange)
}

// table is now populated with the cartesian product 
// of aRange and bRange mapped into addFunction.
val file = File(exportFileName)

vector-test's People

Contributors

ze avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.