Skip to Content
Digital Design and Computer Architecture, 2nd Edition
book

Digital Design and Computer Architecture, 2nd Edition

by David Harris, Sarah Harris
August 2012
Intermediate to advanced
712 pages
19h 33m
English
Morgan Kaufmann
Content preview from Digital Design and Computer Architecture, 2nd Edition

SystemVerilog

module latch(input  logic     clk,

        input  logic  [3:0] d,

        output logic  [3:0] q);

 always_latch

  if (clk) q <= d;

endmodule

always_latch is equivalent to always @(clk, d) and is the preferred idiom for describing a latch in SystemVerilog. It evaluates any time clk or d changes. If clk is HIGH, d flows through to q, so this code describes a positive level sensitive latch. Otherwise, q keeps its old value. SystemVerilog can generate a warning if the always_latch block doesn’t imply a latch.

VHDL

library IEEE; use IEEE.STD_LOGIC_1164.all;

entity latch is

 port(clk: in STD_LOGIC;

    d:  in STD_LOGIC_VECTOR(3 downto 0);

    q:  out STD_LOGIC_VECTOR(3 downto 0));

end;

architecture synth of latch is

begin

 process(clk, ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Digital Design and Computer Architecture

Digital Design and Computer Architecture

David Harris, Sarah Harris
Computer Architecture, 5th Edition

Computer Architecture, 5th Edition

John L. Hennessy, David A. Patterson

Publisher Resources

ISBN: 9780123944245