/************************************************ * SRIP用32ビットALUモジュール * * 以下のファイルを参考に作成 * * $PARTHENON/sfl_lib.src/sfl/alu32.sfl * * $PARTHENON/sfl_lib.src/sfl/alu16.sfl * * $PARTHENON/sfl_lib.src/sfl/alu8.sfl * * $PARTHENON/sfl_lib.src/sfl/alu_32.sfl * * $PARTHENON/sfl_lib.src/sfl/alu_16.sfl * * $PARTHENON/sfl_lib.src/sfl/alu_8.sfl * * $PARTHENON/sfl_lib.src/sfl/alu_4.sfl * * $PARTHENON/sfl_lib.src/int_h/alu_32.h * * $PARTHENON/sfl_lib.src/int_h/alu_16.h * * $PARTHENON/sfl_lib.src/int_h/alu_8.h * * $PARTHENON/sfl_lib.src/int_h/alu_4.h * ************************************************/ module alu32 { submod_type alu_32 { input enb_cry ; input inv_in2 ; input and ; input or ; input eor ; input cin ; input in1<32> ; input in2<32> ; output out<32> ; output gout ; output pout ; output ovf ; output eq ; instrin do ; } input a<32> ; input b<32> ; output out<32> ; output ov ; output z ; instrin add ; instrin sub ; instrin and ; instrin or ; instrin xor ; alu_32 alu32 ; instr_arg alu32.do(enb_cry,inv_in2,and,or,eor,cin,in1,in2) ; instruct add par { out = alu32.do(0b1,0b0,0b0,0b0,0b1,0b0,a,b).out ; ov = alu32.ovf ; } instruct sub par { out = alu32.do(0b1,0b1,0b0,0b0,0b1,0b1,a,b).out ; ov = alu32.ovf ; z = alu32.eq ; } instruct and out = alu32.do(0b0,0b0,0b1,0b0,0b0,0b0,a,b).out ; instruct or out = alu32.do(0b0,0b0,0b0,0b1,0b0,0b0,a,b).out ; instruct xor out = alu32.do(0b0,0b0,0b0,0b0,0b1,0b0,a,b).out ; } module alu_32 { submod_type alu_16 { input enb_cry ; input inv_in2 ; input and ; input or ; input eor ; input cin ; input in1<16> ; input in2<16> ; output out<16> ; output gout ; output pout ; output ovf ; output eq ; instrin do ; } input enb_cry ; input inv_in2 ; input and ; input or ; input eor ; input cin ; input in1<32> ; input in2<32> ; output out<32> ; output gout ; output pout ; output ovf ; output eq ; tmp cry<2> ; instrin do ; alu_16 alu16h ; alu_16 alu16l ; instr_arg alu16h.do(enb_cry,inv_in2,and,or,eor,cin,in1,in2) ; instr_arg alu16l.do(enb_cry,inv_in2,and,or,eor,cin,in1,in2) ; instruct do par { cry = ((cin&alu16l.pout) | alu16l.gout) || cin ; out = alu16h.do(enb_cry,inv_in2,and,or,eor,cry<1>,in1<31:16>,in2<31:16>).out || alu16l.do(enb_cry,inv_in2,and,or,eor,cry<0>,in1<15: 0>,in2<15: 0>).out ; gout = (alu16l.gout&alu16h.pout) | alu16h.gout ; pout = alu16l.pout&alu16h.pout ; ovf = alu16h.ovf ; eq = alu16h.eq&alu16l.eq ; } } module alu_16 { submod_type alu_4 { input enb_cry ; input inv_in2 ; input and ; input or ; input eor ; input cin ; input in1<4> ; input in2<4> ; output out<4> ; output gout ; output pout ; output ovf ; output eq ; instrin do ; } input enb_cry ; input inv_in2 ; input and ; input or ; input eor ; input cin ; input in1<16> ; input in2<16> ; output out<16> ; output gout ; output pout ; output ovf ; output eq ; tmp cry<4> ; alu_4 alu43 ; alu_4 alu42 ; alu_4 alu41 ; alu_4 alu40 ; instrin do ; instr_arg alu43.do(enb_cry,inv_in2,and,or,eor,cin,in1,in2) ; instr_arg alu42.do(enb_cry,inv_in2,and,or,eor,cin,in1,in2) ; instr_arg alu41.do(enb_cry,inv_in2,and,or,eor,cin,in1,in2) ; instr_arg alu40.do(enb_cry,inv_in2,and,or,eor,cin,in1,in2) ; instruct do par { cry = ((cin&alu40.pout&alu41.pout&alu42.pout) | (alu40.gout&alu41.pout&alu42.pout) | (alu41.gout&alu42.pout) | alu42.gout) || ((cin&alu40.pout&alu41.pout) | (alu40.gout&alu41.pout) | alu41.gout) || ((cin&alu40.pout) | alu40.gout) || cin ; out = alu43.do(enb_cry,inv_in2,and,or,eor,cry<3>,in1<15:12>,in2<15:12>).out || alu42.do(enb_cry,inv_in2,and,or,eor,cry<2>,in1<11: 8>,in2<11: 8>).out || alu41.do(enb_cry,inv_in2,and,or,eor,cry<1>,in1< 7: 4>,in2< 7: 4>).out || alu40.do(enb_cry,inv_in2,and,or,eor,cry<0>,in1< 3: 0>,in2< 3: 0>).out ; gout = (alu40.gout&alu41.pout&alu42.pout&alu43.pout) | (alu41.gout&alu42.pout&alu43.pout) | (alu42.gout&alu43.pout) | alu43.gout ; pout = alu40.pout&alu41.pout&alu42.pout&alu43.pout ; ovf = alu43.ovf ; eq = alu40.eq&alu41.eq&alu42.eq&alu43.eq ; } } module alu_4 { input enb_cry ; /* 1 1 0 0 0 */ input inv_in2 ; /* 0 1 0 0 0 */ input and ; /* 0 0 1 0 0 */ input or ; /* 0 0 0 1 0 */ input eor ; /* 1 1 0 0 1 */ input cin ; /* 0 1 0 0 0 */ input in1<4> ; /************************/ input in2<4> ; /* a s a o e */ output out<4> ; /* d u n r o */ output gout ; /* d b d r */ output pout ; output ovf ; output eq ; tmp tmp_in2<4> ; tmp g<4> ; tmp p<4> ; tmp data<4> ; tmp cry<4> ; tmp cout ; instrin do ; instruct do par { any { inv_in2 : tmp_in2 = ^in2<3> || ^in2<2> || ^in2<1> || ^in2<0> ; else : tmp_in2 = in2 ; } g = (in1<3> & tmp_in2<3>) || (in1<2> & tmp_in2<2>) || (in1<1> & tmp_in2<1>) || (in1<0> & tmp_in2<0>) ; p = (in1<3> | tmp_in2<3>) || (in1<2> | tmp_in2<2>) || (in1<1> | tmp_in2<1>) || (in1<0> | tmp_in2<0>) ; data = ((p<3> & or) | (g<3> & and) | (p<3> & ^g<3> & eor)) || ((p<2> & or) | (g<2> & and) | (p<2> & ^g<2> & eor)) || ((p<1> & or) | (g<1> & and) | (p<1> & ^g<1> & eor)) || ((p<0> & or) | (g<0> & and) | (p<0> & ^g<0> & eor)) ; cry = (((cin&p<0>&p<1>&p<2>) | (g<0>&p<1>&p<2>) | (g<1>&p<2>) | g<2>) & enb_cry) || (((cin&p<0>&p<1>) | (g<0>&p<1>) | g<1>) & enb_cry) || (((cin&p<0>) | g<0>) & enb_cry) || (cin & enb_cry) ; cout = (cin&p<0>&p<1>&p<2>&p<3>) | (g<0>&p<1>&p<2>&p<3>) | (g<1>&p<2>&p<3>) | (g<2>&p<3>) | g<3> ; out = data @ cry ; gout = (g<0>&p<1>&p<2>&p<3>) | (g<1>&p<2>&p<3>) | (g<2>&p<3>) | g<3> ; pout = p<0>&p<1>&p<2>&p<3> ; ovf = cout @ cry<3> ; eq = ^(out<3> | out<2> | out<1> | out<0>) ; } }