mirror of
https://github.com/ehw-fit/ariths-gen.git
synced 2025-04-19 21:40:49 +01:00

* #10 CGP Circuits as inputs (#11) * CGP Circuits as inputs * #10 support of signed output in general circuit * input as output works * output connected to input (c) * automated verilog testing * output rename * Implemented CSA and Wallace tree multiplier composing of CSAs. Also did some code cleanup. * Typos fix and code cleanup. * Added new (approximate) multiplier architectures and did some minor changes regarding sign extension for c output formats. * Updated automated testing scripts. * Small bugfix in python code generation (I initially thought this line is useless). * Updated generated circuits folder. Co-authored-by: Vojta Mrazek <mrazek@fit.vutbr.cz>
151 lines
8.3 KiB
C
151 lines
8.3 KiB
C
#include <stdio.h>
|
|
#include <stdint.h>
|
|
|
|
int64_t s_pg_rca8(int64_t a, int64_t b){
|
|
int64_t s_pg_rca8_out = 0;
|
|
uint8_t s_pg_rca8_pg_fa0_xor0 = 0;
|
|
uint8_t s_pg_rca8_pg_fa0_and0 = 0;
|
|
uint8_t s_pg_rca8_pg_fa1_xor0 = 0;
|
|
uint8_t s_pg_rca8_pg_fa1_and0 = 0;
|
|
uint8_t s_pg_rca8_pg_fa1_xor1 = 0;
|
|
uint8_t s_pg_rca8_and1 = 0;
|
|
uint8_t s_pg_rca8_or1 = 0;
|
|
uint8_t s_pg_rca8_pg_fa2_xor0 = 0;
|
|
uint8_t s_pg_rca8_pg_fa2_and0 = 0;
|
|
uint8_t s_pg_rca8_pg_fa2_xor1 = 0;
|
|
uint8_t s_pg_rca8_and2 = 0;
|
|
uint8_t s_pg_rca8_or2 = 0;
|
|
uint8_t s_pg_rca8_pg_fa3_xor0 = 0;
|
|
uint8_t s_pg_rca8_pg_fa3_and0 = 0;
|
|
uint8_t s_pg_rca8_pg_fa3_xor1 = 0;
|
|
uint8_t s_pg_rca8_and3 = 0;
|
|
uint8_t s_pg_rca8_or3 = 0;
|
|
uint8_t s_pg_rca8_pg_fa4_xor0 = 0;
|
|
uint8_t s_pg_rca8_pg_fa4_and0 = 0;
|
|
uint8_t s_pg_rca8_pg_fa4_xor1 = 0;
|
|
uint8_t s_pg_rca8_and4 = 0;
|
|
uint8_t s_pg_rca8_or4 = 0;
|
|
uint8_t s_pg_rca8_pg_fa5_xor0 = 0;
|
|
uint8_t s_pg_rca8_pg_fa5_and0 = 0;
|
|
uint8_t s_pg_rca8_pg_fa5_xor1 = 0;
|
|
uint8_t s_pg_rca8_and5 = 0;
|
|
uint8_t s_pg_rca8_or5 = 0;
|
|
uint8_t s_pg_rca8_pg_fa6_xor0 = 0;
|
|
uint8_t s_pg_rca8_pg_fa6_and0 = 0;
|
|
uint8_t s_pg_rca8_pg_fa6_xor1 = 0;
|
|
uint8_t s_pg_rca8_and6 = 0;
|
|
uint8_t s_pg_rca8_or6 = 0;
|
|
uint8_t s_pg_rca8_pg_fa7_xor0 = 0;
|
|
uint8_t s_pg_rca8_pg_fa7_and0 = 0;
|
|
uint8_t s_pg_rca8_pg_fa7_xor1 = 0;
|
|
uint8_t s_pg_rca8_and7 = 0;
|
|
uint8_t s_pg_rca8_or7 = 0;
|
|
uint8_t s_pg_rca8_xor0 = 0;
|
|
uint8_t s_pg_rca8_xor1 = 0;
|
|
|
|
s_pg_rca8_pg_fa0_xor0 = ((a >> 0) & 0x01) ^ ((b >> 0) & 0x01);
|
|
s_pg_rca8_pg_fa0_and0 = ((a >> 0) & 0x01) & ((b >> 0) & 0x01);
|
|
s_pg_rca8_pg_fa1_xor0 = ((a >> 1) & 0x01) ^ ((b >> 1) & 0x01);
|
|
s_pg_rca8_pg_fa1_and0 = ((a >> 1) & 0x01) & ((b >> 1) & 0x01);
|
|
s_pg_rca8_pg_fa1_xor1 = ((s_pg_rca8_pg_fa1_xor0 >> 0) & 0x01) ^ ((s_pg_rca8_pg_fa0_and0 >> 0) & 0x01);
|
|
s_pg_rca8_and1 = ((s_pg_rca8_pg_fa0_and0 >> 0) & 0x01) & ((s_pg_rca8_pg_fa1_xor0 >> 0) & 0x01);
|
|
s_pg_rca8_or1 = ((s_pg_rca8_and1 >> 0) & 0x01) | ((s_pg_rca8_pg_fa1_and0 >> 0) & 0x01);
|
|
s_pg_rca8_pg_fa2_xor0 = ((a >> 2) & 0x01) ^ ((b >> 2) & 0x01);
|
|
s_pg_rca8_pg_fa2_and0 = ((a >> 2) & 0x01) & ((b >> 2) & 0x01);
|
|
s_pg_rca8_pg_fa2_xor1 = ((s_pg_rca8_pg_fa2_xor0 >> 0) & 0x01) ^ ((s_pg_rca8_or1 >> 0) & 0x01);
|
|
s_pg_rca8_and2 = ((s_pg_rca8_or1 >> 0) & 0x01) & ((s_pg_rca8_pg_fa2_xor0 >> 0) & 0x01);
|
|
s_pg_rca8_or2 = ((s_pg_rca8_and2 >> 0) & 0x01) | ((s_pg_rca8_pg_fa2_and0 >> 0) & 0x01);
|
|
s_pg_rca8_pg_fa3_xor0 = ((a >> 3) & 0x01) ^ ((b >> 3) & 0x01);
|
|
s_pg_rca8_pg_fa3_and0 = ((a >> 3) & 0x01) & ((b >> 3) & 0x01);
|
|
s_pg_rca8_pg_fa3_xor1 = ((s_pg_rca8_pg_fa3_xor0 >> 0) & 0x01) ^ ((s_pg_rca8_or2 >> 0) & 0x01);
|
|
s_pg_rca8_and3 = ((s_pg_rca8_or2 >> 0) & 0x01) & ((s_pg_rca8_pg_fa3_xor0 >> 0) & 0x01);
|
|
s_pg_rca8_or3 = ((s_pg_rca8_and3 >> 0) & 0x01) | ((s_pg_rca8_pg_fa3_and0 >> 0) & 0x01);
|
|
s_pg_rca8_pg_fa4_xor0 = ((a >> 4) & 0x01) ^ ((b >> 4) & 0x01);
|
|
s_pg_rca8_pg_fa4_and0 = ((a >> 4) & 0x01) & ((b >> 4) & 0x01);
|
|
s_pg_rca8_pg_fa4_xor1 = ((s_pg_rca8_pg_fa4_xor0 >> 0) & 0x01) ^ ((s_pg_rca8_or3 >> 0) & 0x01);
|
|
s_pg_rca8_and4 = ((s_pg_rca8_or3 >> 0) & 0x01) & ((s_pg_rca8_pg_fa4_xor0 >> 0) & 0x01);
|
|
s_pg_rca8_or4 = ((s_pg_rca8_and4 >> 0) & 0x01) | ((s_pg_rca8_pg_fa4_and0 >> 0) & 0x01);
|
|
s_pg_rca8_pg_fa5_xor0 = ((a >> 5) & 0x01) ^ ((b >> 5) & 0x01);
|
|
s_pg_rca8_pg_fa5_and0 = ((a >> 5) & 0x01) & ((b >> 5) & 0x01);
|
|
s_pg_rca8_pg_fa5_xor1 = ((s_pg_rca8_pg_fa5_xor0 >> 0) & 0x01) ^ ((s_pg_rca8_or4 >> 0) & 0x01);
|
|
s_pg_rca8_and5 = ((s_pg_rca8_or4 >> 0) & 0x01) & ((s_pg_rca8_pg_fa5_xor0 >> 0) & 0x01);
|
|
s_pg_rca8_or5 = ((s_pg_rca8_and5 >> 0) & 0x01) | ((s_pg_rca8_pg_fa5_and0 >> 0) & 0x01);
|
|
s_pg_rca8_pg_fa6_xor0 = ((a >> 6) & 0x01) ^ ((b >> 6) & 0x01);
|
|
s_pg_rca8_pg_fa6_and0 = ((a >> 6) & 0x01) & ((b >> 6) & 0x01);
|
|
s_pg_rca8_pg_fa6_xor1 = ((s_pg_rca8_pg_fa6_xor0 >> 0) & 0x01) ^ ((s_pg_rca8_or5 >> 0) & 0x01);
|
|
s_pg_rca8_and6 = ((s_pg_rca8_or5 >> 0) & 0x01) & ((s_pg_rca8_pg_fa6_xor0 >> 0) & 0x01);
|
|
s_pg_rca8_or6 = ((s_pg_rca8_and6 >> 0) & 0x01) | ((s_pg_rca8_pg_fa6_and0 >> 0) & 0x01);
|
|
s_pg_rca8_pg_fa7_xor0 = ((a >> 7) & 0x01) ^ ((b >> 7) & 0x01);
|
|
s_pg_rca8_pg_fa7_and0 = ((a >> 7) & 0x01) & ((b >> 7) & 0x01);
|
|
s_pg_rca8_pg_fa7_xor1 = ((s_pg_rca8_pg_fa7_xor0 >> 0) & 0x01) ^ ((s_pg_rca8_or6 >> 0) & 0x01);
|
|
s_pg_rca8_and7 = ((s_pg_rca8_or6 >> 0) & 0x01) & ((s_pg_rca8_pg_fa7_xor0 >> 0) & 0x01);
|
|
s_pg_rca8_or7 = ((s_pg_rca8_and7 >> 0) & 0x01) | ((s_pg_rca8_pg_fa7_and0 >> 0) & 0x01);
|
|
s_pg_rca8_xor0 = ((a >> 7) & 0x01) ^ ((b >> 7) & 0x01);
|
|
s_pg_rca8_xor1 = ((s_pg_rca8_xor0 >> 0) & 0x01) ^ ((s_pg_rca8_or7 >> 0) & 0x01);
|
|
|
|
s_pg_rca8_out |= ((s_pg_rca8_pg_fa0_xor0 >> 0) & 0x01ull) << 0;
|
|
s_pg_rca8_out |= ((s_pg_rca8_pg_fa1_xor1 >> 0) & 0x01ull) << 1;
|
|
s_pg_rca8_out |= ((s_pg_rca8_pg_fa2_xor1 >> 0) & 0x01ull) << 2;
|
|
s_pg_rca8_out |= ((s_pg_rca8_pg_fa3_xor1 >> 0) & 0x01ull) << 3;
|
|
s_pg_rca8_out |= ((s_pg_rca8_pg_fa4_xor1 >> 0) & 0x01ull) << 4;
|
|
s_pg_rca8_out |= ((s_pg_rca8_pg_fa5_xor1 >> 0) & 0x01ull) << 5;
|
|
s_pg_rca8_out |= ((s_pg_rca8_pg_fa6_xor1 >> 0) & 0x01ull) << 6;
|
|
s_pg_rca8_out |= ((s_pg_rca8_pg_fa7_xor1 >> 0) & 0x01ull) << 7;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 8;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 9;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 10;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 11;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 12;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 13;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 14;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 15;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 16;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 17;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 18;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 19;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 20;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 21;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 22;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 23;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 24;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 25;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 26;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 27;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 28;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 29;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 30;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 31;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 32;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 33;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 34;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 35;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 36;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 37;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 38;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 39;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 40;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 41;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 42;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 43;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 44;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 45;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 46;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 47;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 48;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 49;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 50;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 51;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 52;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 53;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 54;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 55;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 56;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 57;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 58;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 59;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 60;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 61;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 62;
|
|
s_pg_rca8_out |= ((s_pg_rca8_xor1 >> 0) & 0x01ull) << 63;
|
|
return s_pg_rca8_out;
|
|
} |