Question.4
A BRAM16x8 uses synchronous read-first operation. The eight-bit word at memory address 3 is initially 8'h5A. Before a rising edge of CLK_G, ADDR[3:0]=4'd3, DIN[7:0]=8'hC7, and WE=1.
What are DOUT[7:0] and the word stored at address 3 immediately after the edge?
This Quick Guide uses vendor-neutral educational PLD models. It focuses on how logic is configured, mapped, routed, counted, and debugged rather than on a specific FPGA tool or device family.

Reprogramming changes the configured function without rewiring the external circuit.
The device still has finite resources: logic terms, LUTs, registers, routing, I/O, memory, and arithmetic blocks.

| Family | Main logic style | Typical strength | Main limit |
|---|---|---|---|
| SPLD | Product terms and macrocells | Small glue and decode logic | Low density |
| CPLD | Groups of macrocells with programmable interconnect | Predictable control and medium-density logic | Product-term and macrocell limits |
| FPGA | LUTs, DFFs, programmable routing, and hard resources | Large configurable digital systems | Mapping, routing, and resource complexity |
The architecture defines the available resources and their connections. The configuration technology defines how the programming state is stored.
| Configuration technology | Volatile? | Reprogrammable? | Startup implication | Practical fit |
|---|---|---|---|---|
| SRAM | Yes | Yes | Configuration must be loaded after power-up | Frequent updates and high-density FPGA fabrics |
| Flash | No | Yes | Configuration is retained without power | Fast readiness and field updates |
| Antifuse | No | No | Programmed function is retained | One-time programming and permanent configuration |

| Requirement | Usually favors | Reason |
|---|---|---|
| A few SOP equations | SPLD | Direct product-term implementation |
| Moderate control logic and predictable startup | CPLD | Macrocell structure and nonvolatile options |
| Many logic functions, registers, memories, or multipliers | FPGA | Dense LUT fabric and dedicated resources |
| Change configuration often | SRAM or Flash | Reprogrammable |
| Retain configuration without reload | Flash or antifuse | Nonvolatile |
| Update after deployment | Flash or SRAM | Antifuse cannot be reprogrammed |
Small example: A board needs six simple active-HIGH control equations and must retain its configuration when power is removed. A small Flash-based SPLD or CPLD is a better starting point than a large SRAM FPGA because the logic density is low and the configuration is nonvolatile. After power is applied, the device still completes its specified internal startup sequence before its logic and I/O are ready; nonvolatile configuration does not mean zero startup time.
Practical rule: Select both an architecture that fits the logic and a configuration technology that fits startup and update requirements.
A ROM/PROM-style realization uses inputs as an address and a programmed output pattern as a truth table. It can realize any listed combination, but may store many rows that a compact SOP form does not need.

| Structure | AND plane | OR plane | Main consequence |
|---|---|---|---|
| PAL | Programmable | Fixed | Simple output structure; sharing depends on fixed connections |
| PLA | Programmable | Programmable | Product terms can be connected to selected outputs |
For the educational PAL/PLA matrices, a connection bit of 1 means connected and 0 means open. Unused product terms must be disabled.
A programmable array selects which signal lines are electrically connected at each crossing point. The physical programming element depends on the device technology.
| Implementation | How the connection is represented |
|---|---|
| Fuse link | Initially connected; programming can open selected links |
| Antifuse link | Initially open; programming permanently creates selected links |
| SRAM-controlled electronic switch | A volatile configuration bit turns a pass transistor or multiplexer path on or off |
| Flash-controlled electronic switch | A nonvolatile stored state controls the switch or selection path |
In EWsim, simple switches make each programmed connection easy to inspect and change.
In actual PLD hardware, microscopic programmable elements and electronic switches are controlled by configuration memory or one-time-programmable links; a person does not operate physical toggle switches inside the device.


A product term is an AND of selected literals. A variable may be used as true, complemented, or don't-care. In the table below, V means the input variable assigned to that literal field, such as A, B, C, or D. In a MACROCELL4 product term, each literal field uses:
| Literal code | Meaning | Contribution to product term |
|---|---|---|
00 | Don't care | Variable omitted; contributes logic 1 to the AND term |
01 | True literal | Use V |
10 | Complemented literal | Use V' |
11 | Reserved/invalid | Do not use |
Because an AND input must be neutral when a variable is omitted, each 00 literal contributes logic 1 to the product-term AND operation. If every literal field is 00 and PT_EN=1, the enabled product term evaluates to 1. PT_EN=0 overrides the literal fields and forces the product-term output to 0.
Practical rule: Disable an unused product term with
PT_EN=0. Leaving an all-don't-care term enabled would contribute1to the following OR stage.
Encoding example: For A'·C, program the A field as 10, the B field as 00, the C field as 01, and the D field as 00. Set PT_EN=1.
Map:
F = A'·B + A·C
| Product term | A | B | C | D | PT_EN | Result |
|---|---|---|---|---|---|---|
PT0 | 10 | 01 | 00 | 00 | 1 | A'·B |
PT1 | 01 | 00 | 01 | 00 | 1 | A·C |
PT2 | 00 | 00 | 00 | 00 | 0 | 0 |
PT3 | 00 | 00 | 00 | 00 | 0 | 0 |
The OR stage combines the enabled terms: F = PT0 + PT1.
A | B | C | F = A'·B + A·C |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 |
| 0 | 1 | 0 | 1 |
| 0 | 1 | 1 | 1 |
| 1 | 0 | 0 | 0 |
| 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 0 |
| 1 | 1 | 1 | 1 |

For two outputs:
F = A'·B + A·C
G = A'·B + B·C
The term A'·B is common. A PLA can program it once and connect it to both output OR paths. A PAL can share it only if its fixed OR structure provides that connection; otherwise, the term must be duplicated.
| Term | Used by F | Used by G | PLA allocation |
|---|---|---|---|
A'·B | Yes | Yes | One shared term |
A·C | Yes | No | One term |
B·C | No | Yes | One term |
A MACROCELL4 has four product terms. Therefore:
H = P0 + P1 + P2 + P3 fits one macrocell.
K = P0 + P1 + P2 + P3 + P4 does not directly fit one macrocell. It must be factored, split across resources, or mapped to a different architecture.
Practical rule: Count the required product terms after simplification and sharing, then compare the count with the destination macrocell and interconnect limits.
MACROCELL4 contains four programmable product terms, an OR stage, optional polarity control, combinational/registered selection, output enable, and selectable internal feedback. Its DFF uses rising-edge CLK_G and synchronous active-HIGH RST.

| Output mode | Pin source | When value can change | Typical use |
|---|---|---|---|
| Combinational | Polarized OR result | After input/configuration propagation | Decode and immediate control |
| Registered | DFF Q | After a rising CLK_G edge | State and clock-aligned control |
| Feedback select | Internal feedback source | Pin OE effect |
|---|---|---|
| Combinational | Polarized OR result | Feedback remains available even if pin is released |
| Registered | DFF Q | Feedback remains available even if pin is released |
OE | External pin | Internal logic/feedback |
|---|---|---|
| 0 | Released, not driven | Still operates |
| 1 | Drives selected output | Still operates |
The simplified MACROCELL4 has no clock enable. On each rising edge:
RST | Active-edge DFF action |
|---|---|
| 1 | Q ← 0 |
| 0 | Q ← polarized OR result |
Because RST is synchronous, asserting it between edges does not immediately clear Q.
Feedback example: Configure the macrocell D input as:
D = A + B'·Q
Here, Q is the registered feedback signal.
| Condition | Resulting D | Behavior at the next rising CLK_G edge when RST=0 |
|---|---|---|
A=1 | 1 | Set Q to 1 |
A=0, B=0 | Q | Hold the current state through feedback |
A=0, B=1 | 0 | Clear Q |

| Goal | Product terms | Polarity | Output mode | OE | Feedback |
|---|---|---|---|---|---|
Combinational active-HIGH F | SOP for F | Normal | Combinational | 1 | Combinational |
Registered F | SOP for next F | Normal | Registered | 1 | Registered Q |
| Active-LOW pin | SOP for active-HIGH internal result | Invert | Selected as needed | 1 | As required |
| Internal-only state bit | Next-state SOP | Normal | Registered | 0 | Registered Q |
CPLD-8 has two function blocks, each containing four MACROCELL4 resources, with eight user I/O, programmable interconnect, global CLK_G, and active-HIGH RST.

A design can fail even with unused macrocells if one output needs more than four product terms or if the required interconnect path is unavailable.
Practical rule: Check product terms per macrocell, total macrocells, I/O, and interconnect—not only the total equation count.
An N-input LUT stores 2^N configuration bits and implements any Boolean function whose required input set has at most N variables. LUT4 stores 16 bits in CFG_INIT[15:0].
ADDR = {I3, I2, I1, I0}
Y = CFG_INIT[ADDR]
I0 is the least-significant address bit. CFG_INIT[0] corresponds to address 0000; CFG_INIT[15] corresponds to 1111.

CFG_INITUse I0=A, I1=B, I2=C, and leave I3 functionally unused for:
F = A'·B + A·C
| Address | I3 | I2=C | I1=B | I0=A | CFG_INIT[address] |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 0 |
| 1 | 0 | 0 | 0 | 1 | 0 |
| 2 | 0 | 0 | 1 | 0 | 1 |
| 3 | 0 | 0 | 1 | 1 | 0 |
| 4 | 0 | 1 | 0 | 0 | 0 |
| 5 | 0 | 1 | 0 | 1 | 1 |
| 6 | 0 | 1 | 1 | 0 | 1 |
| 7 | 0 | 1 | 1 | 1 | 1 |
| 8 | 1 | 0 | 0 | 0 | 0 |
| 9 | 1 | 0 | 0 | 1 | 0 |
| 10 | 1 | 0 | 1 | 0 | 1 |
| 11 | 1 | 0 | 1 | 1 | 0 |
| 12 | 1 | 1 | 0 | 0 | 0 |
| 13 | 1 | 1 | 0 | 1 | 1 |
| 14 | 1 | 1 | 1 | 0 | 1 |
| 15 | 1 | 1 | 1 | 1 | 1 |
Read bits from 15 down to 0 when writing the hexadecimal value:
CFG_INIT[15:0] = 1110_0100_1110_0100 = 16'hE4E4
The upper and lower bytes match because I3 is unused.
For CFG_INIT = 16'h8000, only bit 15 is 1. Therefore Y=1 only for address 1111, so:
Y = I3·I2·I1·I0
To decode any INIT value, expand it to 16 bits, label the rightmost bit as address 0, and identify the addresses containing 1.
A function with five required inputs cannot fit one LUT4. Decompose it, for example:
F = A·B·C·D + E

This mapping uses two LUTs and has LOGIC_LEVELS = 2 on the A-to-D paths. A register would terminate the current combinational path.
The behavior can be verified with three conditions. X means either 0 or 1.
| Condition | E | A·B·C·D | F |
|---|---|---|---|
E is HIGH | 1 | X | 1 |
E is LOW and all four product inputs are HIGH | 0 | 1 | 1 |
E is LOW and at least one product input is LOW | 0 | 0 | 0 |
LE4 combines one LUT4, one DFF, CE, synchronous active-HIGH RST, and combinational/registered output selection.

On a rising edge of CLK_G, the priority is RST > CE > Hold.
RST | CE | DFF action at rising CLK_G | Q after edge |
|---|---|---|---|
| 1 | X | Reset | 0 |
| 0 | 1 | Capture | LUT_OUT |
| 0 | 0 | Hold | Previous Q |
| Output select | LE_OUT |
|---|---|
| Combinational | LUT_OUT |
| Registered | Q |
Report LUT_USED, DFF_USED, and LE_OCCUPIED separately.
| Mapping | LUT_USED | DFF_USED | LE_OCCUPIED |
|---|---|---|---|
| LUT result registered by the same LE DFF | 1 | 1 | 1 |
| Standalone LUT plus unrelated standalone DFF | 1 | 1 | 2 |
| Two standalone LUT functions | 2 | 0 | 2 |
LOGIC_LEVELS is the maximum number of LUT4 stages on a combinational input-to-output path, not the total LUT count.

Local routing is suited to nearby logic, general routing connects broader fabric regions, and global routing distributes CLK_G to many sequential resources. Exact physical timing is outside the educational model.
A ROUTE_MUX4 selects one of four candidate sources.
SEL[1:0] | Selected source |
|---|---|
00 | S0 |
01 | S1 |
10 | S2 |
11 | S3 |
![S0–S3, SEL[1:0], and ROUTE_OUT](https://cdn.ewskills.com/articles/programmable-logic-devices/text/wXhOKcYDfVnh-route-mux4-programmable-routing-circuit.webp)
ROUTE_HOPS counts programmable routing stages:
| Route | Count |
|---|---|
| Direct connection within the same LE | 0 |
One ROUTE_MUX4 | 1 |
ROUTE_MUX4 then inter-cluster stage | 2 |
Important:
ROUTE_HOPSis an abstract structural cost metric, not physical delay. Two routes with the same hop count can have different real timing.

IO_OE | Pin mode | IO_OUT effect | IO_IN role |
|---|---|---|---|
| 0 | Input/released | Pin is not driven | Samples the pin |
| 1 | Output | Drives the pin | May still observe the pin in the abstraction |
Electrical voltage standards and analog pin behavior are outside scope.
Small example: If IO_OUT=1, then IO_OE=1 drives the external pin HIGH. Changing IO_OE to 0 releases the pin; IO_OUT may remain 1 internally, but it no longer drives the external connection. IO_IN observes the external pin level.


Use CLK_G for sequential fabric. A fabric-generated clock can introduce uncontrolled skew, glitches, and routing uncertainty; use clock enable when the goal is conditional updating.
PLL/MMCM/DLL resources manage clock frequency and phase, but their analog implementation is outside scope.
A clock enable keeps the DFF on the global clock and controls the value presented to D through a feedback multiplexer:
D_next = CE·Data + CE'·Q
CE | MUX selection | Rising-edge action |
|---|---|---|
| 0 | Current Q | Hold Q |
| 1 | New Data | Q ← Data |
Small example: If Q=1, Data=0, and CE=0, then D_next=1 and the next clock edge preserves Q=1. If CE changes to 1, D_next=0 and the next edge loads Q=0.

High fan-out signals consume routing resources and may affect implementation timing.
Treat fan-out, congestion, and placement as implementation-awareness issues even when Boolean behavior is correct.
PLD-16 contains 16 LE4 resources arranged as four clusters of four, 16 digital I/O, two BRAM16x8, two DSP8_MADD, CLK_G, and programmable route-mux resources.

BRAM16x8 stores 16 words of 8 bits. Write and output capture occur on a rising CLK_G edge.

| Edge condition | Memory action | DOUT after edge |
|---|---|---|
WE=0 | No write | Captures current MEM[ADDR] |
WE=1 | MEM[ADDR] ← DIN | Captures old MEM[ADDR] |
The same-address write behavior is read-first: the old value appears at DOUT on the write edge, and the new stored value is observed on a later read edge.
Read-first example: Assume MEM[3]=8'h2A. At a rising edge, apply ADDR=3, WE=1, and DIN=8'hC5. After that edge, DOUT=8'h2A while MEM[3] stores 8'hC5. A later read edge at address 3 captures 8'hC5.
Small memories may use distributed logic in some architectures, but a larger array usually favors BRAM so LUTs and DFFs remain available for logic.
DSP8_MADD implements unsigned multiply-add:
P[16:0] = A[7:0] × B[7:0] + C[15:0]

Example: A=25, B=10, and C=1000.
P = 25 × 10 + 1000 = 1250
The maximum result is 255 × 255 + 65535 = 130560, which fits 17 bits because the 17-bit unsigned maximum is 131071.
| Requirement | Preferred mapping | Reason |
|---|---|---|
| 16 × 8 table with clocked access | One BRAM16x8 | Preserves LUT/DFF fabric |
| Two independent 16 × 8 arrays | Two BRAM16x8 blocks | Exact hard-resource fit |
| Three independent 16 × 8 arrays | Does not fit BRAM budget directly | Only two BRAM blocks exist |
| Two simultaneous multiply-adds | Two DSP8_MADD blocks | Parallel arithmetic |
| Three simultaneous multiply-adds | Fails DSP budget or needs a redesign | Only two DSP blocks exist |
Practical rule: A design fails to fit when any required resource is exhausted, even if many other resources remain unused.
Synthesis transforms the logic description into a generic logical network. Technology mapping selects target resources such as product terms, LUTs, DFFs, BRAMs, DSPs, I/O, and routing.

Consider the five-input function:
F = (A + B)·(C + D)·E
Both mappings below use only valid LUT4 input counts.

| Measure | Mapping A | Mapping B |
|---|---|---|
LUT_USED | 2 | 4 |
LOGIC_LEVELS | 2 | 3 |
| Intermediate routed signals | T | P, Q, and R |
| Routing implication | One LUT-to-LUT connection | More internal connections and placement dependence |
Mapping A is the more compact direct implementation. Mapping B is still functionally correct and may become useful if P=A+B and Q=C+D already exist for other outputs; otherwise, it consumes more LUT and routing resources and adds one logic level.
MINI_FABRIC-8 is a small educational FPGA fabric with eight LE4 resources arranged as two clusters of four. It has four external inputs, four outputs, fixed ROUTE_MUX4 resources, one inter-cluster route bus, and shared CLK_G and RST. It contains no hard BRAM or DSP blocks.

The fabric is intended for LUT, register, packing, and routing exercises under explicit resource limits. Memory arrays and multiply-add operations must use the available LE4 fabric or be excluded from a task because no dedicated BRAM or DSP resources exist.
Suppose a design contains 12 LUT functions and 6 DFFs:
Therefore:
LUT_USED = 12
DFF_USED = 6
LE_OCCUPIED = 5 paired + 7 LUT-only + 1 DFF-only = 13
Small packing example: Two LUT outputs each feed their own local DFF. This uses LUT_USED=2, DFF_USED=2, and LE_OCCUPIED=2, because each LUT/DFF pair packs into one LE4.
Utilization (%) = Used / Available × 100%
| Resource | Used | Available | Utilization |
|---|---|---|---|
| LUT4 | 12 | 16 | 75% |
| DFF | 6 | 16 | 37.5% |
| LE4 occupied | 13 | 16 | 81.25% |
| BRAM16x8 | 2 | 2 | 100% |
| DSP8_MADD | 1 | 2 | 50% |
| Digital I/O | 10 | 16 | 62.5% |
Each resource is reported separately. Here, BRAM is the immediate bottleneck: another required BRAM prevents fit even though LUT, DFF, LE, DSP, and I/O capacity remains.
A common subfunction can reduce LUT count when its result can be routed to every consumer. Sharing a time-multiplexed hard resource reduces area but usually increases latency and lowers throughput.

| Choice | Resource use | Throughput/latency consequence |
|---|---|---|
| Parallel resources | Higher | More simultaneous work |
| Shared resource | Lower | Operations are scheduled across cycles |
When two mappings use the same number of LUTs, prefer the one that meets all constraints with acceptable LOGIC_LEVELS, fan-out, and ROUTE_HOPS. Remember that ROUTE_HOPS compares structural route cost only; it is not a delay value.
Practical rule: Optimize for a design that fits every resource budget and behavior requirement, not merely the smallest LUT count.

Placement chooses resource locations; routing selects programmable paths. A correct logical mapping can still fail to route or fail timing.
For SRAM-configured devices, startup includes loading configuration. Flash and antifuse retain configuration, but device readiness still follows the specified startup behavior.
For F = A'·B + A·C with I0=A, I1=B, I2=C, and unused I3, the correct value is 16'hE4E4. Reversing bit significance produces 16'h2727, which implements the wrong rows.
| Check | Correct configuration | Faulty configuration |
|---|---|---|
Address 2 (0010) | Bit 2 = 1 | Bit 2 = 1 |
Address 5 (0101) | Bit 5 = 1 | Bit 5 = 1 |
Address 6 (0110) | Bit 6 = 1 | Bit 6 = 0 |
Address 7 (0111) | Bit 7 = 1 | Bit 7 = 0 |
| Hex value | 16'hE4E4 | 16'h2727 |
Debug by checking ADDR = {I3,I2,I1,I0}, then reading CFG_INIT[ADDR] with bit 0 at the rightmost end of the hexadecimal value.
One-bit check example: With CFG_INIT=16'hE4E4 and address 0110 (decimal 6), Y=CFG_INIT[6]=1. Checking a single known row is a fast way to detect an address-order or bit-order mistake.
Required term: A'·B.
| Field | Correct | Faulty | Effect |
|---|---|---|---|
A literal | 10 | 01 | Uses A instead of A' |
B literal | 01 | 01 | Uses B |
PT_EN | 1 | 1 | Term is active |
| Implemented term | A'·B | A·B | Wrong minterms become active |
Also check PT_EN, polarity, combinational/registered mode, and OE. Correct internal logic with OE=0 still leaves the external pin undriven.

Trace from the failing destination backward through every programmed mux and inter-cluster stage. Change the minimum route controls and recheck that no unintended cross-connection or contention was introduced.

| Symptom | Likely class | Check and correction |
|---|---|---|
| Output wrong for selected input rows | Logic/configuration | Verify LUT address order or product-term literals |
| Output changes immediately but should be clocked | Macrocell/LE mode | Select registered output |
| Register does not clear until a clock edge | Expected synchronous reset behavior | Apply RST=1 at a rising CLK_G edge |
| Internal result is correct but pin is inactive | I/O or OE | Assert the correct output-enable control |
| Mapping report exceeds one resource type | Resource-fit failure | Factor, pack, share, or choose an available hard resource |
| Correct source does not reach destination | Routing | Verify each ROUTE_MUX4 and inter-cluster select |
| Intermittent or unsafe sequential behavior | Clocking | Replace fabric-generated clocks with CLK_G plus CE |
| Simulation/function passes but implementation timing fails | Timing | Reduce LOGIC_LEVELS, fan-out, or route burden |
| Failure appears only after power-up | Startup/configuration | Verify configuration loading and readiness sequence |
| Failure occurs between clock domains | CDC | Apply the previously learned CDC structure; do not treat it as ordinary routing |
ROUTE_HOPS only as a structural metric.Practical rule: Do not change Boolean logic first when the failure is caused by mode, enable, routing, clocking, startup, or exhausted resources.