Update repo
This commit is contained in:
+24
@@ -0,0 +1,24 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="fastintdiv_example"
|
||||
device="Generic C28xx Device"
|
||||
cgtVersion="22.6.0.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="RAM" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --define=DEBUG --cla_support=cla1 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu2 --idiv_support=idiv0 --define=CPU1 --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x100 --heap_size=0x200 --define RAM" />
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../../driverlib/f28002x/driverlib/" scope="project" />
|
||||
<file action="copy" path="../../../../../../../device_support/f28002x/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../../device_support/f28002x/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../../device_support/f28002x/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../../device_support/f28002x/common/targetConfigs/TMS320F280025C.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../cmd/28002x_RAM_lnk.cmd" targetDirectory="" applicableConfigurations="RAM" />
|
||||
<file action="copy" path="../../../../../../../driverlib/f28002x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../../../../../../../device_support/f28002x/common/source/f28002x_codestartbranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../../driverlib/f28002x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../fastintdiv_example.c" targetDirectory="" />
|
||||
<file action="copy" path="../fastintdiv_example.h" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,641 @@
|
||||
//#############################################################################
|
||||
//
|
||||
//! \file fastintdiv_example.c
|
||||
//!
|
||||
//! \brief Performs various types of fast Division using FASTINTDIV Intrinsics
|
||||
//! \date Feb 14, 2019
|
||||
//
|
||||
// Group: C2000
|
||||
// Target Device: TMS320f28002xx
|
||||
//
|
||||
// The following example showcases how various FASTINTDIV intrinsics can be used
|
||||
// to perform various types of division in the fastest way possible. The
|
||||
// example tests each of the 21 intrinsics by providing two sets of input data
|
||||
// and compares the quotient and remainder with the expect value. If both the
|
||||
// values match the pass counter is incremented for every intrinsic test. If
|
||||
// all the intrinsics give correct value then the value of "pass_count" should
|
||||
// be 21 at the end of the code and value of "success" will be 1.
|
||||
//
|
||||
// Add following watch variables to expressions window
|
||||
// -: pass_count
|
||||
// -: success
|
||||
//
|
||||
// Number of software cycles required for each integer division intrinsic including
|
||||
// cycles for output value assignment are indicated below
|
||||
//
|
||||
// 16-bit by 16-bit
|
||||
// __traditional_div_i16byi16() or int/int -> 16 cycles
|
||||
// __euclidean_div_i16byi16() -> 14 cycles
|
||||
// __modulo_div_i16byi16() -> 14 cycles
|
||||
// __traditional_div_u16byu16() or uint16_t/uint16_t -> 14 cycles
|
||||
//
|
||||
// 32-bit by 32-bit
|
||||
// __traditional_div_i32byi32() or long/long -> 13 cycles
|
||||
// __euclidean_div_i32byi32() -> 14 cycles
|
||||
// __modulo_div_i32byi32() -> 14 cycles
|
||||
// __traditional_div_i32byu32() or long/unsigned long -> 14 cycles
|
||||
// __modulo_div_i32byu32() -> 14 cycles
|
||||
// __traditional_div_u32byu32() or unsigned long/unsigned long -> 12 cycles
|
||||
//
|
||||
// 32-bit by 16-bit
|
||||
// __traditional_div_i32byi16() or long/int -> 18 cycles
|
||||
// __euclidean_div_i32byi16() -> 16 cycles
|
||||
// __modulo_div_i32byi16() -> 16 cycles
|
||||
// __traditional_div_u32byu16() or unsigned long/uint16_t -> 13 cycles
|
||||
//
|
||||
// 64-bit by 64-bit
|
||||
// __traditional_div_i64byi64() or long long/long long -> 42 cycles
|
||||
// __euclidean_div_i64byi64() -> 42 cycles
|
||||
// __modulo_div_i64byi64() -> 42 cycles
|
||||
// __traditional_div_i64byu64() or long long/unsigned long long -> 42 cycles
|
||||
// __euclidean_div_i64byu64() -> 42 cycles
|
||||
// __modulo_div_i64byu64() -> 42 cycles
|
||||
// __traditional_div_u64byu64() or unsigned long long/unsigned long long -> 42 cycles
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
#include <stdlib.h>
|
||||
#include "fastintdiv_example.h"
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
|
||||
// 16-bit by 16-bit
|
||||
uint16_t test_traditional_div_i16byi16();
|
||||
uint16_t test_euclidean_div_i16byi16();
|
||||
uint16_t test_modulo_div_i16byi16();
|
||||
uint16_t test_traditional_div_u16byu16();
|
||||
|
||||
// 32-bit by 32-bit
|
||||
uint16_t test_traditional_div_i32byi32();
|
||||
uint16_t test_euclidean_div_i32byi32();
|
||||
uint16_t test_modulo_div_i32byi32();
|
||||
uint16_t test_traditional_div_i32byu32();
|
||||
uint16_t test_modulo_div_i32byu32();
|
||||
uint16_t test_traditional_div_u32byu32();
|
||||
|
||||
|
||||
// 32-bit by 16-bit
|
||||
uint16_t test_traditional_div_i32byi16();
|
||||
uint16_t test_euclidean_div_i32byi16();
|
||||
uint16_t test_modulo_div_i32byi16();
|
||||
uint16_t test_traditional_div_u32byu16();
|
||||
|
||||
// 64-bit by 64-bit
|
||||
uint16_t test_traditional_div_i64byi64();
|
||||
uint16_t test_euclidean_div_i64byi64();
|
||||
uint16_t test_modulo_div_i64byi64();
|
||||
uint16_t test_traditional_div_i64byu64();
|
||||
uint16_t test_euclidean_div_i64byu64();
|
||||
uint16_t test_modulo_div_i64byu64();
|
||||
uint16_t test_euclidean_div_i64byi64();
|
||||
uint16_t test_traditional_div_u64byu64();
|
||||
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
uint16_t pass_count = 0, success = 0;
|
||||
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Disable pin locks and enable internal pullups.
|
||||
//
|
||||
Device_initGPIO();
|
||||
|
||||
|
||||
//
|
||||
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
|
||||
//
|
||||
Interrupt_initModule();
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
//
|
||||
Interrupt_initVectorTable();
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
|
||||
//
|
||||
// Calling routines for testing the fast division intrinsics
|
||||
// and updating pass counter value
|
||||
//
|
||||
|
||||
// 16-bit by 16-bit
|
||||
pass_count += test_traditional_div_i16byi16();
|
||||
pass_count += test_euclidean_div_i16byi16();
|
||||
pass_count += test_modulo_div_i16byi16();
|
||||
pass_count += test_traditional_div_u16byu16();
|
||||
|
||||
// 32-bit by 32-bit
|
||||
pass_count += test_traditional_div_i32byi32();
|
||||
pass_count += test_euclidean_div_i32byi32();
|
||||
pass_count += test_modulo_div_i32byi32();
|
||||
pass_count += test_traditional_div_i32byu32();
|
||||
pass_count += test_modulo_div_i32byu32();
|
||||
pass_count += test_traditional_div_u32byu32();
|
||||
|
||||
|
||||
// 32-bit by 16-bit
|
||||
pass_count += test_traditional_div_i32byi16();
|
||||
pass_count += test_euclidean_div_i32byi16();
|
||||
pass_count += test_modulo_div_i32byi16();
|
||||
pass_count += test_traditional_div_u32byu16();
|
||||
|
||||
// 64-bit by 64-bit
|
||||
pass_count += test_traditional_div_i64byi64();
|
||||
pass_count += test_euclidean_div_i64byi64();
|
||||
pass_count += test_modulo_div_i64byi64();
|
||||
pass_count += test_traditional_div_i64byu64();
|
||||
pass_count += test_euclidean_div_i64byu64();
|
||||
pass_count += test_modulo_div_i64byu64();
|
||||
pass_count += test_traditional_div_u64byu64();
|
||||
|
||||
//
|
||||
// Updating the "success" variable based on pass counter
|
||||
//
|
||||
if (pass_count == 21)
|
||||
success = 1;
|
||||
else
|
||||
success = 0;
|
||||
|
||||
//
|
||||
// Loop indefinitely
|
||||
//
|
||||
while(1)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing traditional i16/i16
|
||||
//
|
||||
uint16_t test_traditional_div_i16byi16()
|
||||
{
|
||||
parameters_div_i16byi16 data1 = {-512,20,-25,-12}, data2 = {2477,-23,-107,16};
|
||||
ldiv_t result1,result2;
|
||||
|
||||
result1.quot = data1.dividend / data1.divisor;
|
||||
result1.rem = data1.dividend % data1.divisor;
|
||||
result2.quot = data2.dividend / data2.divisor;
|
||||
result2.rem = data2.dividend % data2.divisor;
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing euclidean i16/i16
|
||||
//
|
||||
uint16_t test_euclidean_div_i16byi16()
|
||||
{
|
||||
parameters_div_i16byi16 data1 = {-512,20,-26,8}, data2 = {2477,-23,-107,16};
|
||||
ldiv_t result1,result2;
|
||||
|
||||
result1 = __euclidean_div_i16byi16(data1.dividend, data1.divisor);
|
||||
result2 = __euclidean_div_i16byi16(data2.dividend, data2.divisor);
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing modulo i16/i16
|
||||
//
|
||||
uint16_t test_modulo_div_i16byi16()
|
||||
{
|
||||
parameters_div_i16byi16 data1 = {-512,20,-26,8}, data2 = {2477,-23,-108,-7};
|
||||
ldiv_t result1,result2;
|
||||
|
||||
result1 = __modulo_div_i16byi16(data1.dividend, data1.divisor);
|
||||
result2 = __modulo_div_i16byi16(data2.dividend, data2.divisor);
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing traditional u16/u16
|
||||
//
|
||||
uint16_t test_traditional_div_u16byu16()
|
||||
{
|
||||
parameters_div_u16byu16 data1 = {512,20,25,12}, data2 = {2477,23,107,16};
|
||||
__uldiv_t result1,result2;
|
||||
|
||||
result1.quot = data1.dividend / data1.divisor;
|
||||
result1.rem = data1.dividend % data1.divisor;
|
||||
result2.quot = data2.dividend / data2.divisor;
|
||||
result2.rem = data2.dividend % data2.divisor;
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing traditional i32/i32
|
||||
//
|
||||
uint16_t test_traditional_div_i32byi32()
|
||||
{
|
||||
parameters_div_i32byi32 data1 = {-19016,246,-77,-74},data2 = {10414,-83,-125,39};
|
||||
ldiv_t result1,result2;
|
||||
|
||||
result1.quot = data1.dividend / data1.divisor;
|
||||
result1.rem = data1.dividend % data1.divisor;
|
||||
result2.quot = data2.dividend / data2.divisor;
|
||||
result2.rem = data2.dividend % data2.divisor;
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing euclidean i32/i32
|
||||
//
|
||||
uint16_t test_euclidean_div_i32byi32()
|
||||
{
|
||||
parameters_div_i32byi32 data1 = {-19016,246,-78,172}, data2 = {10414,-83,-125,39};
|
||||
ldiv_t result1,result2;
|
||||
|
||||
result1 = __euclidean_div_i32byi32(data1.dividend, data1.divisor);
|
||||
result2 = __euclidean_div_i32byi32(data2.dividend, data2.divisor);
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing modulo i32/i32
|
||||
//
|
||||
uint16_t test_modulo_div_i32byi32()
|
||||
{
|
||||
parameters_div_i32byi32 data1 = {-19016,246,-78,172}, data2 = {10414,-83,-126,-44};
|
||||
ldiv_t result1,result2;
|
||||
|
||||
result1 = __modulo_div_i32byi32(data1.dividend, data1.divisor);
|
||||
result2 = __modulo_div_i32byi32(data2.dividend, data2.divisor);
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing traditional i32/u32
|
||||
//
|
||||
uint16_t test_traditional_div_i32byu32()
|
||||
{
|
||||
parameters_div_i32byu32 data1 = {-19016,246,-77,-74}, data2 = {-10414,83,-125,-39};
|
||||
ldiv_t result1,result2;
|
||||
|
||||
result1 = __traditional_div_i32byu32(data1.dividend, data1.divisor);
|
||||
result2 = __traditional_div_i32byu32(data2.dividend, data2.divisor);
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing modulo i32/u32
|
||||
//
|
||||
uint16_t test_modulo_div_i32byu32()
|
||||
{
|
||||
parameters_div_i32byu32 data1 = {-19016,246,-78,172}, data2 = {-10414,83,-126,44};
|
||||
ldiv_t result1,result2;
|
||||
|
||||
result1 = __modulo_div_i32byu32(data1.dividend, data1.divisor);
|
||||
result2 = __modulo_div_i32byu32(data2.dividend, data2.divisor);
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing traditional u32/u32
|
||||
//
|
||||
uint16_t test_traditional_div_u32byu32()
|
||||
{
|
||||
parameters_div_u32byu32 data1 = {19016,246,77,74}, data2 = {10414,83,125,39};
|
||||
__uldiv_t result1,result2;
|
||||
|
||||
result1.quot = data1.dividend / data1.divisor;
|
||||
result1.rem = data1.dividend % data1.divisor;
|
||||
result2.quot = data2.dividend / data2.divisor;
|
||||
result2.rem = data2.dividend % data2.divisor;
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing traditional i32/i16
|
||||
//
|
||||
uint16_t test_traditional_div_i32byi16()
|
||||
{
|
||||
parameters_div_i32byi16 data1 = {-19016,20,-950,-16}, data2 = {10414,-23,-452,18};
|
||||
ldiv_t result1,result2;
|
||||
|
||||
result1.quot = data1.dividend / data1.divisor;
|
||||
result1.rem = data1.dividend % data1.divisor;
|
||||
result2.quot = data2.dividend / data2.divisor;
|
||||
result2.rem = data2.dividend % data2.divisor;
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing euclidean i32/i16
|
||||
//
|
||||
uint16_t test_euclidean_div_i32byi16()
|
||||
{
|
||||
parameters_div_i32byi16 data1 = {-19016,20,-951,4}, data2 = {10414,-23,-452,18};
|
||||
ldiv_t result1,result2;
|
||||
|
||||
result1 = __euclidean_div_i32byi16(data1.dividend, data1.divisor);
|
||||
result2 = __euclidean_div_i32byi16(data2.dividend, data2.divisor);
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing modulo i32/i16
|
||||
//
|
||||
uint16_t test_modulo_div_i32byi16()
|
||||
{
|
||||
parameters_div_i32byi16 data1 = {-19016,20,-951,4}, data2 = {10414,-23,-453,-5};
|
||||
ldiv_t result1,result2;
|
||||
|
||||
result1 = __modulo_div_i32byi16(data1.dividend, data1.divisor);
|
||||
result2 = __modulo_div_i32byi16(data2.dividend, data2.divisor);
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing traditional u32/u16
|
||||
//
|
||||
uint16_t test_traditional_div_u32byu16()
|
||||
{
|
||||
parameters_div_u32byu16 data1 = {19016,20,950,16}, data2 = {10414,23,452,18};
|
||||
__uldiv_t result1,result2;
|
||||
|
||||
result1.quot = data1.dividend / data1.divisor;
|
||||
result1.rem = data1.dividend % data1.divisor;
|
||||
result2.quot = data2.dividend / data2.divisor;
|
||||
result2.rem = data2.dividend % data2.divisor;
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing traditional i64/i64
|
||||
//
|
||||
uint16_t test_traditional_div_i64byi64()
|
||||
{
|
||||
parameters_div_i64byi64 data1 = {-3218837,1289,-2497,-204}, data2 = {5949371,-3471,-1714,77};
|
||||
lldiv_t result1,result2;
|
||||
|
||||
result1.quot = data1.dividend / data1.divisor;
|
||||
result1.rem = data1.dividend % data1.divisor;
|
||||
result2.quot = data2.dividend / data2.divisor;
|
||||
result2.rem = data2.dividend % data2.divisor;
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing euclidean i64/i64
|
||||
//
|
||||
uint16_t test_euclidean_div_i64byi64()
|
||||
{
|
||||
parameters_div_i64byi64 data1 = {-3218837,1289,-2498,1085}, data2 = {5949371,-3471,-1714,77};
|
||||
lldiv_t result1,result2;
|
||||
|
||||
result1 = __euclidean_div_i64byi64(data1.dividend, data1.divisor);
|
||||
result2 = __euclidean_div_i64byi64(data2.dividend, data2.divisor);
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing modulo i64/i64
|
||||
//
|
||||
uint16_t test_modulo_div_i64byi64()
|
||||
{
|
||||
parameters_div_i64byi64 data1 = {-3218837,1289,-2498,1085}, data2 = {5949371,-3471,-1715,-3394};
|
||||
lldiv_t result1,result2;
|
||||
|
||||
result1 = __modulo_div_i64byi64(data1.dividend, data1.divisor);
|
||||
result2 = __modulo_div_i64byi64(data2.dividend, data2.divisor);
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing traditional i64/u64
|
||||
//
|
||||
uint16_t test_traditional_div_i64byu64()
|
||||
{
|
||||
parameters_div_i64byu64 data1 = {-3218837,1289,-2497,-204}, data2 = {5949371,3471,1714,77};
|
||||
lldiv_t result1,result2;
|
||||
|
||||
result1 = __traditional_div_i64byu64(data1.dividend, data1.divisor);
|
||||
result2 = __traditional_div_i64byu64(data2.dividend, data2.divisor);
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing euclidean i64/u64
|
||||
//
|
||||
uint16_t test_euclidean_div_i64byu64()
|
||||
{
|
||||
parameters_div_i64byu64 data1 = {-3218837,1289,-2498,1085}, data2 = {5949371,3471,1714,77};
|
||||
lldiv_t result1,result2;
|
||||
|
||||
result1 = __euclidean_div_i64byu64(data1.dividend, data1.divisor);
|
||||
result2 = __euclidean_div_i64byu64(data2.dividend, data2.divisor);
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing modulo i64/u64
|
||||
//
|
||||
uint16_t test_modulo_div_i64byu64()
|
||||
{
|
||||
parameters_div_i64byu64 data1 = {-3218837,1289,-2498,1085}, data2 = {5949371,3471,1714,77};
|
||||
lldiv_t result1,result2;
|
||||
|
||||
result1 = __modulo_div_i64byu64(data1.dividend, data1.divisor);
|
||||
result2 = __modulo_div_i64byu64(data2.dividend, data2.divisor);
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing traditional u64/u64
|
||||
//
|
||||
uint16_t test_traditional_div_u64byu64()
|
||||
{
|
||||
parameters_div_u64byu64 data1 = {3218837,1289,2497,204}, data2 = {5949371,3471,1714,77};
|
||||
__ulldiv_t result1,result2;
|
||||
|
||||
result1.quot = data1.dividend / data1.divisor;
|
||||
result1.rem = data1.dividend % data1.divisor;
|
||||
result2.quot = data2.dividend / data2.divisor;
|
||||
result2.rem = data2.dividend % data2.divisor;
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
//#############################################################################
|
||||
//
|
||||
//! \file fastintdiv_example.h
|
||||
//!
|
||||
//! \brief Header file for fast integer division example
|
||||
//! \date Feb 14, 2019
|
||||
//
|
||||
// Group: C2000
|
||||
// Target Device: TMS320f28002x
|
||||
//
|
||||
// The header file defines various types of user-defined data types used for
|
||||
// storing input data passed to various forms of division tests
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
|
||||
#ifndef FASTINTDIV_EXAMPLE_H_
|
||||
#define FASTINTDIV_EXAMPLE_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
typedef struct {
|
||||
int16_t dividend; int16_t divisor; int32_t quotient; int32_t remainder;
|
||||
} parameters_div_i16byi16;
|
||||
|
||||
typedef struct {
|
||||
uint16_t dividend; uint16_t divisor; uint32_t quotient; uint32_t remainder;
|
||||
} parameters_div_u16byu16;
|
||||
|
||||
typedef struct {
|
||||
int32_t dividend; int32_t divisor; int32_t quotient; int32_t remainder;
|
||||
} parameters_div_i32byi32;
|
||||
|
||||
typedef struct {
|
||||
int32_t dividend; uint32_t divisor; int32_t quotient; int32_t remainder;
|
||||
} parameters_div_i32byu32;
|
||||
|
||||
typedef struct {
|
||||
uint32_t dividend; uint32_t divisor; uint32_t quotient; uint32_t remainder;
|
||||
} parameters_div_u32byu32;
|
||||
|
||||
typedef struct {
|
||||
int32_t dividend; int16_t divisor; int32_t quotient; int32_t remainder;
|
||||
} parameters_div_i32byi16;
|
||||
|
||||
typedef struct {
|
||||
uint32_t dividend; uint16_t divisor; uint32_t quotient; uint32_t remainder;
|
||||
} parameters_div_u32byu16;
|
||||
|
||||
typedef struct {
|
||||
int64_t dividend; int64_t divisor; int64_t quotient; int64_t remainder;
|
||||
} parameters_div_i64byi64;
|
||||
|
||||
typedef struct {
|
||||
int64_t dividend; uint64_t divisor; int64_t quotient; int64_t remainder;
|
||||
} parameters_div_i64byu64;
|
||||
|
||||
typedef struct {
|
||||
uint64_t dividend; uint64_t divisor; uint64_t quotient; uint64_t remainder;
|
||||
} parameters_div_u64byu64;
|
||||
|
||||
#endif /* FASTINTDIV_EXAMPLE_H_ */
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="fastintdiv_example"
|
||||
device="Generic C28xx Device"
|
||||
cgtVersion="22.6.0.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="RAM" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --define=DEBUG --cla_support=cla1 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu2 --idiv_support=idiv0 --define=CPU1 --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x100 --heap_size=0x200 --define RAM" />
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../../driverlib/f28003x/driverlib/" scope="project" />
|
||||
<file action="copy" path="../../../../../../../device_support/f28003x/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../../device_support/f28003x/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../../device_support/f28003x/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../../device_support/f28003x/common/targetConfigs/TMS320F280039C.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../cmd/28003x_RAM_lnk.cmd" targetDirectory="" applicableConfigurations="RAM" />
|
||||
<file action="copy" path="../../../../../../../driverlib/f28003x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../../../../../../../device_support/f28003x/common/source/f28003x_codestartbranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../../driverlib/f28003x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../fastintdiv_example.c" targetDirectory="" />
|
||||
<file action="copy" path="../fastintdiv_example.h" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,641 @@
|
||||
//#############################################################################
|
||||
//
|
||||
//! \file fastintdiv_example.c
|
||||
//!
|
||||
//! \brief Performs various types of fast Division using FASTINTDIV Intrinsics
|
||||
//! \date Feb 14, 2019
|
||||
//
|
||||
// Group: C2000
|
||||
// Target Device: TMS320f28002xx
|
||||
//
|
||||
// The following example showcases how various FASTINTDIV intrinsics can be used
|
||||
// to perform various types of division in the fastest way possible. The
|
||||
// example tests each of the 21 intrinsics by providing two sets of input data
|
||||
// and compares the quotient and remainder with the expect value. If both the
|
||||
// values match the pass counter is incremented for every intrinsic test. If
|
||||
// all the intrinsics give correct value then the value of "pass_count" should
|
||||
// be 21 at the end of the code and value of "success" will be 1.
|
||||
//
|
||||
// Add following watch variables to expressions window
|
||||
// -: pass_count
|
||||
// -: success
|
||||
//
|
||||
// Number of software cycles required for each integer division intrinsic including
|
||||
// cycles for output value assignment are indicated below
|
||||
//
|
||||
// 16-bit by 16-bit
|
||||
// __traditional_div_i16byi16() or int/int -> 16 cycles
|
||||
// __euclidean_div_i16byi16() -> 14 cycles
|
||||
// __modulo_div_i16byi16() -> 14 cycles
|
||||
// __traditional_div_u16byu16() or uint16_t/uint16_t -> 14 cycles
|
||||
//
|
||||
// 32-bit by 32-bit
|
||||
// __traditional_div_i32byi32() or long/long -> 13 cycles
|
||||
// __euclidean_div_i32byi32() -> 14 cycles
|
||||
// __modulo_div_i32byi32() -> 14 cycles
|
||||
// __traditional_div_i32byu32() or long/unsigned long -> 14 cycles
|
||||
// __modulo_div_i32byu32() -> 14 cycles
|
||||
// __traditional_div_u32byu32() or unsigned long/unsigned long -> 12 cycles
|
||||
//
|
||||
// 32-bit by 16-bit
|
||||
// __traditional_div_i32byi16() or long/int -> 18 cycles
|
||||
// __euclidean_div_i32byi16() -> 16 cycles
|
||||
// __modulo_div_i32byi16() -> 16 cycles
|
||||
// __traditional_div_u32byu16() or unsigned long/uint16_t -> 13 cycles
|
||||
//
|
||||
// 64-bit by 64-bit
|
||||
// __traditional_div_i64byi64() or long long/long long -> 42 cycles
|
||||
// __euclidean_div_i64byi64() -> 42 cycles
|
||||
// __modulo_div_i64byi64() -> 42 cycles
|
||||
// __traditional_div_i64byu64() or long long/unsigned long long -> 42 cycles
|
||||
// __euclidean_div_i64byu64() -> 42 cycles
|
||||
// __modulo_div_i64byu64() -> 42 cycles
|
||||
// __traditional_div_u64byu64() or unsigned long long/unsigned long long -> 42 cycles
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
#include <stdlib.h>
|
||||
#include "fastintdiv_example.h"
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
|
||||
// 16-bit by 16-bit
|
||||
uint16_t test_traditional_div_i16byi16();
|
||||
uint16_t test_euclidean_div_i16byi16();
|
||||
uint16_t test_modulo_div_i16byi16();
|
||||
uint16_t test_traditional_div_u16byu16();
|
||||
|
||||
// 32-bit by 32-bit
|
||||
uint16_t test_traditional_div_i32byi32();
|
||||
uint16_t test_euclidean_div_i32byi32();
|
||||
uint16_t test_modulo_div_i32byi32();
|
||||
uint16_t test_traditional_div_i32byu32();
|
||||
uint16_t test_modulo_div_i32byu32();
|
||||
uint16_t test_traditional_div_u32byu32();
|
||||
|
||||
|
||||
// 32-bit by 16-bit
|
||||
uint16_t test_traditional_div_i32byi16();
|
||||
uint16_t test_euclidean_div_i32byi16();
|
||||
uint16_t test_modulo_div_i32byi16();
|
||||
uint16_t test_traditional_div_u32byu16();
|
||||
|
||||
// 64-bit by 64-bit
|
||||
uint16_t test_traditional_div_i64byi64();
|
||||
uint16_t test_euclidean_div_i64byi64();
|
||||
uint16_t test_modulo_div_i64byi64();
|
||||
uint16_t test_traditional_div_i64byu64();
|
||||
uint16_t test_euclidean_div_i64byu64();
|
||||
uint16_t test_modulo_div_i64byu64();
|
||||
uint16_t test_euclidean_div_i64byi64();
|
||||
uint16_t test_traditional_div_u64byu64();
|
||||
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
uint16_t pass_count = 0, success = 0;
|
||||
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Disable pin locks and enable internal pullups.
|
||||
//
|
||||
Device_initGPIO();
|
||||
|
||||
|
||||
//
|
||||
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
|
||||
//
|
||||
Interrupt_initModule();
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
//
|
||||
Interrupt_initVectorTable();
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
|
||||
//
|
||||
// Calling routines for testing the fast division intrinsics
|
||||
// and updating pass counter value
|
||||
//
|
||||
|
||||
// 16-bit by 16-bit
|
||||
pass_count += test_traditional_div_i16byi16();
|
||||
pass_count += test_euclidean_div_i16byi16();
|
||||
pass_count += test_modulo_div_i16byi16();
|
||||
pass_count += test_traditional_div_u16byu16();
|
||||
|
||||
// 32-bit by 32-bit
|
||||
pass_count += test_traditional_div_i32byi32();
|
||||
pass_count += test_euclidean_div_i32byi32();
|
||||
pass_count += test_modulo_div_i32byi32();
|
||||
pass_count += test_traditional_div_i32byu32();
|
||||
pass_count += test_modulo_div_i32byu32();
|
||||
pass_count += test_traditional_div_u32byu32();
|
||||
|
||||
|
||||
// 32-bit by 16-bit
|
||||
pass_count += test_traditional_div_i32byi16();
|
||||
pass_count += test_euclidean_div_i32byi16();
|
||||
pass_count += test_modulo_div_i32byi16();
|
||||
pass_count += test_traditional_div_u32byu16();
|
||||
|
||||
// 64-bit by 64-bit
|
||||
pass_count += test_traditional_div_i64byi64();
|
||||
pass_count += test_euclidean_div_i64byi64();
|
||||
pass_count += test_modulo_div_i64byi64();
|
||||
pass_count += test_traditional_div_i64byu64();
|
||||
pass_count += test_euclidean_div_i64byu64();
|
||||
pass_count += test_modulo_div_i64byu64();
|
||||
pass_count += test_traditional_div_u64byu64();
|
||||
|
||||
//
|
||||
// Updating the "success" variable based on pass counter
|
||||
//
|
||||
if (pass_count == 21)
|
||||
success = 1;
|
||||
else
|
||||
success = 0;
|
||||
|
||||
//
|
||||
// Loop indefinitely
|
||||
//
|
||||
while(1)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing traditional i16/i16
|
||||
//
|
||||
uint16_t test_traditional_div_i16byi16()
|
||||
{
|
||||
parameters_div_i16byi16 data1 = {-512,20,-25,-12}, data2 = {2477,-23,-107,16};
|
||||
ldiv_t result1,result2;
|
||||
|
||||
result1.quot = data1.dividend / data1.divisor;
|
||||
result1.rem = data1.dividend % data1.divisor;
|
||||
result2.quot = data2.dividend / data2.divisor;
|
||||
result2.rem = data2.dividend % data2.divisor;
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing euclidean i16/i16
|
||||
//
|
||||
uint16_t test_euclidean_div_i16byi16()
|
||||
{
|
||||
parameters_div_i16byi16 data1 = {-512,20,-26,8}, data2 = {2477,-23,-107,16};
|
||||
ldiv_t result1,result2;
|
||||
|
||||
result1 = __euclidean_div_i16byi16(data1.dividend, data1.divisor);
|
||||
result2 = __euclidean_div_i16byi16(data2.dividend, data2.divisor);
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing modulo i16/i16
|
||||
//
|
||||
uint16_t test_modulo_div_i16byi16()
|
||||
{
|
||||
parameters_div_i16byi16 data1 = {-512,20,-26,8}, data2 = {2477,-23,-108,-7};
|
||||
ldiv_t result1,result2;
|
||||
|
||||
result1 = __modulo_div_i16byi16(data1.dividend, data1.divisor);
|
||||
result2 = __modulo_div_i16byi16(data2.dividend, data2.divisor);
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing traditional u16/u16
|
||||
//
|
||||
uint16_t test_traditional_div_u16byu16()
|
||||
{
|
||||
parameters_div_u16byu16 data1 = {512,20,25,12}, data2 = {2477,23,107,16};
|
||||
__uldiv_t result1,result2;
|
||||
|
||||
result1.quot = data1.dividend / data1.divisor;
|
||||
result1.rem = data1.dividend % data1.divisor;
|
||||
result2.quot = data2.dividend / data2.divisor;
|
||||
result2.rem = data2.dividend % data2.divisor;
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing traditional i32/i32
|
||||
//
|
||||
uint16_t test_traditional_div_i32byi32()
|
||||
{
|
||||
parameters_div_i32byi32 data1 = {-19016,246,-77,-74},data2 = {10414,-83,-125,39};
|
||||
ldiv_t result1,result2;
|
||||
|
||||
result1.quot = data1.dividend / data1.divisor;
|
||||
result1.rem = data1.dividend % data1.divisor;
|
||||
result2.quot = data2.dividend / data2.divisor;
|
||||
result2.rem = data2.dividend % data2.divisor;
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing euclidean i32/i32
|
||||
//
|
||||
uint16_t test_euclidean_div_i32byi32()
|
||||
{
|
||||
parameters_div_i32byi32 data1 = {-19016,246,-78,172}, data2 = {10414,-83,-125,39};
|
||||
ldiv_t result1,result2;
|
||||
|
||||
result1 = __euclidean_div_i32byi32(data1.dividend, data1.divisor);
|
||||
result2 = __euclidean_div_i32byi32(data2.dividend, data2.divisor);
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing modulo i32/i32
|
||||
//
|
||||
uint16_t test_modulo_div_i32byi32()
|
||||
{
|
||||
parameters_div_i32byi32 data1 = {-19016,246,-78,172}, data2 = {10414,-83,-126,-44};
|
||||
ldiv_t result1,result2;
|
||||
|
||||
result1 = __modulo_div_i32byi32(data1.dividend, data1.divisor);
|
||||
result2 = __modulo_div_i32byi32(data2.dividend, data2.divisor);
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing traditional i32/u32
|
||||
//
|
||||
uint16_t test_traditional_div_i32byu32()
|
||||
{
|
||||
parameters_div_i32byu32 data1 = {-19016,246,-77,-74}, data2 = {-10414,83,-125,-39};
|
||||
ldiv_t result1,result2;
|
||||
|
||||
result1 = __traditional_div_i32byu32(data1.dividend, data1.divisor);
|
||||
result2 = __traditional_div_i32byu32(data2.dividend, data2.divisor);
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing modulo i32/u32
|
||||
//
|
||||
uint16_t test_modulo_div_i32byu32()
|
||||
{
|
||||
parameters_div_i32byu32 data1 = {-19016,246,-78,172}, data2 = {-10414,83,-126,44};
|
||||
ldiv_t result1,result2;
|
||||
|
||||
result1 = __modulo_div_i32byu32(data1.dividend, data1.divisor);
|
||||
result2 = __modulo_div_i32byu32(data2.dividend, data2.divisor);
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing traditional u32/u32
|
||||
//
|
||||
uint16_t test_traditional_div_u32byu32()
|
||||
{
|
||||
parameters_div_u32byu32 data1 = {19016,246,77,74}, data2 = {10414,83,125,39};
|
||||
__uldiv_t result1,result2;
|
||||
|
||||
result1.quot = data1.dividend / data1.divisor;
|
||||
result1.rem = data1.dividend % data1.divisor;
|
||||
result2.quot = data2.dividend / data2.divisor;
|
||||
result2.rem = data2.dividend % data2.divisor;
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing traditional i32/i16
|
||||
//
|
||||
uint16_t test_traditional_div_i32byi16()
|
||||
{
|
||||
parameters_div_i32byi16 data1 = {-19016,20,-950,-16}, data2 = {10414,-23,-452,18};
|
||||
ldiv_t result1,result2;
|
||||
|
||||
result1.quot = data1.dividend / data1.divisor;
|
||||
result1.rem = data1.dividend % data1.divisor;
|
||||
result2.quot = data2.dividend / data2.divisor;
|
||||
result2.rem = data2.dividend % data2.divisor;
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing euclidean i32/i16
|
||||
//
|
||||
uint16_t test_euclidean_div_i32byi16()
|
||||
{
|
||||
parameters_div_i32byi16 data1 = {-19016,20,-951,4}, data2 = {10414,-23,-452,18};
|
||||
ldiv_t result1,result2;
|
||||
|
||||
result1 = __euclidean_div_i32byi16(data1.dividend, data1.divisor);
|
||||
result2 = __euclidean_div_i32byi16(data2.dividend, data2.divisor);
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing modulo i32/i16
|
||||
//
|
||||
uint16_t test_modulo_div_i32byi16()
|
||||
{
|
||||
parameters_div_i32byi16 data1 = {-19016,20,-951,4}, data2 = {10414,-23,-453,-5};
|
||||
ldiv_t result1,result2;
|
||||
|
||||
result1 = __modulo_div_i32byi16(data1.dividend, data1.divisor);
|
||||
result2 = __modulo_div_i32byi16(data2.dividend, data2.divisor);
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing traditional u32/u16
|
||||
//
|
||||
uint16_t test_traditional_div_u32byu16()
|
||||
{
|
||||
parameters_div_u32byu16 data1 = {19016,20,950,16}, data2 = {10414,23,452,18};
|
||||
__uldiv_t result1,result2;
|
||||
|
||||
result1.quot = data1.dividend / data1.divisor;
|
||||
result1.rem = data1.dividend % data1.divisor;
|
||||
result2.quot = data2.dividend / data2.divisor;
|
||||
result2.rem = data2.dividend % data2.divisor;
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing traditional i64/i64
|
||||
//
|
||||
uint16_t test_traditional_div_i64byi64()
|
||||
{
|
||||
parameters_div_i64byi64 data1 = {-3218837,1289,-2497,-204}, data2 = {5949371,-3471,-1714,77};
|
||||
lldiv_t result1,result2;
|
||||
|
||||
result1.quot = data1.dividend / data1.divisor;
|
||||
result1.rem = data1.dividend % data1.divisor;
|
||||
result2.quot = data2.dividend / data2.divisor;
|
||||
result2.rem = data2.dividend % data2.divisor;
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing euclidean i64/i64
|
||||
//
|
||||
uint16_t test_euclidean_div_i64byi64()
|
||||
{
|
||||
parameters_div_i64byi64 data1 = {-3218837,1289,-2498,1085}, data2 = {5949371,-3471,-1714,77};
|
||||
lldiv_t result1,result2;
|
||||
|
||||
result1 = __euclidean_div_i64byi64(data1.dividend, data1.divisor);
|
||||
result2 = __euclidean_div_i64byi64(data2.dividend, data2.divisor);
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing modulo i64/i64
|
||||
//
|
||||
uint16_t test_modulo_div_i64byi64()
|
||||
{
|
||||
parameters_div_i64byi64 data1 = {-3218837,1289,-2498,1085}, data2 = {5949371,-3471,-1715,-3394};
|
||||
lldiv_t result1,result2;
|
||||
|
||||
result1 = __modulo_div_i64byi64(data1.dividend, data1.divisor);
|
||||
result2 = __modulo_div_i64byi64(data2.dividend, data2.divisor);
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing traditional i64/u64
|
||||
//
|
||||
uint16_t test_traditional_div_i64byu64()
|
||||
{
|
||||
parameters_div_i64byu64 data1 = {-3218837,1289,-2497,-204}, data2 = {5949371,3471,1714,77};
|
||||
lldiv_t result1,result2;
|
||||
|
||||
result1 = __traditional_div_i64byu64(data1.dividend, data1.divisor);
|
||||
result2 = __traditional_div_i64byu64(data2.dividend, data2.divisor);
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing euclidean i64/u64
|
||||
//
|
||||
uint16_t test_euclidean_div_i64byu64()
|
||||
{
|
||||
parameters_div_i64byu64 data1 = {-3218837,1289,-2498,1085}, data2 = {5949371,3471,1714,77};
|
||||
lldiv_t result1,result2;
|
||||
|
||||
result1 = __euclidean_div_i64byu64(data1.dividend, data1.divisor);
|
||||
result2 = __euclidean_div_i64byu64(data2.dividend, data2.divisor);
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing modulo i64/u64
|
||||
//
|
||||
uint16_t test_modulo_div_i64byu64()
|
||||
{
|
||||
parameters_div_i64byu64 data1 = {-3218837,1289,-2498,1085}, data2 = {5949371,3471,1714,77};
|
||||
lldiv_t result1,result2;
|
||||
|
||||
result1 = __modulo_div_i64byu64(data1.dividend, data1.divisor);
|
||||
result2 = __modulo_div_i64byu64(data2.dividend, data2.divisor);
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing traditional u64/u64
|
||||
//
|
||||
uint16_t test_traditional_div_u64byu64()
|
||||
{
|
||||
parameters_div_u64byu64 data1 = {3218837,1289,2497,204}, data2 = {5949371,3471,1714,77};
|
||||
__ulldiv_t result1,result2;
|
||||
|
||||
result1.quot = data1.dividend / data1.divisor;
|
||||
result1.rem = data1.dividend % data1.divisor;
|
||||
result2.quot = data2.dividend / data2.divisor;
|
||||
result2.rem = data2.dividend % data2.divisor;
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
//#############################################################################
|
||||
//
|
||||
//! \file fastintdiv_example.h
|
||||
//!
|
||||
//! \brief Header file for fast integer division example
|
||||
//! \date Feb 14, 2019
|
||||
//
|
||||
// Group: C2000
|
||||
// Target Device: TMS320f28002x
|
||||
//
|
||||
// The header file defines various types of user-defined data types used for
|
||||
// storing input data passed to various forms of division tests
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
|
||||
#ifndef FASTINTDIV_EXAMPLE_H_
|
||||
#define FASTINTDIV_EXAMPLE_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
typedef struct {
|
||||
int16_t dividend; int16_t divisor; int32_t quotient; int32_t remainder;
|
||||
} parameters_div_i16byi16;
|
||||
|
||||
typedef struct {
|
||||
uint16_t dividend; uint16_t divisor; uint32_t quotient; uint32_t remainder;
|
||||
} parameters_div_u16byu16;
|
||||
|
||||
typedef struct {
|
||||
int32_t dividend; int32_t divisor; int32_t quotient; int32_t remainder;
|
||||
} parameters_div_i32byi32;
|
||||
|
||||
typedef struct {
|
||||
int32_t dividend; uint32_t divisor; int32_t quotient; int32_t remainder;
|
||||
} parameters_div_i32byu32;
|
||||
|
||||
typedef struct {
|
||||
uint32_t dividend; uint32_t divisor; uint32_t quotient; uint32_t remainder;
|
||||
} parameters_div_u32byu32;
|
||||
|
||||
typedef struct {
|
||||
int32_t dividend; int16_t divisor; int32_t quotient; int32_t remainder;
|
||||
} parameters_div_i32byi16;
|
||||
|
||||
typedef struct {
|
||||
uint32_t dividend; uint16_t divisor; uint32_t quotient; uint32_t remainder;
|
||||
} parameters_div_u32byu16;
|
||||
|
||||
typedef struct {
|
||||
int64_t dividend; int64_t divisor; int64_t quotient; int64_t remainder;
|
||||
} parameters_div_i64byi64;
|
||||
|
||||
typedef struct {
|
||||
int64_t dividend; uint64_t divisor; int64_t quotient; int64_t remainder;
|
||||
} parameters_div_i64byu64;
|
||||
|
||||
typedef struct {
|
||||
uint64_t dividend; uint64_t divisor; uint64_t quotient; uint64_t remainder;
|
||||
} parameters_div_u64byu64;
|
||||
|
||||
#endif /* FASTINTDIV_EXAMPLE_H_ */
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="fastintdiv_example"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.0.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --define=DEBUG --cla_support=cla1 --float_support=fpu64 --tmu_support=tmu0 --vcu_support=vcu2 --idiv_support=idiv0 --define=CPU1 --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x100 --heap_size=0x200 --define RAM" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --define=DEBUG --define=_FLASH --cla_support=cla1 --float_support=fpu64 --tmu_support=tmu0 --vcu_support=vcu2 --idiv_support=idiv0 --define=CPU1 --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x100 --heap_size=0x200 " />
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../../driverlib/f2838x/driverlib/" scope="project" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../cmd/2838x_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../fastintdiv_example.c" targetDirectory="" />
|
||||
<file action="copy" path="../fastintdiv_example.h" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,641 @@
|
||||
//#############################################################################
|
||||
//
|
||||
//! \file fastintdiv_example.c
|
||||
//!
|
||||
//! \brief Performs various types of fast Division using FASTINTDIV Intrinsics
|
||||
//! \date Feb 14, 2019
|
||||
//
|
||||
// Group: C2000
|
||||
// Target Device: TMS320f2838x
|
||||
//
|
||||
// The following example showcases how various FASTINTDIV intrinsics can be used
|
||||
// to perform various types of division in the fastest way possible. The
|
||||
// example tests each of the 21 intrinsics by providing two sets of input data
|
||||
// and compares the quotient and remainder with the expect value. If both the
|
||||
// values match the pass counter is incremented for every intrinsic test. If
|
||||
// all the intrinsics give correct value then the value of "pass_count" should
|
||||
// be 21 at the end of the code and value of "success" will be 1.
|
||||
//
|
||||
// Add following watch variables to expressions window
|
||||
// -: pass_count
|
||||
// -: success
|
||||
//
|
||||
// Number of software cycles required for each integer division intrinsic including
|
||||
// cycles for output value assignment are indicated below
|
||||
//
|
||||
// 16-bit by 16-bit
|
||||
// __traditional_div_i16byi16() or int/int -> 16 cycles
|
||||
// __euclidean_div_i16byi16() -> 14 cycles
|
||||
// __modulo_div_i16byi16() -> 14 cycles
|
||||
// __traditional_div_u16byu16() or uint16_t/uint16_t -> 14 cycles
|
||||
//
|
||||
// 32-bit by 32-bit
|
||||
// __traditional_div_i32byi32() or long/long -> 13 cycles
|
||||
// __euclidean_div_i32byi32() -> 14 cycles
|
||||
// __modulo_div_i32byi32() -> 14 cycles
|
||||
// __traditional_div_i32byu32() or long/unsigned long -> 14 cycles
|
||||
// __modulo_div_i32byu32() -> 14 cycles
|
||||
// __traditional_div_u32byu32() or unsigned long/unsigned long -> 12 cycles
|
||||
//
|
||||
// 32-bit by 16-bit
|
||||
// __traditional_div_i32byi16() or long/int -> 18 cycles
|
||||
// __euclidean_div_i32byi16() -> 16 cycles
|
||||
// __modulo_div_i32byi16() -> 16 cycles
|
||||
// __traditional_div_u32byu16() or unsigned long/uint16_t -> 13 cycles
|
||||
//
|
||||
// 64-bit by 64-bit
|
||||
// __traditional_div_i64byi64() or long long/long long -> 42 cycles
|
||||
// __euclidean_div_i64byi64() -> 42 cycles
|
||||
// __modulo_div_i64byi64() -> 42 cycles
|
||||
// __traditional_div_i64byu64() or long long/unsigned long long -> 42 cycles
|
||||
// __euclidean_div_i64byu64() -> 42 cycles
|
||||
// __modulo_div_i64byu64() -> 42 cycles
|
||||
// __traditional_div_u64byu64() or unsigned long long/unsigned long long -> 42 cycles
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
#include <stdlib.h>
|
||||
#include "fastintdiv_example.h"
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
|
||||
// 16-bit by 16-bit
|
||||
uint16_t test_traditional_div_i16byi16();
|
||||
uint16_t test_euclidean_div_i16byi16();
|
||||
uint16_t test_modulo_div_i16byi16();
|
||||
uint16_t test_traditional_div_u16byu16();
|
||||
|
||||
// 32-bit by 32-bit
|
||||
uint16_t test_traditional_div_i32byi32();
|
||||
uint16_t test_euclidean_div_i32byi32();
|
||||
uint16_t test_modulo_div_i32byi32();
|
||||
uint16_t test_traditional_div_i32byu32();
|
||||
uint16_t test_modulo_div_i32byu32();
|
||||
uint16_t test_traditional_div_u32byu32();
|
||||
|
||||
|
||||
// 32-bit by 16-bit
|
||||
uint16_t test_traditional_div_i32byi16();
|
||||
uint16_t test_euclidean_div_i32byi16();
|
||||
uint16_t test_modulo_div_i32byi16();
|
||||
uint16_t test_traditional_div_u32byu16();
|
||||
|
||||
// 64-bit by 64-bit
|
||||
uint16_t test_traditional_div_i64byi64();
|
||||
uint16_t test_euclidean_div_i64byi64();
|
||||
uint16_t test_modulo_div_i64byi64();
|
||||
uint16_t test_traditional_div_i64byu64();
|
||||
uint16_t test_euclidean_div_i64byu64();
|
||||
uint16_t test_modulo_div_i64byu64();
|
||||
uint16_t test_euclidean_div_i64byi64();
|
||||
uint16_t test_traditional_div_u64byu64();
|
||||
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
uint16_t pass_count = 0, success = 0;
|
||||
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Disable pin locks and enable internal pullups.
|
||||
//
|
||||
Device_initGPIO();
|
||||
|
||||
|
||||
//
|
||||
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
|
||||
//
|
||||
Interrupt_initModule();
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
//
|
||||
Interrupt_initVectorTable();
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
|
||||
//
|
||||
// Calling routines for testing the fast division intrinsics
|
||||
// and updating pass counter value
|
||||
//
|
||||
|
||||
// 16-bit by 16-bit
|
||||
pass_count += test_traditional_div_i16byi16();
|
||||
pass_count += test_euclidean_div_i16byi16();
|
||||
pass_count += test_modulo_div_i16byi16();
|
||||
pass_count += test_traditional_div_u16byu16();
|
||||
|
||||
// 32-bit by 32-bit
|
||||
pass_count += test_traditional_div_i32byi32();
|
||||
pass_count += test_euclidean_div_i32byi32();
|
||||
pass_count += test_modulo_div_i32byi32();
|
||||
pass_count += test_traditional_div_i32byu32();
|
||||
pass_count += test_modulo_div_i32byu32();
|
||||
pass_count += test_traditional_div_u32byu32();
|
||||
|
||||
|
||||
// 32-bit by 16-bit
|
||||
pass_count += test_traditional_div_i32byi16();
|
||||
pass_count += test_euclidean_div_i32byi16();
|
||||
pass_count += test_modulo_div_i32byi16();
|
||||
pass_count += test_traditional_div_u32byu16();
|
||||
|
||||
// 64-bit by 64-bit
|
||||
pass_count += test_traditional_div_i64byi64();
|
||||
pass_count += test_euclidean_div_i64byi64();
|
||||
pass_count += test_modulo_div_i64byi64();
|
||||
pass_count += test_traditional_div_i64byu64();
|
||||
pass_count += test_euclidean_div_i64byu64();
|
||||
pass_count += test_modulo_div_i64byu64();
|
||||
pass_count += test_traditional_div_u64byu64();
|
||||
|
||||
//
|
||||
// Updating the "success" variable based on pass counter
|
||||
//
|
||||
if (pass_count == 21)
|
||||
success = 1;
|
||||
else
|
||||
success = 0;
|
||||
|
||||
//
|
||||
// Loop indefinitely
|
||||
//
|
||||
while(1)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing traditional i16/i16
|
||||
//
|
||||
uint16_t test_traditional_div_i16byi16()
|
||||
{
|
||||
parameters_div_i16byi16 data1 = {-512,20,-25,-12}, data2 = {2477,-23,-107,16};
|
||||
ldiv_t result1,result2;
|
||||
|
||||
result1.quot = data1.dividend / data1.divisor;
|
||||
result1.rem = data1.dividend % data1.divisor;
|
||||
result2.quot = data2.dividend / data2.divisor;
|
||||
result2.rem = data2.dividend % data2.divisor;
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing euclidean i16/i16
|
||||
//
|
||||
uint16_t test_euclidean_div_i16byi16()
|
||||
{
|
||||
parameters_div_i16byi16 data1 = {-512,20,-26,8}, data2 = {2477,-23,-107,16};
|
||||
ldiv_t result1,result2;
|
||||
|
||||
result1 = __euclidean_div_i16byi16(data1.dividend, data1.divisor);
|
||||
result2 = __euclidean_div_i16byi16(data2.dividend, data2.divisor);
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing modulo i16/i16
|
||||
//
|
||||
uint16_t test_modulo_div_i16byi16()
|
||||
{
|
||||
parameters_div_i16byi16 data1 = {-512,20,-26,8}, data2 = {2477,-23,-108,-7};
|
||||
ldiv_t result1,result2;
|
||||
|
||||
result1 = __modulo_div_i16byi16(data1.dividend, data1.divisor);
|
||||
result2 = __modulo_div_i16byi16(data2.dividend, data2.divisor);
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing traditional u16/u16
|
||||
//
|
||||
uint16_t test_traditional_div_u16byu16()
|
||||
{
|
||||
parameters_div_u16byu16 data1 = {512,20,25,12}, data2 = {2477,23,107,16};
|
||||
__uldiv_t result1,result2;
|
||||
|
||||
result1.quot = data1.dividend / data1.divisor;
|
||||
result1.rem = data1.dividend % data1.divisor;
|
||||
result2.quot = data2.dividend / data2.divisor;
|
||||
result2.rem = data2.dividend % data2.divisor;
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing traditional i32/i32
|
||||
//
|
||||
uint16_t test_traditional_div_i32byi32()
|
||||
{
|
||||
parameters_div_i32byi32 data1 = {-19016,246,-77,-74},data2 = {10414,-83,-125,39};
|
||||
ldiv_t result1,result2;
|
||||
|
||||
result1.quot = data1.dividend / data1.divisor;
|
||||
result1.rem = data1.dividend % data1.divisor;
|
||||
result2.quot = data2.dividend / data2.divisor;
|
||||
result2.rem = data2.dividend % data2.divisor;
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing euclidean i32/i32
|
||||
//
|
||||
uint16_t test_euclidean_div_i32byi32()
|
||||
{
|
||||
parameters_div_i32byi32 data1 = {-19016,246,-78,172}, data2 = {10414,-83,-125,39};
|
||||
ldiv_t result1,result2;
|
||||
|
||||
result1 = __euclidean_div_i32byi32(data1.dividend, data1.divisor);
|
||||
result2 = __euclidean_div_i32byi32(data2.dividend, data2.divisor);
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing modulo i32/i32
|
||||
//
|
||||
uint16_t test_modulo_div_i32byi32()
|
||||
{
|
||||
parameters_div_i32byi32 data1 = {-19016,246,-78,172}, data2 = {10414,-83,-126,-44};
|
||||
ldiv_t result1,result2;
|
||||
|
||||
result1 = __modulo_div_i32byi32(data1.dividend, data1.divisor);
|
||||
result2 = __modulo_div_i32byi32(data2.dividend, data2.divisor);
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing traditional i32/u32
|
||||
//
|
||||
uint16_t test_traditional_div_i32byu32()
|
||||
{
|
||||
parameters_div_i32byu32 data1 = {-19016,246,-77,-74}, data2 = {-10414,83,-125,-39};
|
||||
ldiv_t result1,result2;
|
||||
|
||||
result1 = __traditional_div_i32byu32(data1.dividend, data1.divisor);
|
||||
result2 = __traditional_div_i32byu32(data2.dividend, data2.divisor);
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing modulo i32/u32
|
||||
//
|
||||
uint16_t test_modulo_div_i32byu32()
|
||||
{
|
||||
parameters_div_i32byu32 data1 = {-19016,246,-78,172}, data2 = {-10414,83,-126,44};
|
||||
ldiv_t result1,result2;
|
||||
|
||||
result1 = __modulo_div_i32byu32(data1.dividend, data1.divisor);
|
||||
result2 = __modulo_div_i32byu32(data2.dividend, data2.divisor);
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing traditional u32/u32
|
||||
//
|
||||
uint16_t test_traditional_div_u32byu32()
|
||||
{
|
||||
parameters_div_u32byu32 data1 = {19016,246,77,74}, data2 = {10414,83,125,39};
|
||||
__uldiv_t result1,result2;
|
||||
|
||||
result1.quot = data1.dividend / data1.divisor;
|
||||
result1.rem = data1.dividend % data1.divisor;
|
||||
result2.quot = data2.dividend / data2.divisor;
|
||||
result2.rem = data2.dividend % data2.divisor;
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing traditional i32/i16
|
||||
//
|
||||
uint16_t test_traditional_div_i32byi16()
|
||||
{
|
||||
parameters_div_i32byi16 data1 = {-19016,20,-950,-16}, data2 = {10414,-23,-452,18};
|
||||
ldiv_t result1,result2;
|
||||
|
||||
result1.quot = data1.dividend / data1.divisor;
|
||||
result1.rem = data1.dividend % data1.divisor;
|
||||
result2.quot = data2.dividend / data2.divisor;
|
||||
result2.rem = data2.dividend % data2.divisor;
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing euclidean i32/i16
|
||||
//
|
||||
uint16_t test_euclidean_div_i32byi16()
|
||||
{
|
||||
parameters_div_i32byi16 data1 = {-19016,20,-951,4}, data2 = {10414,-23,-452,18};
|
||||
ldiv_t result1,result2;
|
||||
|
||||
result1 = __euclidean_div_i32byi16(data1.dividend, data1.divisor);
|
||||
result2 = __euclidean_div_i32byi16(data2.dividend, data2.divisor);
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing modulo i32/i16
|
||||
//
|
||||
uint16_t test_modulo_div_i32byi16()
|
||||
{
|
||||
parameters_div_i32byi16 data1 = {-19016,20,-951,4}, data2 = {10414,-23,-453,-5};
|
||||
ldiv_t result1,result2;
|
||||
|
||||
result1 = __modulo_div_i32byi16(data1.dividend, data1.divisor);
|
||||
result2 = __modulo_div_i32byi16(data2.dividend, data2.divisor);
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing traditional u32/u16
|
||||
//
|
||||
uint16_t test_traditional_div_u32byu16()
|
||||
{
|
||||
parameters_div_u32byu16 data1 = {19016,20,950,16}, data2 = {10414,23,452,18};
|
||||
__uldiv_t result1,result2;
|
||||
|
||||
result1.quot = data1.dividend / data1.divisor;
|
||||
result1.rem = data1.dividend % data1.divisor;
|
||||
result2.quot = data2.dividend / data2.divisor;
|
||||
result2.rem = data2.dividend % data2.divisor;
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing traditional i64/i64
|
||||
//
|
||||
uint16_t test_traditional_div_i64byi64()
|
||||
{
|
||||
parameters_div_i64byi64 data1 = {-3218837,1289,-2497,-204}, data2 = {5949371,-3471,-1714,77};
|
||||
lldiv_t result1,result2;
|
||||
|
||||
result1.quot = data1.dividend / data1.divisor;
|
||||
result1.rem = data1.dividend % data1.divisor;
|
||||
result2.quot = data2.dividend / data2.divisor;
|
||||
result2.rem = data2.dividend % data2.divisor;
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing euclidean i64/i64
|
||||
//
|
||||
uint16_t test_euclidean_div_i64byi64()
|
||||
{
|
||||
parameters_div_i64byi64 data1 = {-3218837,1289,-2498,1085}, data2 = {5949371,-3471,-1714,77};
|
||||
lldiv_t result1,result2;
|
||||
|
||||
result1 = __euclidean_div_i64byi64(data1.dividend, data1.divisor);
|
||||
result2 = __euclidean_div_i64byi64(data2.dividend, data2.divisor);
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing modulo i64/i64
|
||||
//
|
||||
uint16_t test_modulo_div_i64byi64()
|
||||
{
|
||||
parameters_div_i64byi64 data1 = {-3218837,1289,-2498,1085}, data2 = {5949371,-3471,-1715,-3394};
|
||||
lldiv_t result1,result2;
|
||||
|
||||
result1 = __modulo_div_i64byi64(data1.dividend, data1.divisor);
|
||||
result2 = __modulo_div_i64byi64(data2.dividend, data2.divisor);
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing traditional i64/u64
|
||||
//
|
||||
uint16_t test_traditional_div_i64byu64()
|
||||
{
|
||||
parameters_div_i64byu64 data1 = {-3218837,1289,-2497,-204}, data2 = {5949371,3471,1714,77};
|
||||
lldiv_t result1,result2;
|
||||
|
||||
result1 = __traditional_div_i64byu64(data1.dividend, data1.divisor);
|
||||
result2 = __traditional_div_i64byu64(data2.dividend, data2.divisor);
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing euclidean i64/u64
|
||||
//
|
||||
uint16_t test_euclidean_div_i64byu64()
|
||||
{
|
||||
parameters_div_i64byu64 data1 = {-3218837,1289,-2498,1085}, data2 = {5949371,3471,1714,77};
|
||||
lldiv_t result1,result2;
|
||||
|
||||
result1 = __euclidean_div_i64byu64(data1.dividend, data1.divisor);
|
||||
result2 = __euclidean_div_i64byu64(data2.dividend, data2.divisor);
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing modulo i64/u64
|
||||
//
|
||||
uint16_t test_modulo_div_i64byu64()
|
||||
{
|
||||
parameters_div_i64byu64 data1 = {-3218837,1289,-2498,1085}, data2 = {5949371,3471,1714,77};
|
||||
lldiv_t result1,result2;
|
||||
|
||||
result1 = __modulo_div_i64byu64(data1.dividend, data1.divisor);
|
||||
result2 = __modulo_div_i64byu64(data2.dividend, data2.divisor);
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Routine for testing traditional u64/u64
|
||||
//
|
||||
uint16_t test_traditional_div_u64byu64()
|
||||
{
|
||||
parameters_div_u64byu64 data1 = {3218837,1289,2497,204}, data2 = {5949371,3471,1714,77};
|
||||
__ulldiv_t result1,result2;
|
||||
|
||||
result1.quot = data1.dividend / data1.divisor;
|
||||
result1.rem = data1.dividend % data1.divisor;
|
||||
result2.quot = data2.dividend / data2.divisor;
|
||||
result2.rem = data2.dividend % data2.divisor;
|
||||
|
||||
if ((result1.quot == data1.quotient) && (result1.rem == data1.remainder) &&
|
||||
(result2.quot == data2.quotient) && (result2.rem = data2.remainder))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
//#############################################################################
|
||||
//
|
||||
//! \file fastintdiv_example.h
|
||||
//!
|
||||
//! \brief Header file for fast integer division example
|
||||
//! \date Feb 14, 2019
|
||||
//
|
||||
// Group: C2000
|
||||
// Target Device: TMS320f2838x
|
||||
//
|
||||
// The header file defines various types of user-defined data types used for
|
||||
// storing input data passed to various forms of division tests
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
|
||||
#ifndef FASTINTDIV_EXAMPLE_H_
|
||||
#define FASTINTDIV_EXAMPLE_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
typedef struct {
|
||||
int16_t dividend; int16_t divisor; int32_t quotient; int32_t remainder;
|
||||
} parameters_div_i16byi16;
|
||||
|
||||
typedef struct {
|
||||
uint16_t dividend; uint16_t divisor; uint32_t quotient; uint32_t remainder;
|
||||
} parameters_div_u16byu16;
|
||||
|
||||
typedef struct {
|
||||
int32_t dividend; int32_t divisor; int32_t quotient; int32_t remainder;
|
||||
} parameters_div_i32byi32;
|
||||
|
||||
typedef struct {
|
||||
int32_t dividend; uint32_t divisor; int32_t quotient; int32_t remainder;
|
||||
} parameters_div_i32byu32;
|
||||
|
||||
typedef struct {
|
||||
uint32_t dividend; uint32_t divisor; uint32_t quotient; uint32_t remainder;
|
||||
} parameters_div_u32byu32;
|
||||
|
||||
typedef struct {
|
||||
int32_t dividend; int16_t divisor; int32_t quotient; int32_t remainder;
|
||||
} parameters_div_i32byi16;
|
||||
|
||||
typedef struct {
|
||||
uint32_t dividend; uint16_t divisor; uint32_t quotient; uint32_t remainder;
|
||||
} parameters_div_u32byu16;
|
||||
|
||||
typedef struct {
|
||||
int64_t dividend; int64_t divisor; int64_t quotient; int64_t remainder;
|
||||
} parameters_div_i64byi64;
|
||||
|
||||
typedef struct {
|
||||
int64_t dividend; uint64_t divisor; int64_t quotient; int64_t remainder;
|
||||
} parameters_div_i64byu64;
|
||||
|
||||
typedef struct {
|
||||
uint64_t dividend; uint64_t divisor; uint64_t quotient; uint64_t remainder;
|
||||
} parameters_div_u64byu64;
|
||||
|
||||
#endif /* FASTINTDIV_EXAMPLE_H_ */
|
||||
Reference in New Issue
Block a user