Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PP Code Explanation
- The Arduino implementation is largely similar to the Breadboard implementation, from its steps to its logic.
- To begin, we declare multiple variables:
- Line 01: an int clock, starting at 0, which serves as an internal timer.
- Line 02: an int nibbleselector, which holds the state of the machine (show upper, lower, or sum of nibbles).
- Line 03-06: assignments of input pins (relative to ROM). The Arduino module will output a 4-bit binary integer with D as most signifiant.
- Line 07-14: assignments of output pins (relative to ROM). The Arduino module will accept an 8-bit binary integer with 7 as most signifianct.
- The void setup() block (Lines 16-29) uses pinMode() function to properly assign Lines 03-06 as input and Lines 07-14 as output.
- Phase 1: The I-Region
- Step 1: The Clock to Binary Encoder
- The Arduino module uses the value of int clock to determine the amount of seconds passed. Int clock increments by 1 every second via the delay(1000) at Line 148-149. Int clock would also reset to 0 once it increments to 8 (Line 150). This simulates a clock ticking every second. The value of clock would be checked by a series of if-elseif blocks (Line 34-81) which converts the decimal into a 4-bit binary integer. Each bit would be fed into the ROM via parallel-out wire system thingy.
- The result would be an 8-bit binary integer called I-REGION fed into the Arduino module from the ROM.
- Step 2: The Nibble Selector
- The I-REGION is divided into two parts, OPCODE (Operational Code) and DREG-AD (D-REGION Address). OPCODE is a 5-bit integer from 0x03 to 0x07.
- An OPCODE of 00000 would set the machine to State 0, 00001 to State 1, and 00010 to State 2. No other states exist. Since the OPCODEs differ
- only in the two least significant digits, only 0x04 and 0x03 would be used.
- Lines 84-85 assign the two digits to variables, mage1 and mage2. These two variables then decide the machine state, nibbleselector, via conditional statements (Line 86-94).
- Phase 2: The D-Region
- Step 1: DREG-AD Quicksave
- The DREG-AD from the I-Region is temporarily saved on variables "dregionaddress" (Lines 98-100).
- Step 2: DREG-AD to ROM
- The Arduino module will feed dregionaddresses as inputs to the ROM IC. Note that ROMinput_D, the most signficant bit, will always be HIGH in order to access 0x08 to 0x0F in the ROM.
- The result is an 8-bit integer from the ROM fed into Arduino via wires.
- Step 3: DREGION Quicksave
- Each integer is saved into 8 variables "dvaluei" where i is [0,7]. (Line 109-116).
- Step 4: Actual Thingy
- Using the value of nibbleselector, the machine would perform one of three actions, dictated by if-elseif statements:
- Line 119-123: A nibbleselector value of 0 makes the Arduino module output the upper nibble (dvalue7 to dvalue4 where 7 is MSB).
- Line 125-130: A nibbleselector value of 1 makes the Arduino module output the lower nibble (dvalue3 to dvalue0 where 3 is MSB).
- Line 131-144: A nibbleselector value of 2 makes the Arduino do some crazy math stuff. The upper and lower nibbles are treated as two 4-bit integers, which will undergo a painful addition process via adders.
- Addition is composed of two parts: produceSum (Line153-178) which is a complicated XOR gate with fan-in of 3. produceCarry (Line 180-205) is a set of three AND gates with fan-in of 2 and an OR gate with fan in of 3.
- These two parts basically replicate a logic-gate ripple carry adder or whatever it's called.
- In all three states, the Arduino module would produce an output via the Analog Out pins, which are connected to a BCD-to-7segment display thingy.
- And there you go. please give me 3.0 plz
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement