Digilab 7-Segment Displays Lab 4. selyInstruction name “000”true if b = a false otherwise =...

24
Digilab 7-Segment Displays Lab 4
  • date post

    21-Dec-2015
  • Category

    Documents

  • view

    213
  • download

    0

Transcript of Digilab 7-Segment Displays Lab 4. selyInstruction name “000”true if b = a false otherwise =...

Page 1: Digilab 7-Segment Displays Lab 4. selyInstruction name “000”true if b = a false otherwise = “001”true if b /= a false otherwise  “010”true if b < a.

Digilab 7-Segment Displays

Lab 4

Page 2: Digilab 7-Segment Displays Lab 4. selyInstruction name “000”true if b = a false otherwise = “001”true if b /= a false otherwise  “010”true if b < a.

Lab 4

a(n-1:0)y(n-1:0)

sel(2:0)

n-line

ALU3

b(n-1:0)

sel y Instruction name

“000” true if b = afalse otherwise

=

“001” true if b /= afalse otherwise

<>

“010” true if b < a (unsigned)false otherwise

U<

“011” true if b > a (unsigned)false otherwise

U>

“100” true if b <= a (unsigned)false otherwise

U<=

“101” true if b < a (signed)false otherwise

<

“110” true if b > a (signed)false otherwise

>

“111” true if b <= a (signed)false otherwise

<=

Page 3: Digilab 7-Segment Displays Lab 4. selyInstruction name “000”true if b = a false otherwise = “001”true if b /= a false otherwise  “010”true if b < a.

Digilab2 – DIO1 Boards

Four 7-segmentdisplays

dig1 dig2 dig3 dig4

Page 4: Digilab 7-Segment Displays Lab 4. selyInstruction name “000”true if b = a false otherwise = “001”true if b /= a false otherwise  “010”true if b < a.

Digilab2 Board – Common Anodes

A1 A2 A3 A4

AtoG(6 downto 0)

Pins

Pins

Page 5: Digilab 7-Segment Displays Lab 4. selyInstruction name “000”true if b = a false otherwise = “001”true if b /= a false otherwise  “010”true if b < a.

switches

7-segment displaysLEDs

pushbuttons

Digilab XLA

Page 6: Digilab 7-Segment Displays Lab 4. selyInstruction name “000”true if b = a false otherwise = “001”true if b /= a false otherwise  “010”true if b < a.

Digilab Board

dig3 dig2 dig1dig4

Page 7: Digilab 7-Segment Displays Lab 4. selyInstruction name “000”true if b = a false otherwise = “001”true if b /= a false otherwise  “010”true if b < a.

Digilab XLA Board – Common Anodes

A4 A3 A2 A1

CA CB CC CD CE CF CG

Pins

Pins

Page 8: Digilab 7-Segment Displays Lab 4. selyInstruction name “000”true if b = a false otherwise = “001”true if b /= a false otherwise  “010”true if b < a.

7-Segment Decoder

a

b

c

d

e

f

g

dp

a b c d e f g dp

q0

q1

q2

q3

seg7dec

a-g LOW to turn on segment

Page 9: Digilab 7-Segment Displays Lab 4. selyInstruction name “000”true if b = a false otherwise = “001”true if b /= a false otherwise  “010”true if b < a.

library IEEE;use IEEE.std_logic_1164.all; entity seg7dec is port (q: in STD_LOGIC_VECTOR(3 downto 0);

AtoG: out STD_LOGIC_VECTOR(6 downto 0));end seg7dec;

7-Segment Decoder

Page 10: Digilab 7-Segment Displays Lab 4. selyInstruction name “000”true if b = a false otherwise = “001”true if b /= a false otherwise  “010”true if b < a.

architecture seg7dec_arch of seg7dec isbegin process(q) begin case q is when "0000" => AtoG <= "0000001"; when "0001" => AtoG <= "1001111"; when "0010" => AtoG <= "0010010"; when "0011" => AtoG <= "0000110"; when "0100" => AtoG <= "1001100"; when "0101" => AtoG <= "0100100"; when "0110" => AtoG <= "0100000"; when "0111" => AtoG <= "0001101"; when "1000" => AtoG <= "0000000"; when "1001" => AtoG <= "0000100"; when "1010" => AtoG <= "0001000"; when "1011" => AtoG <= "1100000"; when "1100" => AtoG <= "0110001"; when "1101" => AtoG <= "1000010"; when "1110" => AtoG <= "0110000"; when others => AtoG <= "0111000"; end case; end process;end seg7dec_arch;

Page 11: Digilab 7-Segment Displays Lab 4. selyInstruction name “000”true if b = a false otherwise = “001”true if b /= a false otherwise  “010”true if b < a.

Digilab2 Board – Common Anodes

A1 A2 A3 A4

AtoG(6 downto 0)

Pins

Pins

Page 12: Digilab 7-Segment Displays Lab 4. selyInstruction name “000”true if b = a false otherwise = “001”true if b /= a false otherwise  “010”true if b < a.

Multiplex displays

1 0 0 0

0 0 0 0 1 1 0

Page 13: Digilab 7-Segment Displays Lab 4. selyInstruction name “000”true if b = a false otherwise = “001”true if b /= a false otherwise  “010”true if b < a.

Multiplex displays

0 1 0 0

0 0 0 1 1 1 1

Page 14: Digilab 7-Segment Displays Lab 4. selyInstruction name “000”true if b = a false otherwise = “001”true if b /= a false otherwise  “010”true if b < a.

Multiplex displays

0 0 1 0

1 0 0 1 1 0 0

Page 15: Digilab 7-Segment Displays Lab 4. selyInstruction name “000”true if b = a false otherwise = “001”true if b /= a false otherwise  “010”true if b < a.

Multiplex displays

0 0 0 1

0 1 1 1 0 0 0

Page 16: Digilab 7-Segment Displays Lab 4. selyInstruction name “000”true if b = a false otherwise = “001”true if b /= a false otherwise  “010”true if b < a.

Lab 4

ALU3

Acode

seg7dec

Lab4

SW(5:8)

SW(1:4)

cclk

BTN4

AtoG(6:0)

A(1:4)Aen(1:4)

Asel(1:0)

a

b

y

sel

y1

q1(2:0)

“1111”

clkdivctr2bit

clk

clr

q

IBUFG

mclk

bnbnbuf

q1(1:0)

q1(2)

LD(1:8)

ldg‘1’

A(1:4)

led

Page 17: Digilab 7-Segment Displays Lab 4. selyInstruction name “000”true if b = a false otherwise = “001”true if b /= a false otherwise  “010”true if b < a.

signal clkdiv: std_logic_vector(23 downto 0);begin

-- Divide the master clock (50MHz) down -- to a lower frequency.process (mclk)begin

if mclk = '1' and mclk'Event thenclkdiv <= clkdiv + 1;

end if;end process;

 cclk <= clkdiv(17); -- 190 Hz = 50MHz/2^18

Page 18: Digilab 7-Segment Displays Lab 4. selyInstruction name “000”true if b = a false otherwise = “001”true if b /= a false otherwise  “010”true if b < a.

-- A 2-bit up-counterlibrary IEEE;use IEEE.std_logic_1164.all;use IEEE.std_logic_unsigned.all; entity ctr2bit is port ( clr: in STD_LOGIC; clk: in STD_LOGIC; q: out STD_LOGIC_VECTOR (1 downto 0) );end ctr2bit;

ctr2bit.vhd

Page 19: Digilab 7-Segment Displays Lab 4. selyInstruction name “000”true if b = a false otherwise = “001”true if b /= a false otherwise  “010”true if b < a.

architecture ctr2bit_arch of ctr2bit isbeginprocess (clk, clr)variable COUNT: STD_LOGIC_VECTOR (1 downto 0);begin if clr = '1' then q <= "00"; elsif clk'event and clk='1' then COUNT := COUNT + 1; q <= COUNT; end if;end process;end ctr2bit_arch;

ctr2bit.vhd

Page 20: Digilab 7-Segment Displays Lab 4. selyInstruction name “000”true if b = a false otherwise = “001”true if b /= a false otherwise  “010”true if b < a.

Lab 4

ALU3

Acode

seg7dec

Lab4

SW(5:8)

SW(1:4)

cclk

BTN4

AtoG(6:0)

A(1:4)Aen(1:4)

Asel(1:0)

a

b

y

sel

y1

q1(2:0)

“1111”

clkdivctr2bit

clk

clr

q

IBUFG

mclk

bnbnbuf

q1(1:0)

q1(2)

LD(1:8)

ldg‘1’

A(1:4)

led

Page 21: Digilab 7-Segment Displays Lab 4. selyInstruction name “000”true if b = a false otherwise = “001”true if b /= a false otherwise  “010”true if b < a.

library IEEE;use IEEE.std_logic_1164.all; entity Acode is port ( Aen: in STD_LOGIC_VECTOR (3 downto 0); Asel: in STD_LOGIC_VECTOR (1 downto 0); A: out STD_LOGIC_VECTOR (3 downto 0) );end Acode;

Acode.vhd

Page 22: Digilab 7-Segment Displays Lab 4. selyInstruction name “000”true if b = a false otherwise = “001”true if b /= a false otherwise  “010”true if b < a.

architecture Acode_arch of Acode isbegin process(Aen, Asel) begin A <= "0000"; case Asel is when "00" => if Aen(1) = '1' then A <= "1000"; end if; when "01" => if Aen(2) = '1' then A <= "0100"; end if; when "10" => if Aen(3) = '1' then A <= "0010"; end if; when others => if Aen(4) = '1' then A <= "0001"; end if; end case; end process; end Acode_arch;

Acode.vhd

Page 23: Digilab 7-Segment Displays Lab 4. selyInstruction name “000”true if b = a false otherwise = “001”true if b /= a false otherwise  “010”true if b < a.

Lab 4

ALU3

Acode

seg7dec

Lab4

SW(5:8)

SW(1:4)

cclk

BTN4

AtoG(6:0)

A(1:4)Aen(1:4)

Asel(1:0)

a

b

y

sel

y1

q1(2:0)

“1111”

clkdivctr2bit

clk

clr

q

IBUFG

mclk

bnbnbuf

q1(1:0)

q1(2)

LD(1:8)

ldg‘1’

A(1:4)

led

Page 24: Digilab 7-Segment Displays Lab 4. selyInstruction name “000”true if b = a false otherwise = “001”true if b /= a false otherwise  “010”true if b < a.

-- System Library Components 

component IBUFGport (

I : in STD_LOGIC; O : out std_logic

);end component;

U00: IBUFG port map (I => bn, O => bnbuf);

ALU3

Acode

seg7dec

Lab4

SW(5:8)

SW(1:4)

cclk

BTN4

AtoG(6:0)

A(1:4)Aen(1:4)

Asel(1:0)

a

b

y

sel

y1

q1(2:0)

“1111”

clkdivctr2bit

clk

clr

q

IBUFG

mclk

bnbnbuf

q1(1:0)

q1(2)

LD(1:8)

ldg‘1’

A(1:4)

led