Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var product: Bus = aa.host.inputs(aa.length + bb.length)
- var multiplier: Bus = aa.host.inputs(aa.length + bb.length)
- var multiplicand: Bus = bb.host.inputs(aa.length + bb.length)
- var adder: Bus = buildAdder(product, multiplier && multiplicand(0))
- product.buildFeedback(adder)
- var anyTrueGate: Gate = new ConstantGate(multiplicand.host, false)
- for (i <- 0 until multiplicand.length)
- anyTrueGate = anyTrueGate || multiplicand(i)
- var anyTrueGate2: Gate = new ConstantGate(multiplier.host, false)
- for (i <- 0 until multiplier.length)
- anyTrueGate2 = anyTrueGate2 || multiplier(i)
- var readyGate: Gate = !loadEnable && (!anyTrueGate || !anyTrueGate2)
- // build shift feedbacks.
- var zero: Bus = aa.host.falses(1);
- multiplier(0).buildFeedback(aa(0) && loadEnable)
- for(i <- 1 until multiplier.length-1) {
- if(i < aa.length) {
- multiplier(i).buildFeedback((multiplier(i-1) && !loadEnable) || (aa(i) && loadEnable))
- } else {
- multiplier(i).buildFeedback(multiplier(i-1) && !loadEnable)
- }
- }
- for(i <- 1 until multiplicand.length) {
- if(i <= bb.length) {
- multiplicand(i-1).buildFeedback((multiplicand(i) && !loadEnable) || (bb(i-1) && loadEnable))
- } else {
- multiplicand(i-1).buildFeedback(multiplicand(i) && !loadEnable)
- }
- }
- // check whether multiplication is ready.
- // (~operands).values.reduce((A,B) => A & B)
- // final product with adder.
- //product = buildAdder(product, multiplicand /* && multiplier(0)*/)
- (readyGate, product)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement