Fibonacci Sequence Lecture L4.1 Lab 3.

Slides:



Advertisements
Similar presentations
Arbitrary Waveform Discussion 5.5 Example 34.
Advertisements

7-Segment Display: Spartan-3 board
1 VLSI DESIGN USING VHDL Part II A workshop by Dr. Junaid Ahmed Zubairi.
Ring Counter Discussion D5.3 Example 32. Ring Counter if rising_edge(CLK) then for i in 0 to 2 loop s(i)
Generic Multiplexers: Parameters Discussion D2.5 Example 8.
Multiplication Discussion Multiplier Binary Multiplication 4 x 4 Multiplier.
Decoders and Encoders Lecture L4.2. Decoders and Encoders Binary Decoders Binary Encoders Priority Encoders.
Logic Design Fundamentals - 3 Discussion D3.2. Logic Design Fundamentals - 3 Basic Gates Basic Combinational Circuits Basic Sequential Circuits.
Registers VHDL Tutorial R. E. Haskell and D. M. Hanna T2: Sequential Logic Circuits.
RS-232 Port Discussion D7.1. Loop feedback RS-232 voltage levels: +5.5 V (logic 0) -5.5 V (logic 1)
Pulse-Width Modulated DAC
Integer Square Root.
Single-Cycle Instructions VHDL Tutorial R. E. Haskell and D. M. Hanna T5: VHDL ROM.
Digilent Spartan 3 Board Lecture L2.2
FPGAs and VHDL Lecture L12.1. FPGAs and VHDL Field Programmable Gate Arrays (FPGAs) VHDL –2 x 1 MUX –4 x 1 MUX –An Adder –Binary-to-BCD Converter –A Register.
Structural VHDL VHDL Tutorial R. E. Haskell and D. M. Hanna T3: ALU Design.
Counters Discussion D5.3 Example 33. Counters 3-Bit, Divide-by-8 Counter 3-Bit Behavioral Counter in Verilog Modulo-5 Counter An N-Bit Counter.
Finite State Machines Discussion D7.1 Mealy and Moore Machines.
Multiplication Discussion Multiplier Binary Multiplication 4 x 4 Multiplier.
7-Segment Display DIO1 Board. Digilab2 – DIO1 Boards Four 7-segment displays A0A1A2A3.
Introduction to VHDL Multiplexers. Introduction to VHDL VHDL is an acronym for VHSIC (Very High Speed Integrated Circuit) Hardware Description Language.
Lecture L6.2 VHDL Multiply Operator (*)
Lab 2 4-Bit Adder Digilent Spartan 3 Board Lecture L2.3.
Division Lecture L6.3. Division
Finite State Machines Mano and Kime Sections 4-4, 4-5, 4-8.
FPGAs and VHDL Lecture L13.1 Sections 13.1 – 13.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.
Finite State Machines Discussion D8.1 Example 36.
7-Segment Displays Digilent Spartan 3 Board Discussion DS-4.2.
Introduction to VHDL Multiplexers Discussion D1.1.
Division Discussion D11.3. Division
Binary-to-BCD Converter
Registers Lab 5 Mano and Kime Sections 5-2, 5-3, 5-7.
Sequential Multiplication Lecture L6.4. Multiplication 13 x = 8Fh 1101 x
Shift Registers Discussion D5.2 Example Bit Shift Register qs(3) qs(2) qs(1) qs(0) if rising_edge(CLK) then for i in 0 to 2 loop s(i) := s(i+1);
7-Segment Display DIO1 Board Verilog.
VHDL Examples Subra Ganesan Reference: Professor Haskell’s Notes,
4-bit Shift Register. 2-bit Register Serial-in-serial-out Shift Register.
Binary-to-BCD Converter
VHDL in 1h Martin Schöberl. AK: JVMHWVHDL2 VHDL /= C, Java,… Think in hardware All constructs run concurrent Different from software programming Forget.
Copyright(c) 1996 W. B. Ligon III1 Getting Started with VHDL VHDL code is composed of a number of entities Entities describe the interface of the component.
2’s Complement 4-Bit Saturator Discussion D2.8 Lab 2.
 Seattle Pacific University EE Logic System DesignCounters-1 Shift Registers DQ clk DQ DQ ShiftIn Q3Q3 Q2Q2 DQ Q1Q1 Q0Q0 A shift register shifts.
CEC 220 Digital Circuit Design VHDL in Sequential Logic Wednesday, March 25 CEC 220 Digital Circuit Design Slide 1 of 13.
INF H131 Clock and Reset Unit (CRU) module library ieee; use ieee.std_logic_1164.all; entity cru is port ( arst : in std_logic; -- Asynch. reset.
Prime Numbers Lecture L6.1 Sieve of Eratosthenes.
Registers and Counters Discussion D8.1. Logic Design Fundamentals - 3 Registers Counters Shift Registers.
Sequential statements (1) process
Combinational logic circuit
Main Project : Simple Processor Mini-Project : Vending Machine Memory
Lecture L5.1 Mealy and Moore Machines
Part II A workshop by Dr. Junaid Ahmed Zubairi
Part III: SYSTEM DESIGN
CHAPTER 17 VHDL FOR SEQUENTIAL LOGIC
Part IV: VHDL CODING.
Pulse-Width Modulation (PWM)
A Data Stack CoreGen Discussion 12.1.
Binary-to-BCD Converter
VHDL (VHSIC Hardware Description Language)
A Greatest Common Divisor (GCD) Processor
Multiplication Discussion 11.1.
Modeling of Circuits with a Regular Structure
Figure 8.1. The general form of a sequential circuit.
Fast, Asynchronous SRAM
Modeling of Circuits with Regular Structure
Sequntial-Circuit Building Blocks
High-Low Guessing Game
디 지 털 시 스 템 설 계 UP2 Kit를 이용한 카운터 설계
(Sequential-Circuit Building Blocks)
EEL4712 Digital Design (Midterm 1 Review).
Presentation transcript:

Fibonacci Sequence Lecture L4.1 Lab 3

Fibonacci Sequence 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233,… F(0) = 0 F(1) = 1 F(n + 2) = F(n) + F(n + 1) for all n ≥ 0.

The Golden Rectangle b a a + b = f = a2 = ab + b2 1 = f + f2

Good Fibonacci Web Site http://www.mcs.surrey.ac.uk/Personal/R.Knott/Fibonacci/fibnat.html

Logic diagram to generate Fibonacci numbers

adder.vhd -- Title: adder library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_unsigned.all; entity adder is generic(width:positive); port ( A: in STD_LOGIC_VECTOR(width-1 downto 0); B: in STD_LOGIC_VECTOR(width-1 downto 0); S: out STD_LOGIC_VECTOR(width-1 downto 0) ); end adder; architecture adder_arch of adder is begin add1: process(A, B) S <= A + B; end process add1; end adder_arch; adder.vhd

regc.vhd -- Title: register with reset to 0 library IEEE; use IEEE.std_logic_1164.all; entity regc is generic(width: positive); port ( d: in STD_LOGIC_VECTOR (width-1 downto 0); load: in STD_LOGIC; reset: in STD_LOGIC; clk: in STD_LOGIC; q: out STD_LOGIC_VECTOR (width-1 downto 0) ); end regc;

regc.vhd architecture regc_arch of regc is begin process(clk, reset) if reset = '1' then for i in width-1 downto 0 loop q(i) <= '0'; end loop; elsif (clk'event and clk = '1') then if load = '1' then q <= d; end if; end process; end regc_arch;

regs.vhd -- Title: register with reset to 1 library IEEE; use IEEE.std_logic_1164.all; entity regc is generic(width: positive); port ( d: in STD_LOGIC_VECTOR (width-1 downto 0); load: in STD_LOGIC; reset: in STD_LOGIC; clk: in STD_LOGIC; q: out STD_LOGIC_VECTOR (width-1 downto 0) ); end regc;

regs.vhd architecture regs_arch of regs is begin process(clk, reset) if reset = '1' then for i in width-1 downto 1 loop q(i) <= '0'; end loop; q(0) <= '1'; elsif (clk'event and clk = '1') then if load = '1' then q <= d; end if; end process; end regs_arch;

fib_components.vhd -- A package containing component declarations -- for the Fibonacci counter library IEEE; use IEEE.std_logic_1164.all; package fib_components is component regs generic(width: positive); port ( d: in STD_LOGIC_VECTOR (width-1 downto 0); load: in STD_LOGIC; reset: in STD_LOGIC; clk: in STD_LOGIC; q: out STD_LOGIC_VECTOR (width-1 downto 0) ); end component;

fib_components.vhd (cont.) component regc generic(width: positive); port ( d: in STD_LOGIC_VECTOR (width-1 downto 0); load: in STD_LOGIC; reset: in STD_LOGIC; clk: in STD_LOGIC; q: out STD_LOGIC_VECTOR (width-1 downto 0) ); end component;

fib_components.vhd (cont.) component adder generic( width : POSITIVE); port( a : in std_logic_vector((width-1) downto 0); b : in std_logic_vector((width-1) downto 0); y : out std_logic_vector((width-1) downto 0)); end component; component binbcd port ( B: in STD_LOGIC_VECTOR (15 downto 0); P: out STD_LOGIC_VECTOR (15 downto 0)); component x7seg Port ( x : in std_logic_vector(15 downto 0); cclk, clr : in std_logic; AtoG : out std_logic_vector(6 downto 0); A : out std_logic_vector(3 downto 0)); end fib_components;

fib.vhd -- Title: Fibonacci Sequence library IEEE; use IEEE.STD_LOGIC_1164.all; use IEEE.std_logic_unsigned.all; use work.fib_components.all; entity fib is port( mclk : in STD_LOGIC; bn : in STD_LOGIC; BTN4 : in STD_LOGIC; led: out std_logic; ldg : out STD_LOGIC; AtoG : out STD_LOGIC_VECTOR(6 downto 0); A : out STD_LOGIC_VECTOR(3 downto 0) ); end fib;

fib.vhd (cont.) architecture fib_arch of fib is -- System Library Components component IBUFG port ( I : in STD_LOGIC; O : out std_logic ); end component; signal s, r, t, p: std_logic_vector(15 downto 0); signal clr, clk, cclk, bnbuf, one, reset: std_logic; signal clkdiv: std_logic_vector(24 downto 0); constant bus_width: positive := 16;

fib.vhd (cont.) begin U00: IBUFG port map (I => bn, O => bnbuf); led <= bnbuf; ldg <= '1'; -- enable 74HC373 latch clr <= BTN4; -- Divide the master clock (50Mhz) process (mclk) if mclk = '1' and mclk'Event then clkdiv <= clkdiv + 1; end if; end process; clk <= bnbuf; cclk <= clkdiv(17); -- 190 Hz one <= '1';

fib.vhd (cont.) U1: adder generic map(width => bus_width) port map (a => t, b => r, y => s); R1: regs generic map(width => bus_width) port map (d => r, load =>one, reset => reset, clk =>clk, q => t); W1: regc generic map(width => bus_width) port map (d => s, load => one, reset => reset, clk =>clk, q => r); U2: binbcd port map (B => r, P => p); U3: x7seg port map (x => p, cclk => cclk, clr => clr, AtoG => AtoG, A => A); end fib_arch;

Logic diagram to generate Fibonacci numbers

Verilog adder.v // Title: adder module adder(a,b,y); parameter width = 4; input [width-1:0] a; input [width-1:0] b; output [width-1:0] y; reg [width-1:0] y; always @(a, b) begin y = a + b; end endmodule

regc.v // Title: register with reset to 0 module regc(d,load,reset,clk,q); parameter width = 4; input [width-1:0] d; input load, reset, clk; output [width-1:0] q; integer i; reg [width-1:0] q; always @(posedge clk or posedge reset) begin if(reset) q <= 0; else if(load) q <= d; end endmodule

regs.v // Title: register with reset to 1 module regs(d,load,reset,clk,q); parameter width = 4; input [width-1:0] d; input load, reset, clk; output [width-1:0] q; integer i; reg [width-1:0] q; always @(posedge clk or posedge reset) begin if(reset) q <= 1; else if(load) q <= d; end endmodule

fib.vhd // Title: Fibonacci Sequence module fib(mclk, bn, BTN4, led, ldg, AtoG, A); input mclk, bn, BTN4; output led; output [6:0] AtoG; output [3:0] A; wire [6:0] AtoG; wire [3:0] A; wire clr, cclk, bnbuf; reg [24:0] clkdiv; wire [15:0] s, r, t, p;

IBUFG U00 (.I (bn), .O (bnbuf)); assign led = bnbuf; assign clr = BTN4; assign clk = bnbuf; // Divide the master clock (50Mhz) always @(posedge mclk) begin clkdiv <= clkdiv + 1; end assign cclk = clkdiv[17]; // 190 Hz assign one = 1;

defparam U1.width = 16, R1.width = 16, W1.width = 16 ; adder U1(.a(t),.b(r),.y(s)); regs R1(.d(r),.load(one),.reset(reset),.clk(clk),.q(t)); regc W1(.d(s),.load(one),.reset(reset),.clk(clk),.q(r)); binbcd U2(.B(r),.P(p)); x7seg U3(.x(p),.cclk(cclk),.clr(clr),.AtoG(AtoG),.A(A)); endmodule