Skip to content

Commit

Permalink
Add Scalastyle rule to check lines ending with a ;, fix some instances
Browse files Browse the repository at this point in the history
  • Loading branch information
ducky64 authored and palmer-dabbelt committed Nov 2, 2015
1 parent 016d1c2 commit 3fe8122
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 16 deletions.
6 changes: 6 additions & 0 deletions scalastyle-config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@
<check level="warning" class="org.scalastyle.scalariform.NoFinalizeChecker" enabled="true"></check>
<check level="warning" class="org.scalastyle.scalariform.CovariantEqualsChecker" enabled="true"></check>
<check level="warning" class="org.scalastyle.scalariform.StructuralTypeChecker" enabled="true"></check>
<check level="warning" class="org.scalastyle.file.RegexChecker" enabled="true">
<parameters>
<parameter name="regex"><![CDATA[;(\r|)\n]]></parameter>
</parameters>
<customMessage>No lines ending with a ;</customMessage>
</check>
<check level="warning" class="org.scalastyle.file.RegexChecker" enabled="true">
<parameters>
<parameter name="regex"><![CDATA[println]]></parameter>
Expand Down
6 changes: 6 additions & 0 deletions scalastyle-test-config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@
<check level="warning" class="org.scalastyle.scalariform.NoFinalizeChecker" enabled="true"></check>
<check level="warning" class="org.scalastyle.scalariform.CovariantEqualsChecker" enabled="true"></check>
<check level="warning" class="org.scalastyle.scalariform.StructuralTypeChecker" enabled="true"></check>
<check level="warning" class="org.scalastyle.file.RegexChecker" enabled="true">
<parameters>
<parameter name="regex"><![CDATA[^.*;(\r|)\n]]></parameter>
</parameters>
<customMessage>No lines ending with a ;</customMessage>
</check>
<check level="warning" class="org.scalastyle.file.RegexChecker" enabled="true">
<parameters>
<parameter name="regex"><![CDATA[println]]></parameter>
Expand Down
24 changes: 12 additions & 12 deletions src/main/scala/Chisel/Bits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -200,53 +200,53 @@ object Bits extends UIntFactory
* types.
*/
abstract trait Num[T <: Data] {
// def << (b: T): T;
// def >> (b: T): T;
//def unary_-(): T;
// def << (b: T): T
// def >> (b: T): T
//def unary_-(): T

// REVIEW TODO: double check ops conventions against FIRRTL

/** Outputs the sum of `this` and `b`. The resulting width is the max of the
* operands plus 1 (should not overflow).
*/
def + (b: T): T;
def + (b: T): T

/** Outputs the product of `this` and `b`. The resulting width is the sum of
* the operands.
*
* @note can generate a single-cycle multiplier, which can result in
* significant cycle time and area costs
*/
def * (b: T): T;
def * (b: T): T

/** Outputs the quotient of `this` and `b`.
*
* TODO: full rules
*/
def / (b: T): T;
def / (b: T): T

def % (b: T): T;
def % (b: T): T

/** Outputs the difference of `this` and `b`. The resulting width is the max
* of the operands plus 1 (should not overflow).
*/
def - (b: T): T;
def - (b: T): T

/** Outputs true if `this` < `b`.
*/
def < (b: T): Bool;
def < (b: T): Bool

/** Outputs true if `this` <= `b`.
*/
def <= (b: T): Bool;
def <= (b: T): Bool

/** Outputs true if `this` > `b`.
*/
def > (b: T): Bool;
def > (b: T): Bool

/** Outputs true if `this` >= `b`.
*/
def >= (b: T): Bool;
def >= (b: T): Bool

/** Outputs the minimum of `this` and `b`. The resulting width is the max of
* the operands. Generates a comparison followed by a mux.
Expand Down
8 changes: 4 additions & 4 deletions src/main/scala/Chisel/util/Mux.scala
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ object MuxLookup {
* @return the value found or the default if not
*/
def apply[S <: UInt, T <: Bits] (key: S, default: T, mapping: Seq[(S, T)]): T = {
var res = default;
var res = default
for ((k, v) <- mapping.reverse)
res = Mux(k === key, v, res);
res = Mux(k === key, v, res)
res
}

Expand All @@ -66,9 +66,9 @@ object MuxCase {
* @param mapping a set of data values with associated enables
* @return the first value in mapping that is enabled */
def apply[T <: Bits] (default: T, mapping: Seq[(Bool, T)]): T = {
var res = default;
var res = default
for ((t, v) <- mapping.reverse){
res = Mux(t, v, res);
res = Mux(t, v, res)
}
res
}
Expand Down

0 comments on commit 3fe8122

Please sign in to comment.