PIC16F84A Simulation Lab — interactive hardware simulator for the 18-pin PIC16F84A · all special function registers live · type instructions or run full programs
The PIC16F84A is an 18-pin part with only two I/O ports: PORTA
(RA0–RA4, 5 bits) and PORTB (RB0–RB7, 8 bits) — there is no PORTC/PORTD/PORTE on this chip. Both
ports are wired to breadboard hardware here (switches and LEDs/7-seg). Any pin currently configured as an
input (dashed ring, once you flip its TRIS bit) can also be clicked directly on the chip body itself.
GIE0
INTF0
ISR fires0
Counter (RB7:RB4)0
The same circuit style as the Breadboard tab, trimmed to just what this lesson needs:
one switch on RB0/INT and 4 LEDs wired straight to RB4–RB7, forming a 4-bit binary counter
(RB0 itself is the interrupt input, so it can't also drive an LED). Flipping the switch pulses RB0 from 0
to 1, a real rising edge detected every instruction against
OPTION_REG<INTEDG> (default: rising). The main program does
nothing but GOTO $ — a pure infinite loop — yet flipping the switch
still genuinely vectors the CPU to 0x0004, clears GIE, advances the 4-bit counter shown on
RB4–RB7 from inside the ISR, and RETFIE restores GIE and drops back
into that same infinite loop, exactly where it left off. Opening this tab loads the matching tutorial
program into the code editor automatically.
TMR00x00
TMR0 (dec)0
Prescaler0 / 2
T0CS0
T0SE0
PSA0
T0IF0
Only does anything while T0CS=1 and TRISA<4>=1 (RA4 configured as input)
This is the real PIC16F84A TMR0 module — the same block
diagram as the datasheet, animated from live silicon state, not a canned animation. Every instruction cycle
(Tcy = 4/Fosc, exactly one Fosc/4 pulse) is genuinely counted: with T0CS=0 (bit5 of
OPTION_REG) the left multiplexer selects the internal Fosc/4 clock;
set T0CS=1 to instead count edges arriving on the RA4/T0CKI pin (toggle it above, or from the
Breadboard tab's RA4 switch), with T0SE choosing rising or falling edge. PSA (bit3) routes
that clock either straight into TMR0 (PSA=1, prescaler bypassed — it's servicing the Watchdog Timer instead)
or through the programmable prescaler (PSA=0), whose 1:2 – 1:256 divide ratio comes from
PS2:PS0 (bits2:0). TMR0 increments on every pulse that reaches it and rolls 0xFF→0x00, which sets
INTCON<T0IF> — flashed red on the diagram below — exactly like
real hardware; software must clear it with BCF INTCON,T0IF (the sample
program does this every pass). Writing directly to TMR0 (MOVWF TMR0 /
CLRF TMR0) also clears the prescaler count, matching the datasheet
note that the prescaler is shared with the Watchdog Timer. Opening this tab loads a ready-to-run TMR0 demo
(1:64 prescale, polled overflow advancing the PORTB LEDs — visible in the CPU State panel, or wire PORTB to
LEDs on the Breadboard tab) into the code editor automatically.
W (working register)0x00
Active bank (RP0)0
STATUS Register Bits
bit7 IRP0
bit6 RP10
bit5 RP00
bit4 TO0
bit3 PD0
bit2 Z0
bit1 DC0
bit0 C0
Every STATUS bit is genuinely live here: RP0 selects the
active register bank below (the PIC16F84A has only 2 banks, so RP1 and IRP are
unimplemented on this chip — they always read 0 and play no part in bank selection or indirect
addressing), and TO/PD reflect the last
CLRWDT/SLEEP — the watchdog timer itself isn't simulated, so they never change
on their own. Z, DC and C update with every instruction that affects them.
Both banks are fully live. The PIC16F84A's data EEPROM is only 64 bytes: set
EEADR (0x00–0x3F, bank 0) and
EEDATA (bank 0), then flip to bank 1 and
BSF EECON1,RD to read a byte into EEDATA,
or load EEDATA and BSF EECON1,WREN
then BSF EECON1,WR to write one (the EEPROM survives a Reset, just
like real non-volatile memory — only Reassemble clears it; a completed write also sets
INTCON<EEIE>'s companion flag EECON1<EEIF>,
which can itself interrupt if EEIE and GIE are set). Everything else besides the
universal PCL/STATUS/FSR/PCLATH/INTCON mirrors is a single 68-byte block of writable general-purpose RAM
(0x0C–0x4F) mirrored wholesale into bank 1 at 0x8C–0xCF — the same physical bytes either way. 0x50–0x7F
(bank 0) and 0xD0–0xFF (bank 1) are unimplemented and always read as 0.
General-Purpose RAM (0x0C – 0x4F)
A cell flashes briefly whenever an instruction changes it. Switch tabs above to inspect
either bank's copy of general-purpose RAM — it's the same 68 physical bytes mirrored in both.
Logic Analyzer — 4 Channels
Time/div
Name each channel and pick any pin (any port, wired to the breadboard or not) to
trace it live — captured instruction-by-instruction while running, so fast toggles aren't missed.
Time/div runs from 1 ms down to 1 ns; the drawing is laid out on that real time axis (cycles × Tcy),
so zooming in past one instruction's Tcy just shows a held value, same as a real instrument outrunning
its sample rate. This panel is global — it keeps running under the Interrupt (RB0/INT) and SFRs &
Memory tabs too, not just Breadboard — and Run/Stop here are the same Assemble & Run / Stop controls
as the ones next to the code editor, so you never have to leave this view to control the simulation.
How this demo works
• The PIC drives PORTB (RB0–RB7). Each RB pin wires straight into the
jumper matrix — click its L dot to route
that pin to an LED, or its S dot to route it onto the 7-segment bus
(bit0..7 → a,b,c,d,e,f,g,dp).
• Switches are wired to PORTA (RA0–RA4, only 5 lines on this chip) whenever
a pin is configured as an input (TRISA bit = 1) — click to toggle, read with
MOVF PORTA,W / BTFSC PORTA,0.
Configure an RA pin as an output instead and its switch knob turns yellow,
showing the value the CPU is driving, and stops responding to clicks.
• Set TRISB = 0 before writing PORTB, otherwise the pins stay inputs
and nothing lights up.
• Bank switching is real, across both banks. Instructions only carry a
7-bit register offset — PORTA/PORTB (bank 0) and TRISA/TRISB (bank 1) share the same offset, so which one
you actually hit depends on the live STATUS<RP0> bit at
that moment, exactly like real hardware (RP1/IRP are unimplemented on the 84A). Writing
MOVWF TRISB while RP0=0 silently writes PORTB instead —
BSF STATUS,RP0 before touching TRISx, then
BCF STATUS,RP0 before touching PORTx, exactly as the default program
does.
• The currently-executing instruction is highlighted directly in the Program Editor as the program runs.
CPU State
PC
W
Bank
Z
C
DC
0
0x00
0
0
0
0
PORTA
TRISA
PORTB
TRISB
0x00
0x1F
0x00
0xFF
EEDATA
EEADR
Stack
0x00
0x00
0/8
Clock (Fosc):Tcy = 0.500 µs/instr · up to 2.00 MIPS
Run speed:1/4FullFull speed (1×) — real-time-accurate at the selected clock
Demo pace:SlowFast~500 ms / instruction
Instructions: 0 ·
Simulated time: 0.000 ms ·
Real time: 0.000 ms ·
Achieved: —
All 35 mid-range instructions are supported one at a time (no labels/branch targets in
CLI mode — use the editor for that). Literals: 0x.. / b'..' / d'..' / H'..' / plain decimal. Any SFR name
(PORTA, PORTB, TRISA, TRISB, INTCON, OPTION_REG, EEDATA, EEADR, EECON1, EECON2, …) or STATUS/INTCON bit
name (Z, C, RP0, GIE, EEIE, …) works as an operand.