URL
https://opencores.org/ocsvn/ssbcc/ssbcc/trunk
Subversion Repositories ssbcc
Compare Revisions
- This comparison shows the changes necessary to convert path
/ssbcc/trunk/lib
- from Rev 3 to Rev 4
- ↔ Reverse comparison
Rev 3 → Rev 4
/9x8/deprecated/math.s
0,0 → 1,62
; Copyright 2012, Sinclair R.F., Inc. |
; |
; Multi-byte arithmetic |
|
; Notation: Multi-byte values on the stack are xx[n] where n=0 is the least |
; significant byte of the value |
|
.function add_u16_u8__u16 ; ( u0[0] u0[1] u1[0] - us[0] us[1] ) |
swap >r +uu r> + |
.return |
|
.function add_u16_u8__u24 ; ( u0[0] u0[1] u1[0] - us[0] us[1] us[2] ) |
swap >r +uu r> +uu |
.return |
|
.function add_u16_u16__u16 ; ( u0[0] u0[1] u1[0] u1[1] - us[0] us[1] ) |
>r .call(add_u16_u8__u16) r> + |
.return |
|
.function add_u16_u16__u24 ; ( u0[0] u0[1] u1[0] u1[1] - us[0] us[1] us[2] ) |
>r .call(add_u16_u8__u24) r> .call(add_u16_u8__u16) |
.return |
|
.function add_u24_u8__u24 ; ( u0[0] u0[1] u0[2] u1[0] - us[0] us[1] us[2] ) |
swap >r .call(add_u16_u8__u24) r> + |
.return |
|
.function add_u24_u8__u32 ; ( u0[0] u0[1] u0[2] u1[0] - us[0] us[1] us[2] u[3] ) |
swap >r .call(add_u16_u8__u24) r> +uu |
.return |
|
.function add_u24_u16__u24 ; ( u0[0] u0[1] u0[2] u1[0] u1[1] - us[0] us[1] us[2] ) |
>r .call(add_u24_u8__u24) r> .call(add_u16_u8__u16) |
.return |
|
.function add_u24_u16__u32 ; ( u0[0] u0[1] u0[2] u1[0] u1[1] - us[0] us[1] us[2] us[3] ) |
>r .call(add_u24_u8__u32) r> .call(add_u24_u8__u24) |
.return |
|
.function add_u24_u24__u24 ; ( u0[0] u0[1] u0[2] u1[0] u1[1] u1[2] - us[0] us[1] us[2] ) |
>r .call(add_u24_u16__u24) r> + |
.return |
|
.function add_u24_u24__u32 ; ( u0[0] u0[1] u0[2] u1[0] u1[1] u1[2] - us[0] us[1] us[2] us[3] ) |
>r .call(add_u24_u16__u32) r> .call(add_u16_u8__u16) |
.return |
|
.function add_u32_u8__u32 ; ( u0[0] u0[1] u0[2] u0[3] u1[0] - us[0] us[1] us[2] us[3] ) |
swap >r .call(add_u24_u8__u32) r> + |
.return |
|
.function add_u32_u16__u32 ; ( u0[0] u0[1] u0[2] u0[3] u1[0] u1[1] - us[0] us[1] us[2] us[3] ) |
>r .call(add_u32_u8__u32) r> .call(add_u24_u8__u24) |
.return |
|
.function add_u32_u24__u32 ; ( u0[0] u0[1] u0[2] u0[3] u1[0] u1[1] u1[2] - us[0] us[1] us[2] us[3] ) |
>r .call(add_u32_u16__u32) r> .call(add_u16_u8__u16) |
.return |
|
.function add_u32_u32__u32 ; ( u0[0] u0[1] u0[2] u0[3] u1[0] u1[1] u1[2] u1[3] - us[0] us[1] us[2] us[3] ) |
>r .call(add_u32_u24__u32) r> + |
.return |
/9x8/tb/.gitignore
1,6 → 1,5
ssbcc |
tb |
uc.9x8 |
uc.9x8-meta |
uc.v |
*.mem |
/9x8/tb/math/tb.gtkw
0,0 → 1,37
[*] |
[*] GTKWave Analyzer v3.3.42 (w)1999-2012 BSI |
[*] Mon Mar 24 17:27:25 2014 |
[*] |
[dumpfile] "/home/rsinclair/Projects/SSBCC/lib/9x8/tb/math/tb.vcd" |
[dumpfile_mtime] "Mon Mar 24 17:22:21 2014" |
[dumpfile_size] 54584 |
[savefile] "/home/rsinclair/Projects/SSBCC/lib/9x8/tb/math/tb.gtkw" |
[timestart] 593900 |
[size] 1920 1171 |
[pos] -1 -1 |
*-15.400721 750000 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 |
[treeopen] tb. |
[sst_width] 205 |
[signals_width] 223 |
[sst_expanded] 1 |
[sst_vpaned_height] 353 |
@28 |
tb.inst_uc.i_clk |
tb.inst_uc.i_rst |
@23 |
tb.inst_uc.s_R_stack_ptr[4:0] |
@22 |
>10000 |
tb.inst_uc.s_PC[9:0] |
>10000 |
tb.inst_uc.s_opcode[8:0] |
@820 |
>0 |
tb.inst_uc.s_opcode_name[23:0] |
@22 |
tb.inst_uc.s_R[9:0] |
tb.inst_uc.s_T[7:0] |
tb.inst_uc.s_N[7:0] |
tb.inst_uc.s_Np_stack_ptr[6:0] |
[pattern_trace] 1 |
[pattern_trace] 0 |
/9x8/tb/math/run
0,0 → 1,18
#!/bin/bash |
# Copyright 2013, Sinclair R.F., Inc. |
# Run the test benches for the libraries. |
|
NAME="math"; |
|
rm --force ssbcc; |
ln -s ../../../../ssbcc; |
|
./ssbcc -q -P monitor_stack --display-opcode uc.9x8 || { echo "FATAL ERROR testing ${NAME}" > /dev/stderr; exit 1; } |
iverilog -o tb tb.v uc.v || exit 1; |
if [ -n "`./tb | gawk -f tb.awk`" ]; then |
echo "${NAME} failed" > /dev/stderr; |
exit 1; |
fi |
echo "Passed: ${NAME}"; |
|
#rm --force ssbcc uc.9x8-meta uc.v tb; |
9x8/tb/math/run
Property changes :
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: 9x8/tb/math/tb.awk
===================================================================
--- 9x8/tb/math/tb.awk (nonexistent)
+++ 9x8/tb/math/tb.awk (revision 4)
@@ -0,0 +1,8 @@
+/^VCD/{ next; }
+{
+ a=strtonum("0x" $1);
+ b=strtonum("0x" $3);
+ c=strtonum("0x" $5);
+ if (c != a + b)
+ print $0;
+}
9x8/tb/math/tb.awk
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: 9x8/tb/math/uc.s
===================================================================
--- 9x8/tb/math/uc.s (nonexistent)
+++ 9x8/tb/math/uc.s (revision 4)
@@ -0,0 +1,146 @@
+; Copyright 2014, Sinclair R.F., Inc.
+; Test bench for ../../math.s
+
+.include math.s
+
+.macro push16
+.macro push24
+.macro push32
+
+.main
+
+ ; Test u8 + u8 ==> u16
+ 0x7F 0x80
+ 0x7F 0x81
+ 0x80 0x7F
+ 0x80 0x80
+ 0x80 0x81
+ 0xFF 0x00
+ 0xFF 0x01
+ 0xFF 0x02
+ 0xFF 0xFE
+ 0xFF 0xFF
+ ${10-1} :loop__u8_u8_u16 >r
+ .call(out8,over)
+ .call(out8,dup)
+ .call(math__add_u8_u8_u16) .call(out16)
+ .outstrobe(O_VALUE_DONE)
+ r> .jumpc(loop__u8_u8_u16,1-) drop
+
+ .push16(0x007F) 0x80
+ .push16(0x007F) 0x81
+ .push16(0x0080) 0x7F
+ .push16(0x0080) 0x80
+ .push16(0x0080) 0x81
+ .push16(0x00FF) 0x00
+ .push16(0x00FF) 0x01
+ .push16(0x00FF) 0x02
+ .push16(0x00FF) 0xFE
+ .push16(0x00FF) 0xFF
+ .push16(0x017F) 0x80
+ .push16(0x017F) 0x81
+ .push16(0x0180) 0x7F
+ .push16(0x0180) 0x80
+ .push16(0x0180) 0x81
+ .push16(0x01FF) 0x00
+ .push16(0x01FF) 0x01
+ .push16(0x01FF) 0x02
+ .push16(0x01FF) 0xFE
+ .push16(0x01FF) 0xFF
+ ${20-1} :loop__u16_u8_u16 >r
+ >r over .call(out16,over)
+ r> .call(out8,dup)
+ .call(math__add_u16_u8_u16) .call(out16)
+ .outstrobe(O_VALUE_DONE)
+ r> .jumpc(loop__u16_u8_u16,1-) drop
+
+ .push24(0x0001FF) 0xFF
+ ${1-1} :loop__u24_u8_u24 >r
+ >r .call(preserve_out24) r>
+ .call(out8,dup)
+ .call(math__add_u24_u8_u24)
+ .call(out24)
+ .outstrobe(O_VALUE_DONE)
+ r> .jumpc(loop__u24_u8_u24,1-) drop
+
+ .push24(0x0001FF) 0xFF
+ ${1-1} :loop__u24_u8_u32 >r
+ >r .call(preserve_out24) r>
+ .call(out8,dup)
+ .call(math__add_u24_u8_u32)
+ .call(out32)
+ .outstrobe(O_VALUE_DONE)
+ r> .jumpc(loop__u24_u8_u32,1-) drop
+
+ .push32(0x00800000) 0xFF
+ ${1-1} :loop__u32_u8_u32 >r
+ >r .call(preserve_out32) r>
+ .call(out8,dup)
+ .call(math__add_u32_u8_u32)
+ .call(out32)
+ .outstrobe(O_VALUE_DONE)
+ r> .jumpc(loop__u32_u8_u32,1-) drop
+
+ .push32(${0x00800000+0*1280*960*4}) .push24(${1280*960*4})
+ .push32(${0x00800000+1*1280*960*4}) .push24(${1280*960*4})
+ .push32(${0x00800000+2*1280*960*4}) .push24(${1280*960*4})
+ .push32(${0x00800000+3*1280*960*4}) .push24(${1280*960*4})
+ .push32(${0x00800000+4*1280*960*4}) .push24(${1280*960*4})
+ ${5-1} :loop__u32_u24_u32 >r
+ >r >r >r .call(preserve_out32) r> r> r>
+ .call(preserve_out24)
+ .call(math__add_u32_u24_u32)
+ .call(out32)
+ .outstrobe(O_VALUE_DONE)
+ r> .jumpc(loop__u32_u24_u32,1-) drop
+
+ .push32(${0x00800000+0*1280*960*4}) .push32(${1280*960*4})
+ .push32(${0x00800000+1*1280*960*4}) .push32(${1280*960*4})
+ .push32(${0x00800000+2*1280*960*4}) .push32(${1280*960*4})
+ .push32(${0x00800000+3*1280*960*4}) .push32(${1280*960*4})
+ .push32(${0x00800000+4*1280*960*4}) .push32(${1280*960*4})
+ ${5-1} :loop__u32_u32_u32 >r
+ >r >r >r >r .call(preserve_out32) r> r> r> r>
+ .call(preserve_out32)
+ .call(math__add_u32_u32_u32)
+ .call(out32)
+ .outstrobe(O_VALUE_DONE)
+ r> .jumpc(loop__u32_u32_u32,1-) drop
+
+ ; terminate and wait forever
+ .outstrobe(O_TERMINATE) :infinite .jump(infinite)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;
+; Routines to output results.
+;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+.function preserve_out24
+ 0 .outport(O_VALUE)
+ .outport(O_VALUE,>r)
+ .outport(O_VALUE,>r)
+ O_VALUE outport
+ r> r>
+ .return
+
+.function preserve_out32
+ .outport(O_VALUE,>r)
+ .outport(O_VALUE,>r)
+ .outport(O_VALUE,>r)
+ O_VALUE outport
+ r> r> r>
+ .return
+
+.function out8
+ 0 0 0 .call(out32) .return
+
+.function out16
+ 0 0 .call(out32) .return
+
+.function out24
+ 0 .call(out32) .return
+
+.function out32
+ ${4-1} :loop swap .outport(O_VALUE) .jumpc(loop,1-) drop
+ .return
Index: 9x8/tb/math/tb.v
===================================================================
--- 9x8/tb/math/tb.v (nonexistent)
+++ 9x8/tb/math/tb.v (revision 4)
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ *
+ * Copyright 2014, Sinclair R.F., Inc.
+ *
+ * Test bench for the core/9x8 math library.
+ *
+ ******************************************************************************/
+
+`timescale 1ns/1ps
+
+module tb;
+
+reg s_clk = 1'b1;
+always @ (s_clk)
+ s_clk <= #5 ~s_clk;
+
+reg s_rst = 1'b1;
+initial begin
+ repeat (5) @ (posedge s_clk)
+ s_rst <= 1'b0;
+end
+
+wire [95:0] s_value;
+wire s_value_done;
+wire s_terminate;
+uc inst_uc(
+ // synchronous reset and processor clock
+ .i_rst (s_rst),
+ .i_clk (s_clk),
+ // 8-bit test values
+ .o_value (s_value),
+ .o_value_done (s_value_done),
+ // termination strobe
+ .o_terminate (s_terminate)
+);
+
+always @ (posedge s_value_done)
+ $display("%08h + %08h = %08h", s_value[64+:32], s_value[32+:32], s_value[0+:32]);
+
+always @ (posedge s_terminate)
+ $finish;
+
+initial begin
+ $dumpfile("tb.vcd");
+ $dumpvars();
+end
+
+endmodule
9x8/tb/math/tb.v
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: 9x8/tb/math/uc.9x8
===================================================================
--- 9x8/tb/math/uc.9x8 (nonexistent)
+++ 9x8/tb/math/uc.9x8 (revision 4)
@@ -0,0 +1,21 @@
+# Copyright 2014, Sinclair R.F., Inc.
+# Test bench for the math library.
+
+ARCHITECTURE core/9x8 Verilog
+
+INSTRUCTION 1024
+DATA_STACK 128
+RETURN_STACK 32
+
+PORTCOMMENT 32-bit addition result
+PERIPHERAL big_outport outport=O_VALUE \
+ outsignal=o_value \
+ width=96
+OUTPORT strobe o_value_done \
+ O_VALUE_DONE
+
+PORTCOMMENT termination strobe
+OUTPORT strobe o_terminate \
+ O_TERMINATE
+
+ASSEMBLY uc.s
Index: 9x8/tb/char/uc.s
===================================================================
--- 9x8/tb/char/uc.s (revision 3)
+++ 9x8/tb/char/uc.s (revision 4)
@@ -1,5 +1,5 @@
; Copyright 2013, Sinclair R.F., Inc.
-; Test bench for ../char.s
+; Test bench for ../../char.s
.include char.s
/9x8/tb/char/uc.9x8
0,0 → 1,16
# Copyright 2013, Sinclair R.F., Inc. |
# Test bench for the math libraries. |
|
ARCHITECTURE core/9x8 Verilog |
|
INSTRUCTION 1024 |
DATA_STACK 32 |
RETURN_STACK 32 |
|
PORTCOMMENT 8-bit test values |
OUTPORT 8-bit,strobe o_value,o_value_wr O_VALUE |
|
PORTCOMMENT termination strobe |
OUTPORT strobe o_terminate_str O_TERMINATE |
|
ASSEMBLY uc.s |
/9x8/tb/cmp_8bit_uu/uc.s
1,5 → 1,5
; Copyright 2013, Sinclair R.F., Inc. |
; Test bench for ../cmp_8bit_uu.s |
; Test bench for ../../cmp_8bit_uu.s |
|
.include cmp_8bit_uu.s |
|
/9x8/tb/cmp_8bit_uu/uc.9x8
1,5 → 1,5
# Copyright 2013, Sinclair R.F., Inc. |
# Test bench for the math libraries. |
# Test bench for the icomparison math library. |
|
ARCHITECTURE core/9x8 Verilog |
|
/9x8/math.s
1,62 → 1,60
; Copyright 2012, Sinclair R.F., Inc. |
; Copyright 2014, Sinclair R.F., Inc. |
; |
; Multi-byte arithmetic |
; Unsigned arithmetic operations. |
|
; Notation: Multi-byte values on the stack are xx[n] where n=0 is the least |
; significant byte of the value |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
; |
; Add two unsigned 8-bit values to produce an unsigned 16-bit value. |
; Method: Calculate the sum of the msb of the two raw values and the msb of the |
; sums of the 7 lsbs of the two values to get the msb of the sum and |
; the lsb of the MSB of the 16-bit sum. |
; 36 instructions |
; |
; ( u1 u2 - (u1+u2)_LSB (u1+u2)_MSB ) |
.function math__add_u8_u8_u16 |
; and the two 7 lsbs and put the 7 lsb of that sum on the return stack |
over 0x7F & over 0x7F & + dup 0x7F & >r |
; add the msb of the sum of the 7 lsbs and the two inputs |
0x80 & <<msb swap 0x80 & <<msb + swap 0x80 & <<msb + |
; construct the MSB of the sum as bit 1 of the sums of the msbs |
dup 0>> swap |
; set the msb of the LSB if the lsb of the sum of the msbs is non-zero |
0x01 & 0<> 0x80 & r> or |
; swap the orders so that the MSB is on the top of the data stack |
.return(swap) |
|
.function add_u16_u8__u16 ; ( u0[0] u0[1] u1[0] - us[0] us[1] ) |
swap >r +uu r> + |
.return |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
; miscellaneous unsigned addition operations |
|
.function add_u16_u8__u24 ; ( u0[0] u0[1] u1[0] - us[0] us[1] us[2] ) |
swap >r +uu r> +uu |
.return |
.function math__add_u16_u8_u16 |
swap >r .call(math__add_u8_u8_u16) r> .return(+) |
|
.function add_u16_u16__u16 ; ( u0[0] u0[1] u1[0] u1[1] - us[0] us[1] ) |
>r .call(add_u16_u8__u16) r> + |
.return |
.function math__add_u16_u8_u24 |
swap >r .call(math__add_u8_u8_u16) r> .call(math__add_u8_u8_u16) .return |
|
.function add_u16_u16__u24 ; ( u0[0] u0[1] u1[0] u1[1] - us[0] us[1] us[2] ) |
>r .call(add_u16_u8__u24) r> .call(add_u16_u8__u16) |
.return |
.function math__add_u24_u8_u24 |
swap >r .call(math__add_u16_u8_u24) |
r> .return(+) |
|
.function add_u24_u8__u24 ; ( u0[0] u0[1] u0[2] u1[0] - us[0] us[1] us[2] ) |
swap >r .call(add_u16_u8__u24) r> + |
.return |
.function math__add_u24_u8_u32 |
swap >r .call(math__add_u16_u8_u24) |
r> .call(math__add_u8_u8_u16) |
.return |
|
.function add_u24_u8__u32 ; ( u0[0] u0[1] u0[2] u1[0] - us[0] us[1] us[2] u[3] ) |
swap >r .call(add_u16_u8__u24) r> +uu |
.return |
.function math__add_u32_u8_u32 |
swap >r .call(math__add_u24_u8_u32) |
r> .return(+) |
|
.function add_u24_u16__u24 ; ( u0[0] u0[1] u0[2] u1[0] u1[1] - us[0] us[1] us[2] ) |
>r .call(add_u24_u8__u24) r> .call(add_u16_u8__u16) |
.return |
.function math__add_u32_u16_u32 |
>r .call(math__add_u32_u8_u32) |
r> .call(math__add_u24_u8_u24) |
.return |
|
.function add_u24_u16__u32 ; ( u0[0] u0[1] u0[2] u1[0] u1[1] - us[0] us[1] us[2] us[3] ) |
>r .call(add_u24_u8__u32) r> .call(add_u24_u8__u24) |
.return |
.function math__add_u32_u24_u32 |
>r .call(math__add_u32_u16_u32) |
r> .call(math__add_u16_u8_u16) |
.return |
|
.function add_u24_u24__u24 ; ( u0[0] u0[1] u0[2] u1[0] u1[1] u1[2] - us[0] us[1] us[2] ) |
>r .call(add_u24_u16__u24) r> + |
.return |
|
.function add_u24_u24__u32 ; ( u0[0] u0[1] u0[2] u1[0] u1[1] u1[2] - us[0] us[1] us[2] us[3] ) |
>r .call(add_u24_u16__u32) r> .call(add_u16_u8__u16) |
.return |
|
.function add_u32_u8__u32 ; ( u0[0] u0[1] u0[2] u0[3] u1[0] - us[0] us[1] us[2] us[3] ) |
swap >r .call(add_u24_u8__u32) r> + |
.return |
|
.function add_u32_u16__u32 ; ( u0[0] u0[1] u0[2] u0[3] u1[0] u1[1] - us[0] us[1] us[2] us[3] ) |
>r .call(add_u32_u8__u32) r> .call(add_u24_u8__u24) |
.return |
|
.function add_u32_u24__u32 ; ( u0[0] u0[1] u0[2] u0[3] u1[0] u1[1] u1[2] - us[0] us[1] us[2] us[3] ) |
>r .call(add_u32_u16__u32) r> .call(add_u16_u8__u16) |
.return |
|
.function add_u32_u32__u32 ; ( u0[0] u0[1] u0[2] u0[3] u1[0] u1[1] u1[2] u1[3] - us[0] us[1] us[2] us[3] ) |
>r .call(add_u32_u24__u32) r> + |
.return |
.function math__add_u32_u32_u32 |
>r .call(math__add_u32_u24_u32) |
r> .return(+) |