MATLAB DESIGN HDL CODER RELEASE NOTES Betriebsanweisung Seite 56

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 410
  • Inhaltsverzeichnis
  • FEHLERBEHEBUNG
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 55
56 www.xilinx.com System Generator for DSP User Guide
UG640 (v 12.2) July 23, 2010
Chapter 1: Hardware Design Using System Generator
Shift Operations
This example shows how to implement bit-shift operations using the MCode block. Shift
operations are accomplished with multiplication and division by powers of two. For
example, multiplying by 4 is equivalent to a 2-bit left-shift, and dividing by 8 is equivalent
to a 3-bit right-shift. Shift operations are implemented by moving the binary point position
and if necessary, expanding the bit width. Consequently, multiplying a Fix_8_4 number by
4 results in a Fix_8_2 number, and multiplying a Fix_8_4 number by 64 results in a
Fix_10_0 number.
The following shows the xlsimpleshift.m file which specifies one left-shift and one
right-shift:
function [lsh3, rsh2] = xlsimpleshift(din)
% [lsh3, rsh2] = xlsimpleshift(din) does a left shift
% 3 bits and a right shift 2 bits.
% The shift operation is accomplished by
% multiplication and division of power
% of two constant.
lsh3 = din * 8;
rsh2 = din / 4;
The following diagram shows the sub-system after compilation:
Seitenansicht 55
1 2 ... 51 52 53 54 55 56 57 58 59 60 61 ... 409 410

Kommentare zu diesen Handbüchern

Keine Kommentare