Saturday, May 9, 2015

Comparators

I'm getting to the point where delays in setting memory values triggered by clock signals need to be synchronized.  When I decode an opcode, I enable the necessary parts and routers to load the register, but the value doesn't update until the next tick.  I'd bet there are ways around this and optimizations that can be made to reduce this to a point.  But I imagine at some point these break down and you just need to bite the bullet and have some sort of pipeline.  While I could try to make my decode happen without pipelining, I'd rather get everything working first and then worry about optimizations later.

So, I need a part that enables subsequent lines after each tick.  A bare part could be made for this, but I decided to just use a counter with a decoder.  But at some point when the decoding is all done, and everything is in place, we'll want to move to the next instruction and begin again, i.e. reset to 0.  To be honest, I'm not sure how many stages I'll need and would rather not make the reset value be hard-wired.

So the idea is to use a constant value connected to a comparator.  When they are equal, I'll reset the pipeline counter and enable a completion signal.  But of course I need a comparator.

I earlier made a part that checked all bit were low, which is a special case of a general comparator.  It just Nor'd the inputs.  To compare bits, XNor has the right truth table.  For 0,0 and 1,1, 1 is the output, otherwise 0.  So I'll just string together 8 going to an And for the 8bit version.  Then for 32bits I'll just chain together 4 of those.

Here's what the 8bit comparator looks like:

And here is the 32bit version.


No comments:

Post a Comment