Giter Club home page Giter Club logo

Comments (3)

rachitnigam avatar rachitnigam commented on June 19, 2024 1

Alternative proposal: If shrink forces the step size to be the same as the width, the compilation looks like:

decl a: bit<10>[16 bank 8];
decl b: bit<10>[8];

for (let i = 0..8) {
  view v_a = shrink a[i:2]
  b[i] = v_a[0] + 2*v_a[1]
}

compiles to:

for (let i = 0..8) {
  b[i] = v_a[4*i + 0] + 2*v_a[4*i + 1];
}

I propose that we have the explicit syntax:

view v_a = shrink a[4 * i: 4];

where the programmer explicitly specifies 4 * i for the offset and 4 for the width. I think it would reduce mistakes like:

for (let i = 0..12) { // 12 will be OOB!
  view v_a = shrink a[i:2]
  b[i] = v_a[0] + 2*v_a[1]
}

Especially since we don't do any static bounds checking.

from dahlia.

sampsyo avatar sampsyo commented on June 19, 2024
  1. I don't see any immediate problems with any of these three—they all seem like they should probably be fine? It could help to try drawing the "hardware interposer" for each to make sure they seem to have roughly predictable cost.

  2. I think those restrictions make sense, yes.

  3. Some rough ideas, based on previous discussions:

     let v = view a[0..+5];  // v is a view on a with offset 0 and width 5
     let a' = shrink a: int[10 bank 5];   // a' is like a, but with banking factor 5
     let a' = shrink a: int[10 bank 5][10 bank 5];   // for multi-dimensional arrays
    

    flex could work the same way. The idea behind the shrink syntax is that it might be nice, for clarity, to write out the new type of the "adapted" memory.

from dahlia.

rachitnigam avatar rachitnigam commented on June 19, 2024

Tracking in #124.

from dahlia.

Related Issues (20)

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.