0

I am trying to design the following:

  • The datapath of an octal calculator which has a 24-bit input register in reg and a 24-bit accumulator acc.
  • The contents of both registers are displayed as eight octal (radix-8) digits. Both are cleared on reset.
  • The calculator has buttons for C (clear), the numbers 0-7, and the functions +, -, and x. Pressing C once clears in reg.
  • Pressing C a second time with no other intervening keys clears acc. Pressing a number shifts in reg to the left three bits and puts the number pressed into the low three bits.
  • Pressing a function performs that function on the two registers and puts the result in acc. Draw a block diagram from the datapath of this calculator

What I have so far is:

  • reg_in and acc flip flops, with the same clock and reset
  • an ALU(performing function operations) taking in input from in_reg and acc and outputting back into in_reg, driven by an ALUselect signal
  • a shift register to shift the input bits by 3 and put them back into the reg_in

However, the part that I am stuck on is how to implement the "pressing C" part. What design choice can I make which will allow me to clear reg_in if C is pressed once and clear acc if C is pressed again? I want to a find a simpler method than using a counter.

Any help is appreciated!

aa1
  • 783
  • 1
  • 15
  • 31

1 Answers1

1

Additional one-bit register should solve the problem. Let's call it last_button.

  • Set last_button to 1 if C is pressed and last_button is previously 0.
  • Set last_button to 0 if another button is pressed.
  • If last_button is 0 when C is pressed, clear reg_in.
  • If last_button is 1 when C is pressed, clear acc.
  • In case acc is cleared, clear last_button to 0 as well.

You can assume this logic is a Mealy machine with 2 states, then last_button is the state signal. C button always toggles the state, other buttons set the state to zero. The outputs (clear reg_in/acc) of the machine depend on both the inputs (buttons) and the current state.