Skip to content

Commit e94b611

Browse files
committed
Describe flags register
1 parent 45ed844 commit e94b611

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

hardware.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,31 @@ Technically this is solved using the XOR gates and `S-`. The B register is conne
319319

320320
## Flags Register
321321

322-
TODO
322+
Register used for flags.
323+
324+
Flags are 1 bit values (0 or 1 / false or true) that can be stored and used for making decisions by the instruction decoder.
325+
326+
The flags are:
327+
- Carry: whether the ALU calculation results in a number larger than 8 bit (255) and has wrapped around.
328+
- Zero: whether the ALU calculation results in 0.
329+
330+
I included the circuitry for the zero bit here, but it can be debated whether it's part of the ALU or the flags register. I chose here, because the ALU by itself does not use the extra chips for anything, while the flags register depend on them.
331+
332+
* Chips
333+
* 74LS173 register: for storing the 2 flags.
334+
* 74LS02 NOR gate: these gates make up the circuit that will detect if all the bits from the result in the ALU is 0. This becomes the zero bit.
335+
* 74LS08 AND gate: see above.
336+
* Inputs
337+
* Carry bit: from the ALU.
338+
* 8-bit result from the ALU: for checking for 0.
339+
* Outputs
340+
* 1-bit carry flag: goes directly into the instruction decoder.
341+
* 1-bit zero flag: goes directly into the instruction decoder.
342+
* LEDs
343+
* 2x Green: for showing the value of the flags.
344+
* 1x Blue: for showing the value of the zero bit.
345+
* Control lines
346+
* Flags register in: stores the current value of the carry bit and zero bit into the register, on the next clock tick.
323347

324348

325349
## Output Register

0 commit comments

Comments
 (0)