Advertisement
Guest User

Untitled

a guest
Mar 14th, 2014
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 1.59 KB | None | 0 0
  1.     var product: Bus = aa.host.inputs(aa.length + bb.length)
  2.     var multiplier: Bus = aa.host.inputs(aa.length + bb.length)
  3.     var multiplicand: Bus = bb.host.inputs(aa.length + bb.length)
  4.     var adder: Bus = buildAdder(product, multiplier && multiplicand(0))
  5.     product.buildFeedback(adder)
  6.    
  7.     var anyTrueGate: Gate = new ConstantGate(multiplicand.host, false)
  8.     for (i <- 0 until multiplicand.length)
  9.       anyTrueGate = anyTrueGate || multiplicand(i)
  10.     var anyTrueGate2: Gate = new ConstantGate(multiplier.host, false)
  11.     for (i <- 0 until multiplier.length)
  12.       anyTrueGate2 = anyTrueGate2 || multiplier(i)
  13.     var readyGate: Gate = !loadEnable && (!anyTrueGate || !anyTrueGate2)
  14.    
  15.     // build shift feedbacks.
  16.     var zero: Bus = aa.host.falses(1);
  17.     multiplier(0).buildFeedback(aa(0) && loadEnable)
  18.     for(i <- 1 until multiplier.length-1) {
  19.       if(i < aa.length) {
  20.         multiplier(i).buildFeedback((multiplier(i-1) && !loadEnable) || (aa(i) && loadEnable))
  21.       } else {
  22.         multiplier(i).buildFeedback(multiplier(i-1) && !loadEnable)
  23.       }
  24.     }
  25.     for(i <- 1 until multiplicand.length) {
  26.       if(i <= bb.length) {
  27.         multiplicand(i-1).buildFeedback((multiplicand(i) && !loadEnable) || (bb(i-1) && loadEnable))
  28.       } else {
  29.         multiplicand(i-1).buildFeedback(multiplicand(i) && !loadEnable)
  30.       }
  31.     }
  32.    
  33.     // check whether multiplication is ready.
  34.     // (~operands).values.reduce((A,B) => A & B)
  35.    
  36.     // final product with adder.
  37.    //product = buildAdder(product, multiplicand /* && multiplier(0)*/)
  38.    
  39.     (readyGate, product)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement