Spaces:
Sleeping
Sleeping
| from manim import * | |
| class PinDiagram8085(Scene): | |
| def construct(self): | |
| # --- Scene 1: Title and Introduction --- | |
| # Title | |
| title = Text('The 8085 Microprocessor', font_size=48, color=WHITE) | |
| title.to_edge(UP) | |
| self.play(FadeIn(title)) | |
| self.wait(0.5) | |
| # Subtitle | |
| subtitle = Text('Pin Diagram Explanation', font_size=36, color=WHITE) | |
| subtitle.next_to(title, DOWN, buff=0.5) | |
| self.play(FadeIn(subtitle)) | |
| self.wait(1.5) | |
| # Chip body | |
| chip_body = Rectangle(width=6, height=4, color=GREY, fill_opacity=0.2, stroke_width=2) | |
| chip_body.move_to(ORIGIN) | |
| self.play(Create(chip_body)) | |
| self.wait(0.5) | |
| # Chip label | |
| chip_label = Text('8085', font_size=48, color=WHITE) | |
| chip_label.move_to(chip_body.get_center()) | |
| self.play(FadeIn(chip_label)) | |
| self.wait(1.5) | |
| # Store chip objects for later use | |
| self.chip_group = VGroup(chip_body, chip_label) | |
| # --- Scene 2: Full Pin Diagram Layout --- | |
| # Define pin data (Number, Name, Side) | |
| pin_data = [ | |
| (1, "X1", "left"), (2, "X2", "left"), (3, "RESET OUT", "left"), (4, "SOD", "left"), (5, "SID", "left"), | |
| (6, "TRAP", "left"), (7, "RST 7.5", "left"), (8, "RST 6.5", "left"), (9, "RST 5.5", "left"), (10, "INTR", "left"), | |
| (11, "INTA", "left"), (12, "AD0", "left"), (13, "AD1", "left"), (14, "AD2", "left"), (15, "AD3", "left"), | |
| (16, "AD4", "left"), (17, "AD5", "left"), (18, "AD6", "left"), (19, "AD7", "left"), (20, "Vss", "left"), | |
| (21, "A8", "right"), (22, "A9", "right"), (23, "A10", "right"), (24, "A11", "right"), (25, "A12", "right"), | |
| (26, "A13", "right"), (27, "A14", "right"), (28, "A15", "right"), (29, "S0", "right"), (30, "ALE", "right"), | |
| (31, "WR", "right"), (32, "RD", "right"), (33, "S1", "right"), (34, "IO/M", "right"), (35, "READY", "right"), | |
| (36, "RESET IN", "right"), (37, "CLK OUT", "right"), (38, "HLDA", "right"), (39, "HOLD", "right"), (40, "Vcc", "right") | |
| ] | |
| self.pin_mobjects = {} # Dictionary to store pin objects (line + label) | |
| pin_group = VGroup() | |
| # Calculate vertical spacing | |
| chip_height = chip_body.get_height() | |
| num_pins_side = 20 | |
| # Use 19 gaps for 20 pins | |
| v_spacing = chip_height / (num_pins_side - 1) if num_pins_side > 1 else 0 | |
| # Create and position pins | |
| for number, name, side in pin_data: | |
| if side == "left": | |
| # Pin 1 is top-left, Pin 20 is bottom-left | |
| y_pos = chip_body.get_top()[1] - (number - 1) * v_spacing | |
| pin_line_start = np.array([chip_body.get_left()[0], y_pos, 0]) | |
| pin_line_end = pin_line_start + LEFT * 0.3 | |
| label_pos = pin_line_end + LEFT * 0.3 | |
| label_alignment = RIGHT | |
| else: # side == "right" | |
| # Pin 40 is top-right, Pin 21 is bottom-right | |
| # Map pin number 21-40 to index 0-19 for spacing calculation | |
| index = number - 21 | |
| y_pos = chip_body.get_bottom()[1] + index * v_spacing | |
| pin_line_start = np.array([chip_body.get_right()[0], y_pos, 0]) | |
| pin_line_end = pin_line_start + RIGHT * 0.3 | |
| label_pos = pin_line_end + RIGHT * 0.3 | |
| label_alignment = LEFT | |
| pin_line = Line(pin_line_start, pin_line_end, color=WHITE) | |
| pin_number_text = Text(str(number), font_size=18, color=WHITE) | |
| pin_name_text = Text(name, font_size=18, color=WHITE) | |
| # Arrange number and name | |
| if side == "left": | |
| pin_label_group = VGroup(pin_name_text, pin_number_text).arrange(RIGHT, buff=0.1) | |
| else: # right side, number is usually closer to the chip | |
| pin_label_group = VGroup(pin_number_text, pin_name_text).arrange(RIGHT, buff=0.1) | |
| pin_label_group.move_to(label_pos, aligned_edge=label_alignment) | |
| # Store the pin objects | |
| pin_key = f"{name} (Pin {number})" | |
| self.pin_mobjects[pin_key] = VGroup(pin_line, pin_label_group) | |
| pin_group.add(self.pin_mobjects[pin_key]) | |
| # Animate the creation of all pins | |
| self.play(Create(pin_group), run_time=3) | |
| self.wait(2) | |
| # --- Helper function to highlight pins and restore color --- | |
| def highlight_pins(pin_keys, highlight_color): | |
| mobjects_to_highlight = VGroup(*[self.pin_mobjects[key] for key in pin_keys]) | |
| original_colors = [mob.get_color() for mob in mobjects_to_highlight] # Store original colors | |
| self.play( | |
| *[mob.animate.set_color(highlight_color) for mob in mobjects_to_highlight], | |
| run_time=1 | |
| ) | |
| return mobjects_to_highlight, original_colors | |
| def restore_colors(mobjects, original_colors): | |
| self.play( | |
| *[mob.animate.set_color(original_color) for mob, original_color in zip(mobjects, original_colors)], | |
| run_time=1 | |
| ) | |
| # --- Scene 3: Power and Ground Pins --- | |
| self.wait(0.5) | |
| highlighted_pins, original_colors = highlight_pins(['Vcc (Pin 40)', 'Vss (Pin 20)'], YELLOW) | |
| explanation_text_3 = Tex( | |
| r""" | |
| \textbf{Vcc (Pin 40):} +5V Power Supply \\ | |
| \textbf{Vss (Pin 20):} Ground Reference | |
| """, | |
| tex_environment="center", | |
| font_size=30 | |
| ) | |
| explanation_text_3.to_edge(RIGHT, buff=1) | |
| self.play(FadeIn(explanation_text_3)) | |
| self.wait(2) | |
| self.play(FadeOut(explanation_text_3)) | |
| restore_colors(highlighted_pins, original_colors) | |
| self.wait(0.5) | |
| # --- Scene 4: Clock Signals --- | |
| self.wait(0.5) | |
| highlighted_pins, original_colors = highlight_pins(['X1 (Pin 1)', 'X2 (Pin 2)', 'CLK OUT (Pin 37)'], YELLOW) | |
| explanation_text_4 = Tex( | |
| r""" | |
| \textbf{X1, X2:} Crystal/Oscillator Input \\ | |
| \textbf{CLK OUT:} System Clock Output | |
| """, | |
| font_size=30 | |
| ) | |
| explanation_text_4.to_edge(RIGHT, buff=1) | |
| self.play(FadeIn(explanation_text_4)) | |
| self.wait(0.5) | |
| # Arrow for CLK OUT | |
| clk_out_pin = self.pin_mobjects['CLK OUT (Pin 37)'] | |
| clk_out_arrow = Arrow(clk_out_pin.get_center(), clk_out_pin.get_center() + RIGHT*1.5, color=YELLOW) | |
| self.play(Create(clk_out_arrow)) | |
| self.wait(2.5) | |
| self.play(FadeOut(explanation_text_4), FadeOut(clk_out_arrow)) | |
| restore_colors(highlighted_pins, original_colors) | |
| self.wait(0.5) | |
| # --- Scene 5: Address/Data Bus --- | |
| self.wait(0.5) | |
| ad_pins = ['AD0 (Pin 12)', 'AD1 (Pin 13)', 'AD2 (Pin 14)', 'AD3 (Pin 15)', 'AD4 (Pin 16)', 'AD5 (Pin 17)', 'AD6 (Pin 18)', 'AD7 (Pin 19)'] | |
| a_pins = ['A8 (Pin 21)', 'A9 (Pin 22)', 'A10 (Pin 23)', 'A11 (Pin 24)', 'A12 (Pin 25)', 'A13 (Pin 26)', 'A14 (Pin 27)', 'A15 (Pin 28)'] | |
| highlighted_ad_pins, original_ad_colors = highlight_pins(ad_pins, RED) | |
| highlighted_a_pins, original_a_colors = highlight_pins(a_pins, BLUE) | |
| explanation_text_5 = Tex( | |
| r""" | |
| \textbf{AD0-AD7:} Multiplexed Address/Data Bus (Lower 8 bits) \\ | |
| \textbf{A8-A15:} Higher Address Bus (Upper 8 bits) \\ | |
| \textbf{Note:} AD0-AD7 carry address during T1, data during T2/T3. | |
| """, | |
| font_size=28 | |
| ) | |
| explanation_text_5.to_edge(RIGHT, buff=1) | |
| self.play(FadeIn(explanation_text_5)) | |
| self.wait(0.5) | |
| # Arrows for AD0-AD7 (simplified bi-directional) and A8-A15 (output) | |
| # Just show one representative arrow for each group | |
| ad0_pin = self.pin_mobjects['AD0 (Pin 12)'] | |
| ad_arrow = Arrow(ad0_pin.get_center() + LEFT*1.5, ad0_pin.get_center(), color=RED) # Simplified input/output | |
| a8_pin = self.pin_mobjects['A8 (Pin 21)'] | |
| a_arrow = Arrow(a8_pin.get_center(), a8_pin.get_center() + LEFT*1.5, color=BLUE) # Output | |
| self.play(Create(ad_arrow), Create(a_arrow)) | |
| self.wait(3) | |
| self.play(FadeOut(explanation_text_5), FadeOut(ad_arrow), FadeOut(a_arrow)) | |
| restore_colors(highlighted_ad_pins, original_ad_colors) | |
| restore_colors(highlighted_a_pins, original_a_colors) | |
| self.wait(0.5) | |
| # --- Scene 6: Control and Status Signals --- | |
| self.wait(0.5) | |
| control_pins = ['ALE (Pin 30)', 'RD (Pin 32)', 'WR (Pin 31)', 'IO/M (Pin 34)', 'S0 (Pin 29)', 'S1 (Pin 33)'] | |
| highlighted_pins, original_colors = highlight_pins(control_pins, GREEN) | |
| explanation_text_6 = Tex( | |
| r""" | |
| \textbf{ALE:} Address Latch Enable (Output) \\ | |
| \textbf{RD:} Read Control Signal (Output, Active Low) \\ | |
| \textbf{WR:} Write Control Signal (Output, Active Low) \\ | |
| \textbf{IO/M:} I/O or Memory Select (Output) \\ | |
| \textbf{S0, S1:} Status Signals (Output) | |
| """, | |
| font_size=28 | |
| ) | |
| explanation_text_6.to_edge(RIGHT, buff=1) | |
| self.play(FadeIn(explanation_text_6)) | |
| self.wait(0.5) | |
| # Arrows for control/status signals (all output) | |
| control_arrows = VGroup() | |
| for pin_key in control_pins: | |
| pin_mob = self.pin_mobjects[pin_key] | |
| arrow = Arrow(pin_mob.get_center(), pin_mob.get_center() + RIGHT*1.5, color=GREEN) | |
| control_arrows.add(arrow) | |
| self.play(Create(control_arrows)) | |
| self.wait(3.5) | |
| self.play(FadeOut(explanation_text_6), FadeOut(control_arrows)) | |
| restore_colors(highlighted_pins, original_colors) | |
| self.wait(0.5) | |
| # --- Scene 7: Interrupt Signals --- | |
| self.wait(0.5) | |
| interrupt_pins = ['TRAP (Pin 6)', 'RST 7.5 (Pin 7)', 'RST 6.5 (Pin 8)', 'RST 5.5 (Pin 9)', 'INTR (Pin 10)', 'INTA (Pin 11)'] | |
| highlighted_pins, original_colors = highlight_pins(interrupt_pins, ORANGE) | |
| explanation_text_7 = Tex( | |
| r""" | |
| \textbf{TRAP:} Non-maskable Interrupt (Input) \\ | |
| \textbf{RST 7.5, 6.5, 5.5:} Restart Interrupts (Inputs) \\ | |
| \textbf{INTR:} Interrupt Request (Input) \\ | |
| \textbf{INTA:} Interrupt Acknowledge (Output, Active Low) | |
| """, | |
| font_size=28 | |
| ) | |
| explanation_text_7.to_edge(RIGHT, buff=1) | |
| self.play(FadeIn(explanation_text_7)) | |
| self.wait(0.5) | |
| # Arrows for interrupt signals (Inputs except INTA) | |
| interrupt_arrows = VGroup() | |
| for pin_key in interrupt_pins: | |
| pin_mob = self.pin_mobjects[pin_key] | |
| if pin_key == 'INTA (Pin 11)': | |
| arrow = Arrow(pin_mob.get_center(), pin_mob.get_center() + RIGHT*1.5, color=ORANGE) # Output | |
| else: | |
| arrow = Arrow(pin_mob.get_center() + LEFT*1.5, pin_mob.get_center(), color=ORANGE) # Input | |
| interrupt_arrows.add(arrow) | |
| self.play(Create(interrupt_arrows)) | |
| self.wait(4) | |
| self.play(FadeOut(explanation_text_7), FadeOut(interrupt_arrows)) | |
| restore_colors(highlighted_pins, original_colors) | |
| self.wait(0.5) | |
| # --- Scene 8: Serial I/O Signals --- | |
| self.wait(0.5) | |
| serial_pins = ['SID (Pin 5)', 'SOD (Pin 4)'] | |
| highlighted_pins, original_colors = highlight_pins(serial_pins, BLUE_D) | |
| explanation_text_8 = Tex( | |
| r""" | |
| \textbf{SID:} Serial Input Data (Input) \\ | |
| \textbf{SOD:} Serial Output Data (Output) | |
| """, | |
| font_size=30 | |
| ) | |
| explanation_text_8.to_edge(RIGHT, buff=1) | |
| self.play(FadeIn(explanation_text_8)) | |
| self.wait(0.5) | |
| # Arrows for serial I/O signals | |
| sid_pin = self.pin_mobjects['SID (Pin 5)'] | |
| sid_arrow = Arrow(sid_pin.get_center() + LEFT*1.5, sid_pin.get_center(), color=BLUE_D) # Input | |
| sod_pin = self.pin_mobjects['SOD (Pin 4)'] | |
| sod_arrow = Arrow(sod_pin.get_center(), sod_pin.get_center() + RIGHT*1.5, color=BLUE_D) # Output | |
| self.play(Create(sid_arrow), Create(sod_arrow)) | |
| self.wait(2.5) | |
| self.play(FadeOut(explanation_text_8), FadeOut(sid_arrow), FadeOut(sod_arrow)) | |
| restore_colors(highlighted_pins, original_colors) | |
| self.wait(0.5) | |
| # --- Scene 9: DMA Signals --- | |
| self.wait(0.5) | |
| dma_pins = ['HOLD (Pin 39)', 'HLDA (Pin 38)'] | |
| highlighted_pins, original_colors = highlight_pins(dma_pins, RED) | |
| explanation_text_9 = Tex( | |
| r""" | |
| \textbf{HOLD:} Hold Request (Input) \\ | |
| \textbf{HLDA:} Hold Acknowledge (Output) | |
| """, | |
| font_size=30 | |
| ) | |
| explanation_text_9.to_edge(RIGHT, buff=1) | |
| self.play(FadeIn(explanation_text_9)) | |
| self.wait(0.5) | |
| # Arrows for DMA signals | |
| hold_pin = self.pin_mobjects['HOLD (Pin 39)'] | |
| hold_arrow = Arrow(hold_pin.get_center() + LEFT*1.5, hold_pin.get_center(), color=RED) # Input | |
| hlda_pin = self.pin_mobjects['HLDA (Pin 38)'] | |
| hlda_arrow = Arrow(hlda_pin.get_center(), hlda_pin.get_center() + RIGHT*1.5, color=RED) # Output | |
| self.play(Create(hold_arrow), Create(hlda_arrow)) | |
| self.wait(2.5) | |
| self.play(FadeOut(explanation_text_9), FadeOut(hold_arrow), FadeOut(hlda_arrow)) | |
| restore_colors(highlighted_pins, original_colors) | |
| self.wait(0.5) | |
| # --- Scene 10: Reset Signals --- | |
| self.wait(0.5) | |
| reset_pins = ['RESET IN (Pin 36)', 'RESET OUT (Pin 3)'] | |
| highlighted_pins, original_colors = highlight_pins(reset_pins, GREEN) | |
| explanation_text_10 = Tex( | |
| r""" | |
| \textbf{RESET IN:} Reset Input (Input, Active Low) \\ | |
| \textbf{RESET OUT:} Reset Output (Output) | |
| """, | |
| font_size=30 | |
| ) | |
| explanation_text_10.to_edge(RIGHT, buff=1) | |
| self.play(FadeIn(explanation_text_10)) | |
| self.wait(0.5) | |
| # Arrows for Reset signals | |
| reset_in_pin = self.pin_mobjects['RESET IN (Pin 36)'] | |
| reset_in_arrow = Arrow(reset_in_pin.get_center() + LEFT*1.5, reset_in_pin.get_center(), color=GREEN) # Input | |
| reset_out_pin = self.pin_mobjects['RESET OUT (Pin 3)'] | |
| reset_out_arrow = Arrow(reset_out_pin.get_center(), reset_out_pin.get_center() + RIGHT*1.5, color=GREEN) # Output | |
| self.play(Create(reset_in_arrow), Create(reset_out_arrow)) | |
| self.wait(2.5) | |
| self.play(FadeOut(explanation_text_10), FadeOut(reset_in_arrow), FadeOut(reset_out_arrow)) | |
| restore_colors(highlighted_pins, original_colors) | |
| self.wait(0.5) | |
| # --- Scene 11: Ready Signal --- | |
| self.wait(0.5) | |
| ready_pins = ['READY (Pin 35)'] | |
| highlighted_pins, original_colors = highlight_pins(ready_pins, BLUE) | |
| explanation_text_11 = Tex( | |
| r""" | |
| \textbf{READY:} Ready Signal (Input) \\ | |
| Used to synchronize slower peripherals. | |
| """, | |
| font_size=30 | |
| ) | |
| explanation_text_11.to_edge(RIGHT, buff=1) | |
| self.play(FadeIn(explanation_text_11)) | |
| self.wait(0.5) | |
| # Arrow for READY signal | |
| ready_pin = self.pin_mobjects['READY (Pin 35)'] | |
| ready_arrow = Arrow(ready_pin.get_center() + LEFT*1.5, ready_pin.get_center(), color=BLUE) # Input | |
| self.play(Create(ready_arrow)) | |
| self.wait(2.5) | |
| self.play(FadeOut(explanation_text_11), FadeOut(ready_arrow)) | |
| restore_colors(highlighted_pins, original_colors) | |
| self.wait(0.5) | |
| # --- Scene 12: Summary --- | |
| self.wait(0.5) | |
| # Chip body, label, and all pins are already visible | |
| summary_text = Tex( | |
| r""" | |
| \textbf{Pin Groups:} \\ | |
| Power \& Clock \\ | |
| Address/Data Bus \\ | |
| Control \& Status \\ | |
| Interrupts \\ | |
| Serial I/O \\ | |
| DMA \\ | |
| Reset \\ | |
| Ready | |
| """, | |
| font_size=30 | |
| ) | |
| summary_text.to_edge(RIGHT, buff=0.5) | |
| self.play(FadeIn(summary_text)) | |
| self.wait(3) | |
| # Final cleanup (optional, depends on desired end state) | |
| # self.play(FadeOut(self.chip_group), FadeOut(pin_group), FadeOut(summary_text)) | |
| # self.wait(1) | |