# Homework Help: Is data input clocked?

1. Nov 29, 2011

### perplexabot

Hi all.

The question says:

Use the RTL design process to design a system that outputs the average of the most recent two data input samples. The system has an 8-bit unsigned data input I, and an 8-bit unsigned output avg. The data input is sampled when a single-bit input S changes from 0 to 1. Choose internal bitwidths that prevent overflow.

I have two questions. Firstly, is the data input sent following a clock cycle? If not, how do you know when a new datum is sent?

Secondly, how can you tell if the first two bytes are the same byte or different bytes but with equivalent values?

Thank you

2. Nov 29, 2011

### Staff: Mentor

It sounds like the data changes on the 1 --> 0 transition of the sample clock "S", and you should clock the data into your input register on the 0 --> 1 edge.

For each 0 --> 1 clock edge, you will clock in the new byte and clock the previous new byte into another register. Then what do you have to do with those two registers to take the average?

3. Nov 29, 2011

### perplexabot

Oh I see. So the data input is implicitly half a cycle out phase with the register clocks (do I have the idea right?). I was actually thinking about using a clock divider, but I guess not any more.

And to answer your question, to take the average you would use an adder then a bit shifter (right shifter), am I right?

The computation is not my problem, it is how to store the first two bytes that is the problem for me. I'm going to give it another try with your comment in mind. Thanks for the reply.

4. Nov 29, 2011

### Staff: Mentor

Yep. That's a pretty typical way that you manage your clocked systems.

Yep again!

5. Nov 29, 2011

### perplexabot

Wow, that's great. Another question if you don't mind me asking.

I am assuming you are implying to use two registers. But can this not be done with only one register (the other "register" would be the data from the data line)?

6. Nov 29, 2011

### Staff: Mentor

The traditional synchronous way to do this would have 3 clocked 8-bit registers. The input register, the intermediate register, and the output register. What configuration are you thinking about exactly? And can you see some limitations with using less than 3 8-bit registers?

7. Nov 29, 2011

### perplexabot

I was thinking (a rough algorithm):
clock the first data (rising edge) into input register
clock every other data (rising edge) into input register
when not clocking data into register on rising edge : use current data in dataline and register to compute.

I have not heard of the traditional method that you have mentioned, and no i can not see the limitations of using less than 3 registers.

PS: sorry for the misplaced thread

8. Nov 29, 2011

### Staff: Mentor

Well, if you had a lot more information about the timing of the input data stream, you might be able to make something work using both edges of the clock (if the data changed right after the 0 --> 1 clock edge, and was stable soon enough to meet the setup time requirements for the logic being clocked on the 1 --> 0 edge. But that's not usually how synchronous systems work. Generally only one clock edge is used as the "clock" to latch things into registers and flip-flops.

9. Nov 29, 2011

### perplexabot

I am not using both edges. I am using only the rising edges.

10. Nov 29, 2011

### Staff: Mentor

But how are you going to "use current data in dataline" as part of the computation when it is changing between rising clock edges....?

11. Nov 29, 2011

### perplexabot

Wow again, now I get what you meant by
. Ok so theoretically speaking, if the data in the dataline was stable at the moment when a computation called for it, then it would work. Is this correct? But, yes obviously this is very tedious, so I must change my approach.

12. Nov 29, 2011

### Staff: Mentor

Sounds like you get it. Good job!

13. Nov 29, 2011

### perplexabot

14. Nov 29, 2011

### perplexabot

I have used 3 registers as you have mentioned. My output register contains the final computation (which I am using to send to a display). Should the period of the output register clock be twice as "S" since you need to go through two cycles of "S" to get a final output?

15. Nov 29, 2011

### Staff: Mentor

It takes two clock cycles to load the queue. After that, each clock does what the problem statement asks for. You should probably state that in your homework submission.

For extra credit (at the PF if not in your class), how do the setup and hold time specs relate to the maximum clock frequency of your solution?

16. Nov 29, 2011

### Staff: Mentor

Just out of curiosity, do students like you in the hyper-modern era cite Internet forum help threads as part of your online solutions?

EDIT -- Not being judgemental, just curious...

17. Nov 29, 2011

### perplexabot

Sorry for the late reply, was taking a study break.

- I still don't understand how the final register's clock relates to S. I am NOT asking for answers, I am asking for help.

- I don't understand your question (Oops! ). Specifically, what do you mean by "setup and hold time."

- I haven't thought of citing (and I haven't done so before). However, I would not mind doing so. As a matter of fact, I will do so for this homework (since you have helped extensively). I would like to let you know however, I highly doubt this homework is checked. Unfortunately we never get our homework back and I never know whether my design is correct. That is why I am here double checking if I am understanding the concepts. I have a bad professor (good person, bad teacher).

18. Nov 29, 2011

### Staff: Mentor

All good responses.

And please post a sketch of your solution so far. I think you are very close to the solution.

19. Nov 29, 2011

### perplexabot

Here is my current work. Sorry about the bad quality but that is all I have. In the mean time I will google set up time and hold time. I think I have to get rid of the last register (output register). For the datapath image the boxes that are NOT the shifter and adder are registers.

#### Attached Files:

File size:
29.7 KB
Views:
153
• ###### control.jpg
File size:
31.3 KB
Views:
143
20. Nov 30, 2011

### perplexabot

After some reading and researching I think I got the answer to :
The setup time should be enough for the byte to travel to the gates of the register (or the register to read the data) and the hold time should be enough for the data to be stable and pass through the register (or the register to act upon data).

I am embarrassed I did not know what hold time and setup time meant.