/******************** MODULE INFO ****************************/ /* * File name : alu11.sfl * * AUTHOR : Yoshihiro Iida (3aepm001@keyaki.cc.u-tokai.ac.jp) * VERSION : 1.0 * DATE : Oct 16, 2003 * * Compiler : sfl2vl * Project : POP-11: PDP-11 compatible On Programmable chip * Functions : ALU of POP-11 * Copyright (c) Yoshihiro Iida, Tokai University, Shimizu Lab., Japan. (http://shimizu-lab.dt.u-tokai.ac.jp) This software is the property of Tokai University, Shimizu Lab., Japan. The POP-11 is free set of files; you can use it, redistribute it and/or modify it under the following terms: 1. You are not allowed to remove or modify this copyright notice and License paragraphs, even if parts of the software is used. 2. The improvements and/or extentions you make SHALL be available for the community under THIS license, source code included. Improvements or extentions, including adaptions to new architectures/languages, SHALL be reported and transmitted to Tokai University, Shimizu Lab., Japan. 3. You must cause the modified files to carry prominent notices stating that you changed the files, what you did and the date of changes. 4. You may NOT distribute this set of files under another license without explisit permission from Tokai University, Shimizu Lab., Japan. 5. This set of files is free, and distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. You SHALL NOT use this software unless you accept to carry all risk and cost of defects or limitations. * * * ------------ CHANGE RECORD ---------------- * Yoshihiro Iida (3aepm001@keyaki.cc.u-tokai.ac.jp) Sep 21, 2004: * First free version of this software published. * */ %i "cla16.sfl" declare bittest { instrin do; input in<16>, bi; output n,z; instr_arg do(in,bi); } module bittest { instrin do; input in<16>, bi; output n,z; instruct do any { (^bi): par { n = in<15>; z = ^/|in; } ( bi): par { n = in<07>; z = ^/|in<7:0>; } } } declare alu11 { input src<16>, dst<16>; input ni, ci, bi; output out<16>; output ccmask<4>, ccout<4>; instrout cc; instrin inc2, dec2, inc, dec, clr, com, neg, adc, sbc, tst, ror, rol, asr, asl, sxt, mov, cmp, bit, bic, bis, add, sub, exor, swab, mmu; instr_arg inc2(src); instr_arg dec2(src); instr_arg inc(src); instr_arg dec(src); instr_arg clr(src); instr_arg com(src); instr_arg neg(src); instr_arg adc(src); instr_arg sbc(src); instr_arg tst(src); instr_arg mmu(src); instr_arg ror(src); instr_arg rol(src); instr_arg asr(src); instr_arg asl(src); instr_arg sxt(src); instr_arg mov(src); instr_arg cmp(src,dst); instr_arg bit(src,dst); instr_arg bic(src,dst); instr_arg bis(src,dst); instr_arg add(src,dst); instr_arg sub(src,dst); instr_arg exor(src,dst); instr_arg swab(src); } module alu11 { input src<16>, dst<16>; input ni, ci, bi; output out<16>; output ccmask<4>, ccout<4>; instrout cc; instrin inc2, dec2, inc, dec, clr, com, neg, adc, sbc, tst, ror, rol, asr, asl, sxt, mov, cmp, bit, bic, bis, add, sub, exor, swab, mmu; cla16 cla; bittest btt; instr_arg cc(ccmask, ccout); instruct inc2 out = cla.do(src,0x0002,0b0,0b0).out; instruct dec2 out = cla.do(src,0xfffe,0b0,0b0).out; instruct inc par { out = cla.do(0x0000,src,0b1,bi).out; cc(0b1110, cla.n||cla.z||cla.v||0b0); } instruct dec par { out = cla.do(0xffff,src,0b0,bi).out; cc(0b1110, cla.n||cla.z||cla.v||0b0); } instruct clr par { out = 0x0000; cc(0b1111, 0b0100); } instruct com par { out = ^src; btt.do(out,bi); cc(0b1111, btt.n||btt.z||0b01); } instruct neg par { cla.do(0x0000,^src,0b1,bi); out = cla.out; cc(0b1111, cla.n||cla.z||cla.v||^cla.z); } instruct adc par { out = cla.do(0x0000,src,ci,bi).out; cc(0b1111, cla.n||cla.z||cla.v||cla.c); } instruct sbc par { out = cla.do(0xffff,src,^ci,bi).out; cc(0b1111, cla.n||cla.z||cla.v||^cla.c); } instruct tst par { btt.do(src,bi); cc(0b1111, btt.n||btt.z||0b00); } instruct mmu par { btt.do(src,bi); cc(0b1110, btt.n||btt.z||0b00); } instruct ror par { if(^bi) par { out = ci||src<15:1>; btt.do(out,0b0); } if(bi) par { out = 0x00||ci||src<7:1>; btt.do(out,0b1); } cc(0b1111, btt.n||btt.z||(ci@src<0>)||src<0>); } instruct rol par { if(^bi) par { out = src<14:0>||ci; btt.do(out,0b0); cc(0b1111, btt.n||btt.z||(ci@src<15>)||src<15>); } if(bi) par { out = 0x00||src<6:0>||ci; btt.do(out,0b1); cc(0b1111, btt.n||btt.z||(ci@src<7>)||src<7>); } } instruct asr par { if(^bi) par { out = src<15>||src<15:1>; btt.do(out,0b0); cc(0b1111, btt.n||btt.z||(src<15>@src<0>)||src<0>); } if(bi) par { out = 0x00||src<7>||src<7:1>; btt.do(out,0b1); cc(0b1111, btt.n||btt.z||(src<7>@src<0>)||src<0>); } } instruct asl par { if(^bi) par { out = src<14:0>||0b0; btt.do(out,0b0); cc(0b1111, btt.n||btt.z||(src<15>@src<14>)||src<15>); } if(bi) par { out = 0x00||src<6:0>||0b0; btt.do(out,0b1); cc(0b1111, btt.n||btt.z||(src<7>@src<6>)||src<7>); } } instruct sxt par { out = 16#ni; cc(0b0100, 0b0||^ni||0b00); } instruct mov par { if(^bi) out = src; if( bi) out = 16#src<7:0>; btt.do(src,bi); cc(0b1110, btt.n||btt.z||0b00); } instruct cmp par { cla.do(^dst,src,0b1,bi); cc(0b1111, cla.n||cla.z||cla.v||^cla.c); } instruct bit par { btt.do(dst & src,bi); cc(0b1110, btt.n||btt.z||0b00); } instruct bic par { out = dst &^src; btt.do(out,bi); cc(0b1110, btt.n||btt.z||0b00); } instruct bis par { out = dst | src; btt.do(out,bi); cc(0b1110, btt.n||btt.z||0b00); } instruct add par { out = cla.do(dst,src,0b0,0b0).out; cc(0b1111, cla.n||cla.z||cla.v||cla.c); } instruct sub par { out = cla.do(^dst,src,0b1,0b0).out; cc(0b1111, cla.n||cla.z||cla.v||^cla.c); } instruct exor par { out = dst @ src; btt.do(out,0b0); cc(0b1100, btt.n||btt.z||0b00); } instruct swab par { out = src<7:0> || src<15:8>; btt.do(out,0b1); cc(0b1111, btt.n||btt.z||0b00); } }/* alu11 */