@@ -105,8 +105,9 @@ case class SRAMGroup(
105105 family : String ,
106106 vt : Seq [String ],
107107 mux : Int ,
108- depth : Range ,
109- width : Range ,
108+ depth : Iterable [Int ],
109+ width : Iterable [Int ],
110+ triples : Option [Seq [(Int , Int , Int )]],
110111 ports : Seq [MacroPort ],
111112 extraPorts : Seq [MacroExtraPort ] = List ()) {
112113 def toJSON : JsObject = {
@@ -116,8 +117,18 @@ case class SRAMGroup(
116117 " name" -> JsArray (name.map(Json .toJson(_))),
117118 " vt" -> JsArray (vt.map(Json .toJson(_))),
118119 " mux" -> Json .toJson(mux),
119- " depth" -> JsArray (Seq (depth.start, depth.end, depth.step).map { x => Json .toJson(x) }),
120- " width" -> JsArray (Seq (width.start, width.end, width.step).map { x => Json .toJson(x) }),
120+ " depth" -> (depth match {
121+ case list : List [Int ] =>
122+ JsArray (list.map { x => Json .toJson(x) })
123+ case range : Range =>
124+ JsArray (Seq (range.start, range.end, range.step).map { x => Json .toJson(x) })
125+ }),
126+ " width" -> (width match {
127+ case list : List [Int ] =>
128+ JsArray (list.map { x => Json .toJson(x) })
129+ case range : Range =>
130+ JsArray (Seq (range.start, range.end, range.step).map { x => Json .toJson(x) })
131+ }),
121132 " ports" -> JsArray (ports.map { _.toJSON })
122133 )
123134 )
@@ -148,17 +159,35 @@ object SRAMGroup {
148159 case Some (x : JsNumber ) => x.value.intValue
149160 case _ => return None
150161 }
151- val depth : Range = json.get(" depth" ) match {
162+ val triples : Option [Seq [(Int , Int , Int )]] = json.get(" triples" ) match {
163+ case Some (x : JsArray ) =>
164+ val seq = x.as[List [JsArray ]].map(_.as[List [JsNumber ]].map(_.value.intValue))
165+ Some (seq.map(y => (y(0 ), y(1 ), y(2 ))).sorted)
166+ case _ => None
167+ }
168+ val depth : Iterable [Int ] = json.get(" depth list" ) match {
152169 case Some (x : JsArray ) =>
153170 val seq = x.as[List [JsNumber ]].map(_.value.intValue)
154- Range .inclusive(seq(0 ), seq(1 ), seq(2 ))
155- case _ => return None
171+ seq.sorted
172+ case _ => json.get(" depth" ) match {
173+ case Some (x : JsArray ) =>
174+ val seq = x.as[List [JsNumber ]].map(_.value.intValue)
175+ Range .inclusive(seq(0 ), seq(1 ), seq(2 ))
176+ case _ =>
177+ if (triples.isDefined) Seq () else return None
178+ }
156179 }
157- val width : Range = json.get(" width" ) match {
180+ val width : Iterable [ Int ] = json.get(" width list " ) match {
158181 case Some (x : JsArray ) =>
159182 val seq = x.as[List [JsNumber ]].map(_.value.intValue)
160- Range .inclusive(seq(0 ), seq(1 ), seq(2 ))
161- case _ => return None
183+ seq.sorted
184+ case _ => json.get(" width" ) match {
185+ case Some (x : JsArray ) =>
186+ val seq = x.as[List [JsNumber ]].map(_.value.intValue)
187+ Range .inclusive(seq(0 ), seq(1 ), seq(2 ))
188+ case _ =>
189+ if (triples.isDefined) Seq () else return None
190+ }
162191 }
163192 val ports : Seq [MacroPort ] = json.get(" ports" ) match {
164193 case Some (x : JsArray ) =>
@@ -188,7 +217,7 @@ object SRAMGroup {
188217 }
189218 case _ => List ()
190219 }
191- Some (SRAMGroup (name, family, vt, mux, depth, width, ports, extraPorts))
220+ Some (SRAMGroup (name, family, vt, mux, depth, width, triples, ports, extraPorts))
192221 }
193222}
194223
0 commit comments