The Philosophy of Layered Hardware Architecture Design
9 minute read
Why This Article Exists
Nearly all high-speed and complex peripheral interfaces in modern SoCs follow a common layered design architecture. This is not a coincidence but a core design philosophy aimed at the Separation of Concerns, breaking down complex hardware-software interaction problems into smaller, more manageable parts.
This philosophy is a common design paradigm for peripheral interfaces on an SoC. Keeping this paradigm in mind while configuring the DTS (Device Tree) can significantly reduce the feeling of being lost during debugging.
This article will first explain this universal three-layer architectural model, then use the USB interface as an example to detail the complete data path from an external device to the CPU, and finally discuss the universality of this model and its related professional terminology.
I. The Universal Hardware Interface Architecture: A Philosophy of Layering
A typical data path for a peripheral interface can be summarized into three core stages:
Stage One: Physical Layer Interface (PHY) - The “Senses”
- Universal Responsibility: This is the analog front-end where the system directly interacts with the physical world. Whether it’s wired copper cables, optical fibers, or wireless electromagnetic waves, the PHY is responsible for handling the most primitive, low-level physical signals.
- Core Functions:
- Signal Conversion: Performs bidirectional conversion between analog and digital signals.
- Signal Conditioning: Amplifies, filters, and equalizes signals to combat noise and attenuation introduced by the physical medium.
- Clock and Data Recovery (CDR): Accurately recovers the clock signal and data bits from a serial data stream that lacks a separate clock line.
- Essence: The PHY is a “medium specialist.” It only cares about how to reliably send and receive 0s and 1s over a specific physical medium (like a twisted pair or coaxial cable), but it does not understand the meaning of these 0s and 1s.
Stage Two: Protocol Engine / Controller / MAC - The “Language Center”
- Universal Responsibility: This is the digital back-end that handles digital protocol logic. It receives a clean bitstream from the PHY and begins to give it “meaning.”
- Core Functions:
- Framing: Identifies synchronization headers, start/end delimiters in the data stream, and slices the bitstream into meaningful data units, which we call “Frames” or “Packets.”
- Protocol Processing: Parses the header information of frames/packets, such as source/destination addresses, length, type, etc.
- Error Checking: Calculates and verifies CRC/checksums to ensure data integrity during transmission.
- Media Access Control (MAC): (Especially important in shared-media networks like Ethernet) Decides when data can be sent to avoid collisions.
- Essence: The Controller/MAC is a “grammar specialist.” It understands the rules of a specific communication protocol and can assemble a meaningless bitstream into structured, understandable data frames.
Stage Three: System Interface - The “Nerves to the Brain”
- Universal Responsibility: This is the bridge connecting the peripheral module to the SoC’s core (CPU, memory).
- Core Functions:
- Data Buffering: Uses FIFOs (First-In, First-Out queues) to smooth out the speed differences between the peripheral and the system bus.
- Bus Adaptation: Adapts the data to the SoC’s internal high-speed bus protocols (like AXI, AHB).
- Direct Memory Access (DMA): Moves blocks of data between memory and the controller without CPU intervention, greatly improving efficiency.
- Interrupt Generation: Sends an interrupt signal to the CPU upon task completion or error, waking it up for processing.
- Essence: This is a “system integration specialist,” responsible for allowing peripherals to be integrated efficiently and orderly into the overall operation of the SoC.
II. Case Study: The Complete Data Path Using USB as an Example
To understand the three-layer model more concretely, let’s use the USB interface as an example to dissect each stage of its data flow.
The Role of the PHY in USB: The SoC’s “Ears and Mouth”
- What does it do? The PHY is the “manual laborer” that handles physical signals. Its work is at Layer 1 (Physical Layer) of the OSI model.
- Is it Analog -> Digital? Absolutely correct! For receiving data, the PHY’s core tasks are:
- Receiving chaotic, noisy, high-frequency analog signals from the USB lines.
- The PHY contains complex analog circuits responsible for amplifying, filtering, and recovering the clock, “translating” these analog signals into a clean, standard digital bitstream of 0s and 1s.
- For sending data, the process is reversed (Digital -> Analog).
- An Excellent Analogy: The PHY is like the SoC’s “ears and mouth.” It’s responsible for converting external sound waves (analog signals) into syllables the brain can understand (digital signals), or converting the syllables the brain wants to say into sound waves to be sent out. But the PHY itself does not understand the meaning of the words or sentences formed by these syllables.
The Role of the Controller in USB: The SoC’s “Language Center”
- What does it do? The Controller is the “knowledge worker” that processes the digital protocol. It operates at Layer 2 (Data Link Layer) of the OSI model.
- What is its function? The Controller receives the pure 0s and 1s bitstream from the PHY and then starts doing meaningful things:
- Protocol Parsing: It understands the “grammar” of the USB protocol and knows how to identify the start and end of packets (Framing) from the bitstream.
- Data Packing/Unpacking: It adds headers, addresses, CRC checksums, etc., to the data to be sent, forming a complete USB packet. Conversely, it parses received packets and checks if the CRC is correct.
- Transaction Management: It manages USB transactions, such as issuing requests, waiting for responses, and handling handshake signals (ACK/NAK).
- Flow Control: It decides when data can be sent and when it needs to wait.
- An Excellent Analogy: The Controller is like the SoC’s “language center.” It receives the syllables (digital bitstream) from the ears, then assembles them into meaningful words and sentences (data packets), and understands their grammar and meaning.
The Complete Flow: From External Device to CPU
This is the final step that connects all the stages, corresponding to the model’s third stage, “System Interface.”
- Behind the Controller is the SoC’s Internal Bus: Such as an AXI or AHB bus. You can think of this bus as the SoC’s internal “highway system.”
- The Controller, through a DMA (Direct Memory Access) engine, writes the processed data directly into the system memory (DDR RAM) via the internal bus, or reads data from memory to be sent.
- When the data transfer is complete, the Controller sends an interrupt signal to the CPU, telling it: “Hey, the data you requested has been placed at a certain address in memory, come and process it!”
- Where does the SoC stand in all this? All of the above—CPU, PHY, Controller, internal bus, DMA, memory controller—are all integrated onto a single chip. This entire chip is called an SoC (System on a Chip)!
Flow Summary: USB Drive -> USB Port -> PHY (Analog to Digital) -> Controller (Packet Assembly) -> DMA -> Internal Bus -> DDR Memory -> Interrupt -> CPU (Final Data Processing)
III. The Model’s Universality and Professional Terminology
Is This Model Applicable to Other Interfaces (e.g., CAN, EtherCAT)?
Yes, this model is equally applicable, though the names of the specific modules may differ.
Ethernet: This is the most classic example.
- PHY: Responsible for handling the electrical signals on the RJ45 interface.
- MAC: Responsible for handling Ethernet frames (adding preambles, MAC addresses, CRC, etc.).
- System Interface: DMA controller, connected to an AXI bus.
CAN Bus:
- PHY (often called a CAN Transceiver): Responsible for driving and receiving voltage levels on the two differential lines, CAN_H and CAN_L.
- Controller: Responsible for all CAN protocol logic, including arbitration, frame formatting, error handling, etc.
- System Interface: Usually integrated within the Controller, interacting with the CPU via registers or a small FIFO.
EtherCAT:
- It is based on the Ethernet physical layer, so it reuses the Ethernet PHY.
- Its Controller is a specialized EtherCAT Slave Controller (ESC), which processes Ethernet frames “on the fly” in a special way to achieve extremely low latency.
- System Interface: The ESC contains dual-port RAM (DPRAM) that serves as the interface for data exchange with the CPU.
What is the Professional Terminology for This Process?
The term Pipeline is perfectly acceptable in conversational and informal communication because it vividly describes the process of data being processed sequentially through stages.
In a strictly authoritative expert or academic context, more precise terms are:
- Layered Architecture: This is the most accurate description. It emphasizes the modularity of the design and the independence of each layer’s responsibilities, which is in line with the design philosophy of the OSI network model.
- Data Path: This term focuses on describing the hardware path through which data flows from input to output. For example, you would say “design the Ethernet receive data path (RX Data Path).”
- Processing Chain: Similar to Data Path, it emphasizes the process of data being handled by a chain of hardware modules.
Communication Advice: When talking with colleagues or interviewers, saying “hardware processing pipeline” is universally understood. When writing formal technical documents or papers, using “layered architecture” or “data path” will appear more rigorous and professional.
IV. Flowchart Demonstration
graph TD
%% === 1. Define Basic Nodes ===
A([External Physical World<br/>e.g., USB Drive])
B["<b>PHY (Physical Layer)</b><br/>Analog Signal <=> Digital Bitstream"]
C["<b>Controller / MAC (Protocol Layer)</b><br/>Bitstream <=> Packets/Frames"]
E([<b>CPU (Central Processing Unit)</b><br/>Final Software Processing])
%% === 2. Use a subgraph to clearly represent the SoC's internal data path ===
subgraph "SoC Internal Data Path"
direction LR
D_DMA["<b>DMA Engine</b><br/>Efficient Data Mover"]
D_BUS["<b>Internal Bus (System Bus)</b><br/>e.g., AXI, AHB<br/>SoC's Internal Highway"]
D_MEM(["<b>DDR Memory</b><br/>Temporary Data Storage"])
end
%% === 3. Define the Data Path (Solid arrows) ===
A -- "Analog Signal" --> B
B -- "Digital Bitstream" --> C
C -- "Packets/Frames" --> D_DMA
D_DMA -- "Data Transfer via Bus" --> D_BUS
D_BUS -- "Write to Memory" --> D_MEM
%% === 4. Define the Control Path (Dashed arrows) ===
D_DMA -.-> |"Transfer complete, sends interrupt"| E
D_MEM -.-> |"CPU responds to interrupt, reads data from memory"| EV. Final Conclusion
The model we have explored is a fundamental paradigm that has evolved in modern digital chip design to cope with complexity. It elegantly separates the uncertainty of the physical world (analog signals) from the determinism of the digital world (protocol logic) and the efficiency of the system level (buses and DMA). This separation makes hardware design, firmware verification, and software development clearer and more efficient. This understanding itself demonstrates that you have already acquired a system-level perspective.