File: /home/young/mywork/c.arithmetic/bshfit/print.bshift Page 1 of 13

Similar documents
File: /home/young/mywork/5.cordic_vhdl/a.beh/print.cordic_beh Page 1 of 10

library STD; use STD.textio.all; library IEEE; use IEEE.std_logic_1164.all; use IEEE.numeric_std.all; package cordic_pkg is

File: /home/young/mywork/vlsi/c.arithmetic/adder/rtl/adder.print Page 1 of 20

File: /home/young/mywork/7.cordic_accuracy/ghdl/print.file Page 1 of 13

File: /home/young/mywork/5.cordic_vhdl/b.rtl/print.all Page 1 of 45

File: /home/young/mywork/5.cordic_vhdl/b.rtl/cordic.print Page 1 of 44

File: /home/young/mywork/7.cordic_accuracy/if.ghdl/ghdlif.print Page 1 of 15

File: /home/young/mywork/vlsi/c.ari etic/adder/rtl/adder.cla.print Page 1 of 6

ECE 545 Lecture 7. Advanced Testbenches. Required reading. Simple Testbench. Advanced Testbench. Possible Sources of Expected Outputs

ECE 545 Lecture 7. Advanced Testbenches. George Mason University

VHDL/Verilog Simulation. Testbench Design

VHDL Simulation. Testbench Design

VHDL Testbench. Test Bench Syntax. VHDL Testbench Tutorial 1. Contents

cla library ieee; use ieee.std_logic_1164.all;

VHDL Testbench Design. Textbook chapters 2.19, , 9.5

Lecture 6. Advanced Testbenches. George Mason University

Quartus Counter Example. Last updated 9/6/18

VHDL. Official Definition: VHSIC Hardware Description Language VHISC Very High Speed Integrated Circuit

Part 4: VHDL for sequential circuits. Introduction to Modeling and Verification of Digital Systems. Memory elements. Sequential circuits

ECE 545 Lecture 4. Simple Testbenches. George Mason University

VHDL: Code Structure. 1

COVER SHEET: Total: Regrade Info: 5 (5 points) 2 (8 points) 6 (10 points) 7b (13 points) 7c (13 points) 7d (13 points)

The University of Alabama in Huntsville ECE Department CPE Final Exam Solution Spring 2016

FINAL PROJECT DESIGN OF HOUGH TRANSFORM ON A CORDIC CONFIGURABLE ALGORITHM

search_chr: ASM chart search_chr search_chr search_chr MEM_ENABLE MEM_WE MEM_ADDRESS MEM_DATAIN MEM_DATAOUT MEM_READY ADDRESS CHAR LEN nfound

Simulation with ModelSim Altera from Quartus II

The University of Alabama in Huntsville ECE Department CPE Midterm Exam Solution March 2, 2006

Simulation with ModelSim Altera from Quartus II

VHDL And Synthesis Review

In our case Dr. Johnson is setting the best practices

CPE 626 Advanced VLSI Design Lecture 6: VHDL Synthesis. Register File: An Example. Register File: An Example (cont d) Aleksandar Milenkovic

EENG 2910 Project III: Digital System Design. Due: 04/30/2014. Team Members: University of North Texas Department of Electrical Engineering

Accelerate FPGA Prototyping with

Schedule. ECE U530 Digital Hardware Synthesis. Rest of Semester. Midterm Question 1a

The University of Alabama in Huntsville ECE Department CPE Midterm Exam Solution Spring 2016

Getting Started with VHDL

Design a 4 bit-adder. Then design a 4-7 decoder to show the outputs. Output Sum(4 bits) Adder. Output carry(1 bit)

EEL 4712 Digital Design Test 1 Spring Semester 2007

The block diagram representation is given below: The output equation of a 2x1 multiplexer is given below:


Test Benches - Module 8

EEL 4712 Name: SOLUTION Midterm 1 Spring 2016 VERSION 1 UFID:

Midterm Exam Thursday, October 24, :00--2:15PM (75 minutes)

DIGITAL LOGIC WITH VHDL (Fall 2013) Unit 6

EE434 ASIC & Digital Systems

Constructing VHDL Models with CSA


Multi-valued Logic. Standard Logic IEEE 1164 Type std_ulogic is ( U, uninitialized

Contents. Chapter 9 Datapaths Page 1 of 28

VHDL 200X: The Future of VHDL

VHDL 200X: The Future of VHDL

Control and Datapath 8

Sequential Statement

UNIT I Introduction to VHDL VHDL: - V -VHSIC, H - Hardware, D - Description, L Language Fundamental section of a basic VHDL code Library :

Digital Systems Design

VHDL. VHDL History. Why VHDL? Introduction to Structured VLSI Design. Very High Speed Integrated Circuit (VHSIC) Hardware Description Language

8-1. Fig. 8-1 ASM Chart Elements 2001 Prentice Hall, Inc. M. Morris Mano & Charles R. Kime LOGIC AND COMPUTER DESIGN FUNDAMENTALS, 2e, Updated.

ECE 545 Lecture 8. Data Flow Description of Combinational-Circuit Building Blocks. George Mason University

DIGITAL LOGIC DESIGN VHDL Coding for FPGAs Unit 6

Test Bench. Top Level Model Test Bench MUT

ECE 545: Lecture 11. Programmable Logic Memories

ECE 545 Lecture 9. Modeling of Circuits with a Regular Structure. Aliases, Attributes, Packages. George Mason University

ECE 545: Lecture 11. Programmable Logic Memories. Recommended reading. Memory Types. Memory Types. Memory Types specific to Xilinx FPGAs

LECTURE 4: The VHDL N-bit Adder

ECE 545 Lecture 17 RAM. George Mason University

Two HDLs used today VHDL. Why VHDL? Introduction to Structured VLSI Design

SEQUENTIAL STATEMENTS

Experiment 0 OR3 Gate ECE 332 Section 000 Dr. Ron Hayne June 8, 2003

VHDL- VHDL-3. Vsys. maxplus2. Vsys. d:\uoo. vsystem.ini work

The University of Alabama in Huntsville Electrical and Computer Engineering CPE/EE 422/522 Spring 2005 Homework #6 Solution

COVER SHEET: Total: Regrade Info: 2 (6 points) 3 (8 points) 4 (10 points) 8 (12 points) 6 (6 points) 7 (6 points) 9 (30 points) 10 (4 points)

Basic Language Elements

VHDL: Modeling RAM and Register Files. Textbook Chapters: 6.6.1, 8.7, 8.8, 9.5.2, 11.2

COE 405, Term 062. Design & Modeling of Digital Systems. HW# 1 Solution. Due date: Wednesday, March. 14

EITF35: Introduction to Structured VLSI Design

EECE 353: Digital Systems Design Lecture 10: Datapath Circuits

INTRODUCTION TO VHDL ADVANCED COMPUTER ARCHITECTURES. Slides by: Pedro Tomás. Additional reading: - ARQUITECTURAS AVANÇADAS DE COMPUTADORES (AAC)

ECE 699: Lecture 9. Programmable Logic Memories

C. Sisterna UNSJ Argentina. PACKAGE and SUBPROGRAMS

ECE 545 Lecture 5. Data Flow Modeling in VHDL. George Mason University

EL 310 Hardware Description Languages Midterm

Counters. Counter Types. Variations. Modulo Gray Code BCD (Decimal) Decade Ring Johnson (twisted ring) LFSR

Tutorial 4 HDL. Outline VHDL PROCESS. Modeling Combinational Logic. Structural Description Instantiation and Interconnection Hierarchy

VHDL in 1h. Martin Schöberl

Digitaalsüsteemide disain

Very High Speed Integrated Circuit Har dware Description Language

Problem Set 10 Solutions

TSIU03, SYSTEM DESIGN LECTURE 2

ECE Digital Design Laboratory. Lecture 3 Finite State Machines!

COVER SHEET: Total: Regrade Info: 5 (14 points) 7 (15 points) Midterm 1 Spring 2012 VERSION 1 UFID:

Logic and Computer Design Fundamentals VHDL. Part 1 Chapter 4 Basics and Constructs

TKT-1212 Digitaalijärjestelmien toteutus. Lecture 7: VHDL Testbenches Ari Kulmala, Erno Salminen 2008

File: /home/young/mywork/5.cordic_vhdl/f.c/lut.src.print Page 1 of 9

Basic Language Concepts

CSE 260 Digital Computers: Organization and Logical Design. Exam 2. Jon Turner 3/28/2012

VHDL Examples Mohamed Zaky

DIGITAL LOGIC DESIGN VHDL Coding for FPGAs Unit 3

Lattice VHDL Training

IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL

How to simulate an UART VHDL code with ghdl

Transcription:

File: /home/young/mywork/c.arithmetic/bshfit/print.bshift Page 1 of 13 makefile.suffixes :.o.vhdl.vhdl.o : ghdl -a $< # CNF_bshift = c3.bshift_tb_conf.rtl.o \ # c3.bshift_tb_conf.mux.o \ OBJ_bshift = cordic_pkg.o \ c3.bshift.o \ c3.bshift.rtl.o \ c3.bshift.mux.o \ c3.bshift_tb.o \ ${CNF_bshift} EXE_bshift = bshift_tb bshift_tb_conf RTLPATH = "/home/young/mywork/5.cordic_vhdl/b.rtl" bshift_tb_conf : ${OBJ_bshift} \rm -f ${EXE_bshift} ghdl -e bshift_tb_conf run_bshift_tb : bshift_tb_conf ghdl -r bshift_tb_conf disp-tree=inst stop-time=1us vcd=bshift.vcd # gtkwave bshift.vcd & # COPY_SRC = c3.bshift.vhdl \ c3.bshift.mux.vhdl \ copy_to_cordic : \cp ${COPY_SRC} ${RTLPATH} # clean : \rm -f *.o *~ *# *.cf \rm -f *_tb \rm -f *_conf \rm -f *.vcd \rm -f ${EXE_bshift}

File: /home/young/mywork/c.arithmetic/bshfit/print.bshift Page 2 of 13 # print_bshift : more makefile ${OBJ_bshift:o=vhdl} > print.bshift tar : mkdir src cp makefile *.vhdl src tar cvf bshift.tar src \rm -fr src cordic_pkg.vhdl Purpose: utility package of cordic Discussion: Licensing: This code is distributed under the GNU LGPL license. Modified: 2012.03.22 Author: Young W. Lim Functions: Conv2fixedPt (x : real; n : integer) return std_logic_vector; Conv2real (s : std_logic_vector (31 downto 0) ) return real; - library STD; use STD.textio.all; library IEEE; use IEEE.std_logic_1164.all; use IEEE.numeric_std.all;

File: /home/young/mywork/c.arithmetic/bshfit/print.bshift Page 3 of 13 package cordic_pkg is function Conv2fixedPt (x : real; n : integer) return std_logic_vector; function Conv2real (s : std_logic_vector (31 downto 0) ) return real; procedure DispReg (x, y, z : in std_logic_vector (31 downto 0); flag : in integer ); procedure DispAng (angle : in std_logic_vector (31 downto 0)) ; constant clk_period : time := 20 ns; constant half_period : time := clk_period / 2.0; constant pi : real := 3.141592653589793; constant K : real := 1.646760258121; end cordic_pkg; package body cordic_pkg is - function Conv2fixedPt (x : real; n : integer) return std_logic_vector is - constant shft : std_logic_vector (n-1 downto 0) := X"2000_0000"; variable s : std_logic_vector (n-1 downto 0) ; variable z : real := 0.0; - shft = 2^29 = 536870912 bit 31 : msb - sign bit bit 30,29 : integer part bit 28 ~ 0 : fractional part for the value of 0.5 first 4 msb bits [0, 0, 0, 1] > X"1000_0000" To obtain binary number representation of x, where the implicit decimal point between bit 29 and bit 28, multiply "integer converted shft" z := x * real(to_integer(unsigned(shft))); s := std_logic_vector(to_signed(integer(z), n)); return s; end Conv2fixedPt; -

File: /home/young/mywork/c.arithmetic/bshfit/print.bshift Page 4 of 13 - function Conv2real (s : std_logic_vector (31 downto 0) ) return real is - constant shft : std_logic_vector (31 downto 0) := X"2000_0000"; variable z : real := 0.0; - z := real(to_integer(signed(s))) / real(to_integer(unsigned(shft))); return z; end Conv2real; - - procedure DispReg (x, y, z : in std_logic_vector (31 downto 0); flag : in integer ) is - variable l : line; if (flag = 0) then write(l, String'("- ")); writeline(output, l); write(l, String'(" xi = ")); write(l, real'(conv2real(x))); write(l, String'(" yi = ")); write(l, real'(conv2real(y))); write(l, String'(" zi = ")); write(l, real'(conv2real(z))); elsif (flag = 1) then write(l, String'(" xo = ")); write(l, real'(conv2real(x))); write(l, String'(" yo = ")); write(l, real'(conv2real(y))); write(l, String'(" zo = ")); write(l, real'(conv2real(z))); else write(l, String'(" xn = ")); write(l, real'(conv2real(x))); write(l, String'(" yn = ")); write(l, real'(conv2real(y))); write(l, String'(" zn = ")); write(l, real'(conv2real(z))); end if; writeline(output, l); end DispReg; - - procedure DispAng (angle : in std_logic_vector (31 downto 0)) is - variable l : line; write(l, String'(" angle = ")); write(l, real'(conv2real(angle))); writeline(output, l); write(l, String'("... ")); writeline(output, l); end DispAng;

File: /home/young/mywork/c.arithmetic/bshfit/print.bshift Page 5 of 13 end cordic_pkg; c3.bshift.vhdl Purpose: Barrel Shifter Discussion: Licensing: This code is distributed under the GNU LGPL license. Modified: 2013.10.23 Author: Young W. Lim Parameters: Input: Output: - library STD; use STD.textio.all; library IEEE; use IEEE.std_logic_1164.all; use IEEE.numeric_std.all; entity bshift is generic ( WD : in natural := 32; SH : in natural := 5 ); port ( di : in std_logic_vector (WD-1 downto 0) := (others=>'0'); nbit : in std_logic_vector (SH-1 downto 0) := (others=>'0'); cs : in std_logic ; dq : out std_logic_vector (WD-1 downto 0) := (others=>'0'));

File: /home/young/mywork/c.arithmetic/bshfit/print.bshift Page 6 of 13 end bshift; c3.bshift.rtl.vhdl Purpose: Barrel Shifter Discussion: Licensing: This code is distributed under the GNU LGPL license. Modified: 2013.10.23 Author: Young W. Lim Parameters: Input: Output: - library STD; use STD.textio.all; library IEEE; use IEEE.std_logic_1164.all; use IEEE.numeric_std.all; architecture rtl of bshift is bshft: process (di, nbit)

File: /home/young/mywork/c.arithmetic/bshfit/print.bshift Page 7 of 13 variable dix : std_logic_vector (2*WD-1 downto 0) := (others=>'0'); variable offset : natural := 0; variable result : std_logic_vector (WD-1 downto 0) := (others=>'0'); process bshft for i in 2*WD-1 downto 0 loop if i < WD then dix(i) := di(i); else dix(i) := di(wd-1); end if; end loop; i if (cs='1') then offset := to_integer(unsigned(nbit)); else offset := 0; end if; result := dix(wd-1+offset downto offset); dq <= result; end process; end rtl; c3.bshift.mux.vhdl Purpose: Barrel Shifter Based on Mux Discussion: Licensing: This code is distributed under the GNU LGPL license. Modified: 2013.10.23 Author: Young W. Lim

File: /home/young/mywork/c.arithmetic/bshfit/print.bshift Page 8 of 13 Parameters: Input: Output: - library STD; use STD.textio.all; library IEEE; use IEEE.std_logic_1164.all; use IEEE.numeric_std.all; architecture mux of bshift is component mux is generic ( WD : in natural := 1); port ( an : in std_logic_vector (WD-1 downto 0); bn : in std_logic_vector (WD-1 downto 0); s : in std_logic; cn : out std_logic_vector (WD-1 downto 0) ); end component; type array2d is array (WD-1 downto 0, SH-1 downto 0) of std_logic; signal mout: array2d := ((others=> (others=> '0'))); signal m_in: array2d := ((others=> (others=> '0'))); j = SH-1 : top level mux row ILOOP: for i in WD-1 downto 0 generate Sign bit extension ZERO: if ((WD-1-i) < 2**(SH-1)) generate U0: mux generic map (WD => 1) port map (an(0) => di(i), bn(0) => di(wd-1), '0', di(wd-1), s => nbit(sh-1), cn(0) => mout(i, SH-1)); end generate ZERO; stride 2**(SH-1)

File: /home/young/mywork/c.arithmetic/bshfit/print.bshift Page 9 of 13 REST: if ((WD-1-i) >= 2**(SH-1)) generate U1 : mux generic map (WD => 1) port map (an(0) => di(i), bn(0) => di(i+2**(sh-1)), s => nbit(sh-1), cn(0) => mout(i, SH-1)); end generate REST; end generate ILOOP; rest of mux rows JLOOP: for j in SH-2 downto 0 generate ILOOP: for i in WD-1 downto 0 generate Sign bit extension ZERO: if ((WD-1-i) < 2**j) generate U0: mux generic map (WD => 1) port map (an(0) => m_in(i, j+1), bn(0) => m_in(wd-1, j+1), '0', m_in(wd-1, j+1), s => nbit(j), cn(0) => mout(i, j)); end generate ZERO; Stride 2**j REST: if ((WD-1-i) >= 2**j) generate U1: mux port map (an(0) => m_in(i, j+1), bn(0) => m_in(i+2**j, j+1), s => nbit(j), cn(0) => mout(i, j)); end generate REST; end generate ILOOP; end generate JLOOP; process (mout) variable tmp: array2d := ((others=> (others=> '0'))); tmp := mout; m_in <= tmp; for i in WD-1 downto 0 loop dq(i) <= tmp(i, 0); end loop;

File: /home/young/mywork/c.arithmetic/bshfit/print.bshift Page 10 of 13 wait on mout;, di, nbit; end process; end mux; c3.bshift_tb.vhdl Purpose: testbench of bshfit Discussion: Licensing: This code is distributed under the GNU LGPL license. Modified: 2012.07.27 Author: Young W. Lim Parameters: Input: Output: - library STD; use STD.textio.all; library IEEE; use IEEE.std_logic_1164.all; use IEEE.numeric_std.all; use WORK.cordic_pkg.all; use WORK.all;

File: /home/young/mywork/c.arithmetic/bshfit/print.bshift Page 11 of 13 entity bshift_tb is end bshift_tb; architecture beh of bshift_tb is component bshift generic ( WD : in natural := 32; SH : in natural := 5 ); port ( di : in std_logic_vector (WD-1 downto 0); nbit : in std_logic_vector (SH-1 downto 0); dq : out std_logic_vector (WD-1 downto 0) ); end component; for bshift_0: bshift use entity work.bshift(mux); constant nbit : integer := 32; signal clk, rst: std_logic := '0'; signal di : std_logic_vector(31 downto 0) := X"7FFF_FFFF"; signal dq : std_logic_vector(31 downto 0) := X"0000_0000"; signal cnt : std_logic_vector( 4 downto 0) := "00000"; DUT: bshift generic map (WD=>32, SH=>5) port map (di => di, nbit => cnt, dq => dq); clk <= not clk after half_period; rst <= '0', '1' after 2* half_period; process wait until rst = '1'; for i in 0 to 4 loop wait until clk = '1';

File: /home/young/mywork/c.arithmetic/bshfit/print.bshift Page 12 of 13 end loop; i di <= X"7FFF_FFFF"; di <= X"8000_0000"; wait for 0 ns; for i in 0 to 31 loop wait until (clk'event and clk='1'); cnt <= std_logic_vector(to_unsigned(i, 5)); wait for 0 ns; end loop; for i in 0 to 4 loop wait until clk = '1'; end loop; i end process; process wait for 100* clk_period; assert false report "end of simulation" severity failure; end process; XXXXXXX XXXXXX XXXXXX XXXXXX XXXXXXX XXXXXX XXXXX end beh; c3.bshift_tb_conf.rtl.vhdl Purpose: configuration of rca bshift testbench Discussion: Licensing: This code is distributed under the GNU LGPL license. Modified: 2013.10.23

File: /home/young/mywork/c.arithmetic/bshfit/print.bshift Page 13 of 13 Author: Young W. Lim Parameters: Input: Output: - use WORK.all; configuration bshift_tb_conf of bshift_tb is for beh for DUT: bshift use entity work.bshift(mux) ; end for; end for; end bshift_tb_conf;