Giter Club home page Giter Club logo

hw1's Introduction

Homework 1 - Intro to Chisel and Scala

Problem 1 - Bit Extraction & Manipulation (10pts)

Fill in the module RiscvITypeDecoder to practice bit extraction. Given a 32-bit instruction word (instWord) as input, it extracts the fields of a RISC-V I-type instruction (ISA summary). Here are the fields and their bit positions:

Field Positions (inclusive)
opcode 6 - 0
funct3 14 - 12
rs1 19 - 15
rd 11 - 7
immSignExtended 31 - 20 (sign-extend to 32b)

Problem 2 - Write a Chisel Test (20pts)

We can use Scala to write exhaustive tests for a module assuming its input space is relatively small. In this problem, we provide the implementation of MajorityCircuit in the file src/main/scala/hw1/HW1.scala. Your job is to edit the file src/test/scala/hw1/MajorityCircuitTester.scala to fill in the unimplemented test for MajorityCircuit using Chiseltest's peek, poke, and expect. Make sure to test that the output is correct for all 8 possible input values. You may run your test using the command sbt test from your terminal. We strongly encourage you to fill in your own tests for the other problems using src/test/scala/hw1/HW1Tester.scala but they will not be graded.

Problem 3 - Polynomial Evaluator (20pts)

The PolyEval module will be given 3 input coefficients (c0, c1, and c2) at generation time and produce a circuit that computes the polynomial using them and a hardware input x. The circuit will also take an input enable that if true, the output will be the polynomial result, and if false, it will be 0. Fill in the rest of PolyEval.

Parameters (Scala)

  • c0: positive Int (8b)
  • c1: positive Int (8b)
  • c2: positive Int (8b)

Input (Chisel)

  • enable: Bool
  • x: UInt of width 8

Output (Chisel)

  • out: UInt of sufficient width to support growth
    • if enable is high: c0 * x^0 + c1 * x^1 + c2 * x^2
    • if enable is low: 0

Problem 4 - ComplexALU (50pts)

ComplexALU is a generator for an adder/subtractor for complex numbers. If the Chisel input doAdd is high, the module adds the complex numbers, and if it is low, the module subtracts the complex numbers. There is also a Scala parameter (for generation time) onlyAdder, which if true, the generated module should not have any hardware for subtraction logic (and thus ignore doAdd). Fill in ComplexALU, and a summary of its operation is below:

  • if doAdd is high, add the complex numbers (add the real inputs and add the imaginary inputs)
  • if doAdd is low, subtract the complex numbers (find the difference between the real inputs and the difference between the imaginary inputs)
  • if onlyAdder is true, only generate hardware to sum the real inputs and sum the imaginary inputs (ignore doAdd)

hw1's People

Contributors

sbeamer avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.