A Method for the Development of Combined Floating- and Fixed-Point SystemC Models Yves Vanderperren [email protected] 5. European SystemC Users Group Meeting All rights reserved 05/03/2002 2002 - Alcatel Microelectronics Outline t Introduction: Gap between Floating- and Fixed-Point t Floating- and Fixed-Point Values t Bridging the Gap to Fixed-Point with t Conclusions 05/03/2002 A Method for the Development of Combined Floating- and Fixed-Point SystemC Models, 2002 - Alcatel Microelectronics 2 Introduction: Gap between Floating- and Fixed-Point 05/03/2002 A Method for the Development of Combined Floating- and Fixed-Point SystemC Models, 2002 - Alcatel Microelectronics 3 Gap Floating- vs. Fixed-point ? Floating-Point “unlimited” range 05/03/2002 Fixed-Point limited precision A Method for the Development of Combined Floating- and Fixed-Point SystemC Models, 2002 - Alcatel Microelectronics 4 Gap Floating- vs. Fixed-Point • Floating-Point t Fixed-Point Conversion of the SystemC model to fixed-point 05/03/2002 A Method for the Development of Combined Floating- and Fixed-Point SystemC Models, 2002 - Alcatel Microelectronics 5 Gap Floating- vs. Fixed-Point ‚ fixed-point design ... simulation Floating-Point t t Fixed-Point design space exploration Fixed-Point Conversion of the SystemC model to fixed-point Fixed-point design space exploration l scale properly t t l minimize cost & power with precision constraint t 05/03/2002 avoid overflow avoid quantization error use as few bits as possible A Method for the Development of Combined Floating- and Fixed-Point SystemC Models, 2002 - Alcatel Microelectronics 6 Gap Floating- vs. Fixed-Point t Example : SC_MODULE(accumulator) { SC_MODULE(accumulator) { // input ports // input ports sc_in<double> In; sc_in<double> In; sc_in<bool> Rst; sc_in<bool> Rst; sc_in_clk Clk; sc_in_clk Clk; // output ports // output ports sc_out<double> Out; sc_out<double> Out; ... ... }; }; 05/03/2002 SC_MODULE(accumulator) SC_MODULE(accumulator) {{ // // input input ports ports sc_in<sc_fixed<8,1> sc_in<sc_fixed<8,1> >> In; In; sc_in<bool> Rst; sc_in<bool> Rst; sc_in_clk sc_in_clk Clk; Clk; floating point // // output output ports ports sc_out<sc_fixed<8,1> sc_out<sc_fixed<8,1> >> Out; Out; fixed point ... ... }; }; A Method for the Development of Combined Floating- and Fixed-Point SystemC Models, 2002 - Alcatel Microelectronics 7 Gap Floating- vs. Fixed-Point fixed-point design stsetepp s i ththis e r k mmaakeeaasiseier e simulation ioionn s r e s oonnvver c id c aavvooid Floating-Point t t Fixed-Point design space exploration ... Fixed-Point Conversion of the SystemC model to fixed-point Fixed-point design space exploration l scale properly t t l minimize cost & power with precision constraint t 05/03/2002 avoid overflow avoid quantization error use as few bits as possible A Method for the Development of Combined Floating- and Fixed-Point SystemC Models, 2002 - Alcatel Microelectronics 8 Floating- and Fixed-Point Values 05/03/2002 A Method for the Development of Combined Floating- and Fixed-Point SystemC Models, 2002 - Alcatel Microelectronics 9 Floating- and Fixed-Point Values t Fixed-point representation: binary word l l t wl: total word length iwl: integer word length MSB biwl-1 LSB ... b1 b0 ... biwl-wl binary point Link to floating-point: Slope & Bias encoding scheme n fl ≅ n fx = slope ⋅ nq + bias if unsigned : nq = iwl −1 ∑ 0.11 0.10 bi 2 i 0.01 0.00 i =iwl − wl if signed : nq = −biwl −1 2 nq fixed point value nfx iwl −1 + ∑ 1.10 floating point value nfl slope bias = 0 1.11 iwl − 2 bi 2 i 1.01 i =iwl − wl 1.00 05/03/2002 A Method for the Development of Combined Floating- and Fixed-Point SystemC Models, 2002 - Alcatel Microelectronics 10 Floating- and Fixed-Point Values t Example : l l l l sensor measuring water temperature range is limited: 0 to 100 ºC bias is 0 to be mapped onto 8 bits unsigned 6 1 bit ⇔ 1 °C leads to a waste of precision 4 1 bit ⇔ 100/255 °C is better fixed point value (bits) 6 4 00000110 00000000 0°C 0°C 00000101 00000001 1°C 0.4°C 00000100 00000010 2°C 0.8°C 100°C 39.2°C 00000011 00000010 slope-1 = 100/255 [°C/bit] … 01100100 … 11111111 00000001 00000000 imposs. 100°C fl. point value (degrees) 05/03/2002 A Method for the Development of Combined Floating- and Fixed-Point SystemC Models, 2002 - Alcatel Microelectronics 11 Bridging the Gap to Fixed-Point with 05/03/2002 A Method for the Development of Combined Floating- and Fixed-Point SystemC Models, 2002 - Alcatel Microelectronics 12 Fixed-Point with SystemC t SystemC enables fixed-point or floating-point models 6 6specific specificoperations operations DUT floating point double in TB 6 6conversion conversionneeded needed out float 6 6maintenance maintenance 6 6no noscale, scale,no nolink link between fl. & between fl. &fx. fx. DUT fixed point sc_fixed<…> TB 05/03/2002 6 622models models out fixed 6 6fixed-point fixed-pointdesign design space spaceexploration exploration 6 6... ... A Method for the Development of Combined Floating- and Fixed-Point SystemC Models, 2002 - Alcatel Microelectronics 13 Fixed-Point with SystemC t Gap bridged by introducing a new data type l l carrying BOTH floating- and fixed-point values, and the associated slope conditions evaluated using the floating- or the fixed-point value, depending on a precision mode flag DUT fl. point DUT fl. & fx. point TB DUT fx. point in TB out fl&fx TB 05/03/2002 A Method for the Development of Combined Floating- and Fixed-Point SystemC Models, 2002 - Alcatel Microelectronics 14 Fixed-Point with SystemC t Definition of the new data type fx_double floating point value scale fixed point value fixed point parameters precision mode t double double bits word length, quantization mode, overflow mode flag: floating- or fixed-point mode Example of arithmetic operation 25.36 [°C] 100/255 [°C/bit] b#01000000 {⇔ 25.1 [°C]} (8,8,SC_TRN,SC_WRAP) Floating-point mode + note: 05/03/2002 45 [°C] 100/255 [°C/bit] b#01110010 {⇔ 44.7 [°C]} (8,8,SC_TRN,SC_WRAP) Floating-point mode = 70.36 [°C] 100/255 [°C/bit] b#10110010 {⇔ 69.8 [°C]} (8,8,SC_TRN,SC_WRAP) Floating-point mode 70.36 [°C] / (100/255 [°C/bit] ) = b#10110011 propagation of rounding errors A Method for the Development of Combined Floating- and Fixed-Point SystemC Models, 2002 - Alcatel Microelectronics 15 Fixed-Point with SystemC t Example of relational operation 25.36 [°C] 100/255 [°C/bit] b#01000000 {⇔ 25.1 [°C]} (8,8,SC_TRN,SC_WRAP) Floating-point mode 25.36 [°C] 100/255 [°C/bit] b#01000000 {⇔ 25.1 [°C]} (8,8,SC_TRN,SC_WRAP) Fixed-point mode 05/03/2002 > 25.2 [°C] 100/255 [°C/bit] b#01000000 {⇔ 25.1 [°C]} (8,8,SC_TRN,SC_WRAP) Floating-point mode > 25.2 [°C] 100/255 [°C/bit] b#01000000 {⇔ 25.1 [°C]} (8,8,SC_TRN,SC_WRAP) Fixed-point mode Yes No A Method for the Development of Combined Floating- and Fixed-Point SystemC Models, 2002 - Alcatel Microelectronics 16 Gap Floating- vs. Fixed-Point t Example : combined SC_MODULE(accumulator) SC_MODULE(accumulator) {{ // // input input ports ports sc_in<double> sc_in<double> In; In; sc_in<bool> Rst; sc_in<bool> Rst; sc_in_clk Clk; sc_in_clk Clk; // // output output ports ports sc_out<double> sc_out<double> Out; Out; ... ... }; }; SC_MODULE(accumulator) SC_MODULE(accumulator) {{ // // input input ports ports sc_in<sc_fixed<8,1> sc_in<sc_fixed<8,1> >> In; In; sc_in<bool> sc_in<bool> Rst; Rst; sc_in_clk sc_in_clk Clk; Clk; SC_MODULE(accumulator) { SC_MODULE(accumulator) { // input ports // input ports sc_in<fx_double> sc_in<fx_double> In; In; sc_in<bool> Rst; sc_in<bool> Rst; sc_in_clk Clk; sc_in_clk Clk; // // output output ports ports sc_out<fx_double> Out; sc_out<fx_double> Out; ... ... }; }; // // output output ports ports sc_out<sc_fixed<8,1> sc_out<sc_fixed<8,1> >> Out; Out; ... ... }; }; 05/03/2002 A Method for the Development of Combined Floating- and Fixed-Point SystemC Models, 2002 - Alcatel Microelectronics 17 Fixed-Point with SystemC t Experimental results ρ xx (n) = L −1 ∑ x(n − L − k ) ⋅ x* (n − k ) k =0 fx config DUT fl. & fx. point in 05/03/2002 TB out fl&fx A Method for the Development of Combined Floating- and Fixed-Point SystemC Models, 2002 - Alcatel Microelectronics 18 Fixed-Point with SystemC t Experimental results ( normalized speed Floating-point Fixed-point Fixed-point+ Floating-point v2.0) … …but butreduced reduceddesign designtime time! ! fx_double fx_double (with type verif.) 20 18 16 14 12 10 8 6 4 2 0 05/03/2002 A Method for the Development of Combined Floating- and Fixed-Point SystemC Models, 2002 - Alcatel Microelectronics 19 Conclusions 05/03/2002 A Method for the Development of Combined Floating- and Fixed-Point SystemC Models, 2002 - Alcatel Microelectronics 20 Conclusions t Pros & Cons 4 4no noconversion conversion 6 6simulation simulationspeed speed 4 4common commonoperations operations 6 6good goodstyle stylerequired required 4 4common commoninterfaces, interfaces, enhanced enhancedreuse reuse 4 411model model 4 4maintenance maintenance 4 4scale scalepropagation propagation 4 4dynamic dynamicscale scale 4 4fixed-point fixed-pointdesign design space exploration space exploration Questions? 4 4strong strongtype-checking type-checking 05/03/2002 A Method for the Development of Combined Floating- and Fixed-Point SystemC Models, 2002 - Alcatel Microelectronics 21
© Copyright 2026 Paperzz