Code Monkey home page Code Monkey logo

Comments (3)

quark17 avatar quark17 commented on July 3, 2024

The values should be zero-extended; if Bluesim is not doing that, that's a bug. Your example is showing a bug specifically for reading in "wide" data (width > 64), but it would be worth checking the behavior for all the types that Bluesim supports: tUInt8 (for bit vectors up to width 8), tUInt32 (up to 32), tUInt64 (up to 64), and tUWide (65+). Your example is not predictable -- sometimes the values in memory are already zero, so no error is reported -- so I'm unsure how we can add it to the testsuite. Also, we should test the situation when too many digits are provided -- Bluesim should at least report a warning, and it shouldn't overflow the storage and keep writing the digits into memory (but, again, I'm unsure how to test that). We should at least do a manual inspection of the Bluesim code, though.

The code for reading in a memhex file is in bsc/src/bluesim/mem_file.cxx, specifically in the overloaded functions parse_hex and parse_bin (as declared in the header bs_mem_file.h). These are overloaded for each the data types (tUInt8, tUInt32, tUInt64, and tUWide). Wide data is an array of unsigned int. For parsing in wide data, the function goes to the last digit in the string and works its way to front; it accumulates the value for each unsigned int and then writes it to the place in the array. If there is not a full word of digits left at the end, the code writes the value to the full word -- so it is zero-extending up to the word boundary. The problem is that there may be more words in the wide value, and nothing writes zeros into those final words.

I would guess that, at line 649 in mem_file.cxx (for parsing hex) and line 591 (for parsing binary), we should adjust/add something like this (note the addition of ++ in the partial word assignment):

// write partial word at end
if (idx != 0)
  (*value)[word++] = x;

// zero extend any unspecified words
while (word < (data_bits % WORD_SIZE))
  (*value)[word++] = 0;

from bsc.

quark17 avatar quark17 commented on July 3, 2024

FYI, some testing of RegFile load for Bluesim happens in bsc.bluesim/misc/ in the files WideRF.bsv, WindowsRF.bsv, and SparseRF.bsv. I would guess that tests for fewer and greater digits (for bin and hex, and for each of the data types) would go in that directory as well.

from bsc.

rossc719g avatar rossc719g commented on July 3, 2024

FWIW, I believe it already does complain if you provide too many digits.

from bsc.

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.