



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Logic Circuit Lab Spring 2004
Due: By 6:00pm on Wednesday April 28. So far, all our circuits have been purely combinational. The outputs are only a function of the current inputs. If we can define a problem in terms of truth-tables, we can build a combinational circuit that will implement it. However, there are many problems of interest that require that we solve them by completing several steps, one step at a time in a sequential manner. The next step taken may well depend not only on the current inputs to the circuit, but also on which step was just completed. Circuits that operate this way are referred to as sequential circuits or state machines. Sequential circuits differ from purely combinational circuits in that the current outputs of a sequential circuit may not only be a function of present inputs, but also of past inputs. The objective of this lab is to explore options for implementing flip-flops and to characterize their behavior. You will also combine several flip-flops to create a binary counter.
First, you can implement the circuit directly, using NAND gates and inverters using the schematic entry program. However, you can also take advantage of the built-in flip-flop components in schematic entry. For example, the component FD is a D-flip-flop and FD 1 is a D-flip flop with a negative edge triggered clock. There also components for other types of flip-flops, and ones with enable, preset and clear inputs.
Flip-flops and latches can also be implemented using a hardware description language such as VHDL or Verilog. If we wanted to implement a S-R latch in VHDL we could use the following code:
library IEEE; use IEEE.std_logic_1164.all;
entity srlat is port ( sb: in STD_LOGIC; --active low set input rb: in STD_LOGIC; --active low reset input q: buffer STD_LOGIC; --data output qb: buffer STD_LOGIC; --inverted data output ); end srlat;
Logic Circuit Lab Spring 2004
architecture srlat_arch of srlat is begin q <= NOT(sb and qb); --cross-coupled NAND gates qb <= NOT(rb and q); end srlat_arch;
However, we can also create a behavioral model. In this case, we’ll look at a SR flip-flop with a clock input. The key to the behavior model is the PROCESS function. This is only entered when one of the parameters passed with the statement changes.
library IEEE; use IEEE.std_logic_1164.all;
entity srff is port ( c: in STD_LOGIC; --clock sb: in STD_LOGIC; --active low set input rb: in STD_LOGIC; --active low reset input q: buffer STD_LOGIC; --data output qb: OUT STD_LOGIC; --inverted data output ); end srff;
architecture srff_arch of srff is begin PROCESS (c,sb,rb) --entered only when c, sb, rb changes BEGIN IF c=’1’ THEN --change state only when the clock is high IF (sb=’0’) THEN q <=’1’; ELSIF (rb=’0’) THEN q <=’0’; END IF; END IF; END PROCESS; qb <= NOT(q); --generate the inverted output end srff_arch;
Logic Circuit Lab Spring 2004
2 Preliminary Questions
T here are no preliminary questions for this lab
/P /R
/S Q
/Q
D
C
/R
/S P
a Implement directly using NAND gates and inverters in schematic entry. b Implement using the negative edge triggered flip-flop component in the Xilinx software c Implement using a VHDL behavioral model, create a symbol for this, simulate, and compare to parts a and b.
D Q
T=CLK
Logic Circuit Lab Spring 2004
D D
Q1 Q
Binary Value = (Q2 Q1 Q0)
D
Q
CLK
3 The Lab