Project 2 - Recursion

Im trying to look up recursion in logism with no luck, ive come upon some example with subcircuits but the fan-in is always lower meaning it isnt really the same circuit.

The hints given to us arent really helpfull since b isnt defined earlier in the text
there isnt much material on logisim out there.

are we supposed to create mutliple circuits? for each n possible in the recursion?
i.e b2g3, b2g2, b2g1

In order to do recursion, you must create the previous circuits, as you said.
For example, you need to create the base case b2g1, then implement b2g2 using b2g1 as a component, b2g3 using b2g2 as a component, and so on.

b[n - 1 : 0] is the input. I’ve updated the file to make it clear.

1 Like

Thank you, this helps very much.

Does that means we can add circuits in the template file named b2g#(numer of inputs) - as we were told not to create different files/libraries,
Or we need to do all the “sub” recurtions circuits in the main file?

You need to add circuits in the same file, but not in different files.
Look at this screenshot for example.

This is a bad ex. right?
Wer’e supposed to submit only one file inside with the b2g4 name?

Thanks in advance.

No, this is a correct example. There are 4 circuits in the same file. You are allowed to have as many circuits you like within a single Logisim (.circ) file.

My question is if it is okay to have all the circuits in the b2g4 file,
and use them as tunnels, without opening new files at all?

Thank you

Meitar

It is not wrong, but it’s not recommended. As far as possible, keep your designs modular, just like you would make functions when you’re writing a program, instead of dumping everything inside your main().

Modular designs are better as they are more manageable and understandable.

Are there rules for the recursion implementation?
Obviously the first and most important rule is to use the lower case when implementing the solution, as described in the comments above,
But does the circuits must have the same design, differ (almost) only in the bit width? Beside the base case.

Yes, the circuit must have the same basic design.
The point of a recursive function/design is the same idea is repeated on all levels except for the base level. For example, f(n) must call f(n - 1) not some other g(n - 1).

1 Like