mirror of
https://github.com/ehw-fit/ariths-gen.git
synced 2025-04-19 13:30:56 +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>
176 lines
9.1 KiB
C
176 lines
9.1 KiB
C
#include <stdio.h>
|
|
#include <stdint.h>
|
|
|
|
uint64_t u_cla8(uint64_t a, uint64_t b){
|
|
uint64_t u_cla8_out = 0;
|
|
uint8_t u_cla8_pg_logic0_or0 = 0;
|
|
uint8_t u_cla8_pg_logic0_and0 = 0;
|
|
uint8_t u_cla8_pg_logic0_xor0 = 0;
|
|
uint8_t u_cla8_pg_logic1_or0 = 0;
|
|
uint8_t u_cla8_pg_logic1_and0 = 0;
|
|
uint8_t u_cla8_pg_logic1_xor0 = 0;
|
|
uint8_t u_cla8_xor1 = 0;
|
|
uint8_t u_cla8_and0 = 0;
|
|
uint8_t u_cla8_or0 = 0;
|
|
uint8_t u_cla8_pg_logic2_or0 = 0;
|
|
uint8_t u_cla8_pg_logic2_and0 = 0;
|
|
uint8_t u_cla8_pg_logic2_xor0 = 0;
|
|
uint8_t u_cla8_xor2 = 0;
|
|
uint8_t u_cla8_and1 = 0;
|
|
uint8_t u_cla8_and2 = 0;
|
|
uint8_t u_cla8_and3 = 0;
|
|
uint8_t u_cla8_and4 = 0;
|
|
uint8_t u_cla8_or1 = 0;
|
|
uint8_t u_cla8_or2 = 0;
|
|
uint8_t u_cla8_pg_logic3_or0 = 0;
|
|
uint8_t u_cla8_pg_logic3_and0 = 0;
|
|
uint8_t u_cla8_pg_logic3_xor0 = 0;
|
|
uint8_t u_cla8_xor3 = 0;
|
|
uint8_t u_cla8_and5 = 0;
|
|
uint8_t u_cla8_and6 = 0;
|
|
uint8_t u_cla8_and7 = 0;
|
|
uint8_t u_cla8_and8 = 0;
|
|
uint8_t u_cla8_and9 = 0;
|
|
uint8_t u_cla8_and10 = 0;
|
|
uint8_t u_cla8_and11 = 0;
|
|
uint8_t u_cla8_or3 = 0;
|
|
uint8_t u_cla8_or4 = 0;
|
|
uint8_t u_cla8_or5 = 0;
|
|
uint8_t u_cla8_pg_logic4_or0 = 0;
|
|
uint8_t u_cla8_pg_logic4_and0 = 0;
|
|
uint8_t u_cla8_pg_logic4_xor0 = 0;
|
|
uint8_t u_cla8_xor4 = 0;
|
|
uint8_t u_cla8_and12 = 0;
|
|
uint8_t u_cla8_or6 = 0;
|
|
uint8_t u_cla8_pg_logic5_or0 = 0;
|
|
uint8_t u_cla8_pg_logic5_and0 = 0;
|
|
uint8_t u_cla8_pg_logic5_xor0 = 0;
|
|
uint8_t u_cla8_xor5 = 0;
|
|
uint8_t u_cla8_and13 = 0;
|
|
uint8_t u_cla8_and14 = 0;
|
|
uint8_t u_cla8_and15 = 0;
|
|
uint8_t u_cla8_or7 = 0;
|
|
uint8_t u_cla8_or8 = 0;
|
|
uint8_t u_cla8_pg_logic6_or0 = 0;
|
|
uint8_t u_cla8_pg_logic6_and0 = 0;
|
|
uint8_t u_cla8_pg_logic6_xor0 = 0;
|
|
uint8_t u_cla8_xor6 = 0;
|
|
uint8_t u_cla8_and16 = 0;
|
|
uint8_t u_cla8_and17 = 0;
|
|
uint8_t u_cla8_and18 = 0;
|
|
uint8_t u_cla8_and19 = 0;
|
|
uint8_t u_cla8_and20 = 0;
|
|
uint8_t u_cla8_and21 = 0;
|
|
uint8_t u_cla8_or9 = 0;
|
|
uint8_t u_cla8_or10 = 0;
|
|
uint8_t u_cla8_or11 = 0;
|
|
uint8_t u_cla8_pg_logic7_or0 = 0;
|
|
uint8_t u_cla8_pg_logic7_and0 = 0;
|
|
uint8_t u_cla8_pg_logic7_xor0 = 0;
|
|
uint8_t u_cla8_xor7 = 0;
|
|
uint8_t u_cla8_and22 = 0;
|
|
uint8_t u_cla8_and23 = 0;
|
|
uint8_t u_cla8_and24 = 0;
|
|
uint8_t u_cla8_and25 = 0;
|
|
uint8_t u_cla8_and26 = 0;
|
|
uint8_t u_cla8_and27 = 0;
|
|
uint8_t u_cla8_and28 = 0;
|
|
uint8_t u_cla8_and29 = 0;
|
|
uint8_t u_cla8_and30 = 0;
|
|
uint8_t u_cla8_and31 = 0;
|
|
uint8_t u_cla8_or12 = 0;
|
|
uint8_t u_cla8_or13 = 0;
|
|
uint8_t u_cla8_or14 = 0;
|
|
uint8_t u_cla8_or15 = 0;
|
|
|
|
u_cla8_pg_logic0_or0 = ((a >> 0) & 0x01) | ((b >> 0) & 0x01);
|
|
u_cla8_pg_logic0_and0 = ((a >> 0) & 0x01) & ((b >> 0) & 0x01);
|
|
u_cla8_pg_logic0_xor0 = ((a >> 0) & 0x01) ^ ((b >> 0) & 0x01);
|
|
u_cla8_pg_logic1_or0 = ((a >> 1) & 0x01) | ((b >> 1) & 0x01);
|
|
u_cla8_pg_logic1_and0 = ((a >> 1) & 0x01) & ((b >> 1) & 0x01);
|
|
u_cla8_pg_logic1_xor0 = ((a >> 1) & 0x01) ^ ((b >> 1) & 0x01);
|
|
u_cla8_xor1 = ((u_cla8_pg_logic1_xor0 >> 0) & 0x01) ^ ((u_cla8_pg_logic0_and0 >> 0) & 0x01);
|
|
u_cla8_and0 = ((u_cla8_pg_logic0_and0 >> 0) & 0x01) & ((u_cla8_pg_logic1_or0 >> 0) & 0x01);
|
|
u_cla8_or0 = ((u_cla8_pg_logic1_and0 >> 0) & 0x01) | ((u_cla8_and0 >> 0) & 0x01);
|
|
u_cla8_pg_logic2_or0 = ((a >> 2) & 0x01) | ((b >> 2) & 0x01);
|
|
u_cla8_pg_logic2_and0 = ((a >> 2) & 0x01) & ((b >> 2) & 0x01);
|
|
u_cla8_pg_logic2_xor0 = ((a >> 2) & 0x01) ^ ((b >> 2) & 0x01);
|
|
u_cla8_xor2 = ((u_cla8_pg_logic2_xor0 >> 0) & 0x01) ^ ((u_cla8_or0 >> 0) & 0x01);
|
|
u_cla8_and1 = ((u_cla8_pg_logic2_or0 >> 0) & 0x01) & ((u_cla8_pg_logic0_or0 >> 0) & 0x01);
|
|
u_cla8_and2 = ((u_cla8_pg_logic0_and0 >> 0) & 0x01) & ((u_cla8_pg_logic2_or0 >> 0) & 0x01);
|
|
u_cla8_and3 = ((u_cla8_and2 >> 0) & 0x01) & ((u_cla8_pg_logic1_or0 >> 0) & 0x01);
|
|
u_cla8_and4 = ((u_cla8_pg_logic1_and0 >> 0) & 0x01) & ((u_cla8_pg_logic2_or0 >> 0) & 0x01);
|
|
u_cla8_or1 = ((u_cla8_and3 >> 0) & 0x01) | ((u_cla8_and4 >> 0) & 0x01);
|
|
u_cla8_or2 = ((u_cla8_pg_logic2_and0 >> 0) & 0x01) | ((u_cla8_or1 >> 0) & 0x01);
|
|
u_cla8_pg_logic3_or0 = ((a >> 3) & 0x01) | ((b >> 3) & 0x01);
|
|
u_cla8_pg_logic3_and0 = ((a >> 3) & 0x01) & ((b >> 3) & 0x01);
|
|
u_cla8_pg_logic3_xor0 = ((a >> 3) & 0x01) ^ ((b >> 3) & 0x01);
|
|
u_cla8_xor3 = ((u_cla8_pg_logic3_xor0 >> 0) & 0x01) ^ ((u_cla8_or2 >> 0) & 0x01);
|
|
u_cla8_and5 = ((u_cla8_pg_logic3_or0 >> 0) & 0x01) & ((u_cla8_pg_logic1_or0 >> 0) & 0x01);
|
|
u_cla8_and6 = ((u_cla8_pg_logic0_and0 >> 0) & 0x01) & ((u_cla8_pg_logic2_or0 >> 0) & 0x01);
|
|
u_cla8_and7 = ((u_cla8_pg_logic3_or0 >> 0) & 0x01) & ((u_cla8_pg_logic1_or0 >> 0) & 0x01);
|
|
u_cla8_and8 = ((u_cla8_and6 >> 0) & 0x01) & ((u_cla8_and7 >> 0) & 0x01);
|
|
u_cla8_and9 = ((u_cla8_pg_logic1_and0 >> 0) & 0x01) & ((u_cla8_pg_logic3_or0 >> 0) & 0x01);
|
|
u_cla8_and10 = ((u_cla8_and9 >> 0) & 0x01) & ((u_cla8_pg_logic2_or0 >> 0) & 0x01);
|
|
u_cla8_and11 = ((u_cla8_pg_logic2_and0 >> 0) & 0x01) & ((u_cla8_pg_logic3_or0 >> 0) & 0x01);
|
|
u_cla8_or3 = ((u_cla8_and8 >> 0) & 0x01) | ((u_cla8_and11 >> 0) & 0x01);
|
|
u_cla8_or4 = ((u_cla8_and10 >> 0) & 0x01) | ((u_cla8_or3 >> 0) & 0x01);
|
|
u_cla8_or5 = ((u_cla8_pg_logic3_and0 >> 0) & 0x01) | ((u_cla8_or4 >> 0) & 0x01);
|
|
u_cla8_pg_logic4_or0 = ((a >> 4) & 0x01) | ((b >> 4) & 0x01);
|
|
u_cla8_pg_logic4_and0 = ((a >> 4) & 0x01) & ((b >> 4) & 0x01);
|
|
u_cla8_pg_logic4_xor0 = ((a >> 4) & 0x01) ^ ((b >> 4) & 0x01);
|
|
u_cla8_xor4 = ((u_cla8_pg_logic4_xor0 >> 0) & 0x01) ^ ((u_cla8_or5 >> 0) & 0x01);
|
|
u_cla8_and12 = ((u_cla8_or5 >> 0) & 0x01) & ((u_cla8_pg_logic4_or0 >> 0) & 0x01);
|
|
u_cla8_or6 = ((u_cla8_pg_logic4_and0 >> 0) & 0x01) | ((u_cla8_and12 >> 0) & 0x01);
|
|
u_cla8_pg_logic5_or0 = ((a >> 5) & 0x01) | ((b >> 5) & 0x01);
|
|
u_cla8_pg_logic5_and0 = ((a >> 5) & 0x01) & ((b >> 5) & 0x01);
|
|
u_cla8_pg_logic5_xor0 = ((a >> 5) & 0x01) ^ ((b >> 5) & 0x01);
|
|
u_cla8_xor5 = ((u_cla8_pg_logic5_xor0 >> 0) & 0x01) ^ ((u_cla8_or6 >> 0) & 0x01);
|
|
u_cla8_and13 = ((u_cla8_or5 >> 0) & 0x01) & ((u_cla8_pg_logic5_or0 >> 0) & 0x01);
|
|
u_cla8_and14 = ((u_cla8_and13 >> 0) & 0x01) & ((u_cla8_pg_logic4_or0 >> 0) & 0x01);
|
|
u_cla8_and15 = ((u_cla8_pg_logic4_and0 >> 0) & 0x01) & ((u_cla8_pg_logic5_or0 >> 0) & 0x01);
|
|
u_cla8_or7 = ((u_cla8_and14 >> 0) & 0x01) | ((u_cla8_and15 >> 0) & 0x01);
|
|
u_cla8_or8 = ((u_cla8_pg_logic5_and0 >> 0) & 0x01) | ((u_cla8_or7 >> 0) & 0x01);
|
|
u_cla8_pg_logic6_or0 = ((a >> 6) & 0x01) | ((b >> 6) & 0x01);
|
|
u_cla8_pg_logic6_and0 = ((a >> 6) & 0x01) & ((b >> 6) & 0x01);
|
|
u_cla8_pg_logic6_xor0 = ((a >> 6) & 0x01) ^ ((b >> 6) & 0x01);
|
|
u_cla8_xor6 = ((u_cla8_pg_logic6_xor0 >> 0) & 0x01) ^ ((u_cla8_or8 >> 0) & 0x01);
|
|
u_cla8_and16 = ((u_cla8_or5 >> 0) & 0x01) & ((u_cla8_pg_logic5_or0 >> 0) & 0x01);
|
|
u_cla8_and17 = ((u_cla8_pg_logic6_or0 >> 0) & 0x01) & ((u_cla8_pg_logic4_or0 >> 0) & 0x01);
|
|
u_cla8_and18 = ((u_cla8_and16 >> 0) & 0x01) & ((u_cla8_and17 >> 0) & 0x01);
|
|
u_cla8_and19 = ((u_cla8_pg_logic4_and0 >> 0) & 0x01) & ((u_cla8_pg_logic6_or0 >> 0) & 0x01);
|
|
u_cla8_and20 = ((u_cla8_and19 >> 0) & 0x01) & ((u_cla8_pg_logic5_or0 >> 0) & 0x01);
|
|
u_cla8_and21 = ((u_cla8_pg_logic5_and0 >> 0) & 0x01) & ((u_cla8_pg_logic6_or0 >> 0) & 0x01);
|
|
u_cla8_or9 = ((u_cla8_and18 >> 0) & 0x01) | ((u_cla8_and20 >> 0) & 0x01);
|
|
u_cla8_or10 = ((u_cla8_or9 >> 0) & 0x01) | ((u_cla8_and21 >> 0) & 0x01);
|
|
u_cla8_or11 = ((u_cla8_pg_logic6_and0 >> 0) & 0x01) | ((u_cla8_or10 >> 0) & 0x01);
|
|
u_cla8_pg_logic7_or0 = ((a >> 7) & 0x01) | ((b >> 7) & 0x01);
|
|
u_cla8_pg_logic7_and0 = ((a >> 7) & 0x01) & ((b >> 7) & 0x01);
|
|
u_cla8_pg_logic7_xor0 = ((a >> 7) & 0x01) ^ ((b >> 7) & 0x01);
|
|
u_cla8_xor7 = ((u_cla8_pg_logic7_xor0 >> 0) & 0x01) ^ ((u_cla8_or11 >> 0) & 0x01);
|
|
u_cla8_and22 = ((u_cla8_or5 >> 0) & 0x01) & ((u_cla8_pg_logic6_or0 >> 0) & 0x01);
|
|
u_cla8_and23 = ((u_cla8_pg_logic7_or0 >> 0) & 0x01) & ((u_cla8_pg_logic5_or0 >> 0) & 0x01);
|
|
u_cla8_and24 = ((u_cla8_and22 >> 0) & 0x01) & ((u_cla8_and23 >> 0) & 0x01);
|
|
u_cla8_and25 = ((u_cla8_and24 >> 0) & 0x01) & ((u_cla8_pg_logic4_or0 >> 0) & 0x01);
|
|
u_cla8_and26 = ((u_cla8_pg_logic4_and0 >> 0) & 0x01) & ((u_cla8_pg_logic6_or0 >> 0) & 0x01);
|
|
u_cla8_and27 = ((u_cla8_pg_logic7_or0 >> 0) & 0x01) & ((u_cla8_pg_logic5_or0 >> 0) & 0x01);
|
|
u_cla8_and28 = ((u_cla8_and26 >> 0) & 0x01) & ((u_cla8_and27 >> 0) & 0x01);
|
|
u_cla8_and29 = ((u_cla8_pg_logic5_and0 >> 0) & 0x01) & ((u_cla8_pg_logic7_or0 >> 0) & 0x01);
|
|
u_cla8_and30 = ((u_cla8_and29 >> 0) & 0x01) & ((u_cla8_pg_logic6_or0 >> 0) & 0x01);
|
|
u_cla8_and31 = ((u_cla8_pg_logic6_and0 >> 0) & 0x01) & ((u_cla8_pg_logic7_or0 >> 0) & 0x01);
|
|
u_cla8_or12 = ((u_cla8_and25 >> 0) & 0x01) | ((u_cla8_and30 >> 0) & 0x01);
|
|
u_cla8_or13 = ((u_cla8_and28 >> 0) & 0x01) | ((u_cla8_and31 >> 0) & 0x01);
|
|
u_cla8_or14 = ((u_cla8_or12 >> 0) & 0x01) | ((u_cla8_or13 >> 0) & 0x01);
|
|
u_cla8_or15 = ((u_cla8_pg_logic7_and0 >> 0) & 0x01) | ((u_cla8_or14 >> 0) & 0x01);
|
|
|
|
u_cla8_out |= ((u_cla8_pg_logic0_xor0 >> 0) & 0x01ull) << 0;
|
|
u_cla8_out |= ((u_cla8_xor1 >> 0) & 0x01ull) << 1;
|
|
u_cla8_out |= ((u_cla8_xor2 >> 0) & 0x01ull) << 2;
|
|
u_cla8_out |= ((u_cla8_xor3 >> 0) & 0x01ull) << 3;
|
|
u_cla8_out |= ((u_cla8_xor4 >> 0) & 0x01ull) << 4;
|
|
u_cla8_out |= ((u_cla8_xor5 >> 0) & 0x01ull) << 5;
|
|
u_cla8_out |= ((u_cla8_xor6 >> 0) & 0x01ull) << 6;
|
|
u_cla8_out |= ((u_cla8_xor7 >> 0) & 0x01ull) << 7;
|
|
u_cla8_out |= ((u_cla8_or15 >> 0) & 0x01ull) << 8;
|
|
return u_cla8_out;
|
|
} |