dsatizabal / tt03-dsp-4bits-sequential-alu

4-bits sequential ALU for Tiny Tapeout 03

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

4-bits sequential ALU

This ALU takes 4-bits wide operators (2) and opcode (1) sequentially trhough the 4 MSBs of io_in (please refer to TinyTapeout specs for details).

Supported operations are:

  • Sum (opcode = 0)
  • Substracion (opcode = 1)
  • Logical AND (opcode = 2)
  • Logical OR (opcode = 3)
  • Logical NOT (opcode = 4)
  • Logical NAND (opcode = 5)
  • Logical NOR (opcode = 6)
  • Rotate Left (opcode = 7)
  • Rotate Right (opcode = 8)
  • Swap (opcode = 9)
  • Compare (opcode = 10)

pins

All pins follow positive logic so active state is a high voltage level.

inputs

  • io_in[0] = external clock
  • io_in[1] = reset
  • io_in[2] = enabled
  • io_in[3] = unused
  • io_in[7:4] = data in

outputs

  • io_out[3:0] = result
  • io_in[4] = done flag
  • io_in[5] = carry flag
  • io_in[6] = zero flag
  • io_in[7] = sign flag

Operation

When reset input is set to high for at least one clock cycle, the result and all flags are set to 0 as default values.

If clock continues but enabled input is low then ALU does not operates and maintains any previous state.

When enabled input is set to high, the ALU will fetch sequentially operand_1, operand_2 and opcode on every positive edge of the clock, it takes an additional clock cycle to calculate and output results for a total of 4 clock cycles to perform every operation.

It is important to note that:

  • If no clock signal is given the ALU won't operate.
  • For operations that require a single operand, like Logical NOT or rotation, it's still required to provide the second operand and the corresponding clock cycle to fetch it, the value of this second operand is ignored when performing such operations.

If the result of the operation is 0 the the zero flag will be activated. It is verified that the result involves sign and/or carry for SUM and SUB operations, the corresponding flag is set to high if applicable. On the 4th clock cycle of every operation the calculations are performed, result placed for output and done flag is set to high.

Details for some operations

The operationd Rotate Left and Rotate Right rotate the operand_1 in a loop, that is, if operand_1 is 1001 and you perform RL operation the result will be 0011, for RR operation the result will be 1100, operand_2 is ignored.

The operation swap peforms a nibble-like swap operation for 8-bits register but for the 4-bits operand_1, that is, if operand_1 has the value 1100 the result will be 0011, operannd_2 is ignored.

The operation compare performs comparison for equal, greater than and lower that between operand_1 and operand_2 in that order, that is:

  • if operand_1 is equal to operand_2 the result will be 1
  • if operand_1 lower than operand_2 the result will be 2
  • if operand_1 is greater than operand_2 the result will be 4

Acknowldgements

This project was made as part of the Zero2ASIC course using the Tiny Tapeout project (more info below) which I absolutely recommend the reader to checkout and enroll. Special thanks to Matt Venn and all the Zero2ASIC community for the constant support and knowledge sharing.

What is Tiny Tapeout?

TinyTapeout is an educational project that aims to make it easier and cheaper than ever to get your digital designs manufactured on a real chip!

Go to https://tinytapeout.com for instructions!

How to change the Wokwi project

Edit the info.yaml and change the wokwi_id to match your project.

How to enable the GitHub actions to build the ASIC files

Please see the instructions for:

How does it work?

When you edit the info.yaml to choose a different ID, the GitHub Action will fetch the digital netlist of your design from Wokwi.

After that, the action uses the open source ASIC tool called OpenLane to build the files needed to fabricate an ASIC.

Resources

What next?

About

4-bits sequential ALU for Tiny Tapeout 03

License:Apache License 2.0


Languages

Language:Python 58.0%Language:Verilog 28.3%Language:Tcl 8.1%Language:Makefile 5.6%