Commit 05d1f2b4 authored by apaj's avatar apaj
Browse files

Adapted example FullAdder

parent 2be7f81a
Loading
Loading
Loading
Loading
+19 −18
Original line number Diff line number Diff line
// See LICENSE.txt for license details.
// January 20th, 2018	-adapted to Learning Journey

package examples

import chisel3._
import Chisel._

class FullAdder extends Module { 
  val io = IO(new Bundle {
    val a    = Input(UInt(1.W))
    val b    = Input(UInt(1.W))
    val cin  = Input(UInt(1.W))
    val sum  = Output(UInt(1.W))
    val cout = Output(UInt(1.W))
  })

  val io = new Bundle { 
    val a    = UInt(INPUT, 1) 
    val b    = UInt(INPUT, 1) 
    val cin  = UInt(INPUT, 1) 
    val sum  = UInt(OUTPUT, 1) 
    val cout = UInt(OUTPUT, 1) 
  } 
  // Generate the sum 
  val a_xor_b = io.a ^ io.b 
  io.sum := a_xor_b ^ io.cin