question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

shift right does not complain about shift size greater than width

See original GitHub issue

The firrtl spec 7.12

The shift right operation truncates the least significant n bits from e. n must be non-negative and strictly less than the bit width of e.

The following code, run with n = 8, 9, 10

class BrokenShifter(n: Int) extends Module {
  val io = IO(new Bundle {
    val i = Input(FixedPoint(8.W, 4.BP))
    val o = Output(FixedPoint(8.W, 4.BP))
    val si = Input(SInt(8.W))
    val so = Output(SInt(8.W))
  })
  io.o := io.i >> n
  io.so := io.si >> n
}

generates the following firrtl, which is processed without complaint.

circuit BrokenShifter : 
  module BrokenShifter : 
    input clock : Clock
    input reset : UInt<1>
    output io : {flip i : Fixed<8><<4>>, o : Fixed<8><<4>>, flip si : SInt<8>, so : SInt<8>}
    
    io is invalid
    io is invalid
    node _T_10 = shr(io.i, 9) @[FixedPointSpec.scala 135:16]
    io.o <= _T_10 @[FixedPointSpec.scala 135:8]
    node _T_11 = shr(io.si, 9) @[FixedPointSpec.scala 136:18]
    io.so <= _T_11 @[FixedPointSpec.scala 136:9]
    

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
chickcommented, Feb 20, 2017

ok, seems like I should just update the firrtl spec

0reactions
azidarcommented, Dec 15, 2017

Resolution: need update spec.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Shifting unsigned int more than the size of it, undefined or not?
J. 2 Undefined behavior An expression is shifted by a negative number or by an amount greater than or equal to the width...
Read more >
INT34-C. Do not shift an expression by a negative number of ...
This rule uses precision instead of width because, in almost every case, an attempt to shift by a number of bits greater than...
Read more >
Salomon / Atomic / Armada SHIFT MNC Binding - Blister Review
The Shift is a very powerful binding with a noticeably-more-plush ride than a traditional tech binding. We haven't yet directly A/B'd it against ......
Read more >
Using full-sized subfloats causes them to shift to the right - TeX
When using subfloats (with the subfig package) to include graphics at the full text/column width, the graphics seem to be shifted to the...
Read more >
health_hazards_workbook.pdf
Course participants will learn how to anticipate, recognize, evaluate and control occupational health hazards; these hazards include, but are not limited to:.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found