14 332 331 Computer Architecture and Assembly Language
14: 332: 331 Computer Architecture and Assembly Language Spring 2006 Week 5: VHDL Programming [Adapted from Dave Patterson’s UCB CS 152 slides and Mary Jane Irwin’s PSU CSE 331 slides] 331 W 05. 1 Spring 2006
To make the architect’s crucial task even conceivable, it is necessary to separate the architecture, the definition of the product as perceivable by the user, from its implementation. Architecture versus implementation defines a clean boundary between parts of the design task, and there is plenty of work on each side of it. The Mythical Man-Month, Brooks, pg. 256 331 W 05. 2 Spring 2006
Processor Organization q Processor control needs to have the l l q q Ability to input instructions from memory Logic to control instruction sequencing and to issue signals that control the way information flows between the datapath components and the operations performed by them Processor datapath needs to have the l Ability to load data from and store data to memory l Interconnected components - functional units (e. g. , ALU) and storage units (e. g. , Register File) - for executing the ISA Need a way to describe the organization l l l 331 W 05. 3 High level (block diagram) description Schematic (gate level) description Textural (simulation/synthesis level) description Spring 2006
Levels of Description of a Digital System Architectural models programmer's view at a high level; written in your favorite programming language Functional/Behavioral more detailed model, like the block diagram view Register Transfer Logic Circuit Less Abstract model is in terms of datapath FUs, registers, busses; register xfer More operations are clock phase Accurate accurate Slower model is in terms of logic gates; Simulation delay information can be specified for gates; digital waveforms model is in terms of circuits (electrical behavior); accurate analog waveforms Schematic capture + logic simulation package like Logic. Works Special languages + simulation systems for describing the inherent parallel activity in hardware (VHDL and verilog) 331 W 05. 4 Spring 2006
Why Simulate First? q Physical breadboarding l l discrete components/lower scale integration precedes actual construction of the prototype verification of the initial design q No longer possible as designs reach higher levels of integration! q Simulation before construction - aka functional verification l l l 331 W 05. 5 high level constructs means faster to design and test can play “what if” more easily limited performance (can’t usually simulate all possible input transitions) and accuracy (can’t usually model wiring delays accurately), however Spring 2006
VHDL (VHSIC Hardware Description Language) q Goals: l l q Support design, documentation, simulation & verification, and synthesis of hardware Allow integrated design at multiple levels - behavioral and structural (gate level) Concepts: l Design entity-architecture descriptions l Time-based execution (discrete event simulation) model Design Entity-Architecture == Hardware Component Entity == External Characteristics Architecture (Body ) == Internal Behavior or Structure 331 W 05. 6 Spring 2006
Entity Interface q Externally visible characteristics l Ports: channels of communication - (inputs, outputs, clocks, control) l Generic parameters: define class of components - (timing characteristics, size, fan-out) entity name_of_component is port(a, b: in std_logic; y: out std_logic); end name_of_component; 331 W 05. 7 Spring 2006
Architecture Body q Internal behavior or structure of circuit l l Declaration of module’s internal signals Description of behavior of circuit - concurrent behavioral description - collection of Concurrent Signal Assignment (CSA) statements executed concurrently - process behavioral description - CSAs and variable assignment statements within a process description - structural description - system described in terms of the interconnections of its components architecture behavioral of name_of_component is signal s 1, s 2: std_logic; begin - description of behavior of ports and signals; end behavioral; 331 W 05. 8 Spring 2006
VHDL Example: nor-nor gate a b c t 0 y entity nor_logic is port (a, b, c: in std_logic; y: out std_logic); end nor_logic; architecture concurrent_behavior of nor_logic is signal t 0: std_logic; begin t 0 <= a nor b; y <= t 0 nor c; end concurrent_behavior; 331 W 05. 9 Spring 2006
Things to Notice q <= indicates a Concurrent Signal Assignment (CSA) l q like “real” logic, nor_nor “process” is in an infinite loop t 0 and y are signals, not variables l they change when ever the inputs (a, b, or c) change l std_logic conforms to the IEEE 1164 standard library IEEE; use IEEE. std_logic_1164. all; entity nor_logic is 331 W 05. 10 . . . Spring 2006
Modeling Delays q Can model temporal, as well as functional behavior, with delays in CSAs l t 0 changes 1 ns after a or b changes entity nor_logic is port (a, b, c: in std_logic; y: out std_logic); end nor_logic; architecture concurrent_behavior of nor_logic is signal t 0: std_logic; begin t 0 <= (a nor b) after 1 ns; y <= (t 0 nor c) after 1 ns; end concurrent_behavior; 331 W 05. 11 Spring 2006
Review: An Entity-Architecture Example a b c t 0 y entity nor_logic is port(a, b, c: in std_logic; y: out std_logic); end nor_logic; architecture concurrent_behavior of nor_logic is signal t 0: std_logic; begin t 0 <= (a nor b) after 1 ns; y <= (t 0 nor c) after 1 ns; end concurrent_behavior; 331 W 05. 12 Spring 2006
Entity-Architecture Features q Entity defines externally visible characteristics l Ports: channels of communication - signal names for inputs, outputs, clocks, control l Generic parameters: define class of components - timing characteristics, size (fan-in), fan-out q Architecture defines the internal behavior or structure of circuit l Declaration of internal signals l Description of behavior - concurrent behavioral description: collection of Concurrent Signal Assignment (CSA) statements (indicated by <=) executed concurrently; can also model temporal behavior with the delay annotation - process behavioral description: CSAs and variable assignment statements within a process description - structural description: system described in terms of the interconnections of its components 331 W 05. 13 Spring 2006
New Object: Signals q Digital systems are about signals, not variables signal <= value expressions after time expression l signals are analogous to wires and change when ever their inputs change - time-value pairs resulting in a waveform l std_logic conforms to the 9 -value IEEE 1164 standard for signals When a signal has multiple drivers (e. g. , a bus), the value of the resulting signal is determined by a resolution function for std_logic and std_logic_vector the resolution function (lookup table) is provided by std_logic_1164 package 331 W 05. 14 Spring 2006
Model of Execution q CSA’s are executed concurrently - textural order of the statements is irrelevant to the correct operation q Two stage model of circuit execution l first stage - all CSA’s with events occurring at the current time on signals on their right hand side (RHS) are evaluated - all future events that are generated from this evaluation are scheduled on the events list l second stage - time is advanced to the time of the next event q VHDL programmer specifies l l l 331 W 05. 15 events - with CSA’s delays - with CSA’s with delay annotation concurrency - by having a distinct CSA for each signal Spring 2006
Constant Objects q Constant parameters provide default values l l may be overridden on each instance attach value to symbol as attribute entity nor_logic is port(a, b, c: in std_logic; y: out std_logic); end nor_logic; architecture concurrent_behavior of nor_logic is signal t 0: std_logic; constant gate_delay: Time : = 1 ns; begin t 0 <= (a nor b) after gate_delay; y <= (t 0 nor c) after gate_delay; end concurrent_behavior; 331 W 05. 16 Spring 2006
Bit-Vector Data Types q Std_logic_vector (31 downto 0) is equivalent to a 32 -bit bus l Can convert it to a 32 bit integer entity nand 32 is port(a, b: in std_logic_vector (31 downto 0); y: out std_logic_vector (31 downto 0)); end nand 32; architecture concurrent_behavior of nand 32 is begin y <= a nand b; end concurrent_behavior; q Analyzer (compiler) expands the architecture into 32 2 -input nand gates with the inputs connected appropriately 331 W 05. 17 Spring 2006
Conditional Signal Assignment Statement q Conditional CSA l order is important - the first conditional expression that evaluates to true determines the output signal In 0 S 1 00 In 1 entity mux 4 is In 2 port(In 0, In 1, In 2, In 3: in std_logic_vector (7 downto 0); In 3 S 0, S 1: in std_logic; Z: out std_logic_vector (7 downto 0)); end mux 4; architecture behavior of mux 4 is begin Z <= In 0 after 5 ns when S 0 In 1 after 5 ns when S 0 In 2 after 5 ns when S 0 In 3 after 5 ns when S 0 “ 0000” after 5 ns end behavior; 331 W 05. 18 = = ‘ 0’ ‘ 1’ and and S 1 S 1 = = 01 Z 10 11 ‘ 0’ ‘ 1’ else Spring 2006
Selected Signal Assignment Statement q Selected CSA l all choices are evaluated, but only one must be true entity reg_file is port(addr 1, addr 2: in std_logic_vector (1 downto 0); dout 1, dout 2: out std_logic_vector (31 downto 0)); end reg_file; architecture behavior of reg_file is signal reg 0: std_logic_vector (31 downto 0) : = to_stdlogicvector (x” 0000”); signal reg 1, reg 2: std_logic_vector (31 downto 0) : = to_stdlogicvector (x”ffff”); begin with addr 1 select dout 1 <= reg 0 after 5 ns when “ 00”, <= reg 1 after 5 ns when “ 01”, <= reg 2 after 5 ns when others; with addr 2 select dout 2 <= reg 0 after 5 ns when “ 00”, <= reg 1 after 5 ns when “ 01”, <= reg 2 after 5 ns when others; end behavior; 331 W 05. 19 Spring 2006
Summary q Introduction to VHDL l A language to describe hardware - entity = symbol, architecture ~ schematic, signals = wires Inherently concurrent (parallel) l Has time as concept l Behavioral descriptions of a component l - can be specified using CSAs - can be specified using one or more processes and sequential statements l Structural descriptions of a system are specified in terms of its interconnections - behavioral models of each component must be provided 331 W 05. 20 Spring 2006
- Slides: 20