ucb-bar / chisel2-deprecated

chisel.eecs.berkeley.edu
388 stars 90 forks source link

Added a pokePart method to Tester #683

Closed JackDavidson closed 8 years ago

JackDavidson commented 8 years ago

I've often found myself wishing that I could poke I/O in CHISEL tests on only the bits I want to change, rather than having to always poke an entire io object at once.

This commit adds a pokePart(data, hi, lo, x) function to the tester, which allows poking subparts of i/o objects. It also changes the error when you try to run something like: poke(c.io.a(2,0), 0x4) and suggests that you might have meant to use pokePart. The majority of users who get the error will probably be trying to do something like pokePart. The above example then becomes: pokePart(c.io.a, 2, 0, 0x4)

the way the method works is to simply take the old value for the data (or initialize to 0 if there is none to be found) and apply some masking to change only the desired bits.

ghost commented 8 years ago

Can one of the admins verify this patch?

ucbjrl commented 8 years ago

@JackDavidson, unfortunately, this will need some rework as a result of the (very) recent changes to the Tester by @donggyukim. Before you put too much work into this, we should investigate its implications for Chisel3 and "testers as hardware". Take a look at the hwiotesters package in src/main/scala and see what would be required to integrate this into the SteppedHWIOTester.

JackDavidson commented 8 years ago

@ucbjrl I'm looking at the code, and it looks like it would be easy enough to add to SteppedHWIOTester. I could just look at the previous step rather than the current step. I would be calling the existing poke anyway, so everything would work as expected. It would be a one-line change to my existing code, actually.

I am a little confused why you would want a testing system that requires you to step every time you update your inputs though? I regularly have outputs in lower level modules that are based directly on inputs. For those sub-modules, I run lots of input tests and never step.

edit: I can see how tests would be much cleaner and more extensible using this system. We may want to differentiate between a 'step' and a 'cycle' though

JackDavidson commented 8 years ago

Alright, I'm dropping this for now. After CHISEL 3 is released and I can actually see the new testing framework, I'll probably bring it back up