MO801/MC912

Topics in Architecture and Hardware

Second Work

The first work consists of implementing a coin counter circuit restricted to old coins of R$0,01, R$0,05, R$0,10, R$0,50 and R$1,00. Use the entity below:
entity counter is
port (clk : in std_logic;
resetn : in std_logic;
sensor : in std_logic_vector(0 to 4);
total: out natural
);
end entity counter;

Coin counter scheme

All names must be identical to those described above. Use the following convention for signals:
clk
Active clock on rising edge
reset
Circuit reset, active at zero. When a reset occurs, the total value must be turned to zero
sensor Sensor signals vector. sensor(i) = '1' means that there is an object blocking the i-th sensor. 
total Total value so far. The total amount should be updated whenever, and only when, the currency has finished passing through the sensors.

Your circuit must be synchronous and only make changes to the output in the rise pulses of clk.

debounce

All signals coming from sensors can experience unwanted oscillations during transitions. These oscillations must be removed through a special circuit to effect the debounce of the sign. To eliminate them, the circuit of debounce should only consider stable a signal that has the same value per n successive cycles. In the case of this work, we will use n=7. Make your circuit parameterizable (use generic).

testbench

Implement a Testbench for your circuit. Test as many cases as you deem necessary to prove the specified functionality.

Synthesis

Your circuit must be synthesizable with Leonardo. Test it out before handing in the work. For synthesis, use the FPGA Xilinx Virtex v800hq240-4.

Report

Submit a short report about the work.

Example


Coin counter sample waveform. Notice that:
  • Sensor 4 cannot be considered if we work with more than 3 cycles of debounce (in blue).
  • Sensor 0 will not be considered for the second time if we work with more than 2 cycles of debounce (in yellow).
  • Coin counting should only be done in the time indicated in green (assume in this case that the debounce It has already been done).
In this example, given that sensor 3 has been stable for more than n=7 cycles, the currency counted is R$0,50.