How to make Data Structure

Viewed 44

I want to make data structure similar to C-language's support, in the Chisel3 description.

class Tablel(DataWidth: Int, NumLinks: Int) extends Bundle {
        val valid       = Reg(Bool())
        ...
}

in other class references it:

val Tab = Vec(NumEntries, Table(DataWidth, NumLinks))

Error is;

not found: value Table

Yes, it is because of class.

I do not yet understand about how describe data structure which does not use class declaration. Can anyone point out it?

1 Answers

In your example the word Tablel has an extra 'l' at the end. Also to create an instance of a class you must use the new operator.

val tab = Vec(NumEntries, new Table(DataWidth, NumLinks))

I would also recommend following typical Scala formatting rules. For example, variables should be begin with a lower case letter. It will help you read others' code, and for others to read yours.

And as far as your more general question of how to create data structure, the answer for Chisel is to use Bundle, Record, and Vec. So you are on the right track.

Related